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 AOT-safe SetForegroundSessionRequest and COPILOT_HOME env var fr…
…om reference implementation

- Add SetForegroundSessionRequest record in json package for typed serialization
- Update setForegroundSessionId() to use SetForegroundSessionRequest instead of Map.of()
  (port of c63feb2: fix(dotnet): Add AOT-safe SetForegroundSessionRequest)
- Add COPILOT_HOME env variable to E2ETestContext.getEnvironment()
  (port of test harness fix from E2ETestContext.cs)

Co-authored-by: edburns <75821+edburns@users.noreply.github.com>
  • Loading branch information
Copilot and edburns authored Apr 30, 2026
commit 3476fd1cbcde7d1ef208555233f3ab830ac7f131
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,20 @@
/*---------------------------------------------------------------------------------------------
* Copyright (c) Microsoft Corporation. All rights reserved.
*--------------------------------------------------------------------------------------------*/

package com.github.copilot.sdk.json;

import com.fasterxml.jackson.annotation.JsonProperty;

/**
* Request for session.setForeground RPC call.
* <p>
* This is only available when connecting to a server running in TUI+server mode
* (--ui-server).
*
* @since 1.0.0
*/
public record SetForegroundSessionRequest(
/** The ID of the session to bring to the foreground. */
@JsonProperty("sessionId") String sessionId) {
}
1 change: 1 addition & 0 deletions src/test/java/com/github/copilot/sdk/E2ETestContext.java
Original file line number Diff line number Diff line change
Expand Up @@ -249,6 +249,7 @@ public List<Map<String, Object>> getExchanges() throws IOException, InterruptedE
public Map<String, String> getEnvironment() {
Map<String, String> env = new HashMap<>(System.getenv());
env.put("COPILOT_API_URL", proxyUrl);
env.put("COPILOT_HOME", homeDir.toString());
env.put("XDG_CONFIG_HOME", homeDir.toString());
env.put("XDG_STATE_HOME", homeDir.toString());
return env;
Expand Down
Loading