From a8fb548145be0de9ad6d1a9bc1b9a3e8a414d471 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 --- apps/web/src/components/BranchToolbar.tsx | 2 +- .../web/src/components/ChatView.logic.test.ts | 40 ++++ apps/web/src/components/ChatView.logic.ts | 8 + apps/web/src/components/ChatView.tsx | 194 +++++++++--------- apps/web/src/components/chat/ChatComposer.tsx | 2 +- apps/web/src/components/chat/ChatHeader.tsx | 133 +----------- apps/web/src/index.css | 150 +++++++++++++- 7 files changed, 292 insertions(+), 237 deletions(-) diff --git a/apps/web/src/components/BranchToolbar.tsx b/apps/web/src/components/BranchToolbar.tsx index 52b8a6da8f..a7de51ab78 100644 --- a/apps/web/src/components/BranchToolbar.tsx +++ b/apps/web/src/components/BranchToolbar.tsx @@ -286,7 +286,7 @@ export const BranchToolbar = memo(function BranchToolbar({ } return ( -
+
{isMobile ? ( { ).toBeNull(); }); }); + +describe("shouldShowComposerContextStrip", () => { + it("shows git context on a draft with an active project", () => { + expect( + shouldShowComposerContextStrip({ + routeKind: "draft", + isGitRepo: true, + hasActiveProject: true, + }), + ).toBe(true); + }); + + 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 bcbdc93188..1f90194708 100644 --- a/apps/web/src/components/ChatView.logic.ts +++ b/apps/web/src/components/ChatView.logic.ts @@ -224,6 +224,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 afb65c8368..70f4739ba2 100644 --- a/apps/web/src/components/ChatView.tsx +++ b/apps/web/src/components/ChatView.tsx @@ -274,6 +274,7 @@ import { resolveSendEnvMode, revokeBlobPreviewUrl, revokeUserMessagePreviewUrls, + shouldShowComposerContextStrip, waitForStartedServerThread, } from "./ChatView.logic"; import { useLocalStorage } from "~/hooks/useLocalStorage"; @@ -2422,6 +2423,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 = shouldShowComposerContextStrip({ + routeKind, + isGitRepo, + hasActiveProject: activeProject !== null, + }); const initialDiffPanelGitScope = gitStatusQuery.data?.hasWorkingTreeChanges === true ? "unstaged" : "branch"; const diffPanelGitStatusResolutionKey = gitStatusQuery.data ? "resolved" : "pending"; @@ -5751,25 +5757,8 @@ function ChatViewContent(props: ChatViewProps) { ? panelLayoutControls : null} @@ -5899,92 +5888,101 @@ function ChatViewContent(props: ChatViewProps) { : undefined } > -
-
- +
+
+
+ +
- {isGitRepo && ( + {showComposerContextStrip && (
| undefined; - preferredScriptId: string | null; - keybindings: ResolvedKeybindingsConfig; - availableEditors: ReadonlyArray; rightPanelOpen: boolean; - gitCwd: string | null; - onRunProjectScript: (script: ProjectScript) => void; - onAddProjectScript: (input: NewProjectScriptInput) => Promise; - onUpdateProjectScript: ( - scriptId: string, - input: NewProjectScriptInput, - ) => Promise; - onDeleteProjectScript: (scriptId: string) => Promise; -} - -export function shouldShowOpenInPicker(input: { - readonly activeProjectName: string | undefined; - readonly activeThreadEnvironmentId: EnvironmentId; - readonly primaryEnvironmentId: EnvironmentId | null; -}): boolean { - return ( - Boolean(input.activeProjectName) && - input.primaryEnvironmentId !== null && - input.activeThreadEnvironmentId === input.primaryEnvironmentId - ); } export const ChatHeader = memo(function ChatHeader({ - activeThreadEnvironmentId, - activeThreadId, - draftId, activeThreadTitle, - activeProjectName, - activeProjectCwd, - openInCwd, - activeProjectScripts, - preferredScriptId, - keybindings, - availableEditors, rightPanelOpen, - gitCwd, - onRunProjectScript, - onAddProjectScript, - onUpdateProjectScript, - onDeleteProjectScript, }: ChatHeaderProps) { - const primaryEnvironmentId = usePrimaryEnvironmentId(); - const fileScripts = useT3ProjectFileScripts( - activeThreadEnvironmentId, - activeProjectScripts ? activeProjectCwd : null, - ); - const showOpenInPicker = shouldShowOpenInPicker({ - activeProjectName, - activeThreadEnvironmentId, - primaryEnvironmentId, - }); - return ( -
+
- {activeProjectName ? ( - - - - - {activeProjectName} - - - - / - - - ) : null} {activeThreadTitle}
-
- {activeProjectScripts ? ( - - ) : null} - {showOpenInPicker ? ( - - ) : null} - {activeProjectName ? ( - - ) : null} -
); }); diff --git a/apps/web/src/index.css b/apps/web/src/index.css index 2821315118..1648d67b70 100644 --- a/apps/web/src/index.css +++ b/apps/web/src/index.css @@ -419,21 +419,20 @@ html[data-mobile-composer-route-transition="true"]::view-transition-old(t3-mobil backdrop-filter: blur(var(--glass-blur)) saturate(var(--glass-saturation)); } - .chat-composer-glass-host { + .chat-composer-glass-shell { --chat-composer-glass-surface: var(--card); + --chat-composer-outline: rgb(0 0 0 / 8%); position: relative; - box-shadow: - 0 0 0 1px rgb(0 0 0 / 8%), - 0 12px 28px -18px rgb(0 0 0 / 40%); + isolation: isolate; } - .chat-composer-glass-host::before { + .chat-composer-glass-shell::before { pointer-events: none; position: absolute; z-index: 0; inset: 0; - border-radius: inherit; + border-radius: 22px; background: color-mix( in srgb, var(--chat-composer-glass-surface) var(--glass-opacity), @@ -444,14 +443,145 @@ html[data-mobile-composer-route-transition="true"]::view-transition-old(t3-mobil content: ""; } + .chat-composer-glass-shell-with-context { + --chat-composer-context-extension: 2.25rem; + } + + .chat-composer-glass-shell-with-context::before { + border-radius: 0; + clip-path: shape( + from 0 22px, + curve to 22px 0 with 0 9.85px / 9.85px 0, + line to calc(100% - 22px) 0, + curve to 100% 22px with calc(100% - 9.85px) 0 / 100% 9.85px, + line to 100% calc(100% - var(--chat-composer-context-extension) - 22px), + curve to calc(100% - 22px) calc(100% - var(--chat-composer-context-extension)) with 100% + calc(100% - var(--chat-composer-context-extension) - 9.85px) / calc(100% - 9.85px) + calc(100% - var(--chat-composer-context-extension)), + line to calc(100% - 22px) calc(100% - 16px), + curve to calc(100% - 38px) 100% with calc(100% - 22px) calc(100% - 7.16px) / + calc(100% - 29.16px) 100%, + line to 38px 100%, + curve to 22px calc(100% - 16px) with 29.16px 100% / 22px calc(100% - 7.16px), + line to 22px calc(100% - var(--chat-composer-context-extension)), + curve to 0 calc(100% - var(--chat-composer-context-extension) - 22px) with 9.85px + calc(100% - var(--chat-composer-context-extension)) / 0 + calc(100% - var(--chat-composer-context-extension) - 9.85px), + line to 0 22px, + close + ); + } + + @media (min-width: 40rem) { + .chat-composer-glass-shell-with-context { + --chat-composer-context-extension: 2rem; + } + } + + .chat-composer-glass-host { + position: relative; + box-shadow: 0 12px 28px -18px rgb(0 0 0 / 40%); + } + + .chat-composer-glass-host::after { + pointer-events: none; + position: absolute; + z-index: 1; + inset: 0; + border: 1px solid var(--chat-composer-outline); + border-radius: inherit; + content: ""; + } + + .chat-composer-glass-shell-with-context .chat-composer-glass-host::after { + clip-path: polygon( + 0 0, + 100% 0, + 100% 100%, + calc(100% - 22px) 100%, + calc(100% - 22px) calc(100% - 2px), + 22px calc(100% - 2px), + 22px 100%, + 0 100% + ); + } + + .chat-composer-context-strip { + position: relative; + isolation: isolate; + } + + .chat-composer-context-strip::before { + position: absolute; + z-index: -1; + inset: 0; + border: 1px solid var(--chat-composer-outline); + border-radius: 0 0 16px 16px; + -webkit-mask-image: linear-gradient(to bottom, transparent 0 1rem, black 1rem); + mask-image: linear-gradient(to bottom, transparent 0 1rem, black 1rem); + box-shadow: 0 12px 28px -18px rgb(0 0 0 / 40%); + content: ""; + } + .dark .floating-glass-surface { background: color-mix(in srgb, var(--card) 45%, transparent); } - .dark .chat-composer-glass-host { - --chat-composer-glass-surface: color-mix(in srgb, var(--background) 84%, var(--color-white)); + .dark .chat-composer-glass-shell { + --chat-composer-glass-surface: color-mix(in srgb, var(--background) 96%, var(--color-white)); + --chat-composer-outline: color-mix(in srgb, var(--color-white) 5%, transparent); + --chat-composer-highlight: rgb(255 255 255 / 3%); + } - box-shadow: 0 0 0 1px rgb(255 255 255 / 10%); + .dark .chat-composer-glass-host { + box-shadow: none; + } + + .dark .chat-composer-glass-host::after { + box-shadow: inset 0 1px var(--chat-composer-highlight); + } + + .dark .chat-composer-context-strip::before { + border-color: rgb(255 255 255 / 7%); + background: + linear-gradient( + to bottom, + transparent 0 1rem, + rgb(0 0 0 / 18%) 1rem, + transparent calc(1rem + 10px) + ), + rgb(255 255 255 / 2%); + box-shadow: 0 14px 32px -18px rgb(0 0 0 / 75%); + } + + @supports not (clip-path: shape(from 0 0, line to 1px 1px)) { + .chat-composer-glass-shell-with-context::before { + inset-block-end: var(--chat-composer-context-extension); + border-radius: 22px; + clip-path: none; + } + + .chat-composer-context-strip::before { + background: color-mix( + in srgb, + var(--chat-composer-glass-surface) var(--glass-opacity), + transparent + ); + -webkit-backdrop-filter: blur(var(--glass-blur)) saturate(var(--glass-saturation)); + backdrop-filter: blur(var(--glass-blur)) saturate(var(--glass-saturation)); + } + + .dark .chat-composer-context-strip::before { + background: + linear-gradient( + to bottom, + transparent 0 1rem, + rgb(0 0 0 / 18%) 1rem, + transparent calc(1rem + 10px) + ), + linear-gradient(rgb(255 255 255 / 2%), rgb(255 255 255 / 2%)), + color-mix(in srgb, var(--chat-composer-glass-surface) var(--glass-opacity), transparent); + } } .alert-glass { @@ -689,7 +819,7 @@ html[data-mobile-composer-route-transition="true"]::view-transition-old(t3-mobil background: var(--background) !important; } - .chat-composer-glass-host::before { + .chat-composer-glass-shell::before { background: var(--chat-composer-glass-surface); }