Repository navigation
feat(unstable): add session cursors and cursorId on session/fork - #2843
Merged
Merged
Conversation
Implement steps 1 and 2 of the Session Cursors RFD behind the new `unstable_session_cursors` feature, and the fork RFD's "Forking at a cursor" section. - Add `SessionUpdate::CursorUpdate` in v1 and v2, with `CursorUpdate`, `CursorId`, `CursorCapabilities`, `CursorAnchor`, and `CursorAnchorPosition`. The update is an upsert keyed by `cursorId`. `capabilities` is a nullable patch, like tool call capabilities. - Anchors cover user messages, agent messages, agent thoughts, session messages, tool calls, and compactions. Unknown anchor types and positions are preserved, so a Client can tell that it cannot place the cursor. - Parse `capabilities` and `_meta` leniently. A malformed anchor fails the update, and a malformed known anchor type never falls through to the `Other` fallback. - Add the `session.cursors` Client capability in v1. V2 needs no capability. - Add an optional `cursorId` to `session/fork` and a `fork` cursor capability, behind `unstable_session_fork` and `unstable_session_cursors`. A malformed `cursorId` fails with `-32602` and is not treated as omitted. - List `cursor_update` as a known v2 discriminator so a malformed update never falls through to the `Other` fallback. - Document cursors, anchors, placement, replay, and forking at a cursor in the draft v1 and v2 protocol pages. - Add the RFD's Draft entry to the RFD updates page and note the landed steps in both RFDs' revision histories.
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.
Implements steps 1 and 2 of the Session Cursors RFD (#2114) and the fork RFD's "Forking at a cursor" section. Everything is behind the new
unstable_session_cursorsfeature, which is part ofunstable.Schema
cursor_updatesession update in v1 and v2. It is an upsert keyed bycursorId.capabilitiesis a nullable patch object, the same shape as tool call capabilities.anchoris required on the first update for a cursor.CursorAnchoris a union tagged bytype:user_message,agent_message,agent_thought,session_message,tool_call, andcompaction. Each carries the entity's ID and apositionofbeforeorafter. Unknown types and positions are preserved, so a Client can tell that it cannot place the cursor and does not guess.cursorIdonsession/forkand aforkcursor capability, behindunstable_session_forkandunstable_session_cursorstogether.session.cursorsClient capability in v1. V2 needs no capability, because Clients ignore session updates they don't know.In v1, the
session_messageanchor is also behindunstable_subagents, like session messages themselves.Parsing
capabilitiesand_metaparse leniently. A malformed capability reads as not advertised.anchorand the forkcursorIdare strict. A malformed anchor fails the update, and a malformedcursorIdfails the request with-32602. It never falls back to forking the whole session.Othervariant.cursor_updateis in the v2 list of known discriminators for the same reason.Docs
Notes for review
_meta, which the RFD did not spell out. It follows the other nested union payloads, and the RFD's revision history now says so.CursorMessageAnchor,CursorToolCallAnchor, andCursorCompactionAnchor. The four message anchor types share one struct.Testing
npm run generateleaves no diff. The clippy passes,cargo test --all-features, the per-feature schema and generator test runs, the docs.rs build, Prettier, and the spellcheck all pass locally.