Skip to content

renderer: a read that asks for fresh data, or any read after a mutation, no longer answers from the 1s GET dedupe cache - #142

Open
kai-openswarm wants to merge 1 commit into
openswarm-ai:devfrom
kai-openswarm:fix/memory-refresh-cache
Open

renderer: a read that asks for fresh data, or any read after a mutation, no longer answers from the 1s GET dedupe cache#142
kai-openswarm wants to merge 1 commit into
openswarm-ai:devfrom
kai-openswarm:fix/memory-refresh-cache

Conversation

@kai-openswarm

Copy link
Copy Markdown

What

The renderer's fetch interceptor (frontend/src/shared/config.ts) dedupes identical GETs to the local API through a 1 s response cache. Two cases must never be answered from it, and neither was:

  • a caller that asked for fresh data (cache: 'no-store' / 'reload') — it now bypasses the cache and an identical in-flight request;
  • any GET after a successful mutation that may have changed what it reads — every mutation now clears the GET cache (it is a burst dedupe, not a store; the cost is at most one extra round trip per URL).

The policy lives in a small pure module (getCachePolicy.ts) with a node --test file, so it is testable without a window.

Why (user-visible)

Settings › Memory: add a fact within about a second of opening the tab and the list stays on "Nothing saved yet" even though the store already holds the fact — the panel's post-save refresh() GET was served from the panel's own mount GET, cached moments earlier. Reopening the tab showed it. Any panel that mounts, mutates, and refetches the same URL inside a second has the same hole.

How it was verified

  • node --test frontend/src/shared/getCachePolicy.test.ts (2 tests) and tsc --noEmit clean.
  • On a packaged 1.7.7 build (macOS): opening Settings › Memory and adding a fact immediately shows the fact 3/3 runs with this change; the same steps failed 3/3 without it (the list stayed empty until the tab was reopened).

No behaviour change for default reads: bursts of identical GETs (twenty cards mounting) still dedupe exactly as before.

…on, no longer answers from the 1s GET dedupe cache

The fetch interceptor dedupes identical GETs through a 1s response cache. Two
cases must never be served from it: a caller that said cache: 'no-store' /
'reload' (it wants the network), and any GET after a mutation that may have
changed what it reads. Neither was honoured, so Settings > Memory could add a
fact and immediately refetch the list into the pre-save copy cached by its own
mount fetch, showing "Nothing saved yet" for a fact the store already held
until the panel was reopened.

Now no-store/reload bypasses both the cache and an in-flight join, and every
successful mutation clears the GET cache (it is a burst dedupe, not a store;
the cost is at most one extra round trip per URL). Policy lives in a pure
module with a node test.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
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