Skip to content

fix: sync pre-httpapi stability baseline#506

Merged
Astro-Han merged 13 commits into
devfrom
codex/i477-pr4-stability-baseline
May 9, 2026
Merged

fix: sync pre-httpapi stability baseline#506
Astro-Han merged 13 commits into
devfrom
codex/i477-pr4-stability-baseline

Conversation

@Astro-Han

@Astro-Han Astro-Han commented May 8, 2026

Copy link
Copy Markdown
Owner

Summary

  • Sync current upstream provider reasoning variants for GPT-5.x, GPT-5 Pro/chat/codex, OpenAI-compatible paths, Anthropic Opus 4.5, and Gemini thinking controls.
  • Keep the Hono fallback browser-safe by applying CORS before auth failures.
  • Manual-port small desktop/app behavior fixes only: webview zoom shortcut handling, persisted store read fallback, and EPIPE-safe console logging.

Why

This is the PR 4 pre-HttpApi stability baseline for #477. It intentionally keeps the remaining upstream sync moving with one rollback surface around pre-HttpApi safety/stability, while excluding Effect foundation, effectCmd, HttpApi listener work, default listener switching, package consolidation, and v2 session/warping contracts.

Related Issue

Refs #477.

Human Review Status

Pending. A human should make the final merge decision after reviewing the final diff and verification evidence.

Review Focus

  • Provider variant matrices: confirm the newly allowed reasoning efforts match the current upstream/provider contracts and do not reintroduce unsupported minimal values for versioned GPT-5.x models.
  • Server middleware ordering: confirm moving CORS before auth preserves browser CORS headers without weakening Basic/auth_token behavior.
  • Desktop manual ports: confirm these stay behavior-only and do not pull in desktop package consolidation, utility-process restructuring, updater policy, CSP expansion, or HttpApi work.

Risk Notes

  • Provider changes affect the model variant options exposed to users, so incorrect matrices could surface invalid model settings.
  • Hono middleware ordering changes all legacy fallback responses, but the auth tests still cover Basic challenge behavior and auth_token handling.
  • Desktop tests include behavior-level coverage for zoom and logging shell guards, plus a narrow source-contract check for IPC registration fallback; no package structure, dependency, or generated-file changes are included.
  • Hono remains the default listener. This PR does not introduce or switch to Effect HttpApi.

How To Verify

Provider variants: bun test --timeout 30000 test/provider/transform.test.ts -> 200 pass, 0 fail, 382 expect() calls
Server CORS/auth: bun test --timeout 30000 test/server/cors-middleware.test.ts test/server/auth.test.ts -> 12 pass, 0 fail, 26 expect() calls
Desktop shell guards: bun test src/renderer/webview-zoom.test.ts src/main/ipc-window-config.test.ts src/main/logging.test.ts -> 11 pass, 0 fail, 29 expect() calls
opencode typecheck: bun run typecheck -> pass
Desktop Electron typecheck: bun run typecheck -> pass
Diff check: git diff --check -> no whitespace errors
Electron dev smoke: bun run dev:desktop -> built Electron main/preload and reached app starting in dev mode

Screenshots or Recordings

Not required. This PR changes desktop shell behavior guards, not visible UI layout or copy.

Checklist

  • Human review status is stated above as pending, approved, or not required
  • I linked the related issue, or stated why there is no issue
  • This PR has type, primary area, and priority labels, or I requested maintainer labeling
  • I described the review focus and any meaningful risks
  • I listed the relevant verification steps and the key result for each
  • I did not introduce unrelated refactors, dependencies, generated files, or file changes beyond the stated scope
  • I manually checked visible UI or copy changes when needed, with screenshots or recordings
  • I considered macOS and Windows impact for platform, packaging, updater, signing, paths, shell, or permissions changes
  • I called out docs, release notes, dependencies, permissions, credentials, deletion behavior, generated content, or local file changes when relevant
  • I reviewed the final diff for unrelated changes and suspicious dependency changes
  • I am targeting dev, and my PR title and commit messages use Conventional Commits in English

Summary by CodeRabbit

  • Bug Fixes

    • Store reads now fail gracefully (returns null) instead of erroring
    • Logging more robust: broken-pipe errors are suppressed to avoid crashes
  • New Features

    • Added GPT-5 reasoning-effort configuration support
    • Expanded Gemini thinking-level handling
  • Improvements

    • More reliable webview zoom state and keyboard shortcuts
    • CORS handling adjusted to ensure appropriate headers on auth-failing responses

