Repository navigation
fix(settings): share database conversion completion across every mount - #2300
Conversation
useDatabaseConversion previously tracked "the converting -> nativeAuthoritative transition just happened" in a per-mount useRef, so only the exact hook instance that watched the transition live ever set justCompleted. A conversion started from Settings that finished after the user navigated away left the next Settings mount's own first refresh() reading nativeAuthoritative directly, with no local memory of converting, so the one-time retention notice (#2136) never appeared. Move that bookkeeping into two shared Jotai atoms: the last kind observed by any mount, and a justCompleted flag set when any mount observes the transition. Every mount's polling effect now also arms once any mount records "converting", not only its own local state, so an always-mounted observer (the app-root prompt dialog) keeps polling and can record a completion a since-unmounted Settings instance missed. A fresh install's first-ever read already being nativeAuthoritative still never counts as a completion, since the shared "last observed kind" starts at null (#2203). Closes #2267
|
Warning Review limit reachedNext included review available in 16 minutes. View limit detailsLimit details: You’ve used all 2 included reviews currently available. Your 88 included PR review attempts over the past 7 days set your current allowance at 2 reviews per hour. Your organization has reached its usage spending cap. Adjust your spending cap in the billing tab. Review configuration: ⚙️ Run configurationConfiguration used: Repository: shm11C3/HardwareVisualizer/.coderabbit.yml Review profile: CHILL Plan: Team Run ID: 📒 Files selected for processing (2)
Comment |
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
Coverage Report
File Coverage
|
||||||||||||||||||||||||||||||||||||||
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 0b52f034d4
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
E2E capturesEvidence captures for |
CI telemetryCommit
|
| Job | Result | Queue | Duration | CPU avg / p95 | Mem peak | Disk peak | Caches |
|---|---|---|---|---|---|---|---|
test-e2e-native |
✅ | 2s | 12m 22s | 76% / 99% · 3.0/4T T 74 · 75 · 76 · 79 |
4.7 / 15.6 GiB | 68 / 145 GiB | target exact · npm exact |
test-e2e-web |
✅ | 2s | 3m 10s | 55% / 76% · 2.2/4T T 53 · 55 · 52 · 60 |
3.7 / 15.6 GiB | 60 / 144 GiB | npm exact |
check-frontend |
✅ | 2s | 1m 53s | 83% / 99% · 3.3/4T T 82 · 84 · 82 · 83 |
3.0 / 15.6 GiB | 59 / 144 GiB | npm exact |
check-tauri-bindings |
✅ | 7s | 1m 46s | 37% / 60% · 1.5/4T T 37 · 33 · 34 · 45 |
2.2 / 15.6 GiB | 72 / 145 GiB | target exact · sccache Rust 100% (1/1) · C/C++ n/a |
test-render-memory-perf |
✅ | 2s | 1m 21s | 22% / 65% · 0.9/4T T 21 · 22 · 21 · 26 |
3.1 / 15.6 GiB | 60 / 144 GiB | npm exact |
test-render-perf |
✅ | 2s | 1m 01s | 39% / 60% · 1.5/4T T 35 · 41 · 40 · 39 |
3.1 / 15.6 GiB | 60 / 144 GiB | npm exact |
change-detection |
✅ | 3s | 27s | – | – | – | – |
lint-frontend |
✅ | 2s | 17s | 37% / 49% · 1.5/4T T 33 · 42 · 28 · 44 |
1.4 / 15.6 GiB | 59 / 144 GiB | npm exact |
Merge Gate |
✅ | 3s | 13s | – | – | – | – |
Slowest steps
| Step | Duration |
|---|---|
test-e2e-native › Run native E2E smoke |
10m 37s |
test-e2e-web › Run E2E capture tests |
2m 14s |
check-frontend › Run frontend tests with coverage |
1m 32s |
test-e2e-native › Setup Linux dependencies |
1m 03s |
check-frontend › Wait for frontend tests |
1m 03s |
CodeQL Advanced · 3 jobs
| Job | Result | Queue | Duration | CPU avg / p95 | Mem peak | Disk peak | Caches |
|---|---|---|---|---|---|---|---|
Analyze (rust) |
✅ | 1s | 12m 48s | – | – | – | – |
Analyze (javascript-typescript) |
✅ | 1s | 1m 05s | – | – | – | – |
Analyze (actions) |
✅ | 2s | 47s | – | – | – | – |
Slowest steps
| Step | Duration |
|---|---|
Analyze (rust) › Perform CodeQL Analysis |
11m 28s |
Analyze (rust) › Setup Rust |
53s |
Analyze (javascript-typescript) › Perform CodeQL Analysis |
39s |
Analyze (actions) › Perform CodeQL Analysis |
23s |
Analyze (javascript-typescript) › Initialize CodeQL |
19s |
Generated by the CI telemetry workflow from the GitHub API and job log markers. Queue = time from job creation to start. N/MT = average busy threads of M logical CPUs; T = per-thread average %.
…ale read Codex review on #2300 (P2): the app-root prompt dialog's own initial refresh(), issued before any conversion exists, can resolve after Settings has already started and progressed a conversion elsewhere. The prior unconditional shared-atom write let that stale response clobber the shared "converting" kind back to sqliteAuthoritative, defeating the fix and leaving no mount armed to observe the eventual real completion. Add a plain module-scoped sequence counter shared across every mount: each read reserves its place before issuing, and only writes to the shared atoms if no later-issued read or state change already wrote - regardless of resolution order. start()/recover()'s own synchronous priming commits a fresh sequence number immediately, so it always supersedes an earlier-issued, still in-flight read from another mount.
|
@coderabbitai review |
|
|
@coderabbitai approve |
✅ Action performedComments resolved and changes approved. |






















































