Skip to content

fix: track opencode session switches - #2455

Open
akbash-bot wants to merge 3 commits into
masterfrom
akbash/2450-opencode-session-switch
Open

fix: track opencode session switches#2455
akbash-bot wants to merge 3 commits into
masterfrom
akbash/2450-opencode-session-switch

Conversation

@akbash-bot

Copy link
Copy Markdown
Collaborator

Summary

  • report an explicit OpenCode resume before lifecycle state when /session selects an existing conversation
  • allow the selected session to reanchor durable identity while preserving new-session and cross-talk guards
  • bump the managed OpenCode integration to v10 and add boundary regressions

Checks

  • bun test src/integration/assets/opencode/herdr-agent-state.test.ts
  • cargo test opencode_ --bin herdr
  • just ci equivalent: 3,248 tests passed; the isolated-target-incompatible live-handoff PID test was excluded, and the unrelated graphics timeout passed on focused rerun
  • just windows-lint
  • maintenance Python suite (93 tests)

refs #2450

@coderabbitai

coderabbitai Bot commented Aug 6, 2026

Copy link
Copy Markdown

Review Change Stack

Warning

Review limit reached

@akbash-bot, you've reached your PR review limit, so we couldn't start this review.

Next review available in: 47 minutes

Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available.
You're only billed for reviews past your plan's rate limits ($0.25/file).

How can I continue?

After more reviews become available, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews.

How do review limits work?

CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability.

For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window.

Please refer docs for additional details.

Review details
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro Plus

Run ID: 901ce6e3-6431-4feb-9e10-e5a2a74a7443

📥 Commits

Reviewing files that changed from the base of the PR and between 782e2f6 and bbcbfc7.

📒 Files selected for processing (1)
  • src/integration/assets/opencode/herdr-agent-state.test.ts
📝 Walkthrough

Walkthrough

OpenCode session reporting now distinguishes resumed sessions from new sessions. Terminal state accepts resume events and replaces the active lifecycle session. Tests cover report ordering, session sources, hook authority, state updates, and superseded-session rejection.

Changes

OpenCode session resume

Layer / File(s) Summary
Session reporting and classification
src/integration/assets/opencode/herdr-agent-state.js, src/integration/assets/opencode/herdr-agent-state.test.ts, src/integration/mod.rs
The integration records root sessions, reports resumed non-child sessions, updates its version, and tests report ordering and session-start sources.
Terminal resume lifecycle
src/terminal/state.rs, docs/next/CHANGELOG.md
Terminal state accepts "resume" as a session replacement trigger. Tests cover lifecycle replacement, hook authority, state updates, and rejected late reports. The changelog records native restore support.

Estimated code review effort: 3 (Moderate) | ~20 minutes

Sequence Diagram(s)

sequenceDiagram
  participant OpenCode
  participant herdr_agent_state as herdr-agent-state.js
  participant TerminalState
  OpenCode->>herdr_agent_state: Select existing session through /session
  herdr_agent_state->>TerminalState: Report session with resume source
  TerminalState->>TerminalState: Replace active lifecycle session
  OpenCode->>TerminalState: Send subsequent hook report
  TerminalState-->>OpenCode: Accept current session state
Loading

Possibly related PRs

  • herdrdev/herdr#2062: Extends related OpenCode session-state tracking and root/child lifecycle logic.
  • herdrdev/herdr#2194: Modifies agent session lifecycle handling around asynchronous reporting and session replacement.
  • herdrdev/herdr#2223: Modifies OpenCode native session restoration and resume handling.

Suggested labels: coderabbit-review

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly summarizes the main change: tracking OpenCode session switches.
Description check ✅ Passed The description directly explains the OpenCode session tracking changes, integration upgrade, tests, and issue reference.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches 💡 1
📝 Generate docstrings 💡
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch akbash/2450-opencode-session-switch

Comment @coderabbitai help to get the list of available commands.

@akbash-bot akbash-bot added the ai-review Trigger automated AI reviews for pull requests admitted by the PR gate label Aug 6, 2026

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Actionable comments posted: 1


ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro Plus

Run ID: 9dc12150-e42a-4e5c-b532-02d4ecce4fe4

📥 Commits

Reviewing files that changed from the base of the PR and between 69a07fd and 43f6e7f.

📒 Files selected for processing (5)
  • docs/next/CHANGELOG.md
  • src/integration/assets/opencode/herdr-agent-state.js
  • src/integration/assets/opencode/herdr-agent-state.test.ts
  • src/integration/mod.rs
  • src/terminal/state.rs

Comment thread src/integration/assets/opencode/herdr-agent-state.js
@greptile-apps

greptile-apps Bot commented Aug 6, 2026

Copy link
Copy Markdown

Greptile Summary

The PR teaches the OpenCode integration to report explicit session resumes when /session selects another conversation and permits those reports to reanchor the pane’s durable identity.

  • Tracks the currently reported root OpenCode session and emits pane.report_agent_session with a resume source before lifecycle state.
  • Accepts OpenCode resume as an authorized session-replacement source while retaining lifecycle and stale-session guards.
  • Bumps the managed OpenCode integration to version 10 and adds ordering and reanchoring regressions.

Confidence Score: 5/5

The PR appears safe to merge.

No blocking failure remains.

Important Files Changed

Filename Overview
src/integration/assets/opencode/herdr-agent-state.js Adds explicit resume reporting before lifecycle state when the root OpenCode session changes and updates the managed integration marker.
src/integration/assets/opencode/herdr-agent-state.test.ts Adds regression coverage for selected-session reporting, overlapping switches, and pending new-session reports.
src/terminal/state.rs Allows OpenCode resume reports to replace durable session identity and verifies lifecycle authority moves to the selected session.
src/integration/mod.rs Keeps the embedded OpenCode asset version synchronized at version 10.
docs/next/CHANGELOG.md Documents native restore tracking for conversations selected through OpenCode’s session command.

Sequence Diagram

sequenceDiagram
  participant U as User
  participant O as OpenCode
  participant P as Herdr plugin
  participant T as TerminalState
  U->>O: Select existing conversation with /session
  O->>P: chat.message(selected session ID)
  P->>P: Detect root-session ID change
  P->>T: "report_agent_session(source=resume)"
  T->>T: Reanchor durable session identity
  T->>T: Clear previous lifecycle authority
  P->>T: "report_agent(state=working)"
  T->>T: Grant lifecycle authority to selected session
  Note over T: Late reports from the previous session are rejected
Loading

Reviews (3): Last reviewed commit: "test: fail fast on missing opencode requ..." | Re-trigger Greptile

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Actionable comments posted: 1


ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro Plus

Run ID: c7ae0178-b40a-47ec-ba71-8dd4d1caf285

📥 Commits

Reviewing files that changed from the base of the PR and between 43f6e7f and 782e2f6.

📒 Files selected for processing (2)
  • src/integration/assets/opencode/herdr-agent-state.js
  • src/integration/assets/opencode/herdr-agent-state.test.ts
🚧 Files skipped from review as they are similar to previous changes (1)
  • src/integration/assets/opencode/herdr-agent-state.js

Comment thread src/integration/assets/opencode/herdr-agent-state.test.ts Outdated
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ai-review Trigger automated AI reviews for pull requests admitted by the PR gate

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant