MCPcopy Create free account
hub / github.com/WJX20/claude-code / executeImmediateCommand

Function executeImmediateCommand

src/screens/REPL.tsx:3212–3282  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

3210
3211 // Execute the command directly
3212 const executeImmediateCommand = async (): Promise<void> => {
3213 let doneWasCalled = false;
3214 const onDone = (result?: string, doneOptions?: {
3215 display?: CommandResultDisplay;
3216 metaMessages?: string[];
3217 }): void => {
3218 doneWasCalled = true;
3219 setToolJSX({
3220 jsx: null,
3221 shouldHidePromptInput: false,
3222 clearLocalJSX: true
3223 });
3224 const newMessages: MessageType[] = [];
3225 if (result && doneOptions?.display !== 'skip') {
3226 addNotification({
3227 key: `immediate-${matchingCommand.name}`,
3228 text: result,
3229 priority: 'immediate'
3230 });
3231 // In fullscreen the command just showed as a centered modal
3232 // pane — the notification above is enough feedback. Adding
3233 // "❯ /config" + "⎿ dismissed" to the transcript is clutter
3234 // (those messages are type:system subtype:local_command —
3235 // user-visible but NOT sent to the model, so skipping them
3236 // doesn't change model context). Outside fullscreen the
3237 // transcript entry stays so scrollback shows what ran.
3238 if (!isFullscreenEnvEnabled()) {
3239 newMessages.push(createCommandInputMessage(formatCommandInputTags(getCommandName(matchingCommand), commandArgs)), createCommandInputMessage(`<${LOCAL_COMMAND_STDOUT_TAG}>${escapeXml(result)}</${LOCAL_COMMAND_STDOUT_TAG}>`));
3240 }
3241 }
3242 // Inject meta messages (model-visible, user-hidden) into the transcript
3243 if (doneOptions?.metaMessages?.length) {
3244 newMessages.push(...doneOptions.metaMessages.map(content => createUserMessage({
3245 content,
3246 isMeta: true
3247 })));
3248 }
3249 if (newMessages.length) {
3250 setMessages(prev => [...prev, ...newMessages]);
3251 }
3252 // Restore stashed prompt after local-jsx command completes.
3253 // The normal stash restoration path (below) is skipped because
3254 // local-jsx commands return early from onSubmit.
3255 if (stashedPrompt !== undefined) {
3256 setInputValue(stashedPrompt.text);
3257 helpers.setCursorOffset(stashedPrompt.cursorOffset);
3258 setPastedContents(stashedPrompt.pastedContents);
3259 setStashedPrompt(undefined);
3260 }
3261 };
3262
3263 // Build context for the command (reuses existing getToolUseContext).
3264 // Read messages via ref to keep onSubmit stable across message
3265 // updates — matches the pattern at L2384/L2400/L2662 and avoids
3266 // pinning stale REPL render scopes in downstream closures.
3267 const context = getToolUseContext(messagesRef.current, [], createAbortController(), mainLoopModel);
3268 const mod = await matchingCommand.load();
3269 const jsx = await mod.call(onDone, context, commandArgs);

Callers 1

REPLFunction · 0.85

Calls 2

createAbortControllerFunction · 0.85
loadMethod · 0.80

Tested by

no test coverage detected