Skip to content

Allow cross-project sender attribution for thread messages - #235

Merged
SawyerHood merged 1 commit into
mainfrom
bb/fix-bb-thread-logging-thr_ajn56dtay6
Jun 18, 2026
Merged

SawyerHood merged 1 commit into
mainfrom
bb/fix-bb-thread-logging-thr_ajn56dtay6

Conversation

@SawyerHood

Copy link
Copy Markdown
Collaborator

Summary

bb thread tell <target> auto-attaches the caller's BB_THREAD_ID as senderThreadId. The shared send/queue resolver (resolveMessageSenderThreadId) rejected any sender whose project differed from the target's, so a worker thread in one project could not message a coordinator thread in another — it returned HTTP 400: Sender thread is invalid and forced an env -u BB_THREAD_ID workaround that dropped attribution entirely (losing the reply-back affordance).

This drops the cross-project guard so any thread can message any other thread with attribution preserved.

Changes

  • thread-send.ts — resolveMessageSenderThreadId no longer rejects cross-project senders (covers both the immediate-send and queued paths, which share this resolver). Existence and not-deleted checks remain so the reply target is a live thread.
  • lifecycle-api-errors.ts — narrowed throwSenderThreadInvalid's reason type to "deleted" | "not_found" since wrong_project is no longer a sender outcome.
  • public-thread-data.test.ts — flipped the regression test: a cross-project senderThreadId now queues the message (200) with the sender preserved, instead of returning 400.

The create/fork hierarchy guard (assertValidParentThread) is intentionally left project-scoped — that governs parent/fork structure (sidebar grouping, depth caps), not peer-to-peer messaging. The round-trip reply via bb thread tell {{senderThreadId}} now works bidirectionally across projects.

Tests

  • pnpm exec turbo run typecheck --filter=@bb/server — passes
  • pnpm exec turbo run test --filter=@bb/server -- public-thread-data — 59 passed

Risks

Low. Single-user local tool with no cross-tenant boundary; cross-project messaging is a deliberate workflow (coordinator/worker dispatcher pattern). Behavior change only takes effect once the updated server is running.

🤖 Generated with Claude Code

`bb thread tell <target>` auto-attaches the caller's BB_THREAD_ID as
senderThreadId. The shared send/queue resolver rejected a sender whose
project differed from the target's, so a worker thread in one project
could not message a coordinator thread in another (HTTP 400 "Sender
thread is invalid"), forcing an `env -u BB_THREAD_ID` workaround that
dropped attribution entirely.

Drop the cross-project guard in resolveMessageSenderThreadId (covers both
the immediate-send and queued paths). Existence and not-deleted are still
required so the reply target is a live thread, and the round-trip reply
via `bb thread tell {{senderThreadId}}` now works bidirectionally across
projects. The create/fork hierarchy guard (assertValidParentThread) is
intentionally left project-scoped.

Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
@SawyerHood
SawyerHood merged commit 5d75f81 into main Jun 18, 2026
6 checks passed
@SawyerHood
SawyerHood deleted the bb/fix-bb-thread-logging-thr_ajn56dtay6 branch June 18, 2026 21:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant