Skip to content

fix(app): stop dev-run console errors and log flattening - #232

Merged
quickbeard merged 1 commit into
mainfrom
fix/dev-run-errors
Aug 14, 2026
Merged

quickbeard merged 1 commit into
mainfrom
fix/dev-run-errors

Conversation

@quickbeard

Copy link
Copy Markdown
Owner

Summary

A bun dev:desktop run surfaced several errors/warnings in the terminal. Each traced to a distinct root cause; all five are fixed:

  1. Shared directory contexts died with their first caller (packages/app/src/utils/refcount.ts) — createRefCountMap ran create() in the first caller's reactive scope, so the dir SDK context's event unsubscribe fired when the first view of a directory closed, silently stopping live updates for every other view of it. Ownerless callers (event handlers, async continuations — notification.tsx session lookup, layout.tsx openSession) also registered cleanups Solid warns can never run (the cleanups created outside a createRoot line) and pinned items forever. Items now live in their own root under the map's creating scope, disposed when the last pinning caller releases them; ownerless callers borrow without pinning. Two new tests pin the semantics.
  2. [global-sdk] event stream error on normal server lifecycle (packages/app/src/context/server-sdk.tsx) — the first failed SSE attempt races a server being stopped or restarted (sandbox reset, sidecar relaunch). Errors now log only after 3 consecutive failed reconnects (~1s for a genuinely dead server), with the error normalized to name: message.
  3. duplicate command id warnings on navigation (packages/app/src/context/command.tsx) — router transitions keep the outgoing page mounted while the incoming one registers, briefly duplicating command.palette/input.focus on every draft→session navigation. The DEV warning now re-checks after 1s and only reports duplicates that persist; runtime keep-first behavior is unchanged.
  4. [object Object] in terminal and debug bundles (new packages/desktop/src/renderer/console-format.ts) — spyRendererConsole receives Chromium's pre-flattened console string, so object arguments were lost before the main process saw them. The renderer entry now installs a console wrapper that serializes structured arguments at the source (Error-aware, circular-safe, 8KB-truncated). Covered by 5 new tests.
  5. Red Chromium noise (packages/desktop/src/main/logging.ts) — ResizeObserver loop completed… and Autofocus processing was blocked… are interventions the app can't act on; an electron-log hook drops exactly these two from the console transport while file logs keep them.

Docs

  • Five new DIVERGENCES.md rows (one per upstream-file edit) with on-conflict guidance
  • Two CHANGELOG "Unreleased" entries (the live-updates fix is user-facing; the log-fidelity fix affects exported debug bundles)

Verification

  • bun typecheck clean in packages/app and packages/desktop
  • bun test: 659 pass in packages/app (incl. 2 new refcount tests), 83 pass in packages/desktop (incl. 5 new console-format tests)

🤖 Generated with Claude Code

Five issues seen in a `bun dev:desktop` run:

- createRefCountMap ran create() in the first caller's scope, so a shared
  directory context's internal cleanups (the dir SDK event unsubscribe)
  fired when the first view closed while other holders still used it, and
  ownerless callers (event handlers, async continuations) registered
  cleanups Solid warns can never run, pinning items forever. Items now get
  their own root under the map's creating scope, disposed when the last
  pinning caller releases them; ownerless callers borrow without pinning.
- The SSE event stream logged an error on the first failed attempt, which
  races a server being stopped or restarted (sandbox reset, sidecar
  relaunch). It now logs only after 3 consecutive failures, with the error
  normalized to a readable string.
- The DEV duplicate-command-id warning fired on router-transition overlap
  (draft->session registers command.palette/input.focus twice for a
  moment). It now re-checks after 1s and only reports persistent
  duplicates.
- spyRendererConsole receives Chromium's flattened console-message string,
  so renderer console.* with object args reached the terminal and exported
  debug bundles as "[object Object]". A renderer console wrapper now
  serializes structured arguments (Error-aware, circular-safe, truncated).
- Two benign Chromium interventions (ResizeObserver loop, autofocus
  blocked) are dropped from the terminal transport; file logs keep them.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
@quickbeard
quickbeard merged commit 57f79ec into main Aug 14, 2026
0 of 5 checks passed
@quickbeard
quickbeard deleted the fix/dev-run-errors branch August 14, 2026 06:27
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.

1 participant