From e1fed5e47ff8915825516683f36386acc03ecb51 Mon Sep 17 00:00:00 2001 From: Zhenhao Liu <176368005+LikC1606@users.noreply.github.com> Date: Wed, 25 Nov 2026 12:19:50 +0800 Subject: [PATCH] fix(web): repair site typecheck, split English workbench bundle, and fix chat task keys --- .github/workflows/verify.yml | 2 +- apps/web/client/formalize.html | 2 +- apps/web/client/guide.html | 2 +- apps/web/client/invite.html | 2 +- apps/web/client/library.html | 2 +- apps/web/client/login.html | 2 +- apps/web/client/people.html | 2 +- apps/web/client/practice.html | 2 +- apps/web/client/privacy.html | 2 +- apps/web/client/problem.html | 2 +- apps/web/client/share.html | 2 +- apps/web/client/terms.html | 2 +- apps/web/client/theorems.html | 2 +- apps/web/client/ui/ChatWorkspace.tsx | 2 +- apps/web/client/workspace.html | 2 +- docs/web/landing.ts | 2 +- docs/web/process.ts | 9 +++++---- scripts/build-web.ts | 19 ++++++++++--------- scripts/test-web-ui.ts | 2 +- 19 files changed, 32 insertions(+), 30 deletions(-) diff --git a/.github/workflows/verify.yml b/.github/workflows/verify.yml index 8be512d3..9943f760 100644 --- a/.github/workflows/verify.yml +++ b/.github/workflows/verify.yml @@ -26,7 +26,7 @@ jobs: with: bun-version: 1.4.0 - run: bun install --frozen-lockfile - - run: bun run typecheck && bun run typecheck:web + - run: bun run typecheck && bun run typecheck:web && bun run typecheck:site - name: Verify account, job, persistence and operations boundaries without models run: bunx vitest run --maxWorkers=4 tests/webAuth.test.ts tests/webSignup.test.ts tests/webAuthPolicy.test.ts tests/webQuota.test.ts tests/webAdmission.test.ts tests/webAdmissionRace.test.ts tests/webProviderCheck.test.ts tests/webI18n.test.ts tests/webFonts.test.ts tests/webKeyVault.test.ts tests/webJobs.test.ts tests/webLifecyclePersistence.test.ts tests/webCollaboration.test.ts tests/webConversations.test.ts tests/webExplain.test.ts tests/webPersistence.test.ts tests/webFormalizations.test.ts tests/webExplanation.test.ts tests/webExplanationServer.test.ts tests/webServer.test.ts tests/webRunStream.test.ts tests/webRunner.test.ts tests/webPrecheck.test.ts tests/webOperations.test.ts tests/webOperationsApi.test.ts tests/webOperationsScheduled.test.ts tests/webOperationsMonitor.test.ts - name: Verify isolated provider routing and usage accounting without models diff --git a/apps/web/client/formalize.html b/apps/web/client/formalize.html index 186a2166..8de54c6d 100644 --- a/apps/web/client/formalize.html +++ b/apps/web/client/formalize.html @@ -53,5 +53,5 @@ - + diff --git a/apps/web/client/guide.html b/apps/web/client/guide.html index 0839fbc5..206223fd 100644 --- a/apps/web/client/guide.html +++ b/apps/web/client/guide.html @@ -126,6 +126,6 @@

数据与费用

- + diff --git a/apps/web/client/invite.html b/apps/web/client/invite.html index 355dcacc..4bb2b838 100644 --- a/apps/web/client/invite.html +++ b/apps/web/client/invite.html @@ -9,6 +9,6 @@
正在读取研究邀请…
- + diff --git a/apps/web/client/library.html b/apps/web/client/library.html index 9ade5939..914fe302 100644 --- a/apps/web/client/library.html +++ b/apps/web/client/library.html @@ -9,6 +9,6 @@
正在读取共享库…
- + diff --git a/apps/web/client/login.html b/apps/web/client/login.html index 68a758a2..1ae49b21 100644 --- a/apps/web/client/login.html +++ b/apps/web/client/login.html @@ -62,6 +62,6 @@

