Skip to content

TUI: prompt history recall (Up) silently does nothing while the composer has text #45209

Closed

Description

@abkkkbb

Description

packages/tui/src/prompt/history.tsx:69-84 — pressing Up to recall a previous
prompt is a dead key whenever the composer contains any text:

move(direction: 1 | -1, input: string) {
  if (!store.history.length) return undefined
  const current = store.history.at(store.index)
  if (!current) return undefined
  if (current.input !== input && input.length) return   // ← bails here

In this module index === 0 means the live draft slot (append() resets to 0,
and store.index === 0 returning {input: "", parts: []} on line 82 confirms
it); negative indices address real entries from the end. But history.at(0) on
line 71 reads the array element — the oldest retained entry — not the draft.
So on the first Up press from a non-empty draft, the guard compares your typed
text against an entry from up to 50 prompts ago, never matches, and returns.
Nothing is recalled and there is no feedback.

Recall from an empty input works, which makes the failure look intermittent.

Two more things that suggest this isn't intentional:

  • Once you've recalled an entry and edited it, Down is now dead too (same guard,
    at(index) no longer matches the edited text) — you can't even get back to
    your draft. A coherent "don't clobber my draft" design wouldn't trap you there.
  • The guard shipped wholesale in the OpenTUI migration commit (96bdeb3c7b,
    opentui #2685) and was never touched since; no test covers move(), and every major
    shell allows Up with a non-empty input.

Is this guard intentional? If not, happy to send a small PR — skip the
comparison when store.index === 0 (nothing is being displayed yet), which also
unfreezes the edited-recall case above.

Plugins

No response

OpenCode version

dev + manually reproduced

Steps to reproduce

  1. Submit any prompt once so ~/.local/share/opencode/prompt-history.jsonl has an entry
  2. Open the TUI, type anything into the composer, e.g. git p
  3. Press Up twice (first press just moves the cursor to column 0, see
    component/prompt/index.tsx:875; the second invokes history.move)
  4. Nothing happens. Now clear the input and press Up — the last entry recalls fine

Screenshot and/or share link

No response

Operating System

Windows 11

Terminal

Windows Terminal

Activity

  1. simonklee commented on Aug 26, 2026

    @simonklee
    Member

    I think this is fixed in https://opencode.ai/v2/docs which we're working on releasing ASAP. Please re-open if you still have issue there.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions