Give Agents access to Terminal output#1032
Give Agents access to Terminal output#1032maskdotdev wants to merge 10 commits intopingdotgg:mainfrom
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)
📝 Coding Plan
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 Tip CodeRabbit can use OpenGrep to find security vulnerabilities and bugs across 17+ programming languages.OpenGrep is compatible with Semgrep configurations. Add an |
There was a problem hiding this comment.
this looks amazing - definitely will try and get this merged soon. thank you! don't worry about the diff limit for this one
one nit: i think this indicator is a bit small and discrete, how would it look to keep the pill-like thing on top of the message similar to the composer input (or even inline like file taggings?)
another "feature" I originally wanted from this is the ability to tag a terminal using look at the logs in @terminal-1 and fix the build issue or whatever (autocompletes similar to the workspace entries search) and we'd transform that in the user message to include a reference to the terminal log file (in ~/.t3/userdata/logs/terminals/.log` that the agent can go look at
|
I know you mentiond to not worry about the diff size on this one, but would you prefer if I create another issue and separate PR for the |
i don't mind either. whatever is easiest! |
|
inline pills i think looks the best - will also match the existing file pills the best |
|
Style now reflects inline in a similar fashion to file mentions Created a separate issue for Will create a separate PR for that one 🫡 |
|
mind attaching a new recording of the current state? |
|
of course! here you go t3code-term-context-inline.mp4 |
|
Nice PR, just make sure to not spam julius with reviews as it is the weekend! |
|
I think I found a better way to enable terminal/s context, that's not doing manual selection... I'll ping you tomorrow Julius, or feel free to reach out. t3-code-term-context.mov |
is this adjusting the system prompt to include the path to the terminals? or how do you inject the context? |
I used tools instead, I gave these terminal tools to the app server via dynamicTools, OpenAI Dynamic Tools. We dont pass the terminal output in the prompt up front. If the llm decides it needs terminal context (didnt want to bloat the context window), it calls either LMK if you need more details... one thing I dont like about this approach is the architecture for tools, I think it'd be worth having like an internal tool registry, but for now it just a terminal tools file... also, I didnt push on this PR, because I was not sure what you would prefer, and I think this new approach may require some discussion around tools architecture. |
|
what's the effort required to go from the current explicit-tagging method to the tool based one? and is line-based context inclusion (the original PR goal) still supported? |
Line based context inclusion is currently the only feature supported here in this PR. This would be unaffected even if we do explicit tags or auto term context.
While the tool based approach we do 99% of the work in the server (still do cleanup of terminal escape code), and we either add a new lib like xterm/headless, or grabbing the render output from the rendered terminal dom. both of these are about a couple 100s loc, implementations hopefully this answers your questions. Note: Tool based approach is currently on a fully separate local branch |



sorry this is so close to the 1k limit outline in the contributing.md., some of the code here could be reused by the diff pr at #1003 (could make smaller if I remove the timeline and composer pills, but I think those provide value to the end user)
What Changed
Added terminal selection as chat context, surfaced pending terminal-context chips in the composer, and rendered sent terminal context as compact metadata in the timeline.
Why
resolves #26
UI Changes
Composer now shows selected terminal snippets as removable chips, the terminal drawer adds an “Add to chat” action for selections, and sent messages show a compact terminal-context indicator with tooltip preview.
Checklist
t3code-terminal-context-optimized.mp4
Note
Give agents access to terminal output by attaching selected text as context in chat
TerminalViewportthat appears when the user selects text; clicking it appends a<terminal_context>block to the composer draft viacomposerDraftStore.ComposerPendingTerminalContextscomponent.@terminal-1:3-7) with tooltips instead of raw block text.Macroscope summarized 050a3bc.