Skip to content

fix(lr-e0de): session history duplicate write and stop_task session targeting#218

Merged
akuehner merged 2 commits into
mainfrom
fix/lr-e0de-session-history
Jun 11, 2026
Merged

fix(lr-e0de): session history duplicate write and stop_task session targeting#218
akuehner merged 2 commits into
mainfrom
fix/lr-e0de-session-history

Conversation

@akuehner

Copy link
Copy Markdown
Member

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.

akuehner and others added 2 commits June 10, 2026 21:30
… 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>
@akuehner akuehner merged commit 2626948 into main Jun 11, 2026
1 check passed
@akuehner akuehner deleted the fix/lr-e0de-session-history branch June 11, 2026 01:42
@clagentic-release-bot

Copy link
Copy Markdown

This issue has been resolved in version 1.5.0-beta.1 (beta).

To update, run:

npx @clagentic/console@1.5.0-beta.1

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant