anomalyco / anomalyco/opencode
Web UI: session tab switch fails with InvalidRequestError after scrolling back through history
@Hona is already working on this.
Since Aug 18, 2026.
- Dominant language
- TypeScript
- Stars
- 209k
- Forks
- 27.5k
- PR merge metrics
- PR metrics pending
Description
Description
In the V2 web UI, scrolling back through a long session and then switching away and back to that session tab throws Unknown error, with:
{
"_tag": "InvalidRequestError",
"message": "Expected a value less than or equal to 200, got 400\n at [\"limit\"]",
"kind": "Query"
}
The client asks the message endpoint for more than it is allowed to. SessionMessagesQuery caps limit at 200 (packages/protocol/src/groups/message.ts), but the app tracks how many messages it currently has retained for a session and replays that count as the request limit:
setMeta("limit", sessionID, messages.length)stores the retained count (packages/app/src/context/server-session.ts)sync()re-requests withloadMessages(sessionID, options?.messageLimit ?? meta.limit[sessionID] ?? initialMessagePageSize)fetchMessagespasses that straight tomessageApi.listwith no clamp
History pages are 200 at a time, so after scrolling back the retained count goes past 200 and every later re-sync sends an out-of-range limit. Switching back to a session tab triggers exactly that re-sync (packages/app/src/pages/session/timeline/model.ts calls sync(id) / sync(id, { force: true })), which is why it looks like a multi-tab problem.
Still present on dev as of 9b0dd36cd.
Steps to reproduce
- Open a session with more than 400 messages in the web UI (
opencode serve). - Scroll back through the history far enough to load two extra pages.
- Switch to another session tab, then switch back.
- The timeline fails with
Unknown error/InvalidRequestError.
OpenCode version
1.18.18
Operating System
Ubuntu (WSL2, Linux 6.18.33.2-microsoft-standard-WSL2)
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Assessment
This issue has not been assessed yet.