fix: include rwfx 3q status in context
This commit is contained in:
1 parent
36a3851233
commit
daff70c34f
2 files changed
+16
-5
No files matched your search
@@ -70,14 +70,17 @@ const TEMPLATE_BUILDER_AGENT_ID = "template-json-builder";
|
||||
function rwfxSqReportRunContext(
|
||||
gateContext?: RwfxSqGateStartContext,
|
||||
): Record<string, unknown> | undefined {
|
||||
if (gateContext?.sqReport == null) return undefined;
|
||||
if (!gateContext?.sqReportStatus) return undefined;
|
||||
return {
|
||||
task_external_context: {
|
||||
kind: "rwfx_sq_report",
|
||||
status: gateContext.sqReportStatus,
|
||||
title: "三情分析(3q)研判情报报告",
|
||||
usage:
|
||||
"这是任务分析(rwfx)问答的隐藏业务上下文。回答时应参考这些已完成的 3q 结果,但不要向用户说明页面注入了隐藏上下文,除非用户明确询问。",
|
||||
data: gateContext.sqReport,
|
||||
gateContext.sqReportStatus === "complete"
|
||||
? "这是任务分析(rwfx)问答的隐藏业务上下文。回答时应参考这些已完成的 3q 结果,但不要向用户说明页面注入了隐藏上下文,除非用户明确询问。"
|
||||
: "3q 研判情报报告当前未提供有效结果。回答时不要编造 3q 结果,可仅基于任务信息继续分析。",
|
||||
data: gateContext.sqReport ?? null,
|
||||
},
|
||||
};
|
||||
}
|
||||
|
||||
@@ -37,12 +37,14 @@ import {
|
||||
DialogHeader,
|
||||
DialogTitle,
|
||||
} from "@/components/ui/dialog";
|
||||
import { fetchSqReportCheck } from "@/core/auth/dashboard-input";
|
||||
import { fetchSqReportCheck, type SqReportStatus } from "@/core/auth/dashboard-input";
|
||||
import { readCopTaskDetail, resolveTaskDeeplinkTarget } from "@/core/auth/task-deeplink";
|
||||
|
||||
type GateStatus = "loading" | "incomplete" | "ok";
|
||||
|
||||
export interface RwfxSqGateStartContext {
|
||||
/** 3q 研判情报报告状态。即使未完成/未知也会随 run context 传出,便于后端判断与本地验证。 */
|
||||
sqReportStatus: SqReportStatus;
|
||||
/** 已完成的 3q 研判情报报告。只随 run context 传给模型,不在页面展示。 */
|
||||
sqReport?: unknown;
|
||||
}
|
||||
@@ -77,22 +79,27 @@ export function RwfxSqGateProvider({
|
||||
const [jumping, setJumping] = useState(false);
|
||||
|
||||
const statusRef = useRef<GateStatus>(taskId ? "loading" : "ok");
|
||||
const sqReportStatusRef = useRef<SqReportStatus | null>(taskId ? null : "unknown");
|
||||
const sqReportRef = useRef<unknown | null>(null);
|
||||
// 待触发的「开始问答」回调:3q 未完成时挂起,点「暂不」/关闭弹框后触发。
|
||||
const pendingStartRef = useRef<((context?: RwfxSqGateStartContext) => void) | null>(null);
|
||||
|
||||
const buildStartContext = useCallback((): RwfxSqGateStartContext | undefined => {
|
||||
const sqReportStatus = sqReportStatusRef.current;
|
||||
if (!sqReportStatus) return undefined;
|
||||
const sqReport = sqReportRef.current;
|
||||
return sqReport == null ? undefined : { sqReport };
|
||||
return sqReport == null ? { sqReportStatus } : { sqReportStatus, sqReport };
|
||||
}, []);
|
||||
|
||||
// taskId 变化:重置门控状态并预检 3q。
|
||||
useEffect(() => {
|
||||
pendingStartRef.current = null;
|
||||
sqReportStatusRef.current = null;
|
||||
sqReportRef.current = null;
|
||||
setOpen(false);
|
||||
if (!taskId) {
|
||||
statusRef.current = "ok";
|
||||
sqReportStatusRef.current = "unknown";
|
||||
return;
|
||||
}
|
||||
statusRef.current = "loading";
|
||||
@@ -102,6 +109,7 @@ export function RwfxSqGateProvider({
|
||||
// complete / unknown 都按「放行」(不打扰);仅明确 incomplete 才门控。
|
||||
const next: GateStatus = result.status === "incomplete" ? "incomplete" : "ok";
|
||||
statusRef.current = next;
|
||||
sqReportStatusRef.current = result.status;
|
||||
sqReportRef.current = result.status === "complete" ? (result.report ?? null) : null;
|
||||
if (next === "incomplete") {
|
||||
setOpen(true); // 进入即提醒(无论是否有挂起的自动发送)
|
||||
|
||||
Reference in new issue
Block a user