Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 11 additions & 1 deletion apps/web/src/components/GitHubStarPrompt.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down Expand Up @@ -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 () => {
Expand All @@ -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();
Comment on lines +89 to +91

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Default is not tested

The new “disabled on the fork by default” test explicitly sets enabled: false, and startSession() writes that value before calling recordPromptSent(). It therefore passes even if the production default changes back to true.

Leave the setter unused in this case so the test protects the fork's actual default. Keep the override for the existing enabled-path tests.

Note: If this suggestion doesn't match your team's coding style, reply to this and let me know. I'll remember it for next time!

expect(add).not.toHaveBeenCalled();
vi.unstubAllGlobals();
});

it("asks only after the focused page is idle", async () => {
setup({ sent: 5 });
(await startSession()).sendWithoutWaiting();
Expand Down
11 changes: 11 additions & 0 deletions apps/web/src/components/GitHubStarPrompt.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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<void> {
if (!forkStarPromptEnabled) return;
if (shownThisSession) return;
try {
if (getLocalStorageItem(DISMISSED_KEY, Schema.Boolean)) return;
Expand Down
2 changes: 1 addition & 1 deletion scripts/fork-footprint-budget.json
Original file line number Diff line number Diff line change
Expand Up @@ -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,

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Footprint check fails

The budget omits both changed GitHubStarPrompt files. Against the upstream commit merged into the PR base, GitHubStarPrompt.tsx has 11 changed lines and GitHubStarPrompt.test.ts has 12. The checker gives missing entries a limit of zero and exits with an error.

Changing this budget file triggers the Fork machine groups workflow, so its footprint check fails. Add reviewed entries for both files.

"apps/mobile/src/features/threads/ThreadHeader.tsx": 4,
"apps/mobile/src/features/threads/ThreadNavigationSidebar.tsx": 44,
"apps/mobile/src/features/threads/ThreadRouteScreen.tsx": 23,
Expand Down
Loading