Skip to content

fix(desktop): cache external-session catalog per selection so switching sources shows loaded rows instantly - #3905

Open
liuxiaocs7 wants to merge 1 commit into
apache:mainfrom
liuxiaocs7:fix/import-tasks-source-switch-loading
Open

fix(desktop): cache external-session catalog per selection so switching sources shows loaded rows instantly#3905
liuxiaocs7 wants to merge 1 commit into
apache:mainfrom
liuxiaocs7:fix/import-tasks-source-switch-loading

Conversation

@liuxiaocs7

Copy link
Copy Markdown
Member

Summary

Switching the import source — or toggling the archived filter / editing the search, and including returning to a source already loaded — blanked the list and flashed the full-width "Reading external conversations…" spinner on every switch, because loadCatalog unconditionally reset the catalog and loading flag with no per-selection cache.

This caches the last loaded CatalogState per (adapterId, includeArchived, search): a cache hit renders the rows immediately and refreshes in the background, while a miss keeps the existing spinner. The background import poll now observes the request generation instead of claiming a new one, so it can never strand an in-flight load's catalogLoading reset.

Fixes #3904

Verification

  • tsc for tsconfig.preload.json, tsconfig.main.json, tsconfig.renderer.json — all clean.
  • biome check on both changed files — clean.
  • node --test dist/main/__tests__/import-tasks-settings-page.test.js — 19/19 pass (15 existing + 4 new source-switching cases).
  • Fails without the change: reverting only the component to its pre-fix version makes two of the new tests fail — shows a previously-loaded source instantly with no spinner and does not let a stale background refresh overwrite a newer source selection (17/19); restoring the fix returns them to green (19/19).
  • Not run: repo-wide format:check / knip, full npm run build, and the cross-workspace suite. tsconfig.storybook.json reports one pre-existing, unrelated error (UsageRequestLog.sessionName in stories/settings/settings-pages.stories.tsx) that exists on the base commit and this PR does not touch.

Review focus (UI evidence)

I could not capture a headless screenshot of the Electron window in my environment, so the before/after is shown via the deterministic test output above instead of an image. To see it live: run the desktop app, open Settings → Activity → Import Tasks with ≥2 sources, and switch back and forth — a revisited source now appears instantly with no spinner flash (first-time loads still show the spinner).

AI use

Select exactly one:

  • No generative tool made a substantive contribution
  • Generative tooling made a substantive contribution

Tool(s) and scope: Claude Code (Claude Opus) — root-cause investigation, the per-selection cache implementation, and the added tests. Reviewed and submitted by the human contributor of record; commit carries a Generated-by: Claude Code trailer.

Checklist

  • Tests cover the change and fail without it
  • Lint, format, typecheck and the affected suites pass locally

Does this PR entail a change in behavior?

  • Yes — described under Summary above
  • No

…ng sources shows loaded rows instantly

Switching import source (or toggling the archived filter / search) blanked
the list and flashed the full-width 'reading external conversations' spinner
on every switch, including returning to a source already loaded, because
loadCatalog unconditionally reset the catalog and loading flag with no
per-selection caching.

Cache the last loaded CatalogState per (adapterId, includeArchived, search):
a cache hit renders instantly and refreshes in the background instead of
blanking; misses keep the spinner. The poll now observes rather than claims
the request generation so it can never strand an in-flight load's spinner.

Adds source-switching tests (harness now supports multiple adapters).

Generated-by: Claude Code
@M4n5ter
M4n5ter force-pushed the fix/import-tasks-source-switch-loading branch from 3d9b5c9 to fbf120f Compare August 26, 2026 09:58
@github-actions github-actions Bot added the effort/M Under 500 readable lines label Aug 27, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

effort/M Under 500 readable lines

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Import Tasks: switching source blanks the list and re-flashes the loading spinner every time

1 participant