Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/verify.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion apps/web/client/formalize.html
Original file line number Diff line number Diff line change
Expand Up @@ -53,5 +53,5 @@
</div>
</section>
</main>
<noscript><p>需要启用 JavaScript 才能使用在线形式化。</p></noscript><script src="formalize.js" defer></script>
<noscript><p>需要启用 JavaScript 才能使用在线形式化。</p></noscript><script src="formalize.js" type="module"></script>
</body></html>
2 changes: 1 addition & 1 deletion apps/web/client/guide.html
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,6 @@ <h2 id="data-heading">数据与费用</h2>
</main>
</div>
<noscript><div class="no-script">需要启用 JavaScript 才能切换语言。</div></noscript>
<script src="guide.js" defer></script>
<script src="guide.js" type="module"></script>
</body>
</html>
2 changes: 1 addition & 1 deletion apps/web/client/invite.html
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,6 @@
<body class="research-page" data-research-page="invite">
<a class="skip-link" href="#main">跳到主要内容</a>
<div id="research-root"><main id="main" class="research-loading" role="status">正在读取研究邀请…</main></div>
<noscript><p>请启用 JavaScript 查看研究邀请。</p></noscript><script src="research.js" defer></script>
<noscript><p>请启用 JavaScript 查看研究邀请。</p></noscript><script src="research.js" type="module"></script>
</body>
</html>
2 changes: 1 addition & 1 deletion apps/web/client/library.html
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,6 @@
<body class="research-page" data-research-page="library">
<a class="skip-link" href="#main">跳到主要内容</a>
<div id="research-root"><main id="main" class="research-loading" role="status">正在读取共享库…</main></div>
<noscript><p>请启用 JavaScript 查看研究空间。</p></noscript><script src="research.js" defer></script>
<noscript><p>请启用 JavaScript 查看研究空间。</p></noscript><script src="research.js" type="module"></script>
</body>
</html>
2 changes: 1 addition & 1 deletion apps/web/client/login.html
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,6 @@ <h1 id="login-heading">登录研究工作台</h1>
<p class="login-footer"><a href="guide.html" data-guide>使用说明</a> · <a href="terms.html">使用条款</a> · <a href="privacy.html">隐私说明</a> · <a href="https://theoremos.top/feedback.html" data-feedback target="_blank" rel="noopener noreferrer">反馈问题</a><span class="locale-switch-separator"> · </span><button type="button" id="locale-switch" class="text-button locale-switch" hidden></button></p>
</main>
<noscript><div class="no-script">需要启用 JavaScript 才能登录。</div></noscript>
<script src="login.js" defer></script>
<script src="login.js" type="module"></script>
</body>
</html>
2 changes: 1 addition & 1 deletion apps/web/client/people.html
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,6 @@
<body class="research-page" data-research-page="people">
<a class="skip-link" href="#main">跳到主要内容</a>
<div id="research-root"><main id="main" class="research-loading" role="status">正在读取研究空间…</main></div>
<noscript><p>请启用 JavaScript 查看研究空间。</p></noscript><script src="research.js" defer></script>
<noscript><p>请启用 JavaScript 查看研究空间。</p></noscript><script src="research.js" type="module"></script>
</body>
</html>
2 changes: 1 addition & 1 deletion apps/web/client/practice.html
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,6 @@
<header class="topbar"><a class="brand" href="./" aria-label="TheoremOS"><img src="assets/mark.svg" alt="" width="26" height="26"><span>Theorem<span class="brand-os">OS</span></span></a>
<nav aria-label="TheoremOS"><a href="practice.html?lang=en" class="locale-switch" data-practice-language>English</a><a href="./" class="button" data-practice-home>打开工作台</a></nav></header>
<main id="main" tabindex="-1"><div id="practice-root"></div><noscript><p>请启用 JavaScript 体验研究演练。 Enable JavaScript to explore the exercise.</p></noscript></main>
<script src="practice.js" defer></script>
<script src="practice.js" type="module"></script>
</body>
</html>
2 changes: 1 addition & 1 deletion apps/web/client/privacy.html
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,6 @@ <h2 id="contact-heading">五、联系</h2>
</main>
</div>
<noscript><div class="no-script">需要启用 JavaScript 才能切换语言。</div></noscript>
<script src="legal.js" defer></script>
<script src="legal.js" type="module"></script>
</body>
</html>
2 changes: 1 addition & 1 deletion apps/web/client/problem.html
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,6 @@
<body class="research-page" data-research-page="problem">
<a class="skip-link" href="#main">跳到主要内容</a>
<div id="research-root"><main id="main" class="research-loading" role="status">正在读取题目工作区…</main></div>
<noscript><p>请启用 JavaScript 查看题目工作区。</p></noscript><script src="research.js" defer></script>
<noscript><p>请启用 JavaScript 查看题目工作区。</p></noscript><script src="research.js" type="module"></script>
</body>
</html>
2 changes: 1 addition & 1 deletion apps/web/client/share.html
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,6 @@ <h2 id="share-checks-heading" tabindex="-1">验收记录</h2>
<div id="share-toast" class="toast" role="status" hidden></div>
</main>
<noscript><div class="no-script">需要启用 JavaScript 才能查看分享内容。</div></noscript>
<script src="share.js" defer></script>
<script src="share.js" type="module"></script>
</body>
</html>
2 changes: 1 addition & 1 deletion apps/web/client/terms.html
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,6 @@ <h2 id="changes-heading">五、条款更新与联系</h2>
</main>
</div>
<noscript><div class="no-script">需要启用 JavaScript 才能切换语言。</div></noscript>
<script src="legal.js" defer></script>
<script src="legal.js" type="module"></script>
</body>
</html>
2 changes: 1 addition & 1 deletion apps/web/client/theorems.html
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,6 @@
<body class="research-page" data-research-page="theorems">
<a class="skip-link" href="#main">跳到主要内容</a>
<div id="research-root"><main id="main" class="research-loading" role="status">正在读取定理…</main></div>
<noscript><p>请启用 JavaScript 查看研究空间。</p></noscript><script src="research.js" defer></script>
<noscript><p>请启用 JavaScript 查看研究空间。</p></noscript><script src="research.js" type="module"></script>
</body>
</html>
2 changes: 1 addition & 1 deletion apps/web/client/ui/ChatWorkspace.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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 ? <div class="chat-task-links" aria-label={t('相关引理与任务')}>{tasks.map(task => <button type="button" class="text-button" data-chat-task-link={task.id}
return tasks.length > 0 ? <div class="chat-task-links" aria-label={t('相关引理与任务')}>{tasks.map(task => <button key={task.id} type="button" class="text-button" data-chat-task-link={task.id}
onClick={() => props.onArtifact('roadmap', { taskId: task.id, messageId: message.id })}><Icon name="network" />{task.theorem || task.objective || task.id}</button>)}</div> : null;
}

Expand Down
2 changes: 1 addition & 1 deletion apps/web/client/workspace.html
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,6 @@
<body class="research-page" data-research-page="workspace">
<a class="skip-link" href="#main">跳到主要内容</a>
<div id="research-root"><main id="main" class="research-loading" role="status">正在读取研究空间…</main></div>
<noscript><p>请启用 JavaScript 查看研究空间。</p></noscript><script src="research.js" defer></script>
<noscript><p>请启用 JavaScript 查看研究空间。</p></noscript><script src="research.js" type="module"></script>
</body>
</html>
2 changes: 1 addition & 1 deletion docs/web/landing.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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));
Expand Down
9 changes: 5 additions & 4 deletions docs/web/process.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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];
Expand Down Expand Up @@ -154,13 +154,14 @@ function stepDetail(step: Step, run: Run, record: ArchiveIndexRecord, process: A
return task ? `<button data-process-task="${escape(task.id)}">${escape(processTaskName(task, locale))}</button>` : `<span>${escape(id.trim())}</span>`;
}).join('')}</div>` : summary ? `<div class="process-message">${escape(summary)}</div>` : ''}
${check ? `<p class="process-check-scope">${check.scope === 'original' ? choose(locale, '完整原题检查', 'Original problem check') : choose(locale, '局部任务检查', 'Task proof check')}</p>
${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.')
Expand Down Expand Up @@ -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 {
Expand All @@ -212,7 +213,7 @@ function taskContext(task: Task, run: Run, walkthrough: ProofWalkthrough | undef
<div class="process-map-claim"><span>${choose(locale, '这一步推出', 'This step establishes')}</span><p>${escape(prose(found.step.claim, locale))}</p></div>
<p class="process-map-given"><span>${choose(locale, '已知', 'Given')}</span>${escape(prose(found.step.given, locale))}</p>
${found.step.because.zh || found.step.because.en ? `<details class="process-map-why"><summary>${choose(locale, '为什么这一步成立', 'Why this step holds')}</summary><p>${escape(prose(found.step.because, locale))}</p></details>` : ''}
<button class="process-map-read" data-open-reading-step="proof-derivation-${escape(found.step.id)}" data-open-reading-sha="${escape(walkthrough.proofSha256)}">${icon('book-open')}${choose(locale, `在阅读页读第 ${ordinal(found.index)} 步的逐行推导`, `Read the line-by-line derivation of step ${ordinal(found.index)}`)}${icon('arrow-right')}</button>
<button class="process-map-read" data-open-reading-step="proof-derivation-${escape(found.step.id)}" data-open-reading-sha="${escape(found.proofSha256)}">${icon('book-open')}${choose(locale, `在阅读页读第 ${ordinal(found.index)} 步的逐行推导`, `Read the line-by-line derivation of step ${ordinal(found.index)}`)}${icon('arrow-right')}</button>
${dependencies}${brief}`;
const research = /^initial_research_/u.test(task.id);
const capacity = /^capacity_/u.test(task.id);
Expand Down
19 changes: 10 additions & 9 deletions scripts/build-web.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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']])
Expand Down
2 changes: 1 addition & 1 deletion scripts/test-web-ui.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
Loading