Skip to content

fix: read OpenCode v2 session messages - #363

Merged
chattymin merged 1 commit into
chattymin:mainfrom
ilker-sahin:fix/opencode-v2-session-messages
Sep 28, 2026
Merged

chattymin merged 1 commit into
chattymin:mainfrom
ilker-sahin:fix/opencode-v2-session-messages

Conversation

@ilker-sahin

@ilker-sahin ilker-sahin commented Sep 26, 2026 •

Copy link
Copy Markdown
Contributor

Summary

OpenCode v2 writes assistant usage to session_message, while PokeTokenBar currently reads only the legacy message projection. This leaves new V2 usage at zero. Read indexed V2 assistant rows, map their nested model and separate reasoning fields, and merge them with legacy V1 usage.

Type of change

  • Bug fix
  • New feature
  • Refactor / cleanup
  • Documentation
  • Other:

Checklist

  • swift build and swift test pass locally
    • Attempted, but SwiftPM failed before compiling source: the active Command Line Tools toolchain could not link the package manifest (PackageDescription.Package.__allocating_init(...defaultLocalization...) unresolved).
  • PR title and description are written in English
  • No UI changes; UI section omitted
  • No copyrighted assets, secrets, or private tooling references are committed
  • Tests were added for V2 storage and V1/V2 merging

Validation: GitHub Actions passed build-test (including swift build and the full test/coverage gate) and secret-scan. A manual smoke test using the patched build and OpenCode v2 displayed nonzero OpenCode usage in the menu-bar popover. Local git diff --check and Swift frontend syntax parsing also passed.

@ilker-sahin
ilker-sahin force-pushed the fix/opencode-v2-session-messages branch from 7bc33ae to f94111a Compare September 26, 2026 20:22
@ilker-sahin
ilker-sahin marked this pull request as ready for review September 26, 2026 20:33
@chattymin
chattymin merged commit 3ea40af into chattymin:main Sep 28, 2026
4 checks passed
@chattymin

Copy link
Copy Markdown
Owner

Thank you for your contribution!

Strongorange added a commit to Strongorange/PokeTokenBar-windows that referenced this pull request Oct 19, 2026
Port macOS chattymin#363: OpenCode v2 writes assistant usage to the event-sourced
session_message projection (nested model {id, providerID}, tokens carry
no total, reasoning folds into output). The reader now queries both
projections and merges them keep-max, so a v2 install no longer reports
zero usage while v1 history keeps flowing. A v1 database without the
session_message table skips the second query quietly.

Also matches the macOS v1 parser contract: an explicit non-assistant
role disqualifies a message row, but early history rows without any
role field still parse (found by the ported fixture test — our previous
hard role requirement dropped them).
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