Skip to content

Fix stale cache refresh for updated session files - #4

Merged
abasiri merged 1 commit into
doctly:mainfrom
AliFozooni:main
Mar 15, 2026
Merged

abasiri merged 1 commit into
doctly:mainfrom
AliFozooni:main

Conversation

@AliFozooni

Copy link
Copy Markdown
Contributor

Summary

  • derive the cached folder index timestamp from the project directory and its root session .jsonl files
  • use that timestamp consistently in the initial worker scan and in background refresh checks
  • add a regression test for appending to an existing session file

Why

Background refresh currently keys off the project directory mtime. Appending to an existing session file updates the file mtime but usually leaves the directory mtime unchanged, so long-running sessions can keep stale ordering, message counts, titles, and search data until a new file appears or the app restarts.

Verification

  • npm test

@abasiri
abasiri self-requested a review March 15, 2026 20:53
@abasiri
abasiri merged commit 90c3507 into doctly:main Mar 15, 2026
3 checks passed
vincentbattez referenced this pull request in vincentbattez/wootonpad Jul 30, 2026
The collapse initialiser stored a function in a ref and never invoked it,
so the value was always truthy and the auto-collapse-stale logic was dead.
Collapse is now computed as `filter active ? expanded : override ?? stale`,
with the user's toggle held in a separate override ref — so clearing a
filter restores the previous arrangement instead of overwriting it.

Two deliberate notes:
- `_projectMatchedOnly` still wins over the filter check. AC #4 reads as
  "filter always expands", but name-only search matches have no matching
  sessions inside, so expanding them would show empty groups.
- `showTodayOnly` joins the filter predicate; it was already part of
  `visibleItems`'s `anyFilter` but missing from the collapse check.

Stale detection extracted to `src/vue/project-collapse.mjs` as a pure
`isStaleProject(project, maxAgeDays, now)` and covered by unit tests.
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.

2 participants