Skip to content

fix(settings): share database conversion completion across every mount - #2300

Merged
shm11C3 merged 2 commits into
developfrom
fix/2267-conversion-complete-notice
Oct 3, 2026
Merged

shm11C3 merged 2 commits into
developfrom
fix/2267-conversion-complete-notice

Conversation

@shm11C3

@shm11C3 shm11C3 commented Sep 27, 2026

Copy link
Copy Markdown
Owner

Summary

justCompleted in useDatabaseConversion used to live in a per-mount
useRef, so only the exact hook instance that watched the
converting -> nativeAuthoritative transition live ever set it. A
conversion 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 of converting - so the one-time
retention notice (#2136) never appears. The app-root startup-prompt path
(DatabaseConversionPromptDialog) was fine because it stays mounted through
the 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 recently
    observed by any mounted useDatabaseConversion instance.
  • databaseConversionJustCompletedAtom - set once, by whichever mount
    observes the converting -> nativeAuthoritative transition; cleared by
    acknowledgeCompletion() when the notice is dismissed.

A write-only recordObservedDatabaseConversionKindAtom updates both against
the store's current value (via jotai's get/set), so the comparison is
correct 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 local state.kind. Without this, an
always-mounted observer with no converting state of its own (the prompt
dialog, 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 nativeAuthoritative still
never 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) still
guarantees 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.md draws between an Application Preference and
UI-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 DatabaseConversionPromptDialog
and DatabaseConversionSettings unnecessarily.

Related Issues

Closes #2267

