Repository navigation
fix: read OpenCode v2 session messages - #363
Merged
chattymin merged 1 commit intoSep 28, 2026
Merged
Conversation
ilker-sahin
force-pushed
the
fix/opencode-v2-session-messages
branch
from
September 26, 2026 20:22
7bc33ae to
f94111a
Compare
ilker-sahin
marked this pull request as ready for review
September 26, 2026 20:33
Owner
|
Thank you for your contribution! |
7 of 10 tasks
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).
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
OpenCode v2 writes assistant usage to
session_message, while PokeTokenBar currently reads only the legacymessageprojection. 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
Checklist
swift buildandswift testpass locallyPackageDescription.Package.__allocating_init(...defaultLocalization...)unresolved).Validation: GitHub Actions passed
build-test(includingswift buildand the full test/coverage gate) andsecret-scan. A manual smoke test using the patched build and OpenCode v2 displayed nonzero OpenCode usage in the menu-bar popover. Localgit diff --checkand Swift frontend syntax parsing also passed.