Files
syops/backend/app/services/shipping_notice/chat_actions.py
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

85 lines
2.6 KiB
Python
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.
"""
services/shipping_notice/chat_actions.py
用途:发货通知状态机旧模块名的向后兼容 re-export 入口。
依赖:state_machine(ACTION_SPECS、CHECKPOINT_REGISTRY、apply_task_transition 等)、ui_state。
逻辑:历史代码 import chat_actions;新代码应直接引用 state_machine.py / ui_state.py,本模块仅保留兼容导出。
"""
from app.services.shipping_notice.state_machine import (
ACTION_SPECS,
ALL_ACTION_IDS,
ALL_CHECKPOINT_IDS,
CHECKPOINT_REGISTRY,
TaskTransition,
TaskUiState,
action_buttons_for_checkpoint,
apply_task_transition,
build_action_buttons,
build_checkpoint_catalog,
checkpoint_for_task,
human_options_for_checkpoint,
human_options_for_task,
human_options_for_task_or_checkpoint,
resolve_task_ui_state,
ui_state_for_checkpoint,
upload_req_options_for_task,
validate_registry,
)
from app.services.shipping_notice.ui_state import build_task_ui_state
# Legacy alias
CHECKPOINT_OPTIONS = CHECKPOINT_REGISTRY
def build_chat_actions_payload(task) -> dict:
"""
构建聊天气泡侧动作按钮兼容 payload。
核心逻辑:复用统一 UI State 读模型,只抽取聊天侧需要的 checkpoint/action_buttons/summary,
避免 workspace 路由继续依赖已删除的旧读模型实现。
Args:
task: ShippingTask 模型实例。
Returns:
包含 task_no、checkpoint、action_buttons 与摘要的字典。
"""
state = build_task_ui_state(task)
return {
"task_no": state.get("task_no"),
"batch_no": state.get("batch_no"),
"checkpoint": state.get("checkpoint"),
"process_status": state.get("process_status"),
"review_status": state.get("review_status"),
"pending_human_reason": state.get("pending_human_reason"),
"match_status": state.get("match_status"),
"current_step": state.get("current_step"),
"summary": state.get("summary"),
"action_buttons": state.get("action_buttons") or [],
"updated_at": state.get("updated_at"),
}
__all__ = [
"ACTION_SPECS",
"ALL_ACTION_IDS",
"ALL_CHECKPOINT_IDS",
"CHECKPOINT_OPTIONS",
"CHECKPOINT_REGISTRY",
"TaskTransition",
"TaskUiState",
"action_buttons_for_checkpoint",
"apply_task_transition",
"build_action_buttons",
"build_chat_actions_payload",
"build_checkpoint_catalog",
"checkpoint_for_task",
"human_options_for_checkpoint",
"human_options_for_task",
"human_options_for_task_or_checkpoint",
"resolve_task_ui_state",
"ui_state_for_checkpoint",
"upload_req_options_for_task",
"validate_registry",
]