Repository navigation
Support child threads whose parent lives in another project - #1849
Conversation
|
🚨 SLOP COP 🚨 · I am the SlopCop. I am reviewing this pull request for security, code quality, performance, architecture, and end-to-end behavior. I will post one final review after the parallel checks finish. |
Agents delegate work across repositories, but thread creation rejected a parent from a different project with 400 parent_thread_invalid (wrong_project). Relax the hierarchy check while keeping the parent's permission ceiling; forks and side chats stay same-project. Sidebar: "By project" now files each thread under its root ancestor's project so a cross-project child stays nested under its parent, and the row shows a FolderExport marker with an "In project <name>" tooltip. Thread detail lists children by parent only and routes parent links through the parent's own project. `bb status` lists cross-project children. Fixes #1711 Co-Authored-By: Claude <[email protected]>
Co-Authored-By: Claude <[email protected]>
7d71cfd to
5b2f88d
Compare
Co-Authored-By: Claude <[email protected]>
| if (effectivePinnedThreadIds.has(thread.id)) continue; | ||
| const existing = grouped.get(thread.projectId); | ||
| // Cross-project children render under their parent's project group. | ||
| const sidebarProjectId = resolveSidebarProjectId(thread, threadById); |
There was a problem hiding this comment.
🚨 slopcop/review — The sidebar can hide the selected cross-project child.
This code groups the child under the root parent project.
The selection effect still expands selectedThread.projectId at line 345.
If the root project is collapsed, direct navigation selects a hidden row.
Use the resolved sidebar project for selection expansion.
Add a collapsed-project test.
| return useQuery<ThreadListResponse>({ | ||
| queryKey: | ||
| enabled && parentThreadId | ||
| ? threadListQueryKey({ archived: false, parentThreadId }) |
There was a problem hiding this comment.
🚨 slopcop/review — Unrelated project changes refetch every active child list.
This parent-only key enters the global thread-list family.
Realtime logic invalidates all global keys after a change in any project.
Each active detail pane then sends a new child request.
Use a dedicated child-list key.
Invalidate only the changed thread's current or previous parent.
| thread: ThreadListEntry, | ||
| threadById: ReadonlyMap<string, ThreadListEntry>, | ||
| ): string { | ||
| const visitedThreadIds = new Set<string>([thread.id]); |
There was a problem hiding this comment.
🚨 slopcop/review — Root-project resolution repeats work for every thread.
ProjectList calls this helper for each thread.
The helper allocates a Set and repeats ancestor walks.
At 32,767 depth-four threads, the measured pass took 17.58 ms before the ID map.
Cache resolved root projects and reuse ancestor results.
The code already limits the hierarchy to four levels.
| aria-label={crossProjectLabel} | ||
| // Sits above the row's full-size link so it can take hover; | ||
| // nudged 1px down so the glyph reads centered on the text. | ||
| className="relative top-px z-10 flex shrink-0 items-center text-muted-foreground" |
There was a problem hiding this comment.
🚨 slopcop/review — A click on the project marker does not open the thread.
The z-10 sibling sits above the full-row link.
A pointer click on the marker opens no thread.
Make the marker part of the link, or forward the row navigation.
Add a marker-click test.
There was a problem hiding this comment.
🚨 SLOP COP 🚨 · review
Plain English summary
This PR lets an agent create a child thread in one project while its parent stays in another.
The child keeps its own project and workspace.
The sidebar nests the child under its parent and marks the child's project.
Findings
-
Medium: The sidebar expands the child's project, but it renders the child under the root parent's project.
A collapsed root project can therefore hide the selected row.
-
Medium: Each active child-list query uses the global thread-list family.
An unrelated project change can refetch every active child list.
-
Medium: Project grouping resolves the root project separately for every thread.
The measured pass took 17.58 ms for 32,767 depth-four threads, before the new ID-map cost.
-
Medium: The cross-project marker sits above the row link.
A click on the marker does not open the thread.
Architecture
The sidebar computes ancestry during project grouping, selection expansion, and tree construction.
A shared ancestry map can remove this duplication and prevent policy differences.
Security and verification
I found no security issue.
-
All 54 focused server tests passed.
-
All 106 focused app tests passed.
-
The app, server, and SDK Turbo typechecks passed.
-
git diff --checkpassed. -
The browser test created a parent and child in separate projects.
-
Both agents completed, and the child used the correct child-project worktree.
-
The browser showed correct nesting, the project marker, the child route, and the parent route.
The final GPT-5.6 review gate confirmed all four issues.
I posted this as a comment-only review. I did not approve or request changes.
…p, forward marker clicks - Selection auto-expand now targets the project group that renders the selected thread (its root ancestor's project), so a directly opened cross-project child is never hidden under a collapsed group. - createSidebarProjectIdResolver memoizes ancestor walks per sidebar pass. - A click on the cross-project marker forwards to the row link so it opens the thread instead of being a dead zone. Co-Authored-By: Claude <[email protected]>
|
Addressed three of the four SlopCop findings in dad17e9:
The child-list query-key finding (global thread-list family invalidation) is real but pre-dates this PR in shape (
|
What was wrong
assertValidParentThreadcompared the parent'sprojectIdwith the new thread'sprojectIdand threw400 parent_thread_invalid(wrong_project). An agent that ranbb thread spawn --project <other> --parent-selffrom a thread in another repository could not create the child, and so the child could not report back to its parent. Cross-project delegation was blocked end to end. Issue #1711.What changed
Server
apps/server/src/services/threads/thread-parent.ts:assertValidParentThreadandisLiveParentThreadno longer compare projects.wrong_projectis removed fromparentThreadInvalidReasonSchemainpackages/server-contract/src/errors.tsand from the app copy inlifecycle-errors.ts. Forks and side chats stay same-project throughrequireLiveSourceThread. Reparent viaPATCH /threads/:idgets the same relaxation.thread-default-policy.ts: the permission ceiling stays cross-project (a child in project B still clamps to its parent's mode). A cross-project child gets its own project's managed worktree by default and never reuses a personal parent environment from another project.packages/sdk/src/areas/status.ts:bb statuslists children by parent only, so cross-project children appear.HOST_DAEMON_PROTOCOL_VERSIONbump.App
projectThreadGroups.ts: newresolveSidebarProjectIdfiles each thread under its root ancestor's project.ProjectList.tsxuses it, so a cross-project child stays nested under its parent in "By project" mode and does not appear as a root in its own project group.ThreadRow.tsx: new requiredcrossProjectIdprop. When set, the row shows aFolderExportmarker after the title (nudged 1px down to sit on the text) with a Radix tooltip "In project ".ProjectRow.tsxalways routes and keys drafts by the thread's own project and passes the parent's project down the tree.ThreadDetailView.tsx: children query by parent only (useChildThreads); parent links route through the parent's own project.ThreadMetadataContent.tsxgetsparentThreadProjectIdfor the same reason.icon.tsx:FolderExportregistered. New Ladle story "parent with a child from another project".Docs
bb-guide-threads.md: a parent may live in another project;--parent-selfworks with a different--project.Deliberate semantics
How you verified
Tests added (fail before, pass after):
thread-parent.test.ts: a live parent from another project is accepted.thread-default-policy.test.ts: cross-project child keeps the parent's permission ceiling; gets a managed worktree; does not reuse a foreign personal environment.public-thread-parenting.test.ts: create + reparent across projects, list by parent returns both children, sidebar bootstrap files the child under its own project.projectThreadGroups.test.ts:resolveSidebarProjectIdroot-ancestor, orphan fallback, cycle guard.ThreadRow.test.tsx: marker present with project name and outside the trailing slot, route uses the child's project; no marker for same-project rows.Commands:
pnpm exec turbo run typecheck --filter=@bb/app --filter=@bb/server --filter=@bb/sdk --filter=@bb/shared-ui --filter=@bb/server-contract --filter=@bb/cli --filter=@bb/templates— passtest/threads,public-thread-parenting,public-threads.defaults,public-thread-data— 332 passed; server-contract — 57 passedcomponents/sidebar,views/thread-detail,hooks/queries— 451 passedturbo lint --filter=@bb/app— 147 warnings, same asmain(0 new)Manual (dev app + dev-browser): created projects
apiandweb; spawned a parent inapiand a child inwebwith--parent-thread(was a 400). The child ran in awebworktree, shows nested under its parent with the marker and "In project web" tooltip, and reportedchild-completedto the parent.bb statusfrom the parent lists both children.Fixes #1711