Skip to content

perf: preserve matching Accounts settings sections during search - #23192

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

nwparker merged 2 commits into
mainfrom
nwparker/perf-09-25-accounts-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{+}}}$​257 0 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​257
Prod 2 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​91 $\color{#cf222e}{\Huge{\mathbf{−}}}$​8 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​83

ELI5

Typing in Accounts search keeps a matching section open, so it no longer flashes Loading or repeatedly reconnects its sign-in updates.

What Changed

The outer wrapper uses each section's existing stable key. Previously, filtering an earlier section changed later wrapper positions and remounted their contents. This includes the Cursor section added on current main.

Renderer work, including initial mount Before After
Nine matching Grok queries, Windows-account support off / on 4 / 6 status reads 1 / 1
Ten matching Cursor queries, either configuration 4 status reads 1
Eleven matching Codex queries, either configuration 4 login-link reads and subscriptions 1
Explicit refresh, usage update, real hide/reopen Existing refresh behavior Preserved
Refresh caused only by matching search Incidental refresh Removed

Counts use actual components with synthetic API/store boundaries. They measure renderer admissions, not provider latency or whole-app speed.

Why

Keeping component identity removes redundant mount work without adding a cache or timer. Adding a cache would introduce another invalidation policy. This intentionally changes state lifetime and is a separate trade-off PR.

Linked Issue

N/A — PR only, as requested by the maintainer.

Visual Proof

Hidden Electron comparison using actual Accounts/Grok components, synthetic status and inert other sections. Repeated reads are held to expose Loading. These screenshots compare the original audit baseline; the upstream Cursor addition is covered separately by current-main tests.

Both sides initially loaded:

Before search

Matching g → gr: original reloads; candidate retains status:

Matching search

Actual hide/reopen: both reload:

Actual reopen

Testing

  • Inspected three scripted hidden-Electron component comparisons; no native focus or real account action.
  • Added automated tests, including three independent cases for current-main Cursor support.

ORCA_BACKGROUND_LAUNCH=1 pnpm exec vitest run --config config/vitest.config.ts src/renderer/src/components/settings/AccountsPane.section-lifetime.test.tsx: 10 pass on current main; original main 7 fail / 3 controls pass. Genuine removal, subscription cleanup, explicit actions and usage-driven refresh are covered with Windows account support enabled/disabled.

Web typecheck, scoped lint/format and the 127-entry isolated reliability manifest pass. The shared checkout's changed-code quality gate passes across 198 files. Native Linux/Windows, live SSH/WSL/providers and a packaged whole-app run remain untested. The gate starts experimental without CI soak history.

AI Disclosure

Review

Independent source/lifetime review approved. It checked upstream Cursor preservation, status and login owners, subscription cleanup and clipboard-feedback timers. Merge risk: low to moderate, because the production change is two lines but intentionally retains state longer.

Agent skill upstream boundary

  • Not applicable; no upstream skill content copied.

Notes

Negative user-facing trade-offs: matching search no longer incidentally refreshes Grok/Cursor status or pending Codex login URLs. Child drafts, errors, copied feedback and timers persist until their own transition or genuine removal. Explicit refresh, usage timestamps, pushed login URLs and true hide/reopen remain; no automatic freshness deadline is added. Cursor's explicit refresh still depends on a changed usage timestamp, as on main.

No account mutation, credential policy, path, shortcut, execution-host routing or wire change. Existing remote/folder workspace ownership policies remain in force.

Checklist

  • Small and focused
  • Explained behavior, mechanism and alternatives
  • Before/after screenshots attached
  • Independently reviewed for correctness and performance
  • Cross-platform, remote and folder workspace impact considered
  • Full lint/typecheck/test/build — scoped checks above; broader coverage remains to CI

@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: ab8ce280-6afe-487a-8c32-58288f44f7f2

📥 Commits

Reviewing files that changed from the base of the PR and between 92b15ee and e248bfc.

📒 Files selected for processing (1)
  • config/reliability-gates.jsonc

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


📝 Walkthrough

Walkthrough

AccountsPane now delegates section rendering and separators to SettingsSectionStack. New tests cover section identity and provider call counts across search, refresh, usage updates, hiding, reopening, and unmounting. A reliability-gate record defines the section-lifetime invariant and documents test evidence and coverage gaps.

Priority: ⬇️ Low

Merge Risk: ⚪ Minimal · up to e248b

The Accounts sections retain stable identity across filtering, with no identified issue blocking merge after normal checks.

Architecture Summary

Architecture risk: 🔵 Low · up to e248b

The change affects 2 systems.

Changed systems: src, config

Architecture concerns
No architecture-level concerns identified.

Review details

Systems and components

  • observed — src (ui) was modified; 2 changed files map to changed impact.
  • observed — config (service) was modified; 1 changed file maps to changed impact.

Before / after behavior

  • observed — Modified behavior in src/renderer/src/components/settings/AccountsPane.section-lifetime.test.tsx: Adds the happy-dom test setup, mock state and dependencies, and hooks that reset mock state and install or remove window API stubs.
  • observed — Modified behavior in src/renderer/src/components/settings/AccountsPane.section-lifetime.test.tsx: Adds parameterized Grok and Codex tests that compare section DOM identity and status, pending-login, and subscription call counts across search changes, with both Windows-account-support values.
  • observed — Modified behavior in src/renderer/src/components/settings/AccountsPane.section-lifetime.test.tsx: Adds Grok assertions for explicit refresh, status reads after refresh and reopening, hidden-section absence, and no settings writes.
  • observed — Modified behavior in src/renderer/src/components/settings/AccountsPane.section-lifetime.test.tsx: Adds assertions that Grok status reads increase when usage timestamps change while the section remains mounted, but not on a search-query rerender alone.
🚥 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 performance change: preserving matching Accounts settings sections during search.
Description check ✅ Passed The description is complete and covers the user impact, implementation, rationale, linked-issue exception, visual proof, testing, trade-offs, review, and remaining coverage limits. It also explains wh…
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
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

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

This review covered the full diff of PR #23192 at 844f7c15.

  • Stable section keys in AccountsPane — the outer wrapper now keys on section.key rather than the array index, so filtering out an earlier search result no longer remounts later sections; filter(Boolean) becomes a null-narrowing filter. Every section element carries a unique explicit key (account-runtime, claude-accounts, codex-accounts, gemini, opencode-go, minimax, grok, cursor), so identity is preserved exactly when it should be.
  • Regression suite AccountsPane.section-lifetime.test.tsx — 10 cases pinning Grok/Cursor status reads and the Codex login subscription across matching-search rerenders, plus controls for explicit refresh, usage-driven refresh, and genuine removal/unmount.
  • Reliability gate settings.accounts-section-lifetime — experimental/partial manifest entry wiring the new suite into the gate set.

I reproduced the red/green boundary independently: reverting the wrapper to key={index} fails 7 of the 10 new cases (Grok 4/6 reads, Cursor 4, Codex 4 reads plus re-subscribe) while 3 controls pass, matching the PR's evidence exactly; with the change it is 10/10. The existing AccountsPane.test.tsx (9 tests) still passes, check-reliability-gates reports 127 gates with no failures, and oxlint is clean on both changed renderer files.

The intentionally dropped incidental search-driven refresh is called out in the PR body and knownGaps; explicit refresh, usage-timestamp refresh, pushed login URLs, and true hide/reopen/removal all remain, so the freshness trade-off is deliberate and contained. Nothing blocking.

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

This incremental review covered the delta since the prior Pullfrog review at 844f7c15 — the new shared section wrapper and the corresponding test/gate updates.

  • Extracted SettingsSectionStack — AccountsPane now delegates its visibleSections render to a new shared component that keys each child on the section element's own key rather than the array index, filters nulls internally, and takes the pane spacing via a spacing prop (group = space-y-8). Behavior is identical to the inline wrapper it replaced: same DOM nesting, same separator placement, same stable keys.
  • Hardened the regression assertions — the exact one-read counts became post-mount count capture plus DOM-node identity (toBe(mountedHeading)) and non-growing counts, so the suite pins section identity rather than a magic number.
  • Updated the settings.accounts-section-lifetime gate — oracle/evidence text now describes node identity and the shared component.

I independently confirmed the refined suite still fails on the defect: temporarily reverting SettingsSectionStack to key={index} produces exactly 7 failures (2 Grok, 2 Codex, 1 Codex subscription, 2 Cursor) with the 3 refresh/removal controls green, matching the PR's evidence. pnpm tc:web and oxlint on all three changed TS/TSX files are clean.

ℹ️ The same remount pattern still lives in three other settings panes

SettingsSectionStack now documents the key={index} remount hazard, but only AccountsPane was migrated. GeneralPane.tsx:287, TerminalPane.tsx:291, and RepositoryPane.tsx:420 still key their searchable section lists on the array index, so a matching search there still tears down and remounts surviving sections. This is a scope observation, not a defect in this PR — those panes are deliberate follow-ups.

Technical details
# Remaining `key={index}` section lists

## Affected sites
- `src/renderer/src/components/settings/GeneralPane.tsx:287` — `space-y-6` map; sections carry keys (`navigation`, `workspace`, `project-runtime`, `editor`, `cli`, `updates`).
- `src/renderer/src/components/settings/TerminalPane.tsx:291` — `space-y-6` map; sections carry keys (`default-shell`, `windows-shell`, `rendering`, `pane-interaction`, `setup-script`, `manage-sessions`, `advanced`).
- `src/renderer/src/components/settings/RepositoryPane.tsx:420` — `space-y-8` map; sections carry keys (`hooks`, `identity`, `source-control-ai`, `symlinks`, `sparse-presets`, `mcp-configs`).

## Required outcome
- None for this PR. When those panes are migrated, they are drop-in: every section element already carries a unique key, so `<SettingsSectionStack sections={...} spacing="section" | "group" />` preserves identity without further changes. `GeneralPane` must keep its `Support` section outside the stack (it owns its own collapsing separator), which the fragment-returning component already allows.

## Open questions for the human (optional)
- Is migrating the remaining panes planned, or is `SettingsSectionStack` intended to stay Accounts-only while other panes keep their inline maps?

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

@nwparker
nwparker force-pushed the nwparker/perf-09-25-accounts-settings-section-identity branch from fb40837 to 92b15ee Compare September 27, 2026 08:26
…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/subscription-count
oracles as node identity plus non-growing counts so a future freshness fix cannot read as
a regression. Applied on the branch head; the rebase onto main is still outstanding.
@nwparker
nwparker force-pushed the nwparker/perf-09-25-accounts-settings-section-identity branch from 92b15ee to e248bfc Compare September 27, 2026 20:32
@nwparker
nwparker merged commit 32668c3 into main Sep 27, 2026
58 of 60 checks passed
@nwparker
nwparker deleted the nwparker/perf-09-25-accounts-settings-section-identity branch September 27, 2026 20:52
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