mirror of
https://github.com/ThearchyHelios/AgentLab.git
synced 2026-11-20 23:31:58 +00:00
驳回不再记成失败(前端):终态按 end_reason 写「被驳回」,副标题写谁、在哪一步、备注
为什么:服务端已把人的驳回收成 cancelled + end_reason=rejected(上一个提交)。前端以前靠正则解析报错原文认驳回,而且只认 「人工驳回」一种,动作确认、工具调用审批、代码执行审批的三种原话都落到兜底、给出注定再失败的「继续运行」(05-已知遗留 (a))。 做了什么: - types.ts:Run.end_reason(rejected / stopped)。 - lib/status:新增状态 rejected(「被驳回」,同取消的剪影、不画红、终态),resolveStatus 按 endReason 区分;记录页列表、详情、 航迹的终点按它写「被驳回 · 原话」。 - run/decode:run.cancelled 带 reason=rejected 时标题写「被驳回」,副标题「张工 驳回了「付款」:金额不对」(超时驳回写按设置 驳回、不重复备注),指向那一步;手动停止、老事件照旧「已取消」。 - store/chat + ChatPage:终态里被驳回的一轮照 cancelled 收(不给继续运行),徽标写「被驳回」,补救区说明这是审批人的决定、 副标题写谁和备注;刷新之后从 meta.rejected 恢复;核对状态时按运行的 end_reason 认。 - lib/explain:正则只留给存量 failed+驳回,补上「未确认(被驳回)」「的调用已被驳回」「代码执行已被驳回」三种原话,一律不给继续运行。 - 继续运行被拒的说法改成「被驳回的运行不能继续运行:改好内容后重新发起」(check-copy 不收「接着跑」)。 - check-decode 加一节:reason=rejected 的标题、副标题、没署名没备注、超时驳回、相位、手动停止和老事件。 偏离:问数据的「之前的尝试」(retry 留档,W1-a 的地盘)里被驳回的那一次仍写「已手动停止」,没动。
This commit is contained in:
@@ -2,7 +2,7 @@ import { create } from 'zustand'
|
||||
import { ApiError, api, streamCopilot, streamRun } from '../api/client'
|
||||
import type { CopilotOp, FixKind, RunFinal } from '../run/decode'
|
||||
import { copilotContext, copilotLook, decodeRun, looksOf } from '../run/decode'
|
||||
import { CHAT_BLUEPRINT_TEXT, LOOK_TEXT } from '../lib/terms'
|
||||
import { CHAT_BLUEPRINT_TEXT, LOOK_TEXT, REJECTED_TEXT } from '../lib/terms'
|
||||
import type { LookEvent } from '../typesApp'
|
||||
import { errorMessage, humanizeError, isNetworkError } from '../lib/errors'
|
||||
import { guardReview, hasEvidence } from '../lib/evidence'
|
||||
@@ -87,6 +87,11 @@ export interface Failure {
|
||||
fixFirst?: true
|
||||
}
|
||||
|
||||
/** 被驳回的那一句:事件流里来的按 run.cancelled 的谁、哪一步、备注拼(REJECTED_TEXT.sub);核对状态时只有报错原文 */
|
||||
export interface Rejected {
|
||||
sub: string
|
||||
}
|
||||
|
||||
/** 限定这一问只查哪些数据源。名字跟着存:库删了之后,这一轮查的是谁还得说得出来 */
|
||||
export interface ScopeSource {
|
||||
id: string
|
||||
@@ -127,6 +132,8 @@ export interface TurnMeta {
|
||||
issuance?: Record<string, any>
|
||||
noQuery?: boolean
|
||||
outcome?: 'cancelled' | 'suspended'
|
||||
/** 运行被人驳回结束(outcome 是 cancelled):副标题那一句,刷新之后照样写「被驳回」,不退回成「你已停止本轮」 */
|
||||
rejected?: Rejected
|
||||
failure?: Failure
|
||||
attempts?: Attempt[]
|
||||
/** 这一轮从开问到交付的墙钟毫秒 */
|
||||
@@ -180,6 +187,11 @@ export interface ChatTurn {
|
||||
/** 一行错误文案(兼容老数据和流式头部)。结构化的在 failure 里 */
|
||||
error: string
|
||||
failure?: Failure | null
|
||||
/**
|
||||
* 这一轮的运行被人驳回结束(服务端 cancelled + end_reason=rejected,05-已知遗留 (a))。phase 照旧是 cancelled(不是故障、
|
||||
* 不给继续运行),说法另写「被驳回」和谁、在哪一步、备注
|
||||
*/
|
||||
rejected?: Rejected | null
|
||||
startedAt: number
|
||||
/** 交付、失败、取消或中断的时刻。计时器停在这里 */
|
||||
endedAt?: number
|
||||
@@ -440,6 +452,7 @@ function buildMeta(t: ChatTurn): TurnMeta {
|
||||
issuance: slimIssuance(t.output?._issuance ?? t.rawOutput?._issuance) ?? t.meta?.issuance,
|
||||
noQuery: t.noQuery || undefined,
|
||||
outcome: t.phase === 'cancelled' ? 'cancelled' : t.phase === 'suspended' ? 'suspended' : undefined,
|
||||
rejected: t.phase === 'cancelled' && t.rejected ? t.rejected : undefined,
|
||||
failure: t.failure ?? undefined,
|
||||
attempts: t.attempts?.length ? t.attempts : undefined,
|
||||
ms: t.endedAt ? t.endedAt - t.startedAt : t.meta?.ms,
|
||||
@@ -678,6 +691,7 @@ function restoreTurn(t: ConversationTurn): ChatTurn {
|
||||
output,
|
||||
error: phase === 'error' ? (failure ? lineOf(failure) : t.status === 'running' ? buildInterrupted.title : '') : '',
|
||||
failure: phase === 'error' ? (t.status === 'running' ? buildInterrupted : failure) : phase === 'suspended' ? SUSPENDED : null,
|
||||
rejected: phase === 'cancelled' ? meta?.rejected ?? null : null,
|
||||
startedAt: Date.parse(t.created_at ?? '') || Date.now(),
|
||||
endedAt: meta?.ms != null ? (Date.parse(t.created_at ?? '') || 0) + meta.ms : undefined,
|
||||
lastSeq: 0,
|
||||
@@ -1043,7 +1057,10 @@ export const useChat = create<ChatState>((set, get) => ({
|
||||
}
|
||||
if (run.status === 'cancelled') {
|
||||
if (cur.phase !== 'done' && cur.phase !== 'cancelled') {
|
||||
conclude({ phase: 'cancelled', status: PHASE_TEXT.cancelled, failure: null, error: '' }, '已取消')
|
||||
// 被驳回只看服务端的 end_reason:核对时手上只有运行记录,副标题用报错原文(它就是给人看的那句)
|
||||
const rejected = run.end_reason === 'rejected' ? { sub: run.error || REJECTED_TEXT.title } : null
|
||||
conclude({ phase: 'cancelled', status: rejected ? REJECTED_TEXT.title : PHASE_TEXT.cancelled, failure: null,
|
||||
error: '', rejected }, '已取消')
|
||||
}
|
||||
return
|
||||
}
|
||||
@@ -1673,15 +1690,18 @@ function watch(
|
||||
// 服务在关停:这一轮会停在断点上。停在审批上的仍然是在等人
|
||||
if (d.code === 'server_shutdown' && current()?.phase !== 'waiting') suspend()
|
||||
break
|
||||
case 'run.cancelled':
|
||||
case 'run.cancelled': {
|
||||
ended = true
|
||||
batch.now()
|
||||
// 人的驳回(reason=rejected)也收成 cancelled:不是故障、不给继续运行,说法写「被驳回」和谁、哪一步、备注
|
||||
const rejected = d.reason === 'rejected' ? { sub: REJECTED_TEXT.sub(d) } : null
|
||||
patch(() => ({
|
||||
phase: 'cancelled', status: PHASE_TEXT.cancelled, cancel: null, endedAt: Date.now(),
|
||||
runStatus: 'cancelled', final: { status: 'cancelled' },
|
||||
phase: 'cancelled', status: rejected ? REJECTED_TEXT.title : PHASE_TEXT.cancelled, cancel: null,
|
||||
endedAt: Date.now(), runStatus: 'cancelled', final: { status: 'cancelled' }, rejected,
|
||||
}))
|
||||
void flow.persist({ status: 'error', error: '已取消' })
|
||||
break
|
||||
}
|
||||
case 'run.failed': {
|
||||
ended = true
|
||||
batch.now()
|
||||
|
||||
Reference in New Issue
Block a user