GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — fix(gui): refresh every row on the shared Kimi login after logout or … · lidge-jun/opencodex@c3a1ec9

File tree

Expand file treeCollapse file tree
Open diff view settings
Filter options
  • gui
    • src/pages
      • Providers.tsx
      • use-providers-oauth.ts
    • tests
      • provider-revalidation-policy.test.tsx
      • provider-shared-account-controls.test.tsx
  • structure/providers
    • oauth-credential-siblings.md
Expand file treeCollapse file tree
Open diff view settings
Collapse file

‎gui/src/pages/Providers.tsx‎

Copy file name to clipboardExpand all lines: gui/src/pages/Providers.tsx
+8-1Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ import { canCreateJevAutoFrom } from "../jev-decision-service";
3232
import { useProviderSettingsDeepLink } from "./providers-deep-link";
3333
import { subscribeKiroDeviceFinal } from "../kiro-device-login-finalizer";
3434
import type { BrowserLaunch } from "../oauth-browser-launch";
35-
import { oauthCredentialSlot } from "../../../src/oauth/credential-siblings";
35+
import { oauthCredentialSiblingsOf, oauthCredentialSlot } from "../../../src/oauth/credential-siblings";
3636

3737
/** The page's real refresh tickets: only the captured report epoch and account read can settle them. */
3838
// oxlint-disable-next-line react/only-export-components -- keep the page-owned coordinator and its direct race tests in the authorized owner.
@@ -163,6 +163,13 @@ function useAccountSelectionEvents(
163163
if (value.revision <= (revisions.get(key) ?? -1)) return;
164164
revisions.set(key, value.revision);
165165
pending.set(key, { provider: value.provider, kind: value.kind });
166+
// One login can serve several rows (kimi, kimi-responses); the event names the slot.
167+
if (value.kind === "oauth") {
168+
const slot = oauthCredentialSlot(value.provider);
169+
for (const row of [slot, ...oauthCredentialSiblingsOf(slot)]) {
170+
if (row !== value.provider) pending.set(`${value.kind}:${row}`, { provider: row, kind: value.kind });
171+
}
172+
}
166173
flush();
167174
}
168175
};
Collapse file

‎gui/src/pages/use-providers-oauth.ts‎

Copy file name to clipboardExpand all lines: gui/src/pages/use-providers-oauth.ts
+10-7Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ import { isApiTargetCaptureCurrent, targetFetch, type ApiTargetCapture } from ".
1212
import { errorMessageFrom } from "../api-error";
1313
import { useRenderTargetCapture } from "../use-render-target-capture";
1414
import { confirmAction } from "../action-dialogs";
15-
import { oauthCredentialSlot } from "../../../src/oauth/credential-siblings";
15+
import { oauthCredentialSiblingsOf, oauthCredentialSlot } from "../../../src/oauth/credential-siblings";
1616

1717
type AccountSet = { activeAccountId: string | null; accounts: OAuthAccount[] };
1818

