refactor(agent-runtime, shipping-notice, frontend): 重构上下文体系,修复重试RPA无响应问题
- 替换原有的hxops_context模块为全新的代理运行时上下文平台协议,统一跨业务上下文注入逻辑 - 新增多语言操作繁忙提示文案(覆盖中、繁、英、泰四语),前端绑定页面繁忙状态实现操作阻断 - 调整RPA库存导出重试策略:移除可配置的最大自动重试次数,改为固定单次自动重试,手动重试需用户显式触发 - 优化任务用户态状态展示逻辑,优先展示具体的pending原因而非通用状态文案 - 重构任务焦点切换逻辑,统一事件日志与处理流程,复用switch_batch_focus工具函数 - 修复clearAllHistory函数残留UI问题,确保清空会话后完全复位发货通知相关视图 - 更新OpenAPI文档与静态快照,补充工具使用约束说明 - 新增调试打点日志与问题排查文档,完善全套单元测试与快照校验用例 - 更新RPA脚本的README文档,调整登录方式说明与浏览器 profile 路径配置 - 删除废弃的hxops_context模块,迁移所有相关调用到新的上下文体系
This commit is contained in:
1 parent
60dd0c0f58
commit
8846ce159f
102 files changed
+18289
-9072
No files matched your search
@@ -10,6 +10,7 @@ import {
|
||||
submitWorkspaceShippingDecision,
|
||||
} from '@/features/chat/api/shipping.api';
|
||||
import { formatShippingDecisionAssistantMessage } from './shippingDecisionFormat';
|
||||
import { reportShippingDebugEvent } from './shippingDebugReporter';
|
||||
import type { ChatMessage, ChatSessionItem } from '../types/chat.types';
|
||||
import type { ComputedRef, Ref } from 'vue';
|
||||
|
||||
@@ -31,6 +32,7 @@ export interface ShippingDecisionContext {
|
||||
|
||||
export interface ExecuteShippingDecisionOptions {
|
||||
silent?: boolean;
|
||||
taskId?: string;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -43,6 +45,11 @@ export interface ExecuteShippingDecisionOptions {
|
||||
export function createShippingDecisionHandlers(ctx: ShippingDecisionContext) {
|
||||
const manualUploadInFlightTaskIds = new Set<string>();
|
||||
|
||||
// #region debug-point D:decision-submit
|
||||
const reportRetryRpaDebug = (hypothesisId: string, msg: string, data: Record<string, unknown>) =>
|
||||
reportShippingDebugEvent('useChatShippingDecision.ts', hypothesisId, msg, data);
|
||||
// #endregion
|
||||
|
||||
const syncHistoryIfNeeded = async () => {
|
||||
if (!ctx.conversationId.value && ctx.history.value.length === 0) {
|
||||
await ctx.loadHistory();
|
||||
@@ -54,10 +61,12 @@ export function createShippingDecisionHandlers(ctx: ShippingDecisionContext) {
|
||||
|
||||
/**
|
||||
* 提交发货人工决策,并按需把结果落为本地聊天消息。
|
||||
* 核心逻辑:先基于 taskId 调后端决策接口,再根据 silent 选项决定是否写入本地 user/assistant 气泡。
|
||||
* 核心逻辑:优先使用 options.taskId 提交指定任务的决策;未显式传入时再回退到当前激活任务。
|
||||
* 这样可避免工作台多任务场景在焦点刷新抖动时,把 retry_rpa 错投到空任务或直接中断。
|
||||
* @param decision - 决策动作 ID,如 confirm、reparse_inventory
|
||||
* @param displayText - 用户侧展示文案;未传时回退为 decision
|
||||
* @param options.silent - 为 true 时只更新状态与按钮,不追加本地聊天消息
|
||||
* @param options.taskId - 显式指定要提交决策的任务编号;工作台多票动作优先传入
|
||||
* @returns 是否成功提交决策
|
||||
*/
|
||||
const executeShippingDecision = async (
|
||||
@@ -65,16 +74,44 @@ export function createShippingDecisionHandlers(ctx: ShippingDecisionContext) {
|
||||
displayText?: string,
|
||||
options?: ExecuteShippingDecisionOptions,
|
||||
) => {
|
||||
const taskId = ctx.getActiveShippingTaskId();
|
||||
const taskId = String(options?.taskId || ctx.getActiveShippingTaskId() || '').trim().toUpperCase();
|
||||
// #region debug-point D:decision-entry
|
||||
void reportRetryRpaDebug('D', 'executeShippingDecision entry', {
|
||||
decision,
|
||||
taskId,
|
||||
conversationId: ctx.conversationId.value,
|
||||
isShippingNoticeAgent: ctx.isShippingNoticeAgent.value,
|
||||
silent: Boolean(options?.silent),
|
||||
});
|
||||
// #endregion
|
||||
if (!taskId) {
|
||||
// #region debug-point D:decision-missing-task
|
||||
void reportRetryRpaDebug('D', 'executeShippingDecision missing taskId', {
|
||||
decision,
|
||||
conversationId: ctx.conversationId.value,
|
||||
});
|
||||
// #endregion
|
||||
ctx.msg.warning(ctx.t('chat.shippingNoticeMissingTaskId'));
|
||||
return false;
|
||||
}
|
||||
try {
|
||||
// #region debug-point D:decision-before-submit
|
||||
void reportRetryRpaDebug('D', 'executeShippingDecision before submit', {
|
||||
decision,
|
||||
taskId,
|
||||
});
|
||||
// #endregion
|
||||
const result =
|
||||
decision === 'confirm_inventory_mapping'
|
||||
? await autoProgressWorkspaceShippingTask(taskId)
|
||||
: await submitWorkspaceShippingDecision(taskId, decision);
|
||||
// #region debug-point D:decision-after-submit
|
||||
void reportRetryRpaDebug('D', 'executeShippingDecision after submit', {
|
||||
decision,
|
||||
taskId,
|
||||
message: String(result?.message || ''),
|
||||
});
|
||||
// #endregion
|
||||
if (decision === 'correct_inventory_mapping') {
|
||||
const preview = result?.data?.schema_preview;
|
||||
const key = String(taskId || '').trim().toUpperCase();
|
||||
@@ -108,10 +145,20 @@ export function createShippingDecisionHandlers(ctx: ShippingDecisionContext) {
|
||||
local_only: true,
|
||||
};
|
||||
ctx.messages.value.push(userMsg, assistantMsg);
|
||||
// #region debug-point D:decision-messages-appended
|
||||
void reportRetryRpaDebug('D', 'executeShippingDecision appended local messages', {
|
||||
decision,
|
||||
taskId,
|
||||
totalMessages: ctx.messages.value.length,
|
||||
lastUserPreview: String(userMsg.content || '').slice(0, 80),
|
||||
lastAssistantPreview: String(assistantContent || '').slice(0, 120),
|
||||
});
|
||||
// #endregion
|
||||
await ctx.saveLocalMessageToBackend(userMsg, userText);
|
||||
await ctx.saveLocalMessageToBackend(assistantMsg);
|
||||
await syncHistoryIfNeeded();
|
||||
}
|
||||
// 工作台内的 shipping agent 决策以聊天气泡和任务卡刷新为主,避免 retry_rpa 再弹成功 toast 打断操作流。
|
||||
if (result.message && !ctx.isShippingNoticeAgent.value) {
|
||||
ctx.msg.success(result.message);
|
||||
}
|
||||
@@ -121,6 +168,13 @@ export function createShippingDecisionHandlers(ctx: ShippingDecisionContext) {
|
||||
}
|
||||
return true;
|
||||
} catch (e: unknown) {
|
||||
// #region debug-point D:decision-catch
|
||||
void reportRetryRpaDebug('D', 'executeShippingDecision caught error', {
|
||||
decision,
|
||||
taskId,
|
||||
errorMessage: e instanceof Error ? e.message : String(e),
|
||||
});
|
||||
// #endregion
|
||||
const errorMessage = e instanceof Error ? e.message : ctx.t('chat.shippingNoticeUploadFailed');
|
||||
ctx.msg.warning(errorMessage);
|
||||
return false;
|
||||
|
||||
Reference in new issue
Block a user