Skip to content

Commit b760022

Browse files
patnikoCopilot
andcommitted
chore: update all tests, scenarios, and docs to use disconnect()
Migrate all test scenarios, e2e tests, READMEs, and documentation references from destroy()/Destroy() to disconnect()/Disconnect(). - 90 test scenario files across Go/Python/TypeScript/C# - 15 Node.js e2e test files - 8 Python e2e test files - 3 Go e2e test files - 1 .NET test file - READMEs and compatibility docs updated with new API reference - Agent docs updated with new method names - Reconnect scenario log messages updated to 'disconnected' Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
1 parent 1e6f1ee commit b760022

File tree

127 files changed

+251
-245
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

127 files changed

+251
-245
lines changed

.github/agents/docs-maintenance.agent.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -344,7 +344,7 @@ cat nodejs/src/types.ts | grep -A 10 "export interface ExportSessionOptions"
344344
**Must match:**
345345
- `CopilotClient` constructor options: `cliPath`, `cliUrl`, `useStdio`, `port`, `logLevel`, `autoStart`, `autoRestart`, `env`, `githubToken`, `useLoggedInUser`
346346
- `createSession()` config: `model`, `tools`, `hooks`, `systemMessage`, `mcpServers`, `availableTools`, `excludedTools`, `streaming`, `reasoningEffort`, `provider`, `infiniteSessions`, `customAgents`, `workingDirectory`
347-
- `CopilotSession` methods: `send()`, `sendAndWait()`, `getMessages()`, `destroy()`, `abort()`, `on()`, `once()`, `off()`
347+
- `CopilotSession` methods: `send()`, `sendAndWait()`, `getMessages()`, `disconnect()`, `abort()`, `on()`, `once()`, `off()`
348348
- Hook names: `onPreToolUse`, `onPostToolUse`, `onUserPromptSubmitted`, `onSessionStart`, `onSessionEnd`, `onErrorOccurred`
349349

350350
#### Python Validation
@@ -362,7 +362,7 @@ cat python/copilot/types.py | grep -A 15 "class SessionHooks"
362362
**Must match (snake_case):**
363363
- `CopilotClient` options: `cli_path`, `cli_url`, `use_stdio`, `port`, `log_level`, `auto_start`, `auto_restart`, `env`, `github_token`, `use_logged_in_user`
364364
- `create_session()` config keys: `model`, `tools`, `hooks`, `system_message`, `mcp_servers`, `available_tools`, `excluded_tools`, `streaming`, `reasoning_effort`, `provider`, `infinite_sessions`, `custom_agents`, `working_directory`
365-
- `CopilotSession` methods: `send()`, `send_and_wait()`, `get_messages()`, `destroy()`, `abort()`, `export_session()`
365+
- `CopilotSession` methods: `send()`, `send_and_wait()`, `get_messages()`, `disconnect()`, `abort()`, `export_session()`
366366
- Hook names: `on_pre_tool_use`, `on_post_tool_use`, `on_user_prompt_submitted`, `on_session_start`, `on_session_end`, `on_error_occurred`
367367

368368
#### Go Validation
@@ -380,7 +380,7 @@ cat go/types.go | grep -A 15 "type SessionHooks struct"
380380
**Must match (PascalCase for exported):**
381381
- `ClientOptions` fields: `CLIPath`, `CLIUrl`, `UseStdio`, `Port`, `LogLevel`, `AutoStart`, `AutoRestart`, `Env`, `GithubToken`, `UseLoggedInUser`
382382
- `SessionConfig` fields: `Model`, `Tools`, `Hooks`, `SystemMessage`, `MCPServers`, `AvailableTools`, `ExcludedTools`, `Streaming`, `ReasoningEffort`, `Provider`, `InfiniteSessions`, `CustomAgents`, `WorkingDirectory`
383-
- `Session` methods: `Send()`, `SendAndWait()`, `GetMessages()`, `Destroy()`, `Abort()`, `ExportSession()`
383+
- `Session` methods: `Send()`, `SendAndWait()`, `GetMessages()`, `Disconnect()`, `Abort()`, `ExportSession()`
384384
- Hook fields: `OnPreToolUse`, `OnPostToolUse`, `OnUserPromptSubmitted`, `OnSessionStart`, `OnSessionEnd`, `OnErrorOccurred`
385385

386386
#### .NET Validation

docs/compatibility.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,8 @@ The Copilot SDK communicates with the CLI via JSON-RPC protocol. Features must b
1515
| **Session Management** | | |
1616
| Create session | `createSession()` | Full config support |
1717
| Resume session | `resumeSession()` | With infinite session workspaces |
18-
| Destroy session | `destroy()` | Clean up resources |
18+
| Disconnect session | `disconnect()` | Release in-memory resources |
19+
| Destroy session *(deprecated)* | `destroy()` | Use `disconnect()` instead |
1920
| Delete session | `deleteSession()` | Remove from storage |
2021
| List sessions | `listSessions()` | All stored sessions |
2122
| Get last session | `getLastSessionId()` | For quick resume |