@@ -333,6 +333,9 @@ export function useProvidersOAuth({
333333
const logoutTarget = targetKey ?? apiBase;
334334
// A shared-login row (Kimi (Responses)) signs out the owner's Chat row too: say so first.
335335
const sharedOwner = oauthCredentialSlot(provider) !== provider ? oauthCredentialSlot(provider) : undefined;
336+
// Every other row on this login (kimi <-> kimi-responses): logout removes their active account too.
337+
const sharedRows = [oauthCredentialSlot(provider), ...oauthCredentialSiblingsOf(oauthCredentialSlot(provider))]
338+
.filter(row => row !== provider);
336339
if (sharedOwner) {
337340
const consented = await confirmAction({
338341
message: t("prov.logoutConfirmShared", { provider: oauthLabel(sharedOwner) }),
@@ -358,10 +361,10 @@ export function useProvidersOAuth({
358361
bumpLoginGeneration(provider);
359362
setBusy(current => current === provider ? null : current);
360363
setLoginInfo(current => current?.provider === provider ? null : current);
361-
// The shared login's flows and status reads are keyed by the owner (kimi): fence those too,
362-
// so a late owner status read or login poll cannot report the removed account as signed in.
364+
// Fence the other rows on this login too, and the owner's login flows (keyed by kimi), so a
365+
// late status read or login poll cannot report the removed account as signed in.
366+
for (const row of sharedRows) invalidateOauthStatusReads?.(row);
363367
if (sharedOwner) {
364-
invalidateOauthStatusReads?.(sharedOwner);
365368
bumpLoginGeneration(sharedOwner);
366369
setBusy(current => current === sharedOwner ? null : current);
367370
setLoginInfo(current => current?.provider === sharedOwner ? null : current);
@@ -384,16 +387,16 @@ export function useProvidersOAuth({
384387
// A read started while the server was processing logout can still describe
385388
// the old account. Only a read started after settlement can verify status.
386389
if (invalidateOauthStatusReads?.(provider, false) === false) return;
387-
if (sharedOwner) invalidateOauthStatusReads?.(sharedOwner);
390+
for (const row of sharedRows) invalidateOauthStatusReads?.(row);
388391
clearStatus();
389392
if (!success) {
390-
void fetchAccountSets([provider]).catch(() => {});
393+
void fetchAccountSets([provider, ...sharedRows]).catch(() => {});
391394
void fetchOauth();
392395
return;
393396
}
394397
try {
395398
await Promise.all([
396-
fetchAccountSets(sharedOwner ? [provider, sharedOwner] : [provider]), fetchOauth(), fetchConfig(), fetchProviderQuotas(true),
399+
fetchAccountSets([provider, ...sharedRows]), fetchOauth(), fetchConfig(), fetchProviderQuotas(true),
397400
]);
398401
bumpModelsRefresh();
399402
if (targetKeyRef.current === logoutTarget && isApiTargetCaptureCurrent(capture))
Collapse file

‎gui/tests/provider-revalidation-policy.test.tsx‎

Copy file name to clipboardExpand all lines: gui/tests/provider-revalidation-policy.test.tsx
+31Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -227,6 +227,37 @@ for (const kind of ["oauth", "key", "codex"] as const) {
227227
});
228228
}
229229

230+
test("a Kimi account selection event also re-reads the Kimi (Responses) accounts that share the login (#8087)", async () => {
231+
let stream!: ReadableStreamDefaultController<Uint8Array>;
232+
const reads: string[] = [];
233+
const encoder = new TextEncoder();
234+
const send = (event: string, data: unknown) => { stream.enqueue(encoder.encode(`event: ${event}\r\ndata: ${JSON.stringify(data)}\r\n\r\n`)); };
235+
const kimiRow = { adapter: "openai-chat", authMode: "oauth", hasApiKey: false, baseUrl: "https://api.kimi.com/coding/v1" };
236+
Object.defineProperty(globalThis, "fetch", { configurable: true, value: async (input: RequestInfo | URL) => {
237+
const url = new URL(String(input), "http://localhost");
238+
reads.push(url.pathname + url.search);
239+
if (url.pathname === "/api/accounts/events") {
240+
return new Response(new ReadableStream<Uint8Array>({ start(controller) { stream = controller; } }), { headers: { "Content-Type": "text/event-stream" } });
241+
}
242+
if (url.pathname === "/api/config") return Response.json({ port: 10100, defaultProvider: "kimi", providers: {
243+
kimi: kimiRow, "kimi-responses": { ...kimiRow, adapter: "openai-responses" } } });
244+
if (url.pathname === "/api/oauth/providers") return Response.json({ providers: ["kimi"] });
245+
if (url.pathname === "/api/oauth/status") return Response.json({ loggedIn: true });
246+
if (url.pathname === "/api/oauth/accounts") return Response.json({ activeAccountId: "a", accounts: [{ id: "a", active: true, quotaMode: "probe" }] });
247+
if (url.pathname === "/api/codex-auth/accounts") return Response.json({ accounts: [] });
248+
if (url.pathname === "/api/provider-quotas") return Response.json({ reports: [] });
249+
if (url.pathname === "/api/selected-models") return Response.json({ models: {} });
250+
if (url.pathname === "/api/usage") return Response.json({ providers: [], models: [] });
251+
return Response.json({});
252+
} });
253+
await act(async () => { root = createRoot(container); root.render(<LanguageProvider><Providers apiBase="" /></LanguageProvider>); });
254+
await act(async () => { send("ready", { revision: 0 }); });
255+
const siblingReads = () => reads.filter(path => path.startsWith("/api/oauth/accounts?") && path.includes("provider=kimi-responses")).length;
256+
const before = siblingReads();
257+
await act(async () => { send("account-selection", { provider: "kimi", kind: "oauth", revision: 1 }); });
258+
expect(siblingReads()).toBeGreaterThan(before);
259+
});
260+
230261
for (const kind of ["oauth", "api-key"] as const) {
231262
test(`${kind} selection event updates the rendered active row without a poll tick or quota probe`, async () => {
232263
const name = kind === "oauth" ? "cursor" : "deepseek";
Collapse file

‎gui/tests/provider-shared-account-controls.test.tsx‎

Copy file name to clipboardExpand all lines: gui/tests/provider-shared-account-controls.test.tsx
+14Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -170,6 +170,20 @@ test("logging out from Kimi (Responses) confirms that the Kimi Chat row is signe
170170
}
171171
});
172172

173+
test("logging out from the Kimi row refreshes the Kimi (Responses) accounts too, without the sibling confirmation", async () => {
174+
await mount(<LogoutHarness />);
175+
const consent = spyOn(dialogs, "confirmAction").mockResolvedValue(true);
176+
try {
177+
await act(async () => { await logout("kimi"); });
178+
expect(consent).not.toHaveBeenCalled();
179+
expect(puts).toEqual([{ method: "POST", url: "/shared-hook/api/oauth/logout?provider=kimi", body: undefined }]);
180+
expect(refetchedSets).toEqual(expect.arrayContaining(["kimi", "kimi-responses"]));
181+
expect(invalidated).toContain("kimi-responses");
182+
} finally {
183+
consent.mockRestore();
184+
}
185+
});
186+
173187
test("a sibling logout also fences the owner's status reads and login hint", async () => {
174188
await mount(<LogoutHarness />);
175189
const consent = spyOn(dialogs, "confirmAction").mockResolvedValue(true);
Collapse file

‎structure/providers/oauth-credential-siblings.md‎

Copy file name to clipboardExpand all lines: structure/providers/oauth-credential-siblings.md
+2-1Lines changed: 2 additions & 1 deletion
  • Display the source diff
  • Display the rich diff
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,8 @@ with `row: "kimi-responses"`. A sibling row's status and login buttons resolve t
4747
login capture and Cancel, so a Kimi device login started from Kimi (Responses) shows its code there; a
4848
login that settles selects the row it published. Selecting, pausing or deleting an account through either
4949
row clears both rows' model caches, and a manual selection seeds both rows' rotation cursors
50-
(`seedGenericPoolSelection`).
50+
(`seedGenericPoolSelection`). In the dashboard, a logout from either row and an account-selection event for the
51+
login refresh the accounts of every row on it.
5152
Its Accounts panel lists the owner's accounts, and every control there acts on the shared account (owner
5253
decision on #8087): the panel says so, and removing an account or pausing one (which stops the owner's
5354
Chat row from using it too) asks for confirmation that names the owner's row

0 commit comments

Comments
0 (0)
You are visitor 01402792 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.