Skip to content

(restore): retry the cold-cache restore until indexing is done, not once - #263

Merged
devsuitup merged 1 commit into
mainfrom
fix/restore-retry-until-indexed
Sep 11, 2026
Merged

(restore): retry the cold-cache restore until indexing is done, not once#263
devsuitup merged 1 commit into
mainfrom
fix/restore-retry-until-indexed

Conversation

@devsuitup

Copy link
Copy Markdown
Owner

Audit 2026-09-11, finding 5 (.work-files/switchboard/audit-fable-2026-09-11.md, local note); follows #239.

Why

On a cold start populateCacheViaWorker fills sessionMap one folder at a time. The single retry introduced by #239 fired on the first partial projects-changed: it restored whatever was indexed by then and never came back for the rest, or gave up when nothing was indexed yet. Its test was a replica of the app.js orchestration and never modelled a partial map.

What

  • public/restore-plan.js: createRestorePlanner({ savedSet, maxTicks, askOnce }) — a pure planner that tracks the saved ids still missing across ticks. auto restores incrementally as sessions get indexed and keeps waiting until every id is indexed or indexing reports done (then the rest is treated as deleted); ask asks once, with the final picture. Dismiss, a tick cap and a session opened outside the restore all settle it.
  • public/app.js: one planner per startup, ticked from the existing loadProjects() call sites and from updateIndexingBanner on payload.done; the two retry flags are gone.
  • test/session-restore-cold-cache.test.js rewritten against the real module: partial map, none indexed, done-with-missing, cap, dismiss, outside open, already open, askOnce variants, plus one wiring check.

Proof

Mutations: mark everything restored on the first restore → partial-map test red; make wait ignore indexingDone → deleted-sessions test red. task check: 1141 + 119 pass, 0 fail, 8 pre-existing skips.

createRestorePlanner replaces the one-shot defer/retry flags: it ticks
on every projects-changed/indexing-progress event, restoring sessions
incrementally as they get indexed (auto mode) or asking once the full
picture is known (ask mode), instead of consuming its only retry on
the first partially-populated sessionMap.
@devsuitup
devsuitup merged commit f1ffc92 into main Sep 11, 2026
10 checks passed
@devsuitup
devsuitup deleted the fix/restore-retry-until-indexed branch September 11, 2026 14:59
@devsuitup devsuitup mentioned this pull request Sep 11, 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