给 clientTurnId 的回退生成补上随机熵
- apps/ai-game-creator-shell/src/view/project-development/chat/conversation/directCodexConversation.ts 在无 crypto.randomUUID 的回退分支追加 Math.random 派生的随机串 - 原先只有时间戳 + 页内序号,多个 WebView 在同一毫秒创建首轮会得到同一个 clientTurnId,而 Rust 侧用它做项目级唯一校验与历史关联键 - 结果仍是 ASCII 字母数字与连字符组成、长度在 6..160 之间,满足 native 校验
This commit is contained in:
+4
-1
@@ -55,7 +55,10 @@ export function createDirectProjectTurnId() {
|
||||
// WebView 没有 crypto 时使用时间戳和页内序号。
|
||||
}
|
||||
if (/^[a-z0-9][a-z0-9-]{5,159}$/iu.test(randomId)) return randomId;
|
||||
return `${Date.now().toString(36)}-${directProjectTurnSequence.toString(36)}`;
|
||||
// 回退路径也要有实例内唯一性:时间戳 + 页内序号在多 WebView 同毫秒首轮时会撞车,
|
||||
// clientTurnId 是 Rust 侧的项目级唯一与历史关联键,所以再补一段随机串。
|
||||
const entropy = Math.random().toString(36).slice(2, 10);
|
||||
return `${Date.now().toString(36)}-${directProjectTurnSequence.toString(36)}-${entropy}`;
|
||||
}
|
||||
|
||||
export function directCodexConversationMessageId(
|
||||
|
||||
Reference in New Issue
Block a user