Skip to content

Commit 5f16f48

Browse files
t3dotggclaude
andcommitted
fix(web): star toast rechecks the dismissal after the star check
Co-Authored-By: Claude Opus 5.5 <[email protected]>
1 parent f46903c commit 5f16f48

2 files changed

Lines changed: 23 additions & 4 deletions

File tree

‎apps/web/src/components/GitHubStarPrompt.test.ts‎

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,20 +5,24 @@ import type { toastManager } from "./ui/toast";
55

66
const { add, starred } = vi.hoisted(() => ({
77
add: vi.fn<typeof toastManager.add>(),
8-
starred: { value: false },
8+
starred: { value: false, duringCheck: () => {} },
99
}));
1010
vi.mock("./ui/toast", () => ({ toastManager: { add, close: vi.fn() } }));
1111
vi.mock("../rpc/atomRegistry", () => ({ appAtomRegistry: {} }));
1212
vi.mock("../state/sourceControl", () => ({ sourceControlEnvironment: { checkStarred: {} } }));
1313
vi.mock("@t3tools/client-runtime/state/runtime", () => ({
14-
runAtomCommand: async () => ({ _tag: "Success", value: starred.value }),
14+
runAtomCommand: async () => {
15+
starred.duringCheck();
16+
return { _tag: "Success", value: starred.value };
17+
},
1518
}));
1619

1720
const environmentId = EnvironmentId.make("environment-1");
1821

1922
function setup({ sent = 0, writable = true, alreadyStarred = false } = {}) {
2023
add.mockReset();
2124
starred.value = alreadyStarred;
25+
starred.duringCheck = () => {};
2226
const store = new Map([["t3code:github-star-prompt:sent", String(sent)]]);
2327
vi.stubGlobal("window", {
2428
localStorage: {
@@ -29,6 +33,7 @@ function setup({ sent = 0, writable = true, alreadyStarred = false } = {}) {
2933
},
3034
},
3135
});
36+
return store;
3237
}
3338

3439
// A fresh module import stands in for an app reload; storage survives it.
@@ -75,4 +80,12 @@ describe("recordPromptSent", () => {
7580
expect(add).not.toHaveBeenCalled();
7681
vi.unstubAllGlobals();
7782
});
83+
84+
it("never asks when another tab dismisses it during the star check", async () => {
85+
const store = setup({ sent: 5 });
86+
starred.duringCheck = () => store.set("t3code:github-star-prompt:dismissed", "true");
87+
await (await startSession()).send();
88+
expect(add).not.toHaveBeenCalled();
89+
vi.unstubAllGlobals();
90+
});
7891
});

‎apps/web/src/components/GitHubStarPrompt.tsx‎

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,12 @@ export async function recordPromptSent(environmentId: EnvironmentId): Promise<vo
8383
return;
8484
}
8585
shownThisSession = true;
86-
if (await alreadyStarred(environmentId)) dismiss();
87-
else showStarPrompt();
86+
if (await alreadyStarred(environmentId)) return dismiss();
87+
try {
88+
// Another tab can dismiss while the check runs.
89+
if (getLocalStorageItem(DISMISSED_KEY, Schema.Boolean)) return;
90+
} catch {
91+
return;
92+
}
93+
showStarPrompt();
8894
}

0 commit comments

Comments
 (0)