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

Method GetLastSessionID

go/client.go:1357–1373  ·  view source on GitHub ↗

GetLastSessionID returns the ID of the most recently updated session. This is useful for resuming the last conversation when the session ID was not stored. Returns nil if no sessions exist. Example: lastID, err := client.GetLastSessionID(context.Background()) if err != nil { log.Fatal(err)

(ctx context.Context)

Source from the content-addressed store, hash-verified

1355// })
1356// }
1357func (c *Client) GetLastSessionID(ctx context.Context) (*string, error) {
1358 if err := c.ensureConnected(ctx); err != nil {
1359 return nil, err
1360 }
1361
1362 result, err := c.client.Request(ctx, "session.getLastId", getLastSessionIDRequest{})
1363 if err != nil {
1364 return nil, err
1365 }
1366
1367 var response getLastSessionIDResponse
1368 if err := json.Unmarshal(result, &response); err != nil {
1369 return nil, fmt.Errorf("failed to unmarshal getLastId response: %w", err)
1370 }
1371
1372 return response.SessionID, nil
1373}
1374
1375// GetForegroundSessionID returns the ID of the session currently displayed in the TUI.
1376//

Callers 2

TestClientAPIE2EFunction · 0.95
TestSessionE2EFunction · 0.95

Calls 2

ensureConnectedMethod · 0.95
RequestMethod · 0.45

Tested by 2

TestClientAPIE2EFunction · 0.76
TestSessionE2EFunction · 0.76