diff --git a/apps/web/src/components/BranchToolbar.tsx b/apps/web/src/components/BranchToolbar.tsx index 8be263d190..0eec09ed5d 100644 --- a/apps/web/src/components/BranchToolbar.tsx +++ b/apps/web/src/components/BranchToolbar.tsx @@ -343,7 +343,7 @@ export const BranchToolbar = memo(function BranchToolbar({ } return ( -
+
{isMobile ? ( { }); }); -describe("buildThreadTurnInterruptInput", () => { - it("targets the session's active running turn", () => { - const activeTurnId = TurnId.make("turn-running"); - +describe("shouldShowComposerContextStrip", () => { + it("shows git context on a draft with an active project", () => { expect( - buildThreadTurnInterruptInput( - makeThread({ - session: { - ...readySession, - status: "running", - activeTurnId, - }, - }), - ), - ).toEqual({ threadId, turnId: activeTurnId }); + shouldShowComposerContextStrip({ + routeKind: "draft", + isGitRepo: true, + hasActiveProject: true, + }), + ).toBe(true); }); - it("omits a turn id when the session is not running", () => { - expect(buildThreadTurnInterruptInput(makeThread({ session: readySession }))).toEqual({ - threadId, - }); + it("hides git context after the draft becomes a thread", () => { + expect( + shouldShowComposerContextStrip({ + routeKind: "server", + isGitRepo: true, + hasActiveProject: true, + }), + ).toBe(false); + }); + + it("hides git context without a git-backed project", () => { + expect( + shouldShowComposerContextStrip({ + routeKind: "draft", + isGitRepo: false, + hasActiveProject: true, + }), + ).toBe(false); + expect( + shouldShowComposerContextStrip({ + routeKind: "draft", + isGitRepo: true, + hasActiveProject: false, + }), + ).toBe(false); }); }); - describe("deriveComposerSendState", () => { it("treats expired terminal pills as non-sendable content", () => { const state = deriveComposerSendState({ diff --git a/apps/web/src/components/ChatView.logic.ts b/apps/web/src/components/ChatView.logic.ts index 50fe26cdf3..086e1f44d4 100644 --- a/apps/web/src/components/ChatView.logic.ts +++ b/apps/web/src/components/ChatView.logic.ts @@ -255,6 +255,14 @@ export function resolveSendEnvMode(input: { return input.isGitRepo ? input.requestedEnvMode : "local"; } +export function shouldShowComposerContextStrip(input: { + routeKind: "draft" | "server"; + isGitRepo: boolean; + hasActiveProject: boolean; +}): boolean { + return input.routeKind === "draft" && input.isGitRepo && input.hasActiveProject; +} + export function cloneComposerImageForRetry( image: ComposerImageAttachment, ): ComposerImageAttachment { diff --git a/apps/web/src/components/ChatView.tsx b/apps/web/src/components/ChatView.tsx index 94bfdcccd1..5f709326f4 100644 --- a/apps/web/src/components/ChatView.tsx +++ b/apps/web/src/components/ChatView.tsx @@ -274,8 +274,7 @@ import { resolveSendEnvMode, revokeBlobPreviewUrl, revokeUserMessagePreviewUrls, - shouldWriteThreadErrorToCurrentServerThread, - startNewThreadForProject, + shouldShowComposerContextStrip, waitForStartedServerThread, } from "./ChatView.logic"; import type { ThreadSyncPhase } from "../threadSync"; @@ -2384,7 +2383,11 @@ function ChatViewContent(props: ChatViewProps) { terminalUiLaunchContext?.threadId === activeThreadId ? terminalUiLaunchContext : null; // Default true while loading to avoid toolbar flicker. const isGitRepo = gitStatusQuery.data?.isRepo ?? true; - const showComposerContextStrip = isGitRepo && activeProject !== null; + const showComposerContextStrip = shouldShowComposerContextStrip({ + routeKind, + isGitRepo, + hasActiveProject: activeProject !== null, + }); const initialDiffPanelGitScope = gitStatusQuery.data?.hasWorkingTreeChanges === true ? "unstaged" : "branch"; const diffPanelGitStatusResolutionKey = gitStatusQuery.data ? "resolved" : "pending"; @@ -5961,79 +5964,144 @@ function ChatViewContent(props: ChatViewProps) { threadId={activeThread.id} /> ) : null} -
- +
+
+
+ +
+
+
+
+ {showComposerContextStrip && ( +
+ +
+ )} +
+
+
+
diff --git a/apps/web/src/components/chat/ChatComposer.tsx b/apps/web/src/components/chat/ChatComposer.tsx index ff084080fc..35c304beff 100644 --- a/apps/web/src/components/chat/ChatComposer.tsx +++ b/apps/web/src/components/chat/ChatComposer.tsx @@ -2679,7 +2679,7 @@ export const ChatComposer = memo(function ChatComposer(props: ChatComposerProps)