( host: SlashCommandHost, sessionId: string, path: string, choice: AddDirChoice, )
| 57 | } |
| 58 | |
| 59 | async function handleAddDirChoice( |
| 60 | host: SlashCommandHost, |
| 61 | sessionId: string, |
| 62 | path: string, |
| 63 | choice: AddDirChoice, |
| 64 | ): Promise<void> { |
| 65 | host.restoreEditor(); |
| 66 | |
| 67 | if (choice === 'cancel') { |
| 68 | host.showStatus(`Did not add ${path} as a working directory.`); |
| 69 | return; |
| 70 | } |
| 71 | |
| 72 | const session = host.session; |
| 73 | if (session === undefined || session.id !== sessionId) { |
| 74 | host.showError(NO_ACTIVE_SESSION_MESSAGE); |
| 75 | return; |
| 76 | } |
| 77 | |
| 78 | try { |
| 79 | const result = await session.addAdditionalDir(path, { persist: choice === 'remember' }); |
| 80 | host.setAppState({ additionalDirs: result.additionalDirs }); |
| 81 | host.refreshSlashCommandAutocomplete(); |
| 82 | host.showStatus( |
| 83 | choice === 'remember' |
| 84 | ? `Added workspace directory:\n ${path}\n Saved to:\n ${result.configPath}` |
| 85 | : `Added workspace directory:\n ${path}\n For this session only`, |
| 86 | 'success', |
| 87 | ); |
| 88 | } catch (error) { |
| 89 | host.showError(error instanceof Error ? error.message : String(error)); |
| 90 | } |
| 91 | } |
no test coverage detected