Skip to content

feat(agents): add OpenCode 2 beta support - #21418

Merged
nwparker merged 12 commits into
mainfrom
nwparker/feature-add-support-for-opencode2
Sep 20, 2026
Merged

nwparker merged 12 commits into
mainfrom
nwparker/feature-add-support-for-opencode2

Conversation

@nwparker

@nwparker nwparker commented Sep 18, 2026 •

Copy link
Copy Markdown
Contributor
Files Added Deleted Net
Test 25 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​1167 $\color{#cf222e}{\Huge{\mathbf{−}}}$​60 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​1107
Prod 52 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​1182 $\color{#cf222e}{\Huge{\mathbf{−}}}$​120 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​1062

ELI5

Orca now treats the OpenCode 2 beta as a first-class agent. Users can discover and launch the side-by-side opencode2 binary, keep its sessions across tab lifetimes, see working/waiting/done status, resume past sessions, and use it for commit-message generation.

What changed

  • Added the opencode2 agent identity across desktop, telemetry, skills, resume commands, agent selection, and commit-message AI.
  • Added a dedicated OpenCode 2 config overlay and generated server plugin. The plugin uses OpenCode's supported server() / event({ event: { id, type, properties } }) contract rather than undocumented service files or an SSE side channel.
  • Mapped the current OpenCode 2 event families (session.next.*, permission.v2.*, and question.v2.*) into Orca's existing status, preview, permission, and question lifecycle.
  • Added bounded streamed-text accumulation, child-session filtering, separate local/WSL/SSH overlay paths, and preserved the OpenCode 1 plugin path unchanged.
  • Removed the unsupported service-discovery/SSE implementation and unrelated mobile, transcript, and worktree changes that had accumulated in the original PR.

Why

OpenCode's default TUI uses an in-process worker and loads server plugins from its config. Its current source defines the event hook and event schemas in ~/projects/opencode at commit 35075bb46692a921ab36715e5e1f4bf7f2def494. The integration therefore injects a plugin through the existing config-overlay path and keeps the existing Orca status pipeline, with fail-open behavior when a user's config or a remote relay cannot be materialized.

The relay changes are necessary because an SSH or WSL agent executes on another filesystem. The host must ship the generated plugin source over the relay wire, the guest must materialize it beside the user's config, and PTY exit must remove the matching OpenCode 1 or OpenCode 2 overlay. Local PTYs use the same overlay model directly on the host.

This incorporates useful direction from the reference PR while correcting its stale service/SSE assumptions. Xiro The Dev is credited as co-author in the implementation commit.

Linked issue

Fixes #14025

Visual proof

The prior screenshots were inadequate: they showed help/config output rather than the running agent. This replacement screenshot is from the real OpenCode source checkout launched as opencode2 inside Orca. The Orca tab title is OpenCode, confirming the interactive TUI process is running in the terminal pane:

https://github.com/user-attachments/assets/c6042ead-1874-4f12-858e-5a10fe1929d2

The supporting plugin-load proof remains below: OpenCode's own debug config output lists the generated orca-opencode2-status.js plugin and its load marker.

OpenCode 2 plugin loaded by the real source CLI

Testing

  • Focused OpenCode/relay/AI Vault/SSH suite: 20 files, 263 tests
  • Latest follow-up contract suite: 40 tests, including bounded OpenCode 2 text state, worker agent attribution, and question rejection resolving to SessionIdle
  • corepack pnpm tc:node
  • Targeted oxlint on changed integration, SSH, relay, and routing files
  • git diff --check
  • Generated plugin contract tests execute the OpenCode 1 and OpenCode 2 module shapes, permission events, admitted prompts, completed streamed text, and question blockers
  • OpenCode source reviewed repeatedly at the commit listed above
  • Installed dependencies in ~/projects/opencode and ran its actual CLI from the source checkout through Orca; debug config showed the generated orca-opencode2-status.js plugin and its load marker
  • Full pnpm lint, pnpm test, and pnpm build remain CI work

Review notes

Current head: 19474e64ef9. The current diff no longer contains the mobile compatibility, transcript catchup, worktree migration, or removed OpenCode 2 SSE/service files mentioned by older bot comments.

  • Local PTYs select the OpenCode 2 plugin and endpoint; OpenCode 1 continues to use /hook/opencode and its original overlay.
  • SSH and WSL relay installers now ship both plugin sources, materialize separate overlay roots, and clean both roots on PTY exit.
  • The plugin's streamed-text map is bounded to 128 message IDs and entries are removed at text completion.

@nwparker
nwparker force-pushed the nwparker/feature-add-support-for-opencode2 branch from 9d26f3d to db00f47 Compare September 18, 2026 08:38
@coderabbitai

coderabbitai Bot commented Sep 18, 2026 •

Copy link
Copy Markdown
Contributor

Review Change StackReview Change Stack

Note

Reviews paused

It looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the reviews.auto_review.auto_pause_after_reviewed_commits setting.

Use the following commands to manage reviews:

  • @coderabbitai resume to resume automatic reviews.
  • @coderabbitai review to trigger a single review.

Use the checkboxes below for quick actions:

  • ▶️ Resume reviews
  • 🔍 Trigger review
📝 Walkthrough

Walkthrough

The change adds OpenCode 2 as a supported agent. It updates agent configuration, labels, selection, resume handling, telemetry, commit-message commands, and hook routing. It adds separate OpenCode 2 hook plugins and relay overlays. It adds v2 channel-scoped SQLite discovery and parsing for AI Vault sessions. Tests cover agent behavior, hook events, overlay isolation, and SQLite session handling.

Priority: ➖ Normal

Merge Risk: 🟡 Moderate · up to 19474

OpenCode 2 can show stale working state while awaiting input, lose resumable session metadata, and omit prompt handling in supported flows. Schema variations can also reduce session discovery. Resolve these before merging.

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 26.67% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 105 functions across 73 files. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Linked Issues check ✅ Passed Issue #14025 requires native OpenCode 2 support in Orca, including terminal use and session management. The PR adds opencode2 to agent types, selection, PTY configuration, status handling, resume co…
Out of Scope Changes check ✅ Passed The reviewed change summary shows implementation and tests that support native OpenCode 2 integration for Issue #14025. The changes cover agent execution, session management, event handling, plugin re…
Title check ✅ Passed The title clearly and concisely describes the main change: adding OpenCode 2 beta support.
Description check ✅ Passed The description is mostly complete. It explains the user impact, implementation, motivation, linked issue, visual proof, testing, and review context. Some template sections, including AI Disclosure, A…
✨ Finishing Touches 💡 1
📝 Generate docstrings 💡
  • Commit to this branch
  • Create a new PR

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

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

@pullfrog pullfrog Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Caution

opencodeDiscoveries emits an undefined discovery entry on any host that has no OpenCode 2 beta database, and the scanner then throws TypeError: Cannot read properties of undefined (reading 'files') in sessionCandidatesFromDiscoveries. The AI Vault session scan breaks for every existing user who does not have the beta installed — this is the common path, not an edge case. The same root cause already fails two existing tests.

Reviewed changes

  • OpenCode 2 agent identity — added opencode2 across the TUI agent registry, renderer catalog, telemetry schemas, resume commands, skills keys, commit-message AI, terminal-title detection, and mobile agent metadata.
  • Daemon status ingestion — new src/main/opencode2/ service discovery, SSE consumer, event translator, and hook service, registered/cleared with the local PTY lifecycle and feeding the shared agent-status store.
  • AI Vault OpenCode 2 history — new session_v2/session_message SQLite reader and list leg, routed through the existing worker with an agent discriminator, plus opencode*.db name classification.
  • TUI transcript catchup teardown fix — unrelated to OpenCode 2: catchup now owns an abort controller, returns its signal, and settles cancellation; handoff/restart paths handle StructuredTuiCatchupStoppedError; new audit evidence under docs/audits/tui-transcript-acquisition/.
  • Worktree identity migration coverage — unrelated to OpenCode 2: migrateWorktreeIdentity now repoints closedTerminalTabTombstonesByTabId and clientHostedBrowserCloseIntentsByEnvironment rows, with a cross-version downgrade test.
  • Mobile web bundle compatibility wall — unrelated to OpenCode 2: evaluateMobileWebBundleCompat plus new blocked-verdict copy in ProtocolBlockScreen.

⚠️ This PR ships three workstreams unrelated to its title

The description frames the PR as OpenCode 2 support, but the diff also contains the TUI transcript catchup teardown rewrite, the worktree-identity migration coverage, and a new mobile web-bundle compatibility wall. Each is substantial on its own and none is mentioned in the PR body, so a reviewer approving "OpenCode 2" is also approving all of them, and a revert of the feature reverts them too. Please either split these into separate PRs or call each one out explicitly in the description with its own before/after so it gets a targeted review.

Technical details
# Unrelated workstreams bundled into a feature PR

## Affected sites
- `src/main/native-chat/agent-session-wire/structured-tui-transcript-catchup.ts` and the handoff/restart/teardown files — transcript catchup ownership change, documented by `docs/audits/tui-transcript-acquisition/`.
- `src/main/persistence/tracking-repos/worktree-identity-migration.ts` and `src/renderer/src/store/slices/worktrees/session/worktree-identity-rename-state.ts` — worktree rename row coverage, with `tests/e2e/cross-version-wire/cross-version-worktree-identity-downgrade.unit.test.ts`.
- `mobile/src/transport/mobile-web-bundle-compat.ts` and `mobile/src/components/ProtocolBlockScreen.tsx` — a new mobile update wall.

## Required outcome
- Each unrelated workstream is either split out or described in the PR body with its user-visible before/after and mechanism, so it is reviewable and independently revertible.

## Open questions for the human
- Are the catchup and worktree-identity changes prerequisites for OpenCode 2, or incidental commits picked up on this branch?

ℹ️ Nitpicks

  • src/shared/tui-agent-config.ts:132, src/main/opencode2/service-discovery.ts:8, and src/main/opencode2/hook-service.ts:25 reference docs/adr/0001-opencode2-separate-tui-agent.md and docs/adr/0002-opencode2-hooks-via-service-event-stream.md, but no docs/adr/ directory exists in the repo. Either add the ADRs (with the .gitignore allow-list entries) or drop the references.
  • In src/main/opencode2/event-translator.ts, every session.next.tool.* entry in TOOL_EVENTS is also in WORKING_EVENTS, and the WORKING_EVENTS check runs first, so those entries are unreachable; the two branches also build an identical payload. TOOL_EVENTS is effectively dead for the next events.

Pullfrog  | Fix all ➔ | Fix 👍s ➔ | View workflow run | Using DeepSeek Flash (free via Pullfrog for OSS) | 𝕏

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Actionable comments posted: 16

Caution

Some comments are outside the diff and can’t be posted inline due to GitHub limitations.

⚠️ Outside diff range comments (1)

🟠 Major · Recognize OpenCode 2 explicit prompts. · provider-event-routing.ts:96

src/shared/agent-hook-listener/provider-event-routing.ts:96
🎯 Functional Correctness | 🟠 Major | ⚡ Quick win

Recognize OpenCode 2 explicit prompts.

The OpenCode 2 translator emits user prompts as MessagePart with role_user_text. This condition accepts that shape for opencode and mimo-code, but not opencode2.

Add source === 'opencode2'. Otherwise prompt telemetry and prompt-bound permission behavior omit OpenCode 2 turns.


ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Advanced

Run ID: e6cae4e3-12a5-4694-8312-5ac4198962f7

📥 Commits

Reviewing files that changed from the base of the PR and between 1e7a697 and db00f474d90449edf6a5b72512d25c63cc03e2e4.

📒 Files selected for processing (77)
  • .github/workflows/pr.yml
  • README.md
  • docs/audits/tui-transcript-acquisition/README.md
  • docs/audits/tui-transcript-acquisition/fix.patch
  • docs/audits/tui-transcript-acquisition/reproduce.mjs
  • docs/audits/tui-transcript-acquisition/results.json
  • mobile/src/components/ProtocolBlockScreen.test.ts
  • mobile/src/components/ProtocolBlockScreen.tsx
  • mobile/src/diagnostics/use-mobile-web-bundle-probe.test.tsx
  • mobile/src/tasks/mobile-tui-agents.ts
  • mobile/src/transport/mobile-web-bundle-compat.test.ts
  • mobile/src/transport/mobile-web-bundle-compat.ts
  • mobile/src/transport/mobile-web-bundle-reply-schemas.test.ts
  • mobile/src/transport/mobile-web-bundle-reply-schemas.ts
  • src/main/agent-hooks/server-retired-pane-new-turn.test.ts
  • src/main/agent-hooks/server/server-ingest-terminal.ts
  • src/main/ai-vault/session-scanner-agent-parser.ts
  • src/main/ai-vault/session-scanner-opencode-sources.ts
  • src/main/ai-vault/session-scanner-opencode-sqlite-worker-client.ts
  • src/main/ai-vault/session-scanner-opencode-sqlite-worker-entry.ts
  • src/main/ai-vault/session-scanner-opencode-sqlite-worker-protocol.ts
  • src/main/ai-vault/session-scanner-opencode-sqlite-worker-spawn.ts
  • src/main/ai-vault/session-scanner-opencode2-sqlite-list.ts
  • src/main/ai-vault/session-scanner-opencode2-sqlite.test.ts
  • src/main/ai-vault/session-scanner-opencode2-sqlite.ts
  • src/main/ai-vault/session-scanner-parse-cache.ts
  • src/main/ai-vault/session-scanner-test-fixtures.ts
  • src/main/ai-vault/session-scanner.test.ts
  • src/main/ipc/pty/provider/local-configure.ts
  • src/main/ipc/pty/provider/state-cleanup.ts
  • src/main/native-chat/agent-session-wire/structured-agent-session-handoff-forward.ts
  • src/main/native-chat/agent-session-wire/structured-agent-session-handoff-restart-tui.ts
  • src/main/native-chat/agent-session-wire/structured-agent-session-handoff-restart.ts
  • src/main/native-chat/agent-session-wire/structured-agent-session-handoff-types.ts
  • src/main/native-chat/agent-session-wire/structured-agent-session-handoff.test.ts
  • src/main/native-chat/agent-session-wire/structured-agent-session-teardown-handoff-drain.test.ts
  • src/main/native-chat/agent-session-wire/structured-tui-transcript-catchup.ts
  • src/main/native-chat/agent-session-wire/structured-tui-transcript-ownership.test.ts
  • src/main/native-chat/agent-session-wire/structured-tui-transcript-teardown-test-fixture.ts
  • src/main/native-chat/agent-session-wire/structured-tui-transcript-teardown.test.ts
  • src/main/opencode2/event-translator.ts
  • src/main/opencode2/hook-service.test.ts
  • src/main/opencode2/hook-service.ts
  • src/main/opencode2/service-discovery.test.ts
  • src/main/opencode2/service-discovery.ts
  • src/main/opencode2/sse-consumer.ts
  • src/main/persistence/tracking-repos/worktree-identity-migration-field-coverage.test.ts
  • src/main/persistence/tracking-repos/worktree-identity-migration.ts
  • src/main/providers/local-pty-provider-types.ts
  • src/main/providers/local-pty-spawn-environment.ts
  • src/renderer/src/i18n/locales/en.json
  • src/renderer/src/lib/agent-catalog.tsx
  • src/renderer/src/lib/agent-status.ts
  • src/renderer/src/store/slices/worktrees/session/worktree-identity-rename-row-worktree-ids.test.ts
  • src/renderer/src/store/slices/worktrees/session/worktree-identity-rename-state.ts
  • src/shared/agent-hook-listener/provider-dispatch.ts
  • src/shared/agent-hook-listener/provider-event-routing.ts
  • src/shared/agent-hook-listener/providers/opencode-family-events.ts
  • src/shared/agent-hook-relay.ts
  • src/shared/agent-kind.ts
  • src/shared/agent-name-token-match.ts
  • src/shared/agent-session-resume.ts
  • src/shared/agent-type-label.ts
  • src/shared/ai-vault-resume-command.ts
  • src/shared/ai-vault-types.ts
  • src/shared/commit-message-agent-spec.test.ts
  • src/shared/commit-message-agent-specs-primary.ts
  • src/shared/opencode-database-name.ts
  • src/shared/skills-cli-agent-keys.ts
  • src/shared/source-control-ai-action-recipes.test.ts
  • src/shared/telemetry-property-schemas.ts
  • src/shared/terminal-title-agent-type.ts
  • src/shared/tui-agent-config.ts
  • src/shared/tui-agent-display-names.ts
  • src/shared/tui-agent-selection.ts
  • src/shared/tui-agent.ts
  • tests/e2e/cross-version-wire/cross-version-worktree-identity-downgrade.unit.test.ts

Included review availability: Your plan provides up to 10 included reviews per hour; 6 remain after this review.

import { tmpdir } from 'node:os'
import { join, resolve } from 'node:path'
import { fileURLToPath, pathToFileURL } from 'node:url'
import { applyPatch, parsePatch, reversePatch } from 'diff'

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🩺 Stability & Availability | 🟡 Minor | ⚡ Quick win

Declare the direct diff dependency.

Line 7 imports diff, but package.json does not declare it. The documented command can fail after a clean install when no dependency hoists this package.

Add diff to devDependencies.

const manifestSchema = z
.looseObject({
schemaVersion: z.literal(MOBILE_WEB_BUNDLE_SCHEMA_VERSION),
schemaVersion: z.number().int(),

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🎯 Functional Correctness | 🟠 Major | 🏗️ Heavy lift

Parse unsupported schemas as an envelope before validating the current schema.

schemaVersion now accepts a future version, but manifestSchema still requires the current protocol-window and manifest fields. If a valid future schema changes or removes one of those fields, mobileWebBundleManifestRead rejects the reply before evaluateMobileWebBundleCompat can return bundle-shell-too-old. The user then gets a transport error instead of the update block.

Parse schemaVersion first. Validate the full current shape only for supported versions. Add a future-schema fixture that omits a current-only field.

Based on learnings: validate only fields guaranteed across schema versions, and treat later-version fields as optional.

Source: Learnings

@@ -137,6 +139,7 @@ export abstract class AgentHookServerIngestTerminal extends AgentHookServerInges
tabId,
worktreeId,
connectionId,
...(event.providerSession ? { providerSession: event.providerSession } : {}),

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🗄️ Data Integrity & Integration | 🟠 Major | ⚡ Quick win

Give the reported provider session precedence.

preservedProviderSession is spread after event.providerSession, so the previous session overwrites a newly reported session. A pane that replaces an active OpenCode 2 session can retain the old resume ID.

Use event.providerSession ?? preservedProviderSession, or spread the reported value last.

}
return results
})()
return [discovery.then((results) => results[0]!), discovery.then((results) => results[1]!).catch(() => emptyOpenCode2Discovery(storageDir))]

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🩺 Stability & Availability | 🟠 Major | ⚡ Quick win

Return an empty OpenCode 2 discovery when no v2 database exists.

When v2Paths is empty, results contains only the v1 discovery. The second promise then fulfills with undefined; .catch() does not run. This violates the declared SessionFileDiscovery result contract and can make the scanner fail when it reads the discovery.

Proposed fix
       if (v2Paths.length > 0) {
         results.push(await discoverOpenCode2Sessions(storageDir, v2Paths, limit, issues))
+      } else {
+        results.push(emptyOpenCode2Discovery(storageDir))
       }

Comment thread src/main/opencode2/hook-service.ts Outdated
await cancelUnreadResponseBody(response)
throw new Error(`opencode2 service event stream failed: ${response.status}`)
}
this.controller = controller

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🩺 Stability & Availability | 🟠 Major | ⚡ Quick win

