daemon: integrate QoL slices 1-5 (model/rename/catalog, history deletes, stats, repo prepare+imageUsed+built) — 95.3% cover green

This commit is contained in:
Raphael Westphal
2026-08-19 10:07:52 +02:00
parent 7287b831e4
commit 698b742cb3
16 changed files with 1506 additions and 36 deletions
+33
View File
@@ -30,6 +30,9 @@ const (
evBye string = "bye"
evPrompt string = "prompt"
evAbort string = "abort"
evSetModel string = "set_model"
evRename string = "rename"
evErrorNotice string = "error_notice"
frameSessionList string = "session_list"
frameEvents string = "events"
frameSpawnStatus string = "spawn_status"
@@ -647,6 +650,29 @@ func (h *Hub) Abort(sessionID string) error {
})
}
// SetModel routes a set_model frame to the live plugin conn for sessionID.
func (h *Hub) SetModel(sessionID, provider, modelID string) error {
return h.sendToAgent(sessionID, map[string]any{
"v": daemonVersion,
"type": evSetModel,
"sessionId": sessionID,
"ts": time.Now().UnixMilli(),
"provider": provider,
"modelId": modelID,
})
}
// Rename routes a rename frame to the live plugin conn for sessionID.
func (h *Hub) Rename(sessionID, name string) error {
return h.sendToAgent(sessionID, map[string]any{
"v": daemonVersion,
"type": evRename,
"sessionId": sessionID,
"ts": time.Now().UnixMilli(),
"name": name,
})
}
func (h *Hub) sendToAgent(sessionID string, frameBody map[string]any) error {
b, err := json.Marshal(frameBody)
if err != nil {
@@ -689,3 +715,10 @@ func (h *Hub) ServeWebWS(w http.ResponseWriter, r *http.Request) {
c.deliverControl(payload)
}
}
// OnlineCount reports how many agent WS connections are currently live.
func (h *Hub) OnlineCount() int {
h.mu.Lock()
defer h.mu.Unlock()
return len(h.agents)
}