Files
pipelines/internal/server/chat_star.go
T
alan 526c19fc21 web: shared chat stars, pipeline mini graphs and agent questions
- 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.
2026-10-20 03:11:37 +01:00

60 lines
2.4 KiB
Go

package server
import (
"context"
"git.a-wan.net/alan/pipelines/internal/opencode"
"git.a-wan.net/alan/pipelines/internal/protocol"
)
// handleChatStar records the operator's shared star for one operator chat
// session. It is a registry write, not a local preference: every browser and
// device lists the same Starred group, and starring never mutates the OpenCode
// session or its transcript. A session id that is not a recorded operator
// session is refused before anything is written, so a pipeline-owned run session
// is never touched. The request body is a ChatQuery carrying SessionID and the
// desired Starred value; the reply echoes the updated session.
func handleChatStar(ctx context.Context, request protocol.Message, registry operatorRegistry, write func(protocol.Message) error) {
if registry == nil {
_ = write(protocol.Message{Type: protocol.Error, ID: request.ID, Error: "operator session registry is not configured on this server"})
return
}
query := request.ChatQuery
if query == nil || !opencode.ValidSessionID(query.SessionID) {
_ = write(protocol.Message{Type: protocol.Error, ID: request.ID, Error: "a valid OpenCode session id is required"})
return
}
if query.Starred == nil {
_ = write(protocol.Message{Type: protocol.Error, ID: request.ID, Error: "a starred state is required"})
return
}
sessionID := query.SessionID
if _, found, err := registry.OperatorSession(ctx, sessionID); err != nil {
_ = write(protocol.Message{Type: protocol.Error, ID: request.ID, Error: err.Error()})
return
} else if !found {
_ = write(protocol.Message{Type: protocol.Error, ID: request.ID, Error: "session " + sessionID + " is not an operator chat session"})
return
}
if err := registry.SetOperatorSessionStar(ctx, sessionID, *query.Starred); err != nil {
_ = write(protocol.Message{Type: protocol.Error, ID: request.ID, Error: err.Error()})
return
}
session, found, err := registry.OperatorSession(ctx, sessionID)
if err != nil {
_ = write(protocol.Message{Type: protocol.Error, ID: request.ID, Error: err.Error()})
return
}
if !found {
_ = write(protocol.Message{Type: protocol.Error, ID: request.ID, Error: "session " + sessionID + " is no longer an operator session"})
return
}
wire := chatSessionFromOperator(session)
write(protocol.Message{
Type: protocol.ChatStar,
ID: request.ID,
ChatSession: &wire,
ChatSessions: []protocol.ChatSession{wire},
})
}