Skip to content

Fix missing recent replies with OpenCode 2.4 - #203

Merged
backnotprop merged 8 commits into
plannotator:mainfrom
mxl:fix/opencode-24-reply-history
Nov 25, 2026
Merged

backnotprop merged 8 commits into
plannotator:mainfrom
mxl:fix/opencode-24-reply-history

Conversation

@mxl

@mxl mxl commented Nov 24, 2026

Copy link
Copy Markdown
Contributor

Problem

With OpenCode 2.4, plannotator-tui last --host opencode and Herdr's reply picker skip recent replies or report that there are no assistant messages. OpenCode now stores assistant text in session_part rows while session_message.data.content can be empty. A resumed session can contain both formats.

Change

  • Read visible inline text first, then fall back to that reply's text parts in ordinal order. A reply stored in both formats appears only once.
  • Keep the database read-only and preserve support for older OpenCode databases, message metadata, and reply limits.
  • Add SQLite regression tests for mixed history, part ordering, filtering, and malformed part data. Separate the reader, payload parsing, and part lookup into private modules without changing the public API.

Verification

  • cargo test --workspace (1,242 passed)
  • cargo clippy --workspace --all-targets
  • cargo fmt --all --check
  • last --host opencode --session-id <id> --print returns the recent reply from an affected OpenCode 2.4.1 session.
  • Manual Herdr shortcut verification (Ctrl+B, then Shift+O) with the patched plugin binary.

mxl and others added 8 commits November 24, 2026 17:37
OpenCode 2.4 writes each part as its own session_part row and leaves the
assistant payload's content empty, so the reply list showed nothing for new
sessions and lost the newest replies on resumed ones.

Decide the source per reply: text in session_message.data.content wins, and a
reply without visible text falls back to its text parts in ordinal order.
The part table is checked once per read and its statement reused per message;
a database without the table still reads the payload alone.
A part row that will not parse was silently dropped, so a reply could vanish
without a word. The part reader now fails with the operation, session, message
and database path, while a message payload that will not parse stays skipped as
before: it was never selected for its parts, and one bad row must not hide the
session.

The module outgrew one file, so it splits by responsibility: session picking,
the two message readers, the 2.4 part reader, and the shared payload rules that
decide what counts as reply text for every source. The public surface is
unchanged.

The mixed fixture test asserted order, dedup, identity and the limit at once, so
a failure named none of them. Each invariant now has its own test, and the
fixtures moved to a shared module. The part fixture also covers an ignored part
and a reasoning part beside a text part.
…le parts

Its query filters with json_extract, which fails the read on a malformed part row.
A session whose replies all carry payload text no longer depends on the
session_part columns, so a later change to that table cannot break it.

@backnotprop backnotprop left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for tracking this down and fixing it so thoroughly. Reading the reply text from OpenCode 2.4's session_part rows while keeping older databases read-only and unchanged is the right approach, and the mixed-history tests make it easy to trust. I pushed a few small maintainer commits (the design notes moved into docs/decisions.md, and the part query is prepared on first use). Going out in 0.11.8.

@backnotprop
backnotprop added this pull request to the merge queue Nov 25, 2026
Merged via the queue into plannotator:main with commit 2032de1 Nov 25, 2026
3 checks passed
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.

2 participants