Send mid-turn chat prompts to the harness and queue the rest durably on the server
Claude Code (stream-json stdin) and Codex (turn/steer pinned to the active turn) receive a prompt sent while a turn runs immediately. Other harnesses (OpenCode) get a durable chat_prompt_queue row owned by the session: it survives the last client detaching and a server restart, is delivered in order when the turn ends with or without a client, and is deduplicated by operation id. chat_subscribe carries the queue, chat_queue frames report delivered/removed/failed changes, and chat_unqueue removes a waiting prompt.
This commit is contained in:
@@ -388,6 +388,26 @@ func (m *chatManager) PromptWithMessageIDFiles(ctx context.Context, sessionID, t
|
||||
return errChatAttachmentsUnsupported
|
||||
}
|
||||
|
||||
// SteerPrompt forwards a prompt into the routed harness's running turn when
|
||||
// that harness accepts mid-turn input (Claude Code, Codex). A harness without
|
||||
// it reports not delivered, so the hub queues the prompt durably instead.
|
||||
func (m *chatManager) SteerPrompt(ctx context.Context, sessionID, text, messageID string, files []opencode.PromptFile) (bool, error) {
|
||||
adapter, err := m.brokerFor(ctx, sessionID)
|
||||
if err != nil {
|
||||
return false, err
|
||||
}
|
||||
steerer, ok := adapter.(chatMidTurn)
|
||||
if !ok {
|
||||
return false, nil
|
||||
}
|
||||
if len(files) > 0 {
|
||||
if _, ok := adapter.(chatPromptWithFiles); !ok {
|
||||
return false, errChatAttachmentsUnsupported
|
||||
}
|
||||
}
|
||||
return steerer.SteerPrompt(ctx, sessionID, text, messageID, files)
|
||||
}
|
||||
|
||||
var errChatAttachmentsUnsupported = errors.New("this chat harness does not support attachments")
|
||||
var errChatFormReadbackUnsupported = errors.New("this chat harness does not support pending question readback")
|
||||
|
||||
|
||||
Reference in New Issue
Block a user