diff --git a/packages/opencode/src/cli/cmd/tui/component/prompt/history.tsx b/packages/opencode/src/cli/cmd/tui/component/prompt/history.tsx index e55479c0267..e90503e9f52 100644 --- a/packages/opencode/src/cli/cmd/tui/component/prompt/history.tsx +++ b/packages/opencode/src/cli/cmd/tui/component/prompt/history.tsx @@ -9,6 +9,7 @@ import type { AgentPart, FilePart, TextPart } from "@opencode-ai/sdk/v2" export type PromptInfo = { input: string + mode?: "normal" | "shell" parts: ( | Omit | Omit diff --git a/packages/opencode/src/cli/cmd/tui/component/prompt/index.tsx b/packages/opencode/src/cli/cmd/tui/component/prompt/index.tsx index 941b383e649..1f21b7b4693 100644 --- a/packages/opencode/src/cli/cmd/tui/component/prompt/index.tsx +++ b/packages/opencode/src/cli/cmd/tui/component/prompt/index.tsx @@ -491,6 +491,9 @@ export function Prompt(props: PromptProps) { // Filter out text parts (pasted content) since they're now expanded inline const nonTextParts = store.prompt.parts.filter((part) => part.type !== "text") + // Capture mode before it gets reset + const currentMode = store.mode + if (store.mode === "shell") { sdk.client.session.shell({ sessionID, @@ -539,7 +542,10 @@ export function Prompt(props: PromptProps) { ], }) } - history.append(store.prompt) + history.append({ + ...store.prompt, + mode: currentMode, + }) input.extmarks.clear() setStore("prompt", { input: "", @@ -763,6 +769,7 @@ export function Prompt(props: PromptProps) { if (item) { input.setText(item.input) setStore("prompt", item) + setStore("mode", item.mode ?? "normal") restoreExtmarksFromParts(item.parts) e.preventDefault() if (direction === -1) input.cursorOffset = 0