feat: enable direct messaging to subagents from TUI - #1876
Open
cetagostini wants to merge 2 commits into
Open
Conversation
Add the ability for users to type directly to running/persistent subagents from the TUI, bypassing the main agent relay. Changes: - Server: Add POST /:sessionID/inbox/send endpoint that wraps Inbox.send() for direct subagent messaging - TUI: Add onCustomSubmit prop to Prompt component for custom submit routing (skips model/workspace checks) - TUI: Add subagentInputVisible memo and render Prompt with onCustomSubmit when viewing a running/pending/idle subagent The SubagentFooter (navigation + status) remains visible above the input bar when viewing a subagent.
- Fix double-submit race: wrap onCustomSubmit in submitLock - Remove history.append from custom submit path (inbox messages shouldn't pollute the shared prompt history) - Map InboxReceiverNotFound to 404 via Effect.catchTag instead of letting it fall through to 500 - Add 6 test cases for POST /:sessionID/inbox/send: happy path, default type, empty content, missing actorID, nonexistent actor, invalid sessionID format
Author
|
@wqymi and @MiMoHardFather what do you think? |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
POST /:sessionID/inbox/sendserver endpoint that wrapsInbox.send()for direct subagent messagingonCustomSubmitprop toPromptcomponent allowing custom submit routing (skips model/workspace checks)Motivation
When navigating to a subagent's conversation view in the TUI, the input bar was hidden. All communication had to go through the main agent via
actor send, adding latency. This PR enables direct messaging by:Inbox.send()infrastructure as an HTTP endpointIf a sub-agent goes away from the main goal, you can provide small notch to put it back on track. If main agent miss indications, user can provide without let the agent go crazy.
Changes
Server (
packages/opencode/src/server/routes/instance/session.ts)POST /:sessionID/inbox/sendendpoint accepting{ actorID, content, type? }and returning{ inboxID }inboxServiceRef.current.send()that theactor sendtool usesTUI Prompt (
packages/opencode/src/cli/cmd/tui/component/prompt/index.tsx)onCustomSubmitprop onPromptProps: when provided, the submit function calls it instead of the defaultsession.promptpathTUI Session (
packages/opencode/src/cli/cmd/tui/routes/session/index.tsx)subagentInputVisiblememo: returnstruewhen viewing a subagent with statusrunning,pending, orunknown(idle-without-outcome)<Prompt>withonCustomSubmitthat POSTs to the inbox send endpointSubagentFooter(navigation + status) remains visible above the input barTesting
session create --topic testOut of Scope