Skip to content

feat(diagnostics): add an opt-in log for UI hangs - #15

Merged
nplez1 merged 1 commit into
nplez1/mainfrom
nplez1/Debug-Options
Sep 21, 2026
Merged

nplez1 merged 1 commit into
nplez1/mainfrom
nplez1/Debug-Options

Conversation

@nplez1

@nplez1 nplez1 commented Sep 21, 2026 •

Copy link
Copy Markdown
Owner
Files Added Deleted Net
Test 14 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​772 0 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​772
Prod 27 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​820 $\color{#cf222e}{\Huge{\mathbf{−}}}$​5 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​815

ELI5

Sometimes the Orca window freezes. There was no way to record what happened when it did, so "it froze again" was all we could go on. This adds a switch that writes a detailed log of those freezes to a file you can send us.

What Changed

Before: nothing captured a hang. The only existing signal was a macOS watchdog marker consumed on the next launch, and the main-thread probe is an env-var diagnostic (ORCA_MAIN_THREAD_DIAGNOSTICS=1) most people never set. A user hitting a hang repeatedly had no evidence to hand over.

After: Settings → Advanced → Debug Options has a new Log UI hangs switch, off by default. While it is on, Orca appends NDJSON to <userData>/logs/ui-hangs.ndjson, and the pane shows that exact path — plus a note when local writes are disabled by policy (CI / ORCA_DIAGNOSTICS_DISABLED). The toggle applies immediately; no restart.

One file now captures every way the UI stops responding:

Record What it means
stall the renderer's own UI thread was blocked for 250 ms or more
main-stall the main event loop was blocked for 250 ms or more (freezes IPC and terminal input even though the renderer keeps painting), with the subprocess spawns that blocked it
window-unresponsive / window-responsive Electron's coarse window-level freeze, with the recovered duration on the responsive half
ui-hang-meta one header line identifying the build: app version, platform, arch, OS release

Mechanism: a timer that fires late by N ms proves that thread was blocked for N ms. One shared detector (with a sleep/resume guard so waking a laptop never logs a fake hang) backs both the renderer and main probes, so their durations are directly comparable. Main-stall attribution reuses the spawn-initiation timing the git runners already measure — no new call sites and no parallel collector.

Why

The alternative was to keep the main-thread probe env-gated and ask users to relaunch with ORCA_MAIN_THREAD_DIAGNOSTICS=1, which is unrealistic for the people actually hitting hangs. Turning it into a setting that writes a plain, self-describing file means someone can collect evidence without a debugger or a terminal, and we can see the build it came from.

I reused the existing rotating NDJSON sink and the same local-file consent boundary as the trace lane rather than building a second logging path. Renderer samples are normalized at the IPC boundary and cannot inject main-only fields; records carry only timing, source, surface, and visibility — never terminal contents, URLs, env, or account data.

The env-gated churn probe and the macOS hang watchdog are unchanged; only their spawn collector is now shared.

Linked Issue

No tracking issue — this was requested directly.

Visual Proof

Before: the Advanced pane had no Debug Options section. After, rendered from the production AdvancedPane in a hidden Electron window (tests/tools/ui-hang-logging-ui/run.mjs):

Off (default) On
Debug Options, switch off Debug Options, switch on with the log path revealed

The "on" shot is the change the feature is about: flipping the switch reveals the ui-hangs.ndjson path to collect.

Testing

  • pnpm tc:node, pnpm tc:web
  • pnpm run check:code-quality:changed, plus the max-lines, runtime-electron, and rpc-params-catalog gates
  • Localization catalog, extraction, and coverage checks
  • Targeted vitest: ui-hang-log-sink, main-thread-stall-probe, the renderer probe, the window observer, the Debug Options pane, the preload composition test, and the startup / settings-IPC suites — all pass
  • Rendered proof above: hidden window, no page errors, window never made visible

Verified on macOS. Not manually tested on Linux or Windows, and not exercised over SSH. The feature is desktop-only (the Advanced pane is desktop-gated) and the web client gets a deliberate no-op stub.

  • I manually tested these changes locally
  • Automated tests added/updated, or explained why not below

AI Disclosure

Authored with an AI coding agent (pi, deepseek-flash) under human direction. Every change was reviewed and verified against the repo's gates and tests.

Review

Start with src/shared/ui-hang-diagnostics-types.ts (the record shape), then src/main/diagnostics/ui-hang-log-sink.ts (the untrusted-input boundary) and src/main/diagnostics/main-thread-stall-probe.ts (the main-process detector plus spawn attribution). The renderer side is src/renderer/src/lib/ui-hang-diagnostics/ and the UI is UiHangDiagnosticsSetting.tsx.

Agent skill upstream boundary

  • Not applicable, or this change follows docs/reference/agent-skill-sharing-upstream-boundary.md and copies or mechanically translates no upstream skill-installer source, tests, fixtures, registry entries, path tables, comments, or documentation.

Notes

  • Security: the renderer is untrusted; main rejects malformed samples and drops main-only fields (spawn attribution). Only timing/identity-safe fields are written.
  • Cross-platform: pure Node/Electron APIs, no platform-specific paths or shortcuts.
  • SSH / folder workspaces / mobile: unaffected; the feature is desktop-only and no-ops elsewhere.
  • Backwards compatibility: new optional setting, defaults off; older profiles omit it safely.
  • Performance: with the setting off, the main probe does not run at all; spawn attribution is a lone boolean check per spawn. With it on, spawn classification costs the same as the existing env-gated lane.

Checklist

  • This PR is small and focused
  • I explained what changed and why (ELI5, the user-facing before/after, the mechanism, and why over the alternatives)
  • Before/after screenshots or videos attached for UI changes, or N/A with reason
  • Self-reviewed for correctness, security, and performance
  • Cross-platform, SSH/remote, and path/shortcut impact considered (or N/A)
  • pnpm lint, pnpm typecheck, pnpm test, and pnpm build pass — typecheck, the changed-code quality gate, and targeted tests ran locally; the full pnpm test and pnpm build were not run on this machine (CI will cover).

Users who hit repeated hangs had no way to hand us evidence: the only existing
signal was a macOS watchdog marker consumed on the next launch, and the
main-thread probe is an env-var diagnostic most people never set.

Settings → Advanced → Debug Options now has a "Log UI hangs" switch, off by
default. While it is on, Orca appends NDJSON to logs/ui-hangs.ndjson and the
pane shows that exact path, so the file can be collected without hunting
through the logs folder. The toggle applies immediately; no restart.

One file now captures the three distinct ways the UI stops responding:

- `stall` — the renderer's own UI thread was blocked for 250 ms or more,
  measured by a tick-vs-clock watchdog that survives system sleep.
- `main-stall` — the same measurement on the main process, where a blocked
  event loop freezes IPC and terminal input even though the renderer keeps
  painting. These records also name the subprocess spawns that blocked the
  thread, reusing the spawn-initiation timing the git runners already take.
- `window-unresponsive` / `window-responsive` — Electron's coarse window
  signal, with the recovered duration on the responsive half.

A `ui-hang-meta` header records the app version, platform, arch, and OS release
so a collected file is traceable to a release.

Reuses the existing rotating NDJSON sink and honors the same local-file consent
boundary as the trace lane (CI / ORCA_DIAGNOSTICS_DISABLED). Renderer samples
are normalized at the IPC boundary and cannot inject main-only fields; records
carry only timing, source, surface, and visibility — never terminal contents,
URLs, env, or account data.

The env-gated ORCA_MAIN_THREAD_DIAGNOSTICS churn probe and the macOS hang
watchdog are unchanged; only their spawn collector is now shared.

Tests: ui-hang-log-sink, main-thread-stall-probe, the renderer probe, the window
observer, the Debug Options pane, and the preload composition; tc:node, tc:web,
the changed-code quality gate, and the localization checks pass. A hidden-Electron
rendered proof (tests/tools/ui-hang-logging-ui) captures the pane before and after
the switch is flipped.
@nplez1
nplez1 force-pushed the nplez1/Debug-Options branch from e99414a to 27c3000 Compare September 21, 2026 17:37
@nplez1
nplez1 merged this pull request into nplez1/main Sep 21, 2026
35 checks passed
nplez1 added a commit that referenced this pull request Sep 21, 2026
Users who hit repeated hangs had no way to hand us evidence: the only existing
signal was a macOS watchdog marker consumed on the next launch, and the
main-thread probe is an env-var diagnostic most people never set.

Settings → Advanced → Debug Options now has a "Log UI hangs" switch, off by
default. While it is on, Orca appends NDJSON to logs/ui-hangs.ndjson and the
pane shows that exact path, so the file can be collected without hunting
through the logs folder. The toggle applies immediately; no restart.

One file now captures the three distinct ways the UI stops responding:

- `stall` — the renderer's own UI thread was blocked for 250 ms or more,
  measured by a tick-vs-clock watchdog that survives system sleep.
- `main-stall` — the same measurement on the main process, where a blocked
  event loop freezes IPC and terminal input even though the renderer keeps
  painting. These records also name the subprocess spawns that blocked the
  thread, reusing the spawn-initiation timing the git runners already take.
- `window-unresponsive` / `window-responsive` — Electron's coarse window
  signal, with the recovered duration on the responsive half.

A `ui-hang-meta` header records the app version, platform, arch, and OS release
so a collected file is traceable to a release.

Reuses the existing rotating NDJSON sink and honors the same local-file consent
boundary as the trace lane (CI / ORCA_DIAGNOSTICS_DISABLED). Renderer samples
are normalized at the IPC boundary and cannot inject main-only fields; records
carry only timing, source, surface, and visibility — never terminal contents,
URLs, env, or account data.

The env-gated ORCA_MAIN_THREAD_DIAGNOSTICS churn probe and the macOS hang
watchdog are unchanged; only their spawn collector is now shared.

Tests: ui-hang-log-sink, main-thread-stall-probe, the renderer probe, the window
observer, the Debug Options pane, and the preload composition; tc:node, tc:web,
the changed-code quality gate, and the localization checks pass. A hidden-Electron
rendered proof (tests/tools/ui-hang-logging-ui) captures the pane before and after
the switch is flipped.
nplez1 added a commit that referenced this pull request Sep 22, 2026
Users who hit repeated hangs had no way to hand us evidence: the only existing
signal was a macOS watchdog marker consumed on the next launch, and the
main-thread probe is an env-var diagnostic most people never set.

Settings → Advanced → Debug Options now has a "Log UI hangs" switch, off by
default. While it is on, Orca appends NDJSON to logs/ui-hangs.ndjson and the
pane shows that exact path, so the file can be collected without hunting
through the logs folder. The toggle applies immediately; no restart.

One file now captures the three distinct ways the UI stops responding:

- `stall` — the renderer's own UI thread was blocked for 250 ms or more,
  measured by a tick-vs-clock watchdog that survives system sleep.
- `main-stall` — the same measurement on the main process, where a blocked
  event loop freezes IPC and terminal input even though the renderer keeps
  painting. These records also name the subprocess spawns that blocked the
  thread, reusing the spawn-initiation timing the git runners already take.
- `window-unresponsive` / `window-responsive` — Electron's coarse window
  signal, with the recovered duration on the responsive half.

A `ui-hang-meta` header records the app version, platform, arch, and OS release
so a collected file is traceable to a release.

Reuses the existing rotating NDJSON sink and honors the same local-file consent
boundary as the trace lane (CI / ORCA_DIAGNOSTICS_DISABLED). Renderer samples
are normalized at the IPC boundary and cannot inject main-only fields; records
carry only timing, source, surface, and visibility — never terminal contents,
URLs, env, or account data.

The env-gated ORCA_MAIN_THREAD_DIAGNOSTICS churn probe and the macOS hang
watchdog are unchanged; only their spawn collector is now shared.

Tests: ui-hang-log-sink, main-thread-stall-probe, the renderer probe, the window
observer, the Debug Options pane, and the preload composition; tc:node, tc:web,
the changed-code quality gate, and the localization checks pass. A hidden-Electron
rendered proof (tests/tools/ui-hang-logging-ui) captures the pane before and after
the switch is flipped.
nplez1 added a commit that referenced this pull request Sep 25, 2026
Users who hit repeated hangs had no way to hand us evidence: the only existing
signal was a macOS watchdog marker consumed on the next launch, and the
main-thread probe is an env-var diagnostic most people never set.

Settings → Advanced → Debug Options now has a "Log UI hangs" switch, off by
default. While it is on, Orca appends NDJSON to logs/ui-hangs.ndjson and the
pane shows that exact path, so the file can be collected without hunting
through the logs folder. The toggle applies immediately; no restart.

One file now captures the three distinct ways the UI stops responding:

- `stall` — the renderer's own UI thread was blocked for 250 ms or more,
  measured by a tick-vs-clock watchdog that survives system sleep.
- `main-stall` — the same measurement on the main process, where a blocked
  event loop freezes IPC and terminal input even though the renderer keeps
  painting. These records also name the subprocess spawns that blocked the
  thread, reusing the spawn-initiation timing the git runners already take.
- `window-unresponsive` / `window-responsive` — Electron's coarse window
  signal, with the recovered duration on the responsive half.

A `ui-hang-meta` header records the app version, platform, arch, and OS release
so a collected file is traceable to a release.

Reuses the existing rotating NDJSON sink and honors the same local-file consent
boundary as the trace lane (CI / ORCA_DIAGNOSTICS_DISABLED). Renderer samples
are normalized at the IPC boundary and cannot inject main-only fields; records
carry only timing, source, surface, and visibility — never terminal contents,
URLs, env, or account data.

The env-gated ORCA_MAIN_THREAD_DIAGNOSTICS churn probe and the macOS hang
watchdog are unchanged; only their spawn collector is now shared.

Tests: ui-hang-log-sink, main-thread-stall-probe, the renderer probe, the window
observer, the Debug Options pane, and the preload composition; tc:node, tc:web,
the changed-code quality gate, and the localization checks pass. A hidden-Electron
rendered proof (tests/tools/ui-hang-logging-ui) captures the pane before and after
the switch is flipped.
nplez1 added a commit that referenced this pull request Sep 27, 2026
Users who hit repeated hangs had no way to hand us evidence: the only existing
signal was a macOS watchdog marker consumed on the next launch, and the
main-thread probe is an env-var diagnostic most people never set.

Settings → Advanced → Debug Options now has a "Log UI hangs" switch, off by
default. While it is on, Orca appends NDJSON to logs/ui-hangs.ndjson and the
pane shows that exact path, so the file can be collected without hunting
through the logs folder. The toggle applies immediately; no restart.

One file now captures the three distinct ways the UI stops responding:

- `stall` — the renderer's own UI thread was blocked for 250 ms or more,
  measured by a tick-vs-clock watchdog that survives system sleep.
- `main-stall` — the same measurement on the main process, where a blocked
  event loop freezes IPC and terminal input even though the renderer keeps
  painting. These records also name the subprocess spawns that blocked the
  thread, reusing the spawn-initiation timing the git runners already take.
- `window-unresponsive` / `window-responsive` — Electron's coarse window
  signal, with the recovered duration on the responsive half.

A `ui-hang-meta` header records the app version, platform, arch, and OS release
so a collected file is traceable to a release.

Reuses the existing rotating NDJSON sink and honors the same local-file consent
boundary as the trace lane (CI / ORCA_DIAGNOSTICS_DISABLED). Renderer samples
are normalized at the IPC boundary and cannot inject main-only fields; records
carry only timing, source, surface, and visibility — never terminal contents,
URLs, env, or account data.

The env-gated ORCA_MAIN_THREAD_DIAGNOSTICS churn probe and the macOS hang
watchdog are unchanged; only their spawn collector is now shared.

Tests: ui-hang-log-sink, main-thread-stall-probe, the renderer probe, the window
observer, the Debug Options pane, and the preload composition; tc:node, tc:web,
the changed-code quality gate, and the localization checks pass. A hidden-Electron
rendered proof (tests/tools/ui-hang-logging-ui) captures the pane before and after
the switch is flipped.
nplez1 added a commit that referenced this pull request Sep 29, 2026
Users who hit repeated hangs had no way to hand us evidence: the only existing
signal was a macOS watchdog marker consumed on the next launch, and the
main-thread probe is an env-var diagnostic most people never set.

Settings → Advanced → Debug Options now has a "Log UI hangs" switch, off by
default. While it is on, Orca appends NDJSON to logs/ui-hangs.ndjson and the
pane shows that exact path, so the file can be collected without hunting
through the logs folder. The toggle applies immediately; no restart.

One file now captures the three distinct ways the UI stops responding:

- `stall` — the renderer's own UI thread was blocked for 250 ms or more,
  measured by a tick-vs-clock watchdog that survives system sleep.
- `main-stall` — the same measurement on the main process, where a blocked
  event loop freezes IPC and terminal input even though the renderer keeps
  painting. These records also name the subprocess spawns that blocked the
  thread, reusing the spawn-initiation timing the git runners already take.
- `window-unresponsive` / `window-responsive` — Electron's coarse window
  signal, with the recovered duration on the responsive half.

A `ui-hang-meta` header records the app version, platform, arch, and OS release
so a collected file is traceable to a release.

Reuses the existing rotating NDJSON sink and honors the same local-file consent
boundary as the trace lane (CI / ORCA_DIAGNOSTICS_DISABLED). Renderer samples
are normalized at the IPC boundary and cannot inject main-only fields; records
carry only timing, source, surface, and visibility — never terminal contents,
URLs, env, or account data.

The env-gated ORCA_MAIN_THREAD_DIAGNOSTICS churn probe and the macOS hang
watchdog are unchanged; only their spawn collector is now shared.

Tests: ui-hang-log-sink, main-thread-stall-probe, the renderer probe, the window
observer, the Debug Options pane, and the preload composition; tc:node, tc:web,
the changed-code quality gate, and the localization checks pass. A hidden-Electron
rendered proof (tests/tools/ui-hang-logging-ui) captures the pane before and after
the switch is flipped.
nplez1 added a commit that referenced this pull request Oct 1, 2026
Users who hit repeated hangs had no way to hand us evidence: the only existing
signal was a macOS watchdog marker consumed on the next launch, and the
main-thread probe is an env-var diagnostic most people never set.

Settings → Advanced → Debug Options now has a "Log UI hangs" switch, off by
default. While it is on, Orca appends NDJSON to logs/ui-hangs.ndjson and the
pane shows that exact path, so the file can be collected without hunting
through the logs folder. The toggle applies immediately; no restart.

One file now captures the three distinct ways the UI stops responding:

- `stall` — the renderer's own UI thread was blocked for 250 ms or more,
  measured by a tick-vs-clock watchdog that survives system sleep.
- `main-stall` — the same measurement on the main process, where a blocked
  event loop freezes IPC and terminal input even though the renderer keeps
  painting. These records also name the subprocess spawns that blocked the
  thread, reusing the spawn-initiation timing the git runners already take.
- `window-unresponsive` / `window-responsive` — Electron's coarse window
  signal, with the recovered duration on the responsive half.

A `ui-hang-meta` header records the app version, platform, arch, and OS release
so a collected file is traceable to a release.

Reuses the existing rotating NDJSON sink and honors the same local-file consent
boundary as the trace lane (CI / ORCA_DIAGNOSTICS_DISABLED). Renderer samples
are normalized at the IPC boundary and cannot inject main-only fields; records
carry only timing, source, surface, and visibility — never terminal contents,
URLs, env, or account data.

The env-gated ORCA_MAIN_THREAD_DIAGNOSTICS churn probe and the macOS hang
watchdog are unchanged; only their spawn collector is now shared.

Tests: ui-hang-log-sink, main-thread-stall-probe, the renderer probe, the window
observer, the Debug Options pane, and the preload composition; tc:node, tc:web,
the changed-code quality gate, and the localization checks pass. A hidden-Electron
rendered proof (tests/tools/ui-hang-logging-ui) captures the pane before and after
the switch is flipped.
nplez1 added a commit that referenced this pull request Oct 6, 2026
Users who hit repeated hangs had no way to hand us evidence: the only existing
signal was a macOS watchdog marker consumed on the next launch, and the
main-thread probe is an env-var diagnostic most people never set.

Settings → Advanced → Debug Options now has a "Log UI hangs" switch, off by
default. While it is on, Orca appends NDJSON to logs/ui-hangs.ndjson and the
pane shows that exact path, so the file can be collected without hunting
through the logs folder. The toggle applies immediately; no restart.

One file now captures the three distinct ways the UI stops responding:

- `stall` — the renderer's own UI thread was blocked for 250 ms or more,
  measured by a tick-vs-clock watchdog that survives system sleep.
- `main-stall` — the same measurement on the main process, where a blocked
  event loop freezes IPC and terminal input even though the renderer keeps
  painting. These records also name the subprocess spawns that blocked the
  thread, reusing the spawn-initiation timing the git runners already take.
- `window-unresponsive` / `window-responsive` — Electron's coarse window
  signal, with the recovered duration on the responsive half.

A `ui-hang-meta` header records the app version, platform, arch, and OS release
so a collected file is traceable to a release.

Reuses the existing rotating NDJSON sink and honors the same local-file consent
boundary as the trace lane (CI / ORCA_DIAGNOSTICS_DISABLED). Renderer samples
are normalized at the IPC boundary and cannot inject main-only fields; records
carry only timing, source, surface, and visibility — never terminal contents,
URLs, env, or account data.

The env-gated ORCA_MAIN_THREAD_DIAGNOSTICS churn probe and the macOS hang
watchdog are unchanged; only their spawn collector is now shared.

Tests: ui-hang-log-sink, main-thread-stall-probe, the renderer probe, the window
observer, the Debug Options pane, and the preload composition; tc:node, tc:web,
the changed-code quality gate, and the localization checks pass. A hidden-Electron
rendered proof (tests/tools/ui-hang-logging-ui) captures the pane before and after
the switch is flipped.
@nplez1
nplez1 deleted the nplez1/Debug-Options branch October 24, 2026 03:23
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