Skip to content

Make OpenCode E2E green again#967

Merged
Soph merged 6 commits intomainfrom
soph/opencode-fixing
Apr 17, 2026
Merged

Make OpenCode E2E green again#967
Soph merged 6 commits intomainfrom
soph/opencode-fixing

Conversation

@Soph
Copy link
Copy Markdown
Collaborator

@Soph Soph commented Apr 16, 2026

Summary

  • Make turn-start synchronous (callHookSync) so session state is initialized before fast mid-turn commits hit git hooks
  • Add fallback session/turn bootstrapping in message.updated for opencode run flows where message.part.updated fires too late
  • Backfill prompts from OpenCode transcript on turn-end when turn-start sent an empty prompt
  • Exclude agent-owned files (opencode.json, .opencode/) from session tracking via new ProtectedFilesProvider optional interface

Also handles #883

Test plan

  • New tests for sync turn-start dispatch
  • New tests for message.updated fallback (session-start and turn-start)
  • New test for prompt backfill from OpenCode transcript
  • New test for agent file exclusion in DetectFileChanges and FilterAndNormalizePaths
  • New tests for AllProtectedFiles() registry function
  • mise run check passes

Note

Medium Risk
Adjusts OpenCode hook dispatch timing and lifecycle prompt backfill, which can change when sessions/turns are recorded and what files/prompts are attributed to a checkpoint.

Overview
Makes OpenCode hook execution more reliable in fast/non-interactive flows by switching turn-start to synchronous dispatch, adding a message.updated fallback to emit session-start/turn-start early, and centralizing per-session state resets via resetSessionTracking.

Extends the OpenCode agent with PromptExtractor support and updates lifecycle turn-end handling to backfill missing prompt metadata from OpenCode export transcripts (and update session state accordingly).

Improves session file-change attribution by filtering out agent-owned paths (e.g. .opencode/... and opencode.json) from change detection/normalization, with new tests covering the updated behaviors.

Reviewed by Cursor Bugbot for commit 5472a59. Configure here.

Copilot AI review requested due to automatic review settings April 16, 2026 12:40
Copy link
Copy Markdown
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

Updates the OpenCode agent plugin so turn-start runs synchronously (blocking) to ensure session initialization completes before subsequent agent actions (and to avoid shutdown races), and adds a regression test to enforce the behavior.

Changes:

  • Switch turn-start dispatch from async callHook to blocking callHookSync.
  • Update plugin inline documentation to reflect the expanded sync-hook use case.
  • Add a unit test verifying turn-start is dispatched via callHookSync.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.

File Description
cmd/entire/cli/agent/opencode/hooks_test.go Adds a regression test asserting turn-start uses the sync hook path.
cmd/entire/cli/agent/opencode/entire_plugin.ts Changes turn-start hook dispatch to callHookSync and updates comments.

Comment thread cmd/entire/cli/agent/opencode/hooks_test.go
@Soph Soph changed the title block on turn-start in opencode plugin Make OpenCode E2E green again Apr 17, 2026
@Soph
Copy link
Copy Markdown
Collaborator Author

Soph commented Apr 17, 2026

@cursor review

Copy link
Copy Markdown

@cursor cursor bot left a comment

Choose a reason for hiding this comment

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

Cursor Bugbot has reviewed your changes and found 1 potential issue.

Fix All in Cursor

❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.

Comment @cursor review or bugbot run to trigger another review on this PR

Reviewed by Cursor Bugbot for commit 5472a59. Configure here.

Comment thread cmd/entire/cli/state_test.go Outdated
@Soph Soph marked this pull request as ready for review April 17, 2026 15:17
@Soph Soph requested a review from a team as a code owner April 17, 2026 15:17
Soph added 4 commits April 17, 2026 17:20
Entire-Checkpoint: 07fb7365eb59
Entire-Checkpoint: 0786501cea6f
Entire-Checkpoint: 9605eabc462d
Entire-Checkpoint: fc2bd7de6ad8
@Soph Soph force-pushed the soph/opencode-fixing branch 2 times, most recently from ef7dbe7 to 4dad9f6 Compare April 17, 2026 15:58
@Soph Soph force-pushed the soph/opencode-fixing branch from 4dad9f6 to 23e74ce Compare April 17, 2026 16:00
@Soph Soph enabled auto-merge April 17, 2026 17:17
@Soph Soph merged commit b08a1be into main Apr 17, 2026
9 checks passed
@Soph Soph deleted the soph/opencode-fixing branch April 17, 2026 17:20
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