From bb7a490f5cc6d817c1f4fa3b575e3133017eb7ee Mon Sep 17 00:00:00 2001 From: Admin Bot Date: Mon, 28 Sep 2026 18:43:00 +0800 Subject: [PATCH] =?UTF-8?q?fix(sessions):=20use=20entities=20query=20for?= =?UTF-8?q?=20list=20=E2=80=94=20hybridSearch=20requires=20project=20arg?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit hybridSearch mandates a project scope, but sessions scatter across per-session projects (session-). The entities query accepts optional project — omit it to list SESSION entities across all projects. Also adds projectId to the list response so callers can scope follow-up queries to the right session project. Fixes: GET X-Service:sessions X-Resource:sessions returning 502 --- internal/sessions/handler.go | 7 +++++-- internal/sessions/handler_test.go | 7 ++++++- 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/internal/sessions/handler.go b/internal/sessions/handler.go index e1e8be5..b51d346 100644 --- a/internal/sessions/handler.go +++ b/internal/sessions/handler.go @@ -180,9 +180,12 @@ func (h *Handler) handleList(w http.ResponseWriter, r *http.Request) { searchQuery = fmt.Sprintf("%s cwd:%s", searchQuery, cwd) } + // entities query (not hybridSearch) — project arg is optional, so it queries + // across ALL projects. Required because each session lives in its own + // session- project; there is no single project to hybridSearch against. gqlQuery := `query($q:String!,$limit:Int!){ - hybridSearch(query:$q,limit:$limit,entityType:SESSION){ - entities{id name summary tCreated} + entities(query:$q,limit:$limit,entityType:SESSION){ + entities{id name summary projectId tCreated} searchMode } }` diff --git a/internal/sessions/handler_test.go b/internal/sessions/handler_test.go index eab1b5c..437bb4a 100644 --- a/internal/sessions/handler_test.go +++ b/internal/sessions/handler_test.go @@ -18,7 +18,8 @@ import ( // "query" field and records captured request bodies. // // - "upsertEntity" → mutation response -// - "hybridSearch" → search response +// - "hybridSearch" → search response (get, patch, episodes handlers) +// - "entities" → list response (sessions list handler) // - "entity" → single entity response func newGQLServer(t *testing.T, captured *[]byte) *httptest.Server { t.Helper() @@ -33,7 +34,11 @@ func newGQLServer(t *testing.T, captured *[]byte) *httptest.Server { case strings.Contains(bs, "upsertEntity"): fmt.Fprint(w, `{"data":{"upsertEntity":{"id":"test-entity-id","created":true}}}`) case strings.Contains(bs, "hybridSearch"): + // get, patch, episodes handlers still use hybridSearch fmt.Fprint(w, `{"data":{"hybridSearch":{"entities":[]}}}`) + case strings.Contains(bs, "entities"): + // sessions list handler uses entities query + fmt.Fprint(w, `{"data":{"entities":{"entities":[]}}}`) case strings.Contains(bs, "entity"): fmt.Fprint(w, `{"data":{"entity":null}}`) default: