MCPcopy Index your code
hub / github.com/coder/coder / aiBridgeGetSessionThreads

Method aiBridgeGetSessionThreads

enterprise/coderd/aibridge.go:353–529  ·  view source on GitHub ↗

aiBridgeGetSessionThreads returns a single session with fully expanded threads including agentic actions and thinking blocks. @Summary Get AI Bridge session threads @ID get-ai-bridge-session-threads @Security CoderSessionToken @Produce json @Tags AI Bridge @Param session_id path string true "Sessio

(rw http.ResponseWriter, r *http.Request)

Source from the content-addressed store, hash-verified

351// @Success 200 {object} codersdk.AIBridgeSessionThreadsResponse
352// @Router /api/v2/aibridge/sessions/{session_id} [get]
353func (api *API) aiBridgeGetSessionThreads(rw http.ResponseWriter, r *http.Request) {
354 ctx := r.Context()
355
356 sessionIDParam := chi.URLParam(r, "session_id")
357 if sessionIDParam == "" {
358 httpapi.Write(ctx, rw, http.StatusBadRequest, codersdk.Response{
359 Message: "Missing session_id path parameter.",
360 })
361 return
362 }
363
364 // Parse optional pagination cursors.
365 var afterID, beforeID uuid.UUID
366 if v := r.URL.Query().Get("after_id"); v != "" {
367 var err error
368 afterID, err = uuid.Parse(v)
369 if err != nil {
370 httpapi.Write(ctx, rw, http.StatusBadRequest, codersdk.Response{
371 Message: "Invalid after_id query parameter.",
372 Detail: err.Error(),
373 })
374 return
375 }
376 }
377 if v := r.URL.Query().Get("before_id"); v != "" {
378 var err error
379 beforeID, err = uuid.Parse(v)
380 if err != nil {
381 httpapi.Write(ctx, rw, http.StatusBadRequest, codersdk.Response{
382 Message: "Invalid before_id query parameter.",
383 Detail: err.Error(),
384 })
385 return
386 }
387 }
388 if afterID != uuid.Nil && beforeID != uuid.Nil {
389 httpapi.Write(ctx, rw, http.StatusBadRequest, codersdk.Response{
390 Message: "Cannot use both after_id and before_id in the same request.",
391 })
392 return
393 }
394
395 var limit int32 = 50
396 if v := r.URL.Query().Get("limit"); v != "" {
397 parsed, err := strconv.ParseInt(v, 10, 32)
398 if err != nil || parsed < 1 || parsed > 200 {
399 httpapi.Write(ctx, rw, http.StatusBadRequest, codersdk.Response{
400 Message: "Invalid limit query parameter.",
401 Detail: "Limit must be between 1 and 200.",
402 })
403 return
404 }
405 limit = int32(parsed)
406 }
407
408 // Fetch session metadata by reusing the sessions list query
409 // with a session_id filter.
410 //nolint:exhaustruct // Let's keep things concise.

Callers

nothing calls this directly

Calls 15

WriteFunction · 0.92
AIBridgeSessionThreadsFunction · 0.92
ContextMethod · 0.65
GetMethod · 0.65
ParseMethod · 0.65
ListAIBridgeSessionsMethod · 0.65
InTxMethod · 0.65

Tested by

no test coverage detected