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

Function executeImmediateCommand

source code/screens/REPL.tsx:3210–3280  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

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