@Astro-Han Astro-Han added bug Something isn't working upstream Tracked upstream or vendor behavior app Application behavior and product flows platform Electron shell, OS integration, packaging, updater, signing, paths, and permissions P2 Medium priority labels May 8, 2026
@coderabbitai

coderabbitai Bot commented May 8, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

Warning

Rate limit exceeded

@Astro-Han has exceeded the limit for the number of commits that can be reviewed per hour. Please wait 31 minutes and 51 seconds before requesting another review.

You’ve run out of usage credits. Purchase more in the billing tab.

⌛ How to resolve this issue?

After the wait time has elapsed, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

🚦 How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout.

Please see our FAQ for further information.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro Plus

Run ID: a6eb243c-51b2-4033-a3d5-aaa378d5ce0e

📥 Commits

Reviewing files that changed from the base of the PR and between a92f719 and b1856a6.

📒 Files selected for processing (5)
  • packages/desktop-electron/src/main/logging.test.ts
  • packages/desktop-electron/src/main/logging.ts
  • packages/desktop-electron/src/renderer/webview-zoom.test.ts
  • packages/opencode/src/provider/transform.ts
  • packages/opencode/test/provider/transform.test.ts
📝 Walkthrough

Walkthrough

This PR contains three independent improvement areas: desktop electron hardening (IPC store-get error handling, console EPIPE suppression, webview zoom state refactoring), provider reasoning-effort configuration for GPT-5 and Gemini models across multiple AI SDK providers, and server middleware reordering with CORS test validation.

Changes

Desktop Electron Error Handling & State Management

Layer / File(s) Summary
Store-Get IPC Error Handling
packages/desktop-electron/src/main/ipc.ts, packages/desktop-electron/src/main/ipc-window-config.test.ts
IPC store-get handler wraps store access in try/catch and returns null on failure; test verifies the error-handling semantics.
Console Transport EPIPE Suppression
packages/desktop-electron/src/main/logging.ts, packages/desktop-electron/src/main/logging.test.ts
initLogging() calls initConsoleTransport() to wrap console transport's writeFn and suppress broken-pipe (EPIPE) errors; tests mock transports and assert suppression and single-wrap behavior.
Webview Zoom Request Staging
packages/desktop-electron/src/renderer/webview-zoom.ts, packages/desktop-electron/src/renderer/webview-zoom.test.ts
Introduces requestedZoom state variable and rewrites applyZoom to call IPC first, then commit signal only if request matches; keyboard handler now clamps and prevents default; test verifies staging flow and handler structure.

Provider Reasoning-Effort & Thinking Configuration

Layer / File(s) Summary
GPT-5 and Google Reasoning Helpers
packages/opencode/src/provider/transform.ts
Adds GPT-5 effort sets by variant (base, Pro, Codex, chat, deep-research) with version-parsing helpers; adds Google Gemini thinking-level and budget computation functions.
Reasoning Effort Selection
packages/opencode/src/provider/transform.ts
Updates openaiCompatibleReasoningEfforts to use GPT-5-aware selection; applies deep-research and chat/version special-cases.
Provider Variant Selection
packages/opencode/src/provider/transform.ts
Applies GPT-5 effort selection to @openrouter, @ai-sdk/openai-compatible, @ai-sdk/azure, and Anthropic; computes Google Gemini thinking config for Google-Vertex; adds small-options handling for gpt-5-chat and search-api.
Provider Test Coverage
packages/opencode/test/provider/transform.test.ts
Adds and updates test assertions for GPT-5 and Gemini variants across all providers, validating supported reasoning efforts and metadata.

OpenCode Server Middleware & CORS

Layer / File(s) Summary
Middleware Registration Order
packages/opencode/src/server/server.ts
CORS middleware now runs before logging, authentication, and compression in the Hono chain.
CORS Test Harness & Validation
packages/opencode/test/server/cors-middleware.test.ts
Test suite captures/restores server credentials via afterEach hook; new live test verifies CORS headers appear in unauthorized (401) responses.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

Possibly related issues

