Skip to content
Draft
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
20 changes: 11 additions & 9 deletions .github/workflows/nightly.yml
Original file line number Diff line number Diff line change
Expand Up @@ -314,7 +314,8 @@ jobs:
- name: Production-build browser journeys
run: |
export PLAYWRIGHT_MODULE="$RUNNER_TEMP/opendirector-browser/node_modules/playwright-core/index.mjs"
mkdir -p "$RUNNER_TEMP/production-logs"
export CREATION_BROWSER_EVIDENCE="$RUNNER_TEMP/production-evidence"
mkdir -p "$CREATION_BROWSER_EVIDENCE/logs"
python tests/browser/creation_server.py --port 8019 --assistant-fixture >"$RUNNER_TEMP/creation-server.log" 2>&1 &
api_pid=$!
OPENDIRECTOR_API_URL="$CREATION_API_URL" npm run preview -- --port 5179 --strictPort >"$RUNNER_TEMP/preview.log" 2>&1 &
Expand All @@ -333,21 +334,22 @@ jobs:
node -e 'const m=require("./tests/browser/manifest.json");for(const s of m.scripts)if((s.lanes||[]).includes("production"))console.log([s.file,...(s.args||[])].join(" "))'
)
failed=0
: > production-results.txt
results="$CREATION_BROWSER_EVIDENCE/production-results.txt"
: > "$results"
for entry in "${scripts[@]}"; do
log="$RUNNER_TEMP/production-logs/$(echo "$entry" | tr ' .' '_').log"
log="$CREATION_BROWSER_EVIDENCE/logs/$(echo "$entry" | tr ' .' '_').log"
if node tests/browser/$entry >"$log" 2>&1; then
echo "pass $entry" >> production-results.txt
echo "pass $entry" >> "$results"
else
echo "fail $entry" >> production-results.txt
echo "fail $entry" >> "$results"
failed=1
fi
done
cat production-results.txt
cat "$results"
if [ "$failed" -ne 0 ]; then
for entry in "${scripts[@]}"; do
log="$RUNNER_TEMP/production-logs/$(echo "$entry" | tr ' .' '_').log"
if grep -Fq "fail $entry" production-results.txt; then
log="$CREATION_BROWSER_EVIDENCE/logs/$(echo "$entry" | tr ' .' '_').log"
if grep -Fq "fail $entry" "$results"; then
echo "===== $entry ====="
tail -n 40 "$log"
fi
Expand All @@ -365,7 +367,7 @@ jobs:
uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4.6.2
with:
name: production-browser-results
path: production-results.txt
path: ${{ runner.temp }}/production-evidence/
if-no-files-found: ignore

# Lane 5: output verification and performance sampling. The render probe is
Expand Down
39 changes: 39 additions & 0 deletions docs/development/ci-failures.md
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,45 @@ The OpenCode hang tracked as #162 is unrelated and was not verified here.

以上用例已于 2026-11-07 登记 watchlist,由 nightly 观测波动率;修复后从 watchlist 与本表移除。

## Workspace keyboard upload / 工作区键盘上传

