diff --git a/apps/web/src/components/GitHubStarPrompt.test.ts b/apps/web/src/components/GitHubStarPrompt.test.ts index f748ec8b82209..b763568a1c457 100644 --- a/apps/web/src/components/GitHubStarPrompt.test.ts +++ b/apps/web/src/components/GitHubStarPrompt.test.ts @@ -29,8 +29,10 @@ vi.mock("@t3tools/client-runtime/state/runtime", () => ({ const environmentId = EnvironmentId.make("environment-1"); const IDLE_MS = 30_000; +let forkEnabled = true; -function setup({ sent = 0, writable = true, alreadyStarred = false } = {}) { +function setup({ sent = 0, writable = true, alreadyStarred = false, enabled = true } = {}) { + forkEnabled = enabled; add.mockReset(); update.mockReset(); openExternal.mockClear(); @@ -66,6 +68,7 @@ function setup({ sent = 0, writable = true, alreadyStarred = false } = {}) { async function startSession() { vi.resetModules(); const session = await import("./GitHubStarPrompt"); + session.setForkStarPromptEnabledForTest(forkEnabled); return { // Sends a prompt, then leaves the page idle long enough to ask. send: async () => { @@ -83,6 +86,13 @@ const click = (props: unknown) => (props as { onClick: () => unknown }).onClick( describe("recordPromptSent", () => { vi.useFakeTimers(); + it("never asks when disabled on the fork by default", async () => { + setup({ sent: 5, enabled: false }); + await (await startSession()).send(); + expect(add).not.toHaveBeenCalled(); + vi.unstubAllGlobals(); + }); + it("asks only after the focused page is idle", async () => { setup({ sent: 5 }); (await startSession()).sendWithoutWaiting(); diff --git a/apps/web/src/components/GitHubStarPrompt.tsx b/apps/web/src/components/GitHubStarPrompt.tsx index 679d61b1f3502..aaacf83e01dc6 100644 --- a/apps/web/src/components/GitHubStarPrompt.tsx +++ b/apps/web/src/components/GitHubStarPrompt.tsx @@ -138,11 +138,22 @@ async function starRepository(environmentId: EnvironmentId) { return result._tag === "Success" && result.value; } +/** + * Fork policy: the upstream GitHub star prompt is disabled on the EK fork. + * Kept configurable for testing. + */ +export let forkStarPromptEnabled = false; + +export function setForkStarPromptEnabledForTest(enabled: boolean): void { + forkStarPromptEnabled = enabled; +} + /** * Counts a sent prompt. After more than five, asks once per session for a star until dismissed, * unless the environment's GitHub account already starred the repo. Waits until the user is idle. */ export async function recordPromptSent(environmentId: EnvironmentId): Promise { + if (!forkStarPromptEnabled) return; if (shownThisSession) return; try { if (getLocalStorageItem(DISMISSED_KEY, Schema.Boolean)) return; diff --git a/scripts/fork-footprint-budget.json b/scripts/fork-footprint-budget.json index 461b6e230474f..f476b9ed57a11 100644 --- a/scripts/fork-footprint-budget.json +++ b/scripts/fork-footprint-budget.json @@ -46,7 +46,7 @@ "apps/mobile/src/features/threads/NewTaskDraftRouteScreen.tsx": 3, "apps/mobile/src/features/threads/ThreadComposer.tsx": 11, "apps/mobile/src/features/threads/ThreadDetailScreen.tsx": 30, - "apps/mobile/src/features/threads/ThreadFeed.tsx": 244, + "apps/mobile/src/features/threads/ThreadFeed.tsx": 243, "apps/mobile/src/features/threads/ThreadHeader.tsx": 4, "apps/mobile/src/features/threads/ThreadNavigationSidebar.tsx": 44, "apps/mobile/src/features/threads/ThreadRouteScreen.tsx": 23,