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");
+ }
+ }));
}
/**
diff --git a/src/main/java/com/github/copilot/sdk/json/SetForegroundSessionRequest.java b/src/main/java/com/github/copilot/sdk/json/SetForegroundSessionRequest.java
new file mode 100644
index 000000000..1c0087f68
--- /dev/null
+++ b/src/main/java/com/github/copilot/sdk/json/SetForegroundSessionRequest.java
@@ -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.
+ *
+ * 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) {
+}
diff --git a/src/test/java/com/github/copilot/sdk/E2ETestContext.java b/src/test/java/com/github/copilot/sdk/E2ETestContext.java
index 45fcbc0a5..3d9180bf9 100644
--- a/src/test/java/com/github/copilot/sdk/E2ETestContext.java
+++ b/src/test/java/com/github/copilot/sdk/E2ETestContext.java
@@ -249,6 +249,7 @@ public List