登录研究工作台

- + diff --git a/apps/web/client/people.html b/apps/web/client/people.html index 7e021188..086f1ce7 100644 --- a/apps/web/client/people.html +++ b/apps/web/client/people.html @@ -9,6 +9,6 @@
正在读取研究空间…
- + diff --git a/apps/web/client/practice.html b/apps/web/client/practice.html index 679f328d..eab74862 100644 --- a/apps/web/client/practice.html +++ b/apps/web/client/practice.html @@ -11,6 +11,6 @@
TheoremOS
- + diff --git a/apps/web/client/privacy.html b/apps/web/client/privacy.html index 25c8d95b..b5bea7e5 100644 --- a/apps/web/client/privacy.html +++ b/apps/web/client/privacy.html @@ -76,6 +76,6 @@

五、联系

- + diff --git a/apps/web/client/problem.html b/apps/web/client/problem.html index 3ef2aa86..282cef48 100644 --- a/apps/web/client/problem.html +++ b/apps/web/client/problem.html @@ -9,6 +9,6 @@
正在读取题目工作区…
- + diff --git a/apps/web/client/share.html b/apps/web/client/share.html index c51798d6..1da7673a 100644 --- a/apps/web/client/share.html +++ b/apps/web/client/share.html @@ -66,6 +66,6 @@

验收记录

- + diff --git a/apps/web/client/terms.html b/apps/web/client/terms.html index 288b1c72..757aa946 100644 --- a/apps/web/client/terms.html +++ b/apps/web/client/terms.html @@ -72,6 +72,6 @@

五、条款更新与联系