Type of Change

  • Bug fix (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 was
performed per .agents/rules/frontend.md.

Test Plan

  • Unit tests

Added to src/features/settings/hooks/useDatabaseConversion.test.ts:

  • a transition observed by one mount (modeling the always-mounted prompt
    dialog) while a second mount (modeling Settings) is created only
    afterward, and that second mount immediately reports justCompleted: true;
  • a fresh install whose first-ever read is already nativeAuthoritative
    never reports justCompleted, for a first mount or a second one created
    right after;
  • the pre-existing startup-prompt path (a single mount watching the whole
    converting -> nativeAuthoritative transition) still reports completion.

Also added module-reset isolation (vi.resetModules() + dynamic import) to
this test file, matching the existing pattern in
useDatabaseConversionNoticeShown.test.ts, since the new atoms are
module-level singletons that would otherwise leak between test cases.

Validation

npm run lint:ci   # pass
npm run format    # no changes
npm test          # 1019 passed, 1 pre-existing failure (flaky on develop too, unrelated - see below)
npm run build     # tsc + vite build succeed

DatabaseConversionStateBody.test.tsx's
dismissing the notice in one mounted body hides it in the other test
intermittently times out under load in this sandbox on develop itself
(confirmed via git stash, 4/4 failures on unmodified develop, and it also
passed several times on this branch) - a pre-existing environment flake,
unrelated to this change.

Checklist

  • Self-reviewed the code
  • Linting and formatting pass (npm run lint && npm run format)
  • Tests pass (npm test)
  • No new warnings or errors

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

coderabbitai Bot commented Sep 27, 2026 •

Copy link
Copy Markdown
Contributor

Warning

Review limit reached

Next included review available in 16 minutes.

Check out review usage here.

View limit details

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

Learn how review limits work.

Review configuration:

⚙️ Run configuration

Configuration used: Repository: shm11C3/HardwareVisualizer/.coderabbit.yml

Review profile: CHILL

Plan: Team

Run ID: 1269aa26-0cbe-4029-baa2-bb885d3a588f

📥 Commits

Reviewing files that changed from the base of the PR and between 371a486 and d492c44.

📒 Files selected for processing (2)
  • src/features/settings/hooks/useDatabaseConversion.test.ts
  • src/features/settings/hooks/useDatabaseConversion.ts

Comment @coderabbitai help to get the list of available commands.

@github-actions github-actions Bot added change:fix PR: bug-fix branch work change:test PR: test harness, fixtures, or coverage changes area:frontend Area: React, TypeScript, UI, browser tests, or Vite area:javascript Area: JavaScript or TypeScript dependency/tooling work labels Sep 27, 2026
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Sep 27, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-09-27T09:42:49.247920Z 0b52f03 PR opened
🔒 Security Review ✅ Completed 2026-09-27T09:42:36.298629Z 0b52f03 PR opened
ℹ️ 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" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@github-actions

github-actions Bot commented Sep 27, 2026 •

Copy link
Copy Markdown
Contributor

Coverage Report

Status Category Percentage Covered / Total
🟢 Lines 90.47% (🎯 60%) 3675 / 4062
🟢 Statements 90.13% (🎯 60%) 3827 / 4246
🟢 Functions 89.31% (🎯 60%) 903 / 1011
🟢 Branches 77.5% (🎯 60%) 2112 / 2725
File Coverage
File Stmts Branches Functions Lines Uncovered Lines
Changed Files
src/features/settings/hooks/useDatabaseConversion.ts 86.66% 88.46% 93.33% 86.51%
Generated in workflow #4818 for commit d492c44 by the Vitest Coverage Report Action

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 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".

@github-actions

github-actions Bot commented Sep 27, 2026 •

Copy link
Copy Markdown
Contributor

E2E captures

Evidence captures for d492c440185c443200963a49cf83374489bef94b (also available as the e2e-captures workflow artifact).

cpu-detail

cpu-detail

dashboard-gpu-secondary

dashboard-gpu-secondary

dashboard-storage-many

dashboard-storage-many

dashboard

dashboard

database-conversion-action-required-collapsed

database-conversion-action-required-collapsed

database-conversion-action-required-expanded

database-conversion-action-required-expanded

database-conversion-action-required-narrow

database-conversion-action-required-narrow

database-conversion-complete-notice-narrow

database-conversion-complete-notice-narrow

database-conversion-complete-notice

database-conversion-complete-notice

database-conversion-converting-narrow

database-conversion-converting-narrow

database-conversion-converting

database-conversion-converting

database-conversion-not-supported

database-conversion-not-supported

database-conversion-prompt-dialog-complete

database-conversion-prompt-dialog-complete

database-conversion-prompt-dialog-converting

database-conversion-prompt-dialog-converting

database-conversion-prompt-dialog-narrow

database-conversion-prompt-dialog-narrow

database-conversion-prompt-dialog

database-conversion-prompt-dialog

database-conversion-sqlite-authoritative-narrow

database-conversion-sqlite-authoritative-narrow

database-conversion-sqlite-authoritative

database-conversion-sqlite-authoritative

insights-cooling-ambient-only

insights-cooling-ambient-only

insights-cooling-ambient

insights-cooling-ambient

insights-cooling-coverage-90d

insights-cooling-coverage-90d

insights-cooling-establishing

insights-cooling-establishing

insights-cooling-explorer

insights-cooling-explorer

insights-cooling-no-fan

insights-cooling-no-fan

insights-cooling-no-power

insights-cooling-no-power

insights-cooling-observation-mild

insights-cooling-observation-mild

insights-cooling-observation-not-comparable

insights-cooling-observation-not-comparable

insights-cooling-timeline-30d

insights-cooling-timeline-30d

insights-cooling-timeline-90d

insights-cooling-timeline-90d

insights-cooling

insights-cooling

insights-main

insights-main

insights-process

insights-process

nsis-migration-notice

nsis-migration-notice

performance-compact-fullscreen-small-window

performance-compact-fullscreen-small-window

performance-compact-fullscreen

performance-compact-fullscreen

performance-compact-window

performance-compact-window

performance-gpu-selector-compact

performance-gpu-selector-compact

performance-gpu-selector-desktop

performance-gpu-selector-desktop

performance-gpu-selector-monitor

performance-gpu-selector-monitor

performance-monitor-desktop

performance-monitor-desktop

performance-monitor-power-current-compact-window

performance-monitor-power-current-compact-window

performance-monitor-power-current

performance-monitor-power-current

performance-monitor-power-graph-compact-window

performance-monitor-power-graph-compact-window

performance-monitor-power-graph

performance-monitor-power-graph

performance-panels-desktop

performance-panels-desktop

performance-panels-editing-desktop

performance-panels-editing-desktop

performance-panels-power-graph

performance-panels-power-graph

performance-panels-two-column-desktop

performance-panels-two-column-desktop

settings-display-targets

settings-display-targets

settings-elevation-unprotected

settings-elevation-unprotected

settings

settings

system-specifications-compact-window

system-specifications-compact-window

system-specifications-desktop

system-specifications-desktop

usage

usage

@github-actions

github-actions Bot commented Sep 27, 2026 •

Copy link
Copy Markdown
Contributor

CI telemetry

Commit d492c44 · updated 2026-09-27 10:15 UTC

Workflow Result Wall time Longest queue Jobs
CI ✅ success 13m 10s 7s 9
CodeQL Advanced ✅ success 12m 50s 2s 3
PR Branch Name ✅ success 7s 3s 1
CI · 9 jobs · 11 skipped
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.
@shm11C3

shm11C3 commented Sep 27, 2026

Copy link
Copy Markdown
Owner Author

@coderabbitai review

@coderabbitai

coderabbitai Bot commented Sep 27, 2026 •

Copy link
Copy Markdown
Contributor
⚠️ Action not completed

Review rate limited.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

@shm11C3

shm11C3 commented Sep 27, 2026

Copy link
Copy Markdown
Owner Author

@coderabbitai approve

@coderabbitai

coderabbitai Bot commented Sep 27, 2026

Copy link
Copy Markdown
Contributor
✅ Action performed

Comments resolved and changes approved.

@shm11C3
shm11C3 merged commit a70c4c7 into develop Oct 3, 2026
32 checks passed
@shm11C3
shm11C3 deleted the fix/2267-conversion-complete-notice branch October 3, 2026 02:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area:frontend Area: React, TypeScript, UI, browser tests, or Vite area:javascript Area: JavaScript or TypeScript dependency/tooling work change:fix PR: bug-fix branch work change:test PR: test harness, fixtures, or coverage changes

Projects

None yet

Development

Successfully merging this pull request may close these issues.

fix(settings): the conversion-complete notice is lost when Settings is not open at completion

1 participant