Repository navigation
Description
Opening a long Session Chat after a cache miss waits on REST that downloads megabytes the first paint never shows.
On a cold open over Tailscale, unbounded GET /session/{id}/message took 7-9s. That JSON was 3.6-6.0 MB for 44-90 messages. Chat text plus reasoning was about 17-30k characters. The rest was tool output from read/bash, patch parts, and in one session a 394 KB file part. Client fullReload after the response is ~20-40ms.
Bind also fires GET /session/{id}/diff for the Review Changes pill (2.4 MB, 150 files). The pill only uses file count and +/- totals. The server has no counts-only query.
Web does not do this. First paint is connected + session info + a 20-message tail. Older history is loadMore (200). Catalogs and diffs are off that path.
What the servers already support
v1 GET /session/{id}/message
- Query:
limit(integer, 0 means all),before(opaque cursor).beforewithoutlimitis 400. - Omit
limit(what we do): full dump. - Paged body is still a JSON array of full
{info, parts}including tool dumps. - Next page:
X-Next-CursorandLink: rel="next". - Live check on the 60-message session: unbounded 3.78 MB;
limit=20410 KB;limit=40816 KB.
v2 GET /api/session/{id}/message
- Query:
limit(1-200, default 50),order(asc|desc, defaultdesc),cursor. - Cursor must not be sent with
order(400InvalidCursorError). - Envelope
{ data, cursor.previous, cursor.next }. - We send
order=ascand drain every page (maxV2MessageListPages = 500).
Neither protocol strips tool output. Pagination is the available win. Slim parts would need a new server field.
docs/features/message-store/ still lists paginated history (limit / before / x-next-cursor) as out of scope. That has to change for this ticket.
Remaining:
- Seed MessageSync with a newest-first tail (web uses 20). v1:
limit+beforefromX-Next-Cursor. v2:limit+order=desc+cursor.next. Do not drain all pages on bind. - If that page starts mid-turn (assistant without its user/shell), fetch a few older pages so the turn is complete. Web already does this.
- Load older pages on scroll, not on bind.
- Do not fetch last-turn patch text on bind. Load
GET /session/{id}/diffwhen Changes opens. - Same behavior on iOS and Android.
Docs: docs/features/message-store/, docs/features/session-chat/
Imported from Linear OPE-244. Linear status: Done. Priority: High. Created 2026-09-12. Completed 2026-09-13.
Related: OPE-25, OPE-11.
Activity