(host: SlashCommandHost)
| 158 | } |
| 159 | |
| 160 | export async function handleInitCommand(host: SlashCommandHost): Promise<void> { |
| 161 | const session = host.session; |
| 162 | if (host.state.appState.model.trim().length === 0 || session === undefined) { |
| 163 | host.showError(LLM_NOT_SET_MESSAGE); |
| 164 | return; |
| 165 | } |
| 166 | |
| 167 | host.deferUserMessages = true; |
| 168 | host.beginSessionRequest(); |
| 169 | try { |
| 170 | await session.init(); |
| 171 | host.track('init_complete'); |
| 172 | host.streamingUI.finalizeTurn((item) => { |
| 173 | host.sendQueuedMessage(session, item); |
| 174 | }); |
| 175 | } catch (error) { |
| 176 | if (isAbortError(error)) { |
| 177 | host.setAppState({ streamingPhase: 'idle' }); |
| 178 | host.resetLivePane(); |
| 179 | return; |
| 180 | } |
| 181 | const msg = error instanceof Error ? error.message : String(error); |
| 182 | host.failSessionRequest(`Init failed: ${msg}`); |
| 183 | } finally { |
| 184 | host.deferUserMessages = false; |
| 185 | } |
| 186 | } |
no test coverage detected