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

Function executeImmediateCommand

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

Source from the content-addressed store, hash-verified

3238
3239 // Execute the command directly
3240 const executeImmediateCommand = async (): Promise<void> => {
3241 let doneWasCalled = false;
3242 const onDone = (result?: string, doneOptions?: {
3243 display?: CommandResultDisplay;
3244 metaMessages?: string[];
3245 }): void => {
3246 doneWasCalled = true;
3247 setToolJSX({
3248 jsx: null,
3249 shouldHidePromptInput: false,
3250 clearLocalJSX: true
3251 });
3252 const newMessages: MessageType[] = [];
3253 if (result && doneOptions?.display !== 'skip') {
3254 addNotification({
3255 key: `immediate-${matchingCommand.name}`,
3256 text: result,
3257 priority: 'immediate'
3258 });
3259 // In fullscreen the command just showed as a centered modal
3260 // pane — the notification above is enough feedback. Adding
3261 // "❯ /config" + "⎿ dismissed" to the transcript is clutter
3262 // (those messages are type:system subtype:local_command —
3263 // user-visible but NOT sent to the model, so skipping them
3264 // doesn't change model context). Outside fullscreen the
3265 // transcript entry stays so scrollback shows what ran.
3266 if (!isFullscreenEnvEnabled()) {
3267 newMessages.push(createCommandInputMessage(formatCommandInputTags(getCommandName(matchingCommand), commandArgs)), createCommandInputMessage(`<${LOCAL_COMMAND_STDOUT_TAG}>${escapeXml(result)}</${LOCAL_COMMAND_STDOUT_TAG}>`));
3268 }
3269 }
3270 // Inject meta messages (model-visible, user-hidden) into the transcript
3271 if (doneOptions?.metaMessages?.length) {
3272 newMessages.push(...doneOptions.metaMessages.map(content => createUserMessage({
3273 content,
3274 isMeta: true
3275 })));
3276 }
3277 if (newMessages.length) {
3278 setMessages(prev => [...prev, ...newMessages]);
3279 }
3280 // Restore stashed prompt after local-jsx command completes.
3281 // The normal stash restoration path (below) is skipped because
3282 // local-jsx commands return early from onSubmit.
3283 if (stashedPrompt !== undefined) {
3284 setInputValue(stashedPrompt.text);
3285 helpers.setCursorOffset(stashedPrompt.cursorOffset);
3286 setPastedContents(stashedPrompt.pastedContents);
3287 setStashedPrompt(undefined);
3288 }
3289 };
3290
3291 // Build context for the command (reuses existing getToolUseContext).
3292 // Read messages via ref to keep onSubmit stable across message
3293 // updates — matches the pattern at L2384/L2400/L2662 and avoids
3294 // pinning stale REPL render scopes in downstream closures.
3295 const context = getToolUseContext(messagesRef.current, [], createAbortController(), mainLoopModel);
3296 const mod = await matchingCommand.load();
3297 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