Skip to content

feat(desktop): improve hot CPU diagnostics workflow#308

Open
huntharo wants to merge 2 commits into
mainfrom
feat/developer-diagnostics-followup
Open

feat(desktop): improve hot CPU diagnostics workflow#308
huntharo wants to merge 2 commits into
mainfrom
feat/developer-diagnostics-followup

Conversation

@huntharo

@huntharo huntharo commented Jul 5, 2026

Copy link
Copy Markdown
Contributor

Summary

Hot CPU diagnostics are now easier to hand off and safer to operate after a capture. The copied profile text keeps the exact artifact paths, calls out sidecar files, and frames the capture as troubleshooting evidence rather than proof that a bug is still active.

Developer troubleshooting actions now go through diagnostics:* command-bus verbs. The banner can reveal the captured session, Settings can reveal the diagnostics root, and cleanup only targets hot CPU session-shaped direct children under the current hot CPU diagnostics root.

The cleanup path is hardened after review: it uses the same env-aware output root as capture writes, skips active in-process sessions at the main-process command boundary, disables conflicting Settings actions while cleanup is pending, and ignores stale banner reveal failures after a newer profile arrives. Hot CPU sessions also have bounded retention plus a durable runbook for opening .cpuprofile and .heapsnapshot artifacts in Chrome DevTools.

Screenshots

Not included. This is a developer-only diagnostics surface, and the important runtime evidence is the built-app profiling artifact smoke below.

Screen recording

Not included.

How was this tested?

  • pnpm exec vitest run --config vitest.workspace.ts apps/desktop/src/main/handlers/__tests__/diagnostics-handlers.test.ts apps/desktop/src/main/diagnostics/__tests__/hot-cpu-profile-retention.test.ts apps/desktop/src/main/diagnostics/__tests__/hot-cpu-profile-session.test.ts apps/desktop/src/renderer/src/features/settings/pages/__tests__/DeveloperPage.test.tsx apps/desktop/src/renderer/src/features/library/__tests__/HotCpuProfileBanner.test.tsx — 28 passing
  • pnpm typecheck
  • pnpm test — 259 files, 3060 passing, 1 skipped
  • pnpm build
  • pnpm lint

Built-app smoke from the first commit:

  • Launched apps/desktop from the built out/ files through Electron with PWRSNAP_E2E=1 and a temporary PWRSNAP_USER_DATA.
  • Armed hot CPU profiling with a low threshold and heap snapshot capture.
  • Verified the temporary diagnostics root contained session.json, samples.ndjson, events.ndjson, renderer-hot-0001.cpuprofile, and renderer-hot-0001-start.heapsnapshot.
  • Parsed the .cpuprofile JSON and verified it had non-empty nodes and samples arrays.

Review:

  • Ran compound-engineering:ce-code-review; it found cleanup/root/race hardening gaps. Fixed them in fix(desktop): harden hot CPU diagnostics cleanup and reran the full local gates above.

Post-Deploy Monitoring & Validation

  • Log searches: hot CPU diagnostics, retention-pruned, hot_cpu_diagnostics_reveal_failed, SESSION_CREATE_FAILED, diagnostics:clearHotCpuSessions, handler_threw diagnostics.
  • Metrics/signals: developer reports include complete profile handoff text; diagnostics directories contain session.json, samples.ndjson, events.ndjson, .cpuprofile, and optional .heapsnapshot; repeated sessions stay bounded to the latest retained set.
  • Healthy signal: a newly captured hot CPU profile can be revealed from the banner, opened in Chrome DevTools, and correlated with sidecar samples/events.
  • Failure signal: reveal commands return validation errors for valid sessions, active captures fail to write artifacts, cleanup removes active/non-session directories, or diagnostics storage grows without pruning.
  • Rollback/mitigation: disable hot CPU profiling from Settings or unset PWRSNAP_HOT_CPU_PROFILING; if artifact creation/regression is confirmed, revert this PR before the next desktop release.
  • Validation window and owner: validate during the first dogfood session after merge; owner is the PwrSnap desktop maintainer running the diagnostics capture.

Checklist

  • PR title follows type(scope): description
  • Tests added or updated
  • Relevant checks pass locally (pnpm test, pnpm typecheck)
  • THIRD_PARTY_LICENSES unchanged; no dependency changes
  • Screenshot or recording attached for user-facing changes

Compound Engineering
GPT-5

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