Skip to content

Paginate Session web chat history - #1621

Merged
gjkim42 merged 1 commit into
mainfrom
agent/paginate-session-server-history
Aug 8, 2026
Merged

gjkim42 merged 1 commit into
mainfrom
agent/paginate-session-server-history

Conversation

@gjkim42

@gjkim42 gjkim42 commented Aug 8, 2026 •

Copy link
Copy Markdown
Collaborator

What type of PR is this?

/kind bug

What this PR does / why we need it:

The Session web client previously requested history bounds without a bounded history page. Connecting to a long-running Session could therefore replay the entire event history and construct the full conversation DOM before the client became usable.

This PR makes the web client request the latest 20 history items within a 128 KiB budget, caches each Session's history cursor, and adds a Load earlier messages control that prepends older pages while preserving the reader's scroll position. The runtime history snapshot carries the latest bounded file diff independently of transcript pages, so the Changes tab remains complete without loading older messages. The client also applies paged active-turn state and the event high-water mark so queued inputs, interruptions, reconnects, and Session switching remain consistent while older pages load.

The web-facing Session server remains a transparent protocol bridge; pagination and state restoration use the shared runtime history protocol.

Which issue(s) this PR is related to:

N/A

Special notes for your reviewer:

Verification:

  • make test
  • make verify
  • git diff --check

Does this PR introduce a user-facing change?

The Session web chat now opens long conversations with a bounded recent history page and loads earlier messages on demand.

@gjkim42
gjkim42 marked this pull request as ready for review August 8, 2026 15:30
@gjkim42

gjkim42 commented Aug 8, 2026

Copy link
Copy Markdown
Collaborator Author

/kelos review

@gjkim42 gjkim42 self-assigned this Aug 8, 2026
@kelos-bot

kelos-bot Bot commented Aug 8, 2026 •

Copy link
Copy Markdown
Contributor

🤖 Kelos Task Status

Task kelos-reviewer-issue-comment-36ebf123f0cc has succeeded. ✅

@kelos-bot

kelos-bot Bot commented Aug 8, 2026

Copy link
Copy Markdown
Contributor

🤖 Kelos Reviewer Agent @gjkim42

Review Summary

Verdict: APPROVE (sticky comment only)
Overall correctness: patch is correct
Scope: Bounds the Session web client's initial history replay and adds cursor-based loading of earlier pages.

Findings Overview

Priority Count File:Line Summary
P0 0 — none
P1 0 — none
P2 3 internal/sessionserver/web/app.js:1612 The bounded transcript can leave the Changes tab incomplete
P2 3 internal/sessionserver/web/app.js:2403 Older-page replay can emit a false live interruption toast
P2 3 internal/sessionserver/testdata/session_history_test.js:550 The viewport-preservation guarantee is not asserted
P3 0 — none

Findings

Correctness

  • [P2] internal/sessionserver/web/app.js:1612 — Bounding the initial subscription also omits older file.diff events, but state.fileChanges and the Changes tab are rebuilt only by replaying those events. If the workspace was modified before the latest 20 display items and no later diff event was emitted, opening the Session incorrectly shows no changes or an incomplete list until the user happens to load enough earlier transcript pages. Deliver the latest workspace-diff state independently of the bounded transcript page, and cover a diff older than the initial page.
  • [P2] internal/sessionserver/web/app.js:2403 — replayOlderHistoryPage sends retained events through the live handleEvent path, so an older interrupted turn.completed reaches renderTurnEnd and displays Active work interrupted even when the current live turn is still active. Suppress live-only notifications during history-page replay or use a side-effect-free replay path, and assert that loading an interrupted historical turn does not emit the toast.

Tests

  • [P2] internal/sessionserver/testdata/session_history_test.js:550 — The earlier-page test verifies prepend order and live state but never sets or asserts scrollTop, so removing the preservation calculation in replayOlderHistoryPage would still pass despite the documented promise not to move the reader. Start from a nonzero scroll position and assert that it changes by the page's scrollHeight delta after the prepend.

Suggestions

  • [P3] Add a reconnect case proving that an incremental history.start with no new cursor preserves the cached earlier-history cursor while advancing the event high-water mark.

Key takeaways

  • No P0 or P1 issues were found; the bounded subscription, cursor caching, and reconnect high-water handling otherwise match the runtime protocol.
  • The Changes tab needs state independent of transcript pagination, and older-page replay should not produce live-only notifications.
  • The documented scroll-position behavior needs a regression assertion.

@cubic-dev-ai cubic-dev-ai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No issues found across 6 files

Re-trigger cubic

@gjkim42
gjkim42 force-pushed the agent/paginate-session-server-history branch from e542069 to f670217 Compare August 8, 2026 15:54
@gjkim42
gjkim42 added this pull request to the merge queue Aug 8, 2026
Merged via the queue into main with commit 8a5fd17 Aug 8, 2026
23 checks passed
@gjkim42
gjkim42 deleted the agent/paginate-session-server-history branch August 8, 2026 16:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant