[GH-ISSUE #1442] [Issue]: Long-Term Memory: picker and branch recall problems left after #1420, #1433 and #1438 #732

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

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

Originally assigned to: @Promansis on GitHub.

Summary

#1420 (1.4.45), #1433 (1.4.44) and #1438 (1.4.46) each shipped with small problems that their review listed and left unfixed. Two older problems in the same pickers are included, because the same files change here. Together they are:

  • Place picker:
    • Focus is lost after the unsaved-changes prompt.
    • "No memories" collapses when you switch tabs during a search.
    • The "No memories" toggle is a control inside a list that only allows options.
  • Availability editors:
    • Bulk Remove can't remove a place that no longer exists.
    • A chat imported with "All branches" shows one chip per branch, and unticking the chat leaves it available in every one of those branches.
  • Branch recall:
    • If the shared-history lookup fails, the reply gets no memories at all.
    • The search route leaves out shared-history memories.
    • A per-reply cost has no ponytail: comment.
  • Tests and dead code:
    • One browser test assertion is vacuous.
    • #1438's recall wiring has no committed test.
    • deriveScopeBranches is no longer used.

Affected package

long-term-memory 1.4.46 (upstream/staging 60d50d47d).

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

Expected behavior

  • Focus: after the unsaved-changes prompt, focus returns to the place button.
  • "No memories" group:
    • It stays open while a search is active, whichever tab is chosen.
    • Arrow keys from the search box can reach and open it.
  • Bulk Remove: it can remove an assignment to a chat, character or persona that no longer exists, as the single editor already can.
  • Whole chats:
    • A chat chosen as a whole shows one chip, wherever it was chosen.
    • Unticking or removing the chat removes it from every branch.
  • Recall:
    • A branch whose shared-history lookup fails still recalls its own memories.
    • The search route returns what a reply in that chat would recall.

Actual behavior

See each step of the Minimal fix. Every location was checked at 60d50d47d.

Steps to reproduce

  1. Focus. Edit a memory in the Vault without saving. Pick another place from the place dropdown with the keyboard, then press Stay in the prompt. Focus goes to the page body.
  2. Search. Open the place dropdown, type a search that matches a chat with no memories, then press the Chats tab. "No memories" closes while the search text stays.
  3. Whole chat. In Sources, import with the destination "Harbor Watch · All branches". Open the memory's availability editor. It shows the whole-chat chip plus one chip per branch. Untick Harbor Watch and save: the memory is still recalled in every branch.

Minimal fix

One PR, patch bump.

Place picker (C/SourceScopeCombobox.tsx)

  1. Focus after the unsaved-changes prompt.
    • Cause:
      • choose (:114-117) calls onChange before close().
      • close() moves focus to the place button only in the next animation frame (:84-90).
      • The Vault's confirm() (C/vault/MemoryVault.tsx:1203) therefore records the option button as the return target. The dropdown then unmounts it, and the refocus at :1190 skips a disconnected element.
    • Fix: in choose, focus the place button synchronously, then close(), then onChange.
  2. "No memories" stays open while searching.
    • selectKind (:91-96) always calls resetNoMemories().
    • The search effect (:69-73) only reopens the group when the search text changes.
    • Reset only when the search is empty.
  3. No control inside the listbox.
    • Replace the <details>/<summary> at :316-330:
      • While collapsed: the last row is a role="option" row, "Show N places with no memories", with a new locale key.
        • Arrow keys reach it like any other option.
        • Enter or a click opens the group.
        • choose treats it as a toggle and never calls onChange.
      • While open: the group renders like "With memories", as a role="group" with a plain label.
    • Opening it sets noMemoriesPreference, as clicking the summary does now. Clearing a search then returns to that choice, and closing the dropdown resets it.

Availability editors (C/vault/)

  1. Bulk Remove lists places that no longer exist.
    • In remove mode, BulkAvailabilityWorkbench.tsx:55-64 lists only current chats plus branch assignments.
    • Add rows for chat, group, character and persona ids that the selected memories have but no target matches. Use the fallback labels already defined at :101-104, as MemoryAvailabilityWorkbench.tsx:55-80 does for one memory.
  2. A whole chat includes its branches.
    • How the two sides save a whole chat:
      • Sources "All branches" saves { groupId, groupIds: [G], chatIds: <every branch> } (C/sources/SourcesWorkspace.tsx:436-437).
      • The editors save groupIds only (MemoryAvailabilityWorkbench.tsx:139-144).
      • availabilityEntries (vault-shared.ts) makes a chip for every chat id.
    • The fix, in both editors:
      • While chat G is selected, the branch ids that belong to G (target.chatIds) count as part of G:
        • they get no chips of their own;
        • unticking or removing G, or removing G in bulk Remove, also removes them.
      • A branch id whose chat isn't selected keeps its own chip, and saving any other change leaves it as it is (#1420's rule).
    • What stays the same:
      • The editors keep saving a newly chosen whole chat as groupIds only, which also covers branches made later.
      • Stored data, recall and the Vault filter don't change.

