MCPcopy Index your code
hub / github.com/github/copilot-sdk / SetForegroundSessionID

Method SetForegroundSessionID

go/client.go:1417–1441  ·  view source on GitHub ↗

SetForegroundSessionID requests the TUI to switch to displaying the specified session. This is only available when connecting to a server running in TUI+server mode (--ui-server). Example: if err := client.SetForegroundSessionID("session-123"); err != nil { log.Fatal(err) }

(ctx context.Context, sessionID string)

Source from the content-addressed store, hash-verified

1415// log.Fatal(err)
1416// }
1417func (c *Client) SetForegroundSessionID(ctx context.Context, sessionID string) error {
1418 if err := c.ensureConnected(ctx); err != nil {
1419 return err
1420 }
1421
1422 result, err := c.client.Request(ctx, "session.setForeground", setForegroundSessionRequest{SessionID: sessionID})
1423 if err != nil {
1424 return err
1425 }
1426
1427 var response setForegroundSessionResponse
1428 if err := json.Unmarshal(result, &response); err != nil {
1429 return fmt.Errorf("failed to unmarshal setForeground response: %w", err)
1430 }
1431
1432 if !response.Success {
1433 errorMsg := "unknown error"
1434 if response.Error != nil {
1435 errorMsg = *response.Error
1436 }
1437 return fmt.Errorf("failed to set foreground session: %s", errorMsg)
1438 }
1439
1440 return nil
1441}
1442
1443// On subscribes to all session lifecycle events.
1444//

Callers 1

TestClientAPIE2EFunction · 0.95

Calls 2

ensureConnectedMethod · 0.95
RequestMethod · 0.45

Tested by 1

TestClientAPIE2EFunction · 0.76