Skip to content

fix(opencode): end sessions on quit via server.instance.disposed#584

Merged
Soph merged 2 commits intomainfrom
fix/opencode-session-end
Mar 3, 2026
Merged

fix(opencode): end sessions on quit via server.instance.disposed#584
Soph merged 2 commits intomainfrom
fix/opencode-session-end

Conversation

@peyton-alt
Copy link
Contributor

No description provided.

Copilot AI review requested due to automatic review settings March 3, 2026 00:11
@cursor
Copy link

cursor bot commented Mar 3, 2026

PR Summary

Low Risk
Low risk: adds a shutdown event handler to ensure session-end fires reliably on exit; main risk is potential duplicate/missed session-end if event ordering differs across OpenCode versions.

Overview
Ensures OpenCode sessions are explicitly ended when the process quits by handling the server.instance.disposed event and firing a synchronous session-end hook using the last tracked currentSessionID.

This also clears per-session in-memory state (seenUserMessages, messageStore, currentSessionID) during shutdown to avoid leaving stale tracking data.

Written by Cursor Bugbot for commit 5f2edd9. Configure here.

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR updates the OpenCode agent’s embedded plugin template so Entire reliably emits a session-end hook when OpenCode exits, ensuring sessions are properly closed even when the user quits (rather than explicitly deleting a session).

Changes:

  • Handle the server.instance.disposed OpenCode event to end the active session on shutdown.
  • Clear per-session in-memory tracking state before emitting session-end.
  • Use the synchronous hook invocation path for shutdown-time reliability.

@peyton-alt peyton-alt marked this pull request as ready for review March 3, 2026 00:49
@peyton-alt peyton-alt requested a review from a team as a code owner March 3, 2026 00:49
@Soph Soph merged commit dd3a0ac into main Mar 3, 2026
3 checks passed
@Soph Soph deleted the fix/opencode-session-end branch March 3, 2026 14:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

3 participants