fix: restore chat message loading limits and preserve earlier messages#898
Merged
simple-agent-manager[bot] merged 5 commits intomainfrom May 5, 2026
Merged
Conversation
Co-Authored-By: Claude Opus 4.6 <[email protected]>
Two regressions from PR #874 (May 1): 1. Message limit dropped from 1000 to 200 by reusing SAM_HISTORY_LOAD_LIMIT (designed for SAM conversation persistence) for chat session REST endpoints. Added DEFAULT_CHAT_SESSION_MESSAGE_LIMIT (3000) with CHAT_SESSION_MESSAGE_LIMIT env var override. 2. Polling fallback (every 3s) and WebSocket catch-up used 'replace' merge strategy that discarded all earlier-loaded messages. After clicking "Load earlier messages", the next poll cycle would reset back to 200. Fixed mergeReplace() to preserve messages older than the incoming window, and removed hasMore reset from polling/catch-up (only initial load and explicit loadMore should update pagination state). Co-Authored-By: Claude Opus 4.6 <[email protected]>
- Fix extra closing brace in merge-messages.test.ts that caused parse error - Update project-message-view catch-up test: empty incoming now correctly preserves existing messages (intentional behavior change from the fix) Co-Authored-By: Claude Opus 4.6 <[email protected]>
- Move DEFAULT_CHAT_SESSION_MESSAGE_LIMIT from sam.ts to defaults.ts (it's a chat REST limit, not a SAM agent constant) - Remove hasMore param from onCatchUp interface in useChatWebSocket.ts (catch-up should not reset pagination state) - Update WorkspaceChatView.tsx onCatchUp to match new 2-param contract - Update test mocks to match new interface Co-Authored-By: Claude Opus 4.6 <[email protected]>
The mergeReplace boundary condition now preserves messages from prev at the same timestamp as oldestIncoming when their ID is not in the incoming set. This prevents silent drops when the server returns only some messages at the boundary timestamp (e.g., batched tool calls). Co-Authored-By: Claude Opus 4.6 <[email protected]>
|
10 tasks
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.


Summary
Fixes two compounding regressions from PR #874:
Message limit restored:
getSessionMessageLimit()was usingDEFAULT_SAM_HISTORY_LOAD_LIMIT(200) — a constant designed for SAM's own conversation persistence. Restored to a newDEFAULT_CHAT_SESSION_MESSAGE_LIMIT(3000), configurable viaCHAT_SESSION_MESSAGE_LIMITenv var.Earlier messages preserved through polls:
mergeReplace()was discarding all previously-loaded earlier messages on every 3-second poll cycle and WebSocket catch-up. Now preserves messages older than the incoming window, so "Load earlier messages" results persist.Same-timestamp boundary fix: Messages at the boundary timestamp that aren't in the incoming set (loaded via load-more) are preserved instead of silently dropped.
onCatchUpinterface cleaned: Removed unusedhasMoreparameter from the WebSocket catch-up callback contract.Changes
packages/shared/src/constants/defaults.ts— newDEFAULT_CHAT_SESSION_MESSAGE_LIMIT(3000)apps/api/src/routes/chat.ts— use new constant instead of SAM history limitapps/web/src/lib/merge-messages.ts—mergeReplace()preserves earlier-loaded messagesapps/web/src/components/project-message-view/useSessionLifecycle.ts— polling no longer resetshasMoreapps/web/src/hooks/useChatWebSocket.ts—onCatchUpsimplified to 2 paramsTest plan
mergeReplace()preserves messages older than incoming windowgetSessionMessageLimit()uses new 3000 defaultStaging Verification
deploy-staging.yml(run succeeded 2026-05-05)Co-Authored-By: Claude Opus 4.6 [email protected]