Skip to content

fix(frontend): load root folders on mount so cold first add isn't falsely rejected#661

Open
timk75 wants to merge 1 commit into
Listenarrs:canaryfrom
timk75:fix/cold-add-root-folder
Open

fix(frontend): load root folders on mount so cold first add isn't falsely rejected#661
timk75 wants to merge 1 commit into
Listenarrs:canaryfrom
timk75:fix/cold-add-root-folder

Conversation

@timk75

@timk75 timk75 commented Jun 8, 2026

Copy link
Copy Markdown

Summary

Fixes the cold-start "Root folder not configured" false negative. After a fresh page load (or after the app has been idle long enough that the SPA is re-initialised), the first attempt to add an audiobook reports "Root folder not configured" and redirects to Settings — even though a root folder is configured. Going browser-back and trying again works, which is the tell-tale symptom.

Root cause. rootFoldersStore is only ever populated by an explicit load() call. Several views read rootFoldersStore.folders synchronously to gate UI, but nothing loads the store on a cold SPA start — not App.vue, not the router, not these views' onMounted. So the guard sees an empty list and assumes no folder is configured. The redirect to /settings happens to load the store, which is why the second attempt succeeds.

The same un-loaded-store read affects two more views (found while tracing the root cause).

Changes

Changed

  • AddNewView.vue — load root folders in onMounted before addToLibrary()'s guard can read them. This is the primary cold-add fix.
  • AudiobooksView.vuehasRootFolderConfigured drives a "Root Folder Not Configured" empty-state CTA; load the store on mount so an empty library doesn't falsely show it.
  • AudiobookDetailView.vue — the path-preview computed falls back to rootFoldersStore.defaultFolder; load the store on mount so a cold load previews the correct destination instead of the legacy outputPath.
  • All three mirror the existing pattern already used in LibraryImportView.vue and UnmatchedFilesModal.vue (if (folders.length === 0) await load()).

Fixed

  • stores/rootFolders.tsload() no longer resets folders to [] inside its catch. Previously a transient API failure on reload wiped already-loaded folders, making a failed load indistinguishable from "no folders configured". folders still starts as [], so a first-ever failure naturally yields an empty list.

Added

  • Regression test in AddNewView.spec.ts asserting the view fetches root folders on mount.

Testing

  • Full frontend suite green (363 passed, 1 skipped), including the new regression test.
  • vue-tsc --noEmit and eslint clean on all changed files.

Notes

  • The guard at AddNewView.vue also accepts a configured applicationSettings.outputPath as an alternative to a root folder; that path was already loaded on mount, so only the root-folder half was failing.
  • load() has no in-flight de-dupe; the if (folders.length === 0) caller-side guard keeps this to a single fetch per cold load, consistent with the existing call sites. A store-level loading guard would be a reasonable follow-up but is out of scope here.

@timk75 timk75 requested a review from a team June 8, 2026 17:05
@therobbiedavis therobbiedavis self-assigned this Jun 9, 2026
@therobbiedavis therobbiedavis added the patch patch version bump - backward compatible bug fixes label Jun 9, 2026
…sely rejected

The root folders store is only ever populated by an explicit load() call.
Several views read rootFoldersStore.folders synchronously to gate UI, but
never load it on a cold SPA start:

- AddNewView's addToLibrary() guard reported "Root folder not configured"
  and redirected to /settings on the first add after a fresh page load;
  the redirect populated the store, so a back+retry then succeeded.
- AudiobooksView's hasRootFolderConfigured drove a false "Root Folder Not
  Configured" empty-state for users whose library is empty.
- AudiobookDetailView's path preview fell back to the legacy outputPath.

Load the store on mount in each of these views (mirroring the existing
LibraryImportView / UnmatchedFilesModal pattern). Also stop wiping
already-loaded folders when a reload throws, so a transient API failure no
longer masquerades as "no root folders configured".

Adds a regression test asserting AddNewView fetches root folders on mount.
@therobbiedavis therobbiedavis force-pushed the fix/cold-add-root-folder branch from 58f21db to 6e8c024 Compare June 9, 2026 14:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

patch patch version bump - backward compatible bug fixes

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants