diff --git a/apps/server/src/vcs/VcsStatusBroadcaster.test.ts b/apps/server/src/vcs/VcsStatusBroadcaster.test.ts index ac3df2ad30..171747c31f 100644 --- a/apps/server/src/vcs/VcsStatusBroadcaster.test.ts +++ b/apps/server/src/vcs/VcsStatusBroadcaster.test.ts @@ -790,6 +790,7 @@ describe("VcsStatusBroadcaster", () => { const secondRefresh = yield* Effect.forkChild( broadcaster.refreshChangeRequestStatus("/repo"), ); + yield* Effect.yieldNow; yield* TestClock.adjust(Duration.millis(10)); yield* Deferred.succeed(release, undefined); yield* Fiber.join(firstRefresh); diff --git a/apps/web/src/components/Sidebar.tsx b/apps/web/src/components/Sidebar.tsx index 0321128834..d6fab385ce 100644 --- a/apps/web/src/components/Sidebar.tsx +++ b/apps/web/src/components/Sidebar.tsx @@ -15,13 +15,13 @@ import { } from "lucide-react"; import { ChangeRequestStatusIcon, - changeRequestLookupWarning, prStatusIndicator, resolveThreadPr, terminalStatusFromRunningIds, ThreadStatusLabel, ThreadWorktreeIndicator, } from "./ThreadStatusIndicators"; +import { changeRequestLookupWarning } from "./ThreadStatusIndicators.logic"; import { ProjectFavicon } from "./ProjectFavicon"; import { useAtomValue } from "@effect/atom-react"; import { autoAnimate } from "@formkit/auto-animate"; diff --git a/apps/web/src/components/ThreadStatusIndicators.logic.ts b/apps/web/src/components/ThreadStatusIndicators.logic.ts new file mode 100644 index 0000000000..4c42803691 --- /dev/null +++ b/apps/web/src/components/ThreadStatusIndicators.logic.ts @@ -0,0 +1,26 @@ +import type { VcsStatusResult } from "@t3tools/contracts"; + +import { resolveChangeRequestPresentation } from "../sourceControlPresentation"; + +export function changeRequestLookupWarning( + threadBranch: string | null, + gitStatus: VcsStatusResult | null, +): string | null { + if ( + threadBranch === null || + gitStatus === null || + gitStatus.refName !== threadBranch || + gitStatus.changeRequestLookup._tag !== "failed" + ) { + return null; + } + const presentation = resolveChangeRequestPresentation(gitStatus.sourceControlProvider); + switch (gitStatus.changeRequestLookup.reason) { + case "authentication_required": + return `${presentation.shortName} status unavailable: authentication required.`; + case "provider_unavailable": + return `${presentation.shortName} status unavailable: provider integration unavailable.`; + case "lookup_failed": + return `${presentation.shortName} status unavailable: lookup failed.`; + } +} diff --git a/apps/web/src/components/ThreadStatusIndicators.test.tsx b/apps/web/src/components/ThreadStatusIndicators.test.tsx index ece0e6f1fa..cf79de52d2 100644 --- a/apps/web/src/components/ThreadStatusIndicators.test.tsx +++ b/apps/web/src/components/ThreadStatusIndicators.test.tsx @@ -2,7 +2,8 @@ import { ThreadId, type VcsStatusResult } from "@t3tools/contracts"; import { renderToStaticMarkup } from "react-dom/server"; import { describe, expect, it } from "vite-plus/test"; -import { changeRequestLookupWarning, ThreadWorktreeIndicator } from "./ThreadStatusIndicators"; +import { changeRequestLookupWarning } from "./ThreadStatusIndicators.logic"; +import { ThreadWorktreeIndicator } from "./ThreadStatusIndicators"; const failedStatus: VcsStatusResult = { isRepo: true, @@ -34,6 +35,22 @@ describe("changeRequestLookupWarning", () => { it("does not leak warnings across branches", () => { expect(changeRequestLookupWarning("feature/other", failedStatus)).toBeNull(); }); + + it("keeps the refresh warning when a cached open PR remains actionable", () => { + expect( + changeRequestLookupWarning("feature/sidebar-indicator", { + ...failedStatus, + pr: { + number: 42, + title: "Cached open PR", + url: "https://example.com/pr/42", + baseRef: "main", + headRef: "feature/sidebar-indicator", + state: "open", + }, + }), + ).toBe("PR status unavailable: authentication required."); + }); }); describe("ThreadWorktreeIndicator", () => { diff --git a/apps/web/src/components/ThreadStatusIndicators.tsx b/apps/web/src/components/ThreadStatusIndicators.tsx index 965221308d..69b78409af 100644 --- a/apps/web/src/components/ThreadStatusIndicators.tsx +++ b/apps/web/src/components/ThreadStatusIndicators.tsx @@ -20,6 +20,7 @@ import { vcsEnvironment } from "../state/vcs"; import { useUiStateStore } from "../uiStateStore"; import { resolveChangeRequestPresentation } from "../sourceControlPresentation"; import { resolveThreadStatusPill, type ThreadStatusPill } from "./Sidebar.logic"; +import { changeRequestLookupWarning } from "./ThreadStatusIndicators.logic"; import type { SidebarThreadSummary } from "../types"; import { formatWorktreePathForDisplay } from "../worktreeCleanup"; import { Tooltip, TooltipPopup, TooltipTrigger } from "./ui/tooltip"; @@ -39,29 +40,6 @@ export interface TerminalStatusIndicator { export type ThreadPr = VcsStatusResult["pr"]; -export function changeRequestLookupWarning( - threadBranch: string | null, - gitStatus: VcsStatusResult | null, -): string | null { - if ( - threadBranch === null || - gitStatus === null || - gitStatus.refName !== threadBranch || - gitStatus.changeRequestLookup._tag !== "failed" - ) { - return null; - } - const presentation = resolveChangeRequestPresentation(gitStatus.sourceControlProvider); - switch (gitStatus.changeRequestLookup.reason) { - case "authentication_required": - return `${presentation.shortName} status unavailable: authentication required.`; - case "provider_unavailable": - return `${presentation.shortName} status unavailable: provider integration unavailable.`; - case "lookup_failed": - return `${presentation.shortName} status unavailable: lookup failed.`; - } -} - export function prStatusIndicator( pr: ThreadPr, provider: VcsStatusResult["sourceControlProvider"] | null | undefined,