Skip to content

feat(native): diagnostics resource monitor - #114

Merged
rynfar merged 2 commits into
nativefrom
nw/112-resource-monitor
Nov 3, 2026
Merged

rynfar merged 2 commits into
nativefrom
nw/112-resource-monitor

Conversation

@rynfar

@rynfar rynfar commented Nov 3, 2026 •

Copy link
Copy Markdown
Owner

Settings → Diagnostics had the legacy process tables but no resource monitor. This ports the five sections from ResourceTelemetryDiagnostics.tsx: system footprint, host/collection health, resource timeline, live process tree, and instrumented application I/O.

The core owns forward-compatible snapshot/history/retry types and the web's pure logic, including non-depth-first collapse, PID + start-time identity, retry availability, units, and zero-valued history bars. The client decodes on Tokio, publishes the latest snapshot through a bounded watch, reconnects after transport loss, and interrupts demand when its owner drops. Diagnostics owns that handle only while open, resets it on environment changes, and drops it on loss of diagnostics access. Retry checks both diagnostics-read and environment-maintain permission. History includes all four periods, CPU/read/write bars and bucket tooltips; there is no chart animation or new repaint timer. Tables preserve the server's ordering and are virtualized.

ST-DIAG remains partial. Remaining gaps: signal buttons are not duplicated into the new monitor tree (the existing Live Processes controls remain; additional signal actions were out of scope), and the earlier database-notice dismissal remains per app session. No signals were sent through Diagnostics. Refs #112.

Review fixes: connection-wide Defect/ClientProtocolError failures now resume telemetry on the next session; request-local permission and unknown-method errors remain terminal. History state is keyed to the selected period, so a loading or failed 5m request cannot display previously loaded 15m results. Diagnostics owns one history completion task; replacing it or leaving the page aborts its Tokio request and sends an RPC Interrupt. Permission loss and environment switches use the same cancellation path. Three regression tests failed before the fixes; all ten telemetry-focused tests pass.

Validation:

  • Telemetry-focused regressions: cargo test -p t3-core -p t3-client resource_telemetry (10 passed)
  • cargo clippy --workspace --all-targets -- -D warnings
  • cargo test --workspace (1,086 tests passed)
  • cargo build -p t3-native --features snapshot
  • node scripts/gen-theme.ts --check
  • node --test parity/sync.test.ts
  • From client-runtime: node ../../apps/native/conformance/generate.ts --check
  • vp run check:changed fork/native (plus the default changed-file checks; native is the PR base)

Re-ran the read-only smoke probe after the review fixes: the subscription and all four history windows still decode (collector unavailable). The original implementation also exercised Retry successfully, as recorded below.

