HEL-743: restore search shortcut and full-width responsive desk header

Co-authored-by: multica-agent <github@multica.ai>
This commit is contained in:
leefer
2026-10-21 23:26:41 +08:00
co-authored by multica-agent
parent e62499c517
commit 634965f5f5
7 changed files with 580 additions and 1 deletions
@@ -33,6 +33,41 @@
onKind: (kind: 'image' | 'video') => void;
onDetails: () => void;
} = $props();
let searchInput: HTMLInputElement;
let searchOrigin: HTMLElement | null = null;
function searchKeydown(e: KeyboardEvent) {
if (e.defaultPrevented || e.isComposing || e.keyCode === 229) return;
if (
[
...document.querySelectorAll('.shell-pop, .modal, [role="dialog"]'),
].some((el) => el.getClientRects().length)
)
return;
if (e.key === 'Escape' && e.target === searchInput) {
e.preventDefault();
const origin = searchOrigin?.isConnected
? searchOrigin
: searchInput.closest('aside')?.querySelector('button');
if (origin instanceof HTMLElement) origin.focus();
else searchInput.blur();
return;
}
const el = e.target instanceof HTMLElement ? e.target : null;
if (
e.key !== '/' ||
e.ctrlKey ||
e.metaKey ||
e.altKey ||
el?.isContentEditable ||
el?.closest(
'input, textarea, select, [contenteditable]:not([contenteditable="false"])',
) ||
!searchInput?.getClientRects().length
)
return;
e.preventDefault();
searchInput.focus();
}
const client = useQueryClient();
let search = $state(''),
usage = $state(untrack(() => initialUsage)),
@@ -124,6 +159,8 @@
});
</script>
<svelte:window onkeydown={searchKeydown} />
<aside class="workflow-rail" aria-label="创作工作流列表">
<header>
<strong>创作台</strong><button
@@ -152,10 +189,16 @@
<Icon name="search" size={14} />
<input
type="search"
bind:this={searchInput}
onfocus={(e) => {
searchOrigin =
e.relatedTarget instanceof HTMLElement ? e.relatedTarget : null;
}}
bind:value={search}
aria-label="搜索工作流"
placeholder="搜用途、模型或文件名"
/>
<kbd>/</kbd>
</div>
<div class="filters" role="group" aria-label="筛选工作流用途">
<button aria-pressed={usage === 'all'} onclick={() => (usage = 'all')}
@@ -328,7 +371,7 @@
}
.rail-search input {
min-width: 0;
width: 100%;
flex: 1;
padding: 0;
border: 0;
background: none;
@@ -336,6 +379,14 @@
font: inherit;
outline: none;
}
.rail-search kbd {
font: var(--desk-search-key-font);
padding: var(--desk-search-key-padding);
border-radius: var(--desk-search-key-radius);
border: 1px solid var(--line-2);
color: var(--tx-3);
background: var(--bg-1);
}
.rail-search:focus-within {
border-color: var(--scene);
}
@@ -1544,8 +1544,19 @@
align-items: center;
gap: 8px;
height: var(--desk-head-height);
margin: 0 calc(-1 * var(--desk-head-inset));
padding: 0 var(--desk-head-inset);
box-sizing: border-box;
border-bottom: 1px solid var(--line);
background: var(--desk-head-bg);
backdrop-filter: blur(10px);
flex-shrink: 0;
}
@media (max-width: 1366px) {
.workflow-file {
display: none;
}
}
.history-banner {
display: flex;
align-items: center;
+6
View File
@@ -57,11 +57,16 @@
var(--sh-2), 0 0 0 3px color-mix(in srgb, var(--gold) 8%, transparent),
0 0 40px color-mix(in srgb, var(--gold) 8%, transparent);
--desk-head-height: var(--head);
--desk-head-inset: 16px;
--desk-head-bg: var(--glass);
--desk-head-name-size: 14px;
--desk-head-name-weight: 600;
--desk-head-name-line: 1.55;
--desk-search-height: 34px;
--desk-search-size: 13px;
--desk-search-key-font: 500 10.5px/1 var(--mono);
--desk-search-key-padding: 3px 5px;
--desk-search-key-radius: 4px;
--desk-search-radius: var(--r-sm);
--desk-filter-height: 24px;
--desk-filter-size: 11.5px;
@@ -359,6 +364,7 @@
}
[data-theme="bluehour"] {
--desk-head-bg: color-mix(in srgb, #0f1838 55%, transparent);
color-scheme: dark;
--bg-0: #0a1029;
--bg-1: #0f1838;
@@ -0,0 +1,24 @@
# HEL-743 搜索提示与头行定点返工
基于 `e62499c517ccfbd78e7d3c13df98199b6699a6b2`,沿用分支 `feat/hel-729-creative-desk` 和 PR #3,base 保持 `feat/hel-728-night-foundation@8e84e4c21f22febe7bd4f20777d06fa1d4914e8e`。
- `DeskWorkflowRail.svelte` 补原件 `/` kbd,字体、内边距、圆角进入 `static/themes.css`,颜色和边框复用现有主题 token。输入按原件flex:1分配剩余宽度。最终输入样本/实际为176.671875/176.6875px(另两档152.671875/152.6875、140.671875/140.6875),有1/64px排版量化差,未把实测值写成完全相等;kbd字体/内边距/圆角/边框/颜色均一致。非编辑态 `/` 聚焦搜索,编辑器、contenteditable、组合输入、修饰键和可见弹层不会劫持;Esc 保留筛选并归还先前焦点,无可用来源时回到工作流栏控制按钮。
- `StudioDesk.svelte` 修改原头行规则,左右负边距和内边距各16px,背景、底线通到内容列边缘;使用统一玻璃和线条 token,蓝调使用原件55%玻璃背景。内容起点、头行高度及真实连接信息保持。
- 源文件名增加原件 `max-width:1366px` 隐藏规则,1440显示真实source_path的文件名,完整路径仍在title。未伪造业务数据。
- 从 HEL-742 复审的本地材料读取并纳入 `e2e/hel742.cjs`,此前任务附件确实只有5张PNG,脚本并非从附件下载。保留无图片声明时无槽位/素材入口、图视频切换、遮罩双槽对照7项。
- `e2e/hel743.cjs` 新增三档×四主题几何/玻璃/底线/kbd/文件名测量,1367/1366断点、搜索/焦点/输入法/弹层回归。只在隔离数据库中把夹具实际JSON文件的路径写为source_path,以验证真实文件名展示。`e2e/compare-hel743.py` 将测量区域并排,左样本、右实际。
复跑(沿用已有依赖,不新增依赖):
```bash
# HEL740_SAMPLE 指向从主卡独立下载且SHA256核对的原件
# Linux按本机环境提供 PLAYWRIGHT_MODULE_PATH / CHROMIUM_EXECUTABLE_PATH / LD_LIBRARY_PATH
HEL740_SAMPLE=/path/to/approved.html \
HEL729_TESTS=e2e/hel729.cjs,e2e/hel740.cjs,e2e/hel742.cjs,e2e/hel743.cjs \
calliope-backend/.venv/bin/python e2e/run-hel729.py
calliope-backend/.venv/bin/python e2e/compare-hel743.py
```
原件 SHA256:`0473d80d22b90194375f3566c1b8ca30dbd7433581b18f60956eabca252242a4`。runner在前台运行,finally停止并回收本轮服务;隔离夹具为 `e2e/shots/reference`。并排图、逐项结果和实测值随本卡附件交付。
验证:前端 check 0错误、1条既有ShotStagePanel字幕警告;test/build通过;相关后端4组47项通过。全仓lint仍为既有62文件格式问题、ESLint缺少配置;本次组件定向Prettier和 `git diff --check` 通过。浏览器42项原回归、138项R1—R4回归、7项模式切换和91项本轮定向断言通过(结果和实测值见任务附件)。中文输入法组合态用合成isComposing及229事件验证,未接入真实中文输入法/GPU/云生成。浏览器首次尝试因运行库路径不完整退出,修正本地LD_LIBRARY_PATH后正常执行;新增脚本曾因旧“参数”按钮名超时,已改用现有“创作设置⌄”入口复跑。没有修改正式数据、后端、B0顶栏或已裁定非偏差项;没有收费生成、合并或部署。
+21
View File
@@ -0,0 +1,21 @@
"""Assemble measured HEL-743 search/header crops, sample left and actual right."""
from pathlib import Path
import json
from PIL import Image, ImageDraw
root=Path(__file__).resolve().parents[1]
out=root/'e2e/shots/hel743'
rows=json.loads((out/'results.json').read_text())['measurements']
for width in (1440,1366,1280):
entries=[r for r in rows if r['width']==width]
panel_width=1040
canvas=Image.new('RGB',(panel_width*2,4*164),(35,36,40))
draw=ImageDraw.Draw(canvas)
for index,r in enumerate(entries):
for column,side in enumerate(('sample','actual')):
x=column*panel_width+10;y=index*164+8;m=r[side]
draw.text((x,y),f"{width} / {r['theme']} / {side} | head {m['head']['width']}x{m['head']['height']} | input {m['search']['width']} | file {m['file']['width']}",fill='white')
im=Image.open(out/f"{width}-{r['theme']}-{side}.png")
for key,dy in (('head',26),('box',90)):
box=m[key];left=int(box['x']);top=int(box['y']);right=round(box['x']+box['width']);bottom=round(box['y']+box['height'])
canvas.paste(im.crop((left,top,right,bottom)),(x,y+dy))
canvas.save(out/f'compare-{width}.png')
+115
View File
@@ -0,0 +1,115 @@
// HEL-742 independent verification: pure text-to-image / text-to-video
// workflows expose no pad-slot UI at all (no 管理素材 entry, no .a-slot),
// no stale slot UI after mode/workflow switches; positive control on the
// mask workflow (2 slots). Run inside the isolated stack.
const { chromium } = require(
process.env.PLAYWRIGHT_MODULE_PATH || "playwright",
);
const fs = require("node:fs");
const out = "e2e/shots/hel742";
fs.mkdirSync(out, { recursive: true });
const checks = [];
const errors = [];
const ok = (name, value) => {
if (!value) throw new Error("FAIL " + name);
checks.push(name);
console.log("PASS", name);
};
const api = async (p, body) =>
body
? (
await fetch("http://127.0.0.1:8247" + p, {
method: "POST",
headers: { "content-type": "application/json" },
body: JSON.stringify(body),
})
).json()
: (await fetch("http://127.0.0.1:8247" + p)).json();
const pause = (ms) => new Promise((r) => setTimeout(r, ms));
(async () => {
const b = await chromium.launch({
executablePath: process.env.CHROMIUM_EXECUTABLE_PATH,
args: ["--no-sandbox", "--disable-dev-shm-usage"],
});
try {
const c = await b.newContext({ viewport: { width: 1440, height: 900 } });
const p = await c.newPage();
p.on("pageerror", (e) => errors.push(e.message));
p.setDefaultTimeout(15000);
const wfs = await api("/api/workflows");
const t2i = wfs.find((w) => w.name === "文生图·回归");
const t2v = wfs.find((w) => w.name === "文生视频·回归");
let mask = wfs.find((w) => w.name === "遮罩图生图测试");
ok("隔离夹具含文生图/文生视频工作流", t2i && t2v);
if (!mask) {
const base = await api("/api/workflows/" + t2i.id);
const maskBody = {
...base.workflow_json,
5: {
class_type: "LoadImage",
inputs: { image: "" },
_meta: { title: "(Input:image) 输入图" },
},
6: {
class_type: "LoadImageMask",
inputs: { image: "", channel: "red" },
_meta: { title: "(Input:mask) 遮罩" },
},
};
mask = await api("/api/workflows", {
name: "遮罩图生图测试",
kind: "image",
workflow_json: maskBody,
});
}
const noSlotUi = async () =>
(await p.locator(".a-slot").count()) === 0 &&
(await p
.getByRole("button", { name: "管理素材", exact: true })
.count()) === 0;
await p.goto("http://127.0.0.1:5173/create?wf=" + t2i.id);
await p.locator("#desk-prompt").waitFor();
await pause(400);
await p.screenshot({ path: out + "/t2i-no-slot.png" });
ok("文生图无图片输入:无垫图槽、无素材入口", await noSlotUi());
await p.getByRole("tab", { name: "视频", exact: true }).click();
await p.locator(".rail-tools input[type=search]").fill("文生视频");
await p.locator(".workflow-pick").first().click();
await pause(600);
await p.screenshot({ path: out + "/t2v-no-slot.png" });
ok("文生视频无图片输入:无首尾帧槽、无素材入口", await noSlotUi());
await p.getByRole("tab", { name: "图片", exact: true }).click();
await p.locator(".rail-tools input[type=search]").fill("文生图");
await p.locator(".workflow-pick").first().click();
await pause(600);
ok("切回图片后无残留垫图槽", await noSlotUi());
await p.locator(".rail-tools input[type=search]").fill("遮罩");
await p.locator(".workflow-pick").first().click();
await pause(600);
await p.getByRole("button", { name: "管理素材", exact: true }).click();
await pause(400);
ok(
"遮罩工作流仍有两个图片槽(对照)",
(await p.locator(".a-slot").count()) === 2,
);
await p.getByRole("button", { name: "完成", exact: true }).click();
await p.locator(".rail-tools input[type=search]").fill("文生图");
await p.locator(".workflow-pick").first().click();
await pause(600);
ok("从遮罩切回文生图后槽位入口消失", await noSlotUi());
ok("无浏览器异常", errors.length === 0);
fs.writeFileSync(
out + "/results.json",
JSON.stringify({ checks, errors }, null, 2),
);
} finally {
await b.close();
}
})();
+351
View File
@@ -0,0 +1,351 @@
// HEL-743: sample geometry, themes, breakpoint and search keyboard regression.
// Run using e2e/run-hel729.py with HEL729_TESTS=e2e/hel743.cjs.
const { chromium } = require(
process.env.PLAYWRIGHT_MODULE_PATH || "playwright",
);
const fs = require("node:fs"),
path = require("node:path"),
assert = require("node:assert/strict");
const out = "e2e/shots/hel743";
fs.mkdirSync(out, { recursive: true });
const checks = [],
measurements = [],
errors = [];
function ok(name, v) {
assert(v, name);
checks.push(name);
console.log("PASS", name);
}
const pause = (ms) => new Promise((r) => setTimeout(r, ms));
async function metrics(p, sample = false) {
return p.evaluate((sample) => {
const sel = sample
? {
head: ".cc > .ph",
name: "#hdName",
file: "#hdFile",
search: "#wfSearch",
box: "#wfSearch",
key: ".wfb-top kbd",
}
: {
head: ".studio-heading",
name: ".model-selector",
file: ".workflow-file",
search: ".rail-search input",
box: ".rail-search",
key: ".rail-search kbd",
};
const entries = Object.entries(sel).map(([k, sel]) => {
let e = document.querySelector(sel);
if (sample && k === "box") e = e.parentElement;
if (sample && k === "key")
e = document
.querySelector("#wfSearch")
.parentElement.querySelector("kbd");
let r = e.getBoundingClientRect(),
s = getComputedStyle(e);
return [
k,
{
x: r.x,
y: r.y,
width: r.width,
height: r.height,
font: s.font,
fontSize: s.fontSize,
fontWeight: s.fontWeight,
lineHeight: s.lineHeight,
padding: s.padding,
radius: s.borderRadius,
border: s.border,
bottomBorder: s.borderBottom,
background: s.backgroundColor,
color: s.color,
blur: s.backdropFilter,
text: e.textContent,
},
];
});
return {
...Object.fromEntries(entries),
overflow: document.documentElement.scrollWidth > innerWidth,
};
}, sample);
}
(async () => {
const b = await chromium.launch({
executablePath: process.env.CHROMIUM_EXECUTABLE_PATH,
args: ["--no-sandbox", "--disable-dev-shm-usage"],
});
try {
const c = await b.newContext({ viewport: { width: 1440, height: 900 } }),
p = await c.newPage(),
s = await c.newPage();
p.on("pageerror", (e) => errors.push(e.message));
p.setDefaultTimeout(10000);
const wfs = await (
await fetch("http://127.0.0.1:8247/api/workflows")
).json(),
wf = wfs.find((w) => w.name === "遮罩图生图测试");
assert(wf);
// The fixture file and metadata live only under the isolated test data directory.
const settings = await (
await fetch("http://127.0.0.1:8247/api/settings")
).json();
assert.equal(
path.resolve(settings.data_dir),
path.resolve("e2e/shots/reference/data"),
);
const detail = await (
await fetch("http://127.0.0.1:8247/api/workflows/" + wf.id)
).json();
const source = path.join(settings.data_dir, "hel743-mask-workflow.json");
fs.writeFileSync(source, JSON.stringify(detail.workflow_json, null, 2));
require("node:child_process").execFileSync(
"calliope-backend/.venv/bin/python",
[
"-c",
'import sqlite3,sys; c=sqlite3.connect(sys.argv[1]); c.execute("UPDATE workflows SET source_path=? WHERE id=?",(sys.argv[2],int(sys.argv[3]))); c.commit(); c.close()',
path.join(settings.data_dir, "calliope.db"),
source,
String(wf.id),
],
);
await p.goto("http://127.0.0.1:5173/create?wf=" + wf.id);
await p.locator("#desk-prompt").waitFor();
await s.goto(
"file://" +
path.resolve(process.env.HEL740_SAMPLE) +
"?still=1&fill=1#create/image",
);
await s.locator("#wfSearch").waitFor();
for (const [width, height] of [
[1440, 900],
[1366, 768],
[1280, 720],
]) {
await p.setViewportSize({ width, height });
await s.setViewportSize({ width, height });
for (const theme of ["night", "day", "grade", "bluehour"]) {
await p.getByRole("button", { name: "主题", exact: true }).click();
await p
.locator(".choice")
.filter({
hasText: {
night: "夜片场",
day: "日光棚",
grade: "调色间",
bluehour: "蓝调时刻",
}[theme],
})
.click();
await p.keyboard.press("Escape");
await s.evaluate((t) => {
document.documentElement.dataset.theme = t;
renderCreate();
}, theme);
await pause(450);
const actual = await metrics(p),
sample = await metrics(s, true);
measurements.push({ width, height, theme, actual, sample });
const tag = width + "/" + theme;
ok(
tag + " head width/height/name x",
actual.head.width === sample.head.width &&
actual.head.height === sample.head.height &&
actual.name.x === sample.name.x,
);
ok(
tag + " glass/bottom line/blur",
actual.head.background === sample.head.background &&
actual.head.bottomBorder === sample.head.bottomBorder &&
actual.head.blur === sample.head.blur,
);
ok(
tag + " search/input width",
Math.abs(actual.search.width - sample.search.width) < 0.1 &&
actual.box.width === sample.box.width,
);
ok(
tag + " kbd exact appearance",
[
"fontSize",
"fontWeight",
"lineHeight",
"padding",
"radius",
"border",
"background",
"color",
].every((k) => actual.key[k] === sample.key[k]) &&
actual.key.text === "/",
);
ok(
tag + " filename breakpoint",
width <= 1366
? actual.file.width === 0 && sample.file.width === 0
: actual.file.width > 0 && sample.file.width > 0,
);
ok(tag + " no overflow", !actual.overflow);
await p.screenshot({ path: out + `/${width}-${theme}-actual.png` });
await s.screenshot({ path: out + `/${width}-${theme}-sample.png` });
}
}
for (const width of [1367, 1366]) {
await p.setViewportSize({ width, height: 768 });
await s.setViewportSize({ width, height: 768 });
const a = await metrics(p),
v = await metrics(s, true);
ok(
width + " boundary filename matches sample",
(a.file.width === 0) === (v.file.width === 0),
);
}
await p.setViewportSize({ width: 1440, height: 900 });
const search = p.getByRole("searchbox", { name: "搜索工作流" }),
origin = p.getByRole("tab", { name: "图片", exact: true });
await origin.focus();
await p.keyboard.press("/");
ok(
"/ focuses search",
await search.evaluate((e) => e === document.activeElement),
);
await search.fill("遮罩");
await pause(200);
ok("search filters", (await p.locator(".workflow-pick").count()) === 1);
await p.keyboard.press("Escape");
ok(
"Esc returns prior focus",
await origin.evaluate((e) => e === document.activeElement),
);
ok("Esc preserves filter", (await search.inputValue()) === "遮罩");
await search.fill("");
await search.focus();
await p.keyboard.press("/");
ok(
"search typing slash remains literal",
(await search.inputValue()) === "/",
);
await search.fill("");
const prompt = p.locator("#desk-prompt");
await prompt.fill("");
await prompt.focus();
await p.keyboard.press("/");
ok("textarea keeps slash", (await prompt.inputValue()) === "/");
await p.evaluate(() => {
let e = document.createElement("div");
e.id = "editable-probe";
e.contentEditable = "true";
e.textContent = "IME";
document.body.append(e);
e.focus();
});
await p.keyboard.press("/");
ok(
"contenteditable keeps focus",
await p
.locator("#editable-probe")
.evaluate(
(e) => document.activeElement === e && e.textContent.includes("/"),
),
);
await p.locator("#editable-probe").evaluate((e) => e.remove());
await origin.focus();
ok(
"composition slash ignored",
await origin.evaluate((e) => {
let k = new KeyboardEvent("keydown", {
key: "/",
bubbles: true,
cancelable: true,
isComposing: true,
});
e.dispatchEvent(k);
return document.activeElement === e && !k.defaultPrevented;
}),
);
ok(
"legacy IME 229 ignored",
await origin.evaluate((e) => {
let k = new KeyboardEvent("keydown", {
key: "/",
keyCode: 229,
bubbles: true,
cancelable: true,
});
e.dispatchEvent(k);
return document.activeElement === e && !k.defaultPrevented;
}),
);
await p.keyboard.press("Control+/");
ok(
"modified slash ignored",
await origin.evaluate((e) => document.activeElement === e),
);
await prompt.focus();
ok(
"composition Escape keeps editor focus",
await prompt.evaluate((e) => {
let k = new KeyboardEvent("keydown", {
key: "Escape",
bubbles: true,
cancelable: true,
isComposing: true,
});
e.dispatchEvent(k);
return document.activeElement === e && !k.defaultPrevented;
}),
);
await p.setViewportSize({ width: 1440, height: 900 });
ok(
"1440 filename is genuine source basename",
(await p.locator(".workflow-file").textContent()) ===
path.basename(source) &&
(await p.locator(".workflow-file").getAttribute("title")) === source,
);
// Mouse focus and removal of the prior node use a stable rail control fallback.
await search.click();
await p.keyboard.press("Escape");
ok(
"mouse search Esc returns control",
await p.evaluate(
() =>
document.activeElement !==
document.querySelector(".rail-search input"),
),
);
await p
.getByRole("button", { name: "创作设置⌄", exact: true })
.first()
.click();
await p.locator(".modal-panel").waitFor();
await p.locator(".modal-panel button").first().focus();
await p.keyboard.press("/");
ok(
"dialog slash never jumps to rail",
!(await search.evaluate((e) => e === document.activeElement)),
);
await p.keyboard.press("Escape");
ok(
"dialog Escape closes normally",
(await p.locator(".modal-panel").count()) === 0,
);
await p.getByRole("button", { name: "收起历史栏", exact: true }).focus();
await p.keyboard.press("/");
await p.keyboard.press("Escape");
ok(
"keyboard origin restored exactly",
await p
.getByRole("button", { name: "收起历史栏", exact: true })
.evaluate((e) => document.activeElement === e),
);
ok("no browser errors", errors.length === 0);
fs.writeFileSync(
out + "/results.json",
JSON.stringify({ checks, measurements, errors }, null, 2),
);
} finally {
await b.close();
}
})();