(host: SlashCommandHost, value: string)
| 329 | } |
| 330 | |
| 331 | async function applyEditorChoice(host: SlashCommandHost, value: string): Promise<void> { |
| 332 | const previous = host.state.appState.editorCommand ?? ''; |
| 333 | if (value === previous && value.length > 0) { |
| 334 | host.showStatus(`Editor unchanged: ${value.length > 0 ? value : 'auto-detect'}`); |
| 335 | return; |
| 336 | } |
| 337 | |
| 338 | const editorCommand = value.length > 0 ? value : null; |
| 339 | try { |
| 340 | await saveTuiConfig({ |
| 341 | ...currentTuiConfig(host), |
| 342 | editorCommand, |
| 343 | }); |
| 344 | } catch (error) { |
| 345 | host.showStatus( |
| 346 | `Failed to save editor: ${formatErrorMessage(error)}`, |
| 347 | 'error', |
| 348 | ); |
| 349 | return; |
| 350 | } |
| 351 | |
| 352 | host.setAppState({ editorCommand }); |
| 353 | host.showStatus( |
| 354 | value.length > 0 |
| 355 | ? `Editor set to "${value}".` |
| 356 | : 'Editor set to auto-detect ($VISUAL / $EDITOR).', |
| 357 | ); |
| 358 | } |
| 359 | |
| 360 | export function showModelPicker(host: SlashCommandHost, selectedValue: string = host.state.appState.model): void { |
| 361 | const entries = Object.entries(host.state.appState.availableModels); |
no test coverage detected