Expose session context, add filtering, and context_changed event#427
Expose session context, add filtering, and context_changed event#427
Conversation
There was a problem hiding this comment.
Pull request overview
Adds session “working directory / git repo” context to Node SDK SessionMetadata returned by listSessions(), and introduces an optional filter parameter to support server-side session filtering.
Changes:
- Added new public types
SessionContextandSessionListFilter, and extendedSessionMetadatawithcontext?: SessionContext. - Updated
CopilotClient.listSessions()to accept an optional filter and to return the newcontextfield. - Updated Node docs/cookbook examples and added an E2E assertion for the new
contextfield.
Reviewed changes
Copilot reviewed 7 out of 7 changed files in this pull request and generated 6 comments.
Show a summary per file
| File | Description |
|---|---|
| nodejs/src/types.ts | Introduces SessionContext / SessionListFilter and adds context onto SessionMetadata. |
| nodejs/src/client.ts | Extends listSessions() to accept a filter and map context from the JSON-RPC response. |
| nodejs/src/index.ts | Re-exports SessionListFilter from the package entrypoint (but currently not SessionContext). |
| nodejs/test/e2e/session.test.ts | Adds an E2E test asserting listSessions() returns a context.cwd. |
| nodejs/README.md | Documents SessionMetadata.context and the SessionContext fields (but doesn’t yet document filtering). |
| cookbook/nodejs/persisting-sessions.md | Adds example printing session context information. |
| cookbook/nodejs/multiple-sessions.md | Adds example showing context?.cwd when listing sessions. |
Adds SessionContext to SessionMetadata so SDK consumers can see the working directory and repository information for each session. Also adds optional filter parameter to listSessions() for filtering by context fields (cwd, gitRoot, repository, branch). Implemented in all SDK clients: - Node.js - Python - Go - .NET Fixes #413 Fixes #200
Cross-SDK Consistency Review: ✅ Excellent ConsistencyI've reviewed this PR for cross-language SDK consistency. This PR adds session context information ( ✅ What's Consistent1. Type DefinitionsAll SDKs define the same two new types with equivalent fields: SessionContext:
SessionListFilter:
All field names use consistent casing (camelCase for TypeScript, snake_case for Python, PascalCase for .NET/Go). 2. API ChangesAll SDKs updated their
The filter parameter is optional/nullable in all implementations. 3. SessionMetadata UpdatesAll SDKs added the 4. Code ChangesAll SDKs properly:
5. Tests
📝 Minor Documentation Gap (Non-blocking)The following READMEs document the new
These are documentation-only gaps and don't affect API consistency. The in-code documentation (docstrings/JSDoc/XML comments) is complete in all languages. 🎯 RecommendationApprove - This PR maintains excellent cross-SDK consistency. The API design is parallel across all four languages, accounting for language-specific idioms. The minor documentation gaps can be addressed in a follow-up if desired, but they don't affect the functionality or API design consistency. Great work maintaining feature parity across all SDKs! 🚀
|
✅ Cross-SDK Consistency ReviewI've reviewed PR #427 for consistency across all four SDK implementations (Node.js, Python, Go, .NET), and I'm pleased to report that this PR maintains excellent cross-SDK consistency! What was added:
Consistency verification:✅ All four SDKs updated - Node.js, Python, Go, and .NET all include the changes
✅ Naming conventions respected - camelCase (Node/Python JSON), PascalCase (Go/C#) as appropriate Language-specific differences (appropriate):
No consistency issues found. This PR successfully maintains feature parity across all SDK implementations while respecting each language's conventions. Nice work! 🎉
|
|
@jmoseley does the SDK track if the git branch changes? if it does could it expose an event for it? |
Adds the session.context_changed event to generated session event types in all SDK clients (Node.js, Python, Go, .NET). The event fires when the working directory context changes between turns and contains the updated context (cwd, gitRoot, repository, branch).
✅ Cross-SDK Consistency ReviewI've reviewed PR #427 for consistency across all four SDK implementations (Node.js, Python, Go, .NET). Overall, this is an excellent example of consistent cross-SDK development! 🎉 ✅ What's Consistent1. Type Definitions
2. Method Signatures
3. Generated Session Events 4. Public API Exports
📝 Minor Documentation GapIssue: The .NET README documents Current (line 119): ##### `ListSessionsAsync(): Task(List<SessionMetadata)>`
List all available sessions.Suggestion: Update to match the API signature and document the new filtering capability: ##### `ListSessionsAsync(SessionListFilter? filter = null): Task(List<SessionMetadata)>`
List all available sessions. Optionally filter by working directory, git root, repository, or branch.Note: The Go and Node.js READMEs were already updated with examples of the new filtering functionality. Python's README doesn't document 🧪 Testing NoteTests were updated for Node.js and Go:
Python and .NET tests continue to work without changes since the filter parameter is optional. Summary: This PR maintains excellent cross-SDK consistency. The only suggestion is to update the .NET README to reflect the new filter parameter. Great work! 👍
|
- Export SessionContext from index.ts - Use SessionContext type instead of inline redeclaration in client.ts - Update listSessions JSDoc with filter param docs and examples - Update README with filter signature - Update session-persistence docs to mention context field
✅ Cross-SDK Consistency Review: PASSEDI've reviewed this PR for consistency across all four SDK implementations (Node.js/TypeScript, Python, Go, and .NET), and I'm pleased to report that this PR maintains excellent cross-SDK consistency. What This PR AddsThis PR adds session context information and filtering capabilities to
Consistency Analysis✅ TypeScript (Node.js):
✅ Python:
✅ Go:
✅ .NET (C#):
API Design ConsistencyThe PR correctly follows language-specific naming conventions:
All four SDKs maintain semantic equivalence in:
TestingTests have been updated consistently:
RecommendationThis PR is ready to merge from a cross-SDK consistency perspective. The implementation demonstrates excellent attention to maintaining feature parity and consistent API design across all four language implementations. Great work on maintaining consistency! 🎉
|
|
@IeuanWalker yup that is included in this change now. |
- Node.js: Unskip context field test (runtime PR now merged) - Python: Add context assertions to existing list_sessions test - Go: Add context assertions to existing ListSessions test - .NET: Add new test for listing sessions with context
✅ Cross-SDK Consistency Review: PASSGreat work maintaining consistency across all four SDK implementations! This PR successfully implements session context exposure, filtering, and the What I VerifiedTypes & API Consistency:
Testing:
Language Conventions:
ConclusionThis PR maintains excellent cross-SDK consistency. All four language implementations provide equivalent functionality with appropriate naming conventions. No inconsistencies detected. 🎉
|
Summary
Exposes working directory and repository context for sessions via
listSessions(), adds optional filtering, and adds thesession.context_changedevent type for detecting context changes during a session.Implemented across all SDK clients: Node.js, Python, Go, .NET.
New Types
SessionContext
SessionListFilter
API Changes
SessionMetadata
Added
context?: SessionContextfield — available when listing sessions.listSessions()
Now accepts optional filter parameter:
session.context_changed event
New session event emitted when the working directory context changes between turns (e.g., agent switches branch, user changes cwd):
Changes
SessionContextandSessionListFiltertypes to all SDKsSessionMetadatato includecontextfieldlistSessions()to accept optional filter and return contextsession.context_changedto generated session event typesRuntime PRs (merged)
Fixes #413
Fixes #200