docs/guides/setup/scaling.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -412,7 +412,7 @@ class SessionManager {
412412
private async evictOldestSession(): Promise<void> {
413413
const [oldestId] = this.activeSessions.keys();
414414
const session = this.activeSessions.get(oldestId)!;
415-
// Session state is persisted automatically — safe to destroy
415+
// Session state is persisted automatically — safe to disconnect
416416
await session.disconnect();
417417
this.activeSessions.delete(oldestId);
418418
}

dotnet/test/SessionTests.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ namespace GitHub.Copilot.SDK.Test;
1313
public class SessionTests(E2ETestFixture fixture, ITestOutputHelper output) : E2ETestBase(fixture, "session", output)
1414
{
1515
[Fact]
16-
public async Task ShouldCreateAndDestroySessions()
16+
public async Task ShouldCreateAndDisconnectSessions()
1717
{
1818
var session = await CreateSessionAsync(new SessionConfig { Model = "fake-test-model" });
1919

go/README.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -168,7 +168,8 @@ Event types: `SessionLifecycleCreated`, `SessionLifecycleDeleted`, `SessionLifec
168168
- `On(handler SessionEventHandler) func()` - Subscribe to events (returns unsubscribe function)
169169
- `Abort(ctx context.Context) error` - Abort the currently processing message
170170
- `GetMessages(ctx context.Context) ([]SessionEvent, error)` - Get message history
171-
- `Destroy() error` - Destroy the session
171+
- `Disconnect() error` - Disconnect the session (releases in-memory resources, preserves disk state)
172+
- `Destroy() error` - *(Deprecated)* Use `Disconnect()` instead
172173

173174
### Helper Functions
174175

go/internal/e2e/mcp_and_agents_test.go

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ func TestMCPServers(t *testing.T) {
5555
t.Errorf("Expected message to contain '4', got: %v", message.Data.Content)
5656
}
5757

58-
session.Destroy()
58+
session.Disconnect()
5959
})
6060

6161
t.Run("accept MCP server config on resume", func(t *testing.T) {
@@ -104,7 +104,7 @@ func TestMCPServers(t *testing.T) {
104104
t.Errorf("Expected message to contain '6', got: %v", message.Data.Content)
105105
}
106106

107-
session2.Destroy()
107+
session2.Disconnect()
108108
})
109109

110110
t.Run("should pass literal env values to MCP server subprocess", func(t *testing.T) {
@@ -150,7 +150,7 @@ func TestMCPServers(t *testing.T) {
150150
t.Errorf("Expected message to contain 'hunter2', got: %v", message.Data.Content)
151151
}
152152

153-
session.Destroy()
153+
session.Disconnect()
154154
})
155155

156156
t.Run("handle multiple MCP servers", func(t *testing.T) {
@@ -183,7 +183,7 @@ func TestMCPServers(t *testing.T) {
183183
t.Error("Expected non-empty session ID")
184184
}
185185

186-
session.Destroy()
186+
session.Disconnect()
187187
})
188188
}
189189

@@ -235,7 +235,7 @@ func TestCustomAgents(t *testing.T) {
235235
t.Errorf("Expected message to contain '10', got: %v", message.Data.Content)
236236
}
237237

238-
session.Destroy()
238+
session.Disconnect()
239239
})
240240

241241
t.Run("accept custom agent config on resume", func(t *testing.T) {
@@ -284,7 +284,7 @@ func TestCustomAgents(t *testing.T) {
284284
t.Errorf("Expected message to contain '12', got: %v", message.Data.Content)
285285
}
286286

287-
session2.Destroy()
287+
session2.Disconnect()
288288
})
289289

290290
t.Run("handle custom agent with tools", func(t *testing.T) {
@@ -314,7 +314,7 @@ func TestCustomAgents(t *testing.T) {
314314
t.Error("Expected non-empty session ID")
315315
}
316316

317-
session.Destroy()
317+
session.Disconnect()
318318
})
319319

320320
t.Run("handle custom agent with MCP servers", func(t *testing.T) {
@@ -349,7 +349,7 @@ func TestCustomAgents(t *testing.T) {
349349
t.Error("Expected non-empty session ID")
350350
}
351351

352-
session.Destroy()
352+
session.Disconnect()
353353
})
354354

355355
t.Run("handle multiple custom agents", func(t *testing.T) {
@@ -386,7 +386,7 @@ func TestCustomAgents(t *testing.T) {
386386
t.Error("Expected non-empty session ID")
387387
}
388388

389-
session.Destroy()
389+
session.Disconnect()
390390
})
391391
}
392392

@@ -445,6 +445,6 @@ func TestCombinedConfiguration(t *testing.T) {
445445
t.Errorf("Expected message to contain '14', got: %v", message.Data.Content)
446446
}
447447

448-
session.Destroy()
448+
session.Disconnect()
449449
})
450450
}

go/internal/e2e/session_test.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ func TestSession(t *testing.T) {
1515
client := ctx.NewClient()
1616
t.Cleanup(func() { client.ForceStop() })
1717

18-
t.Run("should create and destroy sessions", func(t *testing.T) {
18+
t.Run("should create and disconnect sessions", func(t *testing.T) {
1919
ctx.ConfigureForTest(t)
2020

2121
session, err := client.CreateSession(t.Context(), &copilot.SessionConfig{OnPermissionRequest: copilot.PermissionHandler.ApproveAll, Model: "fake-test-model"})
@@ -45,13 +45,13 @@ func TestSession(t *testing.T) {
4545
t.Errorf("Expected selectedModel to be 'fake-test-model', got %v", messages[0].Data.SelectedModel)
4646
}
4747

48-
if err := session.Destroy(); err != nil {
49-
t.Fatalf("Failed to destroy session: %v", err)
48+
if err := session.Disconnect(); err != nil {
49+
t.Fatalf("Failed to disconnect session: %v", err)
5050
}
5151

5252
_, err = session.GetMessages(t.Context())
5353
if err == nil || !strings.Contains(err.Error(), "not found") {
54-
t.Errorf("Expected GetMessages to fail with 'not found' after destroy, got %v", err)
54+
t.Errorf("Expected GetMessages to fail with 'not found' after disconnect, got %v", err)
5555
}
5656
})
5757

go/internal/e2e/skills_test.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ func TestSkills(t *testing.T) {
7676
t.Errorf("Expected message to contain skill marker '%s', got: %v", skillMarker, message.Data.Content)
7777
}
7878

79-
session.Destroy()
79+
session.Disconnect()
8080
})
8181

8282
t.Run("should not apply skill when disabled via disabledSkills", func(t *testing.T) {
@@ -105,7 +105,7 @@ func TestSkills(t *testing.T) {
105105
t.Errorf("Expected message to NOT contain skill marker '%s' when disabled, got: %v", skillMarker, *message.Data.Content)
106106
}
107107

108-
session.Destroy()
108+
session.Disconnect()
109109
})
110110

111111
t.Run("should apply skill on session resume with skillDirectories", func(t *testing.T) {
@@ -154,6 +154,6 @@ func TestSkills(t *testing.T) {
154154
t.Errorf("Expected message to contain skill marker '%s' after resume, got: %v", skillMarker, message2.Data.Content)
155155
}
156156

157-
session2.Destroy()
157+
session2.Disconnect()
158158
})
159159
}

nodejs/README.md

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -265,9 +265,13 @@ Abort the currently processing message in this session.
265265

266266
Get all events/messages from this session.
267267

268-
##### `destroy(): Promise<void>`
268+
##### `disconnect(): Promise<void>`
269269

270-
Destroy the session and free resources.
270+
Disconnect the session and free resources. Session data on disk is preserved for later resumption.
271+
272+
##### `destroy(): Promise<void>` *(deprecated)*
273+
274+
Deprecated — use `disconnect()` instead.
271275

272276
---
273277

nodejs/test/e2e/agent_and_compact_rpc.test.ts

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ describe("Agent Selection RPC", async () => {
4040
expect(result.agents[0].description).toBe("A test agent");
4141
expect(result.agents[1].name).toBe("another-agent");
4242

43-
await session.destroy();
43+
await session.disconnect();
4444
});
4545

4646
it("should return null when no agent is selected", async () => {
@@ -61,7 +61,7 @@ describe("Agent Selection RPC", async () => {
6161
const result = await session.rpc.agent.getCurrent();
6262
expect(result.agent).toBeNull();
6363

64-
await session.destroy();
64+
await session.disconnect();
6565
});
6666

6767
it("should select and get current agent", async () => {
@@ -90,7 +90,7 @@ describe("Agent Selection RPC", async () => {
9090
expect(currentResult.agent).not.toBeNull();
9191
expect(currentResult.agent!.name).toBe("test-agent");
9292

93-
await session.destroy();
93+
await session.disconnect();
9494
});
9595

9696
it("should deselect current agent", async () => {
@@ -116,7 +116,7 @@ describe("Agent Selection RPC", async () => {
116116
const currentResult = await session.rpc.agent.getCurrent();
117117
expect(currentResult.agent).toBeNull();
118118

119-
await session.destroy();
119+
await session.disconnect();
120120
});
121121

122122
it("should return empty list when no custom agents configured", async () => {
@@ -125,7 +125,7 @@ describe("Agent Selection RPC", async () => {
125125
const result = await session.rpc.agent.list();
126126
expect(result.agents).toEqual([]);
127127

128-
await session.destroy();
128+
await session.disconnect();
129129
});
130130
});
131131

@@ -144,6 +144,6 @@ describe("Session Compact RPC", async () => {
144144
expect(typeof result.tokensRemoved).toBe("number");
145145
expect(typeof result.messagesRemoved).toBe("number");
146146

147-
await session.destroy();
147+
await session.disconnect();
148148
}, 60000);
149149
});

0 commit comments

Comments
 (0)