@@ -14,6 +14,7 @@ import { useUnreadTracking } from "./hooks/useUnreadTracking";
1414import { useAutoCompactContinue } from "./hooks/useAutoCompactContinue" ;
1515import { useWorkspaceStoreRaw , useWorkspaceRecency } from "./stores/WorkspaceStore" ;
1616import { ChatInput } from "./components/ChatInput/index" ;
17+ import type { ChatInputAPI } from "./components/ChatInput/types" ;
1718
1819import { useStableReference , compareMaps } from "./hooks/useStableReference" ;
1920import { CommandRegistryProvider , useCommandRegistry } from "./contexts/CommandRegistryContext" ;
@@ -55,12 +56,27 @@ function AppInner() {
5556 const isMobile = typeof window !== "undefined" && window . innerWidth <= 768 ;
5657 const [ sidebarCollapsed , setSidebarCollapsed ] = usePersistedState ( "sidebarCollapsed" , isMobile ) ;
5758 const defaultProjectPath = getFirstProjectPath ( projects ) ;
59+ const creationChatInputRef = useRef < ChatInputAPI | null > ( null ) ;
60+ const creationProjectPath = ! selectedWorkspace
61+ ? ( pendingNewWorkspaceProject ?? ( projects . size === 1 ? defaultProjectPath : null ) )
62+ : null ;
63+ const handleCreationChatReady = useCallback ( ( api : ChatInputAPI ) => {
64+ creationChatInputRef . current = api ;
65+ api . focus ( ) ;
66+ } , [ ] ) ;
67+
5868 const startWorkspaceCreation = useStartWorkspaceCreation ( {
5969 projects,
6070 setPendingNewWorkspaceProject,
6171 setSelectedWorkspace,
6272 } ) ;
6373
74+ useEffect ( ( ) => {
75+ if ( creationProjectPath ) {
76+ creationChatInputRef . current ?. focus ( ) ;
77+ }
78+ } , [ creationProjectPath ] ) ;
79+
6480 const handleToggleSidebar = useCallback ( ( ) => {
6581 setSidebarCollapsed ( ( prev ) => ! prev ) ;
6682 } , [ setSidebarCollapsed ] ) ;
@@ -569,12 +585,9 @@ function AppInner() {
569585 }
570586 />
571587 </ ErrorBoundary >
572- ) : pendingNewWorkspaceProject || ( projects . size === 1 && defaultProjectPath ) ? (
588+ ) : creationProjectPath ? (
573589 ( ( ) => {
574- const projectPath = pendingNewWorkspaceProject ?? defaultProjectPath ;
575- if ( ! projectPath ) {
576- return null ;
577- }
590+ const projectPath = creationProjectPath ;
578591 const projectName =
579592 projectPath . split ( "/" ) . pop ( ) ?? projectPath . split ( "\\" ) . pop ( ) ?? "Project" ;
580593 return (
@@ -584,6 +597,7 @@ function AppInner() {
584597 variant = "creation"
585598 projectPath = { projectPath }
586599 projectName = { projectName }
600+ onReady = { handleCreationChatReady }
587601 onWorkspaceCreated = { ( metadata ) => {
588602 // Add to workspace metadata map
589603 setWorkspaceMetadata ( ( prev ) => new Map ( prev ) . set ( metadata . id , metadata ) ) ;
0 commit comments