Track the stream before awaiting fetch.

this.controller remains null while fetch is pending. Another terminal registration can start a second stream, and teardown cannot abort the pending request.

Assign the controller before fetch. Clear it only when the same request fails or closes.

Comment thread src/main/opencode2/hook-service.ts Outdated
Comment on lines +200 to +207
if (event === 'session.text.delta') {
const lastIngest = this.lastTextIngestAtByPaneKey.get(paneKey) ?? 0
const now = Date.now()
if (now - lastIngest < TEXT_INGEST_THROTTLE_MS) {
return
}
this.lastTextIngestAtByPaneKey.set(paneKey, now)
} else if (event === 'session.text.ended') {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🚀 Performance & Scalability | 🟠 Major | ⚡ Quick win

Throttle current OpenCode text events.

The checks cover only session.text.delta and session.text.ended. Current session.next.text.delta events bypass the throttle and ingest every fragment.

Match both event families, for example with .endsWith('.text.delta') and .endsWith('.text.ended').

Comment thread src/main/opencode2/hook-service.ts Outdated

private findTerminalByDirectory(directory: string): OpenCode2TerminalRegistration | null {
for (const registration of this.terminals.values()) {
if (isSessionDirectoryInCwd(registration.cwd, directory)) {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🗄️ Data Integrity & Integration | 🟠 Major | 🏗️ Heavy lift

Do not attribute sessions by the first directory match.

If two OpenCode 2 panes use the same cwd, every session matches both registrations and this loop selects the oldest terminal. Prompts, status, and providerSession can then attach to the wrong pane.

Maintain a stable session-to-pane association. Also select the most specific path when nested working directories match.

Comment thread src/main/opencode2/sse-consumer.ts Outdated
Comment on lines +24 to +45
while (true) {
const { done, value } = await reader.read()
if (done) {
break
}
buffer += decoder.decode(value, { stream: true })
let lineEnd = buffer.indexOf('\n')
while (lineEnd !== -1) {
const line = buffer.slice(0, lineEnd).replace(/\r$/, '')
buffer = buffer.slice(lineEnd + 1)
if (line.startsWith('data:')) {
dataLines.push(line.slice(5).trimStart())
} else if (line.length === 0 && dataLines.length > 0) {
const payload = dataLines.join('\n')
dataLines = []
onEnvelope(payload)
}
lineEnd = buffer.indexOf('\n')
}
}
} catch {
// stream died; onClose handles the reconnect

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🩺 Stability & Availability | 🟠 Major | ⚡ Quick win

🔎 Supported by static analysis

🏁 Script executed:

sed -n '1,120p' src/main/opencode2/sse-consumer.ts
rg -n "consumeOpenCode2EventStream|parseOpenCode2SseEnvelope" src/main/opencode2

Repository: stablyai/orca

Length of output: 3635


Bound SSE line and event sizes in consumeOpenCode2EventStream. The consumer appends decoded daemon chunks to buffer until a newline arrives. It also stores every data: line in dataLines until a blank line arrives. A reachable malformed or oversized /api/event stream can therefore grow process memory without bound before onEnvelope runs. Enforce limits on the current line and the complete SSE event, and close or discard the stream when a limit is exceeded.

This limit belongs in src/main/opencode2/sse-consumer.ts. The event translator's per-message accumulator runs only after the consumer emits an envelope, so it cannot bound an unterminated SSE line or event.

Comment on lines +257 to +269
const nextClosedTombstones = repointRowRecord(
session.closedTerminalTabTombstonesByTabId,
oldWorktreeId,
newWorktreeId
)
if (nextClosedTombstones) {
session.closedTerminalTabTombstonesByTabId = nextClosedTombstones
sessionChanged = true
}
const nextCloseIntents = repointRowArrays(
session.clientHostedBrowserCloseIntentsByEnvironment,
oldWorktreeId,
newWorktreeId

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🗄️ Data Integrity & Integration | 🟠 Major | 🏗️ Heavy lift

Repair rows that use prior worktree identities.

The new row migration only matches the immediate oldWorktreeId. The cross-version test proves that an older build can strand these rows under a prior ID. A later current-build rename leaves them stale, so closed terminal tabs or browser pages can return.

  • src/main/persistence/tracking-repos/worktree-identity-migration.ts#L257-L269: Include applicable priorWorktreeIds, or add a load-time repair for stranded rows.
  • src/renderer/src/store/slices/worktrees/session/worktree-identity-rename-state.ts#L206-L210: Pass prior IDs to the renderer rename path, or consume already-repaired persisted state.
  • tests/e2e/cross-version-wire/cross-version-worktree-identity-downgrade.unit.test.ts#L169-L180: After the repair, expect both rows to use THIRD_ID instead of accepting OLD_ID.
📍 Affects 3 files
  • src/main/persistence/tracking-repos/worktree-identity-migration.ts#L257-L269 (this comment)
  • src/renderer/src/store/slices/worktrees/session/worktree-identity-rename-state.ts#L206-L210
  • tests/e2e/cross-version-wire/cross-version-worktree-identity-downgrade.unit.test.ts#L169-L180

@pullfrog pullfrog Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

ℹ️ The new commit removes only the stray root CONTEXT.md; no code changed. The critical finding from the prior review is still open.

Reviewed changes

  • Removed stray CONTEXT.md — the repo root now holds only AGENTS.md/CLAUDE.md/README.md again; this was a scratch file and its removal is correct.

The blocker from the previous review is unchanged at src/main/ai-vault/session-scanner-opencode-sources.ts:64: opencodeDiscoveries still resolves an undefined discovery on a host with no OpenCode 2 beta database, which crashes sessionCandidatesFromDiscoveries. That needs the ?? emptyOpenCode2Discovery(storageDir) fix (and the session-scanner-opencode-sources-wsl-stall.test.ts count update) before this can merge.

Pullfrog  | Fix it ➔ | View workflow run | Using DeepSeek Flash (free via Pullfrog for OSS) | 𝕏

@nwparker
nwparker force-pushed the nwparker/feature-add-support-for-opencode2 branch from db00f47 to 04d99d8 Compare September 18, 2026 09:10

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

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: Repository UI

Review profile: CHILL

Plan: Advanced

Run ID: f5d2b044-d3a7-4607-bdcb-c57064605af1

📥 Commits

Reviewing files that changed from the base of the PR and between db00f474d90449edf6a5b72512d25c63cc03e2e4 and 04d99d8.

📒 Files selected for processing (5)
  • src/main/ai-vault/session-scanner-every-agent-fixture.ts
  • src/main/ai-vault/session-scanner-opencode-sources.ts
  • src/main/ai-vault/session-scanner-opencode2-sqlite.ts
  • src/main/ai-vault/session-scanner-source-discovery.ts
  • src/renderer/src/runtime/agent-resume-host-authority-capability.ts

Included review availability: Your plan provides up to 10 included reviews per hour; 7 remain after this review.

gemini: undefined,
antigravity: undefined,
opencode: undefined,
opencode2: undefined,

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🗄️ Data Integrity & Integration | 🟡 Minor | ⚡ Quick win

🔎 Supported by static analysis

🏁 Script executed:

sed -n '1,120p' src/renderer/src/runtime/agent-resume-host-authority-capability.ts
sed -n '1,240p' src/renderer/src/runtime/remote-agent-session-launch.ts
rg -n "agent-session\.host-authority\.v1|opencode2|ensureAgentSession|invalid_argument" src tests

Repository: stablyai/orca

Length of output: 50371


🏁 Script executed:

#!/bin/bash
set -e
printf '%s\n' '--- capability mapping ---'
cat -n src/renderer/src/runtime/agent-resume-host-authority-capability.ts | sed -n '1,60p'
printf '%s\n' '--- launch path ---'
cat -n src/renderer/src/runtime/remote-agent-session-launch.ts | sed -n '1,110p'
printf '%s\n' '--- protocol capabilities ---'
cat -n src/shared/protocol-version.ts | sed -n '130,230p'
printf '%s\n' '--- resume agent list ---'
cat -n src/shared/agent-session-resume.ts | sed -n '1,40p'
printf '%s\n' '--- ensure-session contract ---'
cat -n src/shared/rpc-contract/agent-session-params.ts | sed -n '100,175p'
printf '%s\n' '--- host-authority declaration ---'
cat -n src/shared/agent-session-host-authority.ts | sed -n '1,180p'
printf '%s\n' '--- focused tests and bindings ---'
rg -n -g '*.ts' -g '*.tsx' -g '*.test.ts' -g '*.spec.ts' \
  'ensureAgentSession|agent-session\.host-authority\.v1|RESUME_HOST_AUTHORITY_CAPABILITY_BY_AGENT|opencode2' \
  src/main src/renderer/src/runtime src/shared | head -n 240
printf '%s\n' '--- relevant commit summary ---'
git show --stat --oneline 04d99d8f80
printf '%s\n' '--- relevant commit diff ---'
git show --format= --no-ext-diff 04d99d8f80 -- \
  src/renderer/src/runtime/agent-resume-host-authority-capability.ts \
  src/shared/agent-session-resume.ts \
  src/shared/protocol-version.ts \
  src/shared/rpc-contract/agent-session-params.ts \
  src/renderer/src/runtime/agent-resume-host-authority-capability.test.ts

Repository: stablyai/orca

Length of output: 50369


🏁 Script executed:

#!/bin/bash
set -e
printf '%s\n' '--- focused host-authority test: old-host simulation ---'
cat -n src/renderer/src/runtime/web-runtime-session-terminal-host-authority.test.ts | sed -n '110,245p'
printf '%s\n' '--- focused host-authority test: capability cases ---'
cat -n src/renderer/src/runtime/web-runtime-session-terminal-host-authority.test.ts | sed -n '245,330p'
printf '%s\n' '--- focused integration test references ---'
cat -n src/main/runtime/remote-agent-session-host-authority.integration.test.ts | sed -n '140,220p'
printf '%s\n' '--- mapping test ---'
cat -n src/renderer/src/runtime/agent-resume-host-authority-capability.test.ts | sed -n '1,220p'

Repository: stablyai/orca

Length of output: 15178


Gate opencode2 resumes behind a dedicated capability. agent-session.host-authority.v1 predates opencode2, but ExplicitEnsure validates agent with z.enum(RESUMABLE_TUI_AGENTS). A host that advertises the generic capability but lacks the newer enum member rejects the resume request with invalid_argument. runRemoteAgentSessionLaunch falls back only for agent_session_legacy_required and method_not_found, so the resume fails instead of using the legacy path. Add a dedicated opencode2 capability and map it here.

@pullfrog pullfrog Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Important

Two things to address before merge: the new opencode2 resume mapping reintroduces a host-version-skew failure this module exists to prevent, and the every-agent capture guard test is currently red.

Reviewed changes

  • Fixed the v2 discovery crash — opencodeDiscoveries now yields only v1 discoveries, and a new opencode2Discoveries returns an empty discovery when a storage dir has no v2 database, so no undefined entry reaches sessionCandidatesFromDiscoveries.
  • Extended the every-agent fixture — writeEveryAgentVault now writes an opencode-next.db v2 fixture.
  • Declared the opencode2 resume gate — added opencode2 to RESUME_HOST_AUTHORITY_CAPABILITY_BY_AGENT as undefined.
  • Added a rename coverage test — worktree-identity-rename-row-worktree-ids.test.ts pins the value-owned worktree rows.
  • Lint suppressions — SAFETY: justifications on three casts in the OpenCode 2 SQLite reader.

Pullfrog  | Fix all ➔ | Fix 👍s ➔ | View workflow run | Using DeepSeek Flash (free via Pullfrog for OSS) | 𝕏

@nwparker
nwparker force-pushed the nwparker/feature-add-support-for-opencode2 branch from 04d99d8 to e21adc4 Compare September 18, 2026 10:45

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Actionable comments posted: 1

Caution

Some comments are outside the diff and can’t be posted inline due to GitHub limitations.

⚠️ Outside diff range comments (1)

🟠 Major · Clean up OpenCode 2 overlays. · plugin-overlay.ts:361

src/relay/plugin-overlay.ts:361
🩺 Stability & Availability | 🟠 Major | ⚡ Quick win

Clean up OpenCode 2 overlays.

In the SSH relay path, buildPluginEnvironment materializes an OpenCode 2 overlay under opencode2Root using paneKey ?? id. PTY exit then calls clearOverlay with the same identifier, but this loop omits opencode2Root. Distinct exited panes can therefore accumulate mirrored configuration and plugin files under the relay home.

Proposed fix
-    for (const root of [this.opencodeRoot, ...Object.values(this.piRoots)]) {
+    for (const root of [
+      this.opencodeRoot,
+      this.opencode2Root,
+      ...Object.values(this.piRoots)
+    ]) {

This fixes the per-PTY SSH overlay path. The WSL handler uses a single instance-scoped cached overlay, not one overlay per PTY.


ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Advanced

Run ID: ead0cdc4-4e74-4abd-bbc8-eac6fe468163

📥 Commits

Reviewing files that changed from the base of the PR and between 04d99d8 and e21adc4.

📒 Files selected for processing (18)
  • src/main/agent-hooks/wsl-guest-plugin-install.ts
  • src/main/agent-hooks/wsl-hook-relay-deps.ts
  • src/main/agent-hooks/wsl-hook-relay-guest-install.ts
  • src/main/agent-hooks/wsl-hook-relay-manager.test.ts
  • src/main/agent-hooks/wsl-hook-relay-manager.ts
  • src/main/ipc/pty/host-env/assembly.ts
  • src/main/opencode/hook-plugin-module-contract.test.ts
  • src/main/opencode/hook-service.test.ts
  • src/main/opencode/hook-service.ts
  • src/main/opencode/status-plugin-factory-source.ts
  • src/main/opencode2/hook-service.ts
  • src/relay/plugin-overlay.test.ts
  • src/relay/plugin-overlay.ts
  • src/relay/relay-agent-hook-runtime.ts
  • src/relay/wsl-install-plugins-handler.test.ts
  • src/relay/wsl-install-plugins-handler.ts
  • src/shared/agent-hook-listener-transport.test.ts
  • src/shared/agent-hook-listener/source-routing.ts

Included review availability: Your plan provides up to 10 included reviews per hour; 3 remain after this review.

return [
...(options.emitNextEvents
? [
'const nextTextByMessageID = new Map();',

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🩺 Stability & Availability | 🟠 Major | ⚡ Quick win

🔎 Supported by static analysis

🏁 Script executed:

sed -n '1,190p' src/main/opencode/status-plugin-factory-source.ts
rg -n 'nextTextByMessageID|session.next.text|dispose|OrcaOpenCodeStatusPlugin' src/main/opencode

Repository: stablyai/orca

Length of output: 18749


🏁 Script executed:

#!/bin/bash
set -e
printf '%s\n' '--- source 190-320 ---'
sed -n '190,320p' src/main/opencode/status-plugin-factory-source.ts
printf '%s\n' '--- cap helpers and next-event tests ---'
rg -n -C 4 'capMessagePartText|session\\.next\\.text|nextTextByMessageID|emitNextEvents|dispose' src/main/opencode --glob '*.ts'
printf '%s\n' '--- generated source consumers ---'
rg -n -C 3 'getStatusPluginFactorySource|emitNextEvents|status-plugin-factory-source' src/main/opencode --glob '*.ts'

Repository: stablyai/orca

Length of output: 46161


Keep nextTextByMessageID per factory and bound both dimensions.

nextTextByMessageID has module scope, but dispose does not clear it. An interrupted stream, or an ended event that returns before deletion, can retain entries after factory disposal. session.next.text.started also inserts without enforcing the 128-entry limit, and delta handling stores unbounded accumulated text.

Move the map inside OrcaOpenCodeStatusPlugin. Enforce the entry limit after both started and delta insertions. Cap each accumulated preview before storing it. Clear the map during disposal.

@pullfrog pullfrog Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Important

The rewrite routes OpenCode 2 through the relay plugin-overlay path, but the SSH sender never ships the OpenCode 2 plugin source, so opencode2 panes on SSH hosts silently get no status. The WSL path ships it; SSH does not.

Reviewed changes

  • Replaced the OpenCode 2 service/SSE integration with a generated status plugin — src/main/opencode2/{event-translator,sse-consumer,service-discovery}.ts and their tests are deleted, and getOpenCodeFamilyPluginSource now takes emitNextEvents, mapping session.next.*, permission.v2.*, and question.v2.* into the existing lifecycle and preview posts.
  • Parameterized OpenCodeHookService by variant — a second instance uses opencode2-config-overlays, opencode2-hooks, and orca-opencode2-status.js, selected in buildPtyHostEnv when launchAgent === 'opencode2'.
  • Extended the relay plugin-overlay path to a second agent — PluginOverlayManager takes an agent discriminator, and RelayAgentHookRuntime plus the WSL guest handler accept and materialize a separate opencode2 overlay.
  • Dropped the deleted service's PTY registration/cleanup from local-configure.ts / state-cleanup.ts.
  • Added plugin-contract tests for the v2 permission and prompt/text mappings, plus separate-overlay tests for the WSL and relay paths.

⚠️ OpenCode 2 status never reaches SSH hosts

The new commits add opencode2PluginSource to the WSL relay deps and teach RelayAgentHookRuntime to materialize a separate OpenCode 2 overlay, but the SSH sender still ships only the OpenCode 1 source. On an SSH host PluginOverlayManager.hasOpenCode2Source() stays false, materializeOpenCode(..., 'opencode2') returns null, and no OPENCODE_CONFIG_DIR is injected into the remote PTY — so an opencode2 pane there reports no status at all. This contradicts the PR description's claim that "WSL and SSH relay paths ship and materialize separate OpenCode 2 overlays".

Technical details
# SSH relay never receives the OpenCode 2 plugin source

## Affected sites
- `src/main/ssh/ssh-relay-session.ts:1531-1536` — `installPluginsOnRelay` sends `opencodePluginSource` but not `opencode2PluginSource`.
- `src/relay/relay-agent-hook-runtime.ts:147-166` — reads `params.opencode2PluginSource` (undefined over SSH), so `hasOpenCode2Source()` is false.
- `src/relay/plugin-overlay.ts:110,159-160,229-232,259-265` — `opencode2PluginSource` stays null; `materializeOpenCode(..., 'opencode2')` returns null.
- `src/relay/relay-agent-hook-runtime.ts:80-91` — for `launchAgent === 'opencode2'`, the `hasOpenCodeSource('opencode2')` guard fails and no `OPENCODE_CONFIG_DIR` is injected.

## Required outcome
- An `opencode2` pane launched on an SSH host materializes the OpenCode 2 overlay and reports status, matching the WSL path.

## Suggested approach
- Add `opencode2PluginSource: openCodeInternals.getOpenCode2PluginSource()` to the `installPluginsOnRelay` payload. The relay handler and overlay already support it, so no relay change is needed.
- Consider asserting the install-plugins payload in `src/main/ssh/ssh-relay-session-managed-hooks.test.ts` so a future source omission fails a test.

ℹ️ Nitpicks

  • No test exercises the question.v2.asked/replied/rejected mapping; only the permission and prompt/text paths are covered, so the question-card contract rests on source inspection alone.

Pullfrog  | Fix all ➔ | Fix 👍s ➔ | View workflow run | Using DeepSeek Flash (free via Pullfrog for OSS) | 𝕏

Comment thread src/main/opencode2/hook-service.ts Resolved
@nwparker
nwparker force-pushed the nwparker/feature-add-support-for-opencode2 branch 3 times, most recently from 28a83fe to 96ae72a Compare September 18, 2026 21:05
@nwparker

Copy link
Copy Markdown
Contributor Author

Rebased and narrowed in 96ae72a7951.

Follow-up review fixes now present:

  • OpenCode 2 plugin source is sent through SSH relay payloads and covered by the managed-hooks test.
  • Relay overlay cleanup removes both OpenCode 1 and OpenCode 2 roots; cleanup has direct test coverage.
  • OpenCode 2 question.v2.* mappings have contract coverage.
  • The no-beta-database AI Vault path returns an empty OpenCode 2 discovery instead of an undefined entry.
  • Removed unrelated mobile, transcript, and worktree changes; removed the stale ADR reference.

The relay changes are required because SSH/WSL execution has a different filesystem: plugin source must cross the wire, be materialized beside the remote user's config, and be cleaned when the remote PTY exits.

Visual proof in the PR body shows the actual OpenCode source checkout running via the opencode2 wrapper inside Orca, its CLI surface, and debug config reporting the generated orca-opencode2-status.js plugin plus its load marker.

@pullfrog pullfrog Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

ℹ️ No critical issues — minor suggestions inline.

Reviewed changes

  • Shipped the OpenCode 2 plugin source over SSH — installPluginsOnRelay now sends opencode2PluginSource, and ssh-relay-session-managed-hooks.test.ts asserts the payload, closing the prior finding that opencode2 panes on SSH hosts silently got no status.
  • Swept the OpenCode 2 overlay on PTY exit — PluginOverlayManager.clearOverlay now includes opencode2Root, so exited panes no longer accumulate mirrored OpenCode 2 config and plugins.
  • Added a question.v2 lifecycle test — pins question.v2.asked to the AskUserQuestion card; the rejected half is asserted loosely (inline note).

Pullfrog  | Fix all ➔ | Fix 👍s ➔ | View workflow run | Using DeepSeek Flash (free via Pullfrog for OSS) | 𝕏

@nwparker
nwparker force-pushed the nwparker/feature-add-support-for-opencode2 branch from 96ae72a to 19474e6 Compare September 18, 2026 21:17
@nwparker

Copy link
Copy Markdown
Contributor Author

I re-read the inline comments. The branch now includes the concrete fixes relevant to the current OpenCode 2 implementation:

  • worker scan issues preserve agent: opencode2;
  • OpenCode 2 streamed text is per-factory, capped, entry-bounded, and cleared on dispose;
  • the unreachable duplicate text guard was removed;
  • the question rejection test now asserts the resulting SessionIdle event instead of reasserting the earlier question event.

Several remaining comments refer to files intentionally removed when the PR was narrowed (mobile compatibility, transcript catchup, worktree migration, and the old OpenCode 2 SSE/service implementation); they are stale against the current diff.

I also replaced the misleading visual proof with an actual Orca screenshot of the real source checkout launched as opencode2, with the Orca terminal tab titled OpenCode: https://github.com/user-attachments/assets/8563616c-a00a-427c-87cc-f6e1633cd587

@nwparker

Copy link
Copy Markdown
Contributor Author

Correction: the previous replacement screenshot still did not make the running TUI legible. This new capture shows the actual OpenCode interactive screen on the left (Ask anything..., model selector, tab agents ctrl+p commands), while the right terminal shows the live opencode2 source process. https://github.com/user-attachments/assets/c6042ead-1874-4f12-858e-5a10fe1929d2

@pullfrog pullfrog Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

✅ No new issues found.

Reviewed changes

This run re-reviewed the three files changed since the prior pullfrog review (5252661170) at 96ae72a; the full 59-file diff was used for context.

  • Labeled OpenCode 2 scan issues correctly — OpenCodeSqliteWorkerClient.list now pushes agent: args.agent ?? 'opencode' on its unavailable and timeout/crash scan issues instead of hardcoding opencode, so an opencode2 history failure is attributed to the right agent.
  • Scoped the streamed-text accumulator per factory instance — nextTextByMessageID moved from module scope into the factory body, so concurrent plugin instances no longer share one map; the map is also bounded at text.started, deltas are capMessagePartText-capped, and dispose clears it.
  • Removed the unreachable session.next.text.delta/ended guard — the prior nit is resolved; the branch already returns earlier.
  • Strengthened the question.v2.rejected test — it now asserts the final post is SessionIdle instead of a some(AskUserQuestion) check the asked case already satisfied. I mutation-tested it: dropping the rejection mapping makes the test fail.

Pullfrog  | Fix it ➔ | View workflow run | Using DeepSeek Flash (free via Pullfrog for OSS) | 𝕏

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

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: Repository UI

Review profile: CHILL

Plan: Advanced

Run ID: d3505b58-2207-4a89-8b55-9ccb9655e1ac

📥 Commits

Reviewing files that changed from the base of the PR and between 96ae72a7951bdf8f88ddd91e1d19f9838ae1d12d and 19474e64ef9660313ff8165ad2f0baa8e41d8812.

📒 Files selected for processing (3)
  • src/main/ai-vault/session-scanner-opencode-sqlite-worker-client.ts
  • src/main/opencode/hook-plugin-module-contract.test.ts
  • src/main/opencode/status-plugin-factory-source.ts

Included review availability: Your plan provides up to 10 included reviews per hour; 4 remain after this review.

@nwparker

Copy link
Copy Markdown
Contributor Author

Updated the PR body at current head 19474e64ef9.

The visual-proof section now leads with the actual interactive OpenCode 2 TUI running inside Orca, plus a second pane showing the live source checkout process. The old help/config-only proof is explicitly replaced. The body also records the latest follow-up tests and clarifies that comments about removed mobile/transcript/worktree/SSE files are stale against the narrowed diff.

Current proof:
https://github.com/user-attachments/assets/c6042ead-1874-4f12-858e-5a10fe1929d2

@nwparker
nwparker force-pushed the nwparker/feature-add-support-for-opencode2 branch from 19474e6 to 7f0544e Compare September 18, 2026 23:17
@nwparker

Copy link
Copy Markdown
Contributor Author

CI follow-up: the previous run exposed two real integration misses, now fixed in 7f0544eeba9: updated the source-control AI unsupported-agent expectation for the new OpenCode 2 capability, and kept status-plugin-factory-source.ts under the repository max-lines gate. Focused validation passes locally (oxlint; 21 tests). New CI is running from this head.

@nwparker
nwparker force-pushed the nwparker/feature-add-support-for-opencode2 branch from 7f0544e to 85004f0 Compare September 19, 2026 02:19
@nwparker

Copy link
Copy Markdown
Contributor Author

CI failure follow-up pushed as 85004f046e9: fixed the pane-agent inventory ratchet (the new OpenCode 2 title callsite adds one occurrence), restored the stable OpenCode 1 plugin digest expectation after the source-only max-lines edit, and retained the source-control AI expectation update. Local focused suite: 47 tests passed; targeted oxlint and diff check passed. CI has restarted from this head.

@nwparker
nwparker force-pushed the nwparker/feature-add-support-for-opencode2 branch from 85004f0 to 7cda04d Compare September 19, 2026 02:31
@nwparker

Copy link
Copy Markdown
Contributor Author

CI static-analysis failure fixed in 7cda04d9947. The changed-code quality gate had 21 cast findings; all now have line-specific SAFETY rationale. Focused suite passes: 6 files / 72 tests, plus local changed-code quality and diff checks. The prior shard failures were also fixed (source-control expectation, pane inventory, and stable plugin digest). CI restarted from this head.

@pullfrog pullfrog Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

ℹ️ No critical issues — one formatting regression inline.

Reviewed changes

This run re-reviewed the delta since the prior pullfrog review (5252759621, at 19474e64); the incremental range-diff since 7f0544e touches two files.

  • Fixed the pane-agent inventory ratchet — titleHasAgentName's expected count for terminal-title-agent-type.ts moved 14 → 15, matching the opencode2 branch this PR adds. pane-agent-identity-inventory.test.ts was failing at the previous head (7f0544e) and now passes.
  • Re-added a blank element to the generated OpenCode 2 plugin-source string array — cosmetic whitespace in the generated JS only; the plugin contract tests still pass.
  • Regressed the formatter output of getStatusPluginFactorySource's options type — oxfmt --check now fails on the joined closing brace.

Pullfrog  | Fix all ➔ | Fix 👍s ➔ | View workflow run | Using DeepSeek Flash (free via Pullfrog for OSS) | 𝕏

@pullfrog pullfrog Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

ℹ️ No critical issues — the delta is test-only, with one assertion that does not actually pin the mapping it was added for.

Reviewed changes

This run re-reviewed the delta since the prior pullfrog review (5255090192, at 447a288); the net change is limited to the OpenCode 2 setup-bridge test plus base-branch OMP content merged by the rebase.

  • Covered the setup bridge's form-created path — hook-plugin-opencode2-setup.test.ts now yields permission.replied and asserts AskUserQuestion for form.created. The form.created assertion is real (a mutation on question.asked fails it), but the companion SessionIdle assertion is satisfied by permission.replied and does not cover form.cancelled (inline).
  • Dropped the unrelated browser-pane fixture edit — ClientHostedBrowserPagePane.markup.test.tsx is back to its base content and is no longer part of the PR; the prior anti-slop thread is retired.
  • Absorbed the base OMP commit-message agent — commit-message-agent-spec.test.ts now lists omp alongside the PR's opencode2.

Pullfrog  | Fix all ➔ | Fix 👍s ➔ | View workflow run | Using DeepSeek Flash (free via Pullfrog for OSS) | 𝕏

@pullfrog pullfrog Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Important

4642d0d restores OMP's config-directory selection but leaves the larger half of the same regression in place: the relay still never exports ORCA_OMP_FRESH_CONFIG, so omp --config "$ORCA_OMP_FRESH_CONFIG" on an SSH/WSL host has no fresh config and src/relay/omp-fresh-launch-environment.test.ts fails.

Reviewed changes

This run re-reviewed the delta since the prior pullfrog review (5255298590, at d31c918): one commit, 4642d0d fix(relay): preserve OMP config directory selection.

  • Restored OMP config-directory selection in the relay overlay — getDefaultPiAgentDir(kind, configDirName?) and materializePi's configDirName option are back, so a custom OMP config dir is honored again on SSH/WSL.
  • Reformatted getRelayOpenCodePluginPath, mirrorOpenCodeConfig, and materializeOpenCode across lines; mirrorOpenCodeConfig still skips both OpenCode plugin file names.
  • Left ORCA_OMP_FRESH_CONFIG dropped — the OMP fresh-launch env var is still absent from buildPluginEnvironment; see inline.

Pullfrog  | Fix all ➔ | Fix 👍s ➔ | View workflow run | Using DeepSeek Flash (free via Pullfrog for OSS) | 𝕏

Comment thread src/relay/relay-agent-hook-runtime.ts Resolved

@pullfrog pullfrog Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

ℹ️ No critical issues — the delta restores the OMP fresh-launch environment; one ordering nuance inline.

Reviewed changes

This run re-reviewed the delta since the prior pullfrog review (5255313220, at 4642d0d). The head commit 6d0dba3 touches four files.

  • Restored ORCA_OMP_FRESH_CONFIG in the relay — buildPluginEnvironment sets the fresh-launch config again, so an SSH/WSL omp launch keeps #20622's no-auto-resume behavior and omp-fresh-launch-environment.test.ts passes. The assignment lands after the hasPiSource early return, where origin/main places it before (inline).
  • Corrected the OMP resume expectation — omp-child-session-recovery.unit.test.ts now expects the session-file path in the resume argv, which is what the OMP transcript resume actually returns.
  • Awaited the async env augmenter — the fresh-launch test's second augment call is now awaited, so its toEqual({}) assertion evaluates the resolved env rather than a promise.
  • Reordered the opencode2 resume case — cosmetic; no behavior change.

Pullfrog  | Fix all ➔ | Fix 👍s ➔ | View workflow run | Using DeepSeek Flash (free via Pullfrog for OSS) | 𝕏

Comment thread src/relay/relay-agent-hook-runtime.ts Resolved

@pullfrog pullfrog Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

✅ No new issues found.

Reviewed changes

This run re-reviewed the delta since the prior pullfrog review (5255468458, at 6d0dba3); the incremental range-diff isolates two files changed by 266e512.

  • Moved the relay OMP fresh-config assignment above the hasPiSource guard — buildPluginEnvironment now sets ORCA_OMP_FRESH_CONFIG before the early return, so an OMP launch on a relay host that holds no cached Pi sources keeps #20622's no-auto-resume behavior, matching origin/main.
  • Pinned the setup-bridge form resolution to the final post — the SessionIdle assertion is now expect(names.at(-1)).toBe('SessionIdle'); I mutation-verified that dropping the form.cancelled arm now fails the test, where permission.replied previously satisfied it.

Verified: pnpm vitest run src/main/opencode/hook-plugin-opencode2-setup.test.ts src/relay/omp-fresh-launch-environment.test.ts src/relay/plugin-overlay.test.ts — 30 tests pass.

Pullfrog  | View workflow run | Using DeepSeek Flash (free via Pullfrog for OSS) | 𝕏

@nwparker
nwparker force-pushed the nwparker/feature-add-support-for-opencode2 branch from 266e512 to f5117da Compare September 19, 2026 22:55
@nwparker
nwparker force-pushed the nwparker/feature-add-support-for-opencode2 branch from 45b9097 to 331765b Compare September 20, 2026 00:16
@nwparker
nwparker merged commit ee354a3 into main Sep 20, 2026
40 checks passed
@mcxinyu

mcxinyu commented Sep 20, 2026

Copy link
Copy Markdown

Please refer to this issue #19708 and avoid putting messy hacks in environment variables or hooks.

@nwparker

Copy link
Copy Markdown
Contributor Author

Please refer to this issue #19708 and avoid putting messy hacks in environment variables or hooks.

looking at it

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Feature]: Add support for opencode2

2 participants