Skip to content

perf: skip new server status checks after settings closes - #23151

Closed
nwparker wants to merge 2 commits into
mainfrom
nwparker/perf-09-25-settings-status-lifetime
Closed

nwparker wants to merge 2 commits into
mainfrom
nwparker/perf-09-25-settings-status-lifetime

Conversation

@nwparker

@nwparker nwparker commented Sep 26, 2026 •

Copy link
Copy Markdown
Contributor
Files Added Deleted Net
Test 1 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​246 0 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​246
Prod 1 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​34 $\color{#cf222e}{\Huge{\mathbf{−}}}$​25 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​9

ELI5

Closing Remote Orca Servers stops new server checks from starting when its saved-server list arrives late.

What Changed

The catalog hook checks whether the pane is still open after the list arrives and after a verified-status wait. In a controlled 40-server case, closing before the list resolves reduces status probes and follow-up snapshot reads from 40 each to 0.

Actual-hook test: 40-server list arrives after close Before After
Status calls started 40 0
Shared snapshot reads started 40 0
Saved-server catalog publications 1 1

Counts use mocked bridge/store boundaries, not physical socket opens or measured UI latency.

Why

The hook keeps shared catalog updates so an add/remove operation that finishes after closing still updates other host pickers. Already-started checks finish normally. Canceling the whole load would also discard those catalog updates. The trade-off is that closing before probing begins defers status freshness to normal status events, another refresh, or reopening.

Separate trade-off PR: status freshness can be delayed with no bounded refresh deadline. The app feed does not guarantee immediate recovery: a new host's event may arrive before its catalog entry and be ignored. A later event, hydration, refresh or reopening may be needed. Already-admitted add/connect/remove operations still finish; connection can begin sooner after closing because the extra status wait is removed.

Linked Issue

Fixes #23150

Visual Proof

N/A

Visible rendering and controls are unchanged; this removes background work after the pane closes. Rendered application and physical server behavior were not exercised.

Testing

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

Six lifecycle tests pass; the original code fails three. Tests use actual React hooks in happy-dom with fake server and store calls, including late list/snapshot completion, mutation catalog reconciliation, active filtering, already-started probes and failures. Renderer typecheck, focused lint/format and the full changed-code quality gate (157 files) pass on macOS. Tests used background-launch mode. No native app, actual IPC/network, SSH/WSL or Windows/Linux runtime test; broader CI/build checks remain pending.

Review

Independent review approved the exact source/test hashes. Ten additional actual-hook tests pass (original five fail), including real add/remove callback paths, web-connect failure rollback, StrictMode effect replay, separate remount ownership and admitted probe success/failure after close. The permanent six-case suite was independently reproduced (original three fail).

Merge risk: low implementation complexity, moderate freshness risk for shared server status. Active request generation and late shared catalog overwrite remain unchanged; this is not general stale-load protection.

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

No host routing, wire formats, process-liveness verdicts or mutations change. Overlapping-refresh generation and cancellation of already-started requests remain outside this change.

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 (or CI will cover; local preferred)

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

ℹ️ No critical issues — one minor cleanup suggestion inline.

Reviewed changes

  • Skip probes after the settings pane closes — loadEnvironments now returns early once the saved-server list has resolved if the pane unmounted, and again after the verified-status snapshot wait, so a closed pane no longer starts status probes or follow-up snapshot reads while still publishing the shared catalog for mutation reconciliation.
  • Lifetime test suite — new happy-dom suite driving the real hook, covering a late list after close, a late mutation-driven reload, a verified wait that outlives the pane, preservation of active probes (verified/ephemeral skipping, exact call counts), an already-started probe after close, and late-error suppression.

The behavior change is narrow and matches the linked issue's documented trade-off (catalog publication is kept; status freshness for a closing pane defers to later events/refresh/reopen). Tests are meaningful — the three closed-pane cases assert getStatus/readRuntimeHostStatusSnapshots are not called, which the unguarded code fails. Focused suite verified passing locally.

Pullfrog  | Fix all ➔ | Fix 👍s ➔ | View workflow run | Using DeepSeek Flash (free via Pullfrog for OSS) | 𝕏

@coderabbitai

coderabbitai Bot commented Sep 26, 2026 •

Copy link
Copy Markdown
Contributor

Review in Change Stack →

Navigate logical layers of code changes, visualize relationships, and explore their blast radius.

Warning

Review limit reached

Next included review available in 9 minutes.

Check out review usage here.

View limit details

Limit details: You’ve used all 10 included reviews currently available.

You've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository.

Learn how review limits work.

Review configuration:

⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Advanced

Run ID: a7a21a32-7885-4bfe-bc11-2c5717253d89

📥 Commits

Reviewing files that changed from the base of the PR and between 6cab5ad and 12e0ced.

📒 Files selected for processing (2)
  • src/renderer/src/components/settings/use-runtime-environment-catalog-lifetime.test.ts
  • src/renderer/src/components/settings/use-runtime-environment-catalog.ts

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Advanced

Run ID: ffc44360-0c17-4556-b334-96bb565023a4

📥 Commits

Reviewing files that changed from the base of the PR and between 2afb9a3 and 6cab5ad.

📒 Files selected for processing (2)
  • src/renderer/src/components/settings/use-runtime-environment-catalog-lifetime.test.ts
  • src/renderer/src/components/settings/use-runtime-environment-catalog.ts

Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 3 remain after this review.


📝 Walkthrough

Walkthrough

The hook stores catalog results after unmount but stops pane-dependent work when the pane is no longer mounted. It checks mount state before verified-status snapshot work and again after the snapshot read. Tests cover mutation reloads after close, probe behavior across unmounts, and late catalog errors.

Priority: ➖ Normal

Severity of issue fixed: Medium

Merge Risk: ⚪ Minimal · up to 6cab5

The pane can close during loading without starting late status probes, while saved-server updates remain available. No actionable merge-blocking risk is identified.

Security Architecture Review

Security architecture risk: 🔵 Low · up to 6cab5

Closing settings can now leave saved-server status unchecked until another refresh or reopening. The saved-server list still updates, and the change does not establish a new external entrypoint or permission path.

Retained concerns

  • Low · security · inferred: A catalog result arriving after settings closes is published to shared state without starting status hydration or probes. Freshness for those hosts then depends on subsequent activity, with no bounded recovery established.
Security review details

Security Blast Radius

  • inferred — The freshness change can affect shared status for saved servers whose catalog results arrive after close; the controlled test demonstrates this across 40 mocked servers, not measured production connections.

Trust Boundaries and Controls

  • observed — Status probes use the existing runtime bridge; the added checks gate when those calls start rather than adding a caller or changing bridge authority.

Resilience and Maintainability Implications

  • inferred — Reopening provides a path to renewed checks, but the inspected hook establishes no deadline for refreshing a status deferred while closed. The downstream security effect of that delay remains unverified.
🚥 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%. Docstring coverage is scoped to functions touched by this diff. Analyzed 4 functions across 2 files. 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 clearly and concisely describes the main change: skipping new server status checks after the settings pane closes.
Description check ✅ Passed The description is complete and relevant. It covers the user impact, implementation, rationale, trade-offs, linked issue, testing, review risk, and cross-platform limitations. Pending broader checks a…
Linked Issues check ✅ Passed The changes satisfy the coding requirements in [#23150]. loadEnvironments always updates the shared catalog, then checks mountedRef before it starts status probes. For verified loads, it checks `m…
Out of Scope Changes check ✅ Passed The pull request changes only useRuntimeEnvironmentCatalog and its lifecycle tests. The implementation preserves admitted catalog reconciliation and active probe synchronization. The tests directly …
✨ Finishing Touches 💡 1
📝 Generate docstrings 💡
  • Commit to this branch
  • Create a new PR

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.

…t-only assertions

The suppression is keyed to useMountedRef, which is per-open-session, so a reopened
pane reloads and reprobes from scratch. Nothing tested that, and the guard now sits
in front of every probe: if the mounted flag ever failed to re-arm on mount, the pane
would issue zero probes and sit on 'loading' forever instead of merely skipping a
setState. Added a close-then-reopen test and a StrictMode double-invoked-effects test
(both fail if the flag is not re-armed), including the assertion that a host whose
probe was suppressed stays 'loading' (never checked) rather than 'error' — a probe
that did not run is not evidence the host is down.

Also removed the now-dead mounted re-check (no suspension point between it and the
preceding guard) and relaxed the incidental snapshot-read count assertion, which
would have flagged coalescing those reads as a regression.

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

✅ No new issues found.

Reviewed changes

  • Added reopen + StrictMode lifetime tests — a close-then-reopen test and a StrictMode double-invoked-effects test confirm the useMountedRef suppression does not persist across mounts, that the reopened pane probes from scratch, and that a host whose probe was skipped stays loading rather than error.
  • Removed the now-dead mounted re-check — the outer if (mountedRef.current) around setEnvironments/setDetailsByEnvironmentId is gone, since the two preceding early returns already guarantee the pane is mounted (no suspension point between them). This addresses the prior review's inline thread.
  • Relaxed the incidental snapshot-read count — the active-probing test now asserts readRuntimeHostStatusSnapshots was called rather than exactly twice; the probe path's shared-status sync is still independently asserted by the already-started-probe test, so no coverage is lost.

The only prior Pullfrog thread (dead mountedRef wrapper) is resolved by 12e0ced. Verified this run: the 8-case suite passes and oxlint is clean on both changed files. The documented freshness trade-off is unchanged and remains accepted.

Pullfrog  | View workflow run | Using DeepSeek Flash (free via Pullfrog for OSS) | 𝕏

@nwparker

Copy link
Copy Markdown
Contributor Author

Closing: rare trigger, tiny saving, and it accepts stale server status in host pickers. The hook was rewritten by #26581/#27934.

@nwparker nwparker closed this Oct 14, 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.

Closed server settings still starts late status probes

1 participant