@@ -93,15 +93,27 @@ export function RepoPage({ ws, projectDir, onBack }: Props) {
9393
9494 // ── Detect on mount ──────────────────────────────────────────────────────
9595
96+ const detectTimeoutRef = useRef < ReturnType < typeof setTimeout > | null > ( null ) ;
97+
9698 const doDetect = useCallback ( ( ) => {
9799 setDetectLoading ( true ) ;
98100 setDetectError ( null ) ;
99101 const rid = ws . repoDetect ( projectDir ) ;
100102 detectReqRef . current = rid ;
101103 pendingRef . current . add ( rid ) ;
104+
105+ // Timeout: if no response within 10s, show error with debug info
106+ if ( detectTimeoutRef . current ) clearTimeout ( detectTimeoutRef . current ) ;
107+ detectTimeoutRef . current = setTimeout ( ( ) => {
108+ if ( detectReqRef . current === rid && pendingRef . current . has ( rid ) ) {
109+ pendingRef . current . delete ( rid ) ;
110+ setDetectError ( `Detect timeout — no response from daemon after 10s` ) ;
111+ setDetectLoading ( false ) ;
112+ }
113+ } , 10_000 ) ;
102114 } , [ ws , projectDir ] ) ;
103115
104- useEffect ( ( ) => { doDetect ( ) ; } , [ doDetect ] ) ;
116+ useEffect ( ( ) => { doDetect ( ) ; return ( ) => { if ( detectTimeoutRef . current ) clearTimeout ( detectTimeoutRef . current ) ; } ; } , [ doDetect ] ) ;
105117
106118 // ── Tab data fetching ────────────────────────────────────────────────────
107119
@@ -142,6 +154,7 @@ export function RepoPage({ ws, projectDir, onBack }: Props) {
142154 if ( msg . type === 'repo.detect_response' ) {
143155 if ( msg . requestId !== detectReqRef . current ) return ;
144156 pendingRef . current . delete ( msg . requestId ) ;
157+ if ( detectTimeoutRef . current ) clearTimeout ( detectTimeoutRef . current ) ;
145158 setContext ( mapDetectToContext ( ( msg as any ) . context ?? msg ) ) ;
146159 setDetectLoading ( false ) ;
147160 return ;
@@ -160,6 +173,7 @@ export function RepoPage({ ws, projectDir, onBack }: Props) {
160173 pendingRef . current . delete ( msg . requestId ) ;
161174 // Could be detect error or tab error
162175 if ( msg . requestId === detectReqRef . current ) {
176+ if ( detectTimeoutRef . current ) clearTimeout ( detectTimeoutRef . current ) ;
163177 setDetectError ( msg . error ) ;
164178 setDetectLoading ( false ) ;
165179 } else {
0 commit comments