fix(hooks): show a file's memories before an edit in every session - #549
Open
kevintseng wants to merge 4 commits into
Open
kevintseng wants to merge 4 commits into
kevintseng wants to merge 4 commits into
Conversation
Once any session on the machine had been shown the memories about a file, every other session editing that file got nothing, and the hook record said "nothing to recall". Each session now keeps its own list of files already shown, a repeat within one session is recorded as already shown, and a new start of a session clears only its own list. Lists idle for 30 days are removed. Fixes #521
The same-file check-then-write in one scenario was flagged by code scanning.
Two failures of the per-session pre-edit recall lists were silent: - when the list directory itself could not be read, nothing was pruned and nothing was said; it now prints the same stderr line a failed per-file removal already prints; - when SessionStart could not remove this session's list, the session kept its old list, so pre-edit recall stayed suppressed, while the start looked clean; it now prints the reason and records an error outcome. Refs #521
The two #521 failure tests passed their preload to `--import` as a plain absolute path. Node on Windows rejects that form (ERR_UNSUPPORTED_ESM_URL_SCHEME) before the injected fault is reached; a file URL is accepted on every platform. Refs #521 [Verified-By: node scripts/run-tests-isolated.mjs tests/hooks/pre-edit-recall.test.ts tests/hooks/session-start.test.ts --maxWorkers=1 → exit 0, Test Files 2 passed, Tests 220 passed (macOS); Windows unverified until CI]
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Refs #521.
What was wrong
Before an edit, MeMesh shows the memories it has about the file being edited. It shows them only once per file per session. The list of "already shown" files was shared by every session on the machine, though. So once any session, or another agent, had been shown the memories for a file, every other session editing that file got nothing. The hook record then said "nothing to recall", which was not true.
What changed
~/.memesh/pre-edit-recall/<session id>.json./clear, resume, compact) clears only that session's list. A subagent's start leaves it alone.Tests
tests/hooks/pre-edit-recall.test.tsandtests/hooks/session-start.test.tsfail without the fix and pass with it.npm run verifyis green.