Files
syops/frontend/src/features/chat/shipping/shippingActionBusy.ts
T
hugo 8846ce159f refactor(agent-runtime, shipping-notice, frontend): 重构上下文体系,修复重试RPA无响应问题
- 替换原有的hxops_context模块为全新的代理运行时上下文平台协议,统一跨业务上下文注入逻辑
- 新增多语言操作繁忙提示文案(覆盖中、繁、英、泰四语),前端绑定页面繁忙状态实现操作阻断
- 调整RPA库存导出重试策略:移除可配置的最大自动重试次数,改为固定单次自动重试,手动重试需用户显式触发
- 优化任务用户态状态展示逻辑,优先展示具体的pending原因而非通用状态文案
- 重构任务焦点切换逻辑,统一事件日志与处理流程,复用switch_batch_focus工具函数
- 修复clearAllHistory函数残留UI问题,确保清空会话后完全复位发货通知相关视图
- 更新OpenAPI文档与静态快照,补充工具使用约束说明
- 新增调试打点日志与问题排查文档,完善全套单元测试与快照校验用例
- 更新RPA脚本的README文档,调整登录方式说明与浏览器 profile 路径配置
- 删除废弃的hxops_context模块,迁移所有相关调用到新的上下文体系
2026-07-03 17:01:42 +08:00

35 lines
1.7 KiB
TypeScript
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
/**
* features/chat/shipping/shippingActionBusy.ts
* 用途:判定发货工作台动作是否应被聊天流忙碌态阻塞。
* 依赖:chat.types 中的 ChatRunStatus 约定;由 useChatPage 与 useChatShipping 共同复用。
* 逻辑:上游先维护全局 isThinking / runs / activeRunId;本文件再过滤出“当前确实存在运行中的 chat run”这一更可信的忙碌态,避免残留 isThinking 误锁工作台。
*/
import type { ChatRun } from '../types/chat.types';
/**
* 判断当前聊天页是否真的存在活跃中的流式问答。
*
* 核心逻辑:仅当 `isThinking=true` 且 runs 中仍存在 `status=running` 的记录时才返回 busy;
* 如果只是历史残留的 thinking 标记,但没有任何运行中的 run,则允许 shipping 工作台继续触发人工动作。
* @param isThinking - 聊天页当前暴露的全局思考态
* @param activeRunId - 当前激活 run 编号;缺失时会回退扫描全部 runs
* @param runs - 当前页面维护的 run 列表
* @returns `true` 表示应继续阻塞工作台动作;`false` 表示可视为残留锁定并允许继续操作
*/
export function hasActiveRunningChatRun(
isThinking: boolean,
activeRunId: number | null | undefined,
runs: ChatRun[] | null | undefined,
): boolean {
if (!isThinking) return false;
const list = Array.isArray(runs) ? runs : [];
if (!list.length) return false;
const normalizedActiveRunId = Number(activeRunId);
if (Number.isFinite(normalizedActiveRunId) && normalizedActiveRunId > 0) {
return list.some((run) => run.runId === normalizedActiveRunId && run.status === 'running');
}
return list.some((run) => run.status === 'running');
}