Summary
justCompletedinuseDatabaseConversionused to live in a per-mountuseRef, so only the exact hook instance that watched theconverting -> nativeAuthoritativetransition live ever set it. Aconversion started from Settings that finishes after the user navigates away
(Settings unmounts) is first observed by the next Settings mount as already
nativeAuthoritative, with no local memory ofconverting- so the one-timeretention notice (#2136) never appears. The app-root startup-prompt path
(
DatabaseConversionPromptDialog) was fine because it stays mounted throughthe whole transition.
This moves that bookkeeping into two shared Jotai atoms, scoped to this
session only (in-memory, not persisted to the Tauri Store):
lastObservedDatabaseConversionKindAtom- the lifecycle kind most recentlyobserved by any mounted
useDatabaseConversioninstance.databaseConversionJustCompletedAtom- set once, by whichever mountobserves the
converting -> nativeAuthoritativetransition; cleared byacknowledgeCompletion()when the notice is dismissed.A write-only
recordObservedDatabaseConversionKindAtomupdates both againstthe store's current value (via jotai's
get/set), so the comparison iscorrect regardless of which mount last rendered - avoiding the stale-closure
problem a plain
useCallback([])reading external state would have.Each mount's polling effect now also arms once any mount records
converting, not only its own localstate.kind. Without this, analways-mounted observer with no
convertingstate of its own (the promptdialog, after being dismissed once) would never re-poll to notice a
conversion started elsewhere, and so could never record the completion for a
later Settings mount to read.
A fresh install's first-ever read already being
nativeAuthoritativestillnever counts as a completion, since the shared "last observed kind" starts at
null- preserving the #2203 constraint.Why a session-scoped atom, not Tauri Store
This bookkeeping ("has a conversion just finished, this session, that no one
has acknowledged yet") is transient observation state, not a user
configuration - it doesn't need to survive an app restart. The existing,
separately-persisted "already shown once" flag
(
useDatabaseConversionNoticeShown, UI-local Tauri Store state) stillguarantees the notice only ever shows once for good; this atom only decides
whether this session witnessed the transition, which is exactly the boundary
.agents/rules/settings.mddraws between an Application Preference andUI-local/transient state.
Why not restructure the polling architecture further
The minimal fix is: share the "last observed kind" and let every mount's
existing polling effect react to it. I considered a single global polling
owner instead of per-mount intervals, but that's a larger architectural change
not required by this issue and would touch
DatabaseConversionPromptDialogand
DatabaseConversionSettingsunnecessarily.Related Issues
Closes #2267
Type of Change
fix/branch)Screenshots / Videos
Not applicable - this is a state-management/timing fix with no rendered
markup change. No
.tsx/CSS output changed, so no visual verification wasperformed per
.agents/rules/frontend.md.Test Plan
Added to
src/features/settings/hooks/useDatabaseConversion.test.ts:dialog) while a second mount (modeling Settings) is created only
afterward, and that second mount immediately reports
justCompleted: true;nativeAuthoritativenever reports
justCompleted, for a first mount or a second one createdright after;
converting -> nativeAuthoritativetransition) still reports completion.Also added module-reset isolation (
vi.resetModules()+ dynamic import) tothis test file, matching the existing pattern in
useDatabaseConversionNoticeShown.test.ts, since the new atoms aremodule-level singletons that would otherwise leak between test cases.
Validation
DatabaseConversionStateBody.test.tsx'sdismissing the notice in one mounted body hides it in the othertestintermittently times out under load in this sandbox on
developitself(confirmed via
git stash, 4/4 failures on unmodifieddevelop, and it alsopassed several times on this branch) - a pre-existing environment flake,
unrelated to this change.
Checklist
npm run lint && npm run format)npm test)