Restrict chat_sessions to server-owned sessions

chat_sessions now brokers GET /api/session but filters the global list to
the sessions this server recorded in run_steps, deduped by session id, and
fails closed to an empty list when no ownership source is configured. A
session another client holds (in-server claim, released on stream end or
disconnect) or an active run is marked busy; a second client's chat_prompt
for a held session is rejected before any OpenCode call. chat_create stays
unbrokered.
This commit is contained in:
2026-10-16 09:21:50 +01:00
parent dca72a09ee
commit 1818a06d2f
11 changed files with 711 additions and 38 deletions
+5
View File
@@ -87,6 +87,11 @@ type ChatSession struct {
ParentID string `json:"parent_id,omitempty"`
CreatedAt int64 `json:"created_at,omitempty"`
UpdatedAt int64 `json:"updated_at,omitempty"`
// Busy marks a session another client currently holds (or one the server
// itself owns as an active run), so the phone can show it read-only instead
// of letting two clients silently write the same conversation. It is
// additive and optional: older peers ignore it.
Busy bool `json:"busy,omitempty"`
}
// ChatCreateRequest is the chat_create request body: a title and an optional