Skip to content
Closed
Show file tree
Hide file tree
Changes from 1 commit
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
Prev Previous commit
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>
  • Loading branch information
Copilot and edburns authored Apr 27, 2026
commit 3e2bf92567b501324416d84a57a7b8f736d6dd40
21 changes: 9 additions & 12 deletions src/main/java/com/github/copilot/sdk/CopilotClient.java
Original file line number Diff line number Diff line change
Expand Up @@ -744,18 +744,15 @@ public CompletableFuture<String> getForegroundSessionId() {
* if the operation fails
*/
public CompletableFuture<Void> setForegroundSessionId(String sessionId) {
return ensureConnected()
.thenCompose(
connection -> connection.rpc
.invoke("session.setForeground", Map.of("sessionId", sessionId),
com.github.copilot.sdk.json.SetForegroundSessionResponse.class)
.thenAccept(response -> {
if (!response.success()) {
throw new RuntimeException(response.error() != null
? response.error()
: "Failed to set foreground session");
}
}));
return ensureConnected().thenCompose(connection -> connection.rpc
.invoke("session.setForeground", new com.github.copilot.sdk.json.SetForegroundSessionRequest(sessionId),
com.github.copilot.sdk.json.SetForegroundSessionResponse.class)
.thenAccept(response -> {
if (!response.success()) {
throw new RuntimeException(
response.error() != null ? response.error() : "Failed to set foreground session");
}
}));
}

/**
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
/*---------------------------------------------------------------------------------------------
* Copyright (c) Microsoft Corporation. All rights reserved.
*--------------------------------------------------------------------------------------------*/

package com.github.copilot.sdk.json;

import com.fasterxml.jackson.annotation.JsonProperty;

/**
* Internal request object for setting the foreground session.
*
* @param sessionId
* the ID of the session to set as the foreground session
* @see com.github.copilot.sdk.CopilotClient#setForegroundSessionId(String)
* @since 1.0.0
*/
public record SetForegroundSessionRequest(@JsonProperty("sessionId") String sessionId) {
}
Loading