Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion docs/guides/session-persistence.md
Original file line number Diff line number Diff line change
Expand Up @@ -293,12 +293,16 @@ session_id = create_session_id("alice", "code-review")
### Listing Active Sessions

```typescript
// List all sessions
const sessions = await client.listSessions();
console.log(`Found ${sessions.length} sessions`);

for (const session of sessions) {
console.log(`- ${session.sessionId} (created: ${session.createdAt})`);
}

// Filter sessions by repository
const repoSessions = await client.listSessions({ repository: "owner/repo" });
```

### Cleaning Up Old Sessions
Expand Down Expand Up @@ -521,7 +525,7 @@ await withSessionLock("user-123-task-456", async () => {
| **Create resumable session** | Provide your own `sessionId` |
| **Resume session** | `client.resumeSession(sessionId)` |
| **BYOK resume** | Re-provide `provider` config |
| **List sessions** | `client.listSessions()` |
| **List sessions** | `client.listSessions(filter?)` |
| **Delete session** | `client.deleteSession(sessionId)` |
| **Destroy active session** | `session.destroy()` |
| **Containerized deployment** | Mount `~/.copilot/session-state/` to persistent storage |
Expand Down
9 changes: 7 additions & 2 deletions dotnet/src/Client.cs
Original file line number Diff line number Diff line change
Expand Up @@ -652,6 +652,7 @@ public async Task DeleteSessionAsync(string sessionId, CancellationToken cancell
/// <summary>
/// Lists all sessions known to the Copilot server.
/// </summary>
/// <param name="filter">Optional filter to narrow down the session list by cwd, git root, repository, or branch.</param>
/// <param name="cancellationToken">A <see cref="CancellationToken"/> that can be used to cancel the operation.</param>
/// <returns>A task that resolves with a list of <see cref="SessionMetadata"/> for all available sessions.</returns>
/// <exception cref="InvalidOperationException">Thrown when the client is not connected.</exception>
Expand All @@ -664,12 +665,12 @@ public async Task DeleteSessionAsync(string sessionId, CancellationToken cancell
/// }
/// </code>
/// </example>
public async Task<List<SessionMetadata>> ListSessionsAsync(CancellationToken cancellationToken = default)
public async Task<List<SessionMetadata>> ListSessionsAsync(SessionListFilter? filter = null, CancellationToken cancellationToken = default)
{
var connection = await EnsureConnectedAsync(cancellationToken);

var response = await InvokeRpcAsync<ListSessionsResponse>(
connection.Rpc, "session.list", [], cancellationToken);
connection.Rpc, "session.list", [new ListSessionsRequest(filter)], cancellationToken);

return response.Sessions;
}
Expand Down Expand Up @@ -1369,6 +1370,9 @@ internal record DeleteSessionResponse(
bool Success,
string? Error);

internal record ListSessionsRequest(
SessionListFilter? Filter);

internal record ListSessionsResponse(
List<SessionMetadata> Sessions);

Expand Down Expand Up @@ -1438,6 +1442,7 @@ public override void WriteLine(string? message) =>
[JsonSerializable(typeof(DeleteSessionResponse))]
[JsonSerializable(typeof(GetLastSessionIdResponse))]
[JsonSerializable(typeof(HooksInvokeResponse))]
[JsonSerializable(typeof(ListSessionsRequest))]
[JsonSerializable(typeof(ListSessionsResponse))]
[JsonSerializable(typeof(PermissionRequestResponse))]
[JsonSerializable(typeof(PermissionRequestResult))]
Expand Down
Loading
Loading