From f58249a75e16f715e93bfe15ca5f86b181ef9b97 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=8E=8B=E5=BE=B7=E5=AE=87?= Date: Sat, 19 Sep 2026 23:12:02 +0800 Subject: [PATCH] =?UTF-8?q?=E7=BB=99=20clientTurnId=20=E7=9A=84=E5=9B=9E?= =?UTF-8?q?=E9=80=80=E7=94=9F=E6=88=90=E8=A1=A5=E4=B8=8A=E9=9A=8F=E6=9C=BA?= =?UTF-8?q?=E7=86=B5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - apps/ai-game-creator-shell/src/view/project-development/chat/conversation/directCodexConversation.ts 在无 crypto.randomUUID 的回退分支追加 Math.random 派生的随机串 - 原先只有时间戳 + 页内序号,多个 WebView 在同一毫秒创建首轮会得到同一个 clientTurnId,而 Rust 侧用它做项目级唯一校验与历史关联键 - 结果仍是 ASCII 字母数字与连字符组成、长度在 6..160 之间,满足 native 校验 --- .../chat/conversation/directCodexConversation.ts | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/apps/ai-game-creator-shell/src/view/project-development/chat/conversation/directCodexConversation.ts b/apps/ai-game-creator-shell/src/view/project-development/chat/conversation/directCodexConversation.ts index 1b28fdb4c..0069a3825 100644 --- a/apps/ai-game-creator-shell/src/view/project-development/chat/conversation/directCodexConversation.ts +++ b/apps/ai-game-creator-shell/src/view/project-development/chat/conversation/directCodexConversation.ts @@ -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(