Branch recall (S/)

  1. Fall back when the lookup fails.
    • generation-injection.ts:189 runs branchInheritedNoteIds inside the recall try. A listChats rejection or an unreadable note fails the whole recall (:211-214).
    • Fix:
      • Catch around that one call.
      • Rethrow if the request was aborted.
      • Otherwise log a logger.warn and continue with undefined, which recalls the branch's own memories.
  2. Name the per-reply cost.
    • Every reply in a branched chat with summaries calls listChats() and listNotes() (:77, :81).
    • Add a ponytail: comment that names this limit and the upgrade path: an Engine group lookup, and reusing the cached notes snapshot.
  3. Search matches a reply.
    • routes/notes.ts:899-935 resolves a chat-only scope "like a turn" (:927-929) but doesn't pass inheritedNoteIds.
    • Export branchInheritedNoteIds and pass it with the request's mode when the route resolved the chat. Use the same fallback as step 6.

Tests and dead code

  1. Delete deriveScopeBranches (C/scope-targets.ts:125) and its cases in tests/long-term-memory-scope-targets.regression.ts (:7, :110-150).
  2. tests/long-term-memory-browser.regression.ts:1812:
    • The current check, noteQueries.some(...) with no scopeChatIds, also passes on queries made before "All" was chosen.
    • Record noteQueries.length before the choice, and check only the queries made after it.
  3. #1438 wiring and wording (tests/long-term-memory-index-keys.regression.ts):
    • In the #1363 retrieveLongTermMemory fixture (:505-575), add a check: with a 린 character memory, 린은 뭐 했지? returns the 린이 웃었다 memory through the bm25 lane.
    • Change the comment at :758 from "folds with any particle" to "folds with one allowed particle".

CHANGELOG under ## Unreleased

Cover the user-visible changes in steps 1–6 and 8. Also add one clarifying sentence for 1.4.44: in Game and Conversation chats, only rolling summaries count for branch recall. Day, week and game-session summaries don't, because each branch can write its own under the same name.

Not included

  • In #1438, every one-syllable word of a multi-word character title counts as a name, for example 그 in 그 남자. This is the approved design. Narrowing it would miss titles such as 린 (Rin).
  • #1420's changelog omits the removed shortcuts. That release note has already shipped, and this issue's entry describes the current behavior.

Regression proof

  • Browser (tests/long-term-memory-browser.regression.ts):
    • Focus: focus is on the place button after Stay and after Discard (step 1).
    • Tabs during a search: a tab change keeps "No memories" open (step 2).
    • Keyboard and roles: ArrowDown reaches the "show" row, Enter opens the group, and the listbox holds only option and group children (step 3).
    • Bulk Remove: it lists and removes an assignment to a deleted chat (step 4).
    • Whole chat: an imported whole chat shows one chip, and unticking it saves a scope with neither the group id nor its branch ids (step 5).
  • tests/long-term-memory-branch-recall.regression.ts:
    • When listChats rejects, recall returns the branch's own memories and logs a warning (step 6).
    • The search route returns the inherited memory for a branch (step 8).
  • Steps 9–11 as listed.
  • Also run scope-targets, routes, runtime and feedback-clarity-ui.

Environment

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

Logs, screenshots, or video

None. Found by the #1420, #1433 and #1438 reviews and confirmed by reading the code at 60d50d47d.

Additional context

