Skip to content

Commit 3e2bf92

Browse files
Copilotedburns
andauthored
Port SetForegroundSessionRequest from reference implementation (c63feb2)
Agent-Logs-Url: https://github.com/github/copilot-sdk-java/sessions/4b8200da-787f-4f51-ab9d-c196711007de Co-authored-by: edburns <75821+edburns@users.noreply.github.com>
1 parent 8e194b0 commit 3e2bf92

2 files changed

Lines changed: 27 additions & 12 deletions

File tree

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

Lines changed: 9 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -744,18 +744,15 @@ public CompletableFuture<String> getForegroundSessionId() {
744744
* if the operation fails
745745
*/
746746
public CompletableFuture<Void> setForegroundSessionId(String sessionId) {
747-
return ensureConnected()
748-
.thenCompose(
749-
connection -> connection.rpc
750-
.invoke("session.setForeground", Map.of("sessionId", sessionId),
751-
com.github.copilot.sdk.json.SetForegroundSessionResponse.class)
752-
.thenAccept(response -> {
753-
if (!response.success()) {
754-
throw new RuntimeException(response.error() != null
755-
? response.error()
756-
: "Failed to set foreground session");
757-
}
758-
}));
747+
return ensureConnected().thenCompose(connection -> connection.rpc
748+
.invoke("session.setForeground", new com.github.copilot.sdk.json.SetForegroundSessionRequest(sessionId),
749+
com.github.copilot.sdk.json.SetForegroundSessionResponse.class)
750+
.thenAccept(response -> {
751+
if (!response.success()) {
752+
throw new RuntimeException(
753+
response.error() != null ? response.error() : "Failed to set foreground session");
754+
}
755+
}));
759756
}
760757

761758
/**
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
/*---------------------------------------------------------------------------------------------
2+
* Copyright (c) Microsoft Corporation. All rights reserved.
3+
*--------------------------------------------------------------------------------------------*/
4+
5+
package com.github.copilot.sdk.json;
6+
7+
import com.fasterxml.jackson.annotation.JsonProperty;
8+
9+
/**
10+
* Internal request object for setting the foreground session.
11+
*
12+
* @param sessionId
13+
* the ID of the session to set as the foreground session
14+
* @see com.github.copilot.sdk.CopilotClient#setForegroundSessionId(String)
15+
* @since 1.0.0
16+
*/
17+
public record SetForegroundSessionRequest(@JsonProperty("sessionId") String sessionId) {
18+
}

0 commit comments

Comments
 (0)