Skip to content

perf: preserve matching General settings sections during search - #23177

Merged
nwparker merged 2 commits into
mainfrom
nwparker/perf-09-25-general-settings-section-identity
Sep 27, 2026
Merged

nwparker merged 2 commits into
mainfrom
nwparker/perf-09-25-general-settings-section-identity

Conversation

@nwparker

@nwparker nwparker commented Sep 26, 2026 •

Copy link
Copy Markdown
Contributor
Files Added Deleted Net
Test 1 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​206 0 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​206
Prod 3 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​123 $\color{#cf222e}{\Huge{\mathbf{−}}}$​9 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​114

ELI5

Searching General settings keeps each section open while it still matches, so typing no longer repeatedly reloads Updates or resets its local controls.

What Changed

Outer section wrappers now use the stable keys their sections already have. Previously, filtering an earlier result changed later wrapper positions and remounted the contents.

Measured behavior Before After
Initial mount + 14 matching queries: version reads 6 1
Same sequence: paired-server refresh admissions 6 1
Programmatic matching query with an uncommitted autosave draft Draft resets Draft retained
Explicit remote refresh or real hide/reopen Refreshes Refreshes

Counts come from actual GeneralPane and update components with synthetic store/API boundaries. They measure renderer request admissions, not backend network savings or packaged responsiveness.

Why

Preserving component identity removes repeated mount work without adding a cache or timer. Refreshing on every matching search would retain the waste. This deliberately changes state lifetime, so it is a separate trade-off PR.

Linked Issue

Fixes #23176

Visual Proof

Actual GeneralPane and autosave controls, canonical CSS, synthetic settings, hidden Electron on macOS. Other sections are inert in this visual fixture. The query changes programmatically while the draft remains uncommitted; ordinary clicking search would normally blur and commit first. This demonstrates section lifetime, not ordinary mouse-search draft loss.

Before query change:

before-search.png

After matching query:

after-search.png

After actually hiding and reopening the section:

after-real-reopen.png

Testing

  • I manually tested these changes locally — inspected three scripted hidden-Electron component comparisons; no native focus, provider calls or real settings writes.
  • Automated tests added/updated.

ORCA_BACKGROUND_LAUNCH=1 pnpm exec vitest run --config config/vitest.config.ts src/renderer/src/components/settings/GeneralPane.section-lifetime.test.tsx: 6 pass; original source 4 fail / 2 controls pass. Author related coverage: 62 tests / 12 suites. Independent permanent rerun: 6 pass; three additional pending-version, error-context and live-store cases pass versus original 2 fail / 1 control. Web typecheck, scoped lint/format, changed-code quality across 183 files and reliability-manifest validation pass.

Tests ran on macOS with Windows runtime flags simulated. Native Linux/Windows, live paired hosts and physical update/install behavior are not tested. Full lint/build and broader platform coverage remain to CI.

AI Disclosure

Review

Independent review approved the frozen two-file change. Merge risk is low to moderate: the production diff is small, but retained section state changes user behavior.

Reliability invariant settings.general-section-lifetime: matching sections retain their owner/state; real removal releases it and reloads on return. New experimental gate checks read counts, explicit refresh, draft override by saved settings and late-version exclusion. CI soak and physical provider evidence remain gaps. Test failures identify the affected read count or lifetime assertion.

Agent skill upstream boundary

  • Not applicable; no upstream skill content copied.

Notes

Negative user-facing trade-off: matching search no longer incidentally refreshes app version, remote update status or CLI discovery. Existing explicit checks, external store updates and genuine hide/reopen remain; no bounded automatic freshness deadline is added. Drafts, release-picker reveal, pending saves and error context persist until their own transition or an actual hide.

No new settings write, polling, subprocess, cache, Git command, host routing or wire field. Local/daemon PTY and mobile execution are unaffected; SSH/WSL/remote-runtime execution ownership remains unchanged. No CPU, heap or whole-app latency claim.

Checklist

  • This PR is small and focused
  • I explained what changed and why (ELI5, before/after, mechanism and alternatives)
  • Before/after screenshots attached with fixture limits stated
  • Self-reviewed and independently reviewed for correctness, security and performance
  • Cross-platform, SSH/remote and path/shortcut impact considered
  • Full lint, typecheck, test and build pass — scoped local checks above; CI covers broader checks

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

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: d0812725-8f3b-4916-8714-cb05948ec5e5

📥 Commits

Reviewing files that changed from the base of the PR and between 2c486e4 and cf35c91.

📒 Files selected for processing (4)
  • config/reliability-gates.jsonc
  • src/renderer/src/components/settings/GeneralPane.section-lifetime.test.tsx
  • src/renderer/src/components/settings/GeneralPane.tsx
  • src/renderer/src/components/settings/SettingsSectionStack.tsx

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


📝 Walkthrough

Walkthrough

GeneralPane now uses SettingsSectionStack to render visible settings sections with stable keys. Added tests cover section retention during search edits, explicit refresh, hide and reopen behavior, autosave drafts, release-picker visibility, and pending version results. Added an experimental reliability gate with test evidence and promotion criteria.

Priority: ➖ Normal

Severity of issue fixed: Medium

Merge Risk: ⚪ Minimal · up to cf35c

Matching General settings sections retain their state during search changes, while genuinely hidden sections refresh when reopened. No merge-blocking issue is established.

Security Architecture Review

Security architecture risk: 🔵 Low · up to cf35c

The settings search now keeps matching sections open instead of resetting them. Existing controls for saving settings and choosing updates remain in place, and no new security issue was established. Review coverage is incomplete, so the risk is assessed as low rather than minimal.

Retained concerns
No architecture-level concerns identified.

Security review details

Security Blast Radius

  • inferred — The identified exposure change is limited to state retained within the renderer settings UI; the examined stack has no path that independently invokes the updater or settings-write APIs.

Trust Boundaries and Controls

  • observed — Retaining the revealed picker does not itself request a build: its switch action still calls the existing updater API after a build is selected. The examined workspace visibility setting likewise retains its capability checks and pending-write guard.

Resilience and Maintainability Implications

  • observed — A genuinely unmounted Updates section ignores a late version result; preserving it during a matching search does not remove that cleanup path.
🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 50.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 2 functions across 3 files. (1 skipped: 1… 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: preserving matching General settings sections during search.
Description check ✅ Passed The description covers the required sections, explains the user-facing change and rationale, includes linked issue information, visual proof, testing details, platform limits, trade-offs, and checklis…
Linked Issues check ✅ Passed Issue #23176 is closed and provides historical context only. No active directly linked issue supplies coding requirements for this pull request. The reviewed changes and tests are consistent with the …
Out of Scope Changes check ✅ Passed The changes are limited to General settings section composition, lifecycle tests, and the related reliability-gate entry. These changes support the stated section-identity and refresh-lifecycle behavi…
Full details: Docstring Coverage

Explanation

Docstring coverage is 50.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 2 functions across 3 files. (1 skipped: 1 unsupported.)

  • Fix all pre-merge checks with AI
✨ 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.

@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

  • Stable wrapper keys in GeneralPane — the visible-sections list now keys each wrapper by section.key instead of positional index, so a section that remains matched keeps its component identity and local state when an earlier result disappears.
  • Type-narrowing filter — .filter(Boolean) became .filter((section) => section !== null) so the array narrows enough to read section.key; the TS 7 inferred type predicate covers this.
  • GeneralPane.section-lifetime.test.tsx — a new happy-dom component test that mounts the real GeneralPane with @/store and the updater API mocked, pinning read counts, explicit refresh, draft retention, release-picker lifetime, and unmounted-section result exclusion.
  • Reliability gate — settings.general-section-lifetime registered as experimental / partial protection, scoped to macOS.

I independently reproduced the red/green split: reverting only key={section.key} to key={index} fails 4 of the 6 cases, matching the PR's claim, and the gate manifest checker plus oxlint pass on the changed files.

ℹ️ Same positional-key remount pattern still exists in sibling settings panes

This PR correctly fixes GeneralPane, but three sibling panes render search-filtered section lists with the identical key={index} + .filter(Boolean) shape, so they retain the same latent remount-on-filter behavior this PR is fixing. Flagging only as a follow-up scope question — no change requested here.

Technical details
# Sibling panes with positional section keys

## Affected sites
- `src/renderer/src/components/settings/TerminalPane.tsx:290` — `visibleSections.map((section, index) => <div key={index} …>)`, sections already carry keys (`windows-shell`, `rendering`, `pane-interaction`).
- `src/renderer/src/components/settings/AccountsPane.tsx:388` — same `key={index}` wrapper over render-function sections (several without their own key).
- `src/renderer/src/components/settings/RepositoryPane.tsx:419` — same pattern.

## Required outcome
None for this PR. If the same section-lifetime guarantee is wanted there, each wrapper needs a stable per-section key and a narrowing filter.

## Open questions for the human
- Is `GeneralPane` intentionally first, or should the sibling panes be tracked for the same fix?

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

@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

Since the prior pullfrog review (2c486e4b07), the only new commit (c31bd34bb1) refactors how General builds its section list:

  • Extracted SettingsSectionStack — the keyed wrapper loop (stable key={section.key}, leading Separator, space-y-6/space-y-8) moved into a new shared component so other settings panes can adopt the same section-lifetime guarantee.
  • Routed GeneralPane through it — the section array is now passed raw as ReactElement | null and the null filter moved inside the component; hasPrecedingSections uses visibleSections.some((section) => section !== null).
  • Updated the section-lifetime test — the retained-section oracle now asserts DOM-node identity plus non-growing version/refresh counts instead of absolute counts, and a new case pins store-published remote update state reaching a retained section.
  • Refreshed the gate manifest — settings.general-section-lifetime oracle/evidence/knownGaps updated; still 127 gates.

I re-ran the focused suite (7 pass), the gate manifest check (127 gates), and check:code-quality:changed (0 findings across all six scans, design system included).

ℹ️ Shared stack extracted for reuse, but only General consumes it

The new component is the intended home for the stable-key fix, yet TerminalPane, AccountsPane, and RepositoryPane still keep their own key={index} wrapper loops — notably RepositoryPane's space-y-8 matches the currently unexercised spacing="group" variant. Is migrating those panes the planned follow-up, or is the shared extraction scoped to General for now?

Technical details
# Shared SettingsSectionStack adoption

## Affected sites
- `src/renderer/src/components/settings/TerminalPane.tsx:290` — `visibleSections.map((section, index) => <div key={index} …>)` with `space-y-6`.
- `src/renderer/src/components/settings/AccountsPane.tsx:388` — same `key={index}` wrapper.
- `src/renderer/src/components/settings/RepositoryPane.tsx:419` — same pattern with `space-y-8`, i.e. the `spacing="group"` case.

## Required outcome
None for this PR. Confirm whether the sibling panes are the intended consumers of `SettingsSectionStack`; if so, verify every section element there carries its own key before switching away from positional keys.

## Open questions for the human
- Is the shared extraction deliberately General-only for now, with sibling adoption tracked separately?

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

…tionStack

Replaces the pane-local index-keyed wrapper with the shared SettingsSectionStack so the
search-stable identity rule lives in one place, and restates the read-count oracles as
node identity plus non-growing read counts. Adds coverage that store-published remote
update state still reaches a section that no longer remounts.
@nwparker
nwparker force-pushed the nwparker/perf-09-25-general-settings-section-identity branch from c31bd34 to cf35c91 Compare September 27, 2026 08:39
@nwparker
nwparker merged commit 3f1bf68 into main Sep 27, 2026
33 checks passed
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.

General settings search reloads sections that still match

1 participant