Follow-up to #1420, #1433 and #1438. It doesn't share files with the retention follow-up #1443, so both can run in parallel.

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 17, 2026). Original GitHub issue: https://github.com/Pasta-Devs/Marinara-Agents/issues/1442 Originally assigned to: @Promansis on GitHub. ## Summary #1420 (1.4.45), #1433 (1.4.44) and #1438 (1.4.46) each shipped with small problems that their review listed and left unfixed. Two older problems in the same pickers are included, because the same files change here. Together they are: - **Place picker:** - Focus is lost after the unsaved-changes prompt. - "No memories" collapses when you switch tabs during a search. - The "No memories" toggle is a control inside a list that only allows options. - **Availability editors:** - Bulk Remove can't remove a place that no longer exists. - A chat imported with "All branches" shows one chip per branch, and unticking the chat leaves it available in every one of those branches. - **Branch recall:** - If the shared-history lookup fails, the reply gets no memories at all. - The search route leaves out shared-history memories. - A per-reply cost has no `ponytail:` comment. - **Tests and dead code:** - One browser test assertion is vacuous. - #1438's recall wiring has no committed test. - `deriveScopeBranches` is no longer used. ## Affected package `long-term-memory` 1.4.46 (`upstream/staging` 60d50d47d). - `C` = `packages/long-term-memory/src/engine/packages/client/src/features/long-term-memory` - `S` = `packages/long-term-memory/src/engine/packages/server/src/services/long-term-memory` ## Expected behavior - **Focus:** after the unsaved-changes prompt, focus returns to the place button. - **"No memories" group:** - It stays open while a search is active, whichever tab is chosen. - Arrow keys from the search box can reach and open it. - **Bulk Remove:** it can remove an assignment to a chat, character or persona that no longer exists, as the single editor already can. - **Whole chats:** - A chat chosen as a whole shows one chip, wherever it was chosen. - Unticking or removing the chat removes it from every branch. - **Recall:** - A branch whose shared-history lookup fails still recalls its own memories. - The search route returns what a reply in that chat would recall. ## Actual behavior See each step of the Minimal fix. Every location was checked at 60d50d47d. ## Steps to reproduce 1. **Focus.** Edit a memory in the Vault without saving. Pick another place from the place dropdown with the keyboard, then press Stay in the prompt. Focus goes to the page body. 2. **Search.** Open the place dropdown, type a search that matches a chat with no memories, then press the Chats tab. "No memories" closes while the search text stays. 3. **Whole chat.** In Sources, import with the destination "Harbor Watch · All branches". Open the memory's availability editor. It shows the whole-chat chip plus one chip per branch. Untick Harbor Watch and save: the memory is still recalled in every branch. ## Minimal fix One PR, patch bump. **Place picker (`C/SourceScopeCombobox.tsx`)** 1. **Focus after the unsaved-changes prompt.** - **Cause:** - `choose` (`:114-117`) calls `onChange` before `close()`. - `close()` moves focus to the place button only in the next animation frame (`:84-90`). - The Vault's `confirm()` (`C/vault/MemoryVault.tsx:1203`) therefore records the option button as the return target. The dropdown then unmounts it, and the refocus at `:1190` skips a disconnected element. - **Fix:** in `choose`, focus the place button synchronously, then `close()`, then `onChange`. 2. **"No memories" stays open while searching.** - `selectKind` (`:91-96`) always calls `resetNoMemories()`. - The search effect (`:69-73`) only reopens the group when the search text changes. - Reset only when the search is empty. 3. **No control inside the listbox.** - Replace the `<details>`/`<summary>` at `:316-330`: - **While collapsed:** the last row is a `role="option"` row, "Show N places with no memories", with a new locale key. - Arrow keys reach it like any other option. - Enter or a click opens the group. - `choose` treats it as a toggle and never calls `onChange`. - **While open:** the group renders like "With memories", as a `role="group"` with a plain label. - Opening it sets `noMemoriesPreference`, as clicking the summary does now. Clearing a search then returns to that choice, and closing the dropdown resets it. **Availability editors (`C/vault/`)** 4. **Bulk Remove lists places that no longer exist.** - In remove mode, `BulkAvailabilityWorkbench.tsx:55-64` lists only current chats plus branch assignments. - Add rows for chat, group, character and persona ids that the selected memories have but no target matches. Use the fallback labels already defined at `:101-104`, as `MemoryAvailabilityWorkbench.tsx:55-80` does for one memory. 5. **A whole chat includes its branches.** - **How the two sides save a whole chat:** - Sources "All branches" saves `{ groupId, groupIds: [G], chatIds: <every branch> }` (`C/sources/SourcesWorkspace.tsx:436-437`). - The editors save `groupIds` only (`MemoryAvailabilityWorkbench.tsx:139-144`). - `availabilityEntries` (`vault-shared.ts`) makes a chip for every chat id. - **The fix, in both editors:** - While chat G is selected, the branch ids that belong to G (`target.chatIds`) count as part of G: - they get no chips of their own; - unticking or removing G, or removing G in bulk Remove, also removes them. - A branch id whose chat isn't selected keeps its own chip, and saving any other change leaves it as it is (#1420's rule). - **What stays the same:** - The editors keep saving a newly chosen whole chat as `groupIds` only, which also covers branches made later. - Stored data, recall and the Vault filter don't change. **Branch recall (`S/`)** 6. **Fall back when the lookup fails.** - `generation-injection.ts:189` runs `branchInheritedNoteIds` inside the recall `try`. A `listChats` rejection or an unreadable note fails the whole recall (`:211-214`). - **Fix:** - Catch around that one call. - Rethrow if the request was aborted. - Otherwise log a `logger.warn` and continue with `undefined`, which recalls the branch's own memories. 7. **Name the per-reply cost.** - Every reply in a branched chat with summaries calls `listChats()` and `listNotes()` (`:77`, `:81`). - Add a `ponytail:` comment that names this limit and the upgrade path: an Engine group lookup, and reusing the cached notes snapshot. 8. **Search matches a reply.** - `routes/notes.ts:899-935` resolves a chat-only scope "like a turn" (`:927-929`) but doesn't pass `inheritedNoteIds`. - Export `branchInheritedNoteIds` and pass it with the request's mode when the route resolved the chat. Use the same fallback as step 6. **Tests and dead code** 9. Delete `deriveScopeBranches` (`C/scope-targets.ts:125`) and its cases in `tests/long-term-memory-scope-targets.regression.ts` (`:7`, `:110-150`). 10. `tests/long-term-memory-browser.regression.ts:1812`: - The current check, `noteQueries.some(...)` with no `scopeChatIds`, also passes on queries made before "All" was chosen. - Record `noteQueries.length` before the choice, and check only the queries made after it. 11. **#1438 wiring and wording** (`tests/long-term-memory-index-keys.regression.ts`): - In the #1363 `retrieveLongTermMemory` fixture (`:505-575`), add a check: with a `린` character memory, `린은 뭐 했지?` returns the `린이 웃었다` memory through the `bm25` lane. - Change the comment at `:758` from "folds with any particle" to "folds with one allowed particle". **CHANGELOG under `## Unreleased`** Cover the user-visible changes in steps 1–6 and 8. Also add one clarifying sentence for 1.4.44: in Game and Conversation chats, only rolling summaries count for branch recall. Day, week and game-session summaries don't, because each branch can write its own under the same name. **Not included** - In #1438, every one-syllable word of a multi-word character title counts as a name, for example `그` in `그 남자`. This is the approved design. Narrowing it would miss titles such as `린 (Rin)`. - #1420's changelog omits the removed shortcuts. That release note has already shipped, and this issue's entry describes the current behavior. ## Regression proof - **Browser** (`tests/long-term-memory-browser.regression.ts`): - **Focus:** focus is on the place button after Stay and after Discard (step 1). - **Tabs during a search:** a tab change keeps "No memories" open (step 2). - **Keyboard and roles:** ArrowDown reaches the "show" row, Enter opens the group, and the listbox holds only `option` and `group` children (step 3). - **Bulk Remove:** it lists and removes an assignment to a deleted chat (step 4). - **Whole chat:** an imported whole chat shows one chip, and unticking it saves a scope with neither the group id nor its branch ids (step 5). - **`tests/long-term-memory-branch-recall.regression.ts`:** - When `listChats` rejects, recall returns the branch's own memories and logs a warning (step 6). - The search route returns the inherited memory for a branch (step 8). - Steps 9–11 as listed. - Also run `scope-targets`, `routes`, `runtime` and `feedback-clarity-ui`. ## Environment - Marinara Engine version: 2.5.0 line (`staging` 2039583ca) - Package version: long-term-memory 1.4.46 (`upstream/staging` 60d50d47d) - Install type: source (code audit) - OS + version: not platform-specific - Browser or app shell: any ## Logs, screenshots, or video None. Found by the #1420, #1433 and #1438 reviews and confirmed by reading the code at 60d50d47d. ## Additional context Follow-up to #1420, #1433 and #1438. It doesn't share files with the retention follow-up #1443, so both can run in parallel. ## 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:10 +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#732
No description provided.