77 ArrowDownIcon ,
88 ArrowLeftIcon ,
99 ArrowUpIcon ,
10- FolderIcon ,
1110 MessageSquareIcon ,
1211 SettingsIcon ,
1312 SquarePenIcon ,
@@ -16,6 +15,7 @@ import {
1615 useDeferredValue ,
1716 useEffect ,
1817 useMemo ,
18+ useRef ,
1919 useState ,
2020 type KeyboardEvent ,
2121 type ReactNode ,
@@ -54,6 +54,7 @@ import {
5454 RECENT_THREAD_LIMIT ,
5555} from "./CommandPalette.logic" ;
5656import { CommandPaletteResults } from "./CommandPaletteResults" ;
57+ import { ProjectFavicon } from "./ProjectFavicon" ;
5758import { useServerKeybindings } from "../rpc/serverState" ;
5859import { resolveShortcutCommand } from "../keybindings" ;
5960import {
@@ -66,12 +67,15 @@ import {
6667} from "./ui/command" ;
6768import { Kbd , KbdGroup } from "./ui/kbd" ;
6869import { toastManager } from "./ui/toast" ;
70+ import { ComposerHandleContext , useComposerHandleContext } from "../composerHandleContext" ;
71+ import type { ChatComposerHandle } from "./chat/ChatComposer" ;
6972
7073export function CommandPalette ( { children } : { children : ReactNode } ) {
7174 const open = useCommandPaletteStore ( ( store ) => store . open ) ;
7275 const setOpen = useCommandPaletteStore ( ( store ) => store . setOpen ) ;
7376 const toggleOpen = useCommandPaletteStore ( ( store ) => store . toggleOpen ) ;
7477 const keybindings = useServerKeybindings ( ) ;
78+ const composerHandleRef = useRef < ChatComposerHandle | null > ( null ) ;
7579 const routeTarget = useParams ( {
7680 strict : false ,
7781 select : ( params ) => resolveThreadRouteTarget ( params ) ,
@@ -104,10 +108,15 @@ export function CommandPalette({ children }: { children: ReactNode }) {
104108 } , [ keybindings , terminalOpen , toggleOpen ] ) ;
105109
106110 return (
107- < CommandDialog open = { open } onOpenChange = { setOpen } >
108- { children }
109- < CommandPaletteDialog />
110- </ CommandDialog >
111+ < ComposerHandleContext . Provider value = { composerHandleRef } >
112+ < CommandDialog
113+ open = { open }
114+ onOpenChange = { setOpen }
115+ >
116+ { children }
117+ < CommandPaletteDialog />
118+ </ CommandDialog >
119+ </ ComposerHandleContext . Provider >
111120 ) ;
112121}
113122
@@ -131,6 +140,7 @@ function CommandPaletteDialog() {
131140function OpenCommandPaletteDialog ( ) {
132141 const navigate = useNavigate ( ) ;
133142 const setOpen = useCommandPaletteStore ( ( store ) => store . setOpen ) ;
143+ const composerHandleRef = useComposerHandleContext ( ) ;
134144 const [ query , setQuery ] = useState ( "" ) ;
135145 const deferredQuery = useDeferredValue ( query ) ;
136146 const isActionsOnly = deferredQuery . startsWith ( ">" ) ;
@@ -186,7 +196,13 @@ function OpenCommandPaletteDialog() {
186196 buildProjectActionItems ( {
187197 projects,
188198 valuePrefix : "project" ,
189- icon : < FolderIcon className = { ITEM_ICON_CLASS } /> ,
199+ icon : ( project ) => (
200+ < ProjectFavicon
201+ environmentId = { project . environmentId }
202+ cwd = { project . cwd }
203+ className = { ITEM_ICON_CLASS }
204+ />
205+ ) ,
190206 runProject : openProjectFromSearch ,
191207 } ) ,
192208 [ openProjectFromSearch , projects ] ,
@@ -197,7 +213,13 @@ function OpenCommandPaletteDialog() {
197213 buildProjectActionItems ( {
198214 projects,
199215 valuePrefix : "new-thread-in" ,
200- icon : < FolderIcon className = { ITEM_ICON_CLASS } /> ,
216+ icon : ( project ) => (
217+ < ProjectFavicon
218+ environmentId = { project . environmentId }
219+ cwd = { project . cwd }
220+ className = { ITEM_ICON_CLASS }
221+ />
222+ ) ,
201223 runProject : async ( project ) => {
202224 await startNewThreadInProjectFromContext (
203225 {
@@ -219,7 +241,13 @@ function OpenCommandPaletteDialog() {
219241 buildProjectActionItems ( {
220242 projects,
221243 valuePrefix : "new-fresh-thread-in" ,
222- icon : < FolderIcon className = { ITEM_ICON_CLASS } /> ,
244+ icon : ( project ) => (
245+ < ProjectFavicon
246+ environmentId = { project . environmentId }
247+ cwd = { project . cwd }
248+ className = { ITEM_ICON_CLASS }
249+ />
250+ ) ,
223251 runProject : async ( project ) => {
224252 await handleNewThread ( scopeProjectRef ( project . environmentId , project . id ) , {
225253 envMode : settings . defaultThreadEnvMode ,
@@ -301,29 +329,6 @@ function OpenCommandPaletteDialog() {
301329 } ) ;
302330 } ,
303331 } ) ;
304-
305- actionItems . push ( {
306- kind : "action" ,
307- value : "action:new-fresh-thread" ,
308- searchTerms : [ "new thread" , "chat" , "create" , settings . defaultThreadEnvMode ] ,
309- title : (
310- < >
311- New { settings . defaultThreadEnvMode } thread in{ " " }
312- < span className = "font-semibold" > { activeProjectTitle } </ span >
313- </ >
314- ) ,
315- icon : < SquarePenIcon className = { ITEM_ICON_CLASS } /> ,
316- shortcutCommand : "chat.newLocal" ,
317- run : async ( ) => {
318- await startNewLocalThreadFromContext ( {
319- activeDraftThread,
320- activeThread,
321- defaultThreadEnvMode : settings . defaultThreadEnvMode ,
322- handleNewThread,
323- projects,
324- } ) ;
325- } ,
326- } ) ;
327332 }
328333
329334 actionItems . push ( {
@@ -335,23 +340,6 @@ function OpenCommandPaletteDialog() {
335340 addonIcon : < SquarePenIcon className = { ADDON_ICON_CLASS } /> ,
336341 groups : [ { value : "projects" , label : "Projects" , items : projectThreadItems } ] ,
337342 } ) ;
338-
339- actionItems . push ( {
340- kind : "submenu" ,
341- value : "action:new-fresh-thread-in" ,
342- searchTerms : [
343- "new thread" ,
344- "project" ,
345- "pick" ,
346- "choose" ,
347- "select" ,
348- settings . defaultThreadEnvMode ,
349- ] ,
350- title : `New ${ settings . defaultThreadEnvMode } thread in...` ,
351- icon : < SquarePenIcon className = { ITEM_ICON_CLASS } /> ,
352- addonIcon : < SquarePenIcon className = { ADDON_ICON_CLASS } /> ,
353- groups : [ { value : "projects" , label : "Projects" , items : projectFreshThreadItems } ] ,
354- } ) ;
355343 }
356344
357345 actionItems . push ( {
@@ -410,6 +398,10 @@ function OpenCommandPaletteDialog() {
410398 aria-label = "Command palette"
411399 className = "overflow-hidden p-0"
412400 data-testid = "command-palette"
401+ finalFocus = { ( ) => {
402+ composerHandleRef ?. current ?. focusAtEnd ( ) ;
403+ return false ;
404+ } }
413405 >
414406 < Command
415407 key = { viewStack . length }
0 commit comments