Brings the chat surface to the Web UI: /api/chat with its own handlers and tests, a self-contained ui/src/chat feature folder, and the shared plumbing to reach the same router Telegram uses. Includes a dangerous-command approval path (internal/gateway/dangerous.go, internal/webui/dangerous.go, and the Telegram counterpart) so /rollback and /stop are gated the same way on both surfaces, persona handling for web sessions, and release-update formatting split out of the Telegram service so both can render it. web_parity_test.go pins that the two surfaces expose the same commands. Authored in a parallel session; committed here so it lands with the rest rather than sitting uncommitted while other work builds on top of it. task check passes with it in place. Screenshots used while building are gitignored (*.png) rather than committed, matching the call made on the earlier design reference.
33 lines
1.1 KiB
Go
33 lines
1.1 KiB
Go
package releaseupdate
|
|
|
|
import (
|
|
"fmt"
|
|
"strings"
|
|
)
|
|
|
|
// FormatSnapshot returns the concise human-facing update status shared by
|
|
// chat adapters. It deliberately includes unchanged components when an
|
|
// update exists so operators can see exactly what will and will not change.
|
|
func FormatSnapshot(snapshot Snapshot) string {
|
|
if len(snapshot.Available()) == 0 && !snapshot.Deferred {
|
|
return "Archie is up to date."
|
|
}
|
|
if len(snapshot.Available()) == 0 && snapshot.Deferred {
|
|
return "The available update is deferred. Archie will ask again when a newer release is available."
|
|
}
|
|
var text strings.Builder
|
|
text.WriteString("Archie has an update available:")
|
|
for _, component := range snapshot.Components {
|
|
fmt.Fprintf(&text, "\n\n--- %s ---\n", component.Label)
|
|
if component.Available == "" || component.Available == component.Installed {
|
|
fmt.Fprintf(&text, "No %s changes as part of this release.", strings.ToLower(strings.TrimPrefix(component.Label, "THE ")))
|
|
continue
|
|
}
|
|
fmt.Fprintf(&text, "%s available", component.Available)
|
|
if component.Changelog != "" {
|
|
fmt.Fprintf(&text, "\n\n%s", component.Changelog)
|
|
}
|
|
}
|
|
return text.String()
|
|
}
|