Repository navigation
#551 Per-turn diff and parent link on v2 - #775
Conversation
- v2 Last turn calls GET /api/session/{id}/diff (from, context 12); the
/openapi.json probe now reads turn diff support next to archive, so
servers before 2.1.0 keep Working tree only
- Changes refetches Last turn when its session goes idle
- v2 createSession sends parentID and omits location when a parent is set
- Android child lockout follows the loaded session's parentId
Co-Authored-By: Claude Opus 5.5 <[email protected]>
OPE-277 Per-turn diff and sub-sessions (v2)
Two v2 server features the apps only half-use today. Everything below is from upstream 1. Per-turn diffWhat it is (plain English)After the agent finishes a "turn" (you send a prompt, the agent works, the session goes idle), the server can tell you exactly which files that turn changed: one entry per file with +/- counts, a status (added / modified / deleted) and a unified-diff patch. That's what the user expects behind Review Changes: "here's what the agent just did", separate from all the other uncommitted changes in the repo. What counts as a "turn"A turn starts at the first user prompt after the session was last idle and ends at the next idle marker. Prompts you steer in while the agent is still busy belong to the same turn. Sessions that have no idle markers at all (older history) fall back to "one prompt until the next user message". Upstream API (v2)
Query params (all optional):
Response: Errors: 404 for an unknown session or message. 400 If no step in the turn recorded a start snapshot, the server returns an empty array. Snapshots only run in git locations with snapshots enabled ( How it's computedIt doesn't use your git history. OpenCode keeps its own snapshots, which are content-addressed git trees of the working copy. Each assistant step stores Eventsv2 has no v1 equivalent
Mapping v1 → v2: How upstream shows it
Commits
2. Sub-sessions (parentID)What it is (plain English)A session can have child sessions. Upstream mostly uses this for subagents: the main agent hands a task to a specialised agent, and that agent works in its own child session with its own transcript. The user sees a "subagent" card in the parent chat and can tap into it to watch what the subagent did. Since Sep 30, any client can also create a child session directly by sending Upstream API (v2)
Agent-spawned vs user-created vs fork
How the web app (packages/app) shows them
v1 equivalent
3. App todayPer-turn diff
Sub-sessions
To doPer-turn diff (v2)
Sub-sessions (v2)
Open questions
|








Summary
getSessionDiffcallsGET /api/session/{id}/diffwithfrom= the turn's user message andcontext=12, replacing the synthetic 404. The response uses the sameFileDiff.Infoshape as v2 Working tree, so the viewer is unchanged. The tool-card changes tap and the Review Changes pill read the same capability, so they turn on with it./openapi.jsoncontract probe now reads per-turn diff support alongside archive (V2SessionArchiveContract→V2ServerContract, returningV2ServerFeatures). Servers before opencode 2.1.0 keep Working tree only, with no error.session.idle. This covers a Changes screen opened from a tool card mid-turn, where v2 compares against the working copy. It applies on v1 too, which also pushes no per-turn diff.createSessionsendsparentIDand leaves outlocationwhen a parent is set.parentId, not only when the navigation route has a parent. iOS already worked this way.Checks
:app:assembleDebugsucceeds. 332 tests pass across the affected classes (SessionChatViewModel, Changes, SessionProtocolRepository, ConnectionProbeService, V2ServerContract, ActiveConnectionManager*, ServerProtocol*), 12 of them new.ktlintCheckreports nothing in the changed files.xcodebuild teston an iPhone 17 simulator (iOS 26.5), 99 tests in 6 suites pass (ChangesViewModel, V2ServerContract, SessionProtocolRepository, ActiveConnectionManagerSessionArchive, ServerProtocolClassifier, ServerProtocolMatrix), 8 of them new.packages/protocol/openapi.json.Issue
Risks / Follow-ups
🤖 Generated with Claude Code
Need help on this PR? Tag
@codesmithwith what you need.