TypeScript
fix(web): prevent chat metadata overlap (#8851)
Matthew Ferozf47e74004af2
diff --git a/apps/web/src/components/BranchToolbar.tsx b/apps/web/src/components/BranchToolbar.tsxindex 8a4dc581992..b0b1440587e 100644--- a/apps/web/src/components/BranchToolbar.tsx+++ b/apps/web/src/components/BranchToolbar.tsx@@ -265,8 +265,10 @@ function useLabelsOverflow(element: HTMLDivElement | null): boolean {let needed = 0;let groups = 0;for (const child of current.children) {- if (!(child instanceof HTMLElement) || child.offsetWidth <= 1) continue;- needed += contentWidth(child);+ if (!(child instanceof HTMLElement)) continue;+ const width = contentWidth(child);+ if (width <= 1) continue;+ needed += width;groups += 1;}needed += stripGap * Math.max(0, groups - 1);@@ -356,7 +358,7 @@ function useLabelsOverflow(element: HTMLDivElement | null): boolean {// Label widths can change without the strip box moving (font family or// size preferences), so re-measure on every render as well as on resize// and font loads.- useEffect(() => {+ useLayoutEffect(() => {measure();});@@ -487,7 +489,7 @@ export const BranchToolbar = memo(function BranchToolbar({onUsePreviousWorktree={onUsePreviousWorktree}/>) : (- <div className="flex min-w-0 flex-1 items-center gap-1">+ <div className="flex min-w-10 flex-1 items-center gap-1">{showEnvironmentIndicator && availableEnvironments && (<><BranchToolbarEnvironmentSelector@@ -520,7 +522,7 @@ export const BranchToolbar = memo(function BranchToolbar({{showGitControls ? (<BranchToolbarBranchSelector- className="min-w-0 flex-1 justify-end md:ml-auto md:flex-none"+ className="min-w-0 flex-1 justify-end md:ml-auto md:flex-initial"environmentId={environmentId}threadId={threadId}{...(draftId ? { draftId } : {})}diff --git a/apps/web/src/components/BranchToolbarEnvModeSelector.tsx b/apps/web/src/components/BranchToolbarEnvModeSelector.tsxindex 9fc2d4892e2..23589d62bd9 100644--- a/apps/web/src/components/BranchToolbarEnvModeSelector.tsx+++ b/apps/web/src/components/BranchToolbarEnvModeSelector.tsx@@ -51,20 +51,25 @@ export const BranchToolbarEnvModeSelector = memo(function BranchToolbarEnvModeSeif (envLocked) {return (<span- className="inline-flex h-7 shrink-0 items-center gap-1 border border-transparent px-[calc(--spacing(3)-1px)] text-sm font-medium text-muted-foreground/70 sm:h-6 sm:text-xs"+ className="inline-flex h-7 min-w-0 items-center gap-1 border border-transparent px-[calc(--spacing(3)-1px)] text-sm font-medium text-muted-foreground/70 sm:h-6 sm:text-xs"data-composer-context-control>{activeWorktreePath ? (- <>- <FolderGitIcon className="size-3" />- {resolveLockedWorkspaceLabel(activeWorktreePath)}- </>+ <FolderGitIcon className="size-3 shrink-0" />) : (- <>- <FolderIcon className="size-3" />- {resolveLockedWorkspaceLabel(activeWorktreePath)}- </>+ <FolderIcon className="size-3 shrink-0" />)}+ <span+ data-composer-label+ className="min-w-0 max-w-[240px] group-data-[compact]/composer-context:max-w-0"+ >+ <span+ data-composer-label-motion+ className="block w-full min-w-0 max-w-[240px] origin-left truncate transition-[opacity,transform] duration-180 ease-[cubic-bezier(0.32,0.72,0,1)] group-data-[compact]/composer-context:[transform:translateX(-0.25rem)_scaleX(0.95)] group-data-[compact]/composer-context:opacity-0 motion-reduce:transform-none motion-reduce:transition-opacity"+ >+ {resolveLockedWorkspaceLabel(activeWorktreePath)}+ </span>+ </span></span>);}diff --git a/apps/web/src/components/chat/ChatHeader.tsx b/apps/web/src/components/chat/ChatHeader.tsxindex dbba327489a..c9c733e10f1 100644--- a/apps/web/src/components/chat/ChatHeader.tsx+++ b/apps/web/src/components/chat/ChatHeader.tsx@@ -288,13 +288,16 @@ export const ChatHeader = memo(function ChatHeader({className="@container/header-actions flex min-w-0 flex-1 items-center gap-2 sm:gap-3"onContextMenu={handleHeaderContextMenu}>- <WorkspaceBreadcrumb ariaLabel="Thread breadcrumb" className="flex-1">+ <WorkspaceBreadcrumb+ ariaLabel="Thread breadcrumb"+ className="flex-1 overflow-clip [overflow-clip-margin:2px]"+ >{/* The project always leads the header: knowing which project athread lives in is priority zero, and the thread title alonedoesn't answer it. */}{activeProjectName ? (<>- <WorkspaceBreadcrumbItem>+ <WorkspaceBreadcrumbItem className="shrink"><Tooltip><TooltipTriggerrender={@@ -302,7 +305,7 @@ export const ChatHeader = memo(function ChatHeader({type="button"aria-label={`New thread in ${activeProjectName}`}onClick={onNewThreadInProject}- className="inline-flex min-w-0 cursor-pointer items-center gap-1.5 rounded-sm text-muted-foreground transition-colors hover:text-foreground focus-visible:outline-hidden focus-visible:ring-2 focus-visible:ring-ring"+ className="inline-flex min-w-0 max-w-full cursor-pointer items-center gap-1.5 rounded-sm text-muted-foreground transition-colors hover:text-foreground focus-visible:outline-hidden focus-visible:ring-2 focus-visible:ring-ring"/>}>@@ -320,7 +323,7 @@ export const ChatHeader = memo(function ChatHeader({<WorkspaceBreadcrumbSeparator /></>) : null}- <WorkspaceBreadcrumbItem current className="flex-1">+ <WorkspaceBreadcrumbItem current className="min-w-10 flex-1">{renamingTitle !== null ? (<inputautoFocus