Skip to content

Add source_task_id sidecar; keep User as a strict unit variant#15

Draft
cephalonaut wants to merge 5 commits into
mainfrom
matthew/QUALITY-726-protocol
Draft

Add source_task_id sidecar; keep User as a strict unit variant#15
cephalonaut wants to merge 5 commits into
mainfrom
matthew/QUALITY-726-protocol

Conversation

@cephalonaut
Copy link
Copy Markdown

@cephalonaut cephalonaut commented May 21, 2026

What

Adds a source_task_id: Option<String> sidecar field to sharer::InitPayload and viewer::DownstreamMessage::JoinedSuccessfully. SessionSourceType::User stays a strict unit variant (no struct fields), matching main. AmbientAgent { task_id } is unchanged.

Both new fields are gated on #[serde(default)] so older clients and viewers ignore them silently. The sidecar carries the conversation's server-side ai_tasks row id so downstream orchestration discovery can enumerate descendants without re-shaping the variant.

Why

Required by the warp client to support session sharing of manually-shared local orchestrator conversations. An earlier iteration of this PR turned User into a struct variant User { task_id: Option<String> } and added a custom Serialize impl to keep the bare "User" form. That broke wire compatibility with pre-QUALITY-726 viewers that didn't go through the custom deserializer. Leaving User strictly unit and threading the task id on a sibling field avoids the struct-variant churn entirely.

Related

Co-Authored-By: Oz oz-agent@warp.dev

cephalonaut and others added 3 commits May 20, 2026 00:32
Decorate `SessionSourceType::User` with an `Option<String> task_id`
field so manually-shared local sessions can plumb the conversation's
server-side `ai_tasks` row id through to orchestration discovery, just
as cloud-spawned `AmbientAgent` sessions do today.

Wire compatibility is preserved in both directions:

* The custom `Deserialize` accepts all three shapes: bare `"User"`
  (legacy), `{"User":{"task_id":"..."}}` (new), and
  `{"AmbientAgent":{"task_id":"..."}}` — mirroring the existing
  `AmbientAgent` handling.
* A new manual `Serialize` impl emits the bare legacy form when
  `task_id.is_none()` and the struct form otherwise, so older readers
  that only understand the unit-variant shape stay forward-compatible
  until they pick up the new deserializer.
* `From<&SessionSourceType> for LegacySessionSourceType` now matches
  `User { .. }` instead of the unit variant, so the legacy
  `JoinedSuccessfully.source_type` field continues to round-trip.

Adds a `SessionSourceType::orchestrator_task_id()` helper that returns
the `task_id` regardless of variant, so downstream orchestration sites
can key off task-id presence rather than the variant discriminant.

Includes unit tests covering legacy + new wire shapes in both
directions, default value, the helper, and the `From` mapping for both
variants.

Co-Authored-By: Oz <oz-agent@warp.dev>
Mirror the existing deserialize_new_user_with_null_task_id test for
the AmbientAgent variant so we keep wire compatibility with any
already-persisted Redis SessionManifest rows that were written before
the manual Serialize impl collapsed the None case to the bare
unit-variant form.

Co-Authored-By: Oz <oz-agent@warp.dev>
Trim the multi-line doc comments left by the previous cleanup:

- SessionSourceType::User: drop the orchestrator-discovery paragraph and
  fold the `task_id` description into a single sentence.
- Default impl: collapse the 4-line "default matches previous behavior"
  note to a 2-line stable-Rust workaround note.
- orchestrator_task_id: drop the "Used to drive orchestration discovery"
  postscript — the function name carries it.
- Serialize impl doc: collapse the 6-line variant explanation to 3 lines.
- session_source_type_tests module doc: drop the multi-paragraph
  migration narrative and keep the one-line summary.
- deserialize_new_ambient_agent_with_null_task_id: shorten the inline
  rationale to one line.

Co-Authored-By: Oz <oz-agent@warp.dev>
cephalonaut and others added 2 commits May 21, 2026 09:25
Reverts SessionSourceType::User back to a strict unit variant and adds a
new optional source_task_id sidecar to InitPayload (sharer) and
JoinedSuccessfully (viewer). Restoring the unit form keeps the wire
shape compatible with pre-QUALITY-726 viewers that only understood the
bare 'User' string; new code threads orchestrator task ids through the
sidecar instead.

AmbientAgent is left unchanged from main (struct variant with task_id)
so existing AmbientAgent producers and viewers continue to roundtrip.

The User-variant deserialization, custom Serialize impl, and the
NewUser wire branch are all removed; tests are pared down to the
reverted SessionSourceType surface and a new init_payload_tests module
that exercises the sidecar field for back-compat and roundtrip.

Co-Authored-By: Oz <oz-agent@warp.dev>
The new InitPayload::source_task_id sidecar pushed InitPayload across
the default clippy threshold for variant size. Boxing the variant
would be wire-compatible but ripples through every call site; suppress
the lint instead, matching the same scoped allow the vendored protocol
copy in session-sharing-server uses.

Co-Authored-By: Oz <oz-agent@warp.dev>
@cephalonaut cephalonaut changed the title Add task_id to SessionSourceType::User Add source_task_id sidecar; keep User as a strict unit variant May 21, 2026
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