Skip to content

perf(platform): read a chat thread's tail and apply the settled row #5154

Closed

Description

@tale-code-bot

Split from #4708 (item 2 of 7), as triaged on TALE-117.

What the read does now

At feature-train 9173785 (paths under services/platform/):

  • GET /api/app/chat/threads/:threadId/messages (backend/domains/chat/routes.ts:1032-1068) returns the whole thread through listMessageViews (backend/domains/chat/message-views.ts:47-62). That is every message with its parts, ORDER BY "order", step_order, with no LIMIT.

  • The server's stream settle already sends only the settled row (backend/domains/chat/generation-watch.ts:331-354, readMessageViewsByIds / readLastMessageView). The client ignores that payload:

    • on settled it invalidates the whole message list and the thread list (app/features/chat/data/thread-stream.ts:173-179);
    • it does the same when a turn opens (:167) and on idle after streaming (:119-120).

    So every turn re-reads the whole thread.

  • A tail reader exists: listThreadMessagesTail (backend/domains/threads/store.ts:193-235), with a default limit of 200, a before cursor and hasMore. Only task comments use it. As it stands it does not fit chat:

    • it filters by thread_id alone, with no org_id;
    • it leaves out tool roles by default;
    • its columns lack model, provider_slug, usage, blocked_reason and error.

What to do

  • Read a chat thread's tail (limit 200, with a cursor for older messages) instead of the whole thread. Reuse the tail reader's keyset rather than writing a second copy.
  • On settled, apply the row the stream already sends to the cached messages instead of re-reading the thread.

Done means:

  • opening a thread and settling a turn each read at most one page;
  • older messages load on demand;
  • tests cover the page, the cursor and the settle.

Activity

  1. added
    agent-ready
    on Oct 30, 2026
  2. added a commit that references this issue on Oct 31, 2026
    0069e13
  3. added
    perf
    on Oct 31, 2026
  4. added 2 commits that reference this issue on Oct 31, 2026
    d964ffb
    9b9e68f
  5. tale-code-bot commented on Oct 31, 2026

    @tale-code-bot
    CollaboratorAuthor

    Landed on release/0.6 with feature train #5221 (merged by rebase on 2026-10-31 at 20:26:51 UTC) as commit 9b9e68f (perf(platform): read a chat thread's tail and apply the settled row). It ships with Tale 0.6.0. GitHub closes issues only for commits on main, so the feature-train role closes this one. Task: TALE-250.

  6. added 18 commits that reference this issue on Nov 1, 2026
    45f55d5
    335db6c
    1b2b1a1
    dc6a218
    ba9fb1a
    39d7d81
    7f10142
    277540b
    4545e2c
    915f5f3
    05f3d24
    a595f0e
    e10bada
    2d0d018
    200a2bd
    ac7a94a
    3f35180
    dd0f745
  7. added a commit that references this issue on Nov 15, 2026
    be7c1d4
  8. added a commit that references this issue on Nov 23, 2026
    73168b1
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    agent-readyperf

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions