必填完整即可保存 span {
+ font-size: 12px;
+ font-weight: 500;
+ color: var(--tx-2);
+}
+.f2 .required {
+ color: var(--err);
}
.role > span {
font-size: 12px;
color: var(--tx-2);
}
+
+.mrow .nm .endpoint-tag {
+ display: inline-flex;
+ align-items: center;
+ height: 16px;
+ margin-left: 6px;
+ padding: 0 6px;
+ border: 1px solid var(--line-2);
+ border-radius: 4px;
+ font: 400 10px var(--font);
+ color: var(--tx-2);
+}
diff --git a/calliope-web/src/lib/components/ui/Button.svelte b/calliope-web/src/lib/components/ui/Button.svelte
index 360626a4..c0484d40 100644
--- a/calliope-web/src/lib/components/ui/Button.svelte
+++ b/calliope-web/src/lib/components/ui/Button.svelte
@@ -9,6 +9,9 @@
size?: 'sm' | 'md' | 'lg';
/** Stretch to the container width (e.g. a panel's main action). */
block?: boolean;
+ iconOnly?: boolean;
+ 'aria-label'?: string;
+ 'aria-pressed'?: boolean;
disabled?: boolean;
loading?: boolean;
type?: 'button' | 'submit' | 'reset';
@@ -21,6 +24,9 @@
variant = 'secondary',
size = 'md',
block = false,
+ iconOnly = false,
+ 'aria-label': ariaLabel,
+ 'aria-pressed': ariaPressed,
disabled = false,
loading = false,
type = 'button',
@@ -35,6 +41,9 @@
class="a-btn btn {variant}"
class:sm={size === 'sm'}
class:lg={size === 'lg'}
+ class:icon-only={iconOnly}
+ aria-label={ariaLabel ?? (iconOnly ? title : undefined)}
+ aria-pressed={ariaPressed}
class:block
class:loading
disabled={disabled || loading}
@@ -56,6 +65,13 @@
.btn {
position: relative;
}
+ .btn.icon-only {
+ width: var(--button-height, 34px);
+ padding: 0;
+ }
+ .btn.icon-only.sm {
+ width: var(--button-sm-height, 28px);
+ }
.btn:disabled {
pointer-events: none;
}
diff --git a/calliope-web/src/lib/components/ui/icons.ts b/calliope-web/src/lib/components/ui/icons.ts
index 94b46ac3..67436fc2 100644
--- a/calliope-web/src/lib/components/ui/icons.ts
+++ b/calliope-web/src/lib/components/ui/icons.ts
@@ -4,6 +4,7 @@
* Each entry is SVG inner content rendered by Icon.svelte via {@html}.
*/
export const icons = {
+ layers: '
',
// Result controls from the approved HEL-716/726 sample.
"result-expand": '
',
"result-down": '
',
diff --git a/calliope-web/src/routes/library/+page.svelte b/calliope-web/src/routes/library/+page.svelte
index 2f262e7c..e22a1db4 100644
--- a/calliope-web/src/routes/library/+page.svelte
+++ b/calliope-web/src/routes/library/+page.svelte
@@ -10,6 +10,7 @@
import AttachToProject from "$lib/components/AttachToProject.svelte";
import ImageLightbox from "$lib/components/ImageLightbox.svelte";
import SafeMedia from "$lib/components/SafeMedia.svelte";
+ import Icon from "$lib/components/ui/Icon.svelte";
import Button from "$lib/components/ui/Button.svelte";
import Modal from "$lib/components/ui/Modal.svelte";
import { toast } from "$lib/toast";
@@ -128,6 +129,9 @@
)
)
return;
+ // Native controls own Space/Enter; the preview shortcut only owns media tiles.
+ const target = e.target as HTMLElement;
+ if (target?.closest("button,a") && !target.closest(".mat")) return;
if (e.key === "/") {
e.preventDefault();
searchEl?.focus();
@@ -182,8 +186,16 @@
>{#each [["all", "全部"], ["image", "图片"], ["video", "视频"]] as [value, label] (value)}
{#each [["all", "全部时间"], ["today", "今天"], ["week", "近 7 天"], ["older", "更早"]] as [value, label] (value)}
{/each}
-
- 还没被任何项目使用的图片和视频。存入项目后,文件改在该项目里管理,不再出现在这里。
-
+
+
+
+ 这里是什么
+ 还没被任何项目使用的图片和视频。存入项目后,文件改在该项目里管理,不再出现在这里。
+
+
{#if kind !== "all" || period !== "all" || search}
diff --git a/calliope-web/src/routes/library/library-v2.css b/calliope-web/src/routes/library/library-v2.css
index 2241760f..fa5b94ac 100644
--- a/calliope-web/src/routes/library/library-v2.css
+++ b/calliope-web/src/routes/library/library-v2.css
@@ -9,6 +9,13 @@
grid-template-columns: var(--lib-filter) minmax(0, 1fr) var(--lib-detail);
min-height: 0;
--scene: var(--gold);
+ --button-secondary-border: var(--line-2);
+}
+.lib2 .mg-filter svg {
+ color: var(--tx-3);
+}
+.lib2 .mg-filter.on svg {
+ color: var(--gold);
}
.lib-main {
display: flex;
@@ -23,14 +30,9 @@
padding: 10px 14px;
border-bottom: 1px solid var(--line);
flex: none;
- gap: 4px;
+ gap: 8px;
}
-.lib-tools .input {
- height: 30px;
- width: 240px;
-}
-.lib-tools select,
-.sel {
+.lib-tools select {
height: 30px;
border-radius: var(--r-sm);
background: var(--well);
@@ -478,20 +480,105 @@
}
.scope-note {
- margin-top: auto;
- padding: 14px 10px 4px;
- font-size: 11px;
- color: var(--tx-2);
- line-height: 1.7;
+ display: flex;
+ gap: 8px;
+ margin: 14px 8px 8px;
+ padding: 10px;
+ border-radius: 10px;
+ border: 1px dashed var(--line-2);
+ font-size: 11.5px;
+ line-height: 1.55;
+ color: var(--tx-3);
}
-.lib-tools input {
- min-width: 90px;
- width: 240px;
+.scope-note > svg {
+ margin-top: 2px;
+ color: var(--gold);
+}
+.scope-note b {
+ display: block;
+ color: var(--tx-2);
+ font-weight: 600;
+ margin-bottom: 2px;
+}
+.lib-search {
+ display: flex;
+ align-items: center;
+ gap: 8px;
height: 30px;
- font-size: 12px;
+ width: 240px;
+ min-width: 90px;
+ padding: 0 10px;
+ border-radius: var(--r-sm);
+ border: 1px solid var(--line-2);
+ background: var(--well);
+ color: var(--tx-3);
+}
+.lib-search input {
+ flex: 1;
+ min-width: 0;
+ width: 100%;
+ border: 0;
+ background: none;
+ outline: 0;
+ color: var(--tx-1);
+ font-size: 13px;
+}
+.lib-search:focus-within {
+ border-color: color-mix(in srgb, var(--scene) 70%, transparent);
+ box-shadow: 0 0 0 3px color-mix(in srgb, var(--scene) 16%, transparent);
}
.lib-tools select {
- max-width: 100px;
+ flex: none;
+}
+.lib-segment {
+ display: flex;
+ flex: none;
+ gap: 2px;
+ padding: 3px;
+ border-radius: var(--lib-segment-radius, 9px);
+ border: 1px solid var(--line);
+ background: var(--well);
+}
+.lib-segment button {
+ border: 0;
+ background: none;
+ font-family: inherit;
+ cursor: pointer;
+ display: flex;
+ align-items: center;
+ justify-content: center;
+ height: 28px;
+ padding: 0 10px;
+ border-radius: var(--lib-option-radius, 7px);
+ font-size: 12.5px;
+ color: var(--tx-2);
+ white-space: nowrap;
+ transition:
+ background var(--t-base) var(--ease-out),
+ color var(--t-base) var(--ease-out);
+}
+.lib-segment button:hover {
+ color: var(--tx-1);
+}
+.lib-segment button.on {
+ background: var(--lib-option-bg, var(--bg-3));
+ color: var(--tx-1);
+ box-shadow: var(--lib-option-shadow, var(--sh-1));
+}
+.lib-segment button.on svg {
+ color: var(--scene);
+}
+[data-theme="day"] .lib2 {
+ --lib-option-bg: var(--hi);
+ --lib-option-shadow:
+ 0 1px 2px rgb(var(--ink) / 0.14), 0 0 0 1px rgb(var(--ink) / 0.06);
+}
+[data-theme="day"] .lib-search {
+ border-color: var(--line-3);
+}
+[data-theme="grade"] .lib2 {
+ --lib-segment-radius: 4px;
+ --lib-option-radius: 4px;
}
.lt .mat img,
.lt .mat video {
diff --git a/docs/changelogs/2026-10-25-hel842-controls.md b/docs/changelogs/2026-10-25-hel842-controls.md
new file mode 100644
index 00000000..7bcb70bd
--- /dev/null
+++ b/docs/changelogs/2026-10-25-hel842-controls.md
@@ -0,0 +1,14 @@
+HEL-842:恢复批准第二版的两页控件
+
+基线 `leefer/hel-731-studio-project@7fbcfad29eb1da28059473bc155829b1ada0f979`。批准包 SHA256 `dfe02579065200e8f0edaa3114709fc44286f232fdaa76c34acd3f3814523508`。原件只读,未替换真实日期/路径/计数,不创建面向线上截图的演示文件。
+
+- `routes/library/+page.svelte`、`library-v2.css`:恢复完整/铺满两段和标准/紧凑图标两段;独立按钮支持 Enter/Space,`aria-pressed` 表达选中状态。选择模式复用 Button 的 secondary/scene,补图标及按下状态。恢复查找图标/快捷键提示、8px 工具条间距、类型筛选图标与选中色、底部虚线说明框。保留最新/最早/最大短标签。页面空格预览快捷键避开其他原生按钮,素材格仍能使用预览快捷键。
+- `manage/LlmModels.svelte`、`models-v2.css`:列表测试改用有边框次按钮,编辑/关闭复用图标按钮;详情输入恢复 well 底、line-2 边框、r-sm 圆角及等宽字段;分工下拉接到正确的页面组件样式,补原样状态点和分组边线;底栏测试/保存恢复正常高度。测试框按未测试/成功/失败呈现原有真实状态,已保存测试记录刷新后仍有对应反馈,原始响应仍折叠。
+- `ui/Button.svelte` 只新增可选 iconOnly、aria-label、aria-pressed;旧调用默认行为不变。`ui/icons.ts` 复用注册表加批准的 layers 几何。样式只在这两页原有统一来源修改,颜色/圆角/阴影沿用 token,不改全局按钮变体。
+- `main.py` 仅修 I001 和同文件一处长行;本次触及 Python 文件 Ruff 全过,不处理其他文件存量问题。未新增产品依赖、接口、迁移或配置键。
+
+自测:前端 check 零错零警、lint/test/build 通过;素材库、模型档案/连接/分工、提示词工具后端测试 59 项通过。真实隔离前端/FastAPI/SQLite/HTTP 假供应商完成两页四主题×三窗口 24 张矩阵,10 个本卡控件状态及 48 项共享交互记录,浏览器脚本错误 0、矩阵无横向溢出;含 Enter/Space、筛选排序查找、多选预览、存入后移出、模型保存刷新、测试中/成功/失败、五智能体计数不含提示词角色、翻译/润色 ABA/撤销、双环和三档动效。两次真实隔离服务进程启动验证分工重启持久化及实际路由。
+
+复现见 `scripts/hel842/README.md`。对照原件与实际媒体、模型名/类型/地址、密钥状态、路径、修改时间、语言日期格式、计数不同;不声称全页逐像素一致。原件模型测试延迟是演示数据,产品延迟来自真实假供应商请求。隔离测试截图不冒充线上图。
+
+未调用真实收费供应商/GPU;未合并、未部署、未触碰现网数据库/媒体/配置/密钥。线上最终外观、真实供应商/GPU留给后续独立复审与获准部署验收。
diff --git a/docs/changelogs/2026-10-25-hel844-weighted-prompt.md b/docs/changelogs/2026-10-25-hel844-weighted-prompt.md
new file mode 100644
index 00000000..838af57e
--- /dev/null
+++ b/docs/changelogs/2026-10-25-hel844-weighted-prompt.md
@@ -0,0 +1,70 @@
+# HEL-844: weighted prompt translation and syntax ownership
+
+The shared translate/polish router previously protected whole weighted expressions.
+A valid `(霓虹灯:1.2)` → `(neon lights:1.2)` therefore retried and failed with
+`502 fragment_lost`. Ordinary words inside groups are now editable.
+
+Before calling the existing LLM client, the router replaces each syntax occurrence
+with a unique opaque token scoped to that request. This includes parentheses,
+square brackets, recognized weight suffixes, tags/dialogue spans, CLI parameters,
+and escaped delimiters. Each occurrence has its own identity, even when literal
+weights or tags repeat. The provider receives the mapped prompt and token meanings.
+
+The result must contain exactly the original ordered identities, each once. The
+server rejects added raw syntax, restores tokens itself, then tokenizes again to
+reject newly formed syntax across restored boundaries (for example adding `:2`
+before an encoded closing parenthesis). Nonempty group operands cannot become
+empty. Nested group structure, tag occurrences, and suffix-to-group placement are
+therefore checked by identity and topology, rather than a bag of numeric weights.
+For example, `(猫:1.2), (狗:0.8)` has distinct identities for its two
+suffixes. Exchanging those identities is rejected even though the numeric
+multiset remains `{1.2, 0.8}`. Exchanging identities for two equal `:1.2`
+suffixes in sibling/nested groups is also rejected. Keeping all identities while
+changing `cat` to a semantically wrong word is outside the machine-checkable
+boundary described below.
+
+Text, whitespace and commas between tokens can change; polishing can move words
+within a group without requiring every original text slot to stay occupied.
+
+`protected_fragments` reports the actual literal tags, suffixes, parameters and
+escaped delimiters in source order with duplicates. For `(霓虹灯:1.2)` it is
+`[":1.2"]`; the editable operand is no longer counted as a literal fragment.
+Brackets are verified structurally and do not inflate that list. Existing frontend
+code already uses the returned array length. Tokens never appear in successful
+responses. The existing correction-once / then-502 contract, timeout budget,
+disconnect handling, profile snapshot and model attribution remain in place.
+
+## Machine-checkable boundary
+
+This guarantees syntactic group identity, nesting, literal syntax and multiplicity.
+It cannot prove natural-language equivalence or detect a model silently swapping
+translated meanings between two otherwise valid operand groups. Translation quality
+still needs preview. The parser recognizes the existing bounded angle tags,
+complete `…` spans and `--parameters`, round/square delimiters, escaped
+ASCII delimiters and numeric round-group suffixes. It does not interpret arbitrary
+prompt dialects or repair malformed input; original malformed delimiters are kept.
+Unknown syntax and ordinary names/numbers are not promoted into literal tags.
+Providers unable to preserve identities fail explicitly after one correction.
+
+No endpoint, configuration key, dependency, frontend asset or deployment changed.
+
+## Reproduction and validation
+
+From `calliope-backend`, with the existing dev dependencies:
+
+```sh
+PYTHONPATH=src python3 scripts/verify_prompt_weights.py --output weight-results.json
+ruff check src/calliope/routers/prompt_tools.py tests/test_prompt_tools.py scripts/verify_prompt_weights.py
+```
+
+The script runs the real FastAPI router and LLMClient against an ephemeral local
+HTTP fake supplier, records request/response bodies plus supplier call counts and
+model routing, and exits nonzero if any regression fails. Fixtures isolate SQLite,
+restore settings, disable persistent config writes and close their HTTP servers.
+No paid LLM, GPU or deployment service is contacted. The artifact includes baseline
+failure logs, final raw logs and JSON responses. Frontend check, lint, test and
+production build were run on the unchanged frontend tree; existing acceptance
+screenshots remain applicable to these identical frontend bytes. No browser matrix
+was repeated for this backend-only change. Existing cancellation (including no
+first chunk and blocking fallback), timeout, model routing/defaults, profile freeze,
+long input and error classification tests provide the shared regression coverage.
diff --git a/scripts/hel842/README.md b/scripts/hel842/README.md
new file mode 100644
index 00000000..6772d111
--- /dev/null
+++ b/scripts/hel842/README.md
@@ -0,0 +1,12 @@
+HEL-842 控件返工复现(仓库根目录执行)
+
+1. `cd calliope-web && npm ci && npm run check && npm run lint && npm test && npm run build`
+2. 后端使用已有项目 `[dev]` 依赖,Python ≥3.11;环境放在 `calliope-backend/.venv`。
+3. `python3 scripts/hel842/capture.py --output ./evidence/hel842/delivery`。编排 Python 使用运行环境已有 Playwright;Chromium 系统库可通过 `HEL840_BROWSER_LIBS` 指定。脚本只操作显式指定的隔离目录,固定本机 18740 端口,结束时检查 daemon PID 后清理自有服务。
+4. `python3 scripts/hel840/restart_config.py --output ./evidence/hel842/restart` 验证实际进程重启后分工持久化与假供应商路由。
+5. `python3 scripts/hel842/compare.py --approved ../reference/approved --evidence ./evidence/hel842/delivery --output ./evidence/hel842/comparison`。`--approved` 指向批准 ZIP 的原样解压目录,原件只读。
+6. `calliope-backend/.venv/bin/python -m pytest calliope-backend/tests/test_asset_library.py calliope-backend/tests/test_llm_profiles.py calliope-backend/tests/test_llm_connection_test.py calliope-backend/tests/test_agent_llm_roles.py calliope-backend/tests/test_prompt_tools.py -q`
+
+矩阵只拍本卡两页(四主题、三窗口,24 张);额外验证四种适配/密度组合、键盘选择、查找排序筛选、模型编辑保存刷新、测试中/成功/失败。复用 HEL-840 的共享回归,覆盖多选、预览、真实读失败、存入后移出、翻译/润色 ABA/撤销、五角色计数、双环和动效档位。前端响应不拦截,真实 FastAPI/SQLite/HTTP 假供应商,不访问现网数据或收费模型/GPU。
+
+对照图左为批准原件(或注明从不改动 HTML 点击重拍),右为真实隔离产品。媒体、模型名/类型/地址、密钥状态、时间、路径、计数均为各自数据,不能据此声明逐像素一致。日期格式来自浏览器语言,源文件修改时间未改成样稿日期。工具条保留规范正文的最新/最早/最大短标签。
diff --git a/scripts/hel842/capture.py b/scripts/hel842/capture.py
new file mode 100644
index 00000000..b2c96da0
--- /dev/null
+++ b/scripts/hel842/capture.py
@@ -0,0 +1,200 @@
+"""Reproducible screenshots of built product against isolated real backend/fake HTTP LLM."""
+
+from __future__ import annotations
+
+import argparse
+import json
+import os
+import subprocess
+import sys
+import time
+import urllib.request
+from pathlib import Path
+
+from playwright.sync_api import sync_playwright
+
+ROOT = Path(__file__).resolve().parents[2]
+sys.path.insert(0, str(ROOT / "scripts/hel840"))
+sys.path.insert(0, str(ROOT / "scripts/hel842"))
+p = argparse.ArgumentParser()
+p.add_argument("--output", type=Path, required=True)
+p.add_argument("--quick", action="store_true")
+p.add_argument("--states-only", action="store_true")
+p.add_argument("--motion-only", action="store_true")
+args = p.parse_args()
+out = args.output.resolve()
+out.mkdir(parents=True, exist_ok=True)
+data = out / "fixture"
+data.mkdir(exist_ok=True)
+log = (out / "server.log").open("w")
+proc = subprocess.Popen(
+ [
+ str(ROOT / "calliope-backend/.venv/bin/python"),
+ str(ROOT / "scripts/hel840/serve_fixture.py"),
+ "--data",
+ str(data),
+ "--port",
+ "18740",
+ ],
+ stdout=log,
+ stderr=subprocess.STDOUT,
+ cwd=ROOT,
+)
+(out / "owned-process.json").write_text(
+ json.dumps(
+ {
+ "pid": proc.pid,
+ "purpose": "isolated fixture backend",
+ "cleanup": "foreground capture.py finally terminates exact child",
+ }
+ )
+)
+try:
+ for _ in range(100):
+ if proc.poll() is not None:
+ raise RuntimeError((out / "server.log").read_text()[-4000:])
+ try:
+ with urllib.request.urlopen(
+ "http://127.0.0.1:18740/api/health", timeout=1
+ ) as response:
+ if response.status == 200:
+ break
+ except OSError:
+ time.sleep(0.1)
+ else:
+ raise RuntimeError("backend not ready")
+ with sync_playwright() as pw:
+ browser = pw.chromium.launch(
+ headless=True,
+ args=["--no-sandbox"],
+ env={
+ **os.environ,
+ "LD_LIBRARY_PATH": os.environ.get(
+ "HEL840_BROWSER_LIBS",
+ str(
+ ROOT
+ / "evidence/hel840/browser-runtime/libs/usr/lib/x86_64-linux-gnu"
+ ),
+ ),
+ },
+ )
+ context = browser.new_context(
+ viewport={"width": 1440, "height": 900},
+ record_video_dir=str(out / "recordings"),
+ record_video_size={"width": 1440, "height": 900},
+ )
+ page = context.new_page()
+ errors = []
+ page.on("pageerror", lambda e: errors.append(str(e)))
+ themes = (
+ []
+ if args.states_only or args.motion_only
+ else ["night"]
+ if args.quick
+ else ["night", "day", "grade", "bluehour"]
+ )
+ sizes = [(1440, 900)] if args.quick else [(1440, 900), (1366, 768), (1280, 720)]
+ metrics = []
+ for theme in themes:
+ for width, height in sizes:
+ page.set_viewport_size({"width": width, "height": height})
+ page.goto("http://127.0.0.1:18740/settings")
+ page.evaluate(
+ '(theme)=>localStorage.setItem("aigc-theme",theme)', theme
+ )
+ for label, route in [
+ ("02-素材库", "/library"),
+ ("03-模型连接", "/connections?tab=llm"),
+ ]:
+ page.goto("http://127.0.0.1:18740" + route)
+ page.wait_for_timeout(700)
+ if label.startswith("03"):
+ for n in range(2):
+ page.locator(".mrow").nth(n).get_by_role(
+ "button", name="测试", exact=True
+ ).click()
+ page.locator(".mrow").nth(n).locator(".spill.ok").wait_for()
+ page.get_by_role("button", name="编辑", exact=True).nth(
+ 1
+ ).click()
+ page.wait_for_timeout(150)
+ assert page.locator(".mlist").bounding_box()["height"] >= 212
+ assert page.locator(".mrow").first.bounding_box()["y"] >= 44
+ if label.startswith("04"):
+ page.locator("#desk-prompt").wait_for()
+ page.locator("#desk-prompt").fill(
+ "一只猫,柔和侧光,,(neon:1.2)"
+ )
+ page.locator(".pt-buttons").first.get_by_role(
+ "button"
+ ).first.click()
+ page.locator(".pt-res").wait_for()
+ folder = out / "matrix" / theme
+ folder.mkdir(parents=True, exist_ok=True)
+ page.screenshot(path=str(folder / f"{label}-{width}x{height}.png"))
+ metrics.append(
+ {
+ "theme": theme,
+ "width": width,
+ "height": height,
+ "page": label,
+ "dom": page.evaluate(
+ """()=>{const rect=s=>{const n=document.querySelector(s);if(!n)return null;const r=n.getBoundingClientRect(),c=getComputedStyle(n);return {x:r.x,y:r.y,width:r.width,height:r.height,bottom:r.bottom,font:c.font,fontFamily:c.fontFamily,color:c.color,background:c.backgroundColor}};return {overflow:document.documentElement.scrollWidth>innerWidth,theme:document.documentElement.dataset.theme,main:rect('main'),resume:rect('.resume'),library:rect('.lib2'),filter:rect('.mg-side'),detail:rect('.lib-detail'),models:rect('.mdl'),modelList:rect('.mlist'),modelRow:rect('.mrow'),modelDetail:rect('.mdl-detail'),band:rect('.ptband'),dock:rect('.studio-form'),media:rect('.stage-media .print'),generate:rect('.gen')}}"""
+ ),
+ }
+ )
+ (out / "geometry.json").write_text(
+ json.dumps(metrics, ensure_ascii=False, indent=2)
+ )
+ from controls import verify_controls
+
+ verify_controls(page, data, out)
+ if args.motion_only:
+ from motion import record_motion
+
+ record_motion(page, data, out)
+ elif not args.quick:
+ from exercise import exercise
+
+ exercise(page, data, out)
+ (out / "browser-errors.json").write_text(
+ json.dumps(errors, ensure_ascii=False, indent=2)
+ )
+ print(
+ json.dumps(
+ {
+ "screenshots": len(metrics),
+ "browser_errors": errors,
+ "output": str(out),
+ },
+ ensure_ascii=False,
+ ),
+ flush=True,
+ )
+ context.close()
+ browser.close()
+finally:
+ # Compare against the workspace daemon before terminating only our own child.
+ raw = subprocess.check_output(
+ ["multica", "daemon", "status", "--output", "json"], text=True
+ )
+ (out / "daemon-status.json").write_text(raw)
+ daemon = json.loads(raw)
+
+ def pids(obj):
+ if isinstance(obj, dict):
+ return [v for k, v in obj.items() if k in ("pid", "process_id")] + [
+ n for v in obj.values() for n in pids(v)
+ ]
+ if isinstance(obj, list):
+ return [n for v in obj for n in pids(v)]
+ return []
+
+ if proc.pid not in pids(daemon):
+ proc.terminate()
+ try:
+ proc.wait(timeout=10)
+ except subprocess.TimeoutExpired:
+ proc.kill()
+ proc.wait(timeout=5)
+ log.close()
diff --git a/scripts/hel842/compare.py b/scripts/hel842/compare.py
new file mode 100644
index 00000000..41c7aefa
--- /dev/null
+++ b/scripts/hel842/compare.py
@@ -0,0 +1,122 @@
+"""Package untouched originals and independently captured product images for visual review."""
+
+import argparse
+import hashlib
+import json
+import os
+import shutil
+from pathlib import Path
+
+from PIL import Image
+from playwright.sync_api import sync_playwright
+
+p = argparse.ArgumentParser()
+p.add_argument("--approved", type=Path, required=True)
+p.add_argument("--evidence", type=Path, required=True)
+p.add_argument("--output", type=Path, required=True)
+a = p.parse_args()
+a.output.mkdir(parents=True, exist_ok=True)
+manifest = []
+
+
+def pair(original, actual, name):
+ target = a.output / name
+ target.parent.mkdir(parents=True, exist_ok=True)
+ left, right = Image.open(original).convert("RGB"), Image.open(actual).convert("RGB")
+ canvas = Image.new(
+ "RGB", (left.width + right.width, max(left.height, right.height))
+ )
+ canvas.paste(left, (0, 0))
+ canvas.paste(right, (left.width, 0))
+ canvas.save(target)
+ manifest.append(
+ {
+ "comparison": name,
+ "original": str(original),
+ "actual": str(actual),
+ "original_sha256": hashlib.sha256(original.read_bytes()).hexdigest(),
+ "actual_sha256": hashlib.sha256(actual.read_bytes()).hexdigest(),
+ }
+ )
+
+
+for actual in sorted((a.evidence / "matrix").rglob("*.png")):
+ rel = actual.relative_to(a.evidence / "matrix")
+ original = a.approved / "四主题三窗口" / rel
+ dest = a.output / "originals" / rel
+ dest.parent.mkdir(parents=True, exist_ok=True)
+ shutil.copy2(original, dest)
+ pair(original, actual, "matrix/" + str(rel))
+
+# Re-render the unchanged approved HTML by clicking its real controls for missing fit/density states.
+with sync_playwright() as pw:
+ browser = pw.chromium.launch(
+ headless=True,
+ args=["--no-sandbox"],
+ env={
+ **os.environ,
+ "LD_LIBRARY_PATH": os.environ.get("HEL840_BROWSER_LIBS", ""),
+ },
+ )
+ page = browser.new_page(viewport={"width": 1440, "height": 900})
+ page.goto(
+ (a.approved / "HEL-837-交互样本-v2.html").resolve().as_uri()
+ + "?theme=night#library"
+ )
+ page.locator("#p-library.on").wait_for()
+ for fill in [False, True]:
+ for dense in [False, True]:
+ page.locator('[data-fit="' + ("fill" if fill else "contain") + '"]').click()
+ page.locator('[data-dens="' + ("dense" if dense else "std") + '"]').click()
+ page.wait_for_timeout(250)
+ name = f"library-fit-{fill}-dense-{dense}.png"
+ original = a.output / ("original-render-" + name)
+ page.screenshot(path=str(original))
+ pair(original, a.evidence / "controls" / name, "controls/" + name)
+ page.goto(
+ (a.approved / "HEL-837-交互样本-v2.html").resolve().as_uri()
+ + "?theme=night#models"
+ )
+ page.reload() # The offline prototype does not route on hashchange.
+ page.locator("#p-models.on").wait_for()
+ page.locator(".md-f [data-mtest]").click()
+ original = a.output / "original-render-model-testing.png"
+ page.screenshot(path=str(original))
+ pair(
+ original,
+ a.evidence / "controls/model-testing.png",
+ "controls/model-testing.png",
+ )
+ page.wait_for_timeout(800)
+ for name in ["model-test-success", "model-save-reload"]:
+ if name == "model-save-reload":
+ page.locator('[data-act="mSave"]').click()
+ original = a.output / ("original-render-" + name + ".png")
+ page.screenshot(path=str(original))
+ pair(
+ original,
+ a.evidence / ("controls/" + name + ".png"),
+ "controls/" + name + ".png",
+ )
+ browser.close()
+for old, new in [
+ ("L01-素材库-多选-1440x900.png", "L01-多选选择条.png"),
+ ("L02-素材库-删除确认-1440x900.png", "L02-删除确认.png"),
+ ("L04-素材库-读取失败-1440x900.png", "L04-真实读取失败.png"),
+ ("L05-素材库-全屏预览-1440x900.png", "L05-全屏预览.png"),
+ ("L07-素材库-存入项目-1440x900.png", "L07-存入项目.png"),
+ ("L08-素材库-存入后移出-1440x900.png", "L08-存入后刷新移出.png"),
+ ("M03-某模型失败-1440x900.png", "M03-模型测试失败.png"),
+ ("M04-添加模型-可直接保存-1440x900.png", "M04-未测试可以保存.png"),
+]:
+ pair(a.approved / "状态图" / old, a.evidence / "states" / new, "states/" + new)
+pair(
+ a.approved / "状态图/M03-某模型失败-1440x900.png",
+ a.evidence / "controls/model-test-failed-raw.png",
+ "controls/model-test-failed-raw.png",
+)
+(a.output / "manifest.json").write_text(
+ json.dumps(manifest, ensure_ascii=False, indent=2)
+)
+
+print(f"{len(manifest)} original/product comparisons; left approved, right actual isolated product")
diff --git a/scripts/hel842/controls.py b/scripts/hel842/controls.py
new file mode 100644
index 00000000..6d4182ca
--- /dev/null
+++ b/scripts/hel842/controls.py
@@ -0,0 +1,86 @@
+"""HEL-842 controls: actual UI state, keyboard access and real saved configuration."""
+
+import json
+
+from playwright.sync_api import expect
+
+
+def verify_controls(page, data, out):
+ base = "http://127.0.0.1:18740"
+ folder = out / "controls"
+ folder.mkdir(exist_ok=True)
+ checks = []
+
+ def shot(name):
+ page.screenshot(path=str(folder / f"{name}.png"))
+ checks.append(name)
+
+ page.goto(base + "/library")
+ page.locator(".lt").first.wait_for()
+ for fill in [False, True]:
+ for dense in [False, True]:
+ fit = page.get_by_role(
+ "button", name="铺满" if fill else "完整", exact=True
+ )
+ fit.focus()
+ page.keyboard.press("Enter")
+ expect(fit).to_have_attribute("aria-pressed", "true")
+ density = page.get_by_role(
+ "button", name="紧凑网格,仅缩略图" if dense else "标准网格", exact=True
+ )
+ density.focus()
+ page.keyboard.press("Space")
+ expect(density).to_have_attribute("aria-pressed", "true")
+ grid = page.locator(".lgrid").first
+ assert ("fill" in (grid.get_attribute("class") or "").split()) == fill
+ assert ("dense" in (grid.get_attribute("class") or "").split()) == dense
+ assert page.locator(".mat img").first.evaluate(
+ "(n)=>getComputedStyle(n).objectFit"
+ ) == ("cover" if fill else "contain")
+ shot(f"library-fit-{fill}-dense-{dense}")
+ select = page.get_by_role("button", name="选择", exact=True)
+ select.focus()
+ page.keyboard.press("Enter")
+ expect(select).to_have_attribute("aria-pressed", "true")
+ expect(page.locator(".lib-main")).to_have_class("lib-main selecting")
+ shot("library-selection-keyboard")
+ page.get_by_role("button", name="图片", exact=False).first.click()
+ expect(page.locator(".lt video")).to_have_count(0)
+ page.get_by_role("combobox", name="排序").select_option("size")
+ search = page.get_by_role("textbox", name="文件名查找")
+ search.fill("样本素材-01")
+ expect(page.locator(".lt")).to_have_count(1)
+ shot("library-filter-sort-search")
+ page.goto(base + "/connections?tab=llm")
+ page.locator(".mrow").first.wait_for()
+ original_name = page.request.get(base + "/api/settings").json()["llm_profiles"][0][
+ "name"
+ ]
+ expect(page.locator(".mrow").nth(1).locator(".use")).to_contain_text("智能体 ×2")
+ edit = page.locator(".mrow").first.get_by_role("button", name="编辑", exact=True)
+ edit.focus()
+ page.keyboard.press("Enter")
+ page.locator(".md-b input").first.fill("HEL-842 保存验证")
+ page.get_by_role("button", name="保存", exact=True).click()
+ expect(page.locator(".mrow").first).to_contain_text("HEL-842 保存验证")
+ page.reload()
+ expect(page.locator(".mrow").first).to_contain_text("HEL-842 保存验证")
+ page.locator(".mrow").first.get_by_role("button", name="编辑", exact=True).click()
+ shot("model-save-reload")
+ (data / "control.json").write_text(json.dumps({"delay": 0.8}))
+ page.get_by_role("button", name="测试连接", exact=True).click()
+ expect(page.locator(".md-f .loading")).to_be_visible()
+ shot("model-testing")
+ expect(page.locator(".testbox.ok")).to_be_visible()
+ shot("model-test-success")
+ (data / "control.json").write_text(json.dumps({"status": 401}))
+ page.get_by_role("button", name="测试连接", exact=True).click()
+ expect(page.locator(".testbox.err")).to_be_visible()
+ page.locator(".testbox.err summary").click()
+ shot("model-test-failed-raw")
+ (data / "control.json").write_text("{}")
+ # Leave original fixture values for the shared ABA/undo/attach regression suite.
+ page.locator(".md-b input").first.fill(original_name)
+ page.get_by_role("button", name="保存", exact=True).click()
+ expect(page.locator(".mrow").first).to_contain_text(original_name)
+ (out / "controls.json").write_text(json.dumps(checks, ensure_ascii=False, indent=2))