Smoke probe (T3_NATIVE_HOME points at this worktree's copied smoke home):

server http://127.0.0.1:14658
subscribeResourceTelemetry native=unavailable processes=0 interval=0ms readAt=2026-11-02T17:58:59.451Z
subscribeResourceTelemetry native=unavailable processes=0 interval=0ms readAt=2026-11-02T17:58:59.451Z
server.getResourceTelemetryHistory 5m buckets=20 topProcesses=0 samples=0
server.getResourceTelemetryHistory 15m buckets=30 topProcesses=0 samples=0
server.getResourceTelemetryHistory 30m buckets=30 topProcesses=0 samples=0
server.getResourceTelemetryHistory 1h buckets=30 topProcesses=0 samples=0
server.retryResourceTelemetry accepted=true native=unavailable
unsubscribeResourceTelemetry (owner dropped; Interrupt verified in client test)

The smoke server lacks its resource-monitor binary for darwin/arm64, so populated process samples could only be verified using fixtures. The retry changes no saved configuration. No provider turns were sent. The passive real-window capture is of our own PID 47906, without synthetic input; that PID was stopped afterwards.

Local PNG evidence (kept local as instructed; not uploaded or committed):

Capture Absolute path
Before (legacy Diagnostics, new sections omitted) /private/tmp/t3-native-112-evidence/before.png
After, populated footprint and host /private/tmp/t3-native-112-evidence/after.png
Timeline and process columns /private/tmp/t3-native-112-evidence/timeline.png
Tree and application I/O /private/tmp/t3-native-112-evidence/tree.png
Collapsed server, separate monitor retained /private/tmp/t3-native-112-evidence/collapsed.png
Unsupported platform + Retry /private/tmp/t3-native-112-evidence/unsupported.png
Subscription error + Retry /private/tmp/t3-native-112-evidence/error.png
Loading /private/tmp/t3-native-112-evidence/loading.png
Empty /private/tmp/t3-native-112-evidence/empty.png
Light appearance /private/tmp/t3-native-112-evidence/light.png
Smoke server, actual unavailable collector /private/tmp/t3-native-112-evidence/smoke.png
Review: loaded 15m history /private/tmp/t3-native-112-evidence/history-period-before.png
Review: switched 5m loading, no prior data /private/tmp/t3-native-112-evidence/history-period-loading.png
Review: switched 5m failure, no prior data /private/tmp/t3-native-112-evidence/history-period-failure.png
Passive real window, PID filtered /private/tmp/t3-native-112-evidence/real-window.png

Reproduce a fixture capture with --snapshot <out.png> --settings diagnostics --resource-telemetry-fixture <json>. Fixture JSON contains snapshot, history, and error; optional history_pending and history_error control subsequent history requests for review captures; the local populated fixture is /private/tmp/t3-native-112-evidence/populated.json. resource_telemetry_probe -- --retry is restricted to the smoke origin.

Built with GPT-6.1 Sol in Codex

@rynfar
rynfar force-pushed the nw/112-resource-monitor branch from 6b28d31 to 1a1cb16 Compare November 3, 2026 08:41
@rynfar

rynfar commented Nov 3, 2026

Copy link
Copy Markdown
Owner Author

Fixed all three verified P2s and rebased onto fork/native @ aff9199ee1.

Head: 1a1cb16e5fbecc935d39d929fe88fd0c60e6c318.

  1. Telemetry retries connection-wide Defect/ClientProtocolError failures using the session's closed pending map; permission failures and request-local unknown-method Exit/Die stay terminal. Tested both recovery paths and terminal classifications against the fake RPC server.
  2. A telemetry-specific HistoryState resets the query when the selected period changes. Loading or failed 5m requests cannot retain 15m data. Same-period refresh retention remains unchanged, and stale replies from older periods/visits are rejected.
  3. Diagnostics owns one history completion task. Replacement, page leave, permission loss and environment changes drop it; its request owner aborts Tokio work. Unary forwarding now propagates caller cancellation to pending-map removal and a wire Interrupt, verified by a focused lifecycle test. Dropping a completed request leaves the connection usable.

The three regressions failed before their fixes. All ten telemetry-focused tests and all 1,086 workspace tests pass. Clippy, snapshot build, theme, parity, conformance and vp run check:changed fork/native pass. The read-only smoke probe still decodes snapshots and all four history periods. The collector remains unavailable on the smoke server, so populated states use fixtures.

Updated local evidence (also in the PR body):

  • /private/tmp/t3-native-112-evidence/history-period-before.png — populated 15m
  • /private/tmp/t3-native-112-evidence/history-period-loading.png — selected 5m loading, no prior data
  • /private/tmp/t3-native-112-evidence/history-period-failure.png — selected 5m failed, no prior data

ST-DIAG remains partial for the previously listed gaps. No merge performed.

@rynfar

rynfar commented Nov 3, 2026

Copy link
Copy Markdown
Owner Author

Exact-head orchestrator gate GREEN at 1a1cb16e5fbecc935d39d929fe88fd0c60e6c318: Clippy, all 1,086 native tests, theme, parity, and conformance passed (exit 0). Independent Sol re-review is clean, including shared unary-RPC cancellation and the three fixed findings. Loading/failure captures inspected: changing to 5m no longer presents old 15m bars or totals. Live populated collector data remains fixture-only because the smoke server lacks the monitor binary; monitor-tree signal controls remain deferred. Native-only surface; shared client RPC cancellation was explicitly reviewed against terminal ordering and update-handoff callers.

@rynfar
rynfar merged commit 9d66d72 into native Nov 3, 2026
@rynfar rynfar mentioned this pull request Nov 3, 2026
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