mirror of
https://github.com/ThearchyHelios/AgentLab.git
synced 2026-11-22 05:41:59 +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:
@@ -17,7 +17,7 @@ import { humanizeError } from '../lib/errors'
|
||||
import { explainRunError } from '../lib/explain'
|
||||
import { canLeave, leavePass } from '../lib/leave'
|
||||
import { formatNumber, formatTime } from '../lib/format'
|
||||
import { CHAT_BLUEPRINT_TEXT } from '../lib/terms'
|
||||
import { CHAT_BLUEPRINT_TEXT, REJECTED_TEXT } from '../lib/terms'
|
||||
import { useCatalog, useCatalogListState, useDatasources, useOnReconnect, type CatalogListState } from '../store/catalog'
|
||||
import { useAtLeast } from '../store/auth'
|
||||
import { useBlueprint } from '../store/blueprint'
|
||||
@@ -383,7 +383,8 @@ function toStreamTurn(turn: ChatTurn): StreamTurn {
|
||||
: turn.phase === 'error' ? 'error'
|
||||
: live || turn.phase === 'checking' ? 'running' : 'done',
|
||||
// 没核对上的不知道结局,用「未运行」那个空心点,不画成完成也不画成失败
|
||||
statusCode: turn.phase === 'cancelled' ? 'cancelled'
|
||||
// 被人驳回的(turn.rejected,服务端 end_reason=rejected)照 lib/status 写「被驳回」,不写「已取消」
|
||||
statusCode: turn.phase === 'cancelled' ? (turn.rejected ? 'rejected' : 'cancelled')
|
||||
: turn.phase === 'suspended' ? 'suspended'
|
||||
// 助手反问:这一轮结束了,在等用户回答
|
||||
: turn.asked && turn.phase === 'done' ? 'waiting'
|
||||
@@ -729,6 +730,7 @@ function Remedies({ conversationId, turnId, last, onRephrase, readOnly }: {
|
||||
|
||||
// 中断、取消、没核对上在流里不出红框(它们不是故障),为什么停、停了意味着什么在这里说
|
||||
const note = kind === 'suspended' || kind === 'unknown' ? turn.failure
|
||||
: kind === 'cancelled' && turn.rejected ? { title: '', reason: REJECTED_TEXT.chatReason, hint: turn.rejected.sub }
|
||||
: kind === 'cancelled' ? { title: '', reason: turn.run ? '你已停止本轮,对应的运行也已一并取消。' : '你在搭建工作流时停止了本轮。' }
|
||||
: null
|
||||
|
||||
|
||||
@@ -205,7 +205,7 @@ export function RunDetailView({ runId, onChange, onDeleted }: {
|
||||
const aimed = focus && !goneFromCanvas(focus) ? focus : null
|
||||
const canvasHref = hrefFor(aimed)
|
||||
// 还在往前走的叫「打开」(接着看实时的、去处理),停下的叫「回放」
|
||||
const replayable = code === 'succeeded' || code === 'failed' || code === 'cancelled'
|
||||
const replayable = code === 'succeeded' || code === 'failed' || code === 'cancelled' || code === 'rejected'
|
||||
const dup = !!run.workflow_id && duplicateNames(workflows.map((w) => ({ id: w.id, name: w.name }))).has(run.workflow_name)
|
||||
|
||||
// ---- 动作 ----
|
||||
@@ -730,7 +730,10 @@ export function RunDetailView({ runId, onChange, onDeleted }: {
|
||||
/** 事件之外的事实(查到的状态、有没有审批)和事件推出的相位合成一个显示码 */
|
||||
function displayCode(run: Run, phase: RunPhase, pending: boolean | undefined): StatusCode {
|
||||
switch (phase) {
|
||||
case 'running': case 'queued': case 'waiting': case 'succeeded': case 'failed': case 'cancelled':
|
||||
case 'cancelled':
|
||||
// 被驳回只看服务端的 end_reason(05-已知遗留 (a))
|
||||
return run.end_reason === 'rejected' ? 'rejected' : 'cancelled'
|
||||
case 'running': case 'queued': case 'waiting': case 'succeeded': case 'failed':
|
||||
return phase
|
||||
case 'suspended':
|
||||
// 后端写的是 interrupted:服务重启打断、没有审批,叫「已挂起 · 可续跑」
|
||||
|
||||
@@ -7,7 +7,8 @@ import {
|
||||
formatCost, formatDateTime, formatDay, formatSpan, formatTime, formatTokens, parseServerTime, shortId,
|
||||
} from '../../lib/format'
|
||||
import {
|
||||
ORIGIN_LABEL, ORIGIN_TEXT, RUN_CLASS_LABEL, TASK_KIND_LABEL, TASK_LOG_TEXT, UNSAVED_HINT, UNSAVED_NAME, isUnsaved, originLabel,
|
||||
ORIGIN_LABEL, ORIGIN_TEXT, REJECTED_TEXT, RUN_CLASS_LABEL, TASK_KIND_LABEL, TASK_LOG_TEXT, UNSAVED_HINT, UNSAVED_NAME, isUnsaved,
|
||||
originLabel,
|
||||
runName,
|
||||
} from '../../lib/terms'
|
||||
import { summarizeRun } from '../../run/decode'
|
||||
@@ -466,6 +467,13 @@ function RowContext({ run, code, approval, now }: {
|
||||
const reason = cancelReason(run.error)
|
||||
return <div className={clsx(line, 'text-faint')} title={run.error ?? undefined}>已取消{reason ? ` · ${reason}` : ''}</div>
|
||||
}
|
||||
case 'rejected':
|
||||
// 人的驳回(end_reason=rejected):报错原文就是给人看的那一句(「「付款」未确认(被驳回),没有发送:…」)
|
||||
return (
|
||||
<div className={clsx(line, 'text-faint')} title={run.error ?? undefined} data-run-reason="rejected">
|
||||
{REJECTED_TEXT.title}{run.error ? ` · ${run.error}` : ''}
|
||||
</div>
|
||||
)
|
||||
default: {
|
||||
const summary = summarizeRun(run.input, run.output)
|
||||
return summary
|
||||
|
||||
@@ -11,7 +11,7 @@ import { explainRunError } from '../../lib/explain'
|
||||
import {
|
||||
NONE, formatCost, formatDateTime, formatNumber, formatOffset, formatSpan, formatTokens, shortId,
|
||||
} from '../../lib/format'
|
||||
import { COST_TEXT, runClassLabel, nodeTypeLabel, runCostText } from '../../lib/terms'
|
||||
import { COST_TEXT, REJECTED_TEXT, runClassLabel, nodeTypeLabel, runCostText } from '../../lib/terms'
|
||||
import { topology, type GraphLike } from '../../run/derive'
|
||||
import {
|
||||
isActivePhase, isSettled, liveAt, project, type NodeState, type Projection, type RunPhase, type Trace,
|
||||
@@ -449,6 +449,7 @@ function momentsOf(
|
||||
const failed = trace.phase === 'failed' ? trace.failedNodeId : undefined
|
||||
const why = trace.phase === 'failed'
|
||||
? explainRunError((failed && trace.nodes[failed]?.error) || error).title
|
||||
: code === 'rejected' ? error?.trim() || undefined
|
||||
: trace.phase === 'cancelled' ? cancelReason(error) ?? undefined
|
||||
: trace.phase === 'suspended' ? error?.trim() || undefined : undefined
|
||||
out.push({
|
||||
@@ -458,6 +459,7 @@ function momentsOf(
|
||||
text: trace.phase === 'succeeded' ? '运行完成'
|
||||
: failed ? `失败于${name(failed)}`
|
||||
: trace.phase === 'failed' ? '运行失败'
|
||||
: code === 'rejected' ? REJECTED_TEXT.title
|
||||
: trace.phase === 'cancelled' ? '运行取消' : '运行挂起',
|
||||
sub: why,
|
||||
})
|
||||
|
||||
@@ -49,8 +49,8 @@ export const SEGMENT_CODES: StatusCode[] = RUN_STATUS_ORDER
|
||||
* 打断后没有审批——要看待审批列表才分得开。approvals 还没加载时传 null,按
|
||||
* 等待审批算(最常见的来源),不会在加载的那一瞬间闪成「已挂起」。
|
||||
*/
|
||||
export function runCode(run: Pick<Run, 'id' | 'status'>, approvals: Approval[] | null): StatusCode {
|
||||
if (run.status !== 'interrupted') return resolveStatus(run.status)
|
||||
export function runCode(run: Pick<Run, 'id' | 'status' | 'end_reason'>, approvals: Approval[] | null): StatusCode {
|
||||
if (run.status !== 'interrupted') return resolveStatus(run.status, { endReason: run.end_reason })
|
||||
return resolveStatus(run.status, {
|
||||
pendingApproval: approvals == null ? undefined : hasPendingApproval(approvals, run.id),
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user