Merge main into chat-close: combine the shared chat room with the server-side close
The item adds chat_close/chat_reopen to the brokered chat protocol and the operator-session registry's closed state. main replaced the per-session claim model with shared chat rooms (chat_subscribe, a prompt queue, one broker stream fanned out to every watcher). This merges the two. Resolved conflicts: - internal/protocol/chat.go, internal/protocol/message.go: kept both additions - ChatClose/ChatReopen and main's ChatSubscribe/ChatQueued. - internal/server/chat_sessions.go: kept the closed fields on a listed session; dropped the `Busy` assignment, because main no longer marks a session Busy (any number of clients may watch and write one). - internal/server/chat_claims.go: main deleted the claim model, so the file goes; close's "is a turn running" check is now `chatHub.turnInFlight` in internal/server/chat_room.go, reading the room's `running` flag. That is the same question the old claim answered, against main's model. - internal/server/chat_close.go: calls turnInFlight instead of the removed `active`. - android AppViewModel.kt, ChatFormat.kt, ChatListPane.kt, Message.kt: kept both sides - main's search state, queued-prompt handling, `Busy`-free status label and row/menu shape, plus the item's close/reopen actions, closed chip and section, close confirmation and "Hide on this device" rename. Also in this merge: main's new convention (AGENTS.md) that an item does not edit a shared document; the item's stale-document record for this change lives in docs/notes/chat-close.md, and docs/cli.md, android/README.md and internal/author/skill/references/operations.md are left to the docs-fold writer. Checks after resolving: gofmt clean, go build ./... and go vet ./... clean, the Go module passes, and the app's :app:assembleDebug and :app:testDebugUnitTest pass (--offline --no-daemon).
This commit is contained in:
@@ -17,15 +17,15 @@ import (
|
||||
// fixed list bounds.
|
||||
const operatorDirectoryLimit = 8
|
||||
|
||||
// handleChatSessions answers chat_sessions with the operator's own sessions,
|
||||
// marking any another client currently holds as Busy. The registry is the single
|
||||
// source of truth for which sessions are listed and for their directory, tag,
|
||||
// created/recency, so a pipeline stage session (recorded in run_steps, never in
|
||||
// the operator registry) is always excluded and a session with no recorded tag
|
||||
// is never listed. FAIL-CLOSED: when no registry is configured the result is
|
||||
// empty, never the whole endpoint list. broker.Sessions is called at most once
|
||||
// per request, and the registry once.
|
||||
func handleChatSessions(ctx context.Context, request protocol.Message, broker chatBroker, hub *chatHub, registry operatorRegistry, clientID string, write func(protocol.Message) error) {
|
||||
// handleChatSessions answers chat_sessions with the operator's own sessions. The
|
||||
// registry is the single source of truth for which sessions are listed and for
|
||||
// their directory, tag, created/recency, so a pipeline stage session (recorded
|
||||
// in run_steps, never in the operator registry) is always excluded and a session
|
||||
// with no recorded tag is never listed. FAIL-CLOSED: when no registry is
|
||||
// configured the result is empty, never the whole endpoint list. broker.Sessions
|
||||
// is called at most once per request, and the registry once. A session is never
|
||||
// marked Busy: any number of clients may watch and write one session.
|
||||
func handleChatSessions(ctx context.Context, request protocol.Message, broker chatBroker, hub *chatHub, registry operatorRegistry, write func(protocol.Message) error) {
|
||||
if broker == nil {
|
||||
_ = write(protocol.Message{Type: protocol.Error, ID: request.ID, Error: "chat is not configured on this server"})
|
||||
return
|
||||
@@ -76,10 +76,10 @@ func handleChatSessions(ctx context.Context, request protocol.Message, broker ch
|
||||
session.UpdatedAt = operator.UpdatedAt
|
||||
// The closed state comes from the registry, so every client sees the same
|
||||
// thing; a closed session stays in the list (the app groups it as history)
|
||||
// rather than disappearing.
|
||||
// rather than disappearing. A session is never marked Busy: any number of
|
||||
// clients may watch and write one session.
|
||||
session.Closed = operator.ClosedAt > 0
|
||||
session.ClosedAt = operator.ClosedAt
|
||||
session.Busy = hub.busyForOther(operator.ID, clientID)
|
||||
response.ChatSessions = append(response.ChatSessions, session)
|
||||
}
|
||||
_ = write(response)
|
||||
|
||||
Reference in New Issue
Block a user