Skip to content

Commit 6b94284

Browse files
committed
Merge remote-tracking branch 'public-upstream/main' into edburns/dd-2785864-pre-public-non-code-changes
2 parents d36624b + 82c0903 commit 6b94284

File tree

5 files changed

+33
-6
lines changed

5 files changed

+33
-6
lines changed

.lastmerge

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
4246289e484d42155c75267660d448d9ac4f9158
1+
4e1499dd23709022c720eaaa5457d00bf0cb3977

src/main/java/com/github/copilot/sdk/CopilotClient.java

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -208,7 +208,18 @@ private void verifyProtocolVersion(Connection connection) throws Exception {
208208
}
209209

210210
/**
211-
* Stops the client and closes all sessions.
211+
* Disconnects from the Copilot server and closes all active sessions.
212+
* <p>
213+
* This method performs graceful cleanup:
214+
* <ol>
215+
* <li>Closes all active sessions (releases in-memory resources)</li>
216+
* <li>Closes the JSON-RPC connection</li>
217+
* <li>Terminates the CLI server process (if spawned by this client)</li>
218+
* </ol>
219+
* <p>
220+
* Note: session data on disk is preserved, so sessions can be resumed later. To
221+
* permanently remove session data before stopping, call
222+
* {@link #deleteSession(String)} for each session first.
212223
*
213224
* @return A future that completes when the client is stopped
214225
*/
@@ -469,9 +480,12 @@ public CompletableFuture<String> getLastSessionId() {
469480
}
470481

471482
/**
472-
* Deletes a session by ID.
483+
* Permanently deletes a session and all its data from disk, including
484+
* conversation history, planning state, and artifacts.
473485
* <p>
474-
* This permanently removes the session and its conversation history.
486+
* Unlike {@link CopilotSession#close()}, which only releases in-memory
487+
* resources and preserves session data for later resumption, this method is
488+
* irreversible. The session cannot be resumed after deletion.
475489
*
476490
* @param sessionId
477491
* the ID of the session to delete

src/main/java/com/github/copilot/sdk/CopilotSession.java

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,13 @@
5858
* A session maintains conversation state, handles events, and manages tool
5959
* execution. Sessions are created via {@link CopilotClient#createSession} or
6060
* resumed via {@link CopilotClient#resumeSession}.
61+
* <p>
62+
* {@code CopilotSession} implements {@link AutoCloseable}. Use the
63+
* try-with-resources pattern for automatic cleanup, or call {@link #close()}
64+
* explicitly. Closing a session releases in-memory resources but preserves
65+
* session data on disk — the conversation can be resumed later via
66+
* {@link CopilotClient#resumeSession}. To permanently delete session data, use
67+
* {@link CopilotClient#deleteSession}.
6168
*
6269
* <h2>Example Usage</h2>
6370
*

src/site/markdown/documentation.md

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -617,8 +617,14 @@ See [ResumeSessionConfig](apidocs/com/github/copilot/sdk/json/ResumeSessionConfi
617617

618618
### Clean Up Sessions
619619

620+
Closing a session releases its in-memory resources but **preserves session data on disk**, so
621+
it can be resumed later. Use `deleteSession()` to permanently remove session data from disk:
622+
620623
```java
621-
// Delete a specific session
624+
// Close a session (releases in-memory resources; session can be resumed later)
625+
session.close();
626+
627+
// Permanently delete a session and all its data from disk (cannot be resumed)
622628
client.deleteSession(sessionId).get();
623629
```
624630

src/test/java/com/github/copilot/sdk/CopilotSessionTest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ static void teardown() throws Exception {
6060
}
6161

6262
/**
63-
* Verifies that a session can be created and destroyed properly.
63+
* Verifies that a session can be created and closed properly.
6464
*
6565
* @see Snapshot: session/should_receive_session_events
6666
*/

0 commit comments

Comments
 (0)