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
@@ -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