🐛 fix(client): 授权与提问提醒不再被运行状态丢掉

This commit is contained in:
pyh
2026-10-04 19:24:02 +08:00
parent 248619ffc3
commit 074cdccdb9
3 changed files with 73 additions and 36 deletions
+34 -12
View File
@@ -8,9 +8,13 @@
import { PENDING_KINDS } from '../constants.js'
/**
* Discriminate a pending interaction the client published. Only the three
* domains the Harness itself renders are served; anything else is ignored
* rather than guessed at.
* Discriminate a pending interaction the client published.
*
* The domains that can ask the user something are `@deepseek-ai/dsh-client-ui-approval`
* (a tool authorisation) and `@deepseek-ai/dsh-client-ui-user-questions` (a
* question batch, or the plan review its `planReviewOf` marks); each publishes a
* literal `kind` on its pending value. Anything else is ignored rather than
* guessed at.
* @param value - `status.pendingInteraction`.
* @returns a served kind, or undefined.
*/
@@ -55,21 +59,39 @@ export function isOnScreen(sessionId, list) {
}
/**
* Whether a queued candidate is still worth delivering. Read from the LIVE
* snapshot rather than the one captured when the transition was seen: a
* conversation that resumed in the settle window owes no alert, and the
* snapshot the transition was derived from still carries the pre-transition
* `running` flag of the session record.
* Whether a queued candidate is still owed, read from the LIVE snapshot rather
* than the one captured when the transition was seen.
*
* The two triggers are owed for different reasons, so they are checked for
* different things:
*
* - A **pending interaction** (approval, question, plan review) is owed until
* the user answers it. It is deliberately NOT gated on the run state: the
* session is `running` while it waits — the client's own `observeRunning`
* only mirrors `api-session/status` and says nothing about a pending request —
* so a running gate would silently drop every approval and question alert.
* - A **completion** is owed only while the conversation stayed idle. A
* conversation that resumed inside the settle window owes no alert, and the
* snapshot the transition was derived from still carries the pre-transition
* `running` flag of the session record.
* @param candidate - the alert waiting for its settle tick.
* @param live - the freshest `{ list, status }` the observer has seen.
* @returns whether the alert is still owed.
*/
export function stillWorth(candidate, live) {
export function stillOwed(candidate, live) {
if (candidate.test === true) return true
if (candidate.pendingKind !== '') {
const sessionStatus = live.status?.get?.(candidate.sessionId)
// No status entry contradicts the request, so it is still the user's move.
if (sessionStatus === undefined) return true
return servedPendingKind(sessionStatus.pendingInteraction) === candidate.pendingKind
}
const list = live.list
if (candidate.test === true || list === undefined) return true
if (list === undefined) return true
const summary = list.byId?.[candidate.sessionId]
if (summary === undefined) return true
const status = live.status
const running = status?.get?.(candidate.sessionId)?.running ?? summary.running
const running = live.status?.get?.(candidate.sessionId)?.running ?? summary.running
return running !== true
}