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 f1ce2b6765..f3217fcbab 100644 --- a/packages/opencode/src/cli/cmd/tui/component/prompt/index.tsx +++ b/packages/opencode/src/cli/cmd/tui/component/prompt/index.tsx @@ -926,13 +926,7 @@ export function Prompt(props: PromptProps) { target: inputTarget, enabled: (() => { cursorVersion() - return ( - inputTarget() !== undefined && - !props.disabled && - !auto()?.visible && - input !== undefined && - (input.cursorOffset === 0 || input.visualCursor.visualRow === 0) - ) + return inputTarget() !== undefined && !props.disabled && !auto()?.visible && input !== undefined })(), commands: [ { @@ -941,12 +935,12 @@ export function Prompt(props: PromptProps) { category: "Prompt", run() { if (input.cursorOffset !== 0) { - input.cursorOffset = 0 - return + if (input.scrollY + input.visualCursor.visualRow === 0) input.cursorOffset = 0 + return false } const item = history.move(-1, input.plainText) - if (!item) return + if (!item) return false input.setText(item.input) setStore("prompt", item) setStore("mode", item.mode ?? "normal") @@ -964,13 +958,7 @@ export function Prompt(props: PromptProps) { target: inputTarget, enabled: (() => { cursorVersion() - return ( - inputTarget() !== undefined && - !props.disabled && - !auto()?.visible && - input !== undefined && - (input.cursorOffset === input.plainText.length || input.visualCursor.visualRow === input.height - 1) - ) + return inputTarget() !== undefined && !props.disabled && !auto()?.visible && input !== undefined })(), commands: [ { @@ -979,12 +967,16 @@ export function Prompt(props: PromptProps) { category: "Prompt", run() { if (input.cursorOffset !== input.plainText.length) { - input.cursorOffset = input.plainText.length - return + if ( + input.scrollY + input.visualCursor.visualRow === + Math.max(0, input.editorView.getTotalVirtualLineCount() - 1) + ) + input.cursorOffset = input.plainText.length + return false } const item = history.move(1, input.plainText) - if (!item) return + if (!item) return false input.setText(item.input) setStore("prompt", item) setStore("mode", item.mode ?? "normal") diff --git a/packages/opencode/src/cli/cmd/tui/routes/session/index.tsx b/packages/opencode/src/cli/cmd/tui/routes/session/index.tsx index b0b48ec42c..b2ee3af622 100644 --- a/packages/opencode/src/cli/cmd/tui/routes/session/index.tsx +++ b/packages/opencode/src/cli/cmd/tui/routes/session/index.tsx @@ -746,7 +746,7 @@ export function Session() { title: "Line up", value: "session.line.up", category: "Session", - enabled: false, + hidden: true, run: () => { scroll.scrollBy(-1) dialog.clear() @@ -756,7 +756,7 @@ export function Session() { title: "Line down", value: "session.line.down", category: "Session", - enabled: false, + hidden: true, run: () => { scroll.scrollBy(1) dialog.clear()