[GH-ISSUE #1535] [Issue]: Long-Term Memory: opening a memory while a bulk availability change runs shows, and can save back, its old availability #1511

Closed
opened 2026-10-22 04:02:49 +07:00 by bsakaguchi · 0 comments
Owner

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

Originally assigned to: @Promansis on GitHub.

Summary

In the Memory Vault, a bulk change (Change availability, Set status, Set modes, Archive) is undone, or left half-finished, when you open a memory before it finishes. The bulk availability panel closes as soon as you press Apply and the change runs in the background. If you open a memory meanwhile, the vault stops following the change when it answers: the memory list is not reloaded, the bulk buttons stay disabled, and the memory you opened keeps showing its availability from before the change. Saving the memory, or its availability from an "Edit availability" panel opened after the change finished, writes the old places back.

A memory that is already open and is part of the change has the same problem without any click: the list reloads, but the open memory keeps its old availability.

Affected package

long-term-memory 1.4.69 (upstream/staging 5984f0784), Memory Vault (client).

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

Expected behavior

When a bulk change finishes, the memory list reloads and the bulk buttons work again, whatever was opened in the meantime. An open memory that was part of the change shows the new availability; without unsaved edits it shows the whole reloaded memory, including a new status after a bulk Set status or Archive and the restored status after an archive Undo. If it has unsaved edits, those edits are kept and only its availability is updated, so saving it afterwards does not put back what the bulk change removed. (An "Edit availability" panel that is already open at that moment keeps its own copy; see "Not included".)

Actual behavior

  • runBatchForIds (C/vault/MemoryVault.tsx:1802) remembers the editor session, sends POST /notes/batch, and after the answer returns at once if the session changed (:1921). Opening a memory (openNote, :1335), starting a new one or switching place all change the session.
  • So when you open a memory during the change, invalidate() (:1975) never runs: the list, counts and place lists keep the notes from before the change.
  • finally clears the busy flag only for the same session (:1980). Every control with disabled={Boolean(busy)} stays disabled: the bulk buttons, each row's Archive and Delete, the editor's Remove detail and Rename detail, and Undo. It clears only when another action resets the flag, for example saving a memory.
  • The memory you opened comes from that old list (openNote copies the list's note). The editor and its "Edit availability" panel show the old scope. saveAvailability (:1486) sends the panel's whole scope and modes, and Save sends scope and modes with the rest of the memory, so either one writes the old places back.
  • A memory that was already open and was part of the change: the session is unchanged and the list reloads, but nothing reloads the open memory, so it shows and saves the old availability the same way.

Reproduced every time in the browser suite by delaying the /notes/batch answer by 1.5 s: the memory opened during the change shows 5 places ("Bulk chat 7", "Unavailable chat", "Conversation A", "Character A", "Persona A") instead of 4, the row actions stay disabled, and no list request follows the change.

Steps to reproduce

  1. Open the Memory Vault on a vault large enough that a bulk change takes a moment (or slow the network in the browser's developer tools).
  2. Choose Select, tick a memory that is available in two chats, and choose Change availability → Remove availability → one of the two chats → Apply.
  3. Before the change finishes, open the same memory from the list.
  4. The editor still counts both chats, and Edit availability lists both. Save availability: the removed chat is back on the memory.
  5. The Select toolbar's buttons stay disabled until you save a memory or leave the vault.

For the already-open case: open the memory first, then do step 2 with it ticked. After Apply the editor still counts the removed chat.

Minimal fix

One PR, patch bump, client only: C/vault/MemoryVault.tsx.

  • A small refreshAfterBatch step after every bulk answer: reload the queries as invalidate() does, then, if the open memory is in the answer's affectedNoteIds, load it again (GET /notes/:id). An editor without unsaved edits takes the reloaded memory. An editor with unsaved edits takes only the availability (scope and modes) and the version, as an availability save already does. The reloaded memory is dropped if the editor moved to another memory while it loaded, or already holds a newer save (a higher version), so a save made meanwhile is not undone.
  • runBatchForIds runs that step whether or not the editor session changed. The session check still guards what belongs to the old session: the selection, the notice or error text and the archive Undo.
  • Undo after a bulk Archive (undoArchive) runs the same step instead of invalidate() (:1472), with the ids the restores changed. Otherwise the reload after the Archive would leave an open memory showing Archived after the Undo had restored it, and saving it would archive it again.
  • Clear the busy flag with the functional form the delete path already uses, setBusy((current) => (current === action ? "" : current)), so it clears after the change without clearing a different action's flag.
  • CHANGELOG under ## Unreleased: "A memory you open, or already have open, while a bulk change in the Memory Vault is running now shows the new availability once the change finishes, so saving the memory then no longer puts the old places back, and the bulk buttons no longer stay disabled. An open memory without unsaved changes also shows its new status after a bulk change and after an archive Undo, so saving it does not change the status back."

Not included

  • A version check on save (the server refusing a save based on an old copy). PATCH /notes/:id has no such check today and the editor does not send a version. It would cover every lost update (another tab, background extraction, a save sent during the change) and needs server, client and error-message work. Separate issue if wanted.
  • Disabling the memory list while a bulk change runs. Smaller, but it does not fix an already-open memory and greys out the list during every busy action.
  • An "Edit availability" panel that is already open when the change finishes keeps the places it opened with, as it does today, and saving it puts the removed places back. Closing and reopening it shows the new availability.
  • An editor with unsaved edits takes only the new availability. After a bulk Set status or Archive that changed the open memory, or an archive Undo that restored it, it still shows the old status, and saving it writes that status back, as it does today for any field being edited.
  • Undo archive, Save, permanent delete and Rename detail also return early when another memory is opened while they run (C/vault/MemoryVault.tsx). Follow-up:
    • Undo archive (undoArchive, return :1432, finally :1478): the busy flag stays set, so the Select toolbar, each row's Archive and Delete, Remove detail, Rename detail and Undo stay disabled until another action such as a save resets it; the lists do not reload; and if only some memories were restored, the rollback that archives them again (:1454-1462) is skipped.
    • Permanent delete (deleteSelected, return :1678): the flag clears (the caller's finally, :1884), but the deleted memories stay listed and ticked with no message, a deleted memory opened meanwhile fails to save, and a later bulk action reports the deleted ids as failed.
    • Save (save(), return :1596, finally :1669): choosing Discard in the unsaved-changes dialog while a slow save runs leaves the flag set the same way (from reading the code).
    • Rename detail (renameSection, return :1766, finally :1799): its dialog's Cancel button is disabled while it runs, but Escape still closes the dialog (:2491), so another memory can be opened and the flag stays set the same way.

Regression proof

In tests/long-term-memory-browser.regression.ts, in the existing bulk "Remove availability" case:

  • After the first bulk removal, with the memory open and part of the change, the editor's summary must count the deleted chat the reload brings ("5 places"). On staging it stays at 4.
  • For the second bulk removal the test holds the /notes/batch answer (page.route, times: 1), opens the memory and edits its title, then releases the answer. It then expects the row's Archive button to be enabled again, a new list request, the title edit kept, and the post-removal availability (one whole-chat chip, no branch chips, 4 chips, the existing assertions). On staging the busy flag never clears and the editor shows 5 chips.
  • In the existing archive Undo case, the test opens one of the two memories before archiving them, then expects the complete Undo to reload it (GET /notes/:id) once the archive's own reload has finished. Without the Undo step the request never comes.
  • Each part of the fix was removed in turn and the suite failed each time.
  • A save answered while the open memory reloads: a local probe (not part of the patch) serves the reload before a Save and answers it after. Without the version check the editor drops back to the copy from before the save and shows it as saved, so a later save writes the old title back; with it the save stays.

Environment

  • Marinara Engine version: 2.5.1 (staging 87d1ccadc)
  • Package version: long-term-memory 1.4.69 (upstream/staging 5984f0784)
  • Install type: source (code reading and the local browser suite)
  • OS + version: Linux 6.8 (Ubuntu); not platform-specific
  • Browser or app shell: any (reproduced in Playwright Chromium)

Logs, screenshots, or video

From the browser suite with the /notes/batch answer delayed by 1.5 s:

DET pills ["Remove Bulk chat 7","Remove Unavailable chat","Remove Conversation A","Remove Character A","Remove Persona A"]
DET busy-buttons-disabled 4
AssertionError [ERR_ASSERTION]: Expected values to be strictly equal:

5 !== 4

Additional context

Tracker item OT-9. Found while measuring the browser-suite flakes (OT-8).

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 21, 2026). Original GitHub issue: https://github.com/Pasta-Devs/Marinara-Agents/issues/1535 Originally assigned to: @Promansis on GitHub. ## Summary In the Memory Vault, a bulk change (Change availability, Set status, Set modes, Archive) is undone, or left half-finished, when you open a memory before it finishes. The bulk availability panel closes as soon as you press Apply and the change runs in the background. If you open a memory meanwhile, the vault stops following the change when it answers: the memory list is not reloaded, the bulk buttons stay disabled, and the memory you opened keeps showing its availability from before the change. Saving the memory, or its availability from an "Edit availability" panel opened after the change finished, writes the old places back. A memory that is already open and is part of the change has the same problem without any click: the list reloads, but the open memory keeps its old availability. ## Affected package `long-term-memory` 1.4.69 (`upstream/staging` 5984f0784), Memory Vault (client). `C` = `packages/long-term-memory/src/engine/packages/client/src/features/long-term-memory` ## Expected behavior When a bulk change finishes, the memory list reloads and the bulk buttons work again, whatever was opened in the meantime. An open memory that was part of the change shows the new availability; without unsaved edits it shows the whole reloaded memory, including a new status after a bulk Set status or Archive and the restored status after an archive Undo. If it has unsaved edits, those edits are kept and only its availability is updated, so saving it afterwards does not put back what the bulk change removed. (An "Edit availability" panel that is already open at that moment keeps its own copy; see "Not included".) ## Actual behavior - `runBatchForIds` (`C/vault/MemoryVault.tsx:1802`) remembers the editor session, sends `POST /notes/batch`, and after the answer returns at once if the session changed (`:1921`). Opening a memory (`openNote`, `:1335`), starting a new one or switching place all change the session. - So when you open a memory during the change, `invalidate()` (`:1975`) never runs: the list, counts and place lists keep the notes from before the change. - `finally` clears the busy flag only for the same session (`:1980`). Every control with `disabled={Boolean(busy)}` stays disabled: the bulk buttons, each row's Archive and Delete, the editor's Remove detail and Rename detail, and Undo. It clears only when another action resets the flag, for example saving a memory. - The memory you opened comes from that old list (`openNote` copies the list's note). The editor and its "Edit availability" panel show the old scope. `saveAvailability` (`:1486`) sends the panel's whole scope and modes, and Save sends scope and modes with the rest of the memory, so either one writes the old places back. - A memory that was already open and was part of the change: the session is unchanged and the list reloads, but nothing reloads the open memory, so it shows and saves the old availability the same way. Reproduced every time in the browser suite by delaying the `/notes/batch` answer by 1.5 s: the memory opened during the change shows 5 places ("Bulk chat 7", "Unavailable chat", "Conversation A", "Character A", "Persona A") instead of 4, the row actions stay disabled, and no list request follows the change. ## Steps to reproduce 1. Open the Memory Vault on a vault large enough that a bulk change takes a moment (or slow the network in the browser's developer tools). 2. Choose Select, tick a memory that is available in two chats, and choose Change availability → Remove availability → one of the two chats → Apply. 3. Before the change finishes, open the same memory from the list. 4. The editor still counts both chats, and Edit availability lists both. Save availability: the removed chat is back on the memory. 5. The Select toolbar's buttons stay disabled until you save a memory or leave the vault. For the already-open case: open the memory first, then do step 2 with it ticked. After Apply the editor still counts the removed chat. ## Minimal fix One PR, patch bump, client only: `C/vault/MemoryVault.tsx`. - A small `refreshAfterBatch` step after every bulk answer: reload the queries as `invalidate()` does, then, if the open memory is in the answer's `affectedNoteIds`, load it again (`GET /notes/:id`). An editor without unsaved edits takes the reloaded memory. An editor with unsaved edits takes only the availability (scope and modes) and the version, as an availability save already does. The reloaded memory is dropped if the editor moved to another memory while it loaded, or already holds a newer save (a higher `version`), so a save made meanwhile is not undone. - `runBatchForIds` runs that step whether or not the editor session changed. The session check still guards what belongs to the old session: the selection, the notice or error text and the archive Undo. - Undo after a bulk Archive (`undoArchive`) runs the same step instead of `invalidate()` (`:1472`), with the ids the restores changed. Otherwise the reload after the Archive would leave an open memory showing Archived after the Undo had restored it, and saving it would archive it again. - Clear the busy flag with the functional form the delete path already uses, `setBusy((current) => (current === action ? "" : current))`, so it clears after the change without clearing a different action's flag. - **CHANGELOG under `## Unreleased`**: "A memory you open, or already have open, while a bulk change in the Memory Vault is running now shows the new availability once the change finishes, so saving the memory then no longer puts the old places back, and the bulk buttons no longer stay disabled. An open memory without unsaved changes also shows its new status after a bulk change and after an archive Undo, so saving it does not change the status back." **Not included** - A version check on save (the server refusing a save based on an old copy). `PATCH /notes/:id` has no such check today and the editor does not send a version. It would cover every lost update (another tab, background extraction, a save sent during the change) and needs server, client and error-message work. Separate issue if wanted. - Disabling the memory list while a bulk change runs. Smaller, but it does not fix an already-open memory and greys out the list during every busy action. - An "Edit availability" panel that is already open when the change finishes keeps the places it opened with, as it does today, and saving it puts the removed places back. Closing and reopening it shows the new availability. - An editor with unsaved edits takes only the new availability. After a bulk Set status or Archive that changed the open memory, or an archive Undo that restored it, it still shows the old status, and saving it writes that status back, as it does today for any field being edited. - Undo archive, Save, permanent delete and Rename detail also return early when another memory is opened while they run (`C/vault/MemoryVault.tsx`). Follow-up: - Undo archive (`undoArchive`, return `:1432`, `finally` `:1478`): the busy flag stays set, so the Select toolbar, each row's Archive and Delete, Remove detail, Rename detail and Undo stay disabled until another action such as a save resets it; the lists do not reload; and if only some memories were restored, the rollback that archives them again (`:1454-1462`) is skipped. - Permanent delete (`deleteSelected`, return `:1678`): the flag clears (the caller's `finally`, `:1884`), but the deleted memories stay listed and ticked with no message, a deleted memory opened meanwhile fails to save, and a later bulk action reports the deleted ids as failed. - Save (`save()`, return `:1596`, `finally` `:1669`): choosing Discard in the unsaved-changes dialog while a slow save runs leaves the flag set the same way (from reading the code). - Rename detail (`renameSection`, return `:1766`, `finally` `:1799`): its dialog's Cancel button is disabled while it runs, but Escape still closes the dialog (`:2491`), so another memory can be opened and the flag stays set the same way. ## Regression proof In `tests/long-term-memory-browser.regression.ts`, in the existing bulk "Remove availability" case: - After the first bulk removal, with the memory open and part of the change, the editor's summary must count the deleted chat the reload brings ("5 places"). On `staging` it stays at 4. - For the second bulk removal the test holds the `/notes/batch` answer (`page.route`, `times: 1`), opens the memory and edits its title, then releases the answer. It then expects the row's Archive button to be enabled again, a new list request, the title edit kept, and the post-removal availability (one whole-chat chip, no branch chips, 4 chips, the existing assertions). On `staging` the busy flag never clears and the editor shows 5 chips. - In the existing archive Undo case, the test opens one of the two memories before archiving them, then expects the complete Undo to reload it (`GET /notes/:id`) once the archive's own reload has finished. Without the Undo step the request never comes. - Each part of the fix was removed in turn and the suite failed each time. - A save answered while the open memory reloads: a local probe (not part of the patch) serves the reload before a Save and answers it after. Without the version check the editor drops back to the copy from before the save and shows it as saved, so a later save writes the old title back; with it the save stays. ## Environment - Marinara Engine version: 2.5.1 (`staging` 87d1ccadc) - Package version: long-term-memory 1.4.69 (`upstream/staging` 5984f0784) - Install type: source (code reading and the local browser suite) - OS + version: Linux 6.8 (Ubuntu); not platform-specific - Browser or app shell: any (reproduced in Playwright Chromium) ## Logs, screenshots, or video From the browser suite with the `/notes/batch` answer delayed by 1.5 s: ``` DET pills ["Remove Bulk chat 7","Remove Unavailable chat","Remove Conversation A","Remove Character A","Remove Persona A"] DET busy-buttons-disabled 4 AssertionError [ERR_ASSERTION]: Expected values to be strictly equal: 5 !== 4 ``` ## Additional context Tracker item OT-9. Found while measuring the browser-suite flakes (OT-8). ## 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-22 04:02:49 +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#1511
No description provided.