Skip to content

fix(terminal): Jump to Latest works in OpenCode Terminal panes (#843) - #1043

Merged
Juliusolsson05 merged 6 commits into
mainfrom
fix/opencode-jump-latest
Sep 19, 2026
Merged

Juliusolsson05 merged 6 commits into
mainfrom
fix/opencode-jump-latest

Conversation

@Juliusolsson05

Copy link
Copy Markdown
Owner

Part 2 of #843. Part 1, the mouse wheel after a remount, is #1041.

Why

OpenCode's TUI pages its transcript inside its own scrollbox on the alternate screen. xterm's scrollToBottom, which was all Jump to Latest did, could never move it.

The TUI's chord (Ctrl+Alt+G = messages_last) was tried and reverted: keybinds are user-configurable, and a supported config can put messages_undo (abort and revert) on that chord. See docs/superpowers/research/2026-09-08-post-merge-regression-audit.md D1.

Change

  • opencode-terminal-headless #3 (merged; the pointer is bumped here) adds jumpToLatest().
    • It posts /tui/execute-command {"command":"messages_last"} to the TUI's own authenticated server, below the keybind layer.
    • It was proven live against the installed 1.18.31. Seed 40 exchanges, page up (a control asserts the newest answer is gone), jump, and the newest answer is back.
    • session.last is accepted with 200 and does nothing. The route answers 200 for any string, so only the live test can tell the two apart.
  • App: an optional AgentSession.jumpToLatest(), SessionManager.jumpToLatest, IPC session:jumpToLatest, and preload.
    • It is a fixed request, never a command string from the renderer, because the route beneath it runs any TUI command.
    • OpencodeTerminalSession implements it.
    • useTerminalFollow calls onJumpToLatest once per new request (never for a mount or session-switch baseline), next to the existing scrollToBottom.
    • Inline TUIs (Claude, Codex) and shells keep their xterm scroll, and the provider call answers unsupported for them.
  • The command's description no longer tells OpenCode users to use their own keys.

Tests

  • terminalFollow.jump.renderer.test.tsx: exactly one provider jump per new request, none on mount or session switch.
  • sessionManager.screenGate.test.ts: routed to a session that implements it, unsupported otherwise, no-session for an unknown id.
  • The live proof is in the package: OpencodeTerminalHeadless.live.test.ts, opt-in.

npx tsc -b is clean.

🤖 Generated with Claude Code

Juliusolsson05 and others added 6 commits September 19, 2026 01:50
Only source and test changes, so package.json and the lockfile are
unchanged.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
#843)

- The follow hook asks the provider to jump exactly once per new request,
  and never for the baseline a mount or session switch takes.
- SessionManager routes the request to a session that implements
  jumpToLatest, answers unsupported for one that does not, and answers
  no-session for an unknown id.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
OpenCode's TUI pages its transcript on the alternate screen, so xterm's
scrollToBottom, the whole of Jump to Latest, could never move it. Its
chord was tried and reverted, because the binding is user-configurable
and a destructive action can sit on it.

A new optional AgentSession.jumpToLatest is reached through a fixed IPC
request (session:jumpToLatest), never a command string from the
renderer. OpencodeTerminalSession implements it through the package's
jumpToLatest, which runs messages_last on the TUI's own authenticated
server below the keybind layer. That was proven live against the
installed 1.18.31 in the package's opt-in test, where session.last is
accepted and ignored. The follow hook still scrolls xterm for inline TUIs
and shells, and every other provider answers unsupported. The command's
description no longer tells OpenCode users to use their own keys.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
CI caught it: AgentTerminalLeaf suites stub window.api without the new
jumpToLatest. The call threw inside the follow effect and broke the
pane's other follow behaviour (tail, pinning). It is optional-called now,
because a bridge without the method must not cost a pane its scrolling.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
# Conflicts:
#	src/main/sessionManager.screenGate.test.ts
@Juliusolsson05
Juliusolsson05 merged commit 479df7a into main Sep 19, 2026
2 checks passed
@Juliusolsson05
Juliusolsson05 deleted the fix/opencode-jump-latest branch September 19, 2026 09:48
Juliusolsson05 added a commit that referenced this pull request Sep 19, 2026
…1047

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant