diff --git a/.github/workflows/pr-agent.yml b/.github/workflows/pr-agent.yml index 39d0509..afe8df4 100644 --- a/.github/workflows/pr-agent.yml +++ b/.github/workflows/pr-agent.yml @@ -11,7 +11,9 @@ jobs: if: > github.event_name == 'pull_request' || (github.event_name == 'issue_comment' && - startsWith(github.event.comment.body, '/')) + github.event.issue.pull_request && + startsWith(github.event.comment.body, '/') && + contains(fromJSON('["OWNER","MEMBER","COLLABORATOR"]'), github.event.comment.author_association)) runs-on: ubuntu-latest permissions: issues: write @@ -36,7 +38,9 @@ jobs: if: > github.event_name == 'pull_request' || (github.event_name == 'issue_comment' && - startsWith(github.event.comment.body, '/')) + github.event.issue.pull_request && + startsWith(github.event.comment.body, '/') && + contains(fromJSON('["OWNER","MEMBER","COLLABORATOR"]'), github.event.comment.author_association)) runs-on: ubuntu-latest permissions: issues: write diff --git a/app/api/gallery-pack/route.ts b/app/api/gallery-pack/route.ts index 9fd5667..818b65e 100644 --- a/app/api/gallery-pack/route.ts +++ b/app/api/gallery-pack/route.ts @@ -27,7 +27,7 @@ export async function POST(req: Request): Promise { return Response.json({ error: "Bad JSON" }, { status: 400 }); } - if (docStr.length > MAX_DOC_BYTES) { + if (new TextEncoder().encode(docStr).byteLength > MAX_DOC_BYTES) { return Response.json( { error: "图集数据太大,无法打包分享" }, { status: 413 }, diff --git a/app/play/page.tsx b/app/play/page.tsx index 66a8a48..0787ab4 100644 --- a/app/play/page.tsx +++ b/app/play/page.tsx @@ -1171,7 +1171,10 @@ function PlayInner() { if (sessionOrientation === "portrait") { console.warn(`[play] portrait firstact missing for ${cardName} (HTTP ${r.status}), falling back to landscape`); const fb = await fetch(`/home/firstact/${encodeURIComponent(cardName)}.json`); - if (fb.ok) return (await fb.json()) as PrebakedFirstAct; + if (fb.ok) { + const fallback = (await fb.json()) as PrebakedFirstAct; + return { ...fallback, scene: { ...fallback.scene, orientation: "landscape" as const } }; + } } throw new Error(`找不到精选剧情:${cardName}`); }, @@ -1500,10 +1503,12 @@ function PlayInner() { ...currentScene, beats: [...currentScene.beats, newBeat], }; + const nextVisited = [...visitedBeatsRef.current, newBeatId]; + visitedBeatsRef.current = nextVisited; const nextSession: Session = { ...session, history: session.history.map((h, i, arr) => - i === arr.length - 1 ? { ...h, scene: patched } : h, + i === arr.length - 1 ? { ...h, scene: patched, visitedBeatIds: nextVisited } : h, ), characters: mergeCharactersPreserveVoice( session.characters, diff --git a/components/SettingsModal.tsx b/components/SettingsModal.tsx index 14b832e..607a872 100644 --- a/components/SettingsModal.tsx +++ b/components/SettingsModal.tsx @@ -100,10 +100,9 @@ export function SettingsModal({ const presetId = keyType === "payg" ? PAYG_PRESET_ID : regionId; writeStoredTtsConfig({ presetId, apiKey: key }); ttsConfigured = true; - } else if (!ttsAlreadyConfigured) { - ttsConfigured = false; } else { - ttsConfigured = true; + clearStoredTtsConfig(); + ttsConfigured = false; } onSaved({ ttsConfigured, playerName: name, visionClickEnabled: visionClick }); diff --git a/lib/engine/agents/styleSelector.ts b/lib/engine/agents/styleSelector.ts index abacf8c..647437d 100644 --- a/lib/engine/agents/styleSelector.ts +++ b/lib/engine/agents/styleSelector.ts @@ -28,7 +28,9 @@ export async function selectStyle( if (STYLE_MAP[picked]) { return STYLE_MAP[picked]; } - const fuzzy = STYLE_NAMES.find((s) => picked.includes(s) || s.includes(picked)); + const fuzzy = picked + ? STYLE_NAMES.find((s) => picked.includes(s) || s.includes(picked)) + : undefined; if (fuzzy) { return STYLE_MAP[fuzzy]!; }