Chat: draw agent follow-ups and automatic continues apart from the operator

The server now names a user turn's origin (followup, auto_continue,
auto_switch, scheduled) on chat messages, user frames and queued prompts,
from the prompt's operation id while it holds the prompt and from its own
text prefixes in history read later. Origin is a new field, so older
clients keep treating these as ordinary user turns.

The app draws an agent follow-up, auto-continue and account-switch prompt
as a quiet outlined card on the agent's side with an icon, label and the
schedule facts from the preamble; the operator's own scheduled message
keeps its bubble with a small Scheduled mark. Find searches the drawn text.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
2026-12-03 15:40:34 +00:00
parent 608b6b8edb
commit 9a6363b80e
22 changed files with 946 additions and 26 deletions
+27 -2
View File
@@ -271,6 +271,24 @@ const (
ChatMessageKindNotice = "notice"
)
// ChatMessage.Origin (and ChatEventFrame.Origin, ChatQueuedPrompt.Origin)
// values: who put a user turn into the chat when it was not the operator
// typing it now. Empty is the operator's own message. Origin is separate from
// Kind, so a client that ignores it still treats the turn as an ordinary user
// turn.
//
// ChatOriginFollowup is a follow-up the agent scheduled for itself
// (schedule_followup). ChatOriginAutoContinue is the server resending a chat
// after its usage limit reset; ChatOriginAutoSwitch is the server continuing
// a chat on another Claude account. ChatOriginScheduled is the operator's own
// message they scheduled to send later.
const (
ChatOriginFollowup = "followup"
ChatOriginAutoContinue = "auto_continue"
ChatOriginAutoSwitch = "auto_switch"
ChatOriginScheduled = "scheduled"
)
// ChatCommand is one slash command or skill the chat's harness session offers.
// Name is the word after the slash; the operator sends "/<Name> <args>" as an
// ordinary prompt and the harness expands it. ArgumentHint is the harness's
@@ -594,6 +612,8 @@ type ChatQueuedPrompt struct {
// SendAt (epoch milliseconds) is set on a scheduled prompt: the earliest
// time the server will deliver it.
SendAt int64 `json:"send_at,omitempty"`
// Origin is the ChatMessage.Origin the prompt is delivered with.
Origin string `json:"origin,omitempty"`
}
// ChatQueueFrame is a session's current server-side prompt queue, in delivery
@@ -659,8 +679,11 @@ type ChatMessage struct {
OperationID string `json:"operation_id,omitempty"`
// Kind is empty for an ordinary user or assistant turn, or one of the
// ChatMessageKind values for content the harness injected.
Kind string `json:"kind,omitempty"`
Parts []ChatPart `json:"parts"`
Kind string `json:"kind,omitempty"`
// Origin is one of the ChatOrigin values on a user turn the operator did
// not type just now; empty otherwise, or when the server no longer knows.
Origin string `json:"origin,omitempty"`
Parts []ChatPart `json:"parts"`
}
// ChatDeltaPartID is the stable part id an incremental text or reasoning delta
@@ -764,6 +787,8 @@ type ChatEventFrame struct {
// MessageKind is the ChatMessage.Kind of the message a text frame starts,
// so a live agent report or notice is never drawn as an answer or a prompt.
MessageKind string `json:"message_kind,omitempty"`
// Origin is the ChatMessage.Origin of a user frame's message.
Origin string `json:"origin,omitempty"`
// Seq numbers a text or reasoning delta within its session, increasing;
// see ChatHistoryPage.LiveSeq. Zero when the harness does not number them.
Seq int64 `json:"seq,omitempty"`