Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
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
2 changes: 1 addition & 1 deletion .lastmerge
Original file line number Diff line number Diff line change
@@ -1 +1 @@
dd2dcbc439256acfb9feb2cff07c0b9c820091b8
e42b726ca42bd1b2e099a956c9287ba9435ba3e5
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@
reference-impl-sync workflow and deal with the subsequent
PR.
-->
<readonly-copilot-sdk-ref-impl-version-from-lastmerge-file-updated-by-reference-impl-sync>^1.0.36-0</readonly-copilot-sdk-ref-impl-version-from-lastmerge-file-updated-by-reference-impl-sync>
<readonly-copilot-sdk-ref-impl-version-from-lastmerge-file-updated-by-reference-impl-sync>^1.0.40-0</readonly-copilot-sdk-ref-impl-version-from-lastmerge-file-updated-by-reference-impl-sync>
Comment thread
edburns marked this conversation as resolved.

</properties>

Expand Down
56 changes: 28 additions & 28 deletions scripts/codegen/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion scripts/codegen/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
"generate:java": "tsx java.ts"
},
"dependencies": {
"@github/copilot": "^1.0.39",
"@github/copilot": "^1.0.40-0",
"json-schema": "^0.4.0",
"tsx": "^4.20.6"
}
Expand Down
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 body for session.setForeground RPC call.
* <p>
* Using an explicit record type (rather than an ad-hoc map) ensures correct
* JSON serialization in all execution environments.
*
* @since 1.0.0
*/
public record SetForegroundSessionRequest(
/** The session ID to bring to the foreground. */
@JsonProperty("sessionId") String sessionId) {
}
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
import com.github.copilot.sdk.json.PreToolUseHookInput;
import com.github.copilot.sdk.json.PreToolUseHookOutput;
import com.github.copilot.sdk.json.SectionOverride;
import com.github.copilot.sdk.json.SetForegroundSessionRequest;
import com.github.copilot.sdk.json.SetForegroundSessionResponse;
import com.github.copilot.sdk.json.ToolBinaryResult;
import com.github.copilot.sdk.json.ToolResultObject;
Expand Down Expand Up @@ -86,6 +87,14 @@ void getForegroundSessionResponseRecord() {
assertEquals("/home/user/project", response.workspacePath());
}

// ===== SetForegroundSessionRequest record =====

@Test
void setForegroundSessionRequestRecord() {
var request = new SetForegroundSessionRequest("session-123");
assertEquals("session-123", request.sessionId());
}

// ===== SetForegroundSessionResponse record =====

@Test
Expand Down
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