diff --git a/packages/convex/convex/lib/teamReadKeyHttp.ts b/packages/convex/convex/lib/teamReadKeyHttp.ts index 57a43759e8..68a2dcd27c 100644 --- a/packages/convex/convex/lib/teamReadKeyHttp.ts +++ b/packages/convex/convex/lib/teamReadKeyHttp.ts @@ -14,6 +14,10 @@ // and a known key is charged before its parameters are read. Both limiters // fail closed. // +// Each session carries transcript_messages: the count of every message in its +// transcript, so the person's prompts, the agent's replies and tool results +// all add to it. The team feed shows the same count at every sharing level. +// // Answers 200 { sessions, next_cursor }; 400 for a bad parameter or cursor; // 401 for a missing, unknown, revoked or expired key; 429 over a limit. import { httpAction } from "../_generated/server"; diff --git a/packages/convex/convex/teamReadKeys.test.ts b/packages/convex/convex/teamReadKeys.test.ts index d7e33c6fa0..cf1b824ff0 100644 --- a/packages/convex/convex/teamReadKeys.test.ts +++ b/packages/convex/convex/teamReadKeys.test.ts @@ -118,7 +118,7 @@ describe("team read keys", () => { test("rows are the team floor at each member's level, metadata only, without child sessions", async () => { const { t, ada, mo, hal, team, other, as } = await setup(); await session(t, ada, { team_id: team, title: "Ada shared", subtitle: "Ada summary", updated_at: NOW - HOUR }); - await session(t, mo, { team_id: team, title: "Mo work", subtitle: "Mo summary", updated_at: NOW - 2 * HOUR }); + await session(t, mo, { team_id: team, title: "Mo work", subtitle: "Mo summary", updated_at: NOW - 2 * HOUR, message_count: 42 }); await session(t, hal, { team_id: team, title: "Hal hidden" }); await session(t, ada, { team_id: other, title: "Ada other team" }); await session(t, ada, { title: "Ada personal", is_private: true }); @@ -140,11 +140,13 @@ describe("team read keys", () => { title: "Ada shared", summary: "Ada summary", sharing: "full", + transcript_messages: 1, work_state: expect.any(String), started_at: new Date(NOW - 2 * HOUR).toISOString(), updated_at: new Date(NOW - HOUR).toISOString(), }, - expect.objectContaining({ title: "Mo work", summary: "Mo summary", sharing: "summary", owner: expect.objectContaining({ name: "Mo" }) }), + // The team feed shows a summary share's message count too. + expect.objectContaining({ title: "Mo work", summary: "Mo summary", sharing: "summary", transcript_messages: 42, owner: expect.objectContaining({ name: "Mo" }) }), expect.objectContaining({ title: "Assigned to Mo", sharing: "full", owner: expect.objectContaining({ id: String(mo) }), repo: null }), ]); for (const leak of SECRETS) expect(raw).not.toContain(leak); diff --git a/packages/convex/convex/teamReadKeys.ts b/packages/convex/convex/teamReadKeys.ts index 5d0b94b041..f28efdbcbf 100644 --- a/packages/convex/convex/teamReadKeys.ts +++ b/packages/convex/convex/teamReadKeys.ts @@ -199,6 +199,8 @@ export type TeamSessionRow = { summary: string | null; /** The level the owner shares this session with the team at. */ sharing: "summary" | "full"; + /** Every message in the transcript: the person's, the agent's and tool results. */ + transcript_messages: number; work_state: WorkState; started_at: string; updated_at: string; @@ -259,6 +261,7 @@ export const sessionsForKey = internalQuery({ title: (c.title_is_custom || c.subtitle !== undefined) && !needsHostedTitle(c) ? (c.title ?? null) : null, summary: c.subtitle ?? null, sharing: floor.contentVisible(c) ? "full" : "summary", + transcript_messages: c.message_count, work_state: (await classifier.classify(c)).work_state, started_at: new Date(c.started_at).toISOString(), updated_at: new Date(c.updated_at).toISOString(),