fix: track opencode session switches - #2455
Conversation
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (2)
🚧 Files skipped from review as they are similar to previous changes (2)
📝 WalkthroughWalkthroughOpenCode now tracks the TUI-selected root session through a dedicated plugin. Installation manages the plugin and JSONC configuration. Terminal state distinguishes local selection from server activity and rejects unrelated session reports. ChangesOpenCode TUI session selection
Estimated code review effort: 4 (Complex) | ~45 minutes Sequence Diagram(s)sequenceDiagram
participant OpenCodeTUI
participant HerdrTUIPlugin
participant TerminalState
OpenCodeTUI->>HerdrTUIPlugin: Select root session
HerdrTUIPlugin->>TerminalState: Report unsequenced "select"
TerminalState->>TerminalState: Reconcile local session ownership
OpenCodeTUI->>TerminalState: Send server session activity
TerminalState-->>OpenCodeTUI: Reject mismatched session report
Possibly related PRs
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✨ Finishing Touches🧪 Generate unit tests (beta)
Comment |
There was a problem hiding this comment.
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
📒 Files selected for processing (5)
docs/next/CHANGELOG.mdsrc/integration/assets/opencode/herdr-agent-state.jssrc/integration/assets/opencode/herdr-agent-state.test.tssrc/integration/mod.rssrc/terminal/state.rs
Greptile SummaryThe PR separates OpenCode’s server-global activity reporting from TUI-local session selection so each pane retains the root conversation selected in its own TUI.
Confidence Score: 5/5The PR appears safe to merge. No blocking failure remains.
|
| Filename | Overview |
|---|---|
| src/integration/assets/opencode/herdr-tui-session.js | Adds polling and bounded retry logic that reports the root session selected by the local OpenCode TUI. |
| src/terminal/state.rs | Adds OpenCode-specific selection reconciliation and cross-talk suppression while retaining lifecycle sequencing. |
| src/integration/opencode_config.rs | Adds comment-preserving, idempotent management of the companion plugin entry in OpenCode’s TUI configuration. |
| src/integration/targets.rs | Installs, validates, and removes both OpenCode integration assets and their managed configuration. |
| src/integration/registry.rs | Marks an otherwise current OpenCode integration as needing repair when its TUI asset or configuration entry is missing. |
Sequence Diagram
sequenceDiagram
participant TUI as OpenCode TUI
participant Companion as TUI companion plugin
participant Herdr as Herdr pane API
participant State as TerminalState
participant ServerPlugin as OpenCode server plugin
TUI->>Companion: Select root conversation
Companion->>Herdr: "report_agent_session(source=select)"
Herdr->>State: Reanchor durable session identity
ServerPlugin->>Herdr: Report server-global activity
Herdr->>State: Route lifecycle update
State->>State: Ignore activity for another root
State-->>Herdr: Preserve TUI-selected session
Reviews (5): Last reviewed commit: "Merge branch 'master' into akbash/2450-o..." | Re-trigger Greptile
There was a problem hiding this comment.
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
📒 Files selected for processing (2)
src/integration/assets/opencode/herdr-agent-state.jssrc/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
bbcbfc7 to
c62f51c
Compare
There was a problem hiding this comment.
Actionable comments posted: 2
🧹 Nitpick comments (3)
src/integration/assets/opencode/herdr-tui-session.test.ts (1)
112-125: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low valueConsider covering the exhausted-retry branch.
SELECTION_RETRY_DELAYS_MShas three entries. After the last retry,herdr-tui-session.jssetsnextReportAttoNumber.POSITIVE_INFINITYand stops reporting the same selection. No test asserts that the reporting stops. A test that waits past the final delay and asserts a stable request count would lock in that boundary.src/terminal/state.rs (2)
1374-1375: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low valueConsider recording the stale session when a selection clears suppression.
selection_can_reconcileremoves the suppression entry for the source without inspectingsuppressed.reason. Every other removal site distinguishesHookClearfromProcessExit.clear_full_lifecycle_hook_suppression_for_detected_agentrecords the suppressedsession_refas a stale session before it drops aHookClearentry (lines 1098-1106). This path drops it silently, so a later report that carries the previous session ref is not filtered byfull_lifecycle_hook_report_matches_stale_session.The
opencode_cross_talkguard at lines 863-870 rejects that report while the process is present and the anchor differs, so the reachable exposure is small. Recording the stale session here would keep the two paths consistent.♻️ Suggested change
if selection_can_reconcile { - self.suppressed_full_lifecycle_hook_reports.remove(&source); + if let Some(suppressed) = self.suppressed_full_lifecycle_hook_reports.remove(&source) { + if let Some(suppressed_ref) = suppressed + .session_ref + .filter(|suppressed_ref| suppressed_ref != &session_ref) + { + self.remember_stale_full_lifecycle_hook_session( + source.clone(), + suppressed.agent_label, + suppressed_ref, + ); + } + } } else if full_lifecycle_source && unsequenced_selection {
4620-4656: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low valueConsider adding a boundary test for cross-talk while the process is absent.
opencode_cross_talkat lines 863-870 requiresprocess_present. When the process is absent, a report carrying a different session ref still reaches the buffering path at lines 906-953. That asymmetry is intentional, but no test pins it. A test that clears the detected agent and then sends a mismatched sequenced report would document the boundary.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro Plus
Run ID: aec6c888-df3f-48b4-b55f-1b0f88080b93
📒 Files selected for processing (16)
docs/next/CHANGELOG.mdjustfilesrc/agent_resume.rssrc/cli/integration.rssrc/integration/actions.rssrc/integration/assets/opencode/herdr-agent-state.jssrc/integration/assets/opencode/herdr-agent-state.test.tssrc/integration/assets/opencode/herdr-tui-session.jssrc/integration/assets/opencode/herdr-tui-session.test.tssrc/integration/mod.rssrc/integration/opencode_config.rssrc/integration/registry.rssrc/integration/targets.rssrc/integration/tests.rssrc/integration/types.rssrc/terminal/state.rs
🚧 Files skipped from review as they are similar to previous changes (2)
- docs/next/CHANGELOG.md
- src/integration/assets/opencode/herdr-agent-state.js
Summary
tui.jsoncentry without blocking OpenCode's config migrationValidation
just checkrefs #2450