MCPcopy Index your code
hub / github.com/docker/docker-agent / GetSessionStatus

Method GetSessionStatus

pkg/server/session_manager.go:258–282  ·  view source on GitHub ↗

GetSessionStatus returns a lightweight snapshot of the session's current runtime state. Designed for late-joining SSE consumers that need to know the session's state without waiting for the next event transition.

(ctx context.Context, id string)

Source from the content-addressed store, hash-verified

256// runtime state. Designed for late-joining SSE consumers that need to know
257// the session's state without waiting for the next event transition.
258func (sm *SessionManager) GetSessionStatus(ctx context.Context, id string) (*api.SessionStatusResponse, error) {
259 rs, ok := sm.runtimeSessions.Load(id)
260 if !ok {
261 return nil, fmt.Errorf("session %s not found", id)
262 }
263
264 sess := rs.session
265
266 // Probe streaming state: TryLock succeeds only when no RunStream is
267 // in progress. Immediately unlock so we don't interfere.
268 streaming := !rs.streaming.TryLock()
269 if !streaming {
270 rs.streaming.Unlock()
271 }
272
273 return &api.SessionStatusResponse{
274 ID: sess.ID,
275 Title: sess.Title,
276 Streaming: streaming,
277 Agent: rs.runtime.CurrentAgentName(ctx),
278 InputTokens: sess.InputTokens,
279 OutputTokens: sess.OutputTokens,
280 NumMessages: len(sess.GetAllMessages()),
281 }, nil
282}
283
284// GetSessionSnapshot returns the full, self-contained state of a session: its
285// stored fields plus, when an active runtime is attached, its live runtime

Callers 1

getSessionStatusMethod · 0.80

Calls 4

LoadMethod · 0.80
GetAllMessagesMethod · 0.80
CurrentAgentNameMethod · 0.65
UnlockMethod · 0.45

Tested by

no test coverage detected