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