fix(apiproxy): derive queued steering on the client, drop it from the wire

The session/queued frame no longer carries steering — AgentMessage no longer
has the field. The client derives it from the same ordered turn boundaries the
host saw (a frame arriving while a turn is open joined the steering FIFO).
This commit is contained in:
_Kerman
2026-07-27 10:22:28 +08:00
parent 2f74ac98ba
commit 1aefcbf4d7
9 changed files with 46 additions and 32 deletions

View File

@@ -105,6 +105,11 @@ export class Session implements ObservableSnapshot<ConversationSnapshot> {
private dispatchesRev = 0
private dispatchesCache: { rev: number; value: ReadonlyMap<string, readonly CodeSubCall[]> } | null = null
private running = false
/** Whether a turn is open on the live stream — set on turn/start, cleared on
* turn/end. A session/queued frame arriving while this is true joined the
* steering FIFO; the host no longer stamps steering on the frame, so the
* client derives it from the same ordered turn boundaries the host saw. */
private turnOpen = false
/**
* Sticky send marker, private input of the composerPhase derivation: set
* synchronously before prompt()'s first await, never reset — the blank →
@@ -334,6 +339,12 @@ export class Session implements ObservableSnapshot<ConversationSnapshot> {
switch (frame.type) {
case 'session/event': {
this.retireQueued(frame.event)
// Track turn-open state AFTER retirement (a message turn/start first
// claims its queued entry, then opens the turn), so a later queued
// frame is stamped steering iff a turn is open — the host no longer
// stamps it on the frame.
if (frame.event.type === 'turn/start') this.turnOpen = true
else if (frame.event.type === 'turn/end') this.turnOpen = false
this.acceptLiveEvent(frame.event, frame.view)
return
}
@@ -343,7 +354,7 @@ export class Session implements ObservableSnapshot<ConversationSnapshot> {
const key = 'rpcId' in frame.source ? String(frame.source.rpcId) : `f:${rpcId}`
this.queued.push({
row: { key, preview: queuePreviewOf(frame.content) },
steering: frame.steering,
steering: this.turnOpen,
sourceJson: JSON.stringify(frame.source),
})
this.queueRev++