Repository navigation
feat(spaces): Make Space Conversations children of the Lead - #4413
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
This comment has been minimized.
This comment has been minimized.
08b114f to
78a73e7
Compare
A Space's Conversations are now child agents of its Lead, so results, messageAgent, listAgents, Watches, stop, archive, and roll-ups work the same as for any parent. The Lead is the tree root of its Space, and a new top_level_conversation_id keeps per-work state, such as Participants, pins, and lists, on each of the Lead's children. The Lead starts work with startAgent, and startConversation is removed. A move into, out of, or between Spaces re-parents the Conversation and its subtree, and refuses to make private work public. A Lead has no cap on active children, its children count as roots for maxAgentDepth, and it hears a child's done as a Conversation note. Co-Authored-By: David Cramer <[email protected]>
…rtAgent Co-Authored-By: David Cramer <[email protected]>
Drop top_level_conversation_id. A Conversation in a Space has the Lead as its parent and its root, as in any agent tree, so Participants and access come from the Lead. A move rewrites the root of the moved subtree, and the migration does the same for existing Space work. Co-Authored-By: David Cramer <[email protected]>
A Space's members were a separate table. With the Lead as the root of every Space Conversation, they are now its Participants, like any agent tree. Creating a Space makes its Lead, joining adds a Participant, and leaving removes it. The migration makes a Lead for every Space and copies the old members onto it. The old table stays unused until a release without it is live. Co-Authored-By: David Cramer <[email protected]>
Co-Authored-By: David Cramer <[email protected]>
4386d35 to
d552342
Compare
The Lead transcript shows the Conversations it starts as child agent rows, like any parent. Drop the Lead page state that only the removed started Conversation card read.
…bers A person joins a Space before they post in it on the web. Before, only the Lead refused web posts from non-members, so a web post in a public Space Conversation made the poster a member. Co-Authored-By: David Cramer <[email protected]>
|
32 screenshot changes — 32 changed · 0 added · 0 removed Review screenshots in Frameshift Show 12 more changed screenshots14 more changed screenshots in Frameshift. |
A Lead heard a child's done as a quiet note, so it could not act on the result, and it broke the rule that a parent gets each child's result.
|
Make sure you clean up any loose ends here. Technically speaking, even things like configuration could actually be tied to the conversation rather than the space, but that's probably a future idea for us. |
…ead design (#4428) States where Spaces and the Lead are heading. A Space uses the core Conversation tree (parents, roots, Participants, access, stops, archives, Watches, updates), and only a few Space-specific layers sit on top of it. - `design/spaces.md` is rewritten. The Lead is the root of the Space's tree. Every Space Conversation, whether the Lead starts it, a person starts it in the Space, or a person moves it in, is a child of the Lead and has the Lead as its root. Children inherit the Lead's Participants. Archive and snooze act per child. The file lists the Space layers explicitly: metadata, membership, configuration, the Lead's prompt and tools, moves, and rendering (the sidebar, the Threads panel, and top-level lists). - `design/lead.md` is new. It covers the Lead's role, its curated manager tool set (it runs Threads, reads, plans, and asks people, and it never writes or runs code), and the Turn gates: explicit reply on child and Event Turns, quiet `done` updates, and child results as claims. Gaps record what is not on main yet. - `design/agent-teams.md`: a Lead's team is its Space, and the Lead gaps move to `lead.md`. - `design/child-agents.md`: removes contradictions with Spaces. A move changes a child's parent, a moved Conversation delivers to its own Location, and the 8-child limit does not apply to a Lead's children. - `TERMINOLOGY.md`: updates Lead, Space, Thread, Team, Delivery, and Participant, and adds Top-level Conversation (derived, not stored). Related: #4377 (`thread` kind), #4411 and #4414 (moves), #4416 (Threads panel). #4413 edits some of the same lines. After this merges, it should drop those doc changes and delete only the gaps it closes. <!-- junior-request-attribution:start --> via @dcramer. <!-- junior-request-attribution:end --> <!-- junior-session-footer:start --> <!-- junior-conversation-id:local%3Aweb%3A56172fc7761dc3a4c09f6bc7 --> -- [View Session](https://junior-prod.sentry.dev/conversations/local%3Aweb%3A56172fc7761dc3a4c09f6bc7) [[Sentry]](https://sentry.sentry.io/explore/conversations/local%3Aweb%3A56172fc7761dc3a4c09f6bc7/?project=4510944073809921) <!-- junior-session-footer:end --> --------- Co-authored-by: sentry-junior[bot] <264270552+sentry-junior[bot]@users.noreply.github.com> Co-authored-by: David Cramer <[email protected]>
# Conflicts: # design/agent-teams.md # design/child-agents.md # packages/junior-evals/evals/agent/lead.eval.ts
…per Conversation A Thread that the grouping puts in Needs you because its tree waits on the viewer now shows that icon, even when its own run failed or is blocked. The Threads panel gets a key per Conversation, so an open Done group does not stay open on the next Conversation.
|
Will this also fix all existing conversations in a space so they roll up to the lead |
|
Yes. The migration (
There are two exceptions, and both leave the Space and stay one-off roots:
|
A `messageAgent` call showed as a generic tool call, so you could not easily see what one agent told another. It now shows as a compact message row. A message from another agent (`agent.message`, `agent.top_level_message`) uses the same row, so the two read as a pair in the Lead and in other Conversations. - One component renders the row the same in every Conversation. There is no Lead-only path. - Direction cue: ↗ "To" for sent, ↙ "From" for received. - The other Conversation's title links to it. The title comes from data the page already holds: the feed list, then the agent tree (including the parent of a pending message to `parent`), then the Conversations that the transcript started (the starting call's title, or its Threads and Tasks). When none of them names it, the row shows "Conversation". No API change, so no title of a Conversation the viewer cannot read leaks. - Delivery state comes from the tool result: `started` → Delivered, `queued` → Queued, `noted` → Saved as a note, a failed call → Refused, running → Sending. - Long text is clamped with the existing `ClampedDisplayText`. Sent and received messages never fold into activity groups. - The received row strips the `<agent-message>` tag that core writes for the model. The child's "Parent agent" input message does not change. - Core change: `isAgentMessageEventType` and the top-level message event type constant now live in `result-event-type.ts`, so the dashboard can import them. - The dashboard first-load bundle baseline goes up 1.3 KB gzip (622.7 → 624.0 KB) for the new rows. ### Normal conversation | | Desktop | Phone | | --- | --- | --- | | Dark |  |  | | Light |  |  | ### Lead | | Desktop | Phone | | --- | --- | --- | | Dark |  |  | | Light |  |  | ### Screenshot changes The 4 added Frameshift shots are `conversation-agent-messages`. 29 of the changed shots come from the new mock rows. The Dashboard QA root (`conversation-*`, `push-notifications-tip*`) has 4 more transcript rows. The Billing migration Lead (`space-lead*`, `space-threads*`, `space-edit*`, `space-pane-menu*`, `space-page`) has a sent message and a received reply. Each pinned transcript now scrolls to a different place. Nothing else in these pages changed. `conversation-unsent-answers` also changed. Its Conversation has no agent messages, and only the scroll position differs. #4177 lists this shot as one that changes on PRs that do not touch it. ### Coordination - #4413: this PR builds on `main` and does not touch `types.ts`. It edits `TranscriptActivityGroup.tsx`, `ConversationTranscript.tsx`, and `mock-reporting/lead-transcript.ts` close to #4413's edits but outside its hunks. - Threads panel (`feat/space-threads-panel`): none of its files change. Its `space-threads*` shots change only because the Lead transcript scrolls to a different place. <!-- junior-request-attribution:start --> via @dcramer. <!-- junior-request-attribution:end --> <!-- junior-session-footer:start --> <!-- junior-conversation-id:agent%3A29ac73b21100f02ba9fd1acfbc7506f4 --> -- [View Session](https://junior-prod.sentry.dev/conversations/agent%3A29ac73b21100f02ba9fd1acfbc7506f4) [[Sentry]](https://sentry.sentry.io/explore/conversations/agent%3A29ac73b21100f02ba9fd1acfbc7506f4/?project=4510944073809921) <!-- junior-session-footer:end --> --------- Co-authored-by: sentry-junior[bot] <264270552+sentry-junior[bot]@users.noreply.github.com> Co-authored-by: David Cramer <[email protected]>
A Lead's child counts as a root for limits.maxAgentDepth, and the depth check in spawn.ts already allows it. The tool binding did not know that, so with depth 0 such a child never got startAgent. The run now passes whether its Conversation is top-level work. Co-Authored-By: David Cramer <[email protected]>
| and listed_lead.space_id is not null | ||
| ))`, | ||
| )!; | ||
| } |
There was a problem hiding this comment.
Space feed rows cannot be pinned
High Severity
Lead children now appear in top-level lists and the personal feed, but pinning still rejects any Conversation with a parent. Pinning or unpinning Space work from the feed fails, and already-pinned migrated Space Conversations cannot be unpinned.
Additional Locations (1)
Reviewed by Cursor Bugbot for commit b2b20b1. Configure here.
There was a problem hiding this comment.
Deferred. Whether a Space Conversation gets its own Pin, or none, waits on the membership question in #4413 (comment).
| * Archive the tree for everyone when no Participant still has it in their | ||
| * feed. Returns the archive time, or null when a subscriber remains. Runs | ||
| * under the root's row lock. | ||
| * under the root's row lock. A Lead's tree is its whole Space, which only |
There was a problem hiding this comment.
Unsubscribe hits the Lead instead
High Severity
Unsubscribing or leaving a Space Conversation resolves to the Lead and writes unsubscribedAt on the Space membership row. The feed filter still checks a participant row on the child, which members do not have, so the Conversation stays in the feed and the Lead is the row that was unsubscribed.
Additional Locations (2)
Reviewed by Cursor Bugbot for commit b2b20b1. Configure here.
There was a problem hiding this comment.
Deferred. This is the same open question as #4413 (comment): does a Space Conversation get its own Leave and Unsubscribe, or do you leave the Space? 34a9c0c10 already stops this path from archiving the Space.
Co-Authored-By: David Cramer <[email protected]> # Conflicts: # TERMINOLOGY.md # design/agent-teams.md # design/spaces.md
The Participants of a Lead are its Space's members, and a person joins a Space on purpose. A mention in a public Space's work added the mentioned person as a Participant of the Lead, which made them a member without Join. Mentions in a Space now add nobody, on the dashboard and in Slack.
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes using default effort and found 2 potential issues.
There are 5 total unresolved issues (including 3 from previous reviews).
❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.
Reviewed by Cursor Bugbot for commit 7ec7c26. Configure here.
#4413 merged into main, so this PR now targets main.
| import type { User } from "@sentry/junior-plugin-api"; | ||
| import { and, asc, desc, eq, gte, isNull, ne, sql } from "drizzle-orm"; | ||
| import { and, asc, desc, eq, gte, ne, sql } from "drizzle-orm"; | ||
| import { topLevelConversation } from "@/chat/conversations/sql/listed"; |
There was a problem hiding this comment.
Location aggregates omit Space children from their own destination
A public conversation moved from a Slack location into a Space is included by the new top-level filter, but the location aggregate joins tree rows rooted at the conversation’s own ID; Space rows instead root at the Lead. The Slack location therefore omits the conversation, while its tree usage is grouped under the Lead’s local destination, and its detail endpoint can return 404.
Evidence
topLevelConversation()matches direct children of a Lead with a non-nullspace_id.- The migration sets moved work’s
root_conversation_idto the Lead and makes it a Lead child without changing its destination, so a moved Slack conversation qualifies for its Slack location but its tree rows are rooted at the Lead. directoryRowsand the location detail aggregate queries inner-jointreeConversation.rootConversationIdto the selected conversation’sconversationId. That join finds no rows for the Space child; the Lead’s row instead aggregates the tree under the Lead’s destination.recentLocationRowsuses the top-level filter without that tree join, but detail returnsundefinedwhen no aggregate location exists, so a location containing only such a conversation can return 404.
Identified by Warden · code-review · D4Q-7BV
| .where(work); | ||
| await db | ||
| .update(juniorConversations) | ||
| .set({ | ||
| parentConversationId: target?.leadConversationId ?? null, | ||
| // A Lead's children are its child agents. | ||
| ...(target | ||
| ? { | ||
| agentConfig: sql`coalesce(${juniorConversations.agentConfig}, '{}'::jsonb)`, | ||
| } | ||
| : undefined), | ||
| detailVersion: nextDetailVersion, | ||
| }) | ||
| .where(eq(juniorConversations.conversationId, conversationId)); |
There was a problem hiding this comment.
Detaching Lead-created Space work leaves the mover without participation
When a user moves a Conversation created as a Lead child out of its Space, the move makes it a root without copying the user's Participant row from the Lead. The mover then cannot stop, rename, archive, or move it again, and it drops out of their member feed unless they later post and create a Participant row.
Evidence
- Space work is created with the Lead as its parent (
packages/junior/src/chat/conversations/web-input.ts);SqlStore.upsertConversationrecords the actor as a Participant only whenparentConversationId === null, while participant writes resolve a child to its root. setConversationSpace(..., null, ...)changes the subtree root to the moved Conversation and clears its parent, but does not create Participant rows. The API permits moving a direct Lead child out of the Space.- After detaching,
conversationAccessFromRowsconsiders a parentless Conversation a Participant only when the viewer has a Participant row for that Conversation. Stop, rename, archive, and further moves require that status; member-feed filtering also relies on Participant rows.
Identified by Warden · code-review · EBQ-9DK
| @@ -235,41 +299,40 @@ export async function leaveSpace( | |||
| .from(juniorSpaces) | |||
| .where(eq(juniorSpaces.id, spaceId)) | |||
| .for("update"); | |||
| const member = and( | |||
| eq(juniorSpaceMembers.spaceId, spaceId), | |||
| eq(juniorSpaceMembers.userId, userId), | |||
| ); | |||
| const lead = inArray(participants.rootConversationId, spaceLeadId(spaceId)); | |||
| if (space?.visibility === "private") { | |||
| const members = await db | |||
| .select({ userId: juniorSpaceMembers.userId }) | |||
| .from(juniorSpaceMembers) | |||
| .where(eq(juniorSpaceMembers.spaceId, spaceId)) | |||
| .select({ userId: participants.userId }) | |||
| .from(participants) | |||
| .where(lead) | |||
| .limit(2); | |||
| if (members.length === 1 && members[0]!.userId === userId) { | |||
| return "last_member"; | |||
| } | |||
| } | |||
| await db.delete(juniorSpaceMembers).where(member); | |||
| // Leaving ends membership, so the row goes, not only the feed entry. | |||
| await db | |||
| .delete(participants) | |||
| .where(and(lead, eq(participants.userId, userId))); | |||
| return undefined; | |||
| }); | |||
There was a problem hiding this comment.
Space membership changes do not invalidate Lead details for former authors
When a Space member who authored a Lead message leaves or is re-added, the Lead’s participants payload changes but joinSpace and leaveSpace do not bump its detail version. Other members can therefore keep the stale payload after a detail poll returns 304.
Evidence
joinSpaceinserts or upserts a participant row, andleaveSpacedeletes one; neither callstouchConversationDetail.readParticipantRowsincludes Lead event authors only while their user has a participant row.readConversationAuthorssupplies that list to the Lead detail report, so removing or restoring a former author changes itsparticipantspayload.- The detail version token covers subtree
detailVersionvalues and the requesting viewer’s state, not other members’ participant rows. For another member, the ETag stays unchanged, and the detail route returns 304 when it matches.
Identified by Warden · code-review · FV6-3TC


Every Conversation in a Space is now a child of that Space's Lead, so the normal parent-child behavior applies to Space work: results go back to the Lead, and the Lead can
messageAgent,listAgents, watch, stop, archive, and roll up its children.Why: a Lead started Space work as separate roots that stored no link to it, so it could not stop or archive that work, and results did not come back to it. Space work now uses the same tree as every other agent's child agents.
Tree model
This is the normal parent-child tree. A Conversation in a Space has
parent_conversation_id= the Space's Lead, and the Lead is theroot_conversation_idof every Conversation in its Space, at any depth. No column is added. Only the Lead storesspace_id, and a Conversation reads the Space of its root (rootSpaceIdSql). State that keys on the root, such as Participants and access, comes from the Lead, so the Space's Conversations inherit it as any child agent does. Top-level Space work means a Lead's direct child (topLevelConversation: no parent, or a parent that is a Lead).Behavior
startAgent.startConversationis gone: the tool, its registry entry, the Lead prompt lines, the dashboard transcript card, and its evals. The Lead transcript shows its children as child agent rows, as any parent's does. A person who starts work directly in a Space also makes a child of the Lead, run as that person.root_conversation_idbecomes the new Lead or the Conversation itself, and a move into a private Space makes the subtree private. A move of a private Conversation into a public Space is refused. The moved root's Participants, pins, and choices do not carry over to the Lead.maxAgentDepth.listAgentsis now a direct Lead tool.startConversationto a Lead'sstartAgent. Core marks the Lead's Run (context.leadon the proposal), and review adds the rule only forstartAgentin that Run. This matches thelead-memberrule in design/guardian.md, which stays as it is.Space roll-up query
readSpaceStates(the sidebar's roll-up from #4366) now reads the Lead and its direct children. A subquery finds the Leads of the listed Spaces throughjunior_conversations_space_lead_idx. The outer query reads the rows whose id is a Lead (primary key) or whose parent is a Lead (junior_conversations_parent_idx), unarchived and readable by the viewer, newest activity first, up to 200.readConversationTreeStatesthen covers each child's own child agents.Space membership
A Space's members are now the Participants of its Lead. The separate member table is no longer read or written.
joinedAtand orders by email.Migration
20261126033000_space_conversations_lead_children, data only:space_idjoins the Lead's tree:root_conversation_idbecomes the Lead for the root and all its child agents.space_idis cleared.junior_space_membersstays in the schema, unused. A later migration drops it once a release that does not use it is live, asmigration-locksrequires.During the deploy build, the live release runs against the new tree for minutes. In that window it reads a Space Conversation as a child of the Lead, so its Turns report to the Lead instead of their Location. A person who joins a Space through the old release in that window lands only in the old table.
Docs
design/spaces.md,design/child-agents.md, anddesign/agent-teams.mdget the confirmed text. Thedesign/agent-teams.mdgap "Agents use different tools…" stays as it is, anddesign/guardian.mddoes not change.TERMINOLOGY.mddefines "Top-level Conversation", updates the Lead, and defines a Member as a Participant of the Lead.policies/conversation-access.mdupdates the Lead write exception, the start line, and Space membership.via @dcramer.
--
View Session [Sentry]