feat: reference other threads from the composer#4010
Conversation
|
Important Review skippedAuto reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the ⚙️ Run configurationConfiguration used: Repository UI Review profile: CHILL Plan: Pro Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
✨ Finishing Touches🧪 Generate unit tests (beta)
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. Comment |
| if (Option.isNone(threadOption)) { | ||
| return yield* new ThreadReferenceNotFoundError({ threadId: input.threadId }); | ||
| } | ||
| const page = buildThreadReferencePage(threadOption.value, input); |
There was a problem hiding this comment.
🟠 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.
What changed
#in the composer to search recently active threads in the current environment.t3-threadreference chip instead of copying the referenced transcript into the prompt.thread_readMCP tool so an agent can fetch only the referenced context it needs.t3-threadreferences 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.t3-thread:///environment-id/thread-idURI carried in Markdown.thread_readreturns message text in bounded pages (40,000 characters by default, 80,000 maximum) and providesnextCursorfor continuation.Verification
pnpm exec vp check— passed with 0 errorspnpm exec vp run typecheck— passedupstream/main— no diagnostics in changed React filesgit diff --check upstream/main...HEAD— passedUI
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 andthread_readMCP tool#trigger in the composer that opens a thread search menu, inserting at3-thread://link as an inline chip when a thread is selected.ComposerThreadNodeLexical decorator node that renders thread references as chips in the editor and serializes them ast3-thread:///env/threadmarkdown links.thread_readMCP tool that fetches paginated thread transcripts, with cursor-based pagination and structured errors for not-found or unavailable threads.t3-threadlinks in chat markdown as clickable chips that navigate internally to the referenced thread instead of opening as external URLs.T3_CODE_THREAD_REFERENCE_INSTRUCTIONSto Codex developer instructions so the AI agent knows how to use thread references viathread_read.📊 Macroscope summarized 9c63d4b. 16 files reviewed, 0 issues evaluated, 0 issues filtered, 0 comments posted
🗂️ Filtered Issues
No issues evaluated.