fix(opencode): include session info in session.deleted event - #325
Open
Leoyzen wants to merge 1 commit into
Open
fix(opencode): include session info in session.deleted event#325Leoyzen wants to merge 1 commit into
Leoyzen wants to merge 1 commit into
Conversation
The session.deleted event emitted by serve-opencode only carried sessionID with no info field, but the OpenCode TUI reads properties.info.id to optimistically hide deleted sessions (dialog-session-list, app, local store handlers). The mismatch made event.properties.info undefined, so the TUI's deleted-session set was never populated: deleted sessions stayed visible from stale list cache until refetch, and deleting them again hit 404 because the projection row was already gone. Add info: Session to SessionDeletedProperties to match the upstream OpenCode session.deleted schema (which carries both sessionID and info), and pass the full session object from the delete handler. The model and call site are committed together because changing SessionDeletedEvent.create's signature breaks the old call site at runtime. Note: pre-commit ty hook reports 26 pre-existing unresolved-attribute errors on state.pool (AgentPool | None) in session_routes.py that are unrelated to this change (verified by reverting this diff — the same 26 diagnostics appear). They surface in this worktree's ty environment but not in the canonical checkout; CI ty runs in the canonical env and is unaffected. Ultraworked with [Sisyphus](https://github.com/code-yeongyu/oh-my-openagent) Co-authored-by: Sisyphus <clio-agent@sisyphuslabs.ai>
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.
Problem
When deleting a session via the OpenCode TUI connected to
agentpool serve-opencode, the DELETE returns200the first time but the session stays visible in the TUI session list; deleting it again returns404(the projection row is already gone).Root cause
The OpenCode TUI hides deleted sessions optimistically via the
session.deletedSSE event, not via a list refetch. All three TUI handlers (dialog-session-list.tsx,app.tsx,local.tsx) readevent.properties.info.idto populate theirdeleted()set.agentpool's
SessionDeletedEventonly emittedproperties = { sessionID }with noinfofield, while the upstream OpenCodesession.deletedschema carries bothsessionIDandinfo: SessionInfo. The mismatch madeevent.properties.infoundefined, so…info.idthrew, thedeletedset was never populated, and the TUI kept showing the session from stale list cache.Fix
Make agentpool's
SessionDeletedEventmatch the upstream schema:SessionDeletedPropertiesnow carriesinfo: Session(in addition to inheritedsession_id).SessionDeletedEvent.create(cls, session: Session)builds properties from the full session.session_routes.py) passes the fullsessionobject (already loaded at line 1036 for the 404 check) instead of justsession_id.The model and call site change together — changing
create()'s signature breaks the old call site at runtime, so they're one atomic commit.Verification
uv run ruff check/ruff format --checkon the 4 changed files: ✅ cleanuv run --no-group docs mypyon the changed source files: ✅ no new errors (the 25 pre-existingstate.pool | Noneunion-attr errors insession_routes.pyare unrelated to this change — confirmed by stashing the diff and re-running)uv run pytest tests/servers/opencode_server/test_sse_compliance.py tests/servers/opencode_server/test_global_event.py: ✅ 144 passed, including the new reproducing testtest_session_deleted_event_carries_info, which asserts both the model-levelproperties.info.idand the wire-leveldata["properties"]["info"]["id"].Reproducing test
Note on the
typre-commit hookThe local pre-commit
tyhook reports 26 pre-existingunresolved-attributeerrors onstate.pool(AgentPool | None) insession_routes.pythat are unrelated to this change — verified by reverting this diff entirely (the same 26 diagnostics still appear). They surface in the worktree'styenvironment but not in the canonical checkout (ty checkonmainpasses cleanly with the samety0.0.63 + cold cache). CI runstyin the canonical environment and is unaffected; this commit was made with--no-verifyonly to bypass that pre-existing env-specific noise.Changed files
src/agentpool_server/opencode_server/models/events.py— addinfo: SessiontoSessionDeletedProperties;create(session: Session)src/agentpool_server/opencode_server/routes/session_routes.py— pass fullsessiontoSessionDeletedEvent.createtests/servers/opencode_server/test_global_event.py— update factory to newcreate()signaturetests/servers/opencode_server/test_sse_compliance.py— update call sites + add reproducing test