[Nightly #34](https://github.com/ThinkFlowLab/OpenDirector/actions/runs/47300922130/job/144931968554)
failed at `workspace_modes.mjs:789`, waiting for `filechooser` after End focused
the upload button. A Chromium probe with Playwright 1.58.2 reproduced this
failure shape by delaying file-chooser interception enablement by 150 ms.
The page now keeps a chooser listener active before navigation and retains
the End-to-Enter keyboard sequence, while checking one event and the original
saved bytes. This addresses the demonstrated subscription race; it does not
prove that race caused the original CI failure.

Nightly #34 在 End 将焦点移到上传按钮后,等待 `filechooser` 超时。
本地将 Playwright 1.58.2 的文件选择器拦截启用延迟 150 ms,复现了相同错误形态。
测试现提前订阅事件,保留 End 获得焦点后直接发送 Enter 的操作,并校验只打开一次选择器及保存后的原始字节。
这修复了已复现的订阅竞态,但不能证明原 CI 就发生了同样的时序。

Set `CREATION_BROWSER_EVIDENCE` to an output directory to retain the workspace
input-event ring and failure screenshot, plus a trace covering the rail and
later checks. The production lane sets it and uploads complete script logs
and evidence under `production-browser-results`. On Windows, wait until the
original provider has entered the closed generation gate before sending chat:
the published `running` snapshot alone can still overlap the generation
checkpoint and reject the draft flush with `storage_busy`. This preserves both
running tasks for the mode-switch assertions without retrying any submission.
For isolated local validation, give the native skill reader writable
`XDG_DATA_HOME`, `XDG_CACHE_HOME` and `XDG_STATE_HOME` directories; a denied global
OpenCode log otherwise rejects the turn with `agent_dependency_unavailable`.
Windows, Node 24.14.1 and Chromium 145 passed the isolated bilingual rail,
delayed-subscription and full production-preview and dev-server checks. Linux CI and the
required Node 24.22.1 runtime remain separate validation.

设置 `CREATION_BROWSER_EVIDENCE` 可保留最近的输入事件、失败截图以及工具栏之后检查的 trace。
生产通道自动设置并将完整脚本日志和证据上传到 `production-browser-results`。
Windows 中等待原生成任务实际进入受控等待后再发送助手消息,避免仅看到 `running` 快照时,
草稿保存仍与生成状态提交争锁;保留两个运行中任务的模式切换断言,不重试提交。
本地验证还需为原生技能读取设置独立且可写的上述三个 XDG 目录,避免全局 OpenCode 日志无权限造成
`agent_dependency_unavailable`。本地中英文上传、延迟订阅及完整生产预览与开发服务器旅程已通过;
Linux CI 和要求的 Node 24.22.1 环境仍需单独验证。

## Canvas pointer tests at reduced zoom

The toolbar top-bar test timed out on both main and PR #689 at 50% zoom. The center of the fixture node was behind the left rail, so the drag pressed Add Text. Use an exposed point on the node and check its hit target before sending pointer input. [Main run](https://github.com/ThinkFlowLab/OpenDirector/actions/runs/47344640055/job/145081431931) · [PR run](https://github.com/ThinkFlowLab/OpenDirector/actions/runs/47378835105/job/145201585744)
Expand Down
6 changes: 6 additions & 0 deletions docs/development/lessons.md
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,12 @@ When work exposes a consequential risk or a recurring problem, add a lesson or u
- The subject-library and video-review checks in Nightly run 45572808123 reached their persisted-state assertions before the lazy previews were ready. After fitting the canvas, wait for the target image to load or the video to load metadata, then verify the dimensions or duration. [Nightly run 45572808123](https://github.com/ThinkFlowLab/OpenDirector/actions/runs/45572808123/job/139063347523)
- [Nightly run 46322961844](https://github.com/ThinkFlowLab/OpenDirector/actions/runs/46322961844/job/141535114491) reached a subject image fingerprint check after the element mounted but before its source was ready. Wait for a nonempty source and decode before reading bytes. The same run's history dialog test intercepted a save on a clean canvas. Make a real edit before testing the pending or failed save states, since the save queue skips unchanged content.

## Keyboard picker tests need an established event subscription

- **Trigger:** A test starts `waitForEvent("filechooser")` alongside an immediate keyboard activation.
- **Evidence:** [Nightly run 47300922130](https://github.com/ThinkFlowLab/OpenDirector/actions/runs/47300922130/job/144931968554) timed out after the upload button's focus assertion passed. A local Chromium probe with Playwright 1.58.2 reproduced the missing event by delaying interception enablement by 150 ms; keeping the subscription active before navigation preserved the event and the bilingual upload's original bytes. The unmodified narrow interaction passed 25 local repetitions, so the probe demonstrates a possible failure mechanism, not the exact CI schedule.
- **Check:** Keep chooser observation active for the page lifetime, retain the keyboard focus assertion and verify exactly one chooser plus persisted bytes. Preserve complete script logs and bounded input events, screenshots and traces on failure. A rerun or a longer timeout alone does not explain a missing chooser.

## Browser clock pauses must precede short-lived observations

- **Trigger:** Freezing browser time to inspect a short-lived response in both languages.
Expand Down
65 changes: 62 additions & 3 deletions tests/browser/workspace_modes.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
import { addCanvasNode } from "./canvas_creation.mjs";
import assert from "node:assert/strict";
import { createHash } from "node:crypto";
import { mkdir } from "node:fs/promises";
import { mkdir, writeFile } from "node:fs/promises";
import { join } from "node:path";
import { launchBrowser } from "./engine.mjs";
import { chooseGenerationModel } from "./model_picker.mjs";
Expand Down Expand Up @@ -48,12 +48,43 @@ const conversation = () => api(root + "/assistant");
const browser = await launchBrowser();
let page;
const errors = [];
const evidenceDir = process.env.CREATION_BROWSER_EVIDENCE;
let tracing = false;
let fileChoosers = 0;
try {
page = await browser.newPage({
locale: "zh-CN",
viewport: { width: 1720, height: 1120 },
});
page.setDefaultTimeout(15000);
page.on("filechooser", () => { fileChoosers += 1; });
if (evidenceDir) {
await mkdir(evidenceDir, { recursive: true });
await page.addInitScript(() => {
const events = [];
window.__workspaceInputEvents = events;
const describe = element => element instanceof Element ? {
tag: element.tagName,
label: element.getAttribute("aria-label"),
className: element.getAttribute("class"),
disabled: element.matches(":disabled"),
inert: Boolean(element.closest("[inert]")),
connected: element.isConnected,
} : null;
for (const type of ["keydown", "keyup", "click", "focusin", "focusout"]) {
document.addEventListener(type, event => {
const entry = { type, key: event.key, time: performance.now(),
target: describe(event.target), active: describe(document.activeElement) };
events.push(entry);
if (events.length > 100) events.shift();
setTimeout(() => {
entry.prevented = event.defaultPrevented;
entry.activeAfter = describe(document.activeElement);
}, 0);
}, true);
}
});
}
const commands = [], stops = [];
page.on("pageerror", (error) => errors.push(error.message));
page.on("request", (request) => {
Expand Down Expand Up @@ -644,6 +675,7 @@ try {
await page.getByRole("button", { name: "提交生成", exact: true }).click();
const running = await until(state, (value) => value.jobs.some((job) => job.status === "running" && job.inputSnapshot.spec.id === specId), "image job must be running");
const jobId = running.jobs.find((job) => job.inputSnapshot.spec.id === specId).id;
await until(() => api("/creation-test-health"), value => value.calls.some(call => call.id === jobId), "original provider is waiting at the generation gate");
// Send the same persisted draft and reference that crossed both layouts during upload.
await assistant.getByRole("button", { name: "发送消息", exact: true }).click();
const turn = await until(conversation, (value) => !!value.activeTurnId && value.messages.at(-1)?.status === "streaming", "assistant turn must be running");
Expand Down Expand Up @@ -755,6 +787,10 @@ try {
await page.keyboard.press("Escape");
await dialog.waitFor({ state: "detached" });
assert.equal(await pending.innerText(), pendingText, "pointer interactions in the modal preserve the pending reference");
if (evidenceDir) {
await page.context().tracing.start({ screenshots: true, snapshots: true, sources: true });
tracing = true;
}
for (const [width, locale] of [[390, "zh-CN"], [1720, "en-US"]]) {
const zh = locale === "zh-CN";
await page.setViewportSize({ width, height: 900 });
Expand Down Expand Up @@ -786,7 +822,9 @@ try {
await rail.getByRole("button", { name: labels[0], exact: true }).press("End");
const uploadButton = rail.getByRole("button", { name: zh ? "上传本地素材" : "Upload local asset", exact: true });
assert.ok(await uploadButton.evaluate(button => button === document.activeElement));
const choosersBefore = fileChoosers;
const [chooser] = await Promise.all([page.waitForEvent("filechooser"), page.keyboard.press("Enter")]);
assert.equal(fileChoosers, choosersBefore + 1, "one keyboard activation opens exactly one chooser");

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

这里在收到第一个 filechooser 后马上检查计数;如果后面再来第二个,下一轮会把它计入新的基准,仍可能全绿。建议在这次上传的保存字节断言后再核对计数,让测试真能捕捉重复 chooser。 (Check the count again after the upload completes.)

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Agreed. At 444b9499, the immediate assertion only confirms that the first chooser arrived. A second event during setFiles, persistence, or the content download can be absorbed into the next iteration's baseline.

The follow-up should retain this iteration's choosersBefore and assert fileChoosers === choosersBefore + 1 again after the downloaded-byte equality check. That closes the upload observation window without adding a sleep or resetting the baseline. The current exactly-one claim is incomplete until that check is added; this thread should remain unresolved.

const name = `workspace-rail-${locale}.png`;
const bytes = await rail.screenshot();
await chooser.setFiles({ name, mimeType: "image/png", buffer: bytes });
Expand Down Expand Up @@ -866,13 +904,34 @@ try {
console.log("PASS workspace modes: bilingual right default and saved docks, edge previews and release, keyboard, direct nodes and upload, shared draft and uninterrupted running tasks");
} catch (error) {
console.error(error);
if (page) console.error({ errors, page: (await page.locator("body").innerText()).slice(-6000) });
if (page) {
try {
console.error({ errors, page: (await page.locator("body").innerText()).slice(-6000) });
} catch (evidenceError) {
console.error("Unable to read workspace failure text", evidenceError);
}
}
if (page && evidenceDir) {
try {
const events = await page.evaluate(() => window.__workspaceInputEvents ?? []);
await writeFile(join(evidenceDir, "workspace-input-events.json"), JSON.stringify({ errors, fileChoosers, events }, null, 2));
await page.screenshot({ path: join(evidenceDir, "workspace-failure.png"), timeout: 5000 });
} catch (evidenceError) {
console.error("Unable to capture workspace failure evidence", evidenceError);
}
}
throw error;
} finally {
try {
await api("/creation-test-assistant-gate", { open: true });
await api("/creation-test-gate", { open: true });
} finally {
await browser.close();
try {
if (tracing) await page.context().tracing.stop({ path: join(evidenceDir, "workspace-trace.zip") });
} catch (evidenceError) {
console.error("Unable to save workspace trace", evidenceError);
} finally {
await browser.close();
}
}
}