( args: ReplQueryPreludeDispatchArgs, deps: ReplQueryPreludeDispatchDeps, )
| 33 | } |
| 34 | |
| 35 | export function dispatchReplQueryPrelude( |
| 36 | args: ReplQueryPreludeDispatchArgs, |
| 37 | deps: ReplQueryPreludeDispatchDeps, |
| 38 | ): void { |
| 39 | if (args.shouldQuery) { |
| 40 | const freshClients = deps.mergeClients( |
| 41 | deps.initialMcpClients, |
| 42 | deps.getDynamicMcpClients(), |
| 43 | ) |
| 44 | deps.handleQueryStart(freshClients) |
| 45 | const ideClient = deps.getConnectedIdeClient(freshClients) |
| 46 | if (ideClient) { |
| 47 | deps.closeOpenDiffs(ideClient) |
| 48 | } |
| 49 | } |
| 50 | |
| 51 | deps.maybeMarkProjectOnboardingComplete() |
| 52 | |
| 53 | if ( |
| 54 | deps.titleDisabled || |
| 55 | deps.sessionTitle || |
| 56 | deps.agentTitle || |
| 57 | deps.haikuTitleAttemptedRef.current |
| 58 | ) { |
| 59 | return |
| 60 | } |
| 61 | |
| 62 | const firstUserMessage = args.newMessages.find( |
| 63 | message => message.type === 'user' && !message.isMeta, |
| 64 | ) |
| 65 | const text = |
| 66 | firstUserMessage?.type === 'user' |
| 67 | ? deps.getContentText(firstUserMessage.message.content) |
| 68 | : null |
| 69 | |
| 70 | if ( |
| 71 | !text || |
| 72 | deps.syntheticBreadcrumbPrefixes.some(prefix => |
| 73 | text.startsWith(`<${prefix}>`), |
| 74 | ) |
| 75 | ) { |
| 76 | return |
| 77 | } |
| 78 | |
| 79 | deps.haikuTitleAttemptedRef.current = true |
| 80 | void deps.generateSessionTitle(text, new AbortController().signal).then( |
| 81 | title => { |
| 82 | if (title) { |
| 83 | deps.setHaikuTitle(title) |
| 84 | } else { |
| 85 | deps.haikuTitleAttemptedRef.current = false |
| 86 | } |
| 87 | }, |
| 88 | () => { |
| 89 | deps.haikuTitleAttemptedRef.current = false |
| 90 | }, |
| 91 | ) |
| 92 | } |
no test coverage detected