MCPcopy Create free account
hub / github.com/github/copilot-sdk / GetForegroundSessionID

Method GetForegroundSessionID

go/client.go:1389–1405  ·  view source on GitHub ↗

GetForegroundSessionID returns the ID of the session currently displayed in the TUI. This is only available when connecting to a server running in TUI+server mode (--ui-server). Returns nil if no foreground session is set. Example: sessionID, err := client.GetForegroundSessionID() if err != nil

(ctx context.Context)

Source from the content-addressed store, hash-verified

1387// fmt.Printf("TUI is displaying session: %s\n", *sessionID)
1388// }
1389func (c *Client) GetForegroundSessionID(ctx context.Context) (*string, error) {
1390 if err := c.ensureConnected(ctx); err != nil {
1391 return nil, err
1392 }
1393
1394 result, err := c.client.Request(ctx, "session.getForeground", getForegroundSessionRequest{})
1395 if err != nil {
1396 return nil, err
1397 }
1398
1399 var response getForegroundSessionResponse
1400 if err := json.Unmarshal(result, &response); err != nil {
1401 return nil, fmt.Errorf("failed to unmarshal getForeground response: %w", err)
1402 }
1403
1404 return response.SessionID, nil
1405}
1406
1407// SetForegroundSessionID requests the TUI to switch to displaying the specified session.
1408//

Callers 1

TestClientAPIE2EFunction · 0.95

Calls 2

ensureConnectedMethod · 0.95
RequestMethod · 0.45

Tested by 1

TestClientAPIE2EFunction · 0.76