fix(session): preserve lastAccountId and lastThreadId on session reset#44773
fix(session): preserve lastAccountId and lastThreadId on session reset#44773obviyus merged 2 commits intoopenclaw:mainfrom
lastAccountId and lastThreadId on session reset#44773Conversation
Greptile SummaryThis PR fixes a bug in
Confidence Score: 4/5
Prompt To Fix All With AIThis is a comment left during a code review.
Path: src/gateway/session-reset-service.ts
Line: 341-342
Comment:
**No unit test covers the preserved fields after reset**
The fix is correct and symmetric with `lastChannel`/`lastTo`, but no test was added to verify that `lastAccountId` and `lastThreadId` survive a `performGatewaySessionReset` call. The existing test suite mocks out `performGatewaySessionReset` entirely (`agent.test.ts`) and the sessions integration test (`server.sessions.gateway-server-sessions-a.test.ts`) doesn't exercise the reset path with these fields set.
Consider adding a test that:
1. Seeds a session store entry with `lastAccountId` and `lastThreadId` populated.
2. Calls `performGatewaySessionReset`.
3. Asserts both fields are present and equal on the returned `entry`.
How can I resolve this? If you propose a fix, please make it concise.Last reviewed commit: 4166db7 |
| lastAccountId: currentEntry?.lastAccountId, | ||
| lastThreadId: currentEntry?.lastThreadId, |
There was a problem hiding this comment.
No unit test covers the preserved fields after reset
The fix is correct and symmetric with lastChannel/lastTo, but no test was added to verify that lastAccountId and lastThreadId survive a performGatewaySessionReset call. The existing test suite mocks out performGatewaySessionReset entirely (agent.test.ts) and the sessions integration test (server.sessions.gateway-server-sessions-a.test.ts) doesn't exercise the reset path with these fields set.
Consider adding a test that:
- Seeds a session store entry with
lastAccountIdandlastThreadIdpopulated. - Calls
performGatewaySessionReset. - Asserts both fields are present and equal on the returned
entry.
Prompt To Fix With AI
This is a comment left during a code review.
Path: src/gateway/session-reset-service.ts
Line: 341-342
Comment:
**No unit test covers the preserved fields after reset**
The fix is correct and symmetric with `lastChannel`/`lastTo`, but no test was added to verify that `lastAccountId` and `lastThreadId` survive a `performGatewaySessionReset` call. The existing test suite mocks out `performGatewaySessionReset` entirely (`agent.test.ts`) and the sessions integration test (`server.sessions.gateway-server-sessions-a.test.ts`) doesn't exercise the reset path with these fields set.
Consider adding a test that:
1. Seeds a session store entry with `lastAccountId` and `lastThreadId` populated.
2. Calls `performGatewaySessionReset`.
3. Asserts both fields are present and equal on the returned `entry`.
How can I resolve this? If you propose a fix, please make it concise.4166db7 to
22947a4
Compare
Summary
performGatewaySessionResetomittedlastAccountIdandlastThreadIdwhen constructingnextEntry, causing both fields to be lost after a session reset.lastAccountIdandlastThreadIdto thenextEntryconstruction insession-reset-service.ts, consistent with howlastChannelandlastToare already handled.Change Type
Scope
Linked Issue/PR
User-visible / Behavior Changes
After a session reset,
lastAccountIdandlastThreadIdare now correctly preserved, restoring proper message routing behavior.Security Impact
Repro + Verification
Environment
Steps
lastAccountId/lastThreadIdset (e.g. via a Discord thread message)/resetor equivalent)Expected
Actual (before fix)
lastAccountId/lastThreadIdwere cleared on reset, causing routing failure or lost repliesEvidence
Human Verification
nextEntrycurrentEntrybeingundefinedis handled safely via optional chainingReview Conversations
Compatibility / Migration
Failure Recovery
git revertthis commitsrc/gateway/session-reset-service.tsRisks and Mitigations
None