feat(web): add newest-first chat order - #327
Merged
Merged
Conversation
ThinkRail-Todo: 01a042c1-dc8d-7035-a256-21dec8a36c07/t_daf0f2326236
ThinkRail-Todo: 01a042c1-dc8d-7035-a256-21dec8a36c07/t_f5e3d7c06afb
ThinkRail-Todo: 01a042c1-dc8d-7035-a256-21dec8a36c07/t_f8352e3e142e
ThinkRail-Todo: 01a042c1-dc8d-7035-a256-21dec8a36c07/t_4ac0030afe08
ThinkRail-Todo: 01a042c1-dc8d-7035-a256-21dec8a36c07/t_15673164aba4
danyaberezun
requested review from
Olga Lavrichenko (OLavrik),
Rustam Sadykov (SBOne-Kenobi) and
Rinat S (rsolmano)
as code owners
August 27, 2026 14:30
# Conflicts: # apps/web/src/chat/SPEC.md # apps/web/src/chat/rows.ts # apps/web/src/store/SPEC.md # apps/web/src/store/appStore.ts # e2e/SPEC.md # packages/contracts/SPEC.md # packages/contracts/src/domain.ts # packages/server/src/persistence/SPEC.md # packages/server/src/settings/SPEC.md # packages/server/src/settings/settings.test.ts
ThinkRail-Todo: 01a05321-f558-705c-810e-7fd1e94bd5f1/t_4d7d16ec4ed6
ThinkRail-Todo: 01a05321-f558-705c-810e-7fd1e94bd5f1/t_4cdbc452875e
ThinkRail-Todo: 01a05321-f558-705c-810e-7fd1e94bd5f1/t_9609676d4bd2
ThinkRail-Todo: 01a05321-f558-705c-810e-7fd1e94bd5f1/t_d0d06ff6c361
Rinat S (rsolmano)
approved these changes
Aug 30, 2026
Iaroslav (Rick) Postovalov (CommanderTvis)
added a commit
to CommanderTvis/thinkrail
that referenced
this pull request
Aug 31, 2026
The engine stops being pi-in-process and becomes any ACP agent the host launches as a child and speaks JSON-RPC to over stdio. A fatal agent or provider fault now kills one supervised child, not the host. packages/acp — the ACP client, and the only client-side package allowed to name an ACP type. connection/ spawns and negotiates (tolerating an agent that writes a banner before its first message), client/ implements what we offer agents (fs, terminals, permissions, elicitation, MCP over the ACP channel), translate/ is the single seam where protocol shapes become ThinkRail shapes, registry/ resolves the published agent registry, and testing/ validates a committed frame corpus against the SDK's own schema so an SDK bump fails here rather than in production. packages/contracts — chatProtocol.ts replaces piProtocol.ts: ThinkRail's own transcript model, a delta event union with three write modes, and a ChatCapabilities record carrying one field per UI-visible affordance, so panels read a negotiated record instead of probing the agent. The package now imports nothing at all. packages/pi-agent — the bundled first-party agent wrapping pi, launched as `thinkrail acp-pi`. It is the only package permitted to import pi, and it carries the four signals ACP has no words for (retry, compaction, queue, steering) in a namespaced _meta. packages/server — the host: an ACP session manager over its own append-only transcript store, so history, search, jump-to-message and reopen work with every agent rather than only those implementing ACP's optional session/load. Credentials belong to the agent now; auth is the policy layer over the six ACP credential operations plus the Central lifecycle the host must own. apps/web — renders the ThinkRail transcript model, never an ACP shape, and gates every control on the negotiated capability record. scripts/check-architecture.ts makes the module boundaries a gate rather than a convention: the ACP SDK stops at five sub-modules of packages/acp plus packages/pi-agent, and pi stops at packages/pi-agent. Rebased onto main. Carried through unchanged: the bottom workbench panel, terminal reservations, Pino host logging, browser history navigation, the subprocess budget, the Remix icon pack, the numeric spacing scale, the gh-CLI Open PR module and the Cloudflare website. Re-landed on the ACP wire, where the shapes differ: - Mid-stream queue editing. The host owns the steering queue, so session.clearQueue and session.removeQueued need none of the drain-and-re-queue emulation pi's all-or-nothing clearQueue forced. queue_changed carries the queued texts beside the depths, and session.abort restores them; SessionQueueContent holds PromptContent so an image-bearing queue restores losslessly. - The native /compact command moves to the agent side. ACP already carries a command list, so packages/pi-agent advertises compact and intercepts it in session/prompt — no session.compact wire method, and any agent that advertises its own compact command gets the same affordance for free. - Plan review (reviewer + reflector sessions, the verdict gate, the auto-fix cycle) runs on AgentSessionManager: sessions are created through it and configured by config-option value, sends are synchronous so the rollback keys off a throw rather than an acceptance window, settlement is observed as turn_settled, and notices land as durable notice markers. The reviewer policy is agent-neutral on the wire — reviewModel/reviewEffort are opaque config-option values, not a pi Model. - Extensions get a real theme (JetBrains#316): plainTextTheme moves into packages/pi-agent beside the bridge it serves, replacing an empty object cast, and an extension failure is named to the client before the session registers. Rebased again onto the Electrobun desktop packaging (JetBrains#317). The desktop app drives the same host, so `createServer` now answers `{ port, stop, shutdown }` with the ACP teardown behind `shutdown()`, `bootHost` runs under upstream's host-ownership lease, and `apps/cli` takes the shared build-support and artifact-probe modules. `artifactProbes.ts` is ported to the ACP wire — the model catalog is read from a session's config options, Central status from `agent.providers`, the trash probe seeds a host transcript, and the retired `provider.loginStart` OAuth leg becomes an `agent.authMethods` probe that the CLI smoke runs beside its own `acp-pi` initialize legs. Upstream's `check:boundaries` table learns the ACP layout (`packages/acp`, `packages/pi-agent`, and the server/cli edges into them); it runs alongside `check:arch`, which keeps policing the pi and ACP-SDK import invariants. Rebased again onto the subagent layer (JetBrains#302/JetBrains#303/JetBrains#304), frontend-local workbench layouts (JetBrains#338), newest-first chat order (JetBrains#327) and Try-again recovery (JetBrains#345). - pi-delegation and pi-subagents are pi packages, so the delegation host moves from packages/server into packages/pi-agent and scopes child sessions by an encoding of the worktree cwd — the agent has no workspace ids. The Agent card registers through the existing tool-renderer seam unchanged; the pi-only subagent-completion custom message drops, because under ACP the child's result already arrives on the Agent tool call. - subagent.getTranscript becomes the first ThinkRail _ext round-trip: the host asks the agent over dev.thinkrail.v1/subagent/transcript and the agent answers with ChatMessages, so the child transcript reaches the UI without the host owning sessions it never created. - Layouts leave the wire with upstream: layout.get/layout.replace, the layout module and the layout.changed channel are gone, and the workbench frame is the web's own state. - The desktop's generated entry registers only the trash helpers now; the bundled pi runtime belongs to the agent process, which registers its own. - Try-again attaches to an error notice, since notices replace the pi-era error turn. Deliberately not carried: the reviewer model/effort pickers in Settings (ACP has no session-less config read to source the options from — the auto-fix toggle stays), and useTranscriptSync's revision fence (this transcript model is one fold over one event log, so a reloaded transcript is the live object graph by construction). Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01BFWLfHUiKpPbiAHxiD75BJ
Iaroslav (Rick) Postovalov (CommanderTvis)
added a commit
to CommanderTvis/thinkrail
that referenced
this pull request
Aug 31, 2026
The engine stops being pi-in-process and becomes any ACP agent the host launches as a child and speaks JSON-RPC to over stdio. A fatal agent or provider fault now kills one supervised child, not the host. packages/acp — the ACP client, and the only client-side package allowed to name an ACP type. connection/ spawns and negotiates (tolerating an agent that writes a banner before its first message), client/ implements what we offer agents (fs, terminals, permissions, elicitation, MCP over the ACP channel), translate/ is the single seam where protocol shapes become ThinkRail shapes, registry/ resolves the published agent registry, and testing/ validates a committed frame corpus against the SDK's own schema so an SDK bump fails here rather than in production. packages/contracts — chatProtocol.ts replaces piProtocol.ts: ThinkRail's own transcript model, a delta event union with three write modes, and a ChatCapabilities record carrying one field per UI-visible affordance, so panels read a negotiated record instead of probing the agent. The package now imports nothing at all. packages/pi-agent — the bundled first-party agent wrapping pi, launched as `thinkrail acp-pi`. It is the only package permitted to import pi, and it carries the four signals ACP has no words for (retry, compaction, queue, steering) in a namespaced _meta. packages/server — the host: an ACP session manager over its own append-only transcript store, so history, search, jump-to-message and reopen work with every agent rather than only those implementing ACP's optional session/load. Credentials belong to the agent now; auth is the policy layer over the six ACP credential operations plus the Central lifecycle the host must own. apps/web — renders the ThinkRail transcript model, never an ACP shape, and gates every control on the negotiated capability record. scripts/check-architecture.ts makes the module boundaries a gate rather than a convention: the ACP SDK stops at five sub-modules of packages/acp plus packages/pi-agent, and pi stops at packages/pi-agent. Rebased onto main. Carried through unchanged: the bottom workbench panel, terminal reservations, Pino host logging, browser history navigation, the subprocess budget, the Remix icon pack, the numeric spacing scale, the gh-CLI Open PR module and the Cloudflare website. Re-landed on the ACP wire, where the shapes differ: - Mid-stream queue editing. The host owns the steering queue, so session.clearQueue and session.removeQueued need none of the drain-and-re-queue emulation pi's all-or-nothing clearQueue forced. queue_changed carries the queued texts beside the depths, and session.abort restores them; SessionQueueContent holds PromptContent so an image-bearing queue restores losslessly. - The native /compact command moves to the agent side. ACP already carries a command list, so packages/pi-agent advertises compact and intercepts it in session/prompt — no session.compact wire method, and any agent that advertises its own compact command gets the same affordance for free. - Plan review (reviewer + reflector sessions, the verdict gate, the auto-fix cycle) runs on AgentSessionManager: sessions are created through it and configured by config-option value, sends are synchronous so the rollback keys off a throw rather than an acceptance window, settlement is observed as turn_settled, and notices land as durable notice markers. The reviewer policy is agent-neutral on the wire — reviewModel/reviewEffort are opaque config-option values, not a pi Model. - Extensions get a real theme (JetBrains#316): plainTextTheme moves into packages/pi-agent beside the bridge it serves, replacing an empty object cast, and an extension failure is named to the client before the session registers. Rebased again onto the Electrobun desktop packaging (JetBrains#317). The desktop app drives the same host, so `createServer` now answers `{ port, stop, shutdown }` with the ACP teardown behind `shutdown()`, `bootHost` runs under upstream's host-ownership lease, and `apps/cli` takes the shared build-support and artifact-probe modules. `artifactProbes.ts` is ported to the ACP wire — the model catalog is read from a session's config options, Central status from `agent.providers`, the trash probe seeds a host transcript, and the retired `provider.loginStart` OAuth leg becomes an `agent.authMethods` probe that the CLI smoke runs beside its own `acp-pi` initialize legs. Upstream's `check:boundaries` table learns the ACP layout (`packages/acp`, `packages/pi-agent`, and the server/cli edges into them); it runs alongside `check:arch`, which keeps policing the pi and ACP-SDK import invariants. Rebased again onto the subagent layer (JetBrains#302/JetBrains#303/JetBrains#304), frontend-local workbench layouts (JetBrains#338), newest-first chat order (JetBrains#327) and Try-again recovery (JetBrains#345). - pi-delegation and pi-subagents are pi packages, so the delegation host moves from packages/server into packages/pi-agent and scopes child sessions by an encoding of the worktree cwd — the agent has no workspace ids. The Agent card registers through the existing tool-renderer seam unchanged; the pi-only subagent-completion custom message drops, because under ACP the child's result already arrives on the Agent tool call. - subagent.getTranscript becomes the first ThinkRail _ext round-trip: the host asks the agent over dev.thinkrail.v1/subagent/transcript and the agent answers with ChatMessages, so the child transcript reaches the UI without the host owning sessions it never created. - Layouts leave the wire with upstream: layout.get/layout.replace, the layout module and the layout.changed channel are gone, and the workbench frame is the web's own state. - The desktop's generated entry registers only the trash helpers now; the bundled pi runtime belongs to the agent process, which registers its own. - Try-again attaches to an error notice, since notices replace the pi-era error turn. Rebased again onto the off-the-event-loop git reads (JetBrains#265). The review and todo read paths are async now, so the host's review send, todo fix request and review snapshot await them; the plan-fix flow keeps upstream's per-item latch (claim on entry, release in a finally) around our synchronous ACP send, and firstOpenWorkspace follows listWorkspaces into a promise. Deliberately not carried: the reviewer model/effort pickers in Settings (ACP has no session-less config read to source the options from — the auto-fix toggle stays), and useTranscriptSync's revision fence (this transcript model is one fold over one event log, so a reloaded transcript is the live object graph by construction). Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01BFWLfHUiKpPbiAHxiD75BJ
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Adds an opt-in newest-first presentation for agent chats while keeping the existing oldest-first order as the compatibility default.
Newest-first keeps each request/answer exchange contiguous, reverses the temporal rows inside it, and leaves the message box at the bottom. It extends the smooth reading-band controller so latest-following, reader detachment, reduced motion, history jumps, touch momentum, keyboard return, and the upward Latest action remain coherent in either direction.
Changes
localStoragein browsers and a stable backend-profile/window adapter in desktop; it never entersAppConfigor synchronizes to other clientschatMessageOrdervalues from stale config rather than persisting or broadcasting them6,5,4 | 3,2,1in newest-first mode without changing Pi transcripts or row identitiesTesting
bun run e2e— 305 passed across all 8 shardsbun run e2e -- e2e/chat-order.spec.ts— 2 passedbun run test— all 14 workspace test tasks passedbun run typecheck— all 14 workspace typecheck tasks passedbun run check:deps— passedbun run check:boundaries— passedbun run check:seams— passedbun run lint— passed (six pre-existing unused-suppression warnings)Screenshots