- + diff --git a/apps/web/client/theorems.html b/apps/web/client/theorems.html index deb4d4df..33ca0589 100644 --- a/apps/web/client/theorems.html +++ b/apps/web/client/theorems.html @@ -9,6 +9,6 @@
正在读取定理…
- + diff --git a/apps/web/client/ui/ChatWorkspace.tsx b/apps/web/client/ui/ChatWorkspace.tsx index 488bbb6b..a83ecc06 100644 --- a/apps/web/client/ui/ChatWorkspace.tsx +++ b/apps/web/client/ui/ChatWorkspace.tsx @@ -298,7 +298,7 @@ function TaskMessage(props: ChatThreadProps) { function MessageTaskLinks({ message, ...props }: ChatThreadProps & { message: WebConversationMessage }) { const tasks = props.run?.observation?.inspection.tasks.filter(task => task.theorem && message.text.includes(task.theorem) || message.guidance?.input.taskRef?.id === task.id) ?? []; - return tasks.length > 0 ? : null; } diff --git a/apps/web/client/workspace.html b/apps/web/client/workspace.html index 90df9792..3b9a1bd8 100644 --- a/apps/web/client/workspace.html +++ b/apps/web/client/workspace.html @@ -9,6 +9,6 @@
正在读取研究空间…
- + diff --git a/docs/web/landing.ts b/docs/web/landing.ts index 35bf9b55..6fb693c4 100644 --- a/docs/web/landing.ts +++ b/docs/web/landing.ts @@ -283,7 +283,7 @@ function initializeProofStage() { if (!canvas) return; const setScale = (width: number) => stage.style.setProperty('--stage-scale', String(width / 1120)); setScale(stage.getBoundingClientRect().width); - if ('ResizeObserver' in window) { + if (typeof ResizeObserver === 'function') { new ResizeObserver(entries => entries.forEach(entry => setScale(entry.contentRect.width))).observe(stage); } else { window.addEventListener('resize', () => setScale(stage.getBoundingClientRect().width)); diff --git a/docs/web/process.ts b/docs/web/process.ts index 6c1f10f9..b92834b7 100644 --- a/docs/web/process.ts +++ b/docs/web/process.ts @@ -6,7 +6,7 @@ import { archiveRoadmapTaskLabel } from './roadmapLabels'; import { renderGlobalTrajectory } from './globalTrajectory'; import { readableProcessText } from './processText'; import { selectedProofWalkthrough } from './proofWalkthrough'; -import type { Localized, ProofWalkthrough, ProofWalkthroughStage, ProofWalkthroughStep } from './proofWalkthroughTypes'; +import type { Localized, ProofWalkthrough } from './proofWalkthroughTypes'; type Run = ArchiveProcess['runs'][number]; type Task = Run['tasks'][number]; @@ -154,13 +154,14 @@ function stepDetail(step: Step, run: Run, record: ArchiveIndexRecord, process: A return task ? `` : `${escape(id.trim())}`; }).join('')}` : summary ? `
${escape(summary)}
` : ''} ${check ? `

${check.scope === 'original' ? choose(locale, '完整原题检查', 'Original problem check') : choose(locale, '局部任务检查', 'Task proof check')}

- ${check.diagnostics ? checkFeedback(check, locale) : ''} + ${checkFeedback(check, locale)} ${checkSource(check, run, process, selection, locale)}` : ''} ${rawDetails([['Kind', step.delivery?.kind ?? step.kind], ['Status', step.status], ['Task ID', step.taskId], ['Commit', check?.commit ?? step.delivery?.commit], ['Lean receipts', check?.receiptIds.join('\n')], ['Worker', step.delivery?.workerId], ['Role', step.delivery?.role]], locale)}`; } /** A verdict a reader can start from; the raw Lean bytes stay one disclosure away. */ function checkFeedback(check: Check, locale: Locale): string { + if (!check.diagnostics) return ''; const failed = ['failed', 'error'].includes(check.status ?? ''); const verdict = failed ? choose(locale, 'Lean 拒绝了这份证明。下面的输出是它给出的原因,逐条对应需要修改的声明。', 'Lean rejected this proof. The output below gives the reasons, clause by clause.') @@ -198,7 +199,7 @@ function walkthroughStep(walkthrough: ProofWalkthrough | undefined, task: Task) if (!step) return undefined; const index = walkthrough.steps.indexOf(step); const stageIndex = Math.max(0, walkthrough.stages.findIndex(stage => stage.stepIds.includes(step.id))); - return { step, index, stage: walkthrough.stages[stageIndex]!, stageIndex }; + return { step, index, stage: walkthrough.stages[stageIndex]!, stageIndex, proofSha256: walkthrough.proofSha256 }; } /** Nodes carry what a reader needs: what was established, from what, and where the reasoning is written out. */ function taskContext(task: Task, run: Run, walkthrough: ProofWalkthrough | undefined, locale: Locale): string { @@ -212,7 +213,7 @@ function taskContext(task: Task, run: Run, walkthrough: ProofWalkthrough | undef
${choose(locale, '这一步推出', 'This step establishes')}

${escape(prose(found.step.claim, locale))}

${choose(locale, '已知', 'Given')}${escape(prose(found.step.given, locale))}

${found.step.because.zh || found.step.because.en ? `
${choose(locale, '为什么这一步成立', 'Why this step holds')}

${escape(prose(found.step.because, locale))}

` : ''} - + ${dependencies}${brief}`; const research = /^initial_research_/u.test(task.id); const capacity = /^capacity_/u.test(task.id); diff --git a/scripts/build-web.ts b/scripts/build-web.ts index 89071f22..de40954a 100644 --- a/scripts/build-web.ts +++ b/scripts/build-web.ts @@ -25,22 +25,23 @@ fs.mkdirSync(reports, { recursive: true }); // in Chinese pages too; the rest of the English interface is loaded only when the page itself needs it. const contentKeys = scanBundle(bundleSources().filter(file => /\btranslator\s*\(/u.test(fs.readFileSync(file, 'utf8')))).keys; const contentEnglish = Object.fromEntries([...contentKeys.keys()].filter(key => en[key]).map(key => [key, en[key]])); -const bundle = (entry: string, directory: string) => - build({ entryPoints: [path.join(root, `apps/web/client/${entry}.ts`)], - ...(entry === 'app' ? { outdir: directory, chunkNames: 'chunks/[name]-[hash]', splitting: true, format: 'esm' as const } - : { outfile: path.join(directory, `${entry}.js`), format: 'iife' as const }), +const bundle = (entries: string[], directory: string, englishOnDemand = false) => + build({ entryPoints: entries.map(entry => path.join(root, `apps/web/client/${entry}.ts`)), + outdir: directory, chunkNames: 'chunks/[name]-[hash]', splitting: englishOnDemand, + format: englishOnDemand ? 'esm' : 'iife', bundle: true, minify: true, target: 'es2023', platform: 'browser', legalComments: 'eof', logLevel: 'silent', - plugins: entry === 'app' ? [{ name: 'workbench-english-on-demand', setup(builder) { + plugins: englishOnDemand ? [{ name: 'workbench-english-on-demand', setup(builder) { builder.onResolve({ filter: /^\.\/i18n\/en$/ }, () => ({ path: 'workbench-english', namespace: 'workbench-english' })); builder.onLoad({ filter: /.*/, namespace: 'workbench-english' }, () => ({ loader: 'ts', resolveDir: root, contents: `import { locale } from ${JSON.stringify(path.join(root, 'apps/web/i18nLocale.ts'))}; export const en = locale === 'en' ? (await import(${JSON.stringify(path.join(root, 'apps/web/i18n/en.ts'))})).en : ${JSON.stringify(contentEnglish)};` })); } }] : [], jsx: 'automatic', jsxImportSource: 'preact' }); -for (const entry of ['theme', 'app', 'login', 'share', 'guide', 'legal', 'explain', 'formalize', 'research', 'practice']) await bundle(entry, output); -// One classic script supports lazy formulas in online pages and self-contained offline reports. -await bundle('math', output); -await bundle('formalization', reports); +// Build online entries together so they share one English chunk. +await bundle(['app', 'login', 'share', 'guide', 'legal', 'formalize', 'research', 'practice'], output, true); +// Theme runs before CSS. Theme, explain and math are also inlined in standalone reports. +await bundle(['theme', 'explain', 'math'], output); +await bundle(['formalization'], reports); for (const page of ['formalization.html', 'explain.html']) fs.copyFileSync(path.join(root, 'apps/web/client', page), path.join(reports, page)); for (const [source, destination] of [['index.html', 'index.html'], ['login.html', 'login.html'], ['share.html', 'share.html'], ['guide.html', 'guide.html'], ['terms.html', 'terms.html'], ['privacy.html', 'privacy.html'], ['explain.html', 'explain.html'], ['app.css', 'app.css'], ['formalize.html', 'formalize.html'], ['formalize.css', 'formalize.css'], ['research-conversation.css', 'research-conversation.css']]) diff --git a/scripts/test-web-ui.ts b/scripts/test-web-ui.ts index 4f56a81c..d4db66c5 100644 --- a/scripts/test-web-ui.ts +++ b/scripts/test-web-ui.ts @@ -302,7 +302,7 @@ try { await stage('排队'); assert.equal(controls.has(queued.id), false); await page.locator('.detail-actions [data-action="cancel"]').click(); - assert.match(await page.locator('#cancel-run-description').innerText(), /还在排队.*不会调用模型/); + assert.match(await page.locator('#cancel-run-description').innerText(), /还在排队,取消后不会开始/); await page.locator('#confirm-cancel-run').click(); await page.locator('#detail-panel .result-verdict').filter({ hasText: '运行已取消' }).waitFor(); assert.equal(await page.locator('.artifact-stages li[data-stage="skipped"]').count(), 3);