The best way to control Claude Code, Codex and more from any computer or phone
refactor(web): ChatView's paste-to-focus, titlebar controls, and timeline overlays move out (#23072)
Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
Julius Marminge committed
Oct 21, 2026 at 13:40 UTC
322d08dbd46eecf4446d33d85f9fd7ff08d60f1b
4 files changed
+173
-120
apps/web/src/components/ChatView.tsx
+22
-119
@@ -1,3 +1,5 @@
1
+import { ScrollToEndButton, WorkspaceFileDropOverlay } from "./chat/TimelineOverlays";
2
+import { usePasteToFocusComposer } from "./chat/usePasteToFocusComposer";
3
import {
4
deriveAvailableRevertTurnCounts,
5
deriveThreadPendingBackgroundTasks,
@@ -44,10 +46,6 @@ import { feedbackBannerItem } from "./chat/ComposerFeedback";
46
import { useUsageLimitsPanel } from "./chat/useUsageLimitsPanel";
47
import { useWorktreeSetup } from "./chat/useWorktreeSetup";
48
import { useChatShortcuts, type ChatShortcutHandler } from "./chat/useChatShortcuts";
47
-import {
48
- pasteTextToFocusComposer,
49
- shouldRedirectInputToComposer,
50
-} from "./chat/composerFocusRedirect";
49
import * as Schema from "effect/Schema";
50
import {
51
AuthOrchestrationOperateScope,
@@ -71,8 +69,6 @@ import {
69
resolveIdleCompaction,
70
RuntimeMode,
71
} from "@t3tools/contracts";
74
-import { readPastedComposerContext } from "./composerInlineTokenPaste";
75
-import { isPasteAsTextShortcut } from "@t3tools/client-runtime/text-paste";
72
import { useThreadActions } from "../hooks/useThreadActions";
73
import {
74
deriveProviderSubagentStatus,
@@ -111,7 +107,6 @@ import { useAtomValue } from "@effect/atom-react";
107
import { type SetStateAction, useEffect, useLayoutEffect, useRef, useState } from "react";
108
import { useLocation, useNavigate } from "@tanstack/react-router";
109
import { assistantCitationFromLocation } from "../lib/assistantCitationNavigation";
114
-import { isMacPlatform } from "../lib/utils";
110
import type { AssistantCitationSourceAnchor } from "~/lib/assistantTextSelection";
111
import { useShallow } from "zustand/react/shallow";
112
import {
@@ -141,7 +136,6 @@ import { useWorkspaceMutationRefresh } from "../hooks/useWorkspaceMutationRefres
136
import { DEFAULT_INTERACTION_MODE, type ChatMessage } from "../types";
137
import { useTheme } from "../hooks/useTheme";
138
import { writeTextToClipboard } from "../hooks/useCopyToClipboard";
144
-import { isCommandPaletteOpen } from "../commandPaletteBus";
139
import { settleAndAdvance } from "../settleAndAdvance";
140
import { subscribeSnapShotComposerFocus } from "../lib/desktopSnapShot";
141
import { useMediaQuery } from "../hooks/useMediaQuery";
@@ -177,7 +171,6 @@ import { makeWorkspaceFileDropHandlers } from "./chat/workspaceFileDrop";
171
import { isEditableFocused } from "../lib/editableFocus";
172
import { DEFAULT_RESOLVED_KEYBINDINGS } from "@t3tools/shared/keybindings";
173
import { shortcutLabelForCommand } from "../keybindings";
180
-import { PaperclipIcon, ChevronDownIcon } from "lucide-react";
174
import { cn } from "~/lib/utils";
175
import { COLLAPSED_SIDEBAR_TITLEBAR_INSET_CLASS } from "~/workspaceTitlebar";
176
import { stackedThreadToast, toastManager } from "./ui/toast";
@@ -276,7 +269,8 @@ import { useOpenFavoriteEditorShortcut } from "./chat/OpenInPickerShortcut";
269
import {
270
PanelLayoutControls,
271
type PanelLayoutControlsProps,
279
- RightPanelMaximizeControl,
272
+ ThreadPanelHeaderControl,
273
+ WorkspaceTitlebarControls,
274
} from "./chat/PanelLayoutControls";
275
import type { ExpandedImagePreview } from "./chat/ExpandedImagePreview";
276
import { ThreadDetailsPanel } from "./chat/ThreadDetailsPanel";
@@ -348,7 +342,6 @@ import { readEnvironmentScope, readPreparedConnection } from "../state/session";
342
import { useAtomCommand } from "../state/use-atom-command";
343
import { useOrchestrationCommand } from "../state/use-orchestration-command";
344
import { useAtomQueryRunner } from "../state/use-atom-query-runner";
351
-import { Button } from "./ui/button";
345
import { observeResize } from "~/lib/observeResize";
346
import { ThreadVisitWatermark } from "./chat/ThreadVisitWatermark";
347
import { ChatTerminalDrawers } from "./chat/ChatTerminalDrawers";
@@ -598,7 +591,6 @@ export default function ChatView(props: ChatViewProps) {
591
const composerFilesRef = useRef<ComposerFileAttachment[]>([]);
592
const composerTerminalContextsRef = useRef<TerminalContextDraft[]>([]);
593
const branchToolbarRef = useRef<BranchToolbarHandle>(null);
601
- const pasteAsTextShortcutUntilRef = useRef(0);
594
const [restingComposerControlsHost, setRestingComposerControlsHost] =
595
useState<HTMLDivElement | null>(null);
596
const [restingComposerControlsVisible, setRestingComposerControlsVisible] = useState(false);
@@ -2868,42 +2860,7 @@ export default function ChatView(props: ChatViewProps) {
2860
});
2861
}, [toggleRightPanelStable, toggleRightPanelMaximizedStable]);
2862
2871
- // Paste-to-focus: the resting composer blurs on a click into the timeline,
2872
- // so a paste that follows has no editable target and would be dropped.
2873
- useEffect(() => {
2874
- const keyHandler = (event: KeyboardEvent) => {
2875
- if (
2876
- shouldRedirectInputToComposer(event) &&
2877
- isPasteAsTextShortcut(event, isMacPlatform(navigator.platform))
2878
- ) {
2879
- pasteAsTextShortcutUntilRef.current = Date.now() + 1_000;
2880
- }
2881
- };
2882
- const handler = (event: ClipboardEvent) => {
2883
- if (!activeThreadId || isCommandPaletteOpen()) return;
2884
- if (getTerminalFocusOwner() !== null) return;
2885
- if (composerRef.current?.isModelPickerOpen()) return;
2886
- const text = pasteTextToFocusComposer(event);
2887
- const clipboardData = event.clipboardData;
2888
- if (text === null || clipboardData === null) return;
2889
- const bypassAutoAttachment = Date.now() <= pasteAsTextShortcutUntilRef.current;
2890
- pasteAsTextShortcutUntilRef.current = 0;
2891
- if (
2892
- ((readPastedComposerContext(clipboardData)?.records.length ?? 0) === 0 &&
2893
- composerRef.current?.pasteTextAtEnd(text, { bypassAutoAttachment })) ||
2894
- composerRef.current?.insertTextAtEnd(text, { clipboardData })
2895
- ) {
2896
- event.preventDefault();
2897
- event.stopPropagation();
2898
- }
2899
- };
2900
- window.addEventListener("keydown", keyHandler, true);
2901
- window.addEventListener("paste", handler, true);
2902
- return () => {
2903
- window.removeEventListener("keydown", keyHandler, true);
2904
- window.removeEventListener("paste", handler, true);
2905
- };
2906
- }, [activeThreadId, composerRef]);
2863
+ usePasteToFocusComposer(activeThreadId, composerRef);
2864
const {
2865
onConfirmRevertStable,
2866
onForkFromRunStable,
@@ -3255,46 +3212,17 @@ export default function ChatView(props: ChatViewProps) {
3212
showThreadPanelControl={!inlineRightPanelOwnsTitleBar}
3213
/>
3214
);
3258
- const threadPanelHeaderControl = (
3259
- <div
3260
- className="absolute top-[var(--workspace-controls-top)] right-[calc(env(safe-area-inset-right)+0.75rem)] z-50 flex h-[var(--workspace-topbar-height)] items-center [-webkit-app-region:no-drag]"
3261
- data-workspace-titlebar-controls
3262
- >
3263
- <PanelLayoutControls
3264
- {...panelToggleControlProps}
3265
- showTerminalControl={false}
3266
- showRightPanelControl={false}
3267
- />
3268
- </div>
3269
- );
3215
+ const threadPanelHeaderControl = <ThreadPanelHeaderControl {...panelToggleControlProps} />;
3216
const panelLayoutControls = (
3271
- <div
3272
- className={cn(
3273
- "pointer-events-none fixed top-[var(--workspace-controls-top)] right-[var(--workspace-controls-right)] z-50 mr-px flex h-[var(--workspace-topbar-height)] items-center gap-1 [-webkit-app-region:no-drag]",
3274
- )}
3275
- data-workspace-titlebar-controls
3217
+ <WorkspaceTitlebarControls
3218
+ showMaximizeControl={!shouldUsePlanSidebarSheet}
3219
+ rightPanelOpen={rightPanelOpen}
3220
+ animationsActive={panelAnimationsActive}
3221
+ maximized={rightPanelMaximized}
3222
+ onToggleMaximized={toggleRightPanelMaximizedStable}
3223
>
3277
- {!shouldUsePlanSidebarSheet ? (
3278
- <span
3279
- aria-hidden={!rightPanelOpen}
3280
- className={cn(
3281
- "flex shrink-0",
3282
- panelAnimationsActive &&
3283
- "motion-safe:transition-opacity motion-safe:duration-(--panel-animation-duration) motion-safe:ease-out",
3284
- rightPanelOpen
3285
- ? "pointer-events-auto opacity-100"
3286
- : "pointer-events-none absolute right-full mr-1 opacity-0",
3287
- )}
3288
- inert={!rightPanelOpen}
3289
- >
3290
- <RightPanelMaximizeControl
3291
- maximized={rightPanelMaximized}
3292
- onToggle={toggleRightPanelMaximizedStable}
3293
- />
3294
- </span>
3295
- ) : null}
3296
- <div className="pointer-events-auto flex h-full items-center">{panelToggleControls}</div>
3297
- </div>
3224
+ {panelToggleControls}
3225
+ </WorkspaceTitlebarControls>
3226
);
3227
const workspaceFileDropHandlers = makeWorkspaceFileDropHandlers({
3228
setDragActive: setIsWorkspaceFileDragActive,
@@ -3382,20 +3310,7 @@ export default function ChatView(props: ChatViewProps) {
3310
onDrop={workspaceFileDropHandlers.onDrop}
3311
>
3312
<ThreadFind onClose={focusComposerStable} />
3385
- {isWorkspaceFileDragActive ? (
3386
- <div
3387
- className="pointer-events-none absolute inset-2 z-40 flex items-center justify-center rounded-2xl border-2 border-dashed border-primary/60 bg-primary/[0.035]"
3388
- data-chat-workspace-drop-overlay="true"
3389
- >
3390
- <div
3391
- role="status"
3392
- className="flex items-center gap-2 rounded-full border border-primary/25 bg-background/95 px-4 py-2.5 text-sm font-medium text-foreground shadow-lg"
3393
- >
3394
- <PaperclipIcon className="size-4 text-primary" aria-hidden="true" />
3395
- Drop files to attach
3396
- </div>
3397
- </div>
3398
- ) : null}
3313
+ {isWorkspaceFileDragActive ? <WorkspaceFileDropOverlay /> : null}
3314
<div className="chat-banner-lane pointer-events-none absolute top-0 z-30 flex flex-col">
3315
<ProviderStatusBanner
3316
status={visibleProviderStatus}
@@ -3546,25 +3461,13 @@ export default function ChatView(props: ChatViewProps) {
3461
/>
3462
3463
{showScrollToBottom && !isThreadFindActive && (
3549
- <div
3550
- className="chat-scroll-to-bottom pointer-events-none absolute z-30 flex justify-center py-1.5"
3551
- style={{ bottom: scrollToEndClearance + 4 }}
3552
- >
3553
- <Button
3554
- aria-label="Scroll to end"
3555
- onPointerDown={(event) => event.preventDefault()}
3556
- onClick={() => {
3557
- composerRef.current?.restoreAfterTimelineReachedEnd();
3558
- scrollToEnd(true);
3559
- }}
3560
- className="pointer-events-auto"
3561
- size="xs"
3562
- variant="glass"
3563
- >
3564
- <ChevronDownIcon className="size-3.5" />
3565
- Scroll to end
3566
- </Button>
3567
- </div>
3464
+ <ScrollToEndButton
3465
+ bottom={scrollToEndClearance + 4}
3466
+ onScrollToEnd={() => {
3467
+ composerRef.current?.restoreAfterTimelineReachedEnd();
3468
+ scrollToEnd(true);
3469
+ }}
3470
+ />
3471
)}
3472
</div>
3473
apps/web/src/components/chat/PanelLayoutControls.tsx
+53
-1
@@ -1,7 +1,9 @@
1
import { PanelBottomIcon, PanelRightIcon, SquareMenuIcon } from "lucide-react";
2
import { Maximize2, Minimize2 } from "lucide";
3
import { MorphIcon } from "~/components/MorphIcon";
4
-import { memo, type ReactElement } from "react";
4
+import { memo, type ReactElement, type ReactNode } from "react";
5
+
6
+import { cn } from "~/lib/utils";
7
8
import type { ThreadPanelPresentation } from "../../rightPanelLayout";
9
import { PopoverCreateHandle, PopoverTrigger } from "../ui/popover";
@@ -160,3 +162,53 @@ export const RightPanelMaximizeControl = memo(function RightPanelMaximizeControl
162
</Tooltip>
163
);
164
});
165
+
166
+/** The thread panel toggle on a header whose right side the inline right panel covers. */
167
+export function ThreadPanelHeaderControl(props: PanelLayoutControlsProps) {
168
+ return (
169
+ <div
170
+ className="absolute top-[var(--workspace-controls-top)] right-[calc(env(safe-area-inset-right)+0.75rem)] z-50 flex h-[var(--workspace-topbar-height)] items-center [-webkit-app-region:no-drag]"
171
+ data-workspace-titlebar-controls
172
+ >
173
+ <PanelLayoutControls {...props} showTerminalControl={false} showRightPanelControl={false} />
174
+ </div>
175
+ );
176
+}
177
+
178
+/** The window's top-right panel controls, with the maximize toggle while the panel is open. */
179
+export function WorkspaceTitlebarControls(props: {
180
+ readonly showMaximizeControl: boolean;
181
+ readonly rightPanelOpen: boolean;
182
+ readonly animationsActive: boolean;
183
+ readonly maximized: boolean;
184
+ readonly onToggleMaximized: () => void;
185
+ readonly children: ReactNode;
186
+}) {
187
+ return (
188
+ <div
189
+ className="pointer-events-none fixed top-[var(--workspace-controls-top)] right-[var(--workspace-controls-right)] z-50 mr-px flex h-[var(--workspace-topbar-height)] items-center gap-1 [-webkit-app-region:no-drag]"
190
+ data-workspace-titlebar-controls
191
+ >
192
+ {props.showMaximizeControl ? (
193
+ <span
194
+ aria-hidden={!props.rightPanelOpen}
195
+ className={cn(
196
+ "flex shrink-0",
197
+ props.animationsActive &&
198
+ "motion-safe:transition-opacity motion-safe:duration-(--panel-animation-duration) motion-safe:ease-out",
199
+ props.rightPanelOpen
200
+ ? "pointer-events-auto opacity-100"
201
+ : "pointer-events-none absolute right-full mr-1 opacity-0",
202
+ )}
203
+ inert={!props.rightPanelOpen}
204
+ >
205
+ <RightPanelMaximizeControl
206
+ maximized={props.maximized}
207
+ onToggle={props.onToggleMaximized}
208
+ />
209
+ </span>
210
+ ) : null}
211
+ <div className="pointer-events-auto flex h-full items-center">{props.children}</div>
212
+ </div>
213
+ );
214
+}
apps/web/src/components/chat/TimelineOverlays.tsx
new
+45
@@ -0,0 +1,45 @@
1
+import { ChevronDownIcon, PaperclipIcon } from "lucide-react";
2
+
3
+import { Button } from "../ui/button";
4
+
5
+export function WorkspaceFileDropOverlay() {
6
+ return (
7
+ <div
8
+ className="pointer-events-none absolute inset-2 z-40 flex items-center justify-center rounded-2xl border-2 border-dashed border-primary/60 bg-primary/[0.035]"
9
+ data-chat-workspace-drop-overlay="true"
10
+ >
11
+ <div
12
+ role="status"
13
+ className="flex items-center gap-2 rounded-full border border-primary/25 bg-background/95 px-4 py-2.5 text-sm font-medium text-foreground shadow-lg"
14
+ >
15
+ <PaperclipIcon className="size-4 text-primary" aria-hidden="true" />
16
+ Drop files to attach
17
+ </div>
18
+ </div>
19
+ );
20
+}
21
+
22
+/** Sits `bottom` pixels up, clear of the composer and its attached banners. */
23
+export function ScrollToEndButton(props: {
24
+ readonly bottom: number;
25
+ readonly onScrollToEnd: () => void;
26
+}) {
27
+ return (
28
+ <div
29
+ className="chat-scroll-to-bottom pointer-events-none absolute z-30 flex justify-center py-1.5"
30
+ style={{ bottom: props.bottom }}
31
+ >
32
+ <Button
33
+ aria-label="Scroll to end"
34
+ onPointerDown={(event) => event.preventDefault()}
35
+ onClick={props.onScrollToEnd}
36
+ className="pointer-events-auto"
37
+ size="xs"
38
+ variant="glass"
39
+ >
40
+ <ChevronDownIcon className="size-3.5" />
41
+ Scroll to end
42
+ </Button>
43
+ </div>
44
+ );
45
+}
apps/web/src/components/chat/usePasteToFocusComposer.ts
new
+53
@@ -0,0 +1,53 @@
1
+import { pasteTextToFocusComposer, shouldRedirectInputToComposer } from "./composerFocusRedirect";
2
+import { readPastedComposerContext } from "../composerInlineTokenPaste";
3
+import { isPasteAsTextShortcut } from "@t3tools/client-runtime/text-paste";
4
+import { useEffect, useRef } from "react";
5
+import { isMacPlatform } from "../../lib/utils";
6
+import { isCommandPaletteOpen } from "../../commandPaletteBus";
7
+import { getTerminalFocusOwner } from "../../lib/terminalFocus";
8
+import type { ThreadId } from "@t3tools/contracts";
9
+import type { ComposerHandleRef } from "../../composerHandleContext";
10
+/**
11
+ * Paste-to-focus: the resting composer blurs on a click into the timeline, so a paste that
12
+ * follows has no editable target and would be dropped. This sends it to the composer instead.
13
+ */
14
+export function usePasteToFocusComposer(
15
+ activeThreadId: ThreadId | null,
16
+ composerRef: ComposerHandleRef,
17
+) {
18
+ const pasteAsTextShortcutUntilRef = useRef(0);
19
+ useEffect(() => {
20
+ const keyHandler = (event: KeyboardEvent) => {
21
+ if (
22
+ shouldRedirectInputToComposer(event) &&
23
+ isPasteAsTextShortcut(event, isMacPlatform(navigator.platform))
24
+ ) {
25
+ pasteAsTextShortcutUntilRef.current = Date.now() + 1_000;
26
+ }
27
+ };
28
+ const handler = (event: ClipboardEvent) => {
29
+ if (!activeThreadId || isCommandPaletteOpen()) return;
30
+ if (getTerminalFocusOwner() !== null) return;
31
+ if (composerRef.current?.isModelPickerOpen()) return;
32
+ const text = pasteTextToFocusComposer(event);
33
+ const clipboardData = event.clipboardData;
34
+ if (text === null || clipboardData === null) return;
35
+ const bypassAutoAttachment = Date.now() <= pasteAsTextShortcutUntilRef.current;
36
+ pasteAsTextShortcutUntilRef.current = 0;
37
+ if (
38
+ ((readPastedComposerContext(clipboardData)?.records.length ?? 0) === 0 &&
39
+ composerRef.current?.pasteTextAtEnd(text, { bypassAutoAttachment })) ||
40
+ composerRef.current?.insertTextAtEnd(text, { clipboardData })
41
+ ) {
42
+ event.preventDefault();
43
+ event.stopPropagation();
44
+ }
45
+ };
46
+ window.addEventListener("keydown", keyHandler, true);
47
+ window.addEventListener("paste", handler, true);
48
+ return () => {
49
+ window.removeEventListener("keydown", keyHandler, true);
50
+ window.removeEventListener("paste", handler, true);
51
+ };
52
+ }, [activeThreadId, composerRef]);
53
+}