Skip to content

[CI] Reduce repeated persistence imports in UI-state tests - #26185

Merged
nwparker merged 1 commit into
mainfrom
nwparker/persistence-ui-initial-store-reuse
Oct 7, 2026
Merged

nwparker merged 1 commit into
mainfrom
nwparker/persistence-ui-initial-store-reuse

Conversation

@nwparker

@nwparker nwparker commented Oct 7, 2026 •

Copy link
Copy Markdown
Contributor

ELI5

The UI-state database tests now create their first real database instance through the existing fixture factory, avoiding repeated loading of the persistence modules. Tests that reopen the database still reload those modules exactly as before.

What Changed

Only the first createStore() call in each case reuses the existing canonical constructor. It still installs that case's encryption provider before creating a fresh real SQLite database and authority in its fresh directory. Later calls keep the original module reset and dynamic import sequence. Every original assertion and cleanup body remains unchanged; the per-case flag resets in beforeEach.

Why

Each store instance and database needs fresh state; loading the same constructor again is unnecessary for the first instance in these UI tests. This keeps security/restart coverage and real Node database contracts, with a smaller change than replacing persistence with mocks or removing all module resets.

Linked Issue

Maintainer performance work; no new issue.

Visual Proof

N/A — test fixture only; no application behavior or UI change.

Testing

Three matched pairs, 41 unchanged original cases in one physical file, macOS arm64, Bun1.4.2 coordinator with actual Node24.20.0 database workers, Vitest5.0.3, four workers, Vitest filesystem module cache disabled. Each time includes the whole pnpm test process through normal close. Same six ordered setups, isolation, assertions, case/status identities and protected actual-Node routing. Source frozen at 5b0d38749de6ef942642d94a0f2e2f6d878dfb80.

Pair Before After Time reduction
1 5.394055s 3.968589s 26.43%
2 5.477007s 4.137775s 24.45%
3 7.017646s 4.343462s 38.11%
Mean 5.962903s 4.149942s 30.40%

1.44× for this suite. All qualified samples, including the slower third control, are retained. One after pair 2 attempt (4.219451s) passed every correctness/config/source gate but overlapped external coordinators; raw logs/reports retained and only that noise failure retried. One subsequent preflight rejected a coordinator before launching any test. No signals were sent and no qualified sample was discarded. This is not a full-suite 2× result.

  • Eight-suite control and candidate qualifications both pass all165 original cases under Bun and stock Node, shuffled seeds104729/130363. Identical physical case/name/title/ancestor/status maps, original project settings and actual Node database routes; zero errors. Source/patch hashes, normal exit and sampled-coordinator absence recorded separately.
  • Node typecheck, changed-code quality, formatting and diff whitespace checks pass.
  • Existing encrypted Kagi restart, durable SSH ownership recovery, UI no-op/notification/scheduling and protected-secret cases preserved. Additional tests are unnecessary: the original restart cases and broader real-database qualification verify the relevant boundary.
  • Full PR CI passes all five Linux ARM shards and every applicable check at head d85f70ea. The tested merge source is b7ac5d9d (incoming main 520033b0 plus this head). Canonical discovery and all five shard assignments enroll all 11,677 physical files exactly once: 11,538 pass and 139 existing skips; 112,605 passing cases, one expected failure and 1,049 existing skipped cases, zero unhandled errors. All 11,669 files from the prior PR source remain, with eight incoming-main additions and no removals. Routing remains 10,551 Bun files, 1,125 actual Node runtime files and one actual Node measurement file. The changed Node database suite passes all 41 cases. Full CI artifacts prove file enrollment and raw case counts; the focused qualifications above separately prove complete named-case parity.

Review

Independent source review confirmed fresh constructor/authority/registration, per-case data-path overwrite, realm encryption-provider lookup, unchanged second/subsequent cold reloads and exact original case/cleanup bodies. Final head has green applicable checks and a clean merge state. Zero review threads were observed; this does not claim a review bot completed coverage. Self and independent source/evidence reviews are complete.

Agent skill upstream boundary

  • Not applicable; no agent-skill source changed.

Notes

No production change, runtime migration, platform path change, deadline change, fixture mock replacement, test exclusion or weakened reload/security assertion. Remote SSH and folder fixtures retain their existing coverage.

Checklist

  • Small and focused; behavior, mechanism and alternatives explained.
  • N/A visual proof explained.
  • Self and independent source review; cross-platform/SSH/folder boundaries considered.
  • Full PR CI passes; source-bound enrollment and unchanged runtime routes checked.

@coderabbitai

coderabbitai Bot commented Oct 7, 2026 •

Copy link
Copy Markdown
Contributor

Review in Change Stack →

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: 81d55770-0b5f-41da-9f1d-6ebf3c1446fa
📥 Commits

Reviewing files that changed from the base of the PR and between 520033b and d85f70e.

📒 Files selected for processing (1)
  • src/main/persistence-ui-state.test.ts

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


📝 Walkthrough

Walkthrough

The test store helper now returns the initially imported store factory on its first call in each test. On later calls, it resets modules and uses the existing SQLite-backed store setup. A per-test flag tracks store creation and resets before each test.

Priority: ⬇️ Low

Merge Risk: ⚪ Minimal · up to d85f7

The change is limited to test-store setup, and the configured runner keeps these cases sequential. No material mergeability risk is established.

🚥 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 1 functions across 1 files. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
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.
Title check ✅ Passed The title clearly and concisely describes the main change: reducing repeated persistence imports in UI-state tests.
Description check ✅ Passed The description covers the required sections, explains the change and rationale, gives testing details, and marks visual proof as not applicable because this is a test-fixture change. It also addresse…
  • Fix all pre-merge checks with AI
✨ Finishing Touches 💡 1
📝 Generate docstrings 💡
  • Commit to this branch
  • Create a new PR
  • Autopilot · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

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.

@nwparker
nwparker merged commit e4da27e into main Oct 7, 2026
30 checks passed
@nwparker nwparker changed the title Reduce repeated persistence imports in UI-state tests [CI] Reduce repeated persistence imports in UI-state tests Oct 9, 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