Address review feedback

- Replace Thread.sleep with sendAndWait in PRVisualization
- Fix top-level statements in multiple-sessions.md (wrap in class)
- Fix .getMessage() → .getData().content() in MultipleSessions.java
- Guard against null readLine() in AccessibilityReport.java
- Add null-safe getCause() + InterruptedException handling in ErrorHandling.java
- Fix paths: jbang commands now include recipe/ prefix
- Fix root README path: cd java/recipe (not java/cookbook/recipe)
- Fix recipe/README.md ralph-loop CLI example
This commit is contained in:
Bruno Borges
2026-04-06 14:12:08 -04:00
parent 57b2799408
commit 0f06f346be
4 changed files with 32 additions and 38 deletions

View File

@@ -23,35 +23,35 @@ import com.github.copilot.sdk.json.*;
public class MultipleSessions {
public static void main(String[] args) throws Exception {
var client = new CopilotClient();
client.start().get();
try (var client = new CopilotClient()) {
client.start().get();
// Create multiple independent sessions
var session1 = client.createSession(new SessionConfig()
.setModel("gpt-5")
.setOnPermissionRequest(PermissionHandler.APPROVE_ALL)).get();
var session2 = client.createSession(new SessionConfig()
.setModel("gpt-5")
.setOnPermissionRequest(PermissionHandler.APPROVE_ALL)).get();
var session3 = client.createSession(new SessionConfig()
.setModel("claude-sonnet-4.5")
.setOnPermissionRequest(PermissionHandler.APPROVE_ALL)).get();
// Create multiple independent sessions
var session1 = client.createSession(new SessionConfig()
.setModel("gpt-5")
.setOnPermissionRequest(PermissionHandler.APPROVE_ALL)).get();
var session2 = client.createSession(new SessionConfig()
.setModel("gpt-5")
.setOnPermissionRequest(PermissionHandler.APPROVE_ALL)).get();
var session3 = client.createSession(new SessionConfig()
.setModel("claude-sonnet-4.5")
.setOnPermissionRequest(PermissionHandler.APPROVE_ALL)).get();
// Each session maintains its own conversation history
session1.sendAndWait(new MessageOptions().setPrompt("You are helping with a Python project")).get();
session2.sendAndWait(new MessageOptions().setPrompt("You are helping with a TypeScript project")).get();
session3.sendAndWait(new MessageOptions().setPrompt("You are helping with a Go project")).get();
// Each session maintains its own conversation history
session1.sendAndWait(new MessageOptions().setPrompt("You are helping with a Python project")).get();
session2.sendAndWait(new MessageOptions().setPrompt("You are helping with a TypeScript project")).get();
session3.sendAndWait(new MessageOptions().setPrompt("You are helping with a Go project")).get();
// Follow-up messages stay in their respective contexts
session1.sendAndWait(new MessageOptions().setPrompt("How do I create a virtual environment?")).get();
session2.sendAndWait(new MessageOptions().setPrompt("How do I set up tsconfig?")).get();
session3.sendAndWait(new MessageOptions().setPrompt("How do I initialize a module?")).get();
// Follow-up messages stay in their respective contexts
session1.sendAndWait(new MessageOptions().setPrompt("How do I create a virtual environment?")).get();
session2.sendAndWait(new MessageOptions().setPrompt("How do I set up tsconfig?")).get();
session3.sendAndWait(new MessageOptions().setPrompt("How do I initialize a module?")).get();
// Clean up all sessions
session1.destroy().get();
session2.destroy().get();
session3.destroy().get();
client.stop().get();
// Clean up all sessions
session1.destroy().get();
session2.destroy().get();
session3.destroy().get();
}
}
}
```