修复拼图生成前订阅授权

新增小程序原生订阅消息授权页,在用户点击后请求生成结果通知授权。

拼图 compile_puzzle_draft 前等待授权页返回或跳过后再发起生成 action。

移除 web-view message 订阅授权路径,改用 storage/hash 回写订阅结果。

补充订阅授权测试、文档和团队踩坑记录。
This commit is contained in:
kdletters
2026-06-08 13:06:07 +08:00
parent 38d9c292ae
commit 3a918687c5
17 changed files with 708 additions and 71 deletions

View File

@@ -1,5 +1,5 @@
import { useCallback, useEffect, useRef, useState } from 'react';
import type { Dispatch, SetStateAction } from 'react';
import { useCallback, useEffect, useRef, useState } from 'react';
import type { TextStreamOptions } from '../../services/aiTypes';
import type { SelectionStage } from './platformEntryTypes';
@@ -90,7 +90,7 @@ type PlatformCreationAgentFlowControllerOptions<
beforeExecuteAction?: (params: {
payload: TActionPayload;
session: TSession;
}) => void;
}) => void | Promise<void>;
onActionError?: (params: {
payload: TActionPayload;
error: unknown;
@@ -211,7 +211,7 @@ export function usePlatformCreationAgentFlowController<
setIsBusy(false);
}
},
[isBusy, options, resetStreamingReply],
[isBusy, options, resetStreamingReply, setSession],
);
const restoreDraft = useCallback(
@@ -249,7 +249,7 @@ export function usePlatformCreationAgentFlowController<
setIsBusy(false);
}
},
[options, resetStreamingReply],
[options, resetStreamingReply, setSession],
);
const submitMessage = useCallback(
@@ -309,7 +309,13 @@ export function usePlatformCreationAgentFlowController<
setIsStreamingReply(false);
}
},
[isStreamingReply, options, session, updateStreamingReplyText],
[
isStreamingReply,
options,
session,
setSession,
updateStreamingReplyText,
],
);
const executeAction = useCallback(
@@ -323,7 +329,7 @@ export function usePlatformCreationAgentFlowController<
setError(null);
try {
options.beforeExecuteAction?.({ payload, session: targetSession });
await options.beforeExecuteAction?.({ payload, session: targetSession });
const response = await options.client.executeAction(
targetSession.sessionId,
payload,
@@ -358,7 +364,7 @@ export function usePlatformCreationAgentFlowController<
setIsBusy(false);
}
},
[isBusy, options, session],
[isBusy, options, session, setSession],
);
const leaveFlow = useCallback(() => {