MCPcopy Index your code
hub / github.com/codeaashu/claude-code / call

Function call

src/commands/add-dir/add-dir.tsx:65–125  ·  view source on GitHub ↗
(onDone: LocalJSXCommandOnDone, context: LocalJSXCommandContext, args?: string)

Source from the content-addressed store, hash-verified

63 return t5;
64}
65export async function call(onDone: LocalJSXCommandOnDone, context: LocalJSXCommandContext, args?: string): Promise<React.ReactNode> {
66 const directoryPath = (args ?? '').trim();
67 const appState = context.getAppState();
68
69 // Helper to handle adding a directory (shared by both with-path and no-path cases)
70 const handleAddDirectory = async (path: string, remember = false) => {
71 const destination: PermissionUpdateDestination = remember ? 'localSettings' : 'session';
72 const permissionUpdate = {
73 type: 'addDirectories' as const,
74 directories: [path],
75 destination
76 };
77
78 // Apply to session context
79 const latestAppState = context.getAppState();
80 const updatedContext = applyPermissionUpdate(latestAppState.toolPermissionContext, permissionUpdate);
81 context.setAppState(prev => ({
82 ...prev,
83 toolPermissionContext: updatedContext
84 }));
85
86 // Update sandbox config so Bash commands can access the new directory.
87 // Bootstrap state is the source of truth for session-only dirs; persisted
88 // dirs are picked up via the settings subscription, but we refresh
89 // eagerly here to avoid a race when the user acts immediately.
90 const currentDirs = getAdditionalDirectoriesForClaudeMd();
91 if (!currentDirs.includes(path)) {
92 setAdditionalDirectoriesForClaudeMd([...currentDirs, path]);
93 }
94 SandboxManager.refreshConfig();
95 let message: string;
96 if (remember) {
97 try {
98 persistPermissionUpdate(permissionUpdate);
99 message = `Added ${chalk.bold(path)} as a working directory and saved to local settings`;
100 } catch (error) {
101 message = `Added ${chalk.bold(path)} as a working directory. Failed to save to local settings: ${error instanceof Error ? error.message : 'Unknown error'}`;
102 }
103 } else {
104 message = `Added ${chalk.bold(path)} as a working directory for this session`;
105 }
106 const messageWithHint = `${message} ${chalk.dim('· /permissions to manage')}`;
107 onDone(messageWithHint);
108 };
109
110 // When no path is provided, show AddWorkspaceDirectory input form directly
111 // and return to REPL after confirmation
112 if (!directoryPath) {
113 return <AddWorkspaceDirectory permissionContext={appState.toolPermissionContext} onAddDirectory={handleAddDirectory} onCancel={() => {
114 onDone('Did not add a working directory.');
115 }} />;
116 }
117 const result = await validateDirectoryForWorkspace(directoryPath, appState.toolPermissionContext);
118 if (result.resultType !== 'success') {
119 const message = addDirHelpMessage(result);
120 return <AddDirError message={message} args={args ?? ''} onDone={() => onDone(message)} />;
121 }
122 return <AddWorkspaceDirectory directoryPath={result.absolutePath} permissionContext={appState.toolPermissionContext} onAddDirectory={handleAddDirectory} onCancel={() => {

Callers

nothing calls this directly

Calls 3

addDirHelpMessageFunction · 0.85
onDoneFunction · 0.50

Tested by

no test coverage detected