Skip to content

Commit bd84b17

Browse files
t3dotggclaude
andauthored
feat(web): simpler composer with grouped controls, effort words and no collapsed state (pingdotgg#25869)
Co-authored-by: Claude Opus 5.5 <[email protected]>
1 parent 48a2923 commit bd84b17

40 files changed

Lines changed: 1162 additions & 1196 deletions

‎apps/desktop/src/settings/DesktopClientSettings.test.ts‎

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,6 @@ const clientSettings: ClientSettings = {
3434
confirmThreadDelete: false,
3535
confirmThreadUnpin: false,
3636
contextWindowMeterEnabled: false,
37-
composerCollapseOnScroll: true,
3837
diffFilesCollapsed: true,
3938
diffIgnoreWhitespace: true,
4039
diffLayout: "stacked",

‎apps/web/src/components/BranchToolbar.logic.ts‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -66,12 +66,12 @@ export function shouldShowComposerContextStrip(input: {
6666
hasActiveProject: boolean;
6767
isGitRepo: boolean;
6868
showEnvironmentIndicator: boolean;
69-
hostsRestingComposerControls: boolean;
7069
}): boolean {
70+
// A new thread always shows the strip, since it names the permissions the first send uses.
7171
return (
7272
input.hasActiveProject &&
73-
(input.isDraftHeroState || input.persistInActiveThreads) &&
74-
(input.isGitRepo || input.showEnvironmentIndicator || input.hostsRestingComposerControls)
73+
(input.isDraftHeroState ||
74+
(input.persistInActiveThreads && (input.isGitRepo || input.showEnvironmentIndicator)))
7575
);
7676
}
7777

‎apps/web/src/components/BranchToolbar.tsx‎

Lines changed: 9 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -5,17 +5,11 @@ import { stackedThreadToast, toastManager } from "./ui/toast";
55
import { ComposerContextLabel } from "./ComposerContextLabel";
66
import { scopeProjectRef, scopeThreadRef } from "@t3tools/client-runtime/environment";
77
import type { EnvironmentId, ProjectId, ThreadId } from "@t3tools/contracts";
8-
import {
9-
ChevronDownIcon,
10-
FolderGit2Icon,
11-
FolderGitIcon,
12-
FolderIcon,
13-
PlusIcon,
14-
ScaleIcon,
15-
} from "lucide-react";
8+
import { FolderGit2Icon, FolderGitIcon, FolderIcon, PlusIcon, ScaleIcon } from "lucide-react";
169
import {
1710
type Ref,
1811
type MouseEvent as ReactMouseEvent,
12+
type ReactNode,
1913
memo,
2014
useImperativeHandle,
2115
useRef,
@@ -72,8 +66,6 @@ import { Tooltip, TooltipPopup, TooltipTrigger } from "./ui/tooltip";
7266
import { MiddleTruncate } from "./ui/middle-truncate";
7367
import { ComposerSurface } from "./chat/ComposerSurface";
7468
import { useComposerMenuProps } from "./chat/composerEventScope";
75-
import { measureRestingComposerControls } from "./chat/restingComposerControlsMeasurement";
76-
import { resolveRestingComposerControlsNaturalWidth } from "./composerFooterLayout";
7769
import { cn } from "~/lib/utils";
7870
import { observeResize } from "~/lib/observeResize";
7971

@@ -105,10 +97,10 @@ interface BranchToolbarProps {
10597
envLocked: boolean;
10698
onCheckoutPullRequestRequest?: (reference: string) => void;
10799
onComposerFocusRequest?: () => void;
100+
/** Shown at the end of the composer strip, such as the new thread's permissions. */
101+
trailing?: ReactNode;
108102
availableEnvironments?: readonly EnvironmentOption[];
109103
onEnvironmentChange?: (environmentId: EnvironmentId) => void;
110-
composerControlsHostRef?: (element: HTMLDivElement | null) => void;
111-
contextStripVisible?: boolean;
112104
}
113105

114106
function showWorkspaceContextMenu(event: ReactMouseEvent, workspacePath: string) {
@@ -317,7 +309,6 @@ const RunContextSelector = memo(function RunContextSelector({
317309
].join(" ")}
318310
>
319311
{triggerContent}
320-
{!isPanel ? <ChevronDownIcon className="size-3 shrink-0 mx-0!" /> : null}
321312
</MenuTrigger>
322313
<MenuPopup
323314
align="start"
@@ -544,16 +535,7 @@ function useLabelsOverflow(): readonly [
544535
let groups = 0;
545536
for (const child of current.children) {
546537
if (!(child instanceof HTMLElement)) continue;
547-
// Reserve overflowed controls' width to prevent repeated hiding and expansion.
548-
const hostedControls = child.matches('[data-chat-resting-composer-controls-host="true"]')
549-
? child.querySelector<HTMLElement>('[data-chat-composer-resting-controls="true"]')
550-
: null;
551-
const hostedMeasurement = hostedControls
552-
? measureRestingComposerControls(hostedControls)
553-
: null;
554-
const width = hostedMeasurement
555-
? resolveRestingComposerControlsNaturalWidth(hostedMeasurement)
556-
: contentWidth(hostedControls ?? child);
538+
const width = contentWidth(child);
557539
if (width <= 1) continue;
558540
groups += 1;
559541
needed += width;
@@ -585,7 +567,6 @@ function useLabelsOverflow(): readonly [
585567
[
586568
current,
587569
...Array.from(current.children),
588-
...Array.from(current.querySelectorAll("[data-chat-composer-resting-controls='true']")),
589570
...Array.from(current.querySelectorAll(COMPOSER_CONTEXT_LABEL_SELECTOR)),
590571
],
591572
measure,
@@ -640,8 +621,7 @@ export const BranchToolbar = memo(function BranchToolbar({
640621
onComposerFocusRequest,
641622
availableEnvironments,
642623
onEnvironmentChange,
643-
composerControlsHostRef,
644-
contextStripVisible = true,
624+
trailing,
645625
}: BranchToolbarProps) {
646626
const branchSelectorRef = useRef<BranchToolbarBranchSelectorHandle>(null);
647627
const threadRef = scopeThreadRef(environmentId, threadId);
@@ -764,11 +744,7 @@ export const BranchToolbar = memo(function BranchToolbar({
764744
<ComposerSurface.ContextStrip
765745
ref={attachStrip}
766746
data-compact={labelsOverflow ? "" : undefined}
767-
className={cn(
768-
"gap-1 text-xs font-normal text-foreground/70 dark:text-muted-foreground",
769-
// Hide empty non-Git strips while retaining host width so controls can reappear as the chat grows.
770-
!contextStripVisible && "pointer-events-none invisible absolute inset-x-0 top-full",
771-
)}
747+
className={cn("gap-1 text-xs font-normal text-foreground/70 dark:text-muted-foreground")}
772748
>
773749
{showGitControls ? (
774750
<div className="contents @3xl/composer-surface:hidden">
@@ -799,7 +775,7 @@ export const BranchToolbar = memo(function BranchToolbar({
799775
className={cn(
800776
"min-h-7 min-w-10 items-center gap-1 sm:min-h-6",
801777
showGitControls ? "hidden @3xl/composer-surface:flex" : "flex",
802-
composerControlsHostRef ? "shrink" : "flex-1",
778+
"flex-1",
803779
)}
804780
>
805781
{showEnvironmentIndicator && availableEnvironments && (
@@ -837,15 +813,6 @@ export const BranchToolbar = memo(function BranchToolbar({
837813
</div>
838814
) : null}
839815

840-
{composerControlsHostRef ? (
841-
<div
842-
ref={composerControlsHostRef}
843-
data-composer-context-control
844-
data-chat-resting-composer-controls-host="true"
845-
className="flex min-w-0 flex-1 items-center justify-start overflow-x-clip overflow-y-visible"
846-
/>
847-
) : null}
848-
849816
{showGitControls ? (
850817
<BranchToolbarBranchSelector
851818
forceNewWorktree={forceNewWorktree}
@@ -864,6 +831,7 @@ export const BranchToolbar = memo(function BranchToolbar({
864831
{...(onComposerFocusRequest ? { onComposerFocusRequest } : {})}
865832
/>
866833
) : null}
834+
{trailing}
867835
</ComposerSurface.ContextStrip>
868836
);
869837
});

‎apps/web/src/components/BranchToolbarBranchSelector.tsx‎

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ import {
1616
type VcsRef,
1717
type ThreadId,
1818
} from "@t3tools/contracts";
19-
import { ChevronDownIcon, GitBranchIcon } from "lucide-react";
19+
import { GitBranchIcon } from "lucide-react";
2020
import {
2121
useDeferredValue,
2222
useEffect,
@@ -732,7 +732,6 @@ export function BranchToolbarBranchSelector({
732732
className="w-full"
733733
/>
734734
</ComposerContextLabel>
735-
{displayMode !== "panel" ? <ChevronDownIcon className="size-3 shrink-0" /> : null}
736735
</ComboboxTrigger>
737736
</span>
738737
{displayMode === "panel" && prNumber !== undefined && prUrl !== undefined ? (

0 commit comments

Comments
 (0)