From 09cd6fc3c7de94fff1d7cfc5dfd441ce97f9edf0 Mon Sep 17 00:00:00 2001 From: sophie Date: Thu, 2 Jul 2026 15:23:10 +0800 Subject: [PATCH] =?UTF-8?q?fix(knowdge-base):=20=E4=BF=AE=E5=A4=8Dgoogle?= =?UTF-8?q?=E6=B5=8F=E8=A7=88=E5=99=A8=E4=B8=8D=E5=85=BC=E5=AE=B9=E9=97=AE?= =?UTF-8?q?=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../services/shipping_notice/chat_actions.py | 31 +++++++++++++++++++ .../src/features/kb/views/KbWorkspaceView.vue | 26 ++++++++-------- 2 files changed, 44 insertions(+), 13 deletions(-) diff --git a/backend/app/services/shipping_notice/chat_actions.py b/backend/app/services/shipping_notice/chat_actions.py index d53d1c13..4ee1a74d 100644 --- a/backend/app/services/shipping_notice/chat_actions.py +++ b/backend/app/services/shipping_notice/chat_actions.py @@ -11,6 +11,7 @@ from app.services.shipping_notice.state_machine import ( ALL_ACTION_IDS, ALL_CHECKPOINT_IDS, CHECKPOINT_REGISTRY, + CP_INVENTORY_SOURCE_REVIEW, TaskTransition, TaskUiState, action_buttons_for_checkpoint, @@ -21,6 +22,7 @@ from app.services.shipping_notice.state_machine import ( human_options_for_checkpoint, human_options_for_task, human_options_for_task_or_checkpoint, + inventory_source_action_buttons, resolve_task_ui_state, ui_state_for_checkpoint, upload_req_options_for_task, @@ -30,6 +32,34 @@ from app.services.shipping_notice.state_machine import ( # Legacy alias CHECKPOINT_OPTIONS = CHECKPOINT_REGISTRY + +def build_chat_actions_payload(task): + """ + Build the legacy chat-actions API payload for one shipping task. + + AI trigger: use this when the workspace chat panel needs the current checkpoint + and clickable action buttons for an existing ShippingTask. The payload keeps the + historical `task_id` field as `task.task_no` so older frontend code can consume it. + """ + ui_state = resolve_task_ui_state(task) + action_buttons = ( + inventory_source_action_buttons(task) + if ui_state.checkpoint == CP_INVENTORY_SOURCE_REVIEW + else ui_state.action_buttons + ) + return { + "task_id": task.task_no, + "task_no": task.task_no, + "checkpoint": ui_state.checkpoint, + "human_options": ui_state.human_options or [], + "action_buttons": action_buttons, + "process_status": task.process_status, + "review_status": task.review_status, + "pending_human_reason": task.pending_human_reason, + "match_status": task.match_status, + "updated_at": task.updated_at.isoformat() if task.updated_at else None, + } + __all__ = [ "ACTION_SPECS", "ALL_ACTION_IDS", @@ -41,6 +71,7 @@ __all__ = [ "action_buttons_for_checkpoint", "apply_task_transition", "build_action_buttons", + "build_chat_actions_payload", "build_checkpoint_catalog", "checkpoint_for_task", "human_options_for_checkpoint", diff --git a/frontend/src/features/kb/views/KbWorkspaceView.vue b/frontend/src/features/kb/views/KbWorkspaceView.vue index 32ece3e9..4cb56514 100644 --- a/frontend/src/features/kb/views/KbWorkspaceView.vue +++ b/frontend/src/features/kb/views/KbWorkspaceView.vue @@ -403,7 +403,7 @@ const kb = useKbWorkspace({ embedded: props.embedded }); ? 'border-brand-200 bg-brand-50/50 border-brand-200' : 'border-default'" > -
+