1+ import { ScrollToEndButton , WorkspaceFileDropOverlay } from "./chat/TimelineOverlays" ;
2+ import { usePasteToFocusComposer } from "./chat/usePasteToFocusComposer" ;
13import {
24 deriveAvailableRevertTurnCounts ,
35 deriveThreadPendingBackgroundTasks ,
@@ -44,10 +46,6 @@ import { feedbackBannerItem } from "./chat/ComposerFeedback";
4446import { useUsageLimitsPanel } from "./chat/useUsageLimitsPanel" ;
4547import { useWorktreeSetup } from "./chat/useWorktreeSetup" ;
4648import { useChatShortcuts , type ChatShortcutHandler } from "./chat/useChatShortcuts" ;
47- import {
48- pasteTextToFocusComposer ,
49- shouldRedirectInputToComposer ,
50- } from "./chat/composerFocusRedirect" ;
5149import * as Schema from "effect/Schema" ;
5250import {
5351 AuthOrchestrationOperateScope ,
@@ -71,8 +69,6 @@ import {
7169 resolveIdleCompaction ,
7270 RuntimeMode ,
7371} from "@t3tools/contracts" ;
74- import { readPastedComposerContext } from "./composerInlineTokenPaste" ;
75- import { isPasteAsTextShortcut } from "@t3tools/client-runtime/text-paste" ;
7672import { useThreadActions } from "../hooks/useThreadActions" ;
7773import {
7874 deriveProviderSubagentStatus ,
@@ -111,7 +107,6 @@ import { useAtomValue } from "@effect/atom-react";
111107import { type SetStateAction , useEffect , useLayoutEffect , useRef , useState } from "react" ;
112108import { useLocation , useNavigate } from "@tanstack/react-router" ;
113109import { assistantCitationFromLocation } from "../lib/assistantCitationNavigation" ;
114- import { isMacPlatform } from "../lib/utils" ;
115110import type { AssistantCitationSourceAnchor } from "~/lib/assistantTextSelection" ;
116111import { useShallow } from "zustand/react/shallow" ;
117112import {
@@ -141,7 +136,6 @@ import { useWorkspaceMutationRefresh } from "../hooks/useWorkspaceMutationRefres
141136import { DEFAULT_INTERACTION_MODE , type ChatMessage } from "../types" ;
142137import { useTheme } from "../hooks/useTheme" ;
143138import { writeTextToClipboard } from "../hooks/useCopyToClipboard" ;
144- import { isCommandPaletteOpen } from "../commandPaletteBus" ;
145139import { settleAndAdvance } from "../settleAndAdvance" ;
146140import { subscribeSnapShotComposerFocus } from "../lib/desktopSnapShot" ;
147141import { useMediaQuery } from "../hooks/useMediaQuery" ;
@@ -177,7 +171,6 @@ import { makeWorkspaceFileDropHandlers } from "./chat/workspaceFileDrop";
177171import { isEditableFocused } from "../lib/editableFocus" ;
178172import { DEFAULT_RESOLVED_KEYBINDINGS } from "@t3tools/shared/keybindings" ;
179173import { shortcutLabelForCommand } from "../keybindings" ;
180- import { PaperclipIcon , ChevronDownIcon } from "lucide-react" ;
181174import { cn } from "~/lib/utils" ;
182175import { COLLAPSED_SIDEBAR_TITLEBAR_INSET_CLASS } from "~/workspaceTitlebar" ;
183176import { stackedThreadToast , toastManager } from "./ui/toast" ;
@@ -276,7 +269,8 @@ import { useOpenFavoriteEditorShortcut } from "./chat/OpenInPickerShortcut";
276269import {
277270 PanelLayoutControls ,
278271 type PanelLayoutControlsProps ,
279- RightPanelMaximizeControl ,
272+ ThreadPanelHeaderControl ,
273+ WorkspaceTitlebarControls ,
280274} from "./chat/PanelLayoutControls" ;
281275import type { ExpandedImagePreview } from "./chat/ExpandedImagePreview" ;
282276import { ThreadDetailsPanel } from "./chat/ThreadDetailsPanel" ;
@@ -348,7 +342,6 @@ import { readEnvironmentScope, readPreparedConnection } from "../state/session";
348342import { useAtomCommand } from "../state/use-atom-command" ;
349343import { useOrchestrationCommand } from "../state/use-orchestration-command" ;
350344import { useAtomQueryRunner } from "../state/use-atom-query-runner" ;
351- import { Button } from "./ui/button" ;
352345import { observeResize } from "~/lib/observeResize" ;
353346import { ThreadVisitWatermark } from "./chat/ThreadVisitWatermark" ;
354347import { ChatTerminalDrawers } from "./chat/ChatTerminalDrawers" ;
@@ -598,7 +591,6 @@ export default function ChatView(props: ChatViewProps) {
598591 const composerFilesRef = useRef < ComposerFileAttachment [ ] > ( [ ] ) ;
599592 const composerTerminalContextsRef = useRef < TerminalContextDraft [ ] > ( [ ] ) ;
600593 const branchToolbarRef = useRef < BranchToolbarHandle > ( null ) ;
601- const pasteAsTextShortcutUntilRef = useRef ( 0 ) ;
602594 const [ restingComposerControlsHost , setRestingComposerControlsHost ] =
603595 useState < HTMLDivElement | null > ( null ) ;
604596 const [ restingComposerControlsVisible , setRestingComposerControlsVisible ] = useState ( false ) ;
@@ -2868,42 +2860,7 @@ export default function ChatView(props: ChatViewProps) {
28682860 } ) ;
28692861 } , [ toggleRightPanelStable , toggleRightPanelMaximizedStable ] ) ;
28702862
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 ) ;
29072864 const {
29082865 onConfirmRevertStable,
29092866 onForkFromRunStable,
@@ -3255,46 +3212,17 @@ export default function ChatView(props: ChatViewProps) {
32553212 showThreadPanelControl = { ! inlineRightPanelOwnsTitleBar }
32563213 />
32573214 ) ;
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 } /> ;
32703216 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 }
32763223 >
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 >
32983226 ) ;
32993227 const workspaceFileDropHandlers = makeWorkspaceFileDropHandlers ( {
33003228 setDragActive : setIsWorkspaceFileDragActive ,
@@ -3382,20 +3310,7 @@ export default function ChatView(props: ChatViewProps) {
33823310 onDrop = { workspaceFileDropHandlers . onDrop }
33833311 >
33843312 < 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 }
33993314 < div className = "chat-banner-lane pointer-events-none absolute top-0 z-30 flex flex-col" >
34003315 < ProviderStatusBanner
34013316 status = { visibleProviderStatus }
@@ -3546,25 +3461,13 @@ export default function ChatView(props: ChatViewProps) {
35463461 />
35473462
35483463 { 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+ />
35683471 ) }
35693472 </ div >
35703473
0 commit comments