MCPcopy Create free account
hub / github.com/MoonshotAI/kimi-code / handleAddDirChoice

Function handleAddDirChoice

apps/kimi-code/src/tui/commands/add-dir.ts:59–91  ·  view source on GitHub ↗
(
  host: SlashCommandHost,
  sessionId: string,
  path: string,
  choice: AddDirChoice,
)

Source from the content-addressed store, hash-verified

57}
58
59async 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}

Callers 1

handleAddDirCommandFunction · 0.85

Calls 6

restoreEditorMethod · 0.65
showStatusMethod · 0.65
showErrorMethod · 0.65
setAppStateMethod · 0.65
addAdditionalDirMethod · 0.45

Tested by

no test coverage detected