From 4bbce5f0835cede3c13f6282288b42519eccb49b Mon Sep 17 00:00:00 2001 From: liangxu Date: Sat, 18 Apr 2026 16:17:11 +0800 Subject: [PATCH] feat(kol): add SSE streaming for prompt assist - Extract assist runtime (prompt building, response parsing, finalize) from the worker into kol_assist_runtime so the sync streaming path and the async task path share the same logic. - Add POST /kol/manage/assist/stream as a Server-Sent Events endpoint emitting start/delta/completed/error events, and wire it to a streamAssist helper on kolManageApi that reports ApiClientError with the server's error envelope. - Stream generated content live in KolPromptEditor and KolGenerateView, switching KolPromptEditArea to a boolean aiBusy flag and refining the generator page layout. - Add KolAssistStreamEvent to shared types. Co-Authored-By: Claude Opus 4.7 (1M context) --- .../src/components/kol/KolPromptEditArea.vue | 91 ++-- .../src/components/kol/KolPromptEditor.vue | 157 +++++-- apps/admin-web/src/lib/api.ts | 64 ++- apps/admin-web/src/views/KolGenerateView.vue | 262 +++++++---- .../src/views/TemplateWizardView.vue | 2 +- apps/admin-web/src/views/TemplatesView.vue | 14 +- apps/admin-web/src/views/WorkspaceView.vue | 15 +- packages/shared-types/src/index.ts | 12 + .../internal/tenant/app/kol_assist_runtime.go | 423 ++++++++++++++++++ .../tenant/app/kol_assist_runtime_test.go | 81 ++++ .../tenant/transport/kol_manage_handler.go | 113 +++++ server/internal/tenant/transport/router.go | 1 + .../worker/assist/kol_assist_worker.go | 61 +-- 13 files changed, 1062 insertions(+), 234 deletions(-) create mode 100644 server/internal/tenant/app/kol_assist_runtime.go create mode 100644 server/internal/tenant/app/kol_assist_runtime_test.go diff --git a/apps/admin-web/src/components/kol/KolPromptEditArea.vue b/apps/admin-web/src/components/kol/KolPromptEditArea.vue index c13fac6..9034a23 100644 --- a/apps/admin-web/src/components/kol/KolPromptEditArea.vue +++ b/apps/admin-web/src/components/kol/KolPromptEditArea.vue @@ -1,7 +1,7 @@