feat(traces): stamp opencode's session title on session spans - #120
Open
Moep90 wants to merge 1 commit into
Open
feat(traces): stamp opencode's session title on session spans#120Moep90 wants to merge 1 commit into
Moep90 wants to merge 1 commit into
Conversation
Session spans carry the id only, and an id like ses_fcc85048effeCXe1RvEetcywD4 tells a reader nothing. opencode names every session from its first prompt and already ships that name in the session events, so the plugin can pass it on. session.created is emitted before the name exists, so the title arrives with session.updated a moment later. The handler records it and stamps it on the spans that are still open for that session, the subagent session span and the active run span, and handleRunStarted picks up a title that is already known for runs that start afterwards. Sessions opencode has not named carry no session.title at all, and an empty title never overwrites a known one. The map is bounded like the other per-session state and swept on session.idle. Signed-off-by: moep90 <volleyballlive@googlemail.com>
Moep90
force-pushed
the
feat/session-title
branch
from
August 24, 2026 14:45
f69d866 to
564d251
Compare
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.
What
Adds a
session.titlespan attribute carrying the name opencode gives a session.Session spans identify a run by id only. In a backend that reads as
ses_fcc85048effeCXe1RvEetcywD4, which says nothing about what the session was. opencode names every session from its first prompt and ships that name in its session events, so the plugin can pass it on for free.How
session.createdfires before opencode has named the session; the name arrives withsession.updateda moment later. So:handleSessionUpdated(new) records the title and stamps it on the spans still open for that session: the subagent session span and the active run span.handleRunStartedpicks up a title that is already known, for runs that start after the naming.handleSessionCreatedtakes the title if opencode already has one.The map is bounded with
setBoundedMaplike the other per-session state and swept insweepSessiononsession.idle. Sessions opencode has not named carry nosession.titleat all, and an empty title never overwrites a known one. Nothing is emitted whensessiontraces are disabled, though the title is still tracked so a later run span can use it.Verified
bun run lint,bun run typecheck,bun test— 334 pass, 0 fail (8 new tests).{"session.title": "session title check", "input.value": "\"Say exactly: session title check\""}which is opencode's own generated title for that session, matching the
titlecolumn in itsopencode.db.Notes
session.is_subagent,agent.type).OPENCODE_DISABLE_TRACES=sessionalready covers it.