Repair cli-shell native Chat scroll physics by replacing app-local dialogueScrollOffset reverse-offset math with native OpenTUI scroll container semantics and MessageRoom-backed incremental history paging.
The change is OpenSpec refine-cli-shell-chat-scrollbox, schema spec-driven.
The intended law from the change artifacts:
- MessageRoom owns durable transcript truth.
- cli-shell owns only an ephemeral loaded message window.
- OpenTUI owns native viewport mechanics.
- Older history loads through
pageGlobalRoomMessages({ chatId, before: nextBefore, limit }). - Prepending older messages preserves a stable visible anchor.
- Bottom-pinned Chat follows new messages; scrolled-up Chat preserves reader position and shows return-to-bottom affordance.
Confirmed from openspec status --change refine-cli-shell-chat-scrollbox --json and openspec instructions apply --change refine-cli-shell-chat-scrollbox --json:
- Artifacts are complete:
proposal,design,specs,tasks. - Tasks are
0/27; none are checked off. - State is
ready; apply instructions say to read context files and work pending tasks. openspec validate refine-cli-shell-chat-scrollbox --strictpasses.
Current main has uncommitted WIP for this change. Dirty/untracked files observed:
openspec/changes/refine-cli-shell-chat-scrollbox/.openspec.yamlopenspec/changes/refine-cli-shell-chat-scrollbox/design.mdopenspec/changes/refine-cli-shell-chat-scrollbox/proposal.mdopenspec/changes/refine-cli-shell-chat-scrollbox/specs/cli-shell-app/spec.mdopenspec/changes/refine-cli-shell-chat-scrollbox/specs/message-chat-control-plane/spec.mdopenspec/changes/refine-cli-shell-chat-scrollbox/tasks.mdpackages/cli-shell/src/index.tspackages/cli-shell/src/tui/controller.tspackages/cli-shell/src/tui/core-app.tspackages/cli-shell/src/tui/dialogue-backend.tspackages/cli-shell/src/tui/dialogue-surface.tspackages/cli-shell/src/tui/model.tspackages/cli-shell/src/tui/types.tspackages/cli-shell/src/tui/view-state.tspackages/cli-shell/src/web/web-app-host.tspackages/cli-shell/test/cli-shell-termless-walkthrough.test.tspackages/cli-shell/test/cli-shell-tui.test.tspackages/cli-shell/src/tui/dialogue-scrollbox.ts
These WIP changes were present on main after Studio landing and are not part of the Studio migration commits.
The WIP already introduces several promising pieces:
packages/cli-shell/src/tui/dialogue-scrollbox.tswith scroll metrics, message window, dedupe/sort, anchor capture/restore, older-page loading, and aCliShellDialogueScrollBoxControllerwrapper around OpenTUIScrollBoxRenderable.- Public exports from
packages/cli-shell/src/index.ts. - Model shape moves from
dialogueScrollOffsettowarddialogueScrollTop,dialogueScroll, anddialogueWindow. - Store harness now includes
pageGlobalRoomMessages. - Tests were added around ScrollBox ownership, scroll direction, older-message loading, anchor preservation, and bottom pinning.
- Web app host and backend projection were partially updated from
offsetFromBottomtoscrollTop/maxScrollTop.
This is not finished and should not be presented as complete:
tasks.mdstill has 0/27 checked.- The WIP has not been committed.
- I did not run focused cli-shell tests or typecheck for this WIP during handoff.
git diff --name-onlyshowsdialogue-backend.ts,web-app-host.ts, andcli-shell-termless-walkthrough.test.tsin addition to the first visible diff set; include them in review.- The WIP is on the main checkout, not isolated in a worktree. Create a worktree or snapshot branch before further risky edits if you want stricter isolation.
Recommended handoff path for the main-branch developer:
- Decide whether to keep this WIP on
mainor move it to a dedicated worktree/branch before implementation continues. - Read the change artifacts under
openspec/changes/refine-cli-shell-chat-scrollbox/. - Run the current focused tests to establish exact failure/pass state:
bun test packages/cli-shell/test/cli-shell-tui.test.ts --timeout 120000bun test packages/cli-shell/test/cli-shell-termless-walkthrough.test.ts --timeout 120000bun run --filter '@agenter/cli-shell' typecheck
- Complete tasks in order, checking them off only after behavior and verification are real.
- Required final gates from tasks:
- focused cli-shell TUI tests
- focused cli-shell web-host tests only if shared room pagination helpers changed
bun run --filter '@agenter/cli-shell' typecheckopenspec validate refine-cli-shell-chat-scrollbox --strictopenspec validate --specs --strictgit diff --check