Skip to content

feat: reference other threads from the composer#4010

Draft
Brechard wants to merge 1 commit into
pingdotgg:mainfrom
Brechard:feature/thread-references
Draft

feat: reference other threads from the composer#4010
Brechard wants to merge 1 commit into
pingdotgg:mainfrom
Brechard:feature/thread-references

Conversation

@Brechard

@Brechard Brechard commented Jul 15, 2026

Copy link
Copy Markdown

What changed

  • Type # in the composer to search recently active threads in the current environment.
  • Insert a compact t3-thread reference chip instead of copying the referenced transcript into the prompt.
  • Render sent references as clickable chips that navigate back to the source thread.
  • Add a read-only, paginated thread_read MCP tool so an agent can fetch only the referenced context it needs.
  • Tell Codex sessions how to resolve t3-thread references through the local T3 Code MCP server.

Why

Long-running work is often split across planning, implementation, and debugging threads. Referencing the source thread lets a new conversation recover that context without manually restating the work or injecting an entire transcript up front.

This implements the use case described in #1286 while keeping prompt size bounded and transcript access explicit.

Closes #1286.

Design notes

  • # is intentionally separate from @ file mentions and $ skills.
  • The picker excludes the current thread and is limited to active threads in the same environment.
  • References use a compact t3-thread:///environment-id/thread-id URI carried in Markdown.
  • thread_read returns message text in bounded pages (40,000 characters by default, 80,000 maximum) and provides nextCursor for continuation.
  • The MCP tool is marked read-only, non-destructive, and idempotent.
  • Malformed references and cursors fail with typed errors.

Verification

  • pnpm exec vp check — passed with 0 errors
  • pnpm exec vp run typecheck — passed
  • Focused feature tests — 81 passed across 7 files
  • Full test suite — 4,619 passed across 586 files; 7 expected skips
  • React Doctor against upstream/main — no diagnostics in changed React files
  • git diff --check upstream/main...HEAD — passed

UI

This is opened as a draft so an interaction recording can be attached before marking it ready for review.

Note

Add thread reference support to the composer with # trigger and thread_read MCP tool

  • Adds a # trigger in the composer that opens a thread search menu, inserting a t3-thread:// link as an inline chip when a thread is selected.
  • Introduces a ComposerThreadNode Lexical decorator node that renders thread references as chips in the editor and serializes them as t3-thread:///env/thread markdown links.
  • Adds a thread_read MCP tool that fetches paginated thread transcripts, with cursor-based pagination and structured errors for not-found or unavailable threads.
  • Renders t3-thread links in chat markdown as clickable chips that navigate internally to the referenced thread instead of opening as external URLs.
  • Adds T3_CODE_THREAD_REFERENCE_INSTRUCTIONS to Codex developer instructions so the AI agent knows how to use thread references via thread_read.
📊 Macroscope summarized 9c63d4b. 16 files reviewed, 0 issues evaluated, 0 issues filtered, 0 comments posted

🗂️ Filtered Issues

No issues evaluated.

@coderabbitai

coderabbitai Bot commented Jul 15, 2026

Copy link
Copy Markdown

Important

Review skipped

Auto reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro

Run ID: bca51b12-2837-4169-96e9-79ffb9da7fb7

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@github-actions github-actions Bot added vouch:unvouched PR author is not yet trusted in the VOUCHED list. size:XL 500-999 changed lines (additions + deletions). labels Jul 15, 2026
if (Option.isNone(threadOption)) {
return yield* new ThreadReferenceNotFoundError({ threadId: input.threadId });
}
const page = buildThreadReferencePage(threadOption.value, input);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟠 High threadReference/handlers.ts:113

threadRead only checks the thread-reference capability and then passes the caller-supplied input.threadId directly to getThreadDetailById, which queries globally by ID. Any holder of a session MCP credential can read an arbitrary active thread transcript — including threads from other environments — by supplying that thread's ID, because the handler never verifies the thread belongs to invocation.environmentId or was actually referenced in the session. Consider checking that the returned thread's environmentId matches the invocation's environment (or otherwise confirming an explicit reference) before returning the transcript.

🤖 Copy this AI Prompt to have your agent fix this:
In file @apps/server/src/mcp/toolkits/threadReference/handlers.ts around line 113:

`threadRead` only checks the `thread-reference` capability and then passes the caller-supplied `input.threadId` directly to `getThreadDetailById`, which queries globally by ID. Any holder of a session MCP credential can read an arbitrary active thread transcript — including threads from other environments — by supplying that thread's ID, because the handler never verifies the thread belongs to `invocation.environmentId` or was actually referenced in the session. Consider checking that the returned thread's `environmentId` matches the invocation's environment (or otherwise confirming an explicit reference) before returning the transcript.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

size:XL 500-999 changed lines (additions + deletions). vouch:unvouched PR author is not yet trusted in the VOUCHED list.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Feature]: Ability to tag other threads in messages

2 participants