fix(lr-e0de): session history duplicate write and stop_task session targeting#218
Merged
Conversation
… targeting defects
4a. saveSessionFile now calls flushSessionBuffer before the atomic rewrite
so pending async-append buffer lines are not double-appended once the
deferred timer fires against the newly-renamed file.
4b. stopTask accepts an explicit session parameter; the stop_task WS handler
in project-sessions.js now passes the ws-resolved session (getSessionForWs)
so multi-session installs abort the requester's session rather than the
globally-active one. Single-session installs are unaffected (fallback path
returns the same session as getActiveSession() when only one session exists).
Regression tests added: test/session-lifecycle-lr-e0de.test.js
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
…ager and attachSessions Previous tests inlined reimplementations (blocked by Peaches). New tests: - 4a: instantiate real createSessionManager via CLAGENTIC_HOME temp dir; use sm.sendAndRecord to populate history+buffer; assert no duplicates after saveSessionFile+timer; regression test demonstrates the pre-fix duplicate by simulating the buggy rewrite-without-flush path. - 4b: call real attachSessions(ctx); spy on sdk.stopTask; verify the stop_task handler passes getSessionForWs(ws) not getActiveSession(). Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
|
This issue has been resolved in version 1.5.0-beta.1 (beta). To update, run: |
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.
Fixes two HIGH session-lifecycle defects (lr-e0de).
4a: saveSessionFile now calls flushSessionBuffer before the atomic rewrite. Previously, lines queued in the per-session async-append buffer were re-appended to the newly-renamed file once the 50ms timer fired, producing duplicated or corrupted JSONL. Callers affected: setSessionVisibility, setSessionBookmarked, reorderBookmarkedSessions, setSessionOwner, autoGenerateTitle.
4b: stopTask now accepts an explicit session parameter. The stop_task WS handler passes getSessionForWs(ws) so multi-session installs abort the requester session rather than the globally-active one. Single-session installs are unaffected via the getActiveSession fallback.
6 regression tests added in test/session-lifecycle-lr-e0de.test.js. npm test: 230/230 pass.