Skip to content

BB-16: Show agent thread title and chat link in task comments - #746

Merged
SawyerHood merged 2 commits into
mainfrom
bb/bb-16-agent-titles-and-thread-links-in-comments-thr_rqd2ny55f3
Jul 16, 2026
Merged

SawyerHood merged 2 commits into
mainfrom
bb/bb-16-agent-titles-and-thread-links-in-comments-thr_rqd2ny55f3

Conversation

@SawyerHood

Copy link
Copy Markdown
Collaborator

Summary

Agent-authored task comments used to render the raw thread id (agent (thr_...)) with no way to open the chat. They now show the authoring thread's current human title as a link that opens the chat, with safe fallbacks.

Changes

  • Contract (shared/contract.ts): new displayCommentSchema extends commentSchema with threadTitle: string | null, used for the listComments output only. The stored comment shape is unchanged; threadId was already persisted.
  • Server (api/index.ts): listComments resolves the title at read time via bb.sdk.threads.get, deduped per thread id. A thread contributes no title (callers fall back to authorName, no link) when it is deleted/hidden/inaccessible or a side chat (originKind/legacy childOrigin === "side-chat"). Picks the first non-blank of title/titleFallback so a whitespace-only primary title can't suppress a useful fallback.
  • UI (views/activity/comment-author.tsx, time.ts, task-activity.tsx): commentByline decides link vs. text; CommentAuthor (SDK-free) renders the title as a navigate.toThread(threadId) link only when a title resolves. System/user comment rendering is unchanged.
  • CLI parity (cli/index.ts): bb tasks show --json includes threadTitle per comment; the human-readable Comments table shows the resolved title.

Design decisions (task was underspecified)

  • Title is resolved live (not from a snapshot) so renames are reflected.
  • Hidden/side-chat/deleted/inaccessible threads never leak a title or link — matching the "don't expose hidden threads" requirement and the plugin's existing authorization boundary (bb.sdk.threads.get).
  • Legacy agent comments with no threadId, plus user/system comments, fall back to the stored authorName.

Tests

  • api/api.test.ts: live title, fallback-only, blank primary title → fallback, side chat (originKind) → null, legacy childOrigin side chat → null, missing thread → null, legacy no-thread → null, user → null, and one threads.get per distinct thread.
  • views/activity/comment-author.test.tsx: rendered jsdom test — linked button name, exact navigate.toThread("thr_worker") on click, and user/unresolved non-link fallbacks.
  • views/activity/activity.test.ts: commentByline branch coverage.

Validation

  • turbo run typecheck build test --filter=bb-plugin-tasks — all green; 153 tests passed.

Known tradeoff (non-blocking)

listComments fans out one bb.sdk.threads.get per distinct agent thread on each read (deduped). The count equals the number of distinct agent threads on a task — typically a small handful — so no bounded-concurrency/cache layer was added; a short-lived cache would risk stale titles after a rename. Revisit if tasks accrue many distinct agent threads.

🤖 Generated with Claude Code

SawyerHood and others added 2 commits July 16, 2026 10:03
Agent-authored task comments rendered the raw thread id ("agent (thr_...)")
and never linked to the chat. Resolve the thread's current human title at
read time in the listComments handler and render it as a link that opens the
chat, with safe fallbacks.

- Add threadTitle to the listComments output (displayCommentSchema); the
  stored comment shape is unchanged and threadId was already persisted.
- Resolve titles live via bb.sdk.threads.get, deduped per thread id;
  deleted/hidden/inaccessible threads leave no title so callers fall back to
  the stored authorName without leaking a thread.
- UI byline links via navigate.toThread only when a title resolves; system
  and user comment rendering is unchanged.
- CLI parity: bb tasks show surfaces the resolved title (JSON + table).
- Tests: contract/server enrichment + byline fallback logic.

Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
…add rendered UI test

- resolveAgentThreadTitles now skips side-chat threads (originKind or legacy
  childOrigin === "side-chat") so internal conversations never surface a
  title/link through an ordinary comment.
- Pick the first non-blank title candidate so a whitespace-only primary title
  no longer suppresses a useful titleFallback.
- Extract CommentAuthor into an SDK-free module and add a rendered jsdom test
  asserting the linked button name, the exact navigate.toThread(threadId)
  click, and the user/unresolved non-link fallbacks.
- Extend the listComments contract test with side-chat (both variants) and
  blank-primary-title cases.

Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
@SawyerHood
SawyerHood merged commit 8be534a into main Jul 16, 2026
10 checks passed
@SawyerHood
SawyerHood deleted the bb/bb-16-agent-titles-and-thread-links-in-comments-thr_rqd2ny55f3 branch July 16, 2026 18:01
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