Possibly related PRs

  • Astro-Han/pawwork#301: Both PRs modify packages/opencode/src/provider/transform.ts—each changing model/provider variant and reasoning-effort selection logic—so they are related.
  • Astro-Han/pawwork#482: Both PRs modify the opencode provider/model logic (notably packages/opencode/src/provider/transform.ts and related provider/plugin hooks and session message handling) to change reasoning-effort/variant selection and provider-model hook behavior, so they are related.
  • Astro-Han/pawwork#304: Both PRs modify packages/opencode/src/provider/transform.ts to change reasoning-effort/DeepSeek handling and related provider variant logic, so they are related.

Suggested labels

desktop

Poem

🐰 Three fixes hopped into view:
IPC errors caught, console pipes too,
Zoom states now stage without colliding,
GPT-5 efforts deciding,
All wrapped in tests shiny and new!

🚥 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 'fix: sync pre-httpapi stability baseline' directly references the main objective stated in the PR description: syncing upstream provider variants and applying small desktop behavior fixes as a pre-HttpApi stability baseline.
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.
Description check ✅ Passed The pull request description is comprehensive and well-structured, covering all required template sections including summary, rationale, related issue, review focus, risk assessment, and detailed verification steps.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch codex/i477-pr4-stability-baseline

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 and usage tips.

@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

🧹 Nitpick comments (3)
packages/desktop-electron/src/main/logging.ts (1)

46-60: 💤 Low value

LGTM — solid EPIPE guard.

writeFn is a v5-introduced callback, so the monkey-patch is correctly targeted. The .bind(log.transports.console) preserves this, and disabling a transport by setting its level to false is the documented API. The isBrokenPipe() guard is type-safe and correctly narrows unknown.

One theoretical concern: if initLogging() is called more than once, writeFn will be double-wrapped (the inner wrapper then becomes the captured write in the outer). This is harmless in practice since initLogging() is called once at startup, but a guard such as a module-level boolean flag would eliminate the possibility entirely.

🛡️ Optional: guard against double-wrapping
+let consoleTransportInitialized = false
+
 function initConsoleTransport() {
+  if (consoleTransportInitialized) return
+  consoleTransportInitialized = true
   const write = log.transports.console.writeFn.bind(log.transports.console)
   log.transports.console.writeFn = (options) => {
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@packages/desktop-electron/src/main/logging.ts` around lines 46 - 60, The
initConsoleTransport function can be double-wrapped if initLogging() is invoked
multiple times; add a simple module-level guard (e.g., a boolean like
consoleTransportInited) checked at the top of initConsoleTransport and set to
true after wrapping to prevent re-wrapping the existing
log.transports.console.writeFn; reference initConsoleTransport, initLogging
(caller), and log.transports.console.writeFn when making the change.
packages/desktop-electron/src/main/logging.test.ts (1)

7-14: ⚡ Quick win

Source-text assertions validate structure but not behavior.

All four toContain() checks scan the raw .ts source for substrings. This means the test cannot distinguish correct logic from inverted logic — for example, it would pass equally for if (isBrokenPipe(err)) throw err (wrong direction) as for the current if (!isBrokenPipe(err)) throw err, because the string 'err.code === "EPIPE"' appears in isBrokenPipe()'s body regardless of how the result is used at the call site.

Consider replacing with a lightweight mock-based behavioral test:

♻️ Proposed behavioral replacement
-import { describe, expect, test } from "bun:test"
-import { readFileSync } from "node:fs"
-import { resolve } from "node:path"
-
-const source = readFileSync(resolve(import.meta.dir, "logging.ts"), "utf8")
-
-describe("desktop logging", () => {
-  test("disables the console transport after a broken pipe", () => {
-    expect(source).toContain("initConsoleTransport()")
-    expect(source).toContain("log.transports.console.writeFn")
-    expect(source).toContain('err.code === "EPIPE"')
-    expect(source).toContain("log.transports.console.level = false")
-  })
-})
+import { describe, expect, test } from "bun:test"
+import { isBrokenPipe, initConsoleTransportForTest } from "./logging"
+
+// Export these from logging.ts for testing, or restructure as shown below.
+// Alternatively, test via a controlled mock of log.transports.console:
+
+describe("desktop logging", () => {
+  test("isBrokenPipe detects EPIPE errors", () => {
+    expect(isBrokenPipe({ code: "EPIPE" })).toBe(true)
+    expect(isBrokenPipe({ code: "ENOENT" })).toBe(false)
+    expect(isBrokenPipe(null)).toBe(false)
+    expect(isBrokenPipe("string")).toBe(false)
+  })
+
+  test("disables console transport and does not rethrow on EPIPE", () => {
+    const fakeTransport = { level: "silly" as string | false, writeFn: null as any }
+    const epipeError = Object.assign(new Error("EPIPE"), { code: "EPIPE" })
+    fakeTransport.writeFn = () => { throw epipeError }
+    // call initConsoleTransportForTest(fakeTransport) to exercise the wrapper
+    // then assert fakeTransport.level === false
+  })
+})

Note: isBrokenPipe and a test-oriented hook would need to be exported from logging.ts. The sketch above shows the structure — adapt to your module's export conventions.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@packages/desktop-electron/src/main/logging.test.ts` around lines 7 - 14, The
test currently only asserts source text contains substrings and not behavior;
replace it with a behavioral mock test that imports initConsoleTransport and
isBrokenPipe (export isBrokenPipe and a test hook from logging.ts), then mock or
stub log.transports.console.writeFn to simulate a write error with err.code ===
"EPIPE" and verify that initConsoleTransport disables the console transport
(e.g., log.transports.console.level === false) when isBrokenPipe returns true
and that it rethrows or leaves transport enabled when false; update logging.ts
to export isBrokenPipe and any minimal test hook needed so the test can control
the broken-pipe predicate and assert real runtime behavior rather than source
text.
packages/desktop-electron/src/renderer/webview-zoom.test.ts (1)

5-21: 🏗️ Heavy lift

Prefer behavior-level tests over source-string assertions.

These checks are useful as a temporary guard, but they’re brittle (format/structure-sensitive) and can miss runtime regressions. Consider testing observable behavior instead (dispatch keydown events, assert preventDefault, and assert window.api.setZoomFactor / zoom state interactions).

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@packages/desktop-electron/src/renderer/webview-zoom.test.ts` around lines 5 -
21, Replace brittle source-string assertions in webview-zoom.test.ts with
behavior-level tests: simulate keyboard events (e.g., '-' '+' '=' '0') that the
module should handle, spy on Event.prototype.preventDefault to assert it was
called only for keys that change zoom, and mock/spy window.api.setZoomFactor
(and any setWebviewZoom/webviewZoom interactions) to assert the correct zoom
values are requested and that requestedZoom/state updates only take effect after
Electron accepts the change; locate helpers/variables by name: requestedZoom,
setWebviewZoom, webviewZoom, and window.api.setZoomFactor when converting the
tests to use dispatched KeyboardEvent and spies instead of string matching.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@packages/desktop-electron/src/main/ipc-window-config.test.ts`:
- Around line 29-31: The test currently computes start and end via
source.indexOf('ipcMain.handle("store-get"') and
source.indexOf('ipcMain.handle("store-set"', start) then slices without
validating those indices; add explicit bounds checks to ensure both markers were
found and that start < end before calling slice (e.g., verify start !== -1, end
!== -1, and end > start) and fail the test with a clear message if checks fail
so the regression test fails loudly when markers drift; update the variables
referenced (start, end, handler, source.indexOf(...) usages) accordingly.

---

Nitpick comments:
In `@packages/desktop-electron/src/main/logging.test.ts`:
- Around line 7-14: The test currently only asserts source text contains
substrings and not behavior; replace it with a behavioral mock test that imports
initConsoleTransport and isBrokenPipe (export isBrokenPipe and a test hook from
logging.ts), then mock or stub log.transports.console.writeFn to simulate a
write error with err.code === "EPIPE" and verify that initConsoleTransport
disables the console transport (e.g., log.transports.console.level === false)
when isBrokenPipe returns true and that it rethrows or leaves transport enabled
when false; update logging.ts to export isBrokenPipe and any minimal test hook
needed so the test can control the broken-pipe predicate and assert real runtime
behavior rather than source text.

In `@packages/desktop-electron/src/main/logging.ts`:
- Around line 46-60: The initConsoleTransport function can be double-wrapped if
initLogging() is invoked multiple times; add a simple module-level guard (e.g.,
a boolean like consoleTransportInited) checked at the top of
initConsoleTransport and set to true after wrapping to prevent re-wrapping the
existing log.transports.console.writeFn; reference initConsoleTransport,
initLogging (caller), and log.transports.console.writeFn when making the change.

In `@packages/desktop-electron/src/renderer/webview-zoom.test.ts`:
- Around line 5-21: Replace brittle source-string assertions in
webview-zoom.test.ts with behavior-level tests: simulate keyboard events (e.g.,
'-' '+' '=' '0') that the module should handle, spy on
Event.prototype.preventDefault to assert it was called only for keys that change
zoom, and mock/spy window.api.setZoomFactor (and any setWebviewZoom/webviewZoom
interactions) to assert the correct zoom values are requested and that
requestedZoom/state updates only take effect after Electron accepts the change;
locate helpers/variables by name: requestedZoom, setWebviewZoom, webviewZoom,
and window.api.setZoomFactor when converting the tests to use dispatched
KeyboardEvent and spies instead of string matching.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro Plus

Run ID: 720473a2-e25d-4377-92e8-8a9b19785f43

📥 Commits

Reviewing files that changed from the base of the PR and between a3d978c and 9b0110a.

📒 Files selected for processing (10)
  • packages/desktop-electron/src/main/ipc-window-config.test.ts
  • packages/desktop-electron/src/main/ipc.ts
  • packages/desktop-electron/src/main/logging.test.ts
  • packages/desktop-electron/src/main/logging.ts
  • packages/desktop-electron/src/renderer/webview-zoom.test.ts
  • packages/desktop-electron/src/renderer/webview-zoom.ts
  • packages/opencode/src/provider/transform.ts
  • packages/opencode/src/server/server.ts
  • packages/opencode/test/provider/transform.test.ts
  • packages/opencode/test/server/cors-middleware.test.ts

Comment thread packages/desktop-electron/src/main/ipc-window-config.test.ts

@gemini-code-assist gemini-code-assist 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.

Code Review

This pull request improves error handling in Electron IPC and logging, refines webview zoom behavior to prevent default browser actions, and significantly updates model provider transformations to support granular reasoning efforts for GPT-5, Gemini-3, and Claude models. Additionally, server middleware was reordered to ensure CORS headers are correctly applied to unauthorized responses. Feedback suggests adding a return statement in the zoom key handler for consistency and aligning Azure reasoning effort logic with other providers for GPT-5 chat models to ensure uniform behavior across the platform.

Comment thread packages/desktop-electron/src/renderer/webview-zoom.ts
Comment thread packages/opencode/src/provider/transform.ts Outdated
@Astro-Han

Copy link
Copy Markdown
Owner Author

@coderabbitai review

@coderabbitai

coderabbitai Bot commented May 9, 2026

Copy link
Copy Markdown
Contributor
✅ Actions performed

Review triggered.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

@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.

🧹 Nitpick comments (1)
packages/desktop-electron/src/renderer/webview-zoom.test.ts (1)

115-115: ⚡ Quick win

Avoid hard-coding the floating-point artifact in the assertion.

Line 115 currently locks in 0.6000000000000001, which is representation-specific and can cause fragile failures if implementation rounds to 0.6 without changing behavior.

Suggested test-robustness patch
-    expect(setZoomFactor.mock.calls.map(([factor]) => factor)).toEqual([0.8, 0.6000000000000001, 1])
+    const factors = setZoomFactor.mock.calls.map(([factor]) => factor)
+    expect(factors).toHaveLength(3)
+    expect(factors[0]).toBeCloseTo(0.8, 10)
+    expect(factors[1]).toBeCloseTo(0.6, 10)
+    expect(factors[2]).toBe(1)
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@packages/desktop-electron/src/renderer/webview-zoom.test.ts` at line 115, The
assertion hard-codes a floating-point artifact (0.6000000000000001) making the
test fragile; update the test in webview-zoom.test.ts to compare zoom factors
with tolerance instead of exact equality by retrieving the values from
setZoomFactor.mock.calls (the same map(([factor]) => factor) expression) and
assert the middle value with a floating-point tolerant check (e.g., use Jest's
toBeCloseTo or round to a fixed number of decimals) while keeping the other
expected values as-is.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Nitpick comments:
In `@packages/desktop-electron/src/renderer/webview-zoom.test.ts`:
- Line 115: The assertion hard-codes a floating-point artifact
(0.6000000000000001) making the test fragile; update the test in
webview-zoom.test.ts to compare zoom factors with tolerance instead of exact
equality by retrieving the values from setZoomFactor.mock.calls (the same
map(([factor]) => factor) expression) and assert the middle value with a
floating-point tolerant check (e.g., use Jest's toBeCloseTo or round to a fixed
number of decimals) while keeping the other expected values as-is.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro Plus

Run ID: 426eecc0-0811-42e6-8736-eb8fff6d71e1

📥 Commits

Reviewing files that changed from the base of the PR and between 9b0110a and a92f719.

📒 Files selected for processing (7)
  • packages/desktop-electron/src/main/ipc-window-config.test.ts
  • packages/desktop-electron/src/main/logging.test.ts
  • packages/desktop-electron/src/main/logging.ts
  • packages/desktop-electron/src/renderer/webview-zoom.test.ts
  • packages/desktop-electron/src/renderer/webview-zoom.ts
  • packages/opencode/src/provider/transform.ts
  • packages/opencode/test/provider/transform.test.ts
✅ Files skipped from review due to trivial changes (1)
  • packages/desktop-electron/src/main/ipc-window-config.test.ts
🚧 Files skipped from review as they are similar to previous changes (2)
  • packages/desktop-electron/src/main/logging.ts
  • packages/desktop-electron/src/renderer/webview-zoom.ts

@Astro-Han Astro-Han merged commit 9f2275e into dev May 9, 2026
20 checks passed
@Astro-Han Astro-Han deleted the codex/i477-pr4-stability-baseline branch May 9, 2026 03:12
Astro-Han added a commit that referenced this pull request May 9, 2026
Refs #477.

This lands the PR5 foundation slice for the upstream sync track after #506. It intentionally absorbs the Effect-backed instance foundation and the smallest effectCmd proof chain without introducing the HttpApi backend, changing the default Hono listener, or pulling in session/warp/workspace migrations.

Why this change exists:
- upstream moved instance bootstrap and command execution toward Effect services;
- PawWork needed the foundation before any later HttpApi parity work could be reviewed cleanly;
- the old explicit InstanceBootstrap call sites were easy to miss across Hono, CLI, worktree, watcher, and tool paths;
- effectCmd needed a minimal proof, but a broad CLI migration would have made rollback and review too noisy.

What changed:
- added Effect-backed InstanceBootstrap, InstanceStore, InstanceRuntime, InstanceLayer, InstanceRef, and InstanceState wiring;
- made InstanceStore own boot, reload, dispose, failed-load retry, and single-flight behavior;
- routed legacy Instance.provide, WithInstance, Hono instance middleware, CLI bootstrap, worktree reload, watcher, bash tool, and related service boundaries through the new instance context path;
- kept plugin/config bootstrap failures fatal and documented that contract, while optional services continue to log and continue;
- registered bootstrap subscriptions with the instance disposer so reload/dispose cleans them up;
- added effectCmd and migrated only the models command as the proof chain;
- preserved Instance.current across Effect.promise and nested AppRuntime.runPromise in the CLI proof path;
- moved File service bootstrap reads from legacy ALS Instance.* to InstanceState.context, so File.init works when only InstanceRef is available during store boot;
- added regression coverage for plugin/config bootstrap, InstanceStore load/reload/dispose, effectCmd ALS bridging, File.init under InstanceRef, and /init command events marking Project.setInitialized.

Review and follow-up notes:
- this is a production-path runtime change because default Hono and CLI paths now flow through InstanceStore;
- Hono remains the default server path and fallback;
- HttpApi parity was split out after the split trigger because importing it would have pulled in excluded listener/session/warp/workspace chains;
- PR6 should continue #477 with non-default HttpApi parity only after this foundation is stable;
- broad CLI command migration, desktop/app package consolidation, HttpApi default listener switch, v2 session, warp, sync ownership, /sync/steal, and workspace-aware patch apply remain explicitly out of scope.

Verification:
- GitHub checks on 3b48455 all passed: ci typecheck, unit-opencode, unit-desktop, unit-app, check, dependency-review, commit-lint, codeql, desktop-smoke, e2e-artifacts, and CodeRabbit;
- local typecheck passed: bun --cwd packages/opencode typecheck;
- focused tests passed: bun --cwd packages/opencode test test/file/index.test.ts test/project/instance-bootstrap-regression.test.ts;
- full opencode CI test suite passed locally: bun --cwd packages/opencode test:ci, 2702 pass, 9 skip, 1 todo, 0 fail;
- diff check passed: git diff --check;
- exclusion scans found no HttpApi or warp/session scope matches in the changed package areas;
- review thread check before merge found 0 unresolved review threads.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

app Application behavior and product flows bug Something isn't working P2 Medium priority platform Electron shell, OS integration, packaging, updater, signing, paths, and permissions upstream Tracked upstream or vendor behavior

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant