[GH-ISSUE #1452] [Issue]: Long-Term Memory: settings forms refill from the cache when the reload after Reset or Import fails #738

Closed
opened 2026-10-20 17:30:13 +07:00 by bsakaguchi · 0 comments
Owner

Originally created by @Promansis on GitHub (Oct 18, 2026).
Original GitHub issue: https://github.com/Pasta-Devs/Marinara-Agents/issues/1452

Originally assigned to: @Promansis on GitHub.

Summary

After Reset settings or Import backup, the settings forms are cleared and refilled from the next fetch. If that fetch fails, the forms refill from the cached pre-reset (or pre-import) values instead, with no error shown. The screen then shows settings the server no longer has, and a Save would write them back. (Tracker item UI-4; a known edge left by #1376's CodeRabbit repair.)

Affected package

long-term-memory 1.4.48 (upstream/staging 1f7954305).

  • C = packages/long-term-memory/src/engine/packages/client/src/features/long-term-memory

Expected behavior

After Reset or Import, the forms show only settings fetched after the action. If that fetch fails, the forms show the error surface with a retry, not the old values.

Actual behavior

  • MaintenancePanel.resetSettings (C/settings/MaintenancePanel.tsx:418-462) calls settings.clear(), awaits the invalidation, then applies the refetched settings or calls settings.clear() again when the refetch did not complete (:441-446). The comment at :441-442 records the refill.
  • settings.clear() (C/settings/MemorySettings.tsx:344-349) sets the four form states to null.
  • The populate effects (MemorySettings.tsx:240-251) run whenever a form is null and global.data or extraction.data exists. React Query keeps the previous data in the cache when a refetch fails, so the effects refill the forms from it.
  • Backup import (MaintenancePanel.tsx:391-412) has the same shape: settings.clear() at :403, then the effects refill from the previous vault's settings.

Checked at 1f7954305.

Steps to reproduce

  1. Set max chunks to a non-default value and save.
  2. Make the settings refetch fail once (block GET /api/long-term-memory/settings in dev tools), then press Reset settings and confirm.
  3. The success message appears, and the form still shows the non-default value. Save is enabled.

Minimal fix

One PR, patch bump. C/settings/MemorySettings.tsx and C/settings/MaintenancePanel.tsx only.

  1. Make clear record when the forms were cleared, for example a formsClearedAt state set to Date.now(), and make the two populate effects (:240-251) populate only when the query's dataUpdatedAt is at or after it. useQuery exposes dataUpdatedAt. Stale cached data then never refills a cleared form.
  2. With that in place, MaintenancePanel no longer needs the second settings.clear() at :446 or the comment at :441-442; keep apply for the success path so the forms load without waiting for a render. Leave the backup import's integrity check (:402-405) as it is.
  3. While the forms are null and the query is in error, MemorySettings already renders its error surface with a retry (the <section> root is kept so the Maintenance panel stays mounted, :359-362); confirm the retry path repopulates once a fetch succeeds.

CHANGELOG under ## Unreleased: one bullet, that a failed reload after Reset or Import now shows an error instead of the old settings.

Not included

  • Dropping the redundant .refetch() calls and the queryKeys.root invalidation noted in the client UI audit (A-012). Different behaviour, separate change.

Regression proof

  • tests/long-term-memory-browser.regression.ts: extend the #1376 Reset case (:3704 onward, which already routes /settings/reset and gates the settings read). Add a variant where the settings refetch after Reset fails once: the form does not show the pre-reset value, the error surface is shown, and a retry loads the reset value. Mirror it for Import backup if the fixture allows; otherwise state that Import shares the code path.
  • Also run feedback-clarity-ui.

Environment

  • Marinara Engine version: 2.5.0 line (staging 2039583ca)
  • Package version: long-term-memory 1.4.48 (upstream/staging 1f7954305)
  • Install type: source (code audit)
  • OS + version: not platform-specific
  • Browser or app shell: any

Logs, screenshots, or video

None. Recorded as a known edge in the #1376 repair notes and confirmed by reading the code at 1f7954305.

Additional context

Tracker item UI-4. Follow-up to #1376 (PR #1400). Shares no source file with the other batch-1 issues; it is the only one that edits the browser regression.

Template check

Please uncheck (untick) the box below before submitting so we know you read the template. It is intentionally pre-checked:

  • I DID NOT read this template and provide the requested details.
Originally created by @Promansis on GitHub (Oct 18, 2026). Original GitHub issue: https://github.com/Pasta-Devs/Marinara-Agents/issues/1452 Originally assigned to: @Promansis on GitHub. ## Summary After Reset settings or Import backup, the settings forms are cleared and refilled from the next fetch. If that fetch fails, the forms refill from the cached pre-reset (or pre-import) values instead, with no error shown. The screen then shows settings the server no longer has, and a Save would write them back. (Tracker item UI-4; a known edge left by #1376's CodeRabbit repair.) ## Affected package `long-term-memory` 1.4.48 (`upstream/staging` 1f7954305). - `C` = `packages/long-term-memory/src/engine/packages/client/src/features/long-term-memory` ## Expected behavior After Reset or Import, the forms show only settings fetched after the action. If that fetch fails, the forms show the error surface with a retry, not the old values. ## Actual behavior - `MaintenancePanel.resetSettings` (`C/settings/MaintenancePanel.tsx:418-462`) calls `settings.clear()`, awaits the invalidation, then applies the refetched settings or calls `settings.clear()` again when the refetch did not complete (`:441-446`). The comment at `:441-442` records the refill. - `settings.clear()` (`C/settings/MemorySettings.tsx:344-349`) sets the four form states to `null`. - The populate effects (`MemorySettings.tsx:240-251`) run whenever a form is `null` and `global.data` or `extraction.data` exists. React Query keeps the previous data in the cache when a refetch fails, so the effects refill the forms from it. - Backup import (`MaintenancePanel.tsx:391-412`) has the same shape: `settings.clear()` at `:403`, then the effects refill from the previous vault's settings. Checked at 1f7954305. ## Steps to reproduce 1. Set max chunks to a non-default value and save. 2. Make the settings refetch fail once (block `GET /api/long-term-memory/settings` in dev tools), then press Reset settings and confirm. 3. The success message appears, and the form still shows the non-default value. Save is enabled. ## Minimal fix One PR, patch bump. `C/settings/MemorySettings.tsx` and `C/settings/MaintenancePanel.tsx` only. 1. Make `clear` record when the forms were cleared, for example a `formsClearedAt` state set to `Date.now()`, and make the two populate effects (`:240-251`) populate only when the query's `dataUpdatedAt` is at or after it. `useQuery` exposes `dataUpdatedAt`. Stale cached data then never refills a cleared form. 2. With that in place, `MaintenancePanel` no longer needs the second `settings.clear()` at `:446` or the comment at `:441-442`; keep `apply` for the success path so the forms load without waiting for a render. Leave the backup import's integrity check (`:402-405`) as it is. 3. While the forms are `null` and the query is in error, `MemorySettings` already renders its error surface with a retry (the `<section>` root is kept so the Maintenance panel stays mounted, `:359-362`); confirm the retry path repopulates once a fetch succeeds. **CHANGELOG under `## Unreleased`**: one bullet, that a failed reload after Reset or Import now shows an error instead of the old settings. **Not included** - Dropping the redundant `.refetch()` calls and the `queryKeys.root` invalidation noted in the client UI audit (A-012). Different behaviour, separate change. ## Regression proof - **`tests/long-term-memory-browser.regression.ts`**: extend the #1376 Reset case (`:3704` onward, which already routes `/settings/reset` and gates the settings read). Add a variant where the settings refetch after Reset fails once: the form does not show the pre-reset value, the error surface is shown, and a retry loads the reset value. Mirror it for Import backup if the fixture allows; otherwise state that Import shares the code path. - Also run `feedback-clarity-ui`. ## Environment - Marinara Engine version: 2.5.0 line (`staging` 2039583ca) - Package version: long-term-memory 1.4.48 (`upstream/staging` 1f7954305) - Install type: source (code audit) - OS + version: not platform-specific - Browser or app shell: any ## Logs, screenshots, or video None. Recorded as a known edge in the #1376 repair notes and confirmed by reading the code at 1f7954305. ## Additional context Tracker item UI-4. Follow-up to #1376 (PR #1400). Shares no source file with the other batch-1 issues; it is the only one that edits the browser regression. ## Template check Please **uncheck (untick)** the box below before submitting so we know you read the template. It is intentionally pre-checked: - [ ] I DID NOT read this template and provide the requested details.
bsakaguchi 2026-10-20 17:30:13 +07:00
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
Pasta-Devs/Marinara-Agents#738
No description provided.