refactor: remove personas

Personas were a misread requirement: SOUL is the chat identity and
identities are per action. The selected persona's prompt never reached the
model. Drops the resource, /personality, the chat selector, the settings
page and ChatService.SetPersona, and deletes stored persona documents.
This commit is contained in:
sam committed 2026-10-16 03:57:08 +11:00
1 parent 2c49fa5a55
commit 78e162fa0a
46 files changed
+384 -1416

No files matched your search

-49
View File
@@ -109,11 +109,6 @@ func chatMediaViews(media []messaging.MediaAttachment) []chatMediaView {
return views
}
type chatPersonaRequest struct {
SessionID string `json:"session_id"`
Name string `json:"name"`
}
type chatCancelRequest struct {
SessionID string `json:"session_id"`
}
@@ -161,13 +156,9 @@ func (s *Server) handleChatSessions(w http.ResponseWriter, r *http.Request) {
return
}
out := make([]messaging.SessionContext, 0, len(snapshot.Sessions))
active := make(map[string]string)
for _, session := range snapshot.Sessions {
if s.ownsChatSession(r.Context(), session) {
out = append(out, session)
if name, ok := snapshot.ActivePersonas[session.SessionID]; ok {
active[session.SessionID] = name
}
}
}
writeJSON(w, map[string]any{
@@ -177,9 +168,7 @@ func (s *Server) handleChatSessions(w http.ResponseWriter, r *http.Request) {
"providers": snapshot.Providers,
"active_model": snapshot.ActiveModel,
"active_provider": snapshot.ActiveProvider,
"personas": snapshot.Personas,
"voice_available": snapshot.VoiceAvailable,
"active_personas": active,
"commands": chatCommandSpecs(chat),
})
}
@@ -494,44 +483,6 @@ func (s *Server) handleChatCancel(w http.ResponseWriter, r *http.Request) {
writeJSON(w, map[string]any{"cancelled": result.Cancelled, "dropped": result.Dropped})
}
func (s *Server) handleChatPersona(w http.ResponseWriter, r *http.Request) {
chat, ok := s.chatReady(w)
if !ok {
return
}
snapshot, err := chat.Contract.Snapshot(r.Context())
if err != nil {
http.Error(w, err.Error(), http.StatusInternalServerError)
return
}
if !snapshot.PersonasAvailable {
http.Error(w, "personality switching is not configured", http.StatusNotImplemented)
return
}
var req chatPersonaRequest
if err := json.NewDecoder(r.Body).Decode(&req); err != nil || req.SessionID == "" || req.Name == "" {
http.Error(w, "session_id and name are required", http.StatusBadRequest)
return
}
if session, found, err := chat.Contract.GetSession(r.Context(), req.SessionID); err != nil {
http.Error(w, err.Error(), http.StatusInternalServerError)
return
} else if !found || !s.ownsChatSession(r.Context(), session) {
http.Error(w, "session not found", http.StatusNotFound)
return
}
changed, err := chat.Contract.SetPersona(r.Context(), req.SessionID, strings.ToLower(req.Name))
if err != nil {
http.Error(w, err.Error(), http.StatusInternalServerError)
return
}
if !changed {
http.Error(w, fmt.Sprintf("unknown personality %q", req.Name), http.StatusBadRequest)
return
}
writeJSON(w, map[string]any{"ok": true, "name": strings.ToLower(req.Name)})
}
// writeUpdateCheckError answers an unset check command as not configured, which
// the dashboard shows as such rather than as a failure.
func writeUpdateCheckError(w http.ResponseWriter, err error) {
@@ -99,7 +99,6 @@ func TestHTTPPolicyCannotBeBypassed(t *testing.T) {
{"POST", "/api/chat/answer"},
{"POST", "/api/chat/cancel"},
{"POST", "/api/chat/message"},
{"POST", "/api/chat/persona"},
{"POST", "/api/chat/stream"},
{"POST", "/api/chat/update/defer"},
{"POST", "/api/chat/update/install"},
+1 -3
View File
@@ -14,7 +14,7 @@ import (
type ownedChat struct{ messaging.ChatContract }
func (ownedChat) Snapshot(context.Context) (messaging.ChatSnapshot, error) {
return messaging.ChatSnapshot{CancellationAvailable: true, PersonasAvailable: true}, nil
return messaging.ChatSnapshot{CancellationAvailable: true}, nil
}
func (ownedChat) GetSession(context.Context, string) (messaging.SessionContext, bool, error) {
@@ -32,7 +32,6 @@ func (ownedChat) RecentTurns(context.Context, string, int) ([]messaging.TurnReco
func (ownedChat) Cancel(context.Context, string) (messaging.ChatCancellation, error) {
return messaging.ChatCancellation{Cancelled: true}, nil
}
func (ownedChat) SetPersona(context.Context, string, string) (bool, error) { return true, nil }
func TestWebChatOwnership(t *testing.T) {
for _, route := range []struct {
@@ -42,7 +41,6 @@ func TestWebChatOwnership(t *testing.T) {
{"messages", "", (*Server).handleChatMessages},
{"turns", "", (*Server).handleChatTurns},
{"cancel", `{"session_id":"private"}`, (*Server).handleChatCancel},
{"persona", `{"session_id":"private","name":"archie"}`, (*Server).handleChatPersona},
} {
for _, user := range []string{"alice", "bob"} {
t.Run(route.name+"/"+user, func(t *testing.T) {
-1
View File
@@ -382,7 +382,6 @@ func (s *Server) registerChatRoutes(mux *http.ServeMux) {
mux.HandleFunc("POST /api/chat/cancel", s.handleChatCancel)
mux.HandleFunc("POST /api/chat/answer", s.handleChatAnswer)
mux.HandleFunc("GET /api/chat/file/{token}", s.handleChatFile)
mux.HandleFunc("POST /api/chat/persona", s.handleChatPersona)
mux.HandleFunc("GET /api/chat/update", instanceOnly(s.handleChatUpdate))
mux.HandleFunc("POST /api/chat/update/defer", instanceOnly(s.handleChatUpdateDefer))
mux.HandleFunc("POST /api/chat/update/install", instanceOnly(s.handleChatUpdateInstall))