@@ -15,7 +15,6 @@ import {
1515 type ServerProviderStatus ,
1616 type ThreadId ,
1717 type TurnId ,
18- type EditorId ,
1918 type KeybindingCommand ,
2019 OrchestrationThreadActivity ,
2120 ProviderInteractionMode ,
@@ -153,6 +152,7 @@ import { ComposerPromptEditor, type ComposerPromptEditorHandle } from "./Compose
153152import { PullRequestThreadDialog } from "./PullRequestThreadDialog" ;
154153import { MessagesTimeline } from "./chat/MessagesTimeline" ;
155154import { ChatHeader } from "./chat/ChatHeader" ;
155+ import { useCodeViewerStore } from "~/codeViewerStore" ;
156156import { PreviewPanel } from "./PreviewPanel" ;
157157import { ContextWindowMeter } from "./chat/ContextWindowMeter" ;
158158import { buildExpandedImagePreview , ExpandedImagePreview } from "./chat/ExpandedImagePreview" ;
@@ -196,7 +196,6 @@ const IMAGE_ONLY_BOOTSTRAP_PROMPT =
196196const EMPTY_ACTIVITIES : OrchestrationThreadActivity [ ] = [ ] ;
197197const EMPTY_KEYBINDINGS : ResolvedKeybindingsConfig = [ ] ;
198198const EMPTY_PROJECT_ENTRIES : ProjectEntry [ ] = [ ] ;
199- const EMPTY_AVAILABLE_EDITORS : EditorId [ ] = [ ] ;
200199const EMPTY_PROVIDER_STATUSES : ServerProviderStatus [ ] = [ ] ;
201200const EMPTY_PENDING_USER_INPUT_ANSWERS : Record < string , PendingUserInputDraftAnswer > = { } ;
202201
@@ -1149,7 +1148,6 @@ export default function ChatView({ threadId }: ChatViewProps) {
11491148 [ nonPersistedComposerImageIds ] ,
11501149 ) ;
11511150 const keybindings = serverConfigQuery . data ?. keybindings ?? EMPTY_KEYBINDINGS ;
1152- const availableEditors = serverConfigQuery . data ?. availableEditors ?? EMPTY_AVAILABLE_EDITORS ;
11531151 const providerStatuses = serverConfigQuery . data ?. providers ?? EMPTY_PROVIDER_STATUSES ;
11541152 const activeProviderStatus = useMemo (
11551153 ( ) => providerStatuses . find ( ( status ) => status . provider === selectedProvider ) ?? null ,
@@ -1200,6 +1198,22 @@ export default function ChatView({ threadId }: ChatViewProps) {
12001198 } ) ;
12011199 } , [ diffOpen , navigate , threadId ] ) ;
12021200
1201+ const toggleCodeViewer = useCodeViewerStore ( ( state ) => state . toggle ) ;
1202+ const pendingContext = useCodeViewerStore ( ( state ) => state . pendingContext ) ;
1203+ const clearPendingContext = useCodeViewerStore ( ( state ) => state . clearPendingContext ) ;
1204+
1205+ // When Cmd+L is pressed in the code viewer, insert the @file:lines mention into the composer
1206+ useEffect ( ( ) => {
1207+ if ( ! pendingContext ) return ;
1208+ const { filePath, fromLine, toLine } = pendingContext ;
1209+ const mention =
1210+ fromLine === toLine ? `@${ filePath } :L${ fromLine } ` : `@${ filePath } :L${ fromLine } -L${ toLine } ` ;
1211+ const currentPrompt = prompt ;
1212+ const separator = currentPrompt . length > 0 && ! currentPrompt . endsWith ( " " ) ? " " : "" ;
1213+ setPrompt ( `${ currentPrompt } ${ separator } ${ mention } ` ) ;
1214+ clearPendingContext ( ) ;
1215+ } , [ pendingContext , clearPendingContext , prompt , setPrompt ] ) ;
1216+
12031217 const envLocked = Boolean (
12041218 activeThread &&
12051219 ( activeThread . messages . length > 0 ||
@@ -3842,7 +3856,6 @@ export default function ChatView({ threadId }: ChatViewProps) {
38423856 activeProject ? ( lastInvokedScriptByProjectId [ activeProject . id ] ?? null ) : null
38433857 }
38443858 keybindings = { keybindings }
3845- availableEditors = { availableEditors }
38463859 terminalAvailable = { activeProject !== undefined }
38473860 terminalOpen = { terminalState . terminalOpen }
38483861 terminalToggleShortcutLabel = { terminalToggleShortcutLabel }
@@ -3862,6 +3875,7 @@ export default function ChatView({ threadId }: ChatViewProps) {
38623875 onToggleDiff = { onToggleDiff }
38633876 onTogglePreview = { ( ) => togglePreviewOpen ( activeThread . id ) }
38643877 onTogglePreviewLayout = { ( ) => togglePreviewLayout ( activeThread . id ) }
3878+ onToggleCodeViewer = { toggleCodeViewer }
38653879 />
38663880 </ header >
38673881
0 commit comments