anomalyco / anomalyco/opencode

Web UI: session tab switch fails with InvalidRequestError after scrolling back through history

Open
#43,279 0 comments 0 reactions 1 assignee View on GitHub

@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 with loadMessages(sessionID, options?.messageLimit ?? meta.limit[sessionID] ?? initialMessagePageSize)
  • fetchMessages passes that straight to messageApi.list with 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
  1. Open a session with more than 400 messages in the web UI (opencode serve).
  2. Scroll back through the history far enough to load two extra pages.
  3. Switch to another session tab, then switch back.
  4. 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

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.