Add shared session watch APIs - #2415
Open
toliaqat wants to merge 5 commits into
Open
Conversation
Expose passive shared-session watch handles for Node and Rust, with generated RPC types, ordered event routing, lifecycle cleanup, and tests. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
| expect((client as any).sharedSessionWatches.has("watch-session")).toBe(false); | ||
| expect("send" in watch).toBe(false); | ||
| expect("abort" in watch).toBe(false); | ||
| if (false) { |
This comment has been minimized.
This comment has been minimized.
Contributor
There was a problem hiding this comment.
Pull request overview
Adds passive shared-session watch APIs for Node.js and Rust, including event replay, lifecycle handling, cleanup, documentation, and generated RPC types.
Changes:
- Adds read-only shared-session watch handles and
sessions.watchintegration. - Propagates
session.disconnectedlifecycle events and cleans up routing. - Updates generated schemas, tests, documentation, and line-ending rules.
Show a summary per file
| File | Description |
|---|---|
.gitattributes |
Standardizes Node.js and Rust line endings. |
nodejs/README.md |
Documents shared-session watching. |
nodejs/src/client.ts |
Implements watch creation and cleanup. |
nodejs/src/generated/rpc.ts |
Adds generated watch RPC types. |
nodejs/src/generated/session-events.ts |
Refreshes generated event types. |
nodejs/src/index.ts |
Exports watch and lifecycle APIs. |
nodejs/src/session.ts |
Adds the passive watch handle. |
nodejs/src/types.ts |
Adds disconnected lifecycle typing. |
nodejs/test/client.test.ts |
Tests watch behavior and payloads. |
rust/README.md |
Documents Rust watch usage. |
rust/src/generated/api_types.rs |
Refreshes generated RPC payload types. |
rust/src/generated/rpc.rs |
Adds the generated watch RPC method. |
rust/src/generated/session_events.rs |
Refreshes generated event types. |
rust/src/handler.rs |
Updates permission-context example. |
rust/src/lib.rs |
Tracks watches and lifecycle cleanup. |
rust/src/router.rs |
Makes the session router cloneable. |
rust/src/session.rs |
Updates permission-context fixtures. |
rust/src/types.rs |
Adds disconnected lifecycle support. |
rust/src/watch.rs |
Implements Rust shared-session watches. |
rust/tests/api_types_test.rs |
Tests credential-free payload shapes. |
rust/tests/session_test.rs |
Tests replay, disconnect, and close behavior. |
Review details
💡 Configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
- Files reviewed: 16/21 changed files
- Comments generated: 3
- Review effort level: Balanced
Comment on lines
+1677
to
+1680
| if event.event_type == SessionLifecycleEventType::Disconnected | ||
| && watch_sessions.lock().remove(&event.session_id) | ||
| { | ||
| router.unregister(&event.session_id); |
| ); | ||
| assert_eq!(terminal.session_id, "watch-session"); | ||
| assert!(terminal.metadata.is_none()); | ||
| assert!(watch.events().recv().await.is_none()); |
Comment on lines
+145
to
+147
| for (const event of pending) { | ||
| handler(event); | ||
| } |
Guard the hand-authored Node and Rust lifecycle unions against silent drift from the Runtime notification contract. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Regenerate the watch RPC from the accepted contract while preserving the SDK's published CLI schema surface and removing unrelated newer Runtime event/type drift. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com> Copilot-Session: be0a255d-04f8-4830-888a-59f54ad1e607
This comment has been minimized.
This comment has been minimized.
Keep the generated watch API additive against the SDK's pinned CLI schema and leave repository-wide line-ending policy unchanged. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com> Copilot-Session: be0a255d-04f8-4830-888a-59f54ad1e607
Contributor
Cross-SDK Consistency ReviewThis PR adds two new capabilities to the Node.js and Rust SDKs:
Feature parity gapsThe following SDKs do not yet implement either feature:
Notes
|
Route disconnect cleanup in the ordered session notification task and store watch classification with router entries so shutdown always uses sessions.close without racing terminal cleanup. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com> Copilot-Session: be0a255d-04f8-4830-888a-59f54ad1e607
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
sessions.watch({ sessionId })RPC surface from Runtime schema commit7c34f30aa270d2a6214d1aa0274fc1afd4c9790d(SHA-256dec3e7be93b7a3ca023eff9f6e90e9858bb6305d15f547d0e599283828a9b310)SharedSessionWatchhandles with immutable read-only metadata, ordered replay/livesession.eventdelivery, idempotentsessions.close, and no interactive or lane-credential surface{ type: "session.disconnected", sessionId }terminal lifecycle signal and atomically clean up watch routing after preceding eventssession.destroyValidation
Runtime and publication dependency
The generated API is pinned to the main-based schema-only Runtime commit above. Execution and normal package-backed regeneration remain blocked until a new
@github/copilotpublication carries Runtime PR github/copilot-agent-runtime#17282 (0179092d8c319b60b4b8cb7df0b0829c095adb4f) together withsessions.watchand the hand-writtensession.disconnectedlifecycle union. The lifecycle variant is intentionally absent fromgenerated/api.schema.json.