526c19fc21
- Persist chat stars in the operator-session registry (chat_star) so every browser/device shows the same Starred group; migrate old local stars once. - Add a compact pipeline graph shape to list responses and draw a lightweight list miniature; replace the cryptic id/version line with the stage count. - Surface OpenCode form questions as a chat card (chat_answer), replay a pending form to late subscribers, and notify for background questions. - Make the mobile dock's Search cell equal to every destination, keep the tab row visible with 100svh, and let Source use the full pane height. - Let a fresh sign-in auto-connect to its own origin; use a Lax session cookie with Expires so Remember me survives app/link launches. - Keep shipped starters and the skill agnostic: no repository paths, project areas or personal device commands; add Diagnose/Fix and Research starters. - Refresh the installed skill and document the new browser conventions.
49 lines
1.9 KiB
Go
49 lines
1.9 KiB
Go
package server
|
|
|
|
import (
|
|
"context"
|
|
|
|
"git.a-wan.net/alan/pipelines/internal/opencode"
|
|
"git.a-wan.net/alan/pipelines/internal/protocol"
|
|
)
|
|
|
|
// handleChatAnswer replies to one OpenCode form, which is how the agent's
|
|
// question tool resumes: the tool call is paused inside form.created until a
|
|
// client answers. It validates the session/form ids before calling the broker,
|
|
// so a malformed answer cannot reach another session. The resulting
|
|
// form.replied/form.cancelled event arrives on the ordinary chat_event stream
|
|
// and clears the card on every watching client.
|
|
func handleChatAnswer(ctx context.Context, request protocol.Message, broker chatBroker, write func(protocol.Message) error) {
|
|
if broker == nil {
|
|
_ = write(protocol.Message{Type: protocol.Error, ID: request.ID, Error: "chat is not configured on this server"})
|
|
return
|
|
}
|
|
answer := request.ChatAnswer
|
|
if answer == nil {
|
|
_ = write(protocol.Message{Type: protocol.Error, ID: request.ID, Error: "a chat_answer payload is required"})
|
|
return
|
|
}
|
|
if !opencode.ValidSessionID(answer.SessionID) {
|
|
_ = write(protocol.Message{Type: protocol.Error, ID: request.ID, Error: "a valid OpenCode session id is required"})
|
|
return
|
|
}
|
|
if answer.FormID == "" {
|
|
_ = write(protocol.Message{Type: protocol.Error, ID: request.ID, Error: "a form id is required"})
|
|
return
|
|
}
|
|
if len(answer.Answers) == 0 {
|
|
_ = write(protocol.Message{Type: protocol.Error, ID: request.ID, Error: "at least one answer is required"})
|
|
return
|
|
}
|
|
answerer, ok := broker.(chatAnswerer)
|
|
if !ok {
|
|
_ = write(protocol.Message{Type: protocol.Error, ID: request.ID, Error: "this chat backend cannot answer questions"})
|
|
return
|
|
}
|
|
if err := answerer.Answer(ctx, *answer); err != nil {
|
|
_ = write(protocol.Message{Type: protocol.Error, ID: request.ID, Error: err.Error()})
|
|
return
|
|
}
|
|
_ = write(protocol.Message{Type: protocol.ChatAnswer, ID: request.ID})
|
|
}
|