From 165ce66c97919d1ba119c331f9ee75284ea91c8a Mon Sep 17 00:00:00 2001 From: Julius Marminge Date: Fri, 24 Jul 2026 13:32:10 +0200 Subject: [PATCH] fix(web): restore v2 composer chrome Co-authored-by: codex --- .../web/src/components/ChatView.logic.test.ts | 55 +-- apps/web/src/components/ChatView.logic.ts | 8 + apps/web/src/components/ChatView.tsx | 312 ++++++++---------- apps/web/src/components/chat/ChatComposer.tsx | 2 +- apps/web/src/components/chat/ChatHeader.tsx | 3 +- apps/web/src/index.css | 245 +++++++++++++- 6 files changed, 428 insertions(+), 197 deletions(-) diff --git a/apps/web/src/components/ChatView.logic.test.ts b/apps/web/src/components/ChatView.logic.test.ts index e38c6e746f..41a1cbed5d 100644 --- a/apps/web/src/components/ChatView.logic.test.ts +++ b/apps/web/src/components/ChatView.logic.test.ts @@ -31,8 +31,7 @@ import { reconcileRetainedMountedThreadIds, resolveThreadMetadataUpdateForNextTurn, resolveSendEnvMode, - startNewThreadForProject, - shouldShowBranchMismatchBanner, + shouldShowComposerContextStrip, shouldWriteThreadErrorToCurrentServerThread, } from "./ChatView.logic"; @@ -160,30 +159,44 @@ describe("resolveThreadMetadataUpdateForNextTurn", () => { }); }); -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 ff46f922ed..c0834fff96 100644 --- a/apps/web/src/components/ChatView.logic.ts +++ b/apps/web/src/components/ChatView.logic.ts @@ -268,6 +268,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 4931c62e89..015871cdfb 100644 --- a/apps/web/src/components/ChatView.tsx +++ b/apps/web/src/components/ChatView.tsx @@ -298,8 +298,7 @@ import { resolveSendEnvMode, revokeBlobPreviewUrl, revokeUserMessagePreviewUrls, - shouldWriteThreadErrorToCurrentServerThread, - startNewThreadForProject, + shouldShowComposerContextStrip, waitForStartedServerThread, } from "./ChatView.logic"; import type { ThreadSyncPhase } from "../threadSync"; @@ -449,14 +448,11 @@ type EnvironmentUnavailableState = { readonly connection: EnvironmentConnectionPresentation; }; -<<<<<<< HEAD -======= type ThreadPlanCatalogEntry = { readonly id: ThreadId; readonly projection: OrchestrationV2ThreadProjection; }; ->>>>>>> d454b3880e (Retire V1 client orchestration parity) function eventPathContainsSelector(event: Event, selector: string): boolean { const path = event.composedPath(); if (path.length === 0 && event.target) { @@ -2334,15 +2330,6 @@ function ChatViewContent(props: ChatViewProps) { ); const draftTimelineEntries = useMemo( () => -<<<<<<< HEAD - deriveTimelineEntries( - timelineMessages, - activeThread?.proposedPlans ?? [], - workLogEntries, - turnPlans, - ), - [activeThread?.proposedPlans, timelineMessages, turnPlans, workLogEntries], -======= optimisticUserMessages.map( (message) => ({ @@ -2353,7 +2340,6 @@ function ChatViewContent(props: ChatViewProps) { }) as const, ), [optimisticUserMessages], ->>>>>>> d454b3880e (Retire V1 client orchestration parity) ); const timelineEntries = isServerThread ? serverTimelineEntries : draftTimelineEntries; const { turnDiffSummaries } = useTurnDiffSummaries(serverProjection); @@ -2449,9 +2435,9 @@ function ChatViewContent(props: ChatViewProps) { // Default true while loading to avoid toolbar flicker. const isGitRepo = gitStatusQuery.data?.isRepo ?? true; const showComposerContextStrip = shouldShowComposerContextStrip({ - hasActiveProject: activeProject !== null, + routeKind, isGitRepo, - showEnvironmentIndicator: showComposerEnvironmentIndicator, + hasActiveProject: activeProject !== null, }); const initialDiffPanelGitScope = gitStatusQuery.data?.hasWorkingTreeChanges === true ? "unstaged" : "branch"; @@ -5491,27 +5477,11 @@ function ChatViewContent(props: ChatViewProps) { beginLocalDispatch({ preparingWorktree: false }); setThreadError(threadIdForSend, null); -<<<<<<< HEAD - // Position this sent row once LegendList has measured the anchored tail. - isAtEndRef.current = true; - timelineScrollModeRef.current = "anchoring-new-turn"; - liveFollowUserScrollGenerationRef.current = anchorUserScrollGenerationRef.current; - setTimelineLiveFollowEnabled(true); - pendingTimelineAnchorRef.current = messageIdForSend; - activeTimelineAnchorIndexRef.current = null; - showScrollDebouncer.current.cancel(); - setShowScrollToBottom(false); - setTimelineAnchor({ - threadKey: scopedThreadKey(scopeThreadRef(activeThread.environmentId, threadIdForSend)), - messageId: messageIdForSend, - }); -======= // Scroll to the current end *before* adding the optimistic message. isAtEndRef.current = true; showScrollDebouncer.current.cancel(); setShowScrollToBottom(false); await legendListRef.current?.scrollToEnd?.({ animated: false }); ->>>>>>> d454b3880e (Retire V1 client orchestration parity) setOptimisticUserMessages((existing) => [ ...existing, @@ -5536,51 +5506,12 @@ function ChatViewContent(props: ChatViewProps) { let failure: AtomCommandResult | null = settingsResult._tag === "Failure" ? settingsResult : null; -<<<<<<< HEAD - const startResult = await startThreadTurn({ - environmentId, - input: { - threadId: threadIdForSend, - message: { - messageId: messageIdForSend, - role: "user", - text: outgoingMessageText, - attachments: [], - }, - modelSelection: ctxSelectedModelSelection, - titleSeed: activeThread.title, - runtimeMode, - interactionMode: nextInteractionMode, - ...(nextInteractionMode === "default" && activeProposedPlan - ? { - sourceProposedPlan: { - threadId: activeThread.id, - planId: activeProposedPlan.id, - }, - } - : {}), - createdAt: messageCreatedAt, - }, - }); - failure = startResult._tag === "Failure" ? startResult : null; - } - - if (failure === null) { - acknowledgeActiveThreadWoke(); - sendInFlightRef.current = false; - return; - } - - setOptimisticUserMessages((existing) => - existing.filter((message) => message.id !== messageIdForSend), -======= if (failure === null) { // Keep the mode toggle and plan-follow-up banner in sync immediately // while the same-thread implementation turn is starting. setComposerDraftInteractionMode( scopeThreadRef(activeThread.environmentId, threadIdForSend), nextInteractionMode, ->>>>>>> d454b3880e (Retire V1 client orchestration parity) ); const startResult = await startThreadTurn({ @@ -5622,31 +5553,6 @@ function ChatViewContent(props: ChatViewProps) { } } sendInFlightRef.current = false; -<<<<<<< HEAD - resetLocalDispatch(); - }, - [ - activeThread, - activeProposedPlan, - acknowledgeActiveThreadWoke, - beginLocalDispatch, - isConnecting, - isSendBusy, - isServerThread, - localCheckoutBranchMismatch, - persistThreadSettingsForNextTurn, - resetLocalDispatch, - runtimeMode, - setComposerDraftInteractionMode, - setThreadError, - startThreadTurn, - activeThreadRef, - autoOpenPlanSidebar, - environmentId, - composerRef, - ], - ); -======= return; } @@ -5663,7 +5569,6 @@ function ChatViewContent(props: ChatViewProps) { sendInFlightRef.current = false; resetLocalDispatch(); } ->>>>>>> d454b3880e (Retire V1 client orchestration parity) const onImplementPlanInNewThread = useCallback(async () => { if ( @@ -6330,79 +6235,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 74500050b6..3d74ee1ebc 100644 --- a/apps/web/src/components/chat/ChatComposer.tsx +++ b/apps/web/src/components/chat/ChatComposer.tsx @@ -2680,7 +2680,7 @@ export const ChatComposer = memo(function ChatComposer(props: ChatComposerProps)