From 09b02d14d1fd9084516e55e9fdc518712cff3388 Mon Sep 17 00:00:00 2001 From: zhanglinghao Date: Mon, 23 Nov 2026 16:01:45 +0800 Subject: [PATCH 1/7] Studio hand-over: every note is not sent, sent and not picked up, or picked up; nothing a person submits is lost MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The first real film lost a batch of 12 notes written after their round had been taken, showed "正在取" while nobody would take anything, and let one storyboard submission end the outline re-review's wait too. - feedback.py: .consumed records who took what (when, which run, which agent program); a wait claims under the lock, so two waits never both hand one submission over; a wait is for one round and ends (exit 7) when its page is no longer out; it first hands over every submission nobody took or answered, of any round, a later batch said as such; the default wait is 12 h (was 7100 s). - status.py: notes nobody took come before any other next step (review.unread, an "unread:" line); a later page of a decided gate ① (1b) waits for the person; holder says which agent program holds the film and whether outside Studio. - standing.py: "正在取" only for a live wait on the round that is out; notes_late / notes_left say who picks notes up; an agent outside Studio's window is named, with a second AI here only as a confirmed second line. - Studio: the notes block shows each note's state, pinned above the note box; a taken round's new notes go as a later batch ("补交"), said before and after sending; "先改" with no note asks once; the conversation tab asks before it starts a second AI on a film an outside agent holds. - Checks: replays of the lost batch, one submission ending two waits, two waits on one note, a timeout leaving notes, the outside agent (test_agents.py handoff); the page in a headless Chrome (test_page.py, page_driver.mjs). --- changes/studio-handover-trust.md | 9 + playbook/01-pipeline.md | 2 +- tools/ci.sh | 8 + tools/commands.json | 6 +- tools/desk/README.md | 17 +- tools/desk/desk.py | 12 +- tools/desk/feedback.py | 198 ++++++++++++++++---- tools/desk/page_driver.mjs | 57 ++++++ tools/desk/server.py | 31 +++- tools/desk/static/agent.js | 31 +++- tools/desk/static/core.js | 25 +++ tools/desk/static/studio.css | 13 ++ tools/desk/static/studio.js | 134 +++++++++++--- tools/desk/test_agents.py | 231 +++++++++++++++++++++++- tools/desk/test_page.py | 172 ++++++++++++++++++ tools/gate.py | 12 +- tools/schemas/output/status.schema.json | 13 +- tools/standing.py | 181 ++++++++++++++++++- tools/status.py | 64 ++++++- 19 files changed, 1104 insertions(+), 112 deletions(-) create mode 100644 changes/studio-handover-trust.md create mode 100644 tools/desk/page_driver.mjs create mode 100644 tools/desk/test_page.py diff --git a/changes/studio-handover-trust.md b/changes/studio-handover-trust.md new file mode 100644 index 00000000..d7cd9d2d --- /dev/null +++ b/changes/studio-handover-trust.md @@ -0,0 +1,9 @@ +**Studio 里交的意见不会再没人收:每份意见都看得到是还没交、交了还没人取,还是被谁取走了** +- Why: 第一支真片子里,人在一轮已经被取走以后又在 Studio 里交了一整批意见,外面等着的 agent 早已不在等,界面却写"已经交给 agent 了";另一回人什么都没交,右栏写"你的意见交出去了,等着的 agent 正在取";分镜那一页交了一次,却让更早开着的大纲复审那一轮也当成交了。 +- 每份提交只在三种状态里的一种,Studio、`bin/vh status` 和等着的 agent 说的一样:还没人取;取走了(什么时候、被哪个 agent 程序,记在 `out/review/feedback/.consumed`);答过了(REVIEW.md 里它那一节写了定了)。一轮被取走以后再写的意见是这一轮的补交,单独交、单独显示,不并进别的哪一页。 +- `bin/vh desk wait` 和 `bin/vh gate --wait` 等的是一轮:一开始先把所有还没人取的意见交出来,哪一轮的都算(补交的写明);两个同时在等,同一份只有一个拿到;等的时候这一页换成了别的页,就说这一轮没人交、退出 7,不再把下一页的提交当成自己这一页的。超时、agent 没了、被停下,都不碰没人取的意见。默认等 12 小时(原来是 7100 秒,人睡一觉 agent 要醒好几次)。 +- `bin/vh status`:有没人取的意见时,下一步先说它们(`unread:` 一行,`--json` 的 `review.unread`),一条 `bin/vh desk wait` 就全交出来;已经定了的关卡 ① 又发出一页(比如大纲复审 1b),这一页等人回,不再算成已定;`holder` 说开着这支片子的 agent 是哪个程序、在不在 Studio 窗口外面。 +- 右栏的状态话只说真的:"正在取"只在有一个活着的等待、等的正是现在这一轮时说;页面在等人时右栏照样摆出这一页要定的事。 +- Studio 右栏:"你的意见"一块写清每份意见的状态(还没交几条;交了几条、还没人取,谁会来取;几点被谁取走),钉在写意见的框上面,1440×900 下决定卡片再多也不用滚就看得到刚记下的那一条。一轮被取走以后,按钮是"补交",交之前和交之后都说清这几条没人在等、什么时候会被取;有 AI 在等这一轮才说"马上会取"。 +- 选了"先改"却一条意见都没写,交之前问一句改哪里:"回去写"或"就这样交"。 +- 片子由 Studio 窗口外面的 agent(终端或桌面版里的 Claude Code、Codex)在做时,右栏直说它在窗口外面、在这里打的字它收不到;"在这里另起一个 AI 做这支片子"放到第二行,点了还要再确认一次;对话页第一句话发出之前也先问,点"另起一个 AI"才开始。 diff --git a/playbook/01-pipeline.md b/playbook/01-pipeline.md index 12ce15ea..2a67273d 100644 --- a/playbook/01-pipeline.md +++ b/playbook/01-pipeline.md @@ -213,7 +213,7 @@ projects/2026-10-01-leo-doppler/ - **什么时候用**:`LOCAL.md` 没写审阅方式时,`studio` 默认用它;`standard` 在 Studio 开着时也用它(`bin/vh gate` 看到 Studio 在跑才这样,不会替你起),Studio 没开时还是静态审阅页,人想逐条点评时也可以开审阅台;`quick` 不设关卡,导演模式要停的那几处在聊天里问或用静态页。 - **语言**:界面语言取 BRIEF 的 `Review language`(`zh` / `en`),按用户第一句话的语言定,建项目时用 `bin/vh new … --lang en`;这一轮的 gate JSON 写了 `lang` 时以它为准(和静态审阅页同一条规则);页面右上角也能切换。字幕和项目文档照旧用项目自己的语言。 - **出页**:运行 `bin/vh gate --desk`,把它打印的消息交给人,在这一关停住。命令会打开 Studio 到这一轮的视图。服务没起来时,静态页可以复制回复到聊天。 -- **有后台唤醒的宿主**:可在后台运行 `bin/vh gate --desk --wait` 出页并等待。这条命令默认等 7100 秒,先打印交给人的消息,收到反馈再打印并退出。此方式适合能在命令结束后唤醒 agent 的会话。不带 `--desk` 也行:这一站开在 Studio 里时 `--wait` 就等;`standard` 的这一站按默认落到静态页(Studio 没开)时,它照常出页、退出 5:没有人答复,这一轮停下,等人在聊天里回。 +- **有后台唤醒的宿主**:可在后台运行 `bin/vh gate --desk --wait` 出页并等待。这条命令默认等 12 小时,先打印交给人的消息,收到反馈再打印并退出;人在已经被取走的一轮里补交的、别的轮还没人取的意见,它一开始就先交出来。退出 7 是这一页已经换成了别的页、这一轮没人交:跑 `bin/vh status`,在现在开着的那一轮上再等。此方式适合能在命令结束后唤醒 agent 的会话。不带 `--desk` 也行:这一站开在 Studio 里时 `--wait` 就等;`standard` 的这一站按默认落到静态页(Studio 没开)时,它照常出页、退出 5:没有人答复,这一轮停下,等人在聊天里回。 - **Codex 或等待已超时的会话**:人在 Studio 提交后,回原对话说一声"我交了"(英文是"I've sent it";Studio 和 `bin/vh gate` 现在教人这么说;老说法"看审阅台""check the desk"也一样算)。继续时先跑 `bin/vh status `,再按 `next:` 读 `bin/vh desk feedback --round <实际轮次>`。适用的原话已写进 `REVIEW.md`,在同一节补"定了 / 改了";自己定的事记进 `DECISIONS.md`。没标的条目都算通过。 - **页面读什么**:项目文件本身和 `bin/vh status`,每次刷新重读,不另存状态。表格怎么写才排得出来(BRIEF 的 Outline 表、SCRIPT 的字幕或旁白表、NOTES 素材清单、DECISIONS 的划线约定、REVIEW、`shots.json`)、gate JSON 给审阅台加的 `music`(音轨、节拍表、乐段的名字),以及提交的 JSON 格式,都在 `tools/desk/README.md`。读不出结构的文档不会消失:照原文排版显示在对应的模块和账本的"文档"里。人想随时看所有片子,`bin/vh desk` 不带项目开一个控制台就行(`--root <文件夹>` 加别处的项目)。 - **成片模块要的数据**:都是已有命令的输出,缺哪样那条轨道就空着、写着做它的命令。关卡 ③ 用审阅台时,片子出来后跑一次 `bin/vh thumbs ` 和 `bin/vh peaks `(只用 ffmpeg,几秒),人拖动时间线就能看到每一秒的画面和波形;镜头、旁白和节拍来自 `bin/vh timeline --resolved` 读的那几份文件,检查的问题来自 `bin/vh check` 的记录,第几版、改了哪里和上一版来自 `bin/vh versions`。 diff --git a/tools/ci.sh b/tools/ci.sh index 2683bb4c..3cc0e9c8 100755 --- a/tools/ci.sh +++ b/tools/ci.sh @@ -3345,6 +3345,14 @@ desk_checks() { # the words a person reads (Studio's tables, where a film stands, the review page, gate's lines): both languages, no retired names if a=$(python3 tools/desk/test_wording.py 2>&1); then ok "the words a person reads: $a" else bad "the words a person reads: $a"; fi + # Studio's page in a headless Chrome (tools/desk/test_page.py, page_driver.mjs): what the person sees of their notes' hand-over + local pt k m; pt=$(mktemp -d "${TMPDIR:-/tmp}/vh-ci.XXXXXX") + python3 tools/desk/test_page.py "$pt" > "$pt/out" 2>&1 + while IFS=$'\t' read -r k m; do + case $k in ok) ok "Studio's page: $m" ;; bad) bad "Studio's page: $m" ;; skip) no_chrome "Studio's page (${m%%:*})" ;; esac + done < "$pt/out" + grep -qx end "$pt/out" || bad "Studio's page: the test stopped: $(tail -n 3 "$pt/out" | tr '\n' ' ')" + rm -rf "$pt" t=$(mktemp -d "${TMPDIR:-/tmp}/vh-ci.XXXXXX") vh desk data tools/desk/fixtures/zh > "$t/zh.json" && vh desk data tools/desk/fixtures/en > "$t/en.json" if python3 - "$t/zh.json" "$t/en.json" <<'PY' diff --git a/tools/commands.json b/tools/commands.json index 6bfc9627..ea537383 100644 --- a/tools/commands.json +++ b/tools/commands.json @@ -1188,7 +1188,8 @@ "(LOCAL.md's 审阅方式; else studio: desk; standard: Studio while it is open, else the page; quick: page), prints the chat message;", "--wait (desk): then waits like desk wait, exit 0 only when a submission was received; a standard film's stop that went out", "as the static page by default (Studio not open): the page goes out as usual, exit 5: nothing was answered; end the turn", - "and wait for the person's reply in the chat (tools/gate.py)" + "and wait for the person's reply in the chat; exit 7: another page went out before anything came for this one: run", + "bin/vh status and wait on the round open now (tools/gate.py)" ] }, { @@ -1229,7 +1230,8 @@ "every project bin/vh projects finds (--root: more folders), a card a film, waiting ones first. A project: the page", "opens on the module of the stop that waits (gate 1 concept, 2 storyboard, 3 the cut, with its timeline). --only: that", "project and nothing else under the roots (bin/vh gate's desk). wait: block until the person submits, print it, exit 0", - "(an agent runs it in the background); feedback: the latest submission; data: what the desk reads from the project, as JSON.", + "(an agent runs it in the background; notes no agent took yet, of any round, come first; 3 after 12 h; 7 this round's", + "page is no longer the one out: run bin/vh status, wait on the round open now); feedback: the latest submission; data: what the desk reads from the project, as JSON.", "revision: put one saved comment and the original and revised cuts in the Cut module's review list.", "The desk shows Studio's window itself: started in a terminal it does (--no-open: not); bin/vh studio does any other", "time, and a page that can only look has a button for it. Nothing it prints opens a page; --print-address writes an", diff --git a/tools/desk/README.md b/tools/desk/README.md index b9d6d0af..394bc1a0 100644 --- a/tools/desk/README.md +++ b/tools/desk/README.md @@ -13,7 +13,7 @@ bin/vh studio --install-icon [--no-shell] [--dir 文件夹] # OVH Studio:Stu bin/vh gate <项目> [--desk|--page|--chat] [--wait] [--print-address] # 一次停一条命令:查 gate-.json,出静态页并记成这一轮(审阅方式:旗子、LOCAL.md,再按档位:studio 是审阅台,standard 在 Studio 开着时也是,否则是静态页;--wait 而 `standard` 的这一站按默认落到静态页(Studio 没开)时,照常出页、退出 5:没有人答复,这一轮停下,等人在聊天里回;`OVH_GATE_STUDIO=0` 时不去找 Studio,`tools/ci.sh` 整个运行都这样设,它的检查不碰不是自己起的 Studio),审阅方式是审阅台时把这一站开在 Studio 的窗口里(Studio 在跑就用它,不在它文件夹里的片子先加进它的空间;Studio 没在跑才在后台起这个项目的审阅台,12 小时没人访问自己停),打印聊天消息;--wait 再像 desk wait 一样等 bin/vh desk [--root 文件夹 …] [--port N] [--no-open] [--print-address] # 控制台:bin/vh projects 找得到的所有项目($OVH_PROJECTS、<仓库>/projects、每个 --root);在终端里起时,起好就叫出它的窗口(--no-open 不开),agent 起的不开;终端里不显示地址,agent 和日志拿到的地址打开的页面只能看(--print-address 才把开门地址写到终端);同样的 roots 已经有一个在跑,就只说一声 bin/vh desk <项目> [--root 文件夹 …] [--port N] [--idle 秒] [--only] # 同一个页面,打开在这个项目上,空间里照样有 roots 下的每一支片子;只听 127.0.0.1;默认 8780–8799 里第一个空闲端口;这个项目已经有一个在跑,就只打印它的地址;--idle:这么久没人访问就自己停;--only:只服务这一个项目(bin/vh gate 在后台起的就是 --only --idle 43200) -bin/vh desk wait <项目> [--timeout 秒] # 等人提交:收到提交才打印反馈、退出码 0;超时退出码 3(默认 7100 s);等的 agent 没了退出码 4 +bin/vh desk wait <项目> [--timeout 秒] # 等人提交:收到提交才打印反馈、退出码 0;超时退出码 3(默认 43200 s,12 小时);等的 agent 没了退出码 4;这一轮的页已经换成了别的页、没人交过退出码 7;一开始先交出所有还没人取的意见,哪一轮的都算 bin/vh desk feedback <项目> [--round 1b] [--json] # 打印最近一次提交,并记为"已交给 agent" bin/vh desk data <项目> # 审阅台从项目里读出了什么(JSON),排查"为什么这一页是空的"时用 bin/vh desk link [<项目>] [--root 目录 …] [--force] [--print-address] # 重起它:停掉在跑的那一个,照原样再起,叫出新的窗口;之前的页面只能看(各有一个把窗口叫出来的按钮) @@ -126,10 +126,10 @@ bin/vh desk agents install # 装那一家的 ACP 适配器 | `GET /static/<文件>` | `ui.css`、`ui.js`(关卡视图的,静态页内嵌的是同两份)、`studio.css`、`studio.js`(控制台的外壳和成片模块)、`modules.css`、`modules.js`(其余模块)、`core.js`(控制台和静态页共用的文字和小函数) | | `GET /api/projects` | `{version, home, roots, count, waiting, projects}`:`bin/vh projects` 的每一行,等人的在前,其余按最后一次动静从新到旧,交付了的在最后;加 `key`(地址里的项目键,见下面)、`picture`(`{path, kind: image \| video, from, href}`:封面,`bin/vh thumbs` 的镜头图,片子本身,联系表,关卡页里的图,分镜关键帧,最新的一张图,只取在的文件)、`ask`(等人时:`{gate, title, title_en, question, questions, summary, decisions}`:`questions` 是这一页的问题,最多四个,`summary` 是这一页的那一句);`title` 在 BRIEF 没写片名时取最新一页关卡页的标题里关卡名之前的那一段 | | `GET /samples/.jpg`、`.mp4` | 空间的样片墙(`server.py` 的 `SAMPLES`,四支,`short`、`math`、`handdrawn`、`launch`):官网那张封面图;片子本身,在 `tools/media.txt` 写的位置、这份克隆里真有时(没有、或是链到克隆外面的,都 404;`GET /api/projects` 的 `samples` 用同一个判断列出给得出的那几支)。只给这几个文件,克隆里别的一概不给 | -| `GET /api/p/<键>/data` | `bin/vh desk data` 的内容,加 `status`(`bin/vh status --json`)、`key`、`home`、`pid`(这个项目文件夹的身份:真实路径的 SHA-1,提交要带上)、`only`、`current`(这一轮的页名)、`round_open`(这一轮那一站还没定:不是 done、skipped;这时提交带上它还没交过、或交过以后改了的决定),和 `studio`(`film` 是成片模块播的那一支,只取在的文件;这一站没点名片子、`bin/vh status` 的那支又没有声音、BRIEF 也没说要无声片时,换成有声音、而且不比它旧的一支(分镜的 animatic、关卡页的 film 或 animatic,新的页在前;`bin/vh status` 本身不变);换了时 `film_instead` 是没放的那支,缩略图、波形和检查的问题都是那支的,不给(读数写明放的是哪个文件,不写第几版);`film_sound` 是它有没有声音(true、false,ffprobe 看不了是 null;一个文件只看一次,大小和时间不变就记着);要的那支不在时,`film_missing` 是它的路径;`sheet` 是最新的联系表;成片模块用的:`timeline` 是 `bin/vh timeline --resolved` 的内容;`thumbs`、`peaks` 是 `bin/vh thumbs`、`peaks` 做过才有的记录;`check` 和 `findings` 是最近一次检查的结论和带时间的问题,没过和要注意的;读不出来的那一样是 `null`,原因记在 `warnings`),和 `mods`(其余模块读的,都是已有命令写下的文件:`loudness` `{integrated, true_peak, lra, target, severity}` 和 `silences`、`checks`(最近一次检查的每条 finding:`kind, severity, message, t, t1`);`pace`(旁白时间轴里 `bin/vh pace` 写的 `reference, unit, speech, with_pauses` 和逐句的 `lines`)、`voice`(旁白用的音色)、`audition`(最新的 `audition.json`:`{file, provider, unit, text, voices: [{voice, file, duration, pitch_hz, speech_rate, misread, error}]}`)、`lifts`(最新的 `*.beats.json` 的候选落点);`covers` `[{path, ratio, id, text}]`、`subs`(字幕文件);`assets`(台账里没删的每一件:`{id, kind, path, there, system, license, license_name, source, url, aigc, used_by, note}`;`system` 是系统自带的字体(`/System/Library/…`、`/Library/Fonts/`、Windows 的 Fonts 这些),算在,不算在项目外;没有台账是 `null`)、`refs`(`research/refs.json`)、`digests` `[{id, path, bytes}]`;没有台账时 `assets_notes` `{file, rows: [{file, source, license, there}]}` 是 NOTES.md 里旧的素材台账表(`there` 对链接是 `null`);每一部分各读各的:读不出的那部分是空的,`errors` 写着它的文件和原因,别的照样有;只读项目里面的文件,指到项目外的链接不跟,和 `/f/` 一样) | +| `GET /api/p/<键>/data` | `bin/vh desk data` 的内容,加 `status`(`bin/vh status --json`)、`key`、`home`、`pid`(这个项目文件夹的身份:真实路径的 SHA-1,提交要带上)、`only`、`current`(这一轮的页名)、`round_open`(这一轮那一站还没定:不是 done、skipped;这时提交带上它还没交过、或交过以后改了的决定),`feedback` 里每份提交的 `state`(`unread` 还没人取、`taken` 取走了、`answered` 答过了;读不出时是 `null`,页面就不说)、`taken`(`t`、`program`、`by`)和 `late`(补交的),`notes_stamp`,和 `studio`(`film` 是成片模块播的那一支,只取在的文件;这一站没点名片子、`bin/vh status` 的那支又没有声音、BRIEF 也没说要无声片时,换成有声音、而且不比它旧的一支(分镜的 animatic、关卡页的 film 或 animatic,新的页在前;`bin/vh status` 本身不变);换了时 `film_instead` 是没放的那支,缩略图、波形和检查的问题都是那支的,不给(读数写明放的是哪个文件,不写第几版);`film_sound` 是它有没有声音(true、false,ffprobe 看不了是 null;一个文件只看一次,大小和时间不变就记着);要的那支不在时,`film_missing` 是它的路径;`sheet` 是最新的联系表;成片模块用的:`timeline` 是 `bin/vh timeline --resolved` 的内容;`thumbs`、`peaks` 是 `bin/vh thumbs`、`peaks` 做过才有的记录;`check` 和 `findings` 是最近一次检查的结论和带时间的问题,没过和要注意的;读不出来的那一样是 `null`,原因记在 `warnings`),和 `mods`(其余模块读的,都是已有命令写下的文件:`loudness` `{integrated, true_peak, lra, target, severity}` 和 `silences`、`checks`(最近一次检查的每条 finding:`kind, severity, message, t, t1`);`pace`(旁白时间轴里 `bin/vh pace` 写的 `reference, unit, speech, with_pauses` 和逐句的 `lines`)、`voice`(旁白用的音色)、`audition`(最新的 `audition.json`:`{file, provider, unit, text, voices: [{voice, file, duration, pitch_hz, speech_rate, misread, error}]}`)、`lifts`(最新的 `*.beats.json` 的候选落点);`covers` `[{path, ratio, id, text}]`、`subs`(字幕文件);`assets`(台账里没删的每一件:`{id, kind, path, there, system, license, license_name, source, url, aigc, used_by, note}`;`system` 是系统自带的字体(`/System/Library/…`、`/Library/Fonts/`、Windows 的 Fonts 这些),算在,不算在项目外;没有台账是 `null`)、`refs`(`research/refs.json`)、`digests` `[{id, path, bytes}]`;没有台账时 `assets_notes` `{file, rows: [{file, source, license, there}]}` 是 NOTES.md 里旧的素材台账表(`there` 对链接是 `null`);每一部分各读各的:读不出的那部分是空的,`errors` 写着它的文件和原因,别的照样有;只读项目里面的文件,指到项目外的链接不跟,和 `/f/` 一样) | | `GET /api/p/<键>/gate/<页>[?lang=zh\|en]` | 那一页的关卡视图:`{version, gate, current, this_round, title, lang, takeall, html, errors, warnings, decisions: [{id, question, recommend, options}], summary, cards, marks, not_reviewed}`;`html` 和静态页同一份标记,文件地址换成 `/f/<键>/…`;`cards` 是所有决定的选项卡(右栏用,同一份标记),`marks` 是没把握和请你听的地方 `[{kind: least \| listen, t, t1, id, note, target}]` | | `GET /api/p/<键>/stage` | 不等人时的画面:`{kind: "video", path, html}`(同一个播放器和标尺),或 `{kind: "image", path, href}`,或 `{kind: null}` | -| `GET /api/p/<键>/status` | 有没有 agent 在等这个项目的反馈,这一轮的页名 `round`,和这支片子现在到哪了:`now`、`plan`(`bin/vh status --json` 的同名字段,按列表的读法算:不读素材台账、cast 和调研)。页面每 4 秒问一次,`now` 变了就换右栏顶上那一句 | +| `GET /api/p/<键>/status` | 有没有 agent 在等这个项目的反馈(`round` 之外,`live`:等着的那个 `wait` 等的正是现在这一轮,一交就取走;`notes_stamp`:交了或取走了一份就变,页面据此重读每份意见的状态),这一轮的页名 `round`,和这支片子现在到哪了:`now`、`plan`(`bin/vh status --json` 的同名字段,按列表的读法算:不读素材台账、cast 和调研)。页面每 4 秒问一次,`now` 变了就换右栏顶上那一句 | | `POST /api/p/<键>/feedback` | 一次提交(格式见下面"写什么"),另带 `pid`:和这个地址现在指的文件夹对不上(或没带)就 409,不写进任何项目 | | `GET /f/<键>/<路径>` | 这个项目里的一个文件(支持 Range) | | `GET /v/<键>/<路径>` | 同一个文件放在一页里:顶上一条细栏写着文件名和它在项目里的位置;文本和 markdown 当文本显示(markdown 经 `reader.render_md`,一律先转义),图片、视频和音频的播放器、网页放在框里(仍受 `/f/` 的沙箱头管着),显示不了的种类说一句并说文件在哪。Studio 自己的应用把控制台里"在新页打开"的链接都开在这里,所以开出来的窗口不会是空的 | @@ -255,7 +255,7 @@ bin/vh desk agents install # 装那一家的 ACP 适配器 2. `REVIEW.md`:插一节 `## 审阅台反馈 · 关卡 <轮> · <日期 时间>`,把上面的文字整段原样放进代码块,下面留一行"定了: 改了:"给 agent 填;插在模板的"授权跳过怎么记"之前,没有这一节就接在文末; 3. `out/review/feedback/<轮>-.json`:最后写,原子替换。`bin/vh desk wait` 等的就是它。同一秒里的第二份、第三份加 `-2`、`-3`,按数字排。 -交给 agent 的提交记在 `out/review/feedback/.consumed`:`bin/vh desk wait` 打印过的、`bin/vh desk feedback` 打印过的,都算交过了。`wait` 一启动,先看这一轮有没有还没交过、又晚于这一页 gate JSON 的提交(比如上一次 `wait` 超时之后人才提交),有就立刻打印、退出 0;没有才开始等新的。`.listening`(有 agent 在等)和 `.desk.json`(服务在跑)里都记着项目目录的完整路径,从别的项目拷来的这两个文件不算数。`.listening` 只在三样都真的时候算有人在等:写它的 `wait` 进程还活着;这个 pid 没被后来的进程占去(进程开始的时间不晚于旗子的 `since`,`ps` 的 `lstart`,到秒);它等的那个 agent 还在(`wait` 启动时往上找最近的一个 agent 程序(claude、codex……,名字整个对上;或者跑着它们的 node),记成 `agent: {pid, start}`,`start` 是它开始的时刻(epoch 秒,用 `ps` 的 `etime` 算,不带时区);找不到就不记;读不出开始时间就不当成同一个进程)。那个 agent 没了,或者 `wait` 自己的父进程没了(被别的进程收养:起它的不管是什么程序,已经结束),`wait` 自己结束(退出 4,旗子拿走),不把意见交给没人读的地方。 +一份提交只在三种状态里的一种:**还没人取**(存好了,没交给任何 agent)、**取走了**(记在 `out/review/feedback/.consumed`:`files` 是名字,`taken` 记着每一份是什么时候、被哪一次运行(`bin/vh` 的活动记录里的 run)、在哪个 agent 程序下(claude、codex……)、怎么取走的(`wait` 或 `feedback`))、**答过了**(它在 REVIEW.md 里的那一节写了定了)。`bin/vh desk wait` 打印过的、`bin/vh desk feedback` 打印过的,都算取走了;认领在 `.consumed.lock` 的文件锁里做,两个 `wait` 同时看到同一份,只有一个拿到。一轮已经被取走以后人又交的,是这一轮的**补交**:照样是一份自己的提交,单独说,不并进别的哪一轮。`wait` 等的是一轮(`bin/vh gate --wait` 的那一页,否则是这一轮的页):一启动,先把所有还没人取、也还没答过的提交都交出来,不管是哪一轮的(补交的会写明,比如上一次 `wait` 超时以后人才交的,或者已经往后走了的那一轮的补交),有就立刻打印、退出 0;没有才开始等新的;等的时候这一轮的页换成了别的页,就说"这一轮没人交"、退出 7,agent 跑 `bin/vh status`、在现在开着的那一轮上再等。超时、agent 没了、被停下,都不碰没人取的意见:下一个 `wait` 和 `bin/vh status` 都看得到。`.listening`(有 agent 在等)和 `.desk.json`(服务在跑)里都记着项目目录的完整路径,从别的项目拷来的这两个文件不算数。`.listening` 只在三样都真的时候算有人在等:写它的 `wait` 进程还活着;这个 pid 没被后来的进程占去(进程开始的时间不晚于旗子的 `since`,`ps` 的 `lstart`,到秒);它等的那个 agent 还在(`wait` 启动时往上找最近的一个 agent 程序(claude、codex……,名字整个对上;或者跑着它们的 node),记成 `agent: {pid, start}`,`start` 是它开始的时刻(epoch 秒,用 `ps` 的 `etime` 算,不带时区);找不到就不记;读不出开始时间就不当成同一个进程)。那个 agent 没了,或者 `wait` 自己的父进程没了(被别的进程收养:起它的不管是什么程序,已经结束),`wait` 自己结束(退出 4,旗子拿走),不把意见交给没人读的地方。 JSON 的格式: @@ -388,11 +388,12 @@ JSON 的格式: - `next_step`:下一步,按项目停在哪一站算出来:`who`(`person`、`agent`、`nobody`、`unknown`)、`do`(一句话,还没填的 `{…}` 和 gate 骨架里的占位有几处都说出来;Director 写了 `x=own`、还没有记录的事排在最前面,记录是它那一站过了,或者 DECISIONS.md 里它那一行写了已定)、`commands`(能直接跑的命令,`` 这类尖括号是要换的)、`read`(该读的:`<文件>#<节>` 由 `bin/vh know --show` 打印,没有 `#` 的整篇读)、`unfilled`(`BRIEF.md`、`STYLE.md`、`STORYBOARD.md` 各还有几处 `{…}`,不算代码块和行内代码里的,也不算模板的 `{none}` 和 `{fill: #e33}` 这种带值的花括号;交付以后 `who` 是 `nobody`,这里是空的,没有要填的了)。 - `now`:这支片子现在怎么样,说给人听的(`tools/standing.py`,Studio 说的也是这些字;字都在它开头的 `WORDS` 表里,中英文挨着)。只说磁盘能证明的:最后记下的事和它在什么时候(命令的开始和结束、交出的意见、Studio 对话的事件、片子自己文件的改动)、现在有没有进程在跑、等着的进程和它等的 agent 活不活着、Studio 的一轮怎么结束的、一条命令是在哪个 agent 程序下跑的(那个 agent 还活着,就是有 agent 开着这支片子)。磁盘不知道 agent 是不是正在两条命令之间想事情,所以安静的片子只说"上一次动静:12 分钟前,渲染做完了",从不说没人在做;"停下了"要有正面的证据;"让 agent 接着做"是一个可以点的选项,不是"没人在做"的断言。字段:`code`、`who`(下一步该谁动,和 `waiting_on` 一致)、`you`(人跟它有什么事:`decide` 在等人定,`nudge` 要人说一声,`offer` 人可以点,`none`)、`tone`(点的颜色:`you` 琥珀、`busy` 紫、`quiet` 灰)、`say`(`{zh, en}` 一句短话,两秒读完)、`more`(`{zh, en}` 或 `null`:下面那一行)、`short`(`{zh, en}` 卡片上的几个字,不带路径,也不带不在词表里的命令名)、`act`(至多一件事:`{kind: "open", mod, sub, label}` 去 Studio 的哪个模块;`{kind: "settings", sub, label}` 去设置页的哪一节(片子等一家服务的 API Key 时:`code` 是 `needs_key`,`facts.keys` 是还没设的 key 名,`facts.service` 是哪一家,`facts.need` 是 key 拿来做什么:`voice`、`timing`、`music`、`image`;下面那一行按它和这台电脑有什么来说不用 key 的办法,没有就直说没有。从整份记录里找(`activity.key_stop`),不看最近几条:有一个 key 设上了、后来同类的活做成了(配音成了,配音和对时间的停都算过去)、或者后来有别的命令失败了,就不再这么说。只在终端的环境变量里设了 key、Studio 又是从别处打开的,Studio 看不到这个变量,会一直说在等,直到那条命令在那个终端里再跑一次);`{kind: "tell", label, text, confirm, secondary}` 对 agent 说的那句话,`confirm` 是先问一次(最近 30 分钟里还有动静,或者有 agent 开着),`secondary` 是它不是主要该做的事、写成第二行的小字;`{kind: "none"}`)、`facts`(`paths`:这些话里点到的项目文件,Studio 里点得开;还有 `stop`、`listening`、`pending`、`cmd`、`film`、`subtitles`、`version`、`keys`、`service` 这些)。 - `code` 按这个先后取第一个对上的:`paused`(REVIEW.md 写了暂停);`revision_ready`(有一条复审等人看);`waiting_you`(一站的页发出去了等人:`facts.listening` 按上面 `.listening` 的三样算,真就"你交了,agent 就接着做",不然"交了以后,要跟 agent 说一声";声音那一站是"等你听");最新的一份意见还没人取时,不管别的在不在跑都先说它:等着的人活着是 `notes_sent`,不然 `notes_unheard`(有命令在跑时写"渲染还在跑,但你 21:30 交的这一份没人取");`notes_taken`(意见交到 agent 手里了,而且这会儿真有东西在为这支片子做:`bin/vh` 命令在跑,或 Studio 的一个对话拿着锁;没东西在跑时不说"正在改");`running`(`bin/vh` 命令在跑,带进度;pid 被后来的进程占去的不算在跑);`working`(Studio 的一个对话拿着锁,锁的 pid 也照这样核对);`delivered`(最新的一份交付记录:哪支成片、旁边的字幕、`versions` 里正好是它的那一版);`no_record`;然后是轮到 agent、现在没东西在跑的几种。先把所有动静排一遍(结束了的命令:做完了、结束时报了问题、被停下了、中断了;发出的审阅页;开始等你的意见;它取走了你的意见;Studio 对话的最后一件事;片子自己的文件里最新改的那个:先看片子的文件夹,再一层层往下(广度优先,四层),不看 `out/`、`media/`、`renders/` 和 Studio 自己写的 `REVIEW.md`;`assets/`、`audio/`、帧序列这种重的文件夹(按名字,或者一个文件夹里超过 300 项)只看文件夹自己的时间,不一个个看;看到 4000 项还没看完就停,这时说的是"看到的最近一次动静","之后没有别的动静"这种话不说),取最新的那一件:它是一条没有结束记录、进程也没了的命令,或者 Studio 的一轮被停下、出错、做到一半断了,而且没有 agent 开着,才是 `stopped`("agent 停下了:渲染中断了。",下面一行是什么时候、到第几帧、之后没有别的动静、下一站);做这支片子的 agent 还开着,是 `agent_open`("现在没有命令在跑;上次做这支片子的 agent 还开着。","让 agent 接着做"降成第二行、点之前先问一次):只在这个 agent 程序最近一次做的就是这支片子,或者这支片子最新的动静在 6 小时以内时这么说;一个开了很久、做过许多支片子的程序(比如 Studio 那一列背后的那个)不让它做过的每支片子都显得"开着",那些片子照常说它们自己的情况,再加一句"做过它的 agent 程序还开着,可能在忙别的片子。";各站都过了还没交付是 `ship_missing`;下一步是装引擎是 `setup`;其余是 `idle`("现在没有命令在跑。",下面一行"上一次动静:……")。一条命令出错结束(`check` 没过、`gate` 拒绝)是它的结果,不是停下了:写成"上一次动静:3 分钟前,检查查出 2 处要改",下一步还是 agent 的。 + `code` 按这个先后取第一个对上的:`paused`(REVIEW.md 写了暂停);`revision_ready`(有一条复审等人看);`waiting_you`(一站的页发出去了等人:`facts.listening` 按上面 `.listening` 的三样算,真就"你交了,agent 就接着做",不然"交了以后,要跟 agent 说一声";声音那一站是"等你听");有意见还没人取、又不只是这一站刚交的那一份时(补交的,或别的轮的),排在等人的页之前先说它们:`notes_late`("你在旁白稿那一轮被取走以后又交了 3 条,还没有 AI 来取。")或 `notes_left`,下面一行说谁会来取:一个活着的 `wait` 正等着现在这一轮,"正在等的 Claude Code 马上会取";做这支片子的 agent 在 Studio 窗口外面,"回到它那边说一声“我交了”";都没有,"现在没有 AI 在等。下次有 AI 接着做这支片子,会先拿到它们。";同时有页在等人,再加一句"大纲也出来了,等你看"。这一站刚交的那一份还没人取时,不管别的在不在跑都先说它:一个活着的 `wait` 正等着现在这一轮(`.listening` 里记着它等的 `round`)是 `notes_sent`,不然 `notes_unheard`(有命令在跑时写"渲染还在跑,但你 21:30 交的这一份没人取";做这支片子的 agent 在窗口外面时,说回到它那边说一声,不给另起一个的按钮);`notes_taken`(意见交到 agent 手里了,而且这会儿真有东西在为这支片子做:`bin/vh` 命令在跑,或 Studio 的一个对话拿着锁;没东西在跑时不说"正在改");`running`(`bin/vh` 命令在跑,带进度;pid 被后来的进程占去的不算在跑);`working`(Studio 的一个对话拿着锁,锁的 pid 也照这样核对);`delivered`(最新的一份交付记录:哪支成片、旁边的字幕、`versions` 里正好是它的那一版);`no_record`;然后是轮到 agent、现在没东西在跑的几种。先把所有动静排一遍(结束了的命令:做完了、结束时报了问题、被停下了、中断了;发出的审阅页;开始等你的意见;它取走了你的意见;Studio 对话的最后一件事;片子自己的文件里最新改的那个:先看片子的文件夹,再一层层往下(广度优先,四层),不看 `out/`、`media/`、`renders/` 和 Studio 自己写的 `REVIEW.md`;`assets/`、`audio/`、帧序列这种重的文件夹(按名字,或者一个文件夹里超过 300 项)只看文件夹自己的时间,不一个个看;看到 4000 项还没看完就停,这时说的是"看到的最近一次动静","之后没有别的动静"这种话不说),取最新的那一件:它是一条没有结束记录、进程也没了的命令,或者 Studio 的一轮被停下、出错、做到一半断了,而且没有 agent 开着,才是 `stopped`("agent 停下了:渲染中断了。",下面一行是什么时候、到第几帧、之后没有别的动静、下一站);做这支片子的 agent 还开着:它不是 Studio 自己那一列起的(往上找它的父进程,没有 `tools/desk/desk.py`),是 `agent_outside`("这支片子正由这个窗口外面的 Claude Code 在做;在这里打的字,它收不到。",下一行"要它接着做,回到它那边说一句。","在这里另起一个 AI 做这支片子"降成第二行,点之前先问一次,问的话就是"外面那个 Claude Code 还开着。两个一起做,可能改到同一处。"(`act.sure`、`act.sure_note`);`facts.program` 是它的程序名);是 Studio 自己那一列起的,是 `agent_open`("现在没有命令在跑;上次做这支片子的 agent 还开着。","让 agent 接着做"降成第二行、点之前先问一次):只在这个 agent 程序最近一次做的就是这支片子,或者这支片子最新的动静在 6 小时以内时这么说;一个开了很久、做过许多支片子的程序(比如 Studio 那一列背后的那个)不让它做过的每支片子都显得"开着",那些片子照常说它们自己的情况,再加一句"做过它的 agent 程序还开着,可能在忙别的片子。";各站都过了还没交付是 `ship_missing`;下一步是装引擎是 `setup`;其余是 `idle`("现在没有命令在跑。",下面一行"上一次动静:……")。一条命令出错结束(`check` 没过、`gate` 拒绝)是它的结果,不是停下了:写成"上一次动静:3 分钟前,检查查出 2 处要改",下一步还是 agent 的。 终端里 `bin/vh status` 在 `next:`、`run:`、`read:` 那几行后面打印 `now: <英文那一句>`,有 `more` 时下一行缩进两格,要人在 Studio 里做的再一行("the person does this in Studio: …"):不写要对 agent 说的话,也不印 `bin/vh studio` 这种命令,读它的常常是 agent 自己。`idle`、`setup`、`agent_open`、`no_record` 时不打印,`next:` 那一行已经说了,这一屏要短。原来的各行(`stops:` 在第二行、`next:`、`read:`)字和先后都不变:agent 每一站都读它们。 - `plan`:这支片子的打算,一句(`{zh, en}`,比如"30 秒竖屏,有旁白,先看方向和初版"):BRIEF 的 Output 一行的时长(`exactly 30s`、`2 min 30 s`、`1:30`、`60–90s`,`tools/gatecheck.py` 的读法;还是模板的 `{…}` 不算)和画幅、Language 一行的 narration(这一格就是否定、或者以否定开头的(none (music only)、无旁白、不要)才是没有旁白,"TTS voice, no music""Charon,不要背景音乐"里的否定说的是别的,照样是有旁白;以 song / 歌开头是配一首歌;待定、TBD、? 这种说不清的不写;其余是说了一个声音,就是有旁白),和这支片子自己的停(`stops` 的 gates 和 checkpoints,不看档位:①③ 是"先看方向和初版",①②③ 是"立意、分镜、初版都给你看",带检查点时一个个列出来,比如"停在立意、锁时、初版",什么都不停是"中间不停,做完给你看")。只在 `--json` 和 Studio 里:终端那一屏的 `stops:` 已经说了在哪几处停。 -- `review`:`current`(这一轮的页名)、`page`、`desk`(在跑时:`url`、`listening`)。 +- `review`:`current`(这一轮的页名)、`page`、`desk`(在跑时:`url`、`listening`)、`unread`(人交了、还没有 agent 取走也还没答过的提交,哪一轮的都算,从旧到新:`round`、`file`、`late`(这一轮被取走以后补交的)、`items`、`decisions`;有就排在下一步的最前面,文字版另起一行 `unread:`)、`taken`(每份取走的提交:`t`、`program`、`by`)。 +- `holder`:开着这支片子的 agent 程序(`program`:claude、codex……),和它是不是在 Studio 窗口外面(`outside`);没有就是 `null`。Studio 说"谁会来取你的意见"时叫它的名字。 - `open`:`review_items`(审阅台提交里标了要改、疑问,而 REVIEW.md 那一节还没写定了 / 改了的条目:`round`、`file`、`target`、`status`、`label`、`text`)、`facts_to_verify`(NOTES.md 待核实里没打勾的)。 - `renders`:`out/`(不含 `out/versions/` 和 `out/proxy/`)、`renders/`、`media/` 往下三层的视频(不含 Manim 的 `partial_movie_files/`),新的在前,最多 10 个:`path`、`size`、`mtime`、`render`(`.render.json` 的帧数、帧率、像素、时间段)、`patches`、`delivery`(它是 `bin/vh deliver` 出的上传版时)、`check`(它最近的检查记录)、`version`(它是哪一版的当前文件,见下面"版本")。`deliveries`:`bin/vh deliver` 的记录。 - `versions`:版本记录(下面"版本")的摘要,还没有记录时是 `null`:`record`、`keep`、`current`、`kept_bytes`、`list`(每版 `id`、`at`、`t`、`film`、`file`、`state`、`made_by`、`from`、`note`、`changed`、`frames`、`pixels`、`check`);记录读不了时是 `{"error"}`。 @@ -505,7 +506,7 @@ Studio 的「成片 → 复审」显示原意见、时间范围和答复状态 - 开着的项目页每 4 秒问一次这一轮是哪一页,agent 发了新的一页就自己换过去;断网或休眠醒来的那几秒里提交的,记在旧的那一轮(那一页的 gate JSON 还在,服务照收)。 - 控制台(和人自己开的 `bin/vh desk <项目>`)把 roots 下的项目都摆出来,也给它们的文件:只绑 127.0.0.1、只认自己的 Host、提交要令牌,但别把 `--root` 指到不想让本机浏览器看到的地方;只想给一个项目,加 `--only`。 -- 几个 `bin/vh desk` 进程同时动手(比如两个 `bin/vh desk wait` 一起启动,或者一边 `wait` 一边 `desk feedback`),最坏是同一份反馈交出去两次:它们各自先看到这份反馈还没交过,各打印一遍。不会崩,也不会丢反馈:每次写文件都用自己的临时文件再原子替换,`.consumed` 的读改写在 `.consumed.lock` 上加了文件锁(flock),谁都不会把别人记下的名字冲掉。 +- 几个 `bin/vh desk` 进程同时动手(比如两个 `bin/vh desk wait` 一起启动,或者一边 `wait` 一边 `desk feedback`):`wait` 先在 `.consumed.lock` 的文件锁里认领、再打印,同一份只有一个 `wait` 交出去;`desk feedback` 照旧打印最新的一份,和一个 `wait` 撞上时,最坏是这一份被打印两次。不会崩,也不会丢反馈:每次写文件都用自己的临时文件再原子替换,`.consumed` 的读改写加了文件锁(flock),谁都不会把别人记下的名字冲掉。 ## 测试 @@ -513,6 +514,8 @@ agent 那一列另有一组(`agent_checks`,`tools/desk/test_agents.py`): `tools/ci.sh` 用 `tools/desk/fixtures/` 里的小项目测:`zh`、`en` 两个测读取;`demo` 是一支编的片子(海水为什么一天涨两次),关卡 ①②③ 都有,画面是几张小 SVG,它还带着旁白的时间、节拍表和一份检查记录,成片模块的每条轨道都有东西。`console_checks` 用它测关卡视图(静态页整个内嵌 `ui.css` 和 `ui.js`、不从外面加载东西、推荐的卡预先选上、立意卡带帧、分镜就是画面、没把握的时间,关卡 ①② 的页带着这一站的模块)、七个模块按它的数据画出来(node 里跑 `core.js` 和 `modules.js`,控制台的和静态页只读的都画)、三套主题(同一组变量,每种字色对底色 4.5:1 以上,样式里没有变量以外的颜色)、字数提醒和控制台(外壳、多个项目、键、等人的排前面和它的问题与画面、项目数据和成片模块的数据、关卡视图和右栏的卡与记号、文件、各种拒绝、一次提交);PR 的截图也只用它。读取的测试(包括读不出表格时退回原文、"这一轮"取 `.current`(2 之后的 1b、3 之后的 E3b、自起的页名,`.current` 指向已删的页时退回流程顺序)、语言规则、超长和深层嵌套的 markdown),在空闲端口起一个服务测 `/api/data`、206 Range、`/p/` 的 sandbox、各种拒绝和坏请求、提交到临时副本、REVIEW.md 的追加,测 `wait` 在有提交时退出 0、启动前就到的提交立刻交出、交过的不再交,拷来的 `.desk.json` 和 `.listening` 不算数,以及 `bin/vh desk -h`。 +页面本身另有一组,在 `desk_checks` 里(`tools/desk/test_page.py`):在一个无头 Chrome 里打开它自己起的控制台(`tools/desk/page_driver.mjs`,用仓库自己的 `tools/textcheck/browser.mjs` 起浏览器),在 `demo` 的几份副本上看人看到的:一轮被取走以后补交的意见怎么说、交之前和交之后各说什么,选了"先改"却没写意见时会不会问,1440×900 下决定卡片很多时刚记下的意见在不在屏幕上。没有 Chrome 时本机跳过,CI 上算失败。 + ## 整套截图(开发用) 改了控制台以后,用截图验收:在几个项目上按原尺寸截全套图,请人或只看图的评审一页一页看。`tools/desk/shoot.py` 截这一套。它不是 `bin/vh` 的命令,`tools/ci.sh` 也不跑它。 diff --git a/tools/desk/desk.py b/tools/desk/desk.py index 6461bd5a..9889aead 100644 --- a/tools/desk/desk.py +++ b/tools/desk/desk.py @@ -17,9 +17,13 @@ project and nothing else under the roots (bin/vh gate starts the desk of a stop so, with --idle 43200: 12 h) bin/vh desk wait [--timeout s] block until the reviewer submits, print the feedback, exit 0 (3 on - timeout; default 7100 s). An agent runs it in the background after each - stop: its exit is the wake-up call. A submission for the current page that - came in before it was armed, and was never handed over, is printed at once. + timeout, default 43200 s: 12 h; 4 the agent it waits for is gone; 7 this + round's page is no longer the one out: nothing came for it, run bin/vh + status and wait on the round open now). It waits for this round's page. + An agent runs it in the background after each stop: its exit is the + wake-up call. Every submission no agent has taken yet, of any round (a + later batch on a round already taken says so), is printed at once; a + wait that ends any other way leaves every note for the next wait. bin/vh desk feedback [--round r] [--json] print the latest submission (exit 1 when there is none); it then counts as handed over (out/review/feedback/.consumed) bin/vh desk revision --before VIDEO --after VIDEO [--item N] [--span START-END] [--json] @@ -91,7 +95,7 @@ def main(argv): ap.add_argument("--no-open", action="store_true", help="started in a terminal it shows Studio's window; this leaves it to " "bin/vh studio (started otherwise it never shows one)") elif sub == "wait": - ap.add_argument("--timeout", type=float, default=7100, help="seconds to wait (default 7100)") + ap.add_argument("--timeout", type=float, default=43200, help="seconds to wait (default 43200: 12 h)") elif sub == "feedback": ap.add_argument("--round", help="only this gate page (1, 2b, E3 …)") ap.add_argument("--json", action="store_true", help="print the JSON record instead of the text") diff --git a/tools/desk/feedback.py b/tools/desk/feedback.py index 02f52682..168a77ca 100644 --- a/tools/desk/feedback.py +++ b/tools/desk/feedback.py @@ -3,6 +3,11 @@ A submission is saved as out/review/feedback/-.json plus a .md copy an agent or a human reads; the same .md text goes into REVIEW.md verbatim, as a dated section (CLAUDE.md: the human's words are recorded word for word). The .json is written last, atomically: it is what the watcher (wait) waits for. + +A submission is in exactly one of three states, and Studio, bin/vh status and a waiting agent all read them from here: +saved and not handed to any agent yet (unread); handed over (feedback/.consumed: which file, when, by which run and agent +program); answered (its REVIEW.md section has a 定了). A submission saved after another one of the same round was handed +over is a later batch (late): it is handed over like any other, said apart, and never merged into another round. """ import datetime, fcntl, json, os, re, signal, sys, tempfile, threading, time from pathlib import Path @@ -19,6 +24,8 @@ RANGE = re.compile(r"range:([0-9]+(?:\.[0-9]+)?)-([0-9]+(?:\.[0-9]+)?)") # fullmatch: range:-, seconds of the film, a < b ROUND = re.compile(r"^[A-Za-z0-9_-]{1,24}$") NO_ROUND = "notes" # comments sent while no gate page is out +WAIT = 43200 # s: how long bin/vh desk wait and gate --wait wait by default (12 h, the gate desk's own idle stop) +MOVED_ON = 7 # wait's exit when this round's page is no longer the one out: nothing came for it REFERENCE = re.compile(r"^## (授权跳过怎么记|给人看的提示|How to record a waived gate|Notes for the reviewer)", re.M) WORDS = { "zh": dict(title="# 审阅反馈 · {round} · {at}", decision="决定 {id}:{v}", default="(按推荐,没改)", @@ -272,7 +279,19 @@ def listening(project): return {"listening": False} if not activity._alive(info["pid"], info.get("since")) or (info.get("agent") is not None and not activity.agent_alive(info.get("agent"))): return {"listening": False} - return {"listening": True, "since": info.get("since"), "until": info.get("until")} + return {"listening": True, "since": info.get("since"), "until": info.get("until"), "round": info.get("round")} + + +def notes_stamp(project): + """A stamp that changes when a submission is saved or handed over (the feedback folder's files and .consumed): a page + that shows the notes' states reads them again when it moves.""" + fdir = Path(project) / "out" / "review" / "feedback" + try: + names = sorted(p.name for p in fdir.glob("*.json")) + c = (fdir / ".consumed").stat().st_mtime_ns if (fdir / ".consumed").exists() else 0 + return f"{len(names)}:{names[-1] if names else ''}:{c}" + except OSError: + return "" def _order(f, j): @@ -298,29 +317,73 @@ def latest(project, rid=None): return best if best else (None, None) +def _consumed_record(project): + try: + d = json.loads((Path(project) / "out" / "review" / "feedback" / ".consumed").read_text()) + return d if isinstance(d, dict) else {} + except (OSError, ValueError): + return {} + + def consumed(project): """Names of the submissions an agent has already been handed (feedback/.consumed).""" + names = _consumed_record(project).get("files", []) + return {n for n in names if isinstance(n, str)} if isinstance(names, list) else set() + + +def taken(project): + """{name: {t, run, program, by}}: when each handed-over submission was taken, by which bin/vh run (its activity run id, + when it ran under bin/vh), the agent program it ran under (claude, codex …, when one was found) and how (wait | + feedback). Older .consumed files have the names only: those are taken with nothing more known.""" + d = _consumed_record(project) + info = d.get("taken") if isinstance(d.get("taken"), dict) else {} + return {n: (info.get(n) if isinstance(info.get(n), dict) else {}) for n in consumed(project)} + + +def _program(): + """The agent program this process runs under, by name (claude, codex …), or None.""" try: - names = json.loads((Path(project) / "out" / "review" / "feedback" / ".consumed").read_text()).get("files", []) - return {n for n in names if isinstance(n, str)} - except (OSError, ValueError, AttributeError): - return set() + a = activity.agent_of(os.getpid()) + if not a: + return None + name = os.path.basename(activity._ps(a["pid"], "comm=") or "") + if name in activity.RUNTIMES: + name = next((os.path.basename(w) for w in activity._ps(a["pid"], "command=").split() if activity.AGENT_PROGRAMS.match(os.path.basename(w))), name) + return name if activity.AGENT_PROGRAMS.match(name) else None + except Exception: + return None -def mark_consumed(project, paths): - """Add these submissions to feedback/.consumed. The read-modify-write holds an flock on feedback/.consumed.lock, - so two bin/vh desk processes doing it at once both get their names in.""" +def mark_consumed(project, paths, by="feedback"): + """Claim these submissions for this process: add the ones no one has taken yet to feedback/.consumed, with when, by which + run and agent program; → the names this call claimed (oldest first, as given). The read-modify-write holds an flock on + feedback/.consumed.lock, so two bin/vh desk processes doing it at once both get their names in, and a submission two + waits see at once goes to exactly one of them.""" fdir = Path(project) / "out" / "review" / "feedback" fdir.mkdir(parents=True, exist_ok=True) + who = {"t": round(time.time(), 3), "run": os.environ.get("OVH_ACTIVITY_RUN") or None, "program": _program(), "by": by} with _lock, open(fdir / ".consumed.lock", "a") as lk: fcntl.flock(lk.fileno(), fcntl.LOCK_EX) try: - names = consumed(project) | {Path(p).name for p in paths} - _write(fdir / ".consumed", json.dumps({"files": sorted(names)}, ensure_ascii=False) + "\n") + d = _consumed_record(project) + had = consumed(project) + info = {k: v for k, v in (d.get("taken") or {}).items() if k in had} if isinstance(d.get("taken"), dict) else {} + mine = [n for n in dict.fromkeys(Path(p).name for p in paths) if n not in had] + for n in mine: + info[n] = who + _write(fdir / ".consumed", json.dumps({"files": sorted(had | set(mine)), "taken": info}, ensure_ascii=False) + "\n") + return mine finally: fcntl.flock(lk.fileno(), fcntl.LOCK_UN) +def current_round(project): + """This round's page id (the one the desk shows as this round: reader.gate_pages' last readable page), or NO_ROUND.""" + import reader + pages = [p for p in reader.gate_pages(project) if gate_options(project, p.stem[5:]) is not None] + return pages[-1].stem[5:] if pages else NO_ROUND + + def pending(project): """Submissions for the current gate page, made after that page was written, that no agent has been handed yet (oldest first). The current page is the one the desk shows as this round (reader.gate_pages).""" @@ -332,7 +395,44 @@ def pending(project): return sorted(out, key=lambda x: _order(*x)) -def show(path, record, out=sys.stdout): +def answered(project): + """Names of the submissions whose REVIEW.md section (the one save() wrote, naming the .json) has a 定了: an agent read it + and wrote what was decided, however it read it.""" + try: + import gatecheck as G + text = G.read(Path(project) / "REVIEW.md") + except (OSError, ImportError): + return set() + out = set() + for _title, lines in G.sections(text)[1:]: + names = re.findall(r"out/review/feedback/([^`\s)]+\.json)", "\n".join(x for x, c in lines if not c)) + if names and G.record(lines)[0]: + out.update(names) + return out + + +def unread(project): + """Every submission no agent has been handed and no agent has answered, of any round, oldest first: [(path, record, + late)]. late: a submission of the same round was handed over before it (the person wrote more after the round was + taken). These are what the next wait hands over first, and what bin/vh status puts before any other work.""" + done, ans = consumed(project), answered(project) + recs = sorted(_records(project), key=lambda x: _order(*x)) + out = [] + for i, (f, j) in enumerate(recs): + if f.name in done or f.name in ans: + continue + late = any(g.name in done and k.get("round") == j.get("round") for g, k in recs[:i]) + out.append((f, j, late)) + return out + + +LATE = ("(a later batch: the person wrote these after round {r} had been handed over; they are notes on round {r}, " + "not on any other page)\n") + + +def show(path, record, out=sys.stdout, late=False): + if late: + out.write(LATE.format(r=record.get("round", "?"))) md = path.with_suffix(".md") try: text = md.read_text(encoding="utf-8") @@ -360,17 +460,38 @@ def _handed(subs): [f for f, _ in subs]) -def wait(project, timeout, poll=1.0, out=sys.stdout, desk=None): - """Hand the agent the reviewer's submission: print it, mark it consumed, return 0; 3 on timeout. - A submission for the current page that arrived before the watcher was armed (say, while it was re-armed after a - timeout) and that no agent has been handed yet is printed at once. Otherwise it waits for a new one, keeping - feedback/.listening ({pid, since, until, project, agent}) so the desk can say an agent is waiting. agent: the agent - program it runs under (activity.agent_of), when there is one; once that agent is gone, or the wait's own parent is (it - was re-parented: whatever program started it ended), the wait ends (4): nobody would read what it hands over. desk: - (pid, since) of the review desk (or Studio) the person submits on (bin/vh gate --wait); once it closes nothing more can - come, and the wait ends (6), saying so.""" +def _hand(project, subs, rid, out): + """Claim and print these [(path, record, late)]; → how many this process got (another wait may have claimed some).""" + mine = set(mark_consumed(project, [f for f, _, _ in subs], by="wait")) + got = [(f, j, late) for f, j, late in subs if f.name in mine] + for f, j, late in got: + show(f, j, out, late=late) + if got: + out.write(HANDED) + if rid is not None and not any(j.get("round") == rid for _, j, _ in got): + out.write(f"Nothing has come for round {rid} yet: once these are dealt with, wait for it again (bin/vh desk wait {project}).\n") + out.flush() + _handed([(f, j) for f, j, _ in got]) + return len(got) + + +def wait(project, timeout, poll=1.0, out=sys.stdout, desk=None, round=None): + """Hand the agent the reviewer's submission: print it, mark it handed over (taken), return 0; 3 on timeout. + The wait is for one round: round (bin/vh gate --wait's page), else this round's page as the desk shows it. First it hands + over every submission nobody has taken or answered yet, of any round (unread: a later batch on a round that was already + taken says so); then it waits for a new submission, keeping feedback/.listening ({pid, since, until, project, agent, + round}) so the desk can say an agent is waiting for that round. A new submission of another round (a page the person's + window still showed) is handed over too, said for what it is: notes are never left behind. Each submission is claimed + under .consumed's lock, so two waits never both take one. When this round's page is no longer the one out (the agent sent + another page), the wait ends (7) and says nothing came for it. agent: the agent program it runs under + (activity.agent_of), when there is one; once that agent is gone, or the wait's own parent is (it was re-parented: whatever + program started it ended), the wait ends (4): nobody would read what it hands over. desk: (pid, since) of the review desk + (or Studio) the person submits on (bin/vh gate --wait); once it closes nothing more can come, and the wait ends (6), + saying so. Whatever ends a wait but a submission (3, 4, 6, 7, a signal) leaves every note unread, for the next wait and + bin/vh status.""" fdir = Path(project) / "out" / "review" / "feedback" flag = fdir / ".listening" + rid = round or current_round(project) def done(code): try: @@ -387,20 +508,15 @@ def stop(signum, _frame): for s in (signal.SIGTERM, signal.SIGINT, signal.SIGHUP): signal.signal(s, stop) fdir.mkdir(parents=True, exist_ok=True) - seen = {p.name for p in fdir.glob("*.json")} # first: a submission landing after this is either pending or new - early = pending(project) - if early: - for f, j in early: - show(f, j, out) - mark_consumed(project, [f for f, _ in early]) - out.write(HANDED) - out.flush() - _handed(early) + seen = {p.name for p in fdir.glob("*.json")} # first: a submission landing after this is either unread now or new + early = unread(project) + if early and _hand(project, early, rid, out): return 0 start = time.time() agent = activity.agent_of(os.getpid()) parent = os.getppid() # whatever program started it: a wait re-parented (its parent gone) has nobody to hand over to - _write(flag, json.dumps({"pid": os.getpid(), "since": start, "until": start + timeout, "project": os.path.realpath(str(project)), "agent": agent})) + _write(flag, json.dumps({"pid": os.getpid(), "since": start, "until": start + timeout, "project": os.path.realpath(str(project)), + "agent": agent, "round": rid})) looked = start while time.time() - start < timeout: gone = os.getppid() != parent @@ -415,16 +531,20 @@ def stop(signum, _frame): out.write("the agent this wait was for is gone; the wait ends (the notes stay in Studio)\n") out.flush() return done(4) - new = sorted(((f, j) for f, j in _records(project) if f.name not in seen), key=lambda x: _order(*x)) - if new: - for f, j in new: - show(f, j, out) - mark_consumed(project, [f for f, _ in new]) - out.write(HANDED) + now = current_round(project) + if now != rid: # another page went out: this round is over, nothing came for it, and the new page's notes are its own wait's + out.write(f"the page for round {rid} is no longer the one out (round {now} is): nothing was submitted for {rid}, " + "and this wait ends. Run bin/vh status, and wait on the round that is open now\n") out.flush() - _handed(new) - return done(0) + return done(MOVED_ON) + new = [(f, j) for f, j in _records(project) if f.name not in seen] + if new: + seen |= {f.name for f, _ in new} + ids = {f.name for f, _ in new} + fresh = [(f, j, late) for f, j, late in unread(project) if f.name in ids] + if fresh and _hand(project, fresh, rid, out): + return done(0) time.sleep(poll) - out.write(f"no feedback within {timeout:.0f} s; arm it again: bin/vh desk wait {project}\n") + out.write(f"no feedback within {timeout:.0f} s; the notes stay unread for the next wait or bin/vh status. Arm it again: bin/vh desk wait {project}\n") out.flush() return done(3) diff --git a/tools/desk/page_driver.mjs b/tools/desk/page_driver.mjs new file mode 100644 index 00000000..d9b2b894 --- /dev/null +++ b/tools/desk/page_driver.mjs @@ -0,0 +1,57 @@ +// page_driver: Studio's page in a headless Chrome, driven step by step, for tools/desk/test_page.py (a check, not a +// bin/vh command). The steps come as JSON on stdin; each "eval" and "until" answer goes to stdout as one JSON line. +// +// usage: node tools/desk/page_driver.mjs < steps.json +// {"url": "", "width": 1440, "height": 900, "steps": [ … ]} +// step: {"go": "#/p//outline"} set the address's hash (the page routes on it) +// {"reload": true} reload the page and wait for it +// {"wait": 500} milliseconds +// {"until": "", "ms": 8000, "name": "…"} wait until it is truthy: {name, ok, value} +// {"eval": "", "name": "…"} evaluate in the page: {name, value} (awaited, as JSON) +// {"write": "", "text": "…"} write a file (a project file the agent changes while the page is open) +// {"click": ""} a real click (mouse events at its middle), as the person's +// The page's own scripts see real input events: a click is the browser's, not element.click(). Nothing else is +// done to the page; a step that fails is said in its line and the rest go on. +import { launchTab } from "../textcheck/browser.mjs"; +import { writeFileSync } from "node:fs"; + +const exe = process.argv[2]; +const input = JSON.parse(await new Promise((ok) => { let s = ""; process.stdin.on("data", (d) => { s += d; }); process.stdin.on("end", () => ok(s)); })); +const out = (x) => process.stdout.write(JSON.stringify(x) + "\n"); +const { browser, sessionId: S } = await launchTab(exe, [], ["Page", "Runtime"]); +const send = (m, p) => browser.send(m, p, S); +const sleep = (ms) => new Promise((ok) => setTimeout(ok, ms)); +async function evaluate(expr) { + const r = await send("Runtime.evaluate", { expression: `(async () => (${expr}))()`, awaitPromise: true, returnByValue: true }); + if (r.exceptionDetails) throw new Error((r.exceptionDetails.exception && r.exceptionDetails.exception.description) || r.exceptionDetails.text); + return r.result.value; +} +async function loaded(navigate) { + const done = browser.once("Page.loadEventFired", S); + await navigate(); + await Promise.race([done, sleep(15000)]); + await sleep(600); +} +try { + await send("Emulation.setDeviceMetricsOverride", { width: input.width || 1440, height: input.height || 900, deviceScaleFactor: 1, mobile: false }); + await loaded(() => send("Page.navigate", { url: input.url })); + for (const st of input.steps) { + try { + if (st.go != null) { await evaluate(`location.hash = ${JSON.stringify(st.go)}`); await sleep(st.after || 1500); } + else if (st.reload) await loaded(() => send("Page.reload", {})); + else if (st.wait) await sleep(st.wait); + else if (st.write) writeFileSync(st.write, st.text); + else if (st.click) { + const box = await evaluate(`(() => { const e = document.querySelector(${JSON.stringify(st.click)}); if (!e) return null; e.scrollIntoView({ block: "center" }); const r = e.getBoundingClientRect(); return { x: r.left + r.width / 2, y: r.top + r.height / 2 }; })()`); + if (!box) { out({ name: st.name || st.click, error: "not there" }); continue; } + for (const type of ["mouseMoved", "mousePressed", "mouseReleased"]) await send("Input.dispatchMouseEvent", { type, x: box.x, y: box.y, button: "left", clickCount: 1 }); + await sleep(st.after || 400); + } else if (st.until) { + const t0 = Date.now(); let v = null; + while (Date.now() - t0 < (st.ms || 8000)) { v = await evaluate(st.until).catch(() => null); if (v) break; await sleep(200); } + out({ name: st.name || st.until, ok: !!v, value: v }); + } else if (st.eval) out({ name: st.name || st.eval, value: await evaluate(st.eval) }); + } catch (e) { out({ name: st.name || JSON.stringify(st).slice(0, 60), error: String(e.message || e).slice(0, 300) }); } + } +} finally { await browser.close(); } +process.exit(0); diff --git a/tools/desk/server.py b/tools/desk/server.py index acae507d..3d795422 100644 --- a/tools/desk/server.py +++ b/tools/desk/server.py @@ -675,6 +675,22 @@ def project_data(project, parts=("studio", "mods")): data["warnings"].append(f"bin/vh status: {type(e).__name__}: {e}") data["pid"] = pid_of(project) data["revision_stamp"] = revision_stamp + # each submission's state: unread (nobody took it; late: after its round was taken) or taken (when, by which agent program) + try: + took, un = F.taken(project), {f.name: late for f, _, late in F.unread(project)} + except Exception as e: # the page says it cannot tell, rather than say something false + took, un = None, None + data["warnings"].append(f"the notes' states: {type(e).__name__}: {e}") + for fb in data.get("feedback") or []: + n = os.path.basename(fb.get("file") or "") + if took is None: + fb["state"] = None + continue + t = took.get(n) + fb["state"] = "taken" if t is not None else "unread" if n in un else "answered" + fb["taken"] = {"t": t.get("t"), "program": t.get("program"), "by": t.get("by")} if t is not None else None + fb["late"] = bool(un.get(n)) + data["notes_stamp"] = F.notes_stamp(project) _drop_missing(project, data.get("shots"), "video") # the storyboard's animatic, and the pictures the gate pages name for r in data.get("rounds") or []: g = r.get("data") if isinstance(r, dict) and isinstance(r.get("data"), dict) else {} @@ -1119,8 +1135,11 @@ def do_GET(self): now, plan = o.get("now"), o.get("plan") except (Exception, SystemExit): # the page keeps what it has now = plan = None - return self._json(dict(F.listening(project), project=project.name, key=key, round=pages[-1].stem[5:] if pages else None, - revision_stamp=RV.stamp(project), now=now, plan=plan)) + lis = F.listening(project) + cur = pages[-1].stem[5:] if pages else None + return self._json(dict(lis, project=project.name, key=key, round=cur, revision_stamp=RV.stamp(project), now=now, plan=plan, + live=bool(lis.get("listening")) and lis.get("round") is not None and lis.get("round") == F.current_round(project), + notes_stamp=F.notes_stamp(project))) if what == "stage": return self._stage(project, key) lang = (parse_qs(urlsplit(self.path).query).get("lang") or [None])[0] @@ -1503,7 +1522,13 @@ def do_POST(self): saved = F.save(project, fb) sys.stderr.write(f"desk: feedback saved → {saved} (also in REVIEW.md)\n") sys.stderr.flush() - self._json(dict(F.listening(project), saved=os.path.relpath(saved, project))) + lis = F.listening(project) # live: a wait on the round that is out takes it within the second + try: + late = next((lt for f, _, lt in F.unread(project) if f.name == saved.name), False) + except Exception: + late = False + self._json(dict(lis, saved=os.path.relpath(saved, project), late=late, + live=bool(lis.get("listening")) and lis.get("round") is not None and lis.get("round") == F.current_round(project))) def _claim(self): """POST /api/claim {c}: a one-time code → this run's token, once.""" diff --git a/tools/desk/static/agent.js b/tools/desk/static/agent.js index fff33186..0e75511a 100644 --- a/tools/desk/static/agent.js +++ b/tools/desk/static/agent.js @@ -38,6 +38,8 @@ const ASTR = { busy_command: "终端里正在跑 {x}。等它跑完再让 agent 动手。", busy_process: "终端里有 {x} 开在这支片子的文件夹里,它可能正在改东西。现在让 {a} 动手,两边可能改到同一处。", busy_waiting: "终端里有个 agent 在等你交这一站。现在让 {a} 动手,两边可能改到同一处。", busy_anyway: "仍然发这一句", busy_not: "先不发", + busy_outside: "这支片子正由这个窗口外面的 {x} 在做,在这里说的话它收不到。在这里发出去,会另起一个 AI 做同一支片子,两个可能改到同一处。", busy_outside_go: "另起一个 AI", + empty_outside: "这支片子正由这个窗口外面的 {x} 在做,在这里说的话它收不到。在这里发第一句,会另起一个 AI;要那边接着做,回到那边说。", ai_any: "AI", perm_h: "{a} 想{v}", perm_toast: "{a} 想{v},等你批准", perm_wait: "等你批准", perm_by_person: "你选了:{o}", perm_by_stop: "你点了停止,取消了", perm_by_timeout: "没有页面开着,{m} 分钟后按“不行”处理了", perm_by_gone: "agent 停了,这一问不算了", perm_by_restart: "Studio 重启过,这一问不算了", perm_by_turn: "它这一句做完了,这一问不算了", perm_by_desk: "Studio 关了,这一问不算了", o_allow_once: "允许这一次", o_allow_always: "这个对话里同类的都允许", o_reject_once: "不允许", o_reject_always: "一直不允许", @@ -93,6 +95,8 @@ const ASTR = { busy_command: "{x} is running in a terminal. Let it finish before the agent starts.", busy_process: "{x} is open in this film's folder in a terminal and may be editing. If {a} starts now, both may edit the same thing.", busy_waiting: "An agent in a terminal is waiting for you to send this stop. If {a} starts now, both may edit the same thing.", busy_anyway: "Send this one anyway", busy_not: "Not now", + busy_outside: "{x} is making this film outside this window, and what you say here does not reach it. Sending here starts a second AI on the same film; the two may change the same thing.", busy_outside_go: "Start a second AI", + empty_outside: "{x} is making this film outside this window, and what you say here does not reach it. Your first message here starts a second AI; to have that one carry on, say so over there.", ai_any: "An AI", perm_h: "{a} wants to {v}", perm_toast: "{a} wants to {v}: waiting for your OK", perm_wait: "Waiting for your OK", perm_by_person: "You chose: {o}", perm_by_stop: "Cancelled when you pressed Stop", perm_by_timeout: "No page was open; after {m} minutes it was refused", perm_by_gone: "The agent stopped, so this request no longer counts", perm_by_restart: "Studio restarted, so this request no longer counts", perm_by_turn: "Its reply ended, so this request no longer counts", perm_by_desk: "Studio closed, so this request no longer counts", o_allow_once: "Allow this once", o_allow_always: "Allow the same kind in this chat", o_reject_once: "Don't allow", o_reject_always: "Never allow", @@ -297,10 +301,17 @@ const AGENT = (() => { let OFFER = null; // the sample the person picked on the space's wall while the box could not take it (no agent set up, the // space's chat working or waiting for approval): kept here and offered again with one click, never put in the box by itself const busyNow = () => !!(S && (S.running || Object.values(S.perms).some((p) => !p.answered))); + function outsider() { // an agent outside this window holds this film, and no conversation here has begun on it: its name, else null + if (KEYP === SPACE || (S && S.sum && S.sum.turns)) return null; + const h = typeof D !== "undefined" && D && D.status && D.status.holder; + return h && h.outside ? ({ claude: "Claude Code", codex: "Codex" }[h.program] || at("ai_any")) : null; + } const offerName = () => (OFFER ? t(`smp_${OFFER}_type`) : ""); function offerKept() { return OFFER && KEYP === SPACE ? `

${esc(at("of_keep", { x: offerName() }))}

` : ""; } let TELLING = ""; // the carry-on words a refused click was for: the busy line's "anyway" sends them, never the box's draft async function sayWords(text, despite) { + const o = !despite && outsider(); + if (o) { BUSY = [{ why: "outside", label: o }]; TELLING = text; render(); return; } // a second AI on this film: asked for in those words first const r = await post(`${S.id}/say`, { text, despite: !!despite }); if (r.ok) { BUSY = null; TELLING = ""; S.sum.turns = (S.sum.turns || 0) + 1; } else if (r.status === 409 && r.data && r.data.who) { BUSY = r.data.who; TELLING = text; } @@ -309,6 +320,7 @@ const AGENT = (() => { } async function again(e) { // "send it anyway" on the busy line: what was refused, the carry-on words or the box if (!e || !e.isTrusted) return; + if (TELLING && !S && !(await start(KIND, true))) return; // (a second AI asked for: it starts now) if (TELLING && S) return sayWords(TELLING, true); return send(e, true); } @@ -316,6 +328,8 @@ const AGENT = (() => { if (!e || !e.isTrusted) return; // only a real key press or click sends, and only what is in the box const ta = $("#agSay"), text = ta ? ta.value.trim() : ""; if (!text) { if (ta) ta.focus(); return; } + const o = !despite && outsider(); + if (o) { BUSY = [{ why: "outside", label: o }]; render(); return; } // nothing starts before the person says to start a second AI if (!S && !(await start(KIND, true))) return; const sc = typeof SCOPE !== "undefined" && SCOPE && SCOPE.target ? SCOPE : null; const scope = sc ? { kind: sc.target.split(":")[0], id: sc.target.split(":").slice(1).join(":"), t: sc.t, t1: sc.t1, module: typeof MOD !== "undefined" ? MOD : "", label: sc.label } : null; @@ -550,7 +564,8 @@ const AGENT = (() => { if (KEYP === SPACE) return `

${esc(at("sp_h"))}

${S ? "" : startPicks()}

${esc(at("sp_b", { a: m.label }))}

${esc(at("sp_c"))}

${prepare}
${ownHtml()}
`; const st = !S && INFO && (INFO.strays || [])[0]; if (st) return `

${esc(at("empty_h", { a: m.label }))}

${esc(at("stray", { x: cut(st.first || "—", 40) }))}

`; - return `

${esc(at("empty_h", { a: m.label }))}

${S ? "" : startPicks()}

${esc(at("empty_b"))}

${esc(at("empty_c"))}

${prepare}${KIND === "dsh" ? `

${esc(at("empty_dsh"))}

` : ""}
`; + const ox = outsider(); + return `

${esc(at("empty_h", { a: m.label }))}

${ox ? `

${esc(at("empty_outside", { x: ox }))}

` : ""}${S ? "" : startPicks()}

${esc(at("empty_b"))}

${esc(at("empty_c"))}

${prepare}${KIND === "dsh" ? `

${esc(at("empty_dsh"))}

` : ""}
`; } function itemHtml(it) { const a = esc(label()); @@ -758,7 +773,8 @@ const AGENT = (() => { const sc = typeof SCOPE !== "undefined" && SCOPE ? SCOPE : null; const x = sc ? sc.label : typeof scopeLabel === "function" ? scopeLabel() : ""; const busy = BUSY ? BUSY.map((w) => at("busy_" + (w.why || "console"), { a: label(), x: w.label || "", p: w.pid || "" })).join(" ") : ""; - const anyway = BUSY && BUSY.length && BUSY.every((w) => w.why === "waiting" || w.why === "process"); + const anyway = BUSY && BUSY.length && BUSY.every((w) => w.why === "waiting" || w.why === "process" || w.why === "outside"); + const goWord = BUSY && BUSY.some((w) => w.why === "outside") ? at("busy_outside_go") : at("busy_anyway"); const ready = !!(f.dataset.ready); if (!ready) { f.dataset.ready = "1"; @@ -796,7 +812,7 @@ const AGENT = (() => { const ofHtml = ofOn ? `${esc(at(busyNow() ? "of_busy" : "of_ready", { x: offerName() }))}${busyNow() ? "" : ``}` : ""; if (of.dataset.html !== ofHtml) { of.innerHTML = ofHtml; of.dataset.html = ofHtml; } const bz = $("#agBusy"); bz.hidden = !busy; - bz.innerHTML = busy ? `${esc(busy)}${anyway ? `` : ""}` : ""; + bz.innerHTML = busy ? `${esc(busy)}${anyway ? `` : ""}` : ""; } function render() { renderHead(); renderThread(); renderFoot(); } async function bring(sid) { // the person's click on a new film's empty column: that conversation from the space comes here @@ -904,13 +920,16 @@ const AGENT = (() => { tabs, setTab, fresh, offer, listening(on) { if (LISTEN !== !!on) { LISTEN = !!on; if (KEYP && KEYP !== SPACE) renderHead(); } }, - async tell(e, text) { // Studio's own button (the column's one action): its own words (bin/vh status's, Studio's word table and numbers), sent in this - // film's conversation, the newest one, else a new one; the box keeps the person's draft (it is filled only by them) + async tell(e, text, sure) { // Studio's own button (the column's one action): its own words (bin/vh status's, Studio's word table and numbers), sent in this + // film's conversation, the newest one, else a new one; the box keeps the person's draft (it is filled only by them). sure: the + // person already said, in so many words, to start a second AI on a film an agent outside this window holds if (!e || !e.isTrusted || !KEYP || KEYP === SPACE || !text || !KEYOK) return; setTab("chat"); if (!S && meta(KIND).installed) { const last = sessionsOf(KIND)[0]; if (last) open(last); } + const o = !sure && outsider(); + if (o) { BUSY = [{ why: "outside", label: o }]; TELLING = text; render(); return; } // asked first, nothing started if (!S && !(await start(KIND, true))) return; - await sayWords(text, false); + await sayWords(text, !!sure); }, _again: (e) => again(e), // for tools/desk/test_agents.py (node): the busy line's "anyway" after a refused carry-on busy: () => !!(S && S.running && KEYP !== SPACE), // a turn in this film's column now (the flow strip's agent lamp) diff --git a/tools/desk/static/core.js b/tools/desk/static/core.js index f24fdd93..eff028dc 100644 --- a/tools/desk/static/core.js +++ b/tools/desk/static/core.js @@ -160,6 +160,19 @@ const STR = { lk_git_n: "git", lk_git_s: "这个工作台更新不了", lk_git_d: "跟你的 agent 说“帮我装上 git”。", lk_browser_n: "浏览器", lk_browser_s: "网页做的画面渲染不出来,也取不了帧来检查", lk_browser_d: "跟你的 agent 说“帮我装上 Chrome”。", lk_agent_n: "Studio 里的 agent", lk_agent_s: "右边的「对话」现在只能看,还不能和 agent 说话。", lk_agent_d: "打开一支片子,在右边「对话」里点「装上」。", + // the notes and their state (draft, sent and not picked up, picked up), and who picks them up: the agent by its name, else AI + ho_mine: "你的意见", ho_ai: "AI", ho_draft: "还没交 {n} 条", ho_unread: "交了 {n} 条,还没人取", ho_unread_late: "补交的 {n} 条,还没人取", + ho_taken: "{at} 被 {a} 取走", ho_taken_n: "{n} 条", ho_who_live: "正在等的 {a} 马上会取。", + ho_who_out: "做这支片子的 {a} 在这个窗口外面:回到它那边说一声“我交了”,它就会来取。", + ho_who_next: "现在没有 AI 在等。下次有 AI 接着做这支片子,会先拿到它们。", + ho_bar_late: "补充 {n} 条 · {s}已被取走,单独交", ho_bar_unread: "交了,还没人取", ho_bar_taken: "{a} 已经取走了", ho_submit_late: "补交", + ho_sent_h: "交了,还没人取的", ho_d_late: "{s}已经被 {a} 取走了。这几条作为补交的意见单独交,不算进别的哪一页。", + ho_d_live: "正在等的 {a} 会马上取走。", ho_d_out: "做这支片子的 {a} 在这个窗口外面:交了以后,回到它那边说一声“我交了”。", + ho_d_nobody: "现在没有 AI 在等这些意见:交了以后先存着,下次有 AI 接着做这支片子会先拿到。", + ho_sent_live: "交了,正在等的 {a} 马上会取", ho_sent_kept: "交了,先存着。现在没有 AI 在等,下次有 AI 接着做会先拿到", ho_sent_out: "交了,先存着。回到 {a} 那边说一声“我交了”,它就来取", + ho_fix_q: "你选了“{x}”,还没写改哪里。", ho_fix_b: "在页面上点要改的地方写一句,或者在上面的整体意见里写。", ho_fix_back: "回去写", ho_fix_go: "就这样交", + ho_s_1: "立意", ho_s_outline: "大纲", ho_s_E0: "画风样张", ho_s_E1: "旁白稿", ho_s_2: "分镜", ho_s_E2: "配乐安排", ho_s_E3: "最终的声音", + ho_s_3: "初版", ho_s_E4: "第一章样片", ho_s_E5: "定画面的版本", ho_s_notes: "随手写的意见", ho_s_other: "这一页", }, en: { revisions: "Revisions", revision_pending: "Ready for review", revision_approved: "Accepted", revision_changes_requested: "Changes requested", @@ -316,6 +329,18 @@ const STR = { lk_git_n: "git", lk_git_s: "this workbench can't update", lk_git_d: "Tell your agent “install git for me”.", lk_browser_n: "A browser", lk_browser_s: "pictures made as web pages can't render, and frames can't be grabbed to check them", lk_browser_d: "Tell your agent “install Chrome for me”.", lk_agent_n: "An agent in Studio", lk_agent_s: "The Chat on the right can only show, not talk to an agent yet.", lk_agent_d: "Open a film and press “Set it up” in its Chat on the right.", + ho_mine: "Your notes", ho_ai: "the AI", ho_draft: "{n} not sent yet", ho_unread: "{n} sent, not picked up yet", ho_unread_late: "{n} sent later, not picked up yet", + ho_taken: "picked up by {a} at {at}", ho_taken_n: "{n} {n|note|notes}", ho_who_live: "The {a} that is waiting picks them up at once.", + ho_who_out: "{a}, outside this window, is making this film: tell it “I've sent it” over there and it picks them up.", + ho_who_next: "No AI is waiting right now. The next AI to carry on with this film gets them first.", + ho_bar_late: "{n} more {n|note|notes} · {s} was already picked up: these go on their own", ho_bar_unread: "Sent, not picked up yet", ho_bar_taken: "{a} has picked them up", ho_submit_late: "Send these too", + ho_sent_h: "Sent, not picked up yet", ho_d_late: "{a} already picked up {s}. These go as later notes of their own, not counted with any other page.", + ho_d_live: "The {a} that is waiting picks them up at once.", ho_d_out: "{a}, outside this window, is making this film: once sent, tell it “I've sent it” over there.", + ho_d_nobody: "No AI is waiting for these notes: once sent they are kept, and the next AI to carry on with this film gets them first.", + ho_sent_live: "Sent; the waiting {a} picks them up at once", ho_sent_kept: "Sent and kept. No AI is waiting; the next one to carry on gets them first", ho_sent_out: "Sent and kept. Tell {a} “I've sent it” and it picks them up", + ho_fix_q: "You picked “{x}” but haven't said what to change.", ho_fix_b: "Click the place to change on the page and write a line, or write it in the overall box above.", ho_fix_back: "Go back and write it", ho_fix_go: "Send as it is", + ho_s_1: "the concept", ho_s_outline: "the outline", ho_s_E0: "the style frames", ho_s_E1: "the script", ho_s_2: "the storyboard", ho_s_E2: "the sound plan", ho_s_E3: "the final sound", + ho_s_3: "the first draft", ho_s_E4: "the first chapter", ho_s_E5: "the picture lock", ho_s_notes: "your loose notes", ho_s_other: "this page", }, }; diff --git a/tools/desk/static/studio.css b/tools/desk/static/studio.css index 4b0d1260..f5b8893d 100644 --- a/tools/desk/static/studio.css +++ b/tools/desk/static/studio.css @@ -209,6 +209,19 @@ html.shell-other .topbar{padding-right:calc(14px + 100vw - env(titlebar-area-x, .col-body .next .who.person{color:var(--wait)} .col-body .next .raw{color:var(--ink-3);font-size:var(--fs-label)} .col-body .quiet-line{color:var(--ink-2)} +/* the notes and their state, pinned to the column's foot right above the note box: what was just kept is seen without scrolling */ +.col-body .c-mine{position:sticky;bottom:-14px;margin:0 -16px -14px;padding:10px 16px 12px;max-height:42vh;overflow:auto;background:var(--panel);border-top:1px solid var(--rule);box-shadow:0 -10px 14px -12px rgba(0,0,0,.35);z-index:1} +.col-body .c-mine .blk-h{position:sticky;top:-10px;margin:-10px 0 4px;padding:10px 0 4px;background:var(--panel);z-index:1} /* the state line stays while the notes scroll */ +.col-body .c-mine .blk-h .tag{margin-left:auto;color:var(--wait)} +.col-body .ho-batch{margin-top:8px} +.col-body .ho-st{margin:0;display:flex;gap:8px;align-items:baseline;font-size:var(--fs-small);color:var(--ink-hi)} +.col-body .ho-st i{flex:none;width:6px;height:6px;border-radius:50%;background:var(--wait);transform:translateY(-1px)} +.col-body .ho-st.taken{color:var(--ink-2)}.col-body .ho-st.taken i{background:var(--rule-2)} +.col-body .ho-more{margin:2px 0 4px 14px;font-size:var(--fs-label);line-height:1.5;color:var(--ink-2)} +.col-body .ho-batch .note-list.sent{margin-left:14px} +.col-body details.ho-batch>summary{list-style:none;cursor:pointer}.col-body details.ho-batch>summary::-webkit-details-marker{display:none} +.confirm .fix-ask{margin:8px 0 0;padding:8px 12px;border-left:2px solid var(--wait);background:var(--wait-soft)} +.confirm .fix-ask .fix-q{margin:0 0 2px;font-size:var(--fs-small);color:var(--ink-hi)} .col-body.more{-webkit-mask-image:linear-gradient(var(--ink) calc(100% - 36px),transparent);mask-image:linear-gradient(var(--ink) calc(100% - 36px),transparent)} /* more below: the column fades out instead of ending under the bar */ .app .g-opt .id{display:none} /* the console says an option by its words; the static page keeps the codes its reply line uses */ .col-body .next code{display:inline;white-space:pre-wrap;overflow-wrap:anywhere;font-size:11.5px;color:var(--ink-2);background:none;padding:0} diff --git a/tools/desk/static/studio.js b/tools/desk/static/studio.js index a4acfe8a..277c45f6 100644 --- a/tools/desk/static/studio.js +++ b/tools/desk/static/studio.js @@ -407,13 +407,13 @@ function renderColumn() { const g = GV && GV.current && roundOpen() ? GV : null; // the cards while this round's stop is open (not passed or skipped) const home = GATE_MOD[gateBase(ROUND.id)] || "cut", here = !g || MOD === home, n = (ROUND.data.decisions || []).length; const page = ROUND.page ? `
${esc(t("static_page"))} ↗` : ""; - const hd = handedNow(), H = hd && !REHAND[KEY]; // this stop's notes were handed over: what went, not the cards as if nothing had + const hd = handedNow(), H = hd && !REHAND[KEY]; // this stop's notes went (taken, or sent and not picked up yet): what went, not the cards as if nothing had const decs = H ? handedHtml(hd) : g && !here ? `
${esc(n ? t("away_decide", { s: gateName(ROUND.id), n }) : t(earOf(ROUND.id) ? "away_listen" : "away_look", { s: gateName(ROUND.id) }))} →
` // another module: one line to the stop's own : g && n ? `

${esc(t("c_decide"))}${n}${esc(t("c_rec"))}

${g.summary ? `

${esc(g.summary)}${page}

` : ""}
${g.cards}
` : g && g.summary ? `

${esc(g.summary)}${page}

` : `

${esc(t(filmDelivered() ? "col_done" : "round_quiet"))}

`; // nothing to decide: one line ("最近定下的" is the ledger's) - const sent = H ? "" : FB.sent ? t("sent_n", { n: FB.sent.n, d: FB.sent.d, at: FB.sent.at }) : FB.submittedAt ? t("submitted", { at: FB.submittedAt }) : ""; // what went, and that it does not go again - $("#colBody").innerHTML = `${sent ? `

${esc(sent)}

` : ""}${decs}
`; + // what went is said in the notes block below, with its state (sent and not picked up, or picked up: when, by whom) + $("#colBody").innerHTML = `${decs}
`; if (COLCTL) { COLCTL.destroy(); COLCTL = null; } const cards = $(".c-cards", $("#colBody")); if (cards) COLCTL = OVH.mount(cards, { initial: FB.decisions, onPick: pick, advance: true }); @@ -423,24 +423,41 @@ function renderColumn() { AGENT.enter(PKEY); // the column's other tab: the conversation with the agent on this film (agent.js) } const REHAND = {}; // a stop whose handed-over notes the person chose to change: its cards again -function handedNow() { // the newest submission for this round's stop, once it went to the agent's side (the stop waits for the agent) +function handedNow() { // the newest submission for this round's stop, once it went (the stop waits for the agent): picked up or not yet if (!D || !ROUND || ROUND.id === "notes" || roundState() !== "waiting_agent") return null; - const L2 = (D.feedback || []).filter((f) => f.round === ROUND.id); + const L2 = (D.feedback || []).filter((f) => f.round === ROUND.id && !f.late); return L2.length ? L2[L2.length - 1] : null; } -function handedHtml(f) { // each decision as it went, the notes, when; and the way to change them and hand over again +const PROG = { claude: "Claude Code", codex: "Codex" }; +function progName(p) { return PROG[p] || t("ho_ai"); } // the agent by its name when it is known, else AI +function holderName() { const h = D && D.status && D.status.holder; return progName(h && h.program); } +function stepName(rid) { // a round by its step's name (旁白稿, 大纲 …): a gate ① page without concept cards is the outline + const b = gateBase(rid), r = (D.rounds || []).find((x) => x.id === rid); + const cards = r && ((r.data || {}).decisions || []).some((d) => (d.options || []).some((o) => o && o.frame)); + const k = rid === "notes" ? "ho_s_notes" : b === "1" && r && !cards ? "ho_s_outline" : b ? "ho_s_" + b : "ho_s_other"; + return STR[LANG][k] ? t(k) : t("ho_s_other"); +} +function subCount(f) { return (f.items || []).length + (f.general ? 1 : 0) + Object.keys(f.decisions || {}).length; } +function lastOf(rid) { const L2 = (D.feedback || []).filter((f) => f.round === rid); return L2.length ? L2[L2.length - 1] : null; } +function roundTaken() { const f = (D.feedback || []).filter((x) => x.round === ROUND.id && x.state === "taken").pop(); return f || null; } +function whoTakes(kind) { // who picks notes up now, in a line: the wait on this round, the agent outside this window, else nobody yet + const h = D.status && D.status.holder, a = holderName(); + return LIVE ? t(kind + "_live", { a }) : h && h.outside ? t(kind + "_out", { a }) : t(kind === "ho_who" ? "ho_who_next" : "ho_d_nobody"); +} +function takenAt(f) { + const x = f.taken && f.taken.t ? new Date(f.taken.t * 1000) : null; + return x ? x.toLocaleString(LANG === "zh" ? "zh-CN" : "en", { month: "numeric", day: "numeric", hour: "2-digit", minute: "2-digit" }) : ""; +} +function handedHtml(f) { // each decision as it went, when; and the way to change them and send again (the notes are in the notes block, with their state) const D2 = ROUND.data.decisions || []; const dec = Object.entries(f.decisions || {}).map(([k, v]) => { const q = D2.find((x) => x.id === k) || {}, o = (q.options || []).find((x) => (x.id || x) === v); const said = o ? (typeof o === "string" ? o : o.label || o.title || t("handed_opt")) : t("handed_gone"); // an option by its words, never its code return `
  • ·${esc(cut(q.question || t("handed_q"), 40))} ${esc(said)}
  • `; }); - const st = { ok: t("st_ok"), change: t("st_change"), ask: t("st_ask") }; - const notes = (f.items || []).map((i) => `
  • ·${esc(cut(i.label || i.target || "", 40))} ${esc(i.text || st[i.status] || "")}
  • `); - const gen = f.general ? [`
  • ·${esc(t("c_whole_note"))} ${esc(f.general)}
  • `] : []; + if (!dec.length) return ""; const at = f.submitted_at ? new Date(f.submitted_at).toLocaleString(LANG === "zh" ? "zh-CN" : "en", { month: "numeric", day: "numeric", hour: "2-digit", minute: "2-digit" }) : ""; - const all = dec.concat(notes, gen); - return `

    ${esc(t("c_handed"))}${at && at !== "Invalid Date" ? `${esc(at)}` : ""}

    ` - + (all.length ? `
      ${all.join("")}
    ` : `

    ${esc(t("handed_none"))}

    `) - + `
    `; + const head = f.state === "taken" ? t("c_handed") : t("ho_sent_h"); // never "handed over" before a run took it + return `

    ${esc(head)}${at && at !== "Invalid Date" ? `${esc(at)}` : ""}

    ` + + `
      ${dec.join("")}
    `; } $("#colBody").addEventListener("click", (e) => { if (e.target.closest("#reHand")) { REHAND[KEY] = true; renderColumn(); } }); function syncPhoneDec() { // a phone lays the cut out picture, timeline, then the column: a bar above the picture goes to the decisions @@ -489,9 +506,25 @@ function renderMine() { const row = ([k, v]) => `
  • ${v.t != null ? esc(fmt(v.t) + (v.t1 != null ? "–" + fmt(v.t1) : "")) : ""}${esc(cut(v.label || k, 40))} ${esc(v.text || st[v.status] || "")}
  • `; const gen = FB.general ? `
  • ·${esc(t("c_whole_note"))} ${esc(FB.general)}
  • ` : ""; const none = !items.length && !gen; // none yet: the heading and how to start, on one line - $("#cMine").innerHTML = `

    ${esc(t("c_mine"))}${items.length + (FB.general ? 1 : 0)}${none ? `${esc(t(MOD === "cut" ? "c_mine_how" : "c_mine_how_m"))}` : ""}

    ` - + (none ? "" : `
      ${items.map(row).join("")}${gen}
    `); -} + const n = items.length + (FB.general ? 1 : 0), subs = D ? (D.feedback || []) : []; + const unread = subs.filter((f) => f.state === "unread"), took = roundTaken(); + const st2 = (cls, words, more) => `

    ${esc(words)}

    ${more ? `

    ${esc(more)}

    ` : ""}`; + const sentList = (f) => `
      ${(f.items || []).map((i) => `
    • ·${esc(cut(i.label || i.target || "", 40))} ${esc(i.text || st[i.status] || "")}
    • `).join("")}${f.general ? `
    • ·${esc(t("c_whole_note"))} ${esc(f.general)}
    • ` : ""}
    `; + const groups = {}; // what was sent and nobody picked up, by round (a later batch said apart) + unread.forEach((f) => { const k = f.round + (f.late ? ":late" : ""); (groups[k] = groups[k] || []).push(f); }); + const unreadHtml = Object.values(groups).map((G) => { const c = G.reduce((a, f) => a + subCount(f), 0), late = G[0].late; + return `
    ${st2("unread", `${t(late ? "ho_unread_late" : "ho_unread", { n: c })} · ${stepName(G[0].round)}`, whoTakes("ho_who"))}${G.map(sentList).join("")}
    `; }).join(""); + const takenHtml = took && !unread.some((f) => f.round === ROUND.id) ? `
    ${st2("taken", t("ho_taken", { at: takenAt(took), a: progName(took.taken && took.taken.program) }) + " · " + t("ho_taken_n", { n: subCount(took) }))}${sentList(took)}
    ` : ""; + $("#cMine").innerHTML = `

    ${esc(t("ho_mine"))}${n ? `${esc(t("ho_draft", { n }))}` : ""}${none && !unreadHtml && !takenHtml ? `${esc(t(MOD === "cut" ? "c_mine_how" : "c_mine_how_m"))}` : ""}

    ` + + (none ? "" : `
      ${items.map(row).join("")}${gen}
    `) + unreadHtml + takenHtml; + requestAnimationFrame(keepNewest); +} +function keepNewest() { // the note kept last is the one in view, however many there are (also once the column's tab shows the block) + const box = $("#cMine"), keys = FB ? Object.keys(FB.items) : []; + const newest = box && keys.length ? $(`li[data-goto="${CSS.escape(keys[keys.length - 1])}"]`, box) : null; + if (newest && box.scrollHeight > box.clientHeight) box.scrollTop = Math.max(0, newest.offsetTop - box.clientHeight + newest.offsetHeight + 8); +} +if (typeof ResizeObserver !== "undefined") new ResizeObserver(() => keepNewest()).observe($("#colBody")); function renderNext() { // what happens next, in a line: who, and what (status's words in this page's language; its commands only in a tooltip) const st = (D && D.status) || {}, ns = st.next_step || {}, run = ((st.activity || {}).running || []); const who = ns.who === "person" ? "person" : ns.who === "nobody" ? "nobody" : "agent"; @@ -515,11 +548,11 @@ function renderNow() { // where this film stands, in bin/vh status's own sente const a = n.act || {}, mod = a.kind === "open" ? (a.mod || "cut") : ""; const armed = a.kind === "tell" && a.confirm && NOWARM === PKEY; // an offer that asks once more: the first click arms it const quiet = a.secondary && !armed, cls = quiet ? "btn btn-quiet xs now-second" : a.secondary ? "btn" : "btn btn-primary"; // a second line, or the one thing to do - const btn = a.kind === "tell" ? `${armed ? `` : ""}` + const btn = a.kind === "tell" ? `${armed ? `` : ""}` : a.kind === "settings" ? `${esc(a.label[L])}` // only the person can give it (an API Key): the settings page's section : mod && mod !== MOD ? `${esc(a.label[L])} →` : ""; // already on that page: no button to it const opens = (txt) => ((n.facts || {}).paths || []).reduce((h, p) => h.split(esc(p)).join(`${esc(p)}`), esc(txt)); // a file the words name opens - const html = `

    ${esc(n.say[L])}

    ${n.more ? `

    ${opens(n.more[L])}

    ` : ""}${armed ? `

    ${esc(t("now_sure_note"))}

    ` : ""}${btn ? `
    ${btn}
    ` : ""}${plan ? `

    ${esc(plan[L])}

    ` : ""}`; + const html = `

    ${esc(n.say[L])}

    ${n.more ? `

    ${opens(n.more[L])}

    ` : ""}${armed ? `

    ${esc(a.sure_note ? a.sure_note[L] : t("now_sure_note"))}

    ` : ""}${btn ? `
    ${btn}
    ` : ""}${plan ? `

    ${esc(plan[L])}

    ` : ""}`; el.className = "col-now" + (n.tone === "you" ? " you" : n.tone === "busy" ? " agent" : ""); // amber: the person's to do; violet: something works now if (el.dataset.html !== html) { el.innerHTML = html; el.dataset.html = html; } el.hidden = false; @@ -531,20 +564,24 @@ $("#colNow").addEventListener("click", (e) => { // the one action that carries if (!e.target.closest("#nowTell") || !a || a.kind !== "tell") return; if (a.confirm && NOWARM !== PKEY) { NOWARM = PKEY; renderNow(); return; } NOWARM = ""; renderNow(); - AGENT.tell(e, a.text[LANG === "zh" ? "zh" : "en"]); + AGENT.tell(e, a.text[LANG === "zh" ? "zh" : "en"], !!a.sure); // a second AI the person confirmed in those words: not asked again }); function roundCounts() { // {n, d, r}: notes to send, decisions the person picked and not sent yet, decisions left to the recommendation const ts = toSend(ROUND.data.decisions, FB.decisions, FB.sentDec, roundOpen()); const d = Object.keys(ts.decisions).filter((k) => !ts.defaulted.includes(k)).length; - return { n: myItems().length + (FB.general ? 1 : 0), d, r: ts.defaulted.length }; + return { n: myItems().length + (FB.general ? 1 : 0), d, r: D && roundTaken() ? 0 : ts.defaulted.length }; // (a later batch sends no recommendation again) } function renderRound() { // what the next submission would send, said plainly ("还没写意见 · 2 件按推荐"); nothing to send: the button rests const { n, d, r } = roundCounts(); - const handed = handedNow() && !REHAND[KEY] && !n && !d; // handed over and nothing new written: the bar says so, and rests - const words = handed ? t("rs_handed") : [n ? t("rs_notes", { n }) : t("rs_none")].concat(d ? [t("rs_picked", { d })] : [], r ? [t("rs_rec", { r })] : []).join(" · "); - const idle = handed || (!n && !d && !r); + const last = D ? lastOf(ROUND.id) : null, took = D ? roundTaken() : null; + const sentNow = !REHAND[KEY] && !n && !d && last && (last.state === "unread" || last.state === "taken") && (handedNow() || last.late); // it went, and nothing new is written + const late = !!took && (n || d) > 0; // the round was picked up: what is written now goes on its own, as a later batch + const words = sentNow ? (last.state === "taken" ? t("ho_bar_taken", { a: progName(last.taken && last.taken.program) }) : t("ho_bar_unread")) + : late ? t("ho_bar_late", { n: n + d, s: stepName(ROUND.id) }) + : [n ? t("rs_notes", { n }) : t("rs_none")].concat(d ? [t("rs_picked", { d })] : [], r ? [t("rs_rec", { r })] : []).join(" · "); + const idle = sentNow || (!n && !d && !r); $("#colRound").hidden = false; - $("#colRound").innerHTML = `${esc(words)}`; + $("#colRound").innerHTML = `${esc(words)}`; $("#openConfirm").addEventListener("click", openConfirm); requestAnimationFrame(fadeMore); } @@ -645,7 +682,9 @@ $("#stage").addEventListener("click", (e) => { // a place in a module: the not /* submitting: everything this round holds, then one button (the desk's channel; bin/vh desk wait wakes on it) */ function payload() { // a stop already settled is not decided again by a later note; a decision sent before goes again only when picked differently - const { decisions, defaulted } = toSend(ROUND.data.decisions, FB.decisions, FB.sentDec, roundOpen()); + const ts = toSend(ROUND.data.decisions, FB.decisions, FB.sentDec, roundOpen()); + if (D && roundTaken()) { ts.defaulted.forEach((k) => delete ts.decisions[k]); ts.defaulted = []; } // a later batch: only what the person picked, never the recommendations again + const { decisions, defaulted } = ts; const all = myItems().map(([k, v]) => Object.assign({ target: k, status: v.status, label: fitLabel(v.label || k), text: v.text || "" }, v.suggest && v.suggest !== v.orig ? { suggest: v.suggest } : {}, v.orig && k.startsWith("cap:") ? { orig: v.orig } : {}, v.t != null ? { t: v.t } : {}, v.t1 != null ? { t1: v.t1 } : {})); // an item feedback.py would refuse costs only itself, said before sending, never the round (its limits: tools/desk/feedback.py) @@ -677,14 +716,42 @@ function openConfirm() { const c = $("#confirm"); c.innerHTML = `

    ${esc(t("d_title"))}

      ${decs ? `

      ${esc(t("d_decisions"))}

      ${decs}` : ""}${leastHtml}

      ${esc(t("d_items"))}

      ${items || `
    • ${esc(t("d_none"))}
    • `}${FB.general ? `
    • ${esc(t("overall"))}${esc(FB.general)}
    • ` : ""}
    -

    ${esc(t("submit_hint"))}

    +

    ${esc(sheetWho())}

    +
    ${esc(t("preview"))}
    `; c.hidden = false; - const pv = () => { $("#preview").textContent = summaryText(payload()); }; + const pv = () => { $("#preview").textContent = summaryText(payload()); fixAsk(); }; pv(); $("#cGeneral").addEventListener("input", pv); $("#doSubmit").addEventListener("click", submit); $("#noSubmit").addEventListener("click", closeConfirm); - setTimeout(() => $("#doSubmit").focus(), 30); + setTimeout(() => ($("#fixBack") || $("#doSubmit")).focus(), 30); +} +function sheetWho() { // before sending: this round already picked up (these go on their own), and who picks them up now + const took = roundTaken(), pre = took ? t("ho_d_late", { s: stepName(ROUND.id), a: progName(took.taken && took.taken.program) }) + " " : ""; + return pre + whoTakes("ho_d"); +} +const CHANGE_ID = /^(fix|change|changes|redo|revise|rework|edit|改)/i, CHANGE_WORDS = /(先改|要改|改一下|重做|重写|修改|fix|change|redo|revise|rework)/i; +function fixPick(p) { // a picked option that asks for changes, sent with no note saying what: {label} (A10), else null + if ((p.items || []).length || p.general) return null; + for (const d of ROUND.data.decisions || []) { + const v = p.decisions[d.id]; if (!v || p.defaulted.includes(d.id)) continue; + const o = (d.options || []).find((x) => (x && x.id != null ? x.id : x) === v) || {}, label = typeof o === "string" ? o : String(o.label || v); + if (CHANGE_ID.test(String(v)) || CHANGE_WORDS.test(label)) return { label: cut(label.replace(/\*\*|`/g, ""), 30) }; + } + return null; +} +function fixAsk() { // asks once: what to change; going back keeps everything, sending as it is stays one click away + const box = $("#fixAsk"); if (!box) return; + const f = fixPick(payload()); + box.innerHTML = f ? `

    ${esc(t("ho_fix_q", { x: f.label }))}

    ${esc(t("ho_fix_b"))}

    ` : ""; + const go = $("#doSubmit"), act = go && go.parentElement; if (!act) return; + const back = $("#fixBack"); + if (f && !back) { act.insertAdjacentHTML("afterbegin", ``); go.textContent = t("ho_fix_go"); go.classList.remove("btn-primary"); $("#fixBack").addEventListener("click", fixBackTo); } + if (!f && back) { back.remove(); go.textContent = t("submit"); go.classList.add("btn-primary"); } +} +function fixBackTo() { // back to the page with nothing lost: the sheet closes, the note box takes the keys + $("#confirm").hidden = true; + const box = $("#composer textarea"); if (box) box.focus(); } function closeConfirm() { $("#confirm").hidden = true; const b = $("#openConfirm"); if (b) b.focus(); } async function submit() { @@ -695,8 +762,9 @@ async function submit() { const j = await r.json(); const box = $("#cGeneral"); if (box) box.value = ""; FB = afterSent(FB, p, new Date().toLocaleString()); store.set(KEY, FB); // what went leaves the draft: it is not sent twice - toast(j.listening ? t("sent_live") : t("sent", { f: j.saved })); - $("#submitHint").textContent = t(j.listening ? "hint_live" : "hint_idle", { f: j.saved }); + const h = D.status && D.status.holder, a = holderName(); // said as it is: picked up only by a wait on this round + const said = j.live ? t("ho_sent_live", { a }) : h && h.outside ? t("ho_sent_out", { a }) : t("ho_sent_kept"); + toast(said); $("#submitHint").textContent = said; renderMine(); renderRound(); setTimeout(async () => { $("#confirm").hidden = true; await reloadProject(); }, 1400); return; @@ -716,10 +784,16 @@ function save() { if (CUT) CUT.refresh(); $$("#stage [data-mark]").forEach(markHost); } +let LIVE = false; // a wait alive on the round that is out now (the status poll): it picks a submission up within the second async function pollLive() { if (!PKEY || RELOADING) return; const r = await getJSON(`/api/p/${enc(PKEY)}/status`); const on = !!(r.ok && r.data && r.data.listening), el = $("#colHead .state"); + const live = !!(r.ok && r.data && r.data.live && r.data.key === PKEY); + if (live !== LIVE) { LIVE = live; renderMine(); } // who picks the notes up: said in the notes block + if (r.ok && r.data && D && r.data.key === PKEY && r.data.notes_stamp !== undefined && r.data.notes_stamp !== D.notes_stamp && !RELOADING) { // a note was saved or picked up: its state on screen follows + await reloadProject(false); return; + } if (el) { el.classList.toggle("agent", on); el.hidden = !on; } AGENT.listening(on); // the conversation that waits for this stop in the background says so const mine = r.ok && r.data && r.data.key === PKEY, got = mine ? r.data.now || null : null; // not answered, or its state unreadable: said as unknown diff --git a/tools/desk/test_agents.py b/tools/desk/test_agents.py index e12fff7e..80b363bd 100644 --- a/tools/desk/test_agents.py +++ b/tools/desk/test_agents.py @@ -2203,7 +2203,7 @@ def one_agent_two_films(): # one agent program, two films: open only on the on os.utime(f, (old3, old3)) n1, n2 = status(f1)["now"], status(f2)["now"] a.kill(); a.wait() - if n2["code"] != "agent_open": + if n2["code"] != "agent_outside": # (a terminal's agent: outside Studio's window) return f"the film it worked on last: {n2['code']}" if n1["code"] != "stopped" or "可能在忙别的片子" not in (n1["more"] or {}).get("zh", ""): return f"the film it left three days ago: {n1['code']} {n1['more']}" @@ -2254,7 +2254,161 @@ def orphaned_wait(): # a wait whose agent was killed: no promise, and the wait return f"before {before}, flag left {flag.exists()}, after {after['facts']}" check("a wait whose agent was killed: the promise goes with the agent, and the wait ends by itself", orphaned_wait) - def open_agent(): # an agent that ran a command on the film and is still open: no "stopped", the offer second and asking once more + # ---- the hand-over between Studio and the agent waiting outside it (the first real film's lost notes) ---- + import feedback as F + + def film_at_script(name): # gate ① decided, the script's page (E1) out: the stop where the notes went missing + p = stage(name) + g = p / "out" / "review" + for x in ("gate-2.json", "gate-3.json"): + (g / x).unlink() + r = (p / "REVIEW.md").read_text(encoding="utf-8") + (p / "REVIEW.md").write_text(r[:r.index("## 关卡 ② 分镜")], encoding="utf-8") + page(p, "E1", {"summary": "旁白稿第一版,逐句看", "decisions": [{"id": "names", "question": "英文名念不念?", "options": [{"id": "N1", "label": "不念"}, {"id": "N2", "label": "念"}], "recommend": "N1"}]}) + return p + + def page(p, rid, d): # the agent sends a page (bin/vh review makes it this round) + (p / "out" / "review" / f"gate-{rid}.json").write_text(json.dumps(d, ensure_ascii=False), encoding="utf-8") + r = subprocess.run(["bash", str(vh), "review", str(p), rid], capture_output=True, text=True, env=env, timeout=60) + if r.returncode: + raise RuntimeError(f"review {rid}: {r.stderr[-300:]}") + + def submit(p, rid, *texts): # the person submits in Studio (what the server does once the post is checked) + items = [{"target": f"seg:{i + 1}", "status": "change", "text": x} for i, x in enumerate(texts)] + return F.save(p, F.validate(p, {"round": rid, "lang": "zh", "decisions": {}, "items": items})) + + def waiter(p, *extra, timeout=60): # an agent's background wait + w = subprocess.Popen(["bash", str(vh), "desk", "wait", str(p), "--timeout", str(timeout), *extra], stdout=subprocess.PIPE, stderr=subprocess.STDOUT, text=True, env=env) + BG.add(w.pid) + return w + + def armed(p, n=1, secs=10): # n waits have written their flag (the newest one's is on disk) + t0 = time.time() + while time.time() - t0 < secs: + try: + if json.loads((p / "out" / "review" / "feedback" / ".listening").read_text()).get("pid"): + time.sleep(0.3 * n) + return True + except (OSError, ValueError): + pass + time.sleep(0.1) + return False + + def answer(p, name, said="照改"): # the agent writes 定了 under a submission's REVIEW.md section + r = (p / "REVIEW.md").read_text(encoding="utf-8") + i = r.index(name) + j = r.index("- 定了: 改了:", i) + (p / "REVIEW.md").write_text(r[:j] + f"- 定了:{said} 改了:大纲" + r[j + len("- 定了: 改了:"):], encoding="utf-8") + + def one_submission_two_waits(): # 9.16: the outline's second page waits, then the storyboard's; one storyboard submission + p = film_at_script("two-waits") + page(p, "1b", {"summary": "大纲改成 3 段,再看一遍", "decisions": [{"id": "go", "question": "大纲能做分镜了吗?", "options": [{"id": "OK", "label": "可以"}, {"id": "FIX", "label": "先改"}], "recommend": "OK"}]}) + w1 = waiter(p) + if not armed(p): + return "the 1b wait did not start" + shutil.copy(ROOT / "tools" / "desk" / "fixtures" / "demo" / "out" / "review" / "gate-2.json", p / "out" / "review" / "gate-2.json") + subprocess.run(["bash", str(vh), "review", str(p), "2"], capture_output=True, text=True, env=env, timeout=60) + try: + o1, _ = w1.communicate(timeout=20) + except subprocess.TimeoutExpired: + w1.kill() + return "the 1b wait went on after page 2 went out" + w2 = waiter(p) + if not armed(p): + return "the storyboard's wait did not start" + f = submit(p, "2", "第二镜再慢一点") + o2, _ = w2.communicate(timeout=20) + took = F.taken(p).get(f.name) or {} + if w1.returncode != F.MOVED_ON or "nothing was submitted for 1b" not in o1 or "第二镜" in o1: + return f"the 1b wait: exit {w1.returncode}: {o1[-300:]}" + if w2.returncode != 0 or "第二镜再慢一点" not in o2 or took.get("by") != "wait": + return f"the storyboard's wait: exit {w2.returncode}, taken {took}: {o2[-300:]}" + check("one submission is one round's: a wait for a page that is no longer out ends (exit 7) saying nothing came for it, and the next " + "page's submission goes to that page's wait alone, recorded as taken by it", one_submission_two_waits) + + def two_waits_one_note(): # two waits on one round, one submission: exactly one of them hands it over + p = film_at_script("race") + ws = [waiter(p), waiter(p)] + if not armed(p, 2): + return "the waits did not start" + submit(p, "E1", "只交一次") + time.sleep(4) + outs = [] + for w in ws: + if w.poll() is None: + w.kill() + outs.append((w.wait(), (w.stdout.read() or ""))) + got = [o for rc, o in outs if "只交一次" in o] + if len(got) != 1: + return f"{len(got)} waits handed it over: {[rc for rc, _ in outs]}" + check("two waits on one round and one submission: exactly one hands it over", two_waits_one_note) + + def later_batch(): # 5.4 / 9.5: E1 taken, the person writes more on E1, the agent sends the outline's second page + p = film_at_script("late") + w = waiter(p) + if not armed(p): + return "the wait did not start" + f1 = submit(p, "E1", "开头再短点") + w.communicate(timeout=20) + time.sleep(1.1) + f2 = submit(p, "E1", "补交一条", "补交两条") + un = F.unread(p) + if [(f.name, late) for f, _, late in un] != [(f2.name, True)]: + return f"unread after a later batch: {[(f.name, late) for f, _, late in un]}" + o = status(p) + n = o["now"] + if n["code"] != "notes_late" or "被取走以后又交了 2 条" not in n["say"]["zh"] or "正在取" in json.dumps(n, ensure_ascii=False) \ + or "现在没有 AI 在等" not in (n["more"] or {}).get("zh", "") or "desk wait" not in " ".join(o["next_step"]["commands"]): + return f"status with a later batch nobody waits for: {n['code']} {n['say']} {n['more']} next {o['next_step']}" + answer(p, f1.name) + page(p, "1b", {"summary": "大纲改成 3 段,再看一遍", "decisions": [{"id": "go", "question": "大纲能做分镜了吗?", "options": [{"id": "OK", "label": "可以"}, {"id": "FIX", "label": "先改"}], "recommend": "OK"}]}) + o = status(p) + st1 = next(x for x in o["stations"] if x["id"] == "1") + n = o["now"] + if st1["state"] != "waiting_person" or n["code"] != "notes_late" or "大纲也出来了" not in (n["more"] or {}).get("zh", "") \ + or (n["act"] or {}).get("mod") != "outline" or not any(x["late"] and x["round"] == "E1" for x in o["review"]["unread"]): + return f"with the outline's second page out: stop ① {st1['state']}, {n['code']} {n['more']} {n['act']}" + w = waiter(p) + out, _ = w.communicate(timeout=20) + if w.returncode != 0 or "补交两条" not in out or "a later batch" not in out or "Nothing has come for round 1b" not in out: + return f"the next wait: exit {w.returncode}: {out[-400:]}" + w = waiter(p) + if not armed(p): + return "the 1b wait did not start" + o = status(p) + n = o["now"] + w.kill(); w.wait() + if n["code"] != "waiting_you" or "大纲出来了,等你看" not in n["say"]["zh"] or (n["act"] or {}).get("mod") != "outline": + return f"the outline's second page, a wait on it: {n['code']} {n['say']} {n['act']}" + check("notes written after their round was taken are a later batch: bin/vh status says so first (nobody has them, nobody waits) and names the " + "command, the outline's second page waits for the person on the outline, and the next wait hands the batch over at once, said for what it is", + later_batch) + + def nothing_left_behind(): # a wait that times out, then a submission: unread for status and the next wait; "正在取" only for a live wait on this round + p = film_at_script("left") + w = waiter(p, timeout=2) + w.communicate(timeout=20) + submit(p, "E1", "超时以后才交的") + o = status(p) + if w.returncode != 3 or [x["round"] for x in o["review"]["unread"]] != ["E1"] or o["now"]["code"] != "notes_unheard": + return f"after a timeout: exit {w.returncode}, unread {o['review']['unread']}, {o['now']['code']}" + stale = p / "out" / "review" / "feedback" / ".listening" # a live wait that waits for another round (a page no longer out) takes nothing + sleeper = subprocess.Popen(["sleep", "30"]) + BG.add(sleeper.pid) + stale.write_text(json.dumps({"pid": sleeper.pid, "since": time.time() - 1, "until": time.time() + 60, "project": os.path.realpath(str(p)), "agent": None, "round": "1"})) + n = status(p)["now"] + sleeper.kill(); sleeper.wait(); stale.unlink() + if n["code"] == "notes_sent" or "正在取" in json.dumps(n, ensure_ascii=False): + return f"a wait on another round counted as taking these notes: {n['code']} {n['say']}" + w = waiter(p) + out, _ = w.communicate(timeout=20) + if w.returncode != 0 or "超时以后才交的" not in out: + return f"the next wait: exit {w.returncode} {out[-300:]}" + check("a wait that ends without a submission leaves every note for bin/vh status and the next wait, and \"正在取\" is said only for a live wait on " + "the round that is out", nothing_left_behind) + + def open_agent(): # an agent outside Studio's window that ran a command on the film and is still open: no "stopped"; said where it is, + # that words typed in Studio do not reach it, and a second AI here only as a second line that asks once more in those words o = stage("open") a = fake_agent("bash", str(vh), "peaks", str(o)) if a is None: @@ -2263,11 +2417,38 @@ def open_agent(): # an agent that ran a command on the film and is still open: n = status(o)["now"] a.kill(); a.wait() m = status(o)["now"] - if n["code"] != "agent_open" or not n["act"].get("secondary") or not n["act"].get("confirm") or "没有 agent" in n["say"]["zh"]: + act = n["act"] + if n["code"] != "agent_outside" or not act.get("secondary") or not act.get("confirm") or "没有 agent" in n["say"]["zh"] \ + or "窗口外面的 Claude Code" not in n["say"]["zh"] or "收不到" not in n["say"]["zh"] or "另起一个 AI" not in act["label"]["zh"] \ + or "两个一起做" not in (act.get("sure_note") or {}).get("zh", "") or "outside this window" not in n["say"]["en"]: return f"while it is open: {n}" - if m["code"] == "agent_open": + if m["code"] in ("agent_open", "agent_outside"): return f"after it went: {m['code']}" - check("an agent that ran a command on the film and is still open: said so, and the offer to carry on is a second line that asks once more", open_agent) + check("an agent outside Studio's window that ran a command on the film and is still open: said so by name, that what is typed in Studio does " + "not reach it, and a second AI here only as a second line that asks once more, saying two would work at once", open_agent) + + def studio_agent(): # an agent Studio's own column started (under tools/desk/desk.py): the old offer, no "outside" + o = stage("own") + cc = shutil.which("cc") + if not cc or fake_agent("true") is None: + return None + shim = T / "studio-shim" / "tools" / "desk" / "desk.py" # a stand-in desk server: its command line names tools/desk/desk.py + shim.parent.mkdir(parents=True, exist_ok=True) + shim.write_text("import subprocess, sys, time\np = subprocess.Popen(sys.argv[1:])\np.wait()\ntime.sleep(600)\n") + e = {k: v for k, v in env.items() if k != "OVH_ACTIVITY_AGENT"} + d = subprocess.Popen([sys.executable, str(shim), str(T / "agentbin" / "claude"), "bash", str(vh), "peaks", str(o)], + stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, env=e, start_new_session=True) + BG.add(d.pid) + time.sleep(3) + n = status(o)["now"] + try: + os.killpg(d.pid, signal.SIGKILL) + except OSError: + pass + d.wait() + if n["code"] != "agent_open": + return f"Studio's own agent: {n['code']} {n['say']}" + check("an agent Studio's own column started is not said to be outside the window", studio_agent) def reused_pid(): # a pid a later process took is not the run's, nor the lock holder's o = stage("reused") @@ -2339,6 +2520,46 @@ def click_path(): # the carry-on click through agent.js itself: its own words check("the carry-on click through agent.js: its own words go to the film's conversation; refused, \"anyway\" sends those words again, not the box's draft; " "a click that is not the person's sends nothing", click_path) + def outside_ask(): # an agent outside Studio's window holds the film: nothing starts in the column until the person says, in those words + node = shutil.which("node") + if not node: + return None + prog = r""" +const vm = require("vm"), fs = require("fs"); +const el = () => new Proxy(function () {}, { get: (t, k) => k === "classList" ? { toggle() {}, add() {}, remove() {}, contains: () => false } : k === "dataset" ? {} : + k === "value" ? "" : k === "hidden" ? false : k === "querySelector" ? () => null : k === "querySelectorAll" ? () => [] : k === Symbol.toPrimitive ? () => "" : el(), + set: () => true, apply: () => el() }); +const shown = []; +const doc = { querySelector: (q) => (q === "#agBusy" ? new Proxy(el(), { set: (t, k, v) => { if (k === "innerHTML") shown.push(String(v)); return true; } }) : el()), querySelectorAll: () => [], + documentElement: { lang: "" }, getElementById: () => el(), addEventListener() {} }; +const posts = []; +const g = vm.createContext({ console, document: doc, window: {}, localStorage: { getItem: () => null, setItem() {} }, setTimeout, clearTimeout, clearInterval, setInterval, + requestAnimationFrame: () => 0, toast() {}, EventSource: class { constructor() {} addEventListener() {} close() {} }, LANG: "zh", + D: { status: { holder: { program: "codex", outside: true } } }, + getJSON: async () => ({ ok: true, data: { agents: [{ kind: "claude", label: "Claude Code", installed: true }], sessions: [], pid: "p" } }), + fetch: async (u, o) => { const b = JSON.parse(o.body); posts.push([u, b]); return { ok: true, status: 200, json: async () => (u.endsWith("/new") ? { id: "n1", kind: "claude" } : { ok: true }) }; } }); +for (const f of ["core.js", "agent.js"]) vm.runInContext(fs.readFileSync(process.argv[1] + "/" + f, "utf8") + (f === "agent.js" ? "\nthis.AGENT = AGENT;" : ""), g); +(async () => { + await g.AGENT.enter("film~1"); + await g.AGENT.tell({ isTrusted: true }, "接着做这支片子。"); + const before = posts.length, asked = shown.filter((h) => h.includes("窗口外面的 Codex") && h.includes("另起一个 AI")).length; + await g.AGENT._again({ isTrusted: true }); + console.log(JSON.stringify({ before, asked, after: posts.map(([u, b]) => [u.split("/").slice(-2).join("/"), b.text || "", !!b.despite]) })); process.exit(0); +})().catch((e) => { console.log(JSON.stringify({ error: String(e && e.stack || e) })); process.exit(0); }); +""" + out = subprocess.run([node, "-e", prog, str(HERE / "static")], capture_output=True, text=True, timeout=30) + try: + r = json.loads(out.stdout.strip().splitlines()[-1]) + except (ValueError, IndexError): + return (out.stdout + out.stderr)[-400:] + if r.get("error"): + return r["error"][:400] + said = [x for x in r["after"] if x[0].endswith("/say") or x[0].endswith("/new")] + if r["before"] != 0 or not r["asked"] or [x[0].split("/")[-1] for x in said] != ["new", "say"] or said[-1][1] != "接着做这支片子。" or not said[-1][2]: + return r + check("an agent outside Studio's window holds the film: the column starts nothing and asks, naming it and saying a second AI would work on the same " + "film; only \"另起一个 AI\" starts one and sends the words", outside_ask) + g = stage("wait", "3") def stop_waits(): diff --git a/tools/desk/test_page.py b/tools/desk/test_page.py new file mode 100644 index 00000000..d39b94bd --- /dev/null +++ b/tools/desk/test_page.py @@ -0,0 +1,172 @@ +"""Studio's page in a headless Chrome (tools/ci.sh desk_checks): what the person sees of their notes' hand-over, on copies +of the demo film, a desk of these checks' own on a free port, nothing sent anywhere else. One line a check on stdout: +"ok\t", "bad\t: ", or "skip\t: " (no Chrome or no node), then "end". + + python3 tools/desk/test_page.py + +The page is driven by tools/desk/page_driver.mjs (the repo's own headless Chrome launcher, tools/textcheck/browser.mjs). +""" +import json, os, re, shutil, signal, subprocess, sys, time +from pathlib import Path + +HERE = Path(__file__).resolve().parent +ROOT = HERE.parent.parent +sys.path.insert(0, str(HERE)) +T = Path(sys.argv[1]).resolve() if len(sys.argv) > 1 else sys.exit("usage: python3 tools/desk/test_page.py ") +VH = ROOT / "bin" / "vh" +ENV = dict(os.environ, HOME=str(T / "home"), TMPDIR=str(T / "tmp"), XDG_CACHE_HOME=str(T / "cache"), XDG_DATA_HOME=str(T / "data"), + XDG_CONFIG_HOME=str(T / "config"), OVH_PROJECTS=str(T / "none"), OVH_STUDIO_PROFILES=str(T / "profiles"), + OVH_STUDIO_SHELL_PROFILE=str(T / "shellprof"), OVH_STUDIO_SHELL_CACHE=str(T / "shellcache"), OVH_AGENTS_DIR=str(T / "agents"), + OVH_LOCAL_MD="/dev/null/LOCAL.md", OVH_STUDIO_SHELL="none", OVH_STUDIO_BROWSER="none", OVH_GATE_STUDIO="0", OVH_KEYSTORE="none", + BROWSER="/usr/bin/true", OVH_ACTIVITY_AGENT="0") +for k in ("HOME", "TMPDIR", "XDG_CACHE_HOME", "XDG_DATA_HOME", "XDG_CONFIG_HOME"): + Path(ENV[k]).mkdir(parents=True, exist_ok=True) +os.environ.update({k: ENV[k] for k in ("TMPDIR", "OVH_ACTIVITY_AGENT")}) +import feedback as F # noqa: E402 +import server # noqa: E402 + + +def say(kind, what, why=""): + print(f"{kind}\t{what}" + (f": {why}" if why else ""), flush=True) + + +def chrome(): + for p in (os.environ.get("CHROME_PATH"), "/Applications/Google Chrome.app/Contents/MacOS/Google Chrome", "/usr/bin/google-chrome", + "/usr/bin/google-chrome-stable", "/usr/bin/chromium", "/usr/bin/chromium-browser"): + if p and os.access(p, os.X_OK): + return p + return None + + +def film(name, gate_e1): + """A copy of the demo film at its script stop (gate ① decided, page E1 out).""" + p = T / "root" / name + shutil.copytree(ROOT / "tools" / "desk" / "fixtures" / "demo", p) + g = p / "out" / "review" + for x in ("gate-2.json", "gate-3.json"): + (g / x).unlink() + r = (p / "REVIEW.md").read_text(encoding="utf-8") + (p / "REVIEW.md").write_text(r[:r.index("## 关卡 ② 分镜")], encoding="utf-8") + (g / "gate-E1.json").write_text(json.dumps(gate_e1, ensure_ascii=False), encoding="utf-8") + subprocess.run(["bash", str(VH), "review", str(p), "E1"], capture_output=True, text=True, env=ENV, timeout=60, check=True) + return p + + +def key(p): + return server.keyify(p.name, p) + + +def drive(url, steps): + r = subprocess.run(["node", str(HERE / "page_driver.mjs"), BROWSER], input=json.dumps({"url": url, "width": 1440, "height": 900, "steps": steps}), + capture_output=True, text=True, timeout=300, env=ENV) + out = {} + for line in r.stdout.splitlines(): + try: + j = json.loads(line) + out[j.get("name")] = j + except ValueError: + pass + if not out: + raise RuntimeError(f"the page driver said nothing: {(r.stdout + r.stderr)[-400:]}") + return out + + +def v(res, name): + x = res.get(name) or {} + return x.get("value") if "error" not in x else f"<{x['error']}>" + + +BROWSER = chrome() +if not BROWSER or not shutil.which("node"): + say("skip", "Studio's page in a headless Chrome", "no Chrome" if not BROWSER else "no node") + print("end") + sys.exit(0) + +E1 = {"summary": "旁白稿第一版,逐句看", "decisions": [{"id": "names", "question": "英文名念不念?", "options": [{"id": "N1", "label": "不念"}, {"id": "N2", "label": "念"}], "recommend": "N1"}, + {"id": "go", "question": "旁白稿能定吗?", "options": [{"id": "OK", "label": "可以,往下做"}, {"id": "FIX", "label": "先改"}], "recommend": "OK"}], + "appendix": [{"title": "大纲", "text": "| 段落 | 时间 |\n|---|---|\n| 开场 | 0–9 s |"}, {"title": "事实清单", "text": "- 一天两次"}, {"title": "引用", "text": "- 某教材"}], + "decided": ["立意:从海边讲起"], "delegated": ["配音用男声"]} +late = film("late", E1) # the script's round was submitted and an agent took it; the person writes more +first = F.save(late, F.validate(late, {"round": "E1", "lang": "zh", "decisions": {"names": "N1", "go": "OK"}, "items": [{"target": "seg:1", "status": "change", "text": "开头再短点"}]})) +F.mark_consumed(late, [first]) # (as an agent's wait or desk feedback leaves it) +fix = film("fix", E1) # nothing submitted yet: "先改" picked with no note +busy = film("busy", dict(E1, least_sure=[{"id": f"c0{i}", "note": f"第 {i} 句会不会太书面,念出来像在读稿"} for i in range(1, 5)])) # eight notes kept beside a full column: the newest and the state line on screen at 1440 x 900 + +proc = subprocess.Popen([sys.executable, str(HERE / "fixtures" / "with_tty.py"), "bash", str(VH), "desk", "--root", str(T / "root"), "--port", "0", "--no-open", "--print-address"], + stdout=subprocess.PIPE, stderr=subprocess.STDOUT, text=True, env=ENV, start_new_session=True) +url, t0, seen = None, time.time(), "" +try: + while time.time() - t0 < 30 and not url: + line = proc.stdout.readline() + seen += line + m = re.search(r"(http://127\.0\.0\.1:\d+/\?c=[A-Za-z0-9_-]+)", line) + url = m.group(1) if m else None + if not url: + say("bad", "Studio's page: the desk did not start", seen[-300:]) + print("end") + sys.exit(0) + tab = {"click": "#colTabs [data-tab=round]", "name": "tab"} + KEEP = "(FB.items[{t!r}] = {{ status: 'change', text: {x!r}, label: {lb!r} }}, save(), renderColumn(), true)" + steps = [ + {"go": f"#/p/{key(late)}/outline", "after": 2500}, tab, + {"eval": KEEP.format(t="seg:2", x="这段再短一点", lb="大纲 第 2 段"), "name": "keep"}, + {"eval": "$('#colRound').innerText", "name": "late_bar"}, + {"eval": "$('#cMine').innerText", "name": "late_block"}, + {"click": "#openConfirm"}, {"eval": "$('#submitHint').innerText", "name": "late_sheet"}, + {"click": "#doSubmit", "after": 3000}, + {"until": "$('#cMine') && /补交的 1 条,还没人取/.test($('#cMine').innerText) && $('#colRound').innerText", "name": "late_after", "ms": 10000}, + {"go": f"#/p/{key(fix)}/outline/script", "after": 2500}, tab, + {"eval": "(pick('go', 'FIX'), true)", "name": "pick"}, + {"click": "#openConfirm"}, + {"eval": "JSON.stringify({ ask: ($('#fixAsk') || {}).innerText || '', back: !!$('#fixBack'), go: ($('#doSubmit') || {}).innerText })", "name": "fix_sheet"}, + {"click": "#fixBack"}, + {"eval": "JSON.stringify({ hidden: $('#confirm').hidden, focus: document.activeElement && document.activeElement.id })", "name": "fix_back"}, + {"eval": "(FB.general = '第三句改口语', save(), true)", "name": "general"}, + {"click": "#openConfirm"}, + {"eval": "JSON.stringify({ ask: ($('#fixAsk') || {}).innerText || '', back: !!$('#fixBack') })", "name": "fix_with_note"}, + {"click": "#noSubmit"}, + {"go": f"#/p/{key(busy)}/outline/script", "after": 2500}, tab, + {"eval": "(" + ", ".join(KEEP.format(t=f"cap:c0{i}", x=f"第 {i} 句再口语一点", lb=f"字幕 c0{i}") for i in range(1, 9)) + ")", "name": "eight"}, + {"wait": 800}, + {"eval": "JSON.stringify((() => { const m = $('#cMine'), h = $('#cMine .blk-h'), n = $('#cMine li[data-goto=\"cap:c08\"]'), r = (e) => e && e.getBoundingClientRect(); " + "const H = r(h), N = r(n), M = r(m), B = r($('#colBody')); return { h: H && [H.top, H.bottom], n: N && [N.top, N.bottom], m: M && [M.top, M.bottom], " + "body: [B.top, B.bottom], text: h && h.innerText }; })())", + "name": "busy_view"}, + ] + res = drive(url, steps) +finally: + try: + os.killpg(proc.pid, signal.SIGTERM) + except OSError: + pass + proc.wait(timeout=10) + + +def check(what, ok, why): + say("ok" if ok else "bad", what, "" if ok else str(why)[:500]) + + +bar, block, sheet, after = v(res, "late_bar") or "", v(res, "late_block") or "", v(res, "late_sheet") or "", res.get("late_after") or {} +check("a round an agent already took: the bar says these notes go on their own as a later batch (补交), the notes block says the earlier ones were " + "picked up, the sheet says so before sending and who picks them up; after sending, the block says they are not picked up yet, never that they went to the agent", + "补充 1 条" in bar and "补交" in bar and "已经交给" not in bar and "还没交 1 条" in block and "取走" in block and "已经被 AI 取走了" in sheet + and "单独交" in sheet and "现在没有 AI 在等" in sheet and after.get("ok") and "交了,还没人取" in str(after.get("value")) and "已经交给 agent" not in str(after.get("value")), + [bar, block, sheet, after]) +fs, fb, fn = v(res, "fix_sheet"), v(res, "fix_back"), v(res, "fix_with_note") +try: + fs, fb, fn = json.loads(fs), json.loads(fb), json.loads(fn) + ok = "先改" in fs["ask"] and "还没写改哪里" in fs["ask"] and fs["back"] and fs["go"] == "就这样交" and fb["hidden"] and fb["focus"] == "say" and not fn["back"] and not fn["ask"] +except (TypeError, ValueError, KeyError): + ok = False +check("\"先改\" picked with no note: the sheet asks what to change, \"回去写\" closes it with the note box ready, \"就这样交\" still sends; with a note it does not ask", + ok, [fs, fb, fn]) +bv = v(res, "busy_view") +try: + b = json.loads(bv) + def seen(x): # inside the column's visible part, and inside the block's own + return x[0] >= b["body"][0] - 1 and x[1] <= min(b["body"][1], b["m"][1]) + 1 + ok = b["h"] and b["n"] and seen(b["h"]) and seen(b["n"]) and b["n"][0] >= b["h"][1] - 2 and "还没交 8 条" in b["text"] +except (TypeError, ValueError, KeyError): + ok = False +check("eight notes kept beside two decisions, four unsure places and three appendices at 1440 x 900: the notes' state line and the note kept last are on screen, no scrolling", ok, bv) +print("end", flush=True) diff --git a/tools/gate.py b/tools/gate.py index 5ecabe96..1bd61dc2 100644 --- a/tools/gate.py +++ b/tools/gate.py @@ -20,8 +20,9 @@ page, once, within ten minutes, to your terminal alone (the message says only where it is). Refused with no terminal (an agent's shell has none) and while this film's desk runs (bin/vh desk link --print-address) --wait the desk channel: then wait like bin/vh desk wait (exit 0 only when a submission was received, and it is - printed; 3 after --timeout, default 7100 s; 4 when the agent it waits for is gone; 6 when the desk it waits on - closed). Hosts with background wakeup can run this in the background: the message is printed first. A standard + printed; 3 after --timeout, default 43200 s (12 h); 4 when the agent it waits for is gone; 6 when the desk it + waits on closed; 7 when another page went out before anything came for this one: run bin/vh status and wait on + the round open now). Notes nobody has taken yet, of any round, are printed first. Hosts with background wakeup can run this in the background: the message is printed first. A standard film's stop that went out as the static page by default (Studio not open): the page goes out as usual, exit 5: nothing was answered; end the turn and wait for the person's reply in the chat --init write out/review/gate-.json as a skeleton for this stop, in the BRIEF's review language, and stop: every text @@ -38,7 +39,8 @@ Stops line: REVIEW.md lacks the person's words and "定了:…" for it, or the user's own words waiving it) · 3 --wait timed out · 4 --wait: the agent it waited for is gone · 5 --wait, and a standard film's stop went out as the static page by default (Studio not open): the page goes out as usual; nothing was answered; end the turn and wait for the person's reply in the chat -(stdout is the message to pass on, as without --wait) · 6 --wait: the desk it waited on closed. +(stdout is the message to pass on, as without --wait) · 6 --wait: the desk it waited on closed · 7 --wait: another page went out +before anything came for this one: run bin/vh status, and wait on the round open now. """ import argparse, contextlib, json, os, re, sys from pathlib import Path @@ -307,7 +309,7 @@ def main(argv): for c in ("desk", "page", "chat"): how.add_argument(f"--{c}", dest="channel", action="store_const", const=c, help=f"review in the {c} this time") ap.add_argument("--wait", action="store_true", help="the desk only: then wait for the submission, like bin/vh desk wait") - ap.add_argument("--timeout", type=float, default=7100, help="with --wait: seconds (default 7100)") + ap.add_argument("--timeout", type=float, default=43200, help="with --wait: seconds (default 43200: 12 h)") ap.add_argument("--port", type=int, help="the desk's port when it has to start (default: the first free of 8780–8799)") ap.add_argument("--print-address", action="store_true", help="the desk only, for a browser on another machine: open none, write an " "address that opens one page to your terminal alone (refused with no terminal, " @@ -420,7 +422,7 @@ def main(argv): watch = desk_since(info) if info else None except Exception: watch = None - return feedback.wait(project, a.timeout, desk=watch) + return feedback.wait(project, a.timeout, desk=watch, round=page.gate) if __name__ == "__main__": diff --git a/tools/schemas/output/status.schema.json b/tools/schemas/output/status.schema.json index 04f50716..319156d9 100644 --- a/tools/schemas/output/status.schema.json +++ b/tools/schemas/output/status.schema.json @@ -91,6 +91,16 @@ "current": {"type": ["string", "null"]}, "page": {"type": ["string", "null"]}, "desk": {}, + "unread": { + "type": "array", + "description": "The person's submissions no agent has taken yet, of any round (tools/desk/feedback.py's unread), oldest first; late: written after that round had been handed over.", + "items": {"type": "object", "required": ["round", "file", "late"], "properties": {"round": {"type": "string"}, "file": {"type": "string"}, "late": {"type": "boolean"}, "items": {"type": "integer"}, "decisions": {"type": "integer"}}} + }, + "taken": { + "type": "object", + "description": "Each handed-over submission by file name: when (t, epoch seconds), under which agent program and how (wait | feedback); null where an older record does not say.", + "additionalProperties": {"type": "object", "properties": {"t": {"type": ["number", "null"]}, "program": {"type": ["string", "null"]}, "by": {"type": ["string", "null"]}}} + }, "revisions": { "type": "array", "description": "Published comparisons as in review-revision.schema.json, with the reviewer's reply and availability.", @@ -251,7 +261,8 @@ } }, "now": {"$ref": "#/$defs/now"}, - "plan": {"$ref": "#/$defs/plan"} + "plan": {"$ref": "#/$defs/plan"}, + "holder": {"description": "The agent program open on this film now, by name, and whether outside Studio's window (tools/standing.py's holder); null when none is", "type": ["object", "null"], "properties": {"program": {"type": ["string", "null"]}, "outside": {"type": "boolean"}}} }, "$defs": { "words": {"type": "object", "required": ["zh", "en"], "properties": {"zh": {"type": "string"}, "en": {"type": "string"}}}, diff --git a/tools/standing.py b/tools/standing.py index 1c2f4298..ac48751b 100644 --- a/tools/standing.py +++ b/tools/standing.py @@ -155,6 +155,28 @@ "I sent my notes for this stop in Studio. Fetch and read them (bin/vh status says how), then carry on."), "say.resume": ("接着做这支片子:REVIEW.md 里写着暂停,现在恢复,在那里记一节恢复。先跑 bin/vh status 看下一步。", "Carry on with this film: REVIEW.md says paused; it resumes now, so note that there. Run bin/vh status first for the next step."), + # the person's notes nobody has taken, and who holds the film outside Studio's window (new words: the agent by its name + # when known, else "AI"; the step by name; never a file name) + "seen.outline": ("大纲", "the outline"), "seen.script": ("旁白稿", "the script"), + "step.1": ("立意", "the concept"), "step.outline": ("大纲", "the outline"), "step.E0": ("画风样张", "the style frames"), + "step.E1": ("旁白稿", "the script"), "step.2": ("分镜", "the storyboard"), "step.E2": ("配乐安排", "the sound plan"), + "step.E3": ("最终的声音", "the final sound"), "step.3": ("初版", "the first draft"), "step.E4": ("第一章样片", "the first chapter"), + "step.E5": ("定画面的版本", "the picture lock"), "step.notes": ("随手写的意见", "your loose notes"), "step.other": ("这一页", "this page"), + "prog.claude": ("Claude Code", "Claude Code"), "prog.codex": ("Codex", "Codex"), "prog.ai": ("AI", "the AI"), + "notes_late": ("你在{s}那一轮被取走以后又交了 {n} 条,还没有 AI 来取。", "After {s} was picked up you sent {n} more {n_notes}; no AI has picked them up yet."), + "notes_late.short": ("补交的意见还没人取", "later notes not picked up"), + "notes_left": ("你交的 {n} 份意见还没有 AI 来取({s})。", "{N} {n_subs} you sent {are} not picked up by any AI yet ({s})."), + "notes_left.short": ("意见还没人取", "notes not picked up yet"), + "notes_left.live": ("正在等的 {a} 马上会取。", "The {a} that is waiting picks them up at once."), + "notes_left.outside": ("做这支片子的 {a} 在这个窗口外面:回到它那边说一声“我交了”,它就会来取。", "{A}, outside this window, is making this film: tell it \u201cI've sent it\u201d over there and it picks them up."), + "notes_left.next": ("现在没有 AI 在等。下次有 AI 接着做这支片子,会先拿到它们。", "No AI is waiting right now. The next AI to carry on with this film gets them first."), + "notes_left.also": ("{s}也出来了,等你{v}。", "{S} {be} out for you too."), + "agent_outside": ("这支片子正由这个窗口外面的 {a} 在做;在这里打的字,它收不到。", "{A} is making this film outside this window; what you type here does not reach it."), + "agent_outside.more": ("要它接着做,回到它那边说一句。", "To have it carry on, say so over there."), + "agent_outside.short": ("在窗口外面做", "made outside this window"), + "act.second": ("在这里另起一个 AI 做这支片子", "Start a second AI on this film here"), + "act.second_sure": ("确定,另起一个", "Yes, start a second one"), + "act.second_note": ("外面那个 {a} 还开着。两个一起做,可能改到同一处。", "{A} outside is still open. Two working at once may change the same thing."), # the film's plan "plan.secs": ("{n} 秒", "{n} s"), "plan.span": ("{a}–{b} 秒", "{a}–{b} s"), "plan.min": ("{m} 分钟", "{m} min"), "plan.min_s": ("{m} 分 {s} 秒", "{m} min {s} s"), "plan.vertical": ("竖屏", "vertical"), "plan.landscape": ("横屏", "landscape"), "plan.square": ("方屏", "square"), @@ -297,6 +319,100 @@ def listener(project): return False +def taker(project): + """A live wait that takes a new submission within the second: one alive (listener) that waits for the round that is out + now. A wait for a page that is no longer out ends by itself and takes nothing; an older wait that names no round is not + counted on.""" + try: + _desk() + import feedback as F + info = F.listening(project) + return bool(info.get("listening")) and info.get("round") is not None and info.get("round") == F.current_round(project) + except Exception: + return False + + +def unread(project): + """The person's notes no agent has taken yet: [(path, record, late)] (tools/desk/feedback.py).""" + try: + _desk() + import feedback as F + return F.unread(project) + except Exception: + return [] + + +def program_of(agent): + """The agent program's name (claude, codex …) of a run's agent record, or None.""" + try: + import activity + name = os.path.basename(activity._ps(int(agent["pid"]), "comm=") or "") + if name in activity.RUNTIMES: + name = next((os.path.basename(x) for x in activity._ps(int(agent["pid"]), "command=").split() if activity.AGENT_PROGRAMS.match(os.path.basename(x))), name) + return name if activity.AGENT_PROGRAMS.match(name) else None + except Exception: + return None + + +def in_studio(agent): + """Is this agent program one Studio's own column started (it runs under a desk server: tools/desk/desk.py among its + parents)? None when that cannot be told.""" + try: + import activity + p = int(agent["pid"]) + for _ in range(16): + if p <= 1: + return False + line = activity._ps(p, "ppid=,command=").split(None, 1) + if len(line) < 2 or not line[0].isdigit(): + return None + if re.search(r"tools/desk/desk\.py\b", line[1]): + return True + p = int(line[0]) + return False + except Exception: + return None + + +def prog_words(name): + """[zh, en] of an agent program for the person: Claude Code, Codex, else AI.""" + k = f"prog.{name}" if f"prog.{name}" in WORDS else "prog.ai" + return [w(k, 0), w(k, 1)] + + +def has_cards(project, pid): + """Does this review page hold concept cards (an option with a picture: its frame)? A gate ① page without them is about + the outline.""" + try: + d = json.loads((Path(project) / "out" / "review" / f"gate-{pid}.json").read_text(encoding="utf-8-sig")) + return any(isinstance(o, dict) and o.get("frame") for x in d.get("decisions") or [] if isinstance(x, dict) for o in x.get("options") or []) + except (OSError, ValueError, AttributeError, TypeError): + return True + + +def page_of(s): + """The page id a station is at (its latest page), else its own id.""" + return Path(s["page"]).stem[5:] if s.get("page") else s["id"] + + +def stop_place(project, s): + """(module, tab, seen-words key) of what a stop's page asks the person about: a gate ① page with concept cards is the + concept, one without is the outline; E1 is the script, on the outline's script tab; the rest as MOD says.""" + pid = page_of(s) + if s["id"] == "1" and not has_cards(project, pid): + return "outline", None, "seen.outline" + if s["id"] == "E1": + return "outline", "script", f"seen.{s['id']}" + return MOD.get(s["id"], "cut"), None, f"seen.{s['id']}" + + +def step_words(round_id): + """[zh, en] of a round's step by name (旁白稿, 大纲 …), from its page id (1b → gate ①: the concept or outline).""" + m = re.match(r"^(E\d|\d)", str(round_id or "")) + k = "step.notes" if round_id == "notes" else f"step.{m.group(1)}" if m and f"step.{m.group(1)}" in WORDS else "step.other" + return [w(k, 0), w(k, 1)] + + def newest_file(project, limit=4000): """(mtime, path from the project, whole) of the newest change among the film's own files, or None. Where source lives is looked at first (the film's folder, then its folders breadth first, four deep); out/, media/, renders/ … are not its @@ -434,6 +550,16 @@ def open_agent(o, project, newest, now): return None +def holder(project, o, now=None): + """The agent program open on this film now (the one its newest recorded run was started under, alive, and this film its + latest work): {program: claude | codex | … | None, outside: it is not one Studio's own column started}, or None. Studio + names it when it says who picks the person's notes up.""" + held = open_agent(o, project, None, time.time() if now is None else now) + if not held or held[0] != "here": + return None + return {"program": program_of(held[1]), "outside": in_studio(held[1]) is False} + + def say(code, who, you, s, more=None, short=None, act=None, paths=(), tone=None, **facts): """s, short: {zh, en}; more: a list of {zh, en} (None skipped), joined into the line under the sentence.""" parts = [m for m in more or [] if m] @@ -536,14 +662,49 @@ def seen(s): return say("revision_ready", who, "decide", both("revision_ready"), [both("revision_ready.more")], act=act_open("cut", both("act.revision"), "revisions"), revisions=len(revs)) wait = next((s for s in st if s["state"] == "waiting_person"), None) - if wait: - n, many, ear = seen(wait), wait["id"] in PLURAL, wait["id"] in LISTEN + live = taker(project) # a wait alive on the round that is out now: it takes a new submission within the second + un = unread(project) + cur_pid = page_of(nxt) if nxt else None + covered = not un or (wait is None and nxt is not None and fb.get("pending") and all(j.get("round") == cur_pid and not late for _, j, late in un)) + if wait: # what the waiting page asks about: a gate ① page without cards is the outline, E1 is the script (its tab) + mod, tab, seen_key = stop_place(project, wait) + n, many, ear = (both(seen_key) if seen_key in WORDS else seen(wait)), wait["id"] in PLURAL and seen_key != "seen.outline", wait["id"] in LISTEN v = [w("take.listen" if ear else "take.look", i) for i in (0, 1)] + if not covered: # notes the person sent that nobody took: said first, with who takes them; never "received" until a run took them + held0 = open_agent(o, project, None, now) + prog = program_of(held0[1]) if held0 and held0[0] == "here" else None + outside = bool(held0 and held0[0] == "here" and in_studio(held0[1]) is False) + late = [(f, j) for f, j, lt in un if lt] + if late: + r = late[-1][1].get("round") + sw = step_words(r) + if str(r).startswith("1") and not has_cards(project, r): + sw = [w("step.outline", 0), w("step.outline", 1)] + nl = sum(len(j.get("items") or []) + (1 if j.get("general") else 0) + len(j.get("decisions") or {}) for _, j in late if isinstance(j, dict)) + nl = nl or len(late) + head = two(w("notes_late", 0, s=sw[0], n=nl), w("notes_late", 1, s=sw[1], n=nl, n_notes="note" if nl == 1 else "notes")) + code = "notes_late" + else: + rounds = list(dict.fromkeys(str(j.get("round")) for _, j, _ in un)) + sws = [step_words(r) if not (r.startswith("1") and not has_cards(project, r)) else [w("step.outline", 0), w("step.outline", 1)] for r in rounds] + k = len(un) + head = two(w("notes_left", 0, n=k, s=w("plan.list", 0).join(x[0] for x in sws)), + w("notes_left", 1, N=k, n_subs="submission" if k == 1 else "submissions", are="is" if k == 1 else "are", s=w("plan.list", 1).join(x[1] for x in sws))) + code = "notes_left" + a = prog_words(prog) + who_line = (two(w("notes_left.live", 0, a=a[0]), w("notes_left.live", 1, a=a[1])) if live else + two(w("notes_left.outside", 0, a=a[0]), w("notes_left.outside", 1, A=cap(a[1]))) if outside else both("notes_left.next")) + also = two(w("notes_left.also", 0, s=n["zh"], v=v[0]), w("notes_left.also", 1, S=cap(n["en"]), be="are" if many else "is")) if wait else None + act = act_open(mod, two(w("act.look", 0, v=v[0], s=n["zh"]), w("act.look", 1, V=cap(v[1]), s=n["en"])), tab) if wait else \ + (None if (live or outside) else act_tell(both("act.fetch"), both("say.fetch"))) + return say(code, "agent", "none" if live else "nudge", head, [who_line, also], both(code + ".short"), act, + tone="busy" if live else "you", unread=len(un), late=len(late), live=live, outside=outside, program=prog) + if wait: return say("waiting_you", who, "decide", two(w("waiting_you", 0, s=n["zh"], v=v[0]), w("waiting_you", 1, S=cap(n["en"]), be="are" if many else "is", wait="wait" if many else "waits")), [both("waiting_you.listening" if listening else "waiting_you.alone")], two(w("waiting_you.short", 0, s=n["zh"], v=v[0]), w("waiting_you.short", 1, s=n["en"])), - act_open(MOD.get(wait["id"], "cut"), two(w("act.look", 0, v=v[0], s=n["zh"]), w("act.look", 1, V=cap(v[1]), s=n["en"]))), + act_open(mod, two(w("act.look", 0, v=v[0], s=n["zh"]), w("act.look", 1, V=cap(v[1]), s=n["en"])), tab), stop=wait["id"], listening=listening) took = None # when an agent was handed the person's submissions for this stop if fb.get("handed"): @@ -552,13 +713,19 @@ def seen(s): except OSError: took = None if fb.get("pending"): # the newest submission: nobody has it yet, whatever else runs - if listening: # a live listener (and its agent) takes it within the second + if live: # a live listener on this very round (and its agent) takes it within the second return say("notes_sent", who, "none", both("notes_sent"), stop=nxt["id"]) try: tl = clock((project / fb["last"]).stat().st_mtime, now) except (OSError, KeyError, TypeError): tl = clock(now, now) c, pr = (cmd_words(working[0]), progress(working[0])) if working else (None, None) + held0 = open_agent(o, project, None, now) + outside = bool(held0 and held0[0] == "here" and in_studio(held0[1]) is False) + if outside and not c: # the agent that would fetch them is outside this window: what to say there, no button that starts another + a = prog_words(program_of(held0[1])) + return say("notes_unheard", who, "nudge", both("notes_unheard"), [two(w("notes_left.outside", 0, a=a[0]), w("notes_left.outside", 1, A=cap(a[1])))], + stop=nxt["id"], pending=fb["pending"], outside=True) more = [two(w("notes_unheard.busy", 0, x=c[0], p=pr[0], t=tl), w("notes_unheard.busy", 1, X=cap(c[2]), p=pr[1], t=tl)) if pr else two(w("notes_unheard.busy0", 0, x=c[0], t=tl), w("notes_unheard.busy0", 1, X=cap(c[2]), t=tl))] if c else [both("notes_unheard.more")] return say("notes_unheard", who, "nudge", both("notes_unheard"), more, act=act_tell(both("act.fetch"), both("say.fetch")), @@ -634,6 +801,12 @@ def seen(s): return say("stopped", who, "nudge", two(w("stopped", 0, x=short[0]), w("stopped", 1, x=short[1])), [two(w(k, 0, a=a[0], x=why[0]), w(k, 1, a=a[1], X=cap(why[1]))), read, has, later, away], act=act_tell(both("act.carry"), two(w("say.stopped", 0, x=why[0]), w("say.stopped", 1, x=why[1]))), paths=paths) # (it broke: nothing to ask twice) + if agent and in_studio(agent[1]) is False: # an agent outside this window: Studio cannot reach that conversation, and says so + a = prog_words(program_of(agent[1])) + sec = act_tell(both("act.second"), both("say.carry"), confirm=True, secondary=True) + sec.update(sure=both("act.second_sure"), sure_note=two(w("act.second_note", 0, a=a[0]), w("act.second_note", 1, A=cap(a[1])))) + return say("agent_outside", who, "offer", two(w("agent_outside", 0, a=a[0]), w("agent_outside", 1, A=cap(a[1]))), + [both("agent_outside.more"), lastw, read, later], act=sec, paths=paths, program=program_of(agent[1])) if agent: return say("agent_open", who, "offer", both("agent_open"), [lastw, read, later], act=act_tell(both("act.carry_open"), both("say.carry"), confirm=True, secondary=True), paths=paths) diff --git a/tools/status.py b/tools/status.py index e98ae167..1f2b661e 100644 --- a/tools/status.py +++ b/tools/status.py @@ -255,6 +255,16 @@ def on_file(s): st["state"] = "waiting_person" elif latest is not None: st["state"], st["note"] = "waiting_agent", f"this round moved on to {cur}; REVIEW.md has no decision for {pid}" + # a later page of gate ① (1b: the outline again, after the concept was decided) that is out now and that nothing + # answers yet: gate ①'s record stays as bin/vh render and check read it, but the page waits for its own answer + if key == "1" and st["state"] == "done" and latest is not None and pid == cur and len(plist) > 1 and pid != plist[0].stem[5:] \ + and latest.with_suffix(".html").exists() and R.refusal(project, pid) is None and not (page_secs and G.record(page_secs[-1][1])[0]): + if pend: + st["state"], st["note"] = "waiting_agent", f"{len(pend)} submission(s) for page {pid} not handed to the agent yet (bin/vh desk feedback)" + elif handed: + st["state"], st["note"] = "waiting_agent", f"the submission for page {pid} was handed over; REVIEW.md has no decision for it yet" + else: + st["state"], st["note"] = "waiting_person", f"page {pid} is out and waits for its own answer (gate ① itself is on record)" if how == "stop_older" and st["state"] not in ("done", "skipped", "no_record"): st["note"] = ((st["note"] + "; ") if st["note"] else "") + \ f"its REVIEW.md section has a decision, but names no page and is older than the page: not counted (its 页面 line: {stub})" @@ -596,8 +606,29 @@ def film_state(project, by_video): is_final = G.is_final # a film that counts as the delivery (tools/gatecheck.py) -def next_step(project, proj, st, paused, no_record, working, desk, by_video): - """{who, do, commands, read, unfilled}: who has the next move at the stop the project is at, and how to take it.""" +def unread_line(unread): + """The rounds of the notes no agent has taken, in words: "E1 (a later batch, written after it was taken)", "1b".""" + by = {} + for x in unread: + by.setdefault(x["round"], []).append(x) + return ", ".join(f"{r} ({len(xs)} submission(s)" + (", a later batch written after that round was taken" if any(x["late"] for x in xs) else "") + ")" + for r, xs in by.items()) + + +def unread_covered(st, unread): + """The notes no agent has taken are all the stop-at-hand's own new submission, which its waiting_agent line already + says how to read: nothing more to say about them.""" + s = next((x for x in st if x["state"] in ("waiting_agent", "in_progress")), None) + if not unread or any(x["state"] == "waiting_person" for x in st) or s is None or not (s.get("feedback") or {}).get("pending"): + return not unread + pid = Path(s["page"]).stem[5:] if s["page"] else s["id"] + return all(x["round"] == pid and not x["late"] for x in unread) + + +def next_step(project, proj, st, paused, no_record, working, desk, by_video, unread=()): + """{who, do, commands, read, unfilled}: who has the next move at the stop the project is at, and how to take it. + unread: the person's notes no agent has taken yet (feedback.unread): unless they are just the stop's own new submission, + reading them comes before anything else, a stop that waits for the person included.""" p = shown(project) left = unfilled(project) state = {x["id"]: x["state"] for x in st} @@ -618,6 +649,10 @@ def out(who, do, commands=(), read=()): busy = f"{working[0]['cmd']} is running (bin/vh activity {p}); when it ends: " if working else "" if paused: return out("person", "paused (REVIEW.md): the person resumes it") + if not unread_covered(st, unread): # notes the person sent that nobody took: before anything else, and never left behind + return out("agent", busy + f"read the notes the person sent in Studio that no agent has taken yet: round {unread_line(unread)}. " + "bin/vh desk wait hands every one over at once (exit 0 straight away); write what you decide under each one's section " + "in REVIEW.md, then go on", [f"bin/vh desk wait {p}"], [R_DESK]) wait = next((s for s in st if s["state"] == "waiting_person"), None) if wait: where = f"the desk {desk['url']}" if desk else wait["page"] or "the chat" @@ -895,11 +930,21 @@ def collect(project, now=None, light=False): warnings = [] _, todo = reader._facts(reader.strip_comments(reader._read(project / "NOTES.md", warnings)), warnings) facts = [x["text"] for x in todo if not x["done"] and not x["text"].startswith("{")] # not the template's {claim} line + # the person's notes no agent has taken yet, of any round (tools/desk/feedback.py's unread): never left behind + try: + took = F.taken(project) + unread = [{"round": text(j.get("round")), "file": rel(project, f), "late": late, "submitted_at": text(j.get("submitted_at")), + "items": len(j.get("items") or []) if isinstance(j.get("items"), list) else 0, "decisions": len(j.get("decisions") or {}) if isinstance(j.get("decisions"), dict) else 0} + for f, j, late in F.unread(project)] + except Exception: + took, unread = {}, [] # who is waited on, and the next step in one line waiting = [s for s in st if s["state"] == "waiting_person"] agent = [s for s in st if s["state"] in ("waiting_agent", "in_progress")] if paused: waiting_on, nxt = "person", "paused (REVIEW.md): the person resumes it" + elif not unread_covered(st, unread): + waiting_on, nxt = "agent", f"the agent: read the person's notes no agent has taken yet (round {unread_line(unread)})" elif waiting: s = waiting[0] waiting_on, nxt = "person", f"the person: review {s['name']} on " + (f"the desk {desk['url']}" if desk else s["page"] or "the chat") @@ -964,19 +1009,20 @@ def vinfo(v, s): out = {"version": 1, "project": proj, "paused": paused, "waiting_on": waiting_on, "next": nxt, "stations": st, "stops": {"gates": plan["gates"], "checkpoints": plan["checkpoints"], "line": plan["line"], "costly": [c["say"] for c in plan["costly"]], "kept": plan["kept"], "note": G.plan_note(plan)}, - "review": {"current": cur, "page": cur_stop["page"] if cur_stop else None, "desk": desk, + "review": {"current": cur, "page": cur_stop["page"] if cur_stop else None, "desk": desk, "unread": unread, + "taken": {k: {"t": v.get("t"), "program": v.get("program"), "by": v.get("by")} for k, v in took.items()}, "revisions": RV.listing(project)}, # a few small records: the space's card says when a change waits for review "open": {"review_items": open_items, "facts_to_verify": facts}, "renders": [vinfo(v, s) for v, s in vids[:10]], "deliveries": deliveries, "versions": vers, "check": check_summary(project, *checks[0]) if checks else None, "assets": assets, "cast": cast, "research": research, "activity": {"running": working, "listening": listening, "recent": recent, "key_stop": standing.key_stop(runs)}, # (the whole log: a stop for an API Key nothing settled) - "media": None, "next_step": None, "now": None, "plan": None} + "media": None, "next_step": None, "now": None, "plan": None, "holder": None} try: # what cannot be read is said, never a failure of status out["media"] = media(project) except Exception as e: out["media"] = {"film": None, "version": None, "from": None, "proxy": None, "thumbs": None, "peaks": None, "stale": [], "error": f"{type(e).__name__}: {e}"} try: # not the command that asks (bin/vh new); what cannot be worked out is said, never a failure of status - out["next_step"] = next_step(project, proj, st, paused, no_record, [r for r in working if r.get("run") != os.environ.get("OVH_ACTIVITY_RUN")], desk, by_video) + out["next_step"] = next_step(project, proj, st, paused, no_record, [r for r in working if r.get("run") != os.environ.get("OVH_ACTIVITY_RUN")], desk, by_video, unread) except Exception as e: out["next_step"] = {"who": "unknown", "do": f"the next step could not be worked out ({e})", "commands": [], "read": [], "unfilled": {}} try: # where it stands for the person, in a sentence (tools/standing.py): what Studio says too @@ -988,6 +1034,10 @@ def vinfo(v, s): out["plan"] = standing.plan_line(out) except Exception: out["plan"] = None + try: # who is open on the film, by name, and whether outside Studio's window: who picks the person's notes up + out["holder"] = standing.holder(project, out, now) + except Exception: + out["holder"] = None return out @@ -1026,6 +1076,10 @@ def show(o, now): a = nw.get("act") or {} if a.get("kind") == "open": # (no command here: an agent reads this too, and a window nobody asked for is no help) print(f" the person does this in Studio: {a['label']['en']}") + un = (o.get("review") or {}).get("unread") or [] + if un: # the person's notes nobody took: said on a line of their own, whatever the next step is + print(f"unread: {len(un)} submission(s) from Studio no agent has taken yet: round {unread_line(un)} " + f"(bin/vh desk wait {shown(Path(p['path']))} hands them over)") ri, fv = o["open"]["review_items"], o["open"]["facts_to_verify"] if ri or fv: print("open: " + " · ".join(x for x in (f"{len(ri)} review item(s) (round {', '.join(dict.fromkeys(str(i['round']) for i in ri))})" if ri else "", From 1ece33e8897e7c67396ff3c2694c5de69212e49c Mon Sep 17 00:00:00 2001 From: zhanglinghao Date: Mon, 23 Nov 2026 16:27:39 +0800 Subject: [PATCH 2/7] Hand-over fixes from the full check run: status's terminal view leaves out the outside-agent line (the agent reading it is that agent); unread counts only submissions as Studio saves them; the output schemas name the new codes and fields; the notes block's edge uses a theme colour --- tools/desk/feedback.py | 3 ++- tools/desk/static/studio.css | 2 +- tools/schemas/output/projects.schema.json | 2 +- tools/schemas/output/status.schema.json | 7 +++---- tools/status.py | 2 +- 5 files changed, 8 insertions(+), 8 deletions(-) diff --git a/tools/desk/feedback.py b/tools/desk/feedback.py index 168a77ca..463782a1 100644 --- a/tools/desk/feedback.py +++ b/tools/desk/feedback.py @@ -416,7 +416,8 @@ def unread(project): late)]. late: a submission of the same round was handed over before it (the person wrote more after the round was taken). These are what the next wait hands over first, and what bin/vh status puts before any other work.""" done, ans = consumed(project), answered(project) - recs = sorted(_records(project), key=lambda x: _order(*x)) + recs = sorted(((f, j) for f, j in _records(project) if isinstance(j.get("round"), str) and ROUND.match(j["round"]) and isinstance(j.get("submitted_at"), str)), + key=lambda x: _order(*x)) # (submissions as save() writes them: a stray or broken file is no note of the person's) out = [] for i, (f, j) in enumerate(recs): if f.name in done or f.name in ans: diff --git a/tools/desk/static/studio.css b/tools/desk/static/studio.css index f5b8893d..7920a4ac 100644 --- a/tools/desk/static/studio.css +++ b/tools/desk/static/studio.css @@ -210,7 +210,7 @@ html.shell-other .topbar{padding-right:calc(14px + 100vw - env(titlebar-area-x, .col-body .next .raw{color:var(--ink-3);font-size:var(--fs-label)} .col-body .quiet-line{color:var(--ink-2)} /* the notes and their state, pinned to the column's foot right above the note box: what was just kept is seen without scrolling */ -.col-body .c-mine{position:sticky;bottom:-14px;margin:0 -16px -14px;padding:10px 16px 12px;max-height:42vh;overflow:auto;background:var(--panel);border-top:1px solid var(--rule);box-shadow:0 -10px 14px -12px rgba(0,0,0,.35);z-index:1} +.col-body .c-mine{position:sticky;bottom:-14px;margin:0 -16px -14px;padding:10px 16px 12px;max-height:42vh;overflow:auto;background:var(--panel);border-top:1px solid var(--rule-2);z-index:1} .col-body .c-mine .blk-h{position:sticky;top:-10px;margin:-10px 0 4px;padding:10px 0 4px;background:var(--panel);z-index:1} /* the state line stays while the notes scroll */ .col-body .c-mine .blk-h .tag{margin-left:auto;color:var(--wait)} .col-body .ho-batch{margin-top:8px} diff --git a/tools/schemas/output/projects.schema.json b/tools/schemas/output/projects.schema.json index 7b03ecb0..a829e9f8 100644 --- a/tools/schemas/output/projects.schema.json +++ b/tools/schemas/output/projects.schema.json @@ -95,7 +95,7 @@ }, "$defs": { "words": {"type": "object", "required": ["zh", "en"], "properties": {"zh": {"type": "string"}, "en": {"type": "string"}}}, - "now": {"description": "Where the film stands for the person, in a sentence, and the one thing to do (tools/standing.py): what Studio says too", "type": ["object", "null"], "required": ["code", "who", "you", "tone", "say", "more", "short", "act", "facts"], "properties": {"code": {"enum": ["paused", "revision_ready", "waiting_you", "notes_unheard", "notes_sent", "notes_taken", "running", "working", "delivered", "no_record", "stopped", "agent_open", "ship_missing", "setup", "needs_key", "idle", "unknown"]}, "who": {"enum": ["person", "agent", "nobody", "unknown"]}, "say": {"$ref": "#/$defs/words"}, "more": {"anyOf": [{"type": "null"}, {"$ref": "#/$defs/words"}]}, "short": {"$ref": "#/$defs/words"}, "act": {"type": "object", "required": ["kind"], "properties": {"kind": {"enum": ["open", "tell", "settings", "none"]}, "mod": {"type": ["string", "null"]}, "sub": {"type": ["string", "null"]}, "label": {"$ref": "#/$defs/words"}, "text": {"$ref": "#/$defs/words"}, "confirm": {"type": "boolean"}, "secondary": {"type": "boolean"}}}, "facts": {"type": "object", "properties": {"paths": {"type": "array", "items": {"type": "string"}}, "stop": {"type": "string"}, "listening": {"type": "boolean"}, "pending": {"type": "integer"}, "revisions": {"type": "integer"}, "cmd": {"type": ["string", "null"]}, "film": {"type": ["string", "null"]}, "subtitles": {"type": "array", "items": {"type": "string"}}, "version": {"type": ["string", "null"]}, "keys": {"type": "array", "items": {"type": "string"}}, "service": {"type": ["string", "null"]}, "need": {"enum": ["voice", "timing", "music", "image", null]}}}, "you": {"enum": ["decide", "nudge", "offer", "none"]}, "tone": {"enum": ["you", "busy", "quiet"]}}}, + "now": {"description": "Where the film stands for the person, in a sentence, and the one thing to do (tools/standing.py): what Studio says too", "type": ["object", "null"], "required": ["code", "who", "you", "tone", "say", "more", "short", "act", "facts"], "properties": {"code": {"enum": ["paused", "revision_ready", "waiting_you", "notes_unheard", "notes_sent", "notes_taken", "running", "working", "delivered", "no_record", "stopped", "agent_open", "agent_outside", "notes_late", "notes_left", "ship_missing", "setup", "needs_key", "idle", "unknown"]}, "who": {"enum": ["person", "agent", "nobody", "unknown"]}, "say": {"$ref": "#/$defs/words"}, "more": {"anyOf": [{"type": "null"}, {"$ref": "#/$defs/words"}]}, "short": {"$ref": "#/$defs/words"}, "act": {"type": "object", "required": ["kind"], "properties": {"kind": {"enum": ["open", "tell", "settings", "none"]}, "mod": {"type": ["string", "null"]}, "sub": {"type": ["string", "null"]}, "label": {"$ref": "#/$defs/words"}, "text": {"$ref": "#/$defs/words"}, "confirm": {"type": "boolean"}, "secondary": {"type": "boolean"}, "sure": {"$ref": "#/$defs/words"}, "sure_note": {"$ref": "#/$defs/words"}}}, "facts": {"type": "object", "properties": {"paths": {"type": "array", "items": {"type": "string"}}, "stop": {"type": "string"}, "listening": {"type": "boolean"}, "pending": {"type": "integer"}, "revisions": {"type": "integer"}, "cmd": {"type": ["string", "null"]}, "film": {"type": ["string", "null"]}, "subtitles": {"type": "array", "items": {"type": "string"}}, "version": {"type": ["string", "null"]}, "keys": {"type": "array", "items": {"type": "string"}}, "service": {"type": ["string", "null"]}, "need": {"enum": ["voice", "timing", "music", "image", null]}, "program": {"type": ["string", "null"]}, "outside": {"type": "boolean"}, "unread": {"type": "integer"}, "late": {"type": "integer"}, "live": {"type": "boolean"}}}, "you": {"enum": ["decide", "nudge", "offer", "none"]}, "tone": {"enum": ["you", "busy", "quiet"]}}}, "plan": {"description": "The film in a line from its BRIEF and its stops", "anyOf": [{"type": "null"}, {"$ref": "#/$defs/words"}]} } } diff --git a/tools/schemas/output/status.schema.json b/tools/schemas/output/status.schema.json index 319156d9..1440875f 100644 --- a/tools/schemas/output/status.schema.json +++ b/tools/schemas/output/status.schema.json @@ -94,12 +94,11 @@ "unread": { "type": "array", "description": "The person's submissions no agent has taken yet, of any round (tools/desk/feedback.py's unread), oldest first; late: written after that round had been handed over.", - "items": {"type": "object", "required": ["round", "file", "late"], "properties": {"round": {"type": "string"}, "file": {"type": "string"}, "late": {"type": "boolean"}, "items": {"type": "integer"}, "decisions": {"type": "integer"}}} + "items": {"type": "object", "required": ["round", "file", "late"], "properties": {"round": {"type": "string"}, "file": {"type": "string"}, "late": {"type": "boolean"}, "submitted_at": {"type": ["string", "null"]}, "items": {"type": "integer"}, "decisions": {"type": "integer"}}} }, "taken": { "type": "object", - "description": "Each handed-over submission by file name: when (t, epoch seconds), under which agent program and how (wait | feedback); null where an older record does not say.", - "additionalProperties": {"type": "object", "properties": {"t": {"type": ["number", "null"]}, "program": {"type": ["string", "null"]}, "by": {"type": ["string", "null"]}}} + "description": "Each handed-over submission by file name (keys are file names, so not listed): {t: epoch seconds or null, program: the agent program or null, by: wait | feedback or null}; null where an older record does not say." }, "revisions": { "type": "array", @@ -266,7 +265,7 @@ }, "$defs": { "words": {"type": "object", "required": ["zh", "en"], "properties": {"zh": {"type": "string"}, "en": {"type": "string"}}}, - "now": {"description": "Where the film stands for the person, in a sentence, and the one thing to do (tools/standing.py): what Studio says too", "type": ["object", "null"], "required": ["code", "who", "you", "tone", "say", "more", "short", "act", "facts"], "properties": {"code": {"enum": ["paused", "revision_ready", "waiting_you", "notes_unheard", "notes_sent", "notes_taken", "running", "working", "delivered", "no_record", "stopped", "agent_open", "ship_missing", "setup", "needs_key", "idle", "unknown"]}, "who": {"enum": ["person", "agent", "nobody", "unknown"]}, "say": {"$ref": "#/$defs/words"}, "more": {"anyOf": [{"type": "null"}, {"$ref": "#/$defs/words"}]}, "short": {"$ref": "#/$defs/words"}, "act": {"type": "object", "required": ["kind"], "properties": {"kind": {"enum": ["open", "tell", "settings", "none"]}, "mod": {"type": ["string", "null"]}, "sub": {"type": ["string", "null"]}, "label": {"$ref": "#/$defs/words"}, "text": {"$ref": "#/$defs/words"}, "confirm": {"type": "boolean"}, "secondary": {"type": "boolean"}}}, "facts": {"type": "object", "properties": {"paths": {"type": "array", "items": {"type": "string"}}, "stop": {"type": "string"}, "listening": {"type": "boolean"}, "pending": {"type": "integer"}, "revisions": {"type": "integer"}, "cmd": {"type": ["string", "null"]}, "film": {"type": ["string", "null"]}, "subtitles": {"type": "array", "items": {"type": "string"}}, "version": {"type": ["string", "null"]}, "keys": {"type": "array", "items": {"type": "string"}}, "service": {"type": ["string", "null"]}, "need": {"enum": ["voice", "timing", "music", "image", null]}}}, "you": {"enum": ["decide", "nudge", "offer", "none"]}, "tone": {"enum": ["you", "busy", "quiet"]}}}, + "now": {"description": "Where the film stands for the person, in a sentence, and the one thing to do (tools/standing.py): what Studio says too", "type": ["object", "null"], "required": ["code", "who", "you", "tone", "say", "more", "short", "act", "facts"], "properties": {"code": {"enum": ["paused", "revision_ready", "waiting_you", "notes_unheard", "notes_sent", "notes_taken", "running", "working", "delivered", "no_record", "stopped", "agent_open", "agent_outside", "notes_late", "notes_left", "ship_missing", "setup", "needs_key", "idle", "unknown"]}, "who": {"enum": ["person", "agent", "nobody", "unknown"]}, "say": {"$ref": "#/$defs/words"}, "more": {"anyOf": [{"type": "null"}, {"$ref": "#/$defs/words"}]}, "short": {"$ref": "#/$defs/words"}, "act": {"type": "object", "required": ["kind"], "properties": {"kind": {"enum": ["open", "tell", "settings", "none"]}, "mod": {"type": ["string", "null"]}, "sub": {"type": ["string", "null"]}, "label": {"$ref": "#/$defs/words"}, "text": {"$ref": "#/$defs/words"}, "confirm": {"type": "boolean"}, "secondary": {"type": "boolean"}, "sure": {"$ref": "#/$defs/words"}, "sure_note": {"$ref": "#/$defs/words"}}}, "facts": {"type": "object", "properties": {"paths": {"type": "array", "items": {"type": "string"}}, "stop": {"type": "string"}, "listening": {"type": "boolean"}, "pending": {"type": "integer"}, "revisions": {"type": "integer"}, "cmd": {"type": ["string", "null"]}, "film": {"type": ["string", "null"]}, "subtitles": {"type": "array", "items": {"type": "string"}}, "version": {"type": ["string", "null"]}, "keys": {"type": "array", "items": {"type": "string"}}, "service": {"type": ["string", "null"]}, "need": {"enum": ["voice", "timing", "music", "image", null]}, "program": {"type": ["string", "null"]}, "outside": {"type": "boolean"}, "unread": {"type": "integer"}, "late": {"type": "integer"}, "live": {"type": "boolean"}}}, "you": {"enum": ["decide", "nudge", "offer", "none"]}, "tone": {"enum": ["you", "busy", "quiet"]}}}, "plan": {"description": "The film in a line from its BRIEF and its stops", "anyOf": [{"type": "null"}, {"$ref": "#/$defs/words"}]}, "run": { "type": "object", diff --git a/tools/status.py b/tools/status.py index 1f2b661e..692c9ae1 100644 --- a/tools/status.py +++ b/tools/status.py @@ -1068,7 +1068,7 @@ def show(o, now): if n["read"]: print(" read: " + " · ".join(n["read"]) + " (with a #section: bin/vh know --show \"#
    \" prints it; without: the whole file)") nw = o.get("now") or {} - if nw.get("say") and nw.get("code") not in ("idle", "setup", "agent_open", "no_record", "unknown"): # the person's words, as Studio says them + if nw.get("say") and nw.get("code") not in ("idle", "setup", "agent_open", "agent_outside", "no_record", "unknown"): # the person's words, as Studio says them # (tools/standing.py), when they say more than next: does; the view stays short (plan: is in --json and in Studio) print(f"now: {nw['say']['en']}") if nw.get("more"): From 11bf99ba5c846190670b55a6777f4e142fa69d3d Mon Sep 17 00:00:00 2001 From: zhanglinghao Date: Mon, 23 Nov 2026 16:47:53 +0800 Subject: [PATCH 3/7] The notes' counts agree with what is listed (the bar's, the block's; each whole-film note its own once the note box keeps several); the agent column's check for adapters left behind looks only at its own desk's process tree, never by name, so two runs of the checks on one machine don't trip each other --- tools/desk/static/studio.js | 8 ++++++-- tools/desk/test_agents.py | 12 ++++++++++-- tools/desk/test_page.py | 9 +++++++++ 3 files changed, 25 insertions(+), 4 deletions(-) diff --git a/tools/desk/static/studio.js b/tools/desk/static/studio.js index 277c45f6..6bf2cd25 100644 --- a/tools/desk/static/studio.js +++ b/tools/desk/static/studio.js @@ -499,6 +499,10 @@ function renderMarks() { // the round's places in the film: on the round's own $$("#cMarks details").forEach((d) => d.addEventListener("toggle", () => { COLOPEN[d.dataset.k] = d.open; })); } const COLOPEN = { least: false, listen: false }; +function notesCount() { // the notes the person sees listed, the bar's count and the block's alike: each whole-film note its own (generalParts, + // where the note box keeps several), else the overall words as one + return myItems().length + (typeof generalParts === "function" ? generalParts().length : FB.general ? 1 : 0); +} function myItems() { return Object.entries(FB.items).filter(([, v]) => v && v.status); } function renderMine() { const items = myItems().sort((a, b) => (a[1].t != null ? a[1].t : 1e9) - (b[1].t != null ? b[1].t : 1e9)); @@ -506,7 +510,7 @@ function renderMine() { const row = ([k, v]) => `
  • ${v.t != null ? esc(fmt(v.t) + (v.t1 != null ? "–" + fmt(v.t1) : "")) : ""}${esc(cut(v.label || k, 40))} ${esc(v.text || st[v.status] || "")}
  • `; const gen = FB.general ? `
  • ·${esc(t("c_whole_note"))} ${esc(FB.general)}
  • ` : ""; const none = !items.length && !gen; // none yet: the heading and how to start, on one line - const n = items.length + (FB.general ? 1 : 0), subs = D ? (D.feedback || []) : []; + const n = notesCount(), subs = D ? (D.feedback || []) : []; const unread = subs.filter((f) => f.state === "unread"), took = roundTaken(); const st2 = (cls, words, more) => `

    ${esc(words)}

    ${more ? `

    ${esc(more)}

    ` : ""}`; const sentList = (f) => `
      ${(f.items || []).map((i) => `
    • ·${esc(cut(i.label || i.target || "", 40))} ${esc(i.text || st[i.status] || "")}
    • `).join("")}${f.general ? `
    • ·${esc(t("c_whole_note"))} ${esc(f.general)}
    • ` : ""}
    `; @@ -569,7 +573,7 @@ $("#colNow").addEventListener("click", (e) => { // the one action that carries function roundCounts() { // {n, d, r}: notes to send, decisions the person picked and not sent yet, decisions left to the recommendation const ts = toSend(ROUND.data.decisions, FB.decisions, FB.sentDec, roundOpen()); const d = Object.keys(ts.decisions).filter((k) => !ts.defaulted.includes(k)).length; - return { n: myItems().length + (FB.general ? 1 : 0), d, r: D && roundTaken() ? 0 : ts.defaulted.length }; // (a later batch sends no recommendation again) + return { n: notesCount(), d, r: D && roundTaken() ? 0 : ts.defaulted.length }; // (a later batch sends no recommendation again) } function renderRound() { // what the next submission would send, said plainly ("还没写意见 · 2 件按推荐"); nothing to send: the button rests const { n, d, r } = roundCounts(); diff --git a/tools/desk/test_agents.py b/tools/desk/test_agents.py index 80b363bd..c48e3abc 100644 --- a/tools/desk/test_agents.py +++ b/tools/desk/test_agents.py @@ -801,13 +801,21 @@ def codex_dsh(): d.a(sid7, "say", {"text": "写个文件"}) L7.wait(lambda e: e["type"] == "permission") L7.close() + # this desk's own adapters, by process tree (never by name: another run of these checks on the machine has stand-ins too) + rows = [x.split(None, 2) for x in subprocess.run(["ps", "-A", "-o", "pid=,ppid=,command="], capture_output=True, text=True).stdout.splitlines()] + tree, grew = {d.proc.pid}, True + while grew: + more = {int(x[0]) for x in rows if len(x) == 3 and x[1].isdigit() and int(x[1]) in tree} - tree + tree, grew = tree | more, bool(more) + mine = [int(x[0]) for x in rows if len(x) == 3 and int(x[0]) in tree and "fake_acp.py" in x[2]] code = d.stop() def reaped(): + if not mine: + return "no stand-in adapter was found under the desk before it stopped" t0 = time.time() while time.time() - t0 < 12: - ps = subprocess.run(["ps", "-A", "-o", "pid=,command="], capture_output=True, text=True).stdout - left = [l for l in ps.splitlines() if "fake_acp.py" in l and str(agents) in l or ("fake_acp.py" in l and " --speed 0.02" in l)] + left = [x for x in mine if "fake_acp.py" in subprocess.run(["ps", "-o", "command=", "-p", str(x)], capture_output=True, text=True).stdout] # (alive, and still that program: a pid taken since is not it) if not left: break time.sleep(0.3) diff --git a/tools/desk/test_page.py b/tools/desk/test_page.py index d39b94bd..07e4f373 100644 --- a/tools/desk/test_page.py +++ b/tools/desk/test_page.py @@ -125,6 +125,8 @@ def v(res, name): {"click": "#openConfirm"}, {"eval": "JSON.stringify({ ask: ($('#fixAsk') || {}).innerText || '', back: !!$('#fixBack') })", "name": "fix_with_note"}, {"click": "#noSubmit"}, + {"eval": "(" + ", ".join(KEEP.format(t=f"cap:c0{i}", x=f"第 {i} 句", lb=f"字幕 c0{i}") for i in (1, 2)) + ")", "name": "two"}, + {"eval": "JSON.stringify({ bar: $('#colRound').innerText, block: $('#cMine .blk-h').innerText, rows: document.querySelectorAll('#cMine ul.mine li').length })", "name": "counts"}, {"go": f"#/p/{key(busy)}/outline/script", "after": 2500}, tab, {"eval": "(" + ", ".join(KEEP.format(t=f"cap:c0{i}", x=f"第 {i} 句再口语一点", lb=f"字幕 c0{i}") for i in range(1, 9)) + ")", "name": "eight"}, {"wait": 800}, @@ -160,6 +162,13 @@ def check(what, ok, why): ok = False check("\"先改\" picked with no note: the sheet asks what to change, \"回去写\" closes it with the note box ready, \"就这样交\" still sends; with a note it does not ask", ok, [fs, fb, fn]) +cn = v(res, "counts") +try: + c = json.loads(cn) + ok = c["rows"] == 3 and f"{c['rows']} 条意见" in c["bar"] and f"还没交 {c['rows']} 条" in c["block"] +except (TypeError, ValueError, KeyError): + ok = False +check("the bar's count, the notes block's count and the notes listed agree (two notes on lines and the overall words)", ok, cn) bv = v(res, "busy_view") try: b = json.loads(bv) From bdc722dd522e9fe051eaa4ee5610124e52e10e5e Mon Sep 17 00:00:00 2001 From: zhanglinghao Date: Mon, 23 Nov 2026 17:13:51 +0800 Subject: [PATCH 4/7] Studio follows the film's files and opens a stop on what it asks about MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The first real film's window kept a 9-part outline the agent had already cut to 7 and the script's first version after its fourth; a reload jumped to another page; four stops in six opened on the wrong page; clicking the script tab put the stop's explanations above it and pushed what was reviewed far down. - server.py: files_stamp (the documents, shot and edit lists, review pages, .current) in the status poll and the data. - studio.js: the page reloads in place when the stamp moves (module, tab, scroll, playhead and drafts kept; not while the person types, the send sheet is open or the film plays) and says so; a draft on a place that is gone says so. - A stop opens on what it asks about (stopMod / stopSub): a gate ① page with no concept cards on the outline, E1 on the outline's script tab; used by the gate route, the first open, the follow, the column and stopPage. - A module the page picked itself is written into the address (replaceState): rail clicks work after a follow, a reload stays. - The stop's page on a module tab: its summary above the tabs, the rest after the tab's content. - test_page.py: four page checks (where a stop opens, the follow and reload, the outline rewritten while open, the tab row), each failing on the hand-over PR's code alone. --- changes/studio-window-follows-files.md | 6 ++ tools/desk/README.md | 8 +-- tools/desk/server.py | 23 +++++++- tools/desk/static/core.js | 2 + tools/desk/static/studio.css | 1 + tools/desk/static/studio.js | 77 ++++++++++++++++++++------ tools/desk/test_page.py | 63 +++++++++++++++++++++ 7 files changed, 157 insertions(+), 23 deletions(-) create mode 100644 changes/studio-window-follows-files.md diff --git a/changes/studio-window-follows-files.md b/changes/studio-window-follows-files.md new file mode 100644 index 00000000..5dcd8175 --- /dev/null +++ b/changes/studio-window-follows-files.md @@ -0,0 +1,6 @@ +**Studio 的窗口跟着文件走:agent 改了大纲、文案,窗口自己换成新的一版;一站开在它要审的东西上** +- Why: 第一支真片子里,人对着已经不存在的 9 段大纲写意见,文案改到第四版窗口还是第一版,要按"显示 → 重新载入",重新载入又跳回别的页;六次开站有四次停错页(大纲复审停在立意,文案停在大纲页签);点下面的"字幕 / 旁白",内容却在上面展开,要审的旁白被挤到很下面。 +- agent 改了片子的文件(BRIEF、SCRIPT、NOTES、DECISIONS、REVIEW、镜头表、剪辑表、审阅页),开着的 Studio 几秒内自己换成新的,停在原来的模块、页签和位置,说一句"文件改了,这里换成了新的一版";人正在打字、交之前的那一页开着、片子在放时先不换。草稿对着的那一处没有了(大纲少了一段),草稿照留,写明"这一处已经不在了"。 +- 一站开在它要问的东西上:立意定了以后再发的大纲(1b)、没有立意卡的关卡 ① 开在大纲上,要定的事在右栏;文案(E1)开在大纲的"字幕 / 旁白"页签上。 +- 窗口自己挑的模块写进地址:agent 发来新的一页、窗口跟过去以后,左边点同一个模块不再没反应,重新载入也停在原处。 +- 关卡页的说明(已经定了的、替你定的、附录、没看没听的)放到页签内容的下面,页签上面只留一句摘要:点哪个页签,要审的东西都在页签下面紧挨着。 diff --git a/tools/desk/README.md b/tools/desk/README.md index 394bc1a0..ba79f7e0 100644 --- a/tools/desk/README.md +++ b/tools/desk/README.md @@ -2,7 +2,7 @@ 审阅台是一个本地网页控制台,样子是 Studio 的外壳:左边一列模块,顶上这支片子走到哪一站,右边一列分两页:和这台机器上的 agent 说话(Claude Code、Codex、DeepSeek Harness),以及这一轮要人定的事和人的点评。不带项目打开,是这台机器上所有片子的空间;进了一个项目,打开在等人的那一站(立意、分镜或成片),成片模块把片子、镜头、旁白、音乐、检查和点评排在一条时间线上。人点卡片选选项、选中一处写一句、提交;agent 在后台等着,人一提交就接着做。它是 `studio` 档位默认的审阅界面;Studio 开着时,`standard` 的停也默认开在它里面(`bin/vh gate` 看到 Studio 在跑才这样,从不为此起 Studio);别的时候 `standard` 想用也可以(什么时候用、agent 怎么挂等待,见 `playbook/01-pipeline.md` 的"审阅台")。这一页讲它读什么、写什么,也就是项目文件要怎么写,审阅台才排得出来。 -**文件是唯一的事实来源。** 审阅台每次刷新都从项目文件重新读,自己不存状态;人的草稿只留在浏览器里,提交以后才落进项目。读不出结构的文档不会被藏起来:每份文档都在"文档"页原样排版,结构化的页面空着时,就地显示那份文档的原文,"文档"页顶上列出哪些没按约定读出来。 +**文件是唯一的事实来源。** 审阅台每次刷新都从项目文件重新读,自己不存状态;agent 改了片子的文件(文档、镜头表、剪辑表、审阅页),开着的页面几秒内自己重读,停在原来的模块、页签和滚动位置,说一句"文件改了";人正在打字、交之前的那一页开着、片子在放时,等这些停下再读。草稿对着的那一处在新文件里没有了(大纲改了段),草稿照留,写明"这一处已经不在了"。人的草稿只留在浏览器里,提交以后才落进项目。读不出结构的文档不会被藏起来:每份文档都在"文档"页原样排版,结构化的页面空着时,就地显示那份文档的原文,"文档"页顶上列出哪些没按约定读出来。 ## 命令 @@ -69,7 +69,7 @@ bin/vh desk agents install # 装那一家的 ACP 适配器 - **样片墙**:片子下面是"照着样片开始":工作台自己做的四支片子(`showcase/` 里官网也放的那四支,同样的顺序:竖屏科普、数学讲解、手绘短片、发布短片),每张卡写类型、时长、竖屏还是横屏和尺寸、风格(库里有这个风格的,带上它的 id),一个按钮"照这个做一支"。按钮只把一句话写进对话那一列开新片子的框里,不发送、不开始任何事:和官网那张卡复制的一字不差(`tools/desk/test_wording.py` 对着官网查),点名库里的风格(`styles/`)和取自这支片子的配方;有要你填的空([在这里贴上它的链接])就选中它;框里原来写的,⌘Z 拿得回来;窄屏上那一列在下面,框会滚到眼前。框写不进去时不写:这一页只能看,就说这一页只能看;还没装 agent,就把这一句先留着,在那一列的"装上"那里说一声并滚到眼前,装好以后框上面有一个"写进框里",点了才写;空间里那段对话还在做、或在等你批准,不换走它,框上面说一句,等它停下再点"写进框里"。那段对话闲着时,换成开新片子的框,并说一声它在"历史"里。画面是官网的封面图(`docs/site/img/`);这份克隆里有这支片子(`tools/fetch_media.sh` 下载到 `tools/media.txt` 写的那个位置)时,鼠标停在卡上静音放 4 秒。空间里还没有片子时样片墙展开着,就是这一页;有了自己的片子,它收在片子下面成一行,点开再看;窄屏(900 px 以下,那一列在页面下面)也先收着,免得四张卡把框推到几屏以外。人自己点开、收起的,这个浏览器记住。 - **交出去以后**:这一站的意见交给 agent 以后(这一站在等 agent),"这一站"那一页不再摆着没选过似的卡片,而是"交给 agent 的":每件决定选了哪个、每条意见、什么时候交的,下面一个"改了再交",点了才把卡片摆回来;底下那一条写"已经交给 agent 了",按钮歇着,标签页上也不再写"等你定"。没交成功时,服务回一个 `reason`(`token`、`origin`、`page_changed`、`invalid`、`too_big`、`slow`、`moved`),页面照它用人的语言说发生了什么、该做什么,不把服务的英文原样放上去。 - **现在到哪了**:进了一支片子,右栏两页(对话、这一站)的上面是一句短话,说这支片子现在怎么样、轮到谁,下面一行小一点的字说细节(停在哪、留了什么、做好的文件,文件点得开),都是 `bin/vh status` 的 `now:` 那几行(中文或英文;英文和终端里一字不差),再下面至多一个按钮:要人看的一站是"去看初版"这种,转到那一站的模块(已经在那一页就不放);要 agent 接着做的(意见交了没人取、agent 停下了、引擎没装、暂停了)是"让 agent 来看意见""让 agent 接着做":点一下,在这支片子最近的对话里(没有就开一个)发一句写好的话:只用 `standing.py` 词表里的字、数字和时间拼成(命令名不在词表里时只认 `bin/vh` 命令名的样子),不放项目文件里的别的文字;输入框里人自己的草稿不动,这句话照样在对话记录里,记的是人说的。下面一行小字是这支片子的打算(`plan`:多长、竖屏横屏、有没有旁白、在哪几处停给人看),从 BRIEF 和停的计划读,模板里没填的不写。空间的卡片上写这一句的短的那一半("停下了""正在渲染,340 / 900 帧""意见还没人取"),轮到人的(等人看、意见没人取、停下了、暂停了)亮琥珀色。每种情况说什么,见下面"一个项目到哪了"的 `now`。 -- **一支片子**(`#/p/<键>[/<模块>]`):打开在等人的那一站的模块(关卡 ① 立意,② 分镜,③ 成片);没人等时打开正在做的那一站,再没有就是成片。关卡不再是另一页:等人那一站的模块就是这一轮的关卡页,要你定的事在右栏。照原型排的模块自己画关卡页的画面(立意卡、镜头),关卡页里其余的东西(替你定的、附录、别的图)接在模块下面;成片模块把关卡页的画面放在它的时间线上。`#/p/<键>/gate/<页>` 打开那一页所在的模块,之前的页只看不交。 +- **一支片子**(`#/p/<键>[/<模块>]`):打开在等人的那一站的模块,按那一页问的是什么定(关卡 ① 有立意卡是立意,没有立意卡的(比如立意定了以后再发的大纲 1b)是大纲;脚本 E1 是大纲的"字幕 / 旁白"页签;② 分镜,③ 成片);页面自己挑的模块写进地址(不另加一条历史),所以左边点它不会没反应,重新载入也停在原处;没人等时打开正在做的那一站,再没有就是成片。关卡不再是另一页:等人那一站的模块就是这一轮的关卡页,要你定的事在右栏。照原型排的模块自己画关卡页的画面(立意卡、镜头),关卡页里其余的东西(替你定的、附录、别的图)接在模块下面;别的页签也一样:关卡页的一句话摘要在页签上面,其余的接在页签的内容下面,点页签不会把要看的东西挤下去;成片模块把关卡页的画面放在它的时间线上。`#/p/<键>/gate/<页>` 打开那一页问的那个模块和页签,之前的页只看不交。 - **其余模块**照原型排(`static/modules.js`、`modules.css`),画面在前,字少;每样东西都能选中再写点评,点评带着它是什么。数据只来自已有的命令和项目文件,缺的那一块照实说空,写上做它的命令。 - **模板里没填的不算写了**:BRIEF、NOTES 里原样留着的模板占位(整格只是一个 `{…}`,比如 `{the story in one sentence: …}`)当成还没写:立意、故事线、素材清单的那一行、大纲那一段都不显示,立意页写"立意卡还没出来,立意也还没写",底下一条写"立意还没定",大纲页写"大纲还没写";不会把刚 `bin/vh new` 出来的片子说成已经定了什么。 - **立意**:左边是 NOTES.md 素材清单里只属于这个题目的东西,按数字、物件、原话、矛盾、意外分组,和「点子」里那条同题的视频常见的样子;右边是最新一页关卡 ① 的立意卡(带画面的那件决定),各配一帧。关卡 ① 开着时,"选这张"就是这一轮的决定,和右栏同步;"再想一张像它的"要 agent,这一版把这半句话放进写点评的框。还没有关卡 ① 的页时,显示 BRIEF 写下的立意。 @@ -129,7 +129,7 @@ bin/vh desk agents install # 装那一家的 ACP 适配器 | `GET /api/p/<键>/data` | `bin/vh desk data` 的内容,加 `status`(`bin/vh status --json`)、`key`、`home`、`pid`(这个项目文件夹的身份:真实路径的 SHA-1,提交要带上)、`only`、`current`(这一轮的页名)、`round_open`(这一轮那一站还没定:不是 done、skipped;这时提交带上它还没交过、或交过以后改了的决定),`feedback` 里每份提交的 `state`(`unread` 还没人取、`taken` 取走了、`answered` 答过了;读不出时是 `null`,页面就不说)、`taken`(`t`、`program`、`by`)和 `late`(补交的),`notes_stamp`,和 `studio`(`film` 是成片模块播的那一支,只取在的文件;这一站没点名片子、`bin/vh status` 的那支又没有声音、BRIEF 也没说要无声片时,换成有声音、而且不比它旧的一支(分镜的 animatic、关卡页的 film 或 animatic,新的页在前;`bin/vh status` 本身不变);换了时 `film_instead` 是没放的那支,缩略图、波形和检查的问题都是那支的,不给(读数写明放的是哪个文件,不写第几版);`film_sound` 是它有没有声音(true、false,ffprobe 看不了是 null;一个文件只看一次,大小和时间不变就记着);要的那支不在时,`film_missing` 是它的路径;`sheet` 是最新的联系表;成片模块用的:`timeline` 是 `bin/vh timeline --resolved` 的内容;`thumbs`、`peaks` 是 `bin/vh thumbs`、`peaks` 做过才有的记录;`check` 和 `findings` 是最近一次检查的结论和带时间的问题,没过和要注意的;读不出来的那一样是 `null`,原因记在 `warnings`),和 `mods`(其余模块读的,都是已有命令写下的文件:`loudness` `{integrated, true_peak, lra, target, severity}` 和 `silences`、`checks`(最近一次检查的每条 finding:`kind, severity, message, t, t1`);`pace`(旁白时间轴里 `bin/vh pace` 写的 `reference, unit, speech, with_pauses` 和逐句的 `lines`)、`voice`(旁白用的音色)、`audition`(最新的 `audition.json`:`{file, provider, unit, text, voices: [{voice, file, duration, pitch_hz, speech_rate, misread, error}]}`)、`lifts`(最新的 `*.beats.json` 的候选落点);`covers` `[{path, ratio, id, text}]`、`subs`(字幕文件);`assets`(台账里没删的每一件:`{id, kind, path, there, system, license, license_name, source, url, aigc, used_by, note}`;`system` 是系统自带的字体(`/System/Library/…`、`/Library/Fonts/`、Windows 的 Fonts 这些),算在,不算在项目外;没有台账是 `null`)、`refs`(`research/refs.json`)、`digests` `[{id, path, bytes}]`;没有台账时 `assets_notes` `{file, rows: [{file, source, license, there}]}` 是 NOTES.md 里旧的素材台账表(`there` 对链接是 `null`);每一部分各读各的:读不出的那部分是空的,`errors` 写着它的文件和原因,别的照样有;只读项目里面的文件,指到项目外的链接不跟,和 `/f/` 一样) | | `GET /api/p/<键>/gate/<页>[?lang=zh\|en]` | 那一页的关卡视图:`{version, gate, current, this_round, title, lang, takeall, html, errors, warnings, decisions: [{id, question, recommend, options}], summary, cards, marks, not_reviewed}`;`html` 和静态页同一份标记,文件地址换成 `/f/<键>/…`;`cards` 是所有决定的选项卡(右栏用,同一份标记),`marks` 是没把握和请你听的地方 `[{kind: least \| listen, t, t1, id, note, target}]` | | `GET /api/p/<键>/stage` | 不等人时的画面:`{kind: "video", path, html}`(同一个播放器和标尺),或 `{kind: "image", path, href}`,或 `{kind: null}` | -| `GET /api/p/<键>/status` | 有没有 agent 在等这个项目的反馈(`round` 之外,`live`:等着的那个 `wait` 等的正是现在这一轮,一交就取走;`notes_stamp`:交了或取走了一份就变,页面据此重读每份意见的状态),这一轮的页名 `round`,和这支片子现在到哪了:`now`、`plan`(`bin/vh status --json` 的同名字段,按列表的读法算:不读素材台账、cast 和调研)。页面每 4 秒问一次,`now` 变了就换右栏顶上那一句 | +| `GET /api/p/<键>/status` | `files_stamp`:页面读的那些文件(文档、`shots.json`、`edit.json`、审阅页和 `.current`)的修改时间和大小算成的一个戳,变了页面就重读;有没有 agent 在等这个项目的反馈(`round` 之外,`live`:等着的那个 `wait` 等的正是现在这一轮,一交就取走;`notes_stamp`:交了或取走了一份就变,页面据此重读每份意见的状态),这一轮的页名 `round`,和这支片子现在到哪了:`now`、`plan`(`bin/vh status --json` 的同名字段,按列表的读法算:不读素材台账、cast 和调研)。页面每 4 秒问一次,`now` 变了就换右栏顶上那一句 | | `POST /api/p/<键>/feedback` | 一次提交(格式见下面"写什么"),另带 `pid`:和这个地址现在指的文件夹对不上(或没带)就 409,不写进任何项目 | | `GET /f/<键>/<路径>` | 这个项目里的一个文件(支持 Range) | | `GET /v/<键>/<路径>` | 同一个文件放在一页里:顶上一条细栏写着文件名和它在项目里的位置;文本和 markdown 当文本显示(markdown 经 `reader.render_md`,一律先转义),图片、视频和音频的播放器、网页放在框里(仍受 `/f/` 的沙箱头管着),显示不了的种类说一句并说文件在哪。Studio 自己的应用把控制台里"在新页打开"的链接都开在这里,所以开出来的窗口不会是空的 | @@ -514,7 +514,7 @@ agent 那一列另有一组(`agent_checks`,`tools/desk/test_agents.py`): `tools/ci.sh` 用 `tools/desk/fixtures/` 里的小项目测:`zh`、`en` 两个测读取;`demo` 是一支编的片子(海水为什么一天涨两次),关卡 ①②③ 都有,画面是几张小 SVG,它还带着旁白的时间、节拍表和一份检查记录,成片模块的每条轨道都有东西。`console_checks` 用它测关卡视图(静态页整个内嵌 `ui.css` 和 `ui.js`、不从外面加载东西、推荐的卡预先选上、立意卡带帧、分镜就是画面、没把握的时间,关卡 ①② 的页带着这一站的模块)、七个模块按它的数据画出来(node 里跑 `core.js` 和 `modules.js`,控制台的和静态页只读的都画)、三套主题(同一组变量,每种字色对底色 4.5:1 以上,样式里没有变量以外的颜色)、字数提醒和控制台(外壳、多个项目、键、等人的排前面和它的问题与画面、项目数据和成片模块的数据、关卡视图和右栏的卡与记号、文件、各种拒绝、一次提交);PR 的截图也只用它。读取的测试(包括读不出表格时退回原文、"这一轮"取 `.current`(2 之后的 1b、3 之后的 E3b、自起的页名,`.current` 指向已删的页时退回流程顺序)、语言规则、超长和深层嵌套的 markdown),在空闲端口起一个服务测 `/api/data`、206 Range、`/p/` 的 sandbox、各种拒绝和坏请求、提交到临时副本、REVIEW.md 的追加,测 `wait` 在有提交时退出 0、启动前就到的提交立刻交出、交过的不再交,拷来的 `.desk.json` 和 `.listening` 不算数,以及 `bin/vh desk -h`。 -页面本身另有一组,在 `desk_checks` 里(`tools/desk/test_page.py`):在一个无头 Chrome 里打开它自己起的控制台(`tools/desk/page_driver.mjs`,用仓库自己的 `tools/textcheck/browser.mjs` 起浏览器),在 `demo` 的几份副本上看人看到的:一轮被取走以后补交的意见怎么说、交之前和交之后各说什么,选了"先改"却没写意见时会不会问,1440×900 下决定卡片很多时刚记下的意见在不在屏幕上。没有 Chrome 时本机跳过,CI 上算失败。 +页面本身另有一组,在 `desk_checks` 里(`tools/desk/test_page.py`):在一个无头 Chrome 里打开它自己起的控制台(`tools/desk/page_driver.mjs`,用仓库自己的 `tools/textcheck/browser.mjs` 起浏览器),在 `demo` 的几份副本上看人看到的:一轮被取走以后补交的意见怎么说、交之前和交之后各说什么,选了"先改"却没写意见时会不会问,1440×900 下决定卡片很多时刚记下的意见在不在屏幕上;一站开在哪个模块和页签,agent 发来新的一页时窗口跟过去、地址和重新载入对不对得上,agent 改了大纲时页面几秒内换成新的,点页签时页签那一排有没有被挤下去。没有 Chrome 时本机跳过,CI 上算失败。 ## 整套截图(开发用) diff --git a/tools/desk/server.py b/tools/desk/server.py index 3d795422..65d1ba39 100644 --- a/tools/desk/server.py +++ b/tools/desk/server.py @@ -660,6 +660,26 @@ def _drop_missing(project, d, key): d[key], d[key + "_missing"] = "", v +def files_stamp(project): + """A stamp of the files the page is drawn from: the project's documents (reader.DOCS), its shot list and edit list, its + review pages and which one is this round. It changes when the agent writes one of them, and an open page then reads the + film again (renders, frames and other media do not change it).""" + project = Path(project) + paths = [project / n for n in list(reader.DOCS) + ["shots.json", "edit.json"]] + [project / "out" / "review" / ".current"] + try: + paths += sorted((project / "out" / "review").glob("gate-*.json")) + except OSError: + pass + h = hashlib.sha1() + for p in paths: + try: + st = p.stat() + h.update(f"{p.name}:{st.st_mtime_ns}:{st.st_size};".encode()) + except OSError: + h.update(f"{p.name}:-;".encode()) + return h.hexdigest()[:16] + + def project_data(project, parts=("studio", "mods")): """A project's data as the console reads it (GET /api/p//data, less the key): reader.read_project, bin/vh status, the folder's identity, this round and whether it is open, and the parts asked for, what the cut module lays out (studio) @@ -691,6 +711,7 @@ def project_data(project, parts=("studio", "mods")): fb["taken"] = {"t": t.get("t"), "program": t.get("program"), "by": t.get("by")} if t is not None else None fb["late"] = bool(un.get(n)) data["notes_stamp"] = F.notes_stamp(project) + data["files_stamp"] = files_stamp(project) _drop_missing(project, data.get("shots"), "video") # the storyboard's animatic, and the pictures the gate pages name for r in data.get("rounds") or []: g = r.get("data") if isinstance(r, dict) and isinstance(r.get("data"), dict) else {} @@ -1139,7 +1160,7 @@ def do_GET(self): cur = pages[-1].stem[5:] if pages else None return self._json(dict(lis, project=project.name, key=key, round=cur, revision_stamp=RV.stamp(project), now=now, plan=plan, live=bool(lis.get("listening")) and lis.get("round") is not None and lis.get("round") == F.current_round(project), - notes_stamp=F.notes_stamp(project))) + notes_stamp=F.notes_stamp(project), files_stamp=files_stamp(project))) if what == "stage": return self._stage(project, key) lang = (parse_qs(urlsplit(self.path).query).get("lang") or [None])[0] diff --git a/tools/desk/static/core.js b/tools/desk/static/core.js index eff028dc..beb15224 100644 --- a/tools/desk/static/core.js +++ b/tools/desk/static/core.js @@ -173,6 +173,7 @@ const STR = { ho_fix_q: "你选了“{x}”,还没写改哪里。", ho_fix_b: "在页面上点要改的地方写一句,或者在上面的整体意见里写。", ho_fix_back: "回去写", ho_fix_go: "就这样交", ho_s_1: "立意", ho_s_outline: "大纲", ho_s_E0: "画风样张", ho_s_E1: "旁白稿", ho_s_2: "分镜", ho_s_E2: "配乐安排", ho_s_E3: "最终的声音", ho_s_3: "初版", ho_s_E4: "第一章样片", ho_s_E5: "定画面的版本", ho_s_notes: "随手写的意见", ho_s_other: "这一页", + ho_files: "文件改了,这里换成了新的一版", ho_gone: "(这一处已经不在了)", }, en: { revisions: "Revisions", revision_pending: "Ready for review", revision_approved: "Accepted", revision_changes_requested: "Changes requested", @@ -341,6 +342,7 @@ const STR = { ho_fix_q: "You picked “{x}” but haven't said what to change.", ho_fix_b: "Click the place to change on the page and write a line, or write it in the overall box above.", ho_fix_back: "Go back and write it", ho_fix_go: "Send as it is", ho_s_1: "the concept", ho_s_outline: "the outline", ho_s_E0: "the style frames", ho_s_E1: "the script", ho_s_2: "the storyboard", ho_s_E2: "the sound plan", ho_s_E3: "the final sound", ho_s_3: "the first draft", ho_s_E4: "the first chapter", ho_s_E5: "the picture lock", ho_s_notes: "your loose notes", ho_s_other: "this page", + ho_files: "The files changed; this shows the new version", ho_gone: " (no longer there)", }, }; diff --git a/tools/desk/static/studio.css b/tools/desk/static/studio.css index 7920a4ac..335b893d 100644 --- a/tools/desk/static/studio.css +++ b/tools/desk/static/studio.css @@ -214,6 +214,7 @@ html.shell-other .topbar{padding-right:calc(14px + 100vw - env(titlebar-area-x, .col-body .c-mine .blk-h{position:sticky;top:-10px;margin:-10px 0 4px;padding:10px 0 4px;background:var(--panel);z-index:1} /* the state line stays while the notes scroll */ .col-body .c-mine .blk-h .tag{margin-left:auto;color:var(--wait)} .col-body .ho-batch{margin-top:8px} +.col-body .note-list em.gone{font-style:normal;color:var(--wait);margin-left:4px} .col-body .ho-st{margin:0;display:flex;gap:8px;align-items:baseline;font-size:var(--fs-small);color:var(--ink-hi)} .col-body .ho-st i{flex:none;width:6px;height:6px;border-radius:50%;background:var(--wait);transform:translateY(-1px)} .col-body .ho-st.taken{color:var(--ink-2)}.col-body .ho-st.taken i{background:var(--rule-2)} diff --git a/tools/desk/static/studio.js b/tools/desk/static/studio.js index 6bf2cd25..da6843d8 100644 --- a/tools/desk/static/studio.js +++ b/tools/desk/static/studio.js @@ -68,7 +68,7 @@ function parse() { const m = h.match(/^\/p\/([^/]+)(?:\/(.*))?$/); if (m) { const rest = m[2] || "", g = rest.match(/^gate\/([A-Za-z0-9_-]{1,24})$/); - if (g) return { view: "project", key: m[1], gate: g[1], mod: gateMod(g[1]) }; + if (g) return { view: "project", key: m[1], gate: g[1], mod: "" }; // its module and tab: from what the page asks about (stopMod), once the film is read let [mod, sub, ...more] = rest.split("/"); if (LEGACY[mod] != null && !MODS.includes(mod)) { const x = LEGACY[mod].split("/"); return { view: "project", key: m[1], mod: x[0], sub: x[1] || "", doc: x[1] === "docs" ? [sub].concat(more).filter(Boolean).join("/") : "" }; } return { view: "project", key: m[1], mod: MODS.includes(mod) ? mod : "", sub: sub || "", doc: sub === "docs" ? more.join("/") : "" }; @@ -361,7 +361,9 @@ async function reloadProject(follow) { // the same film read again (a submissi const at = CUT && !follow ? CUT.time() : null, y = window.scrollY, s = $("#stage").scrollTop; leaveProject(); applyProject(key, x); const r = follow ? { view: "project", key } : Object.assign(parse(), { key }); // follow: a new page opens on its own stop's module - MOD = r.mod || defaultMod(); SUB = r.sub || ""; DOC = r.doc || DOC; GATE = r.gate || ""; + const pl = placeOf(r); + MOD = pl.mod; SUB = pl.sub; DOC = r.doc || DOC; GATE = r.gate || ""; + keepAddress(r); crumbs([{ text: t("m_space"), href: "#/" }, { text: D.project.title }]); renderFlow(); renderRail(); renderColumn(); renderModule(); updateComposer(); liveTimer = setInterval(pollLive, 4000); @@ -374,11 +376,31 @@ function waitingGate() { // this round's page, when its stop waits for the per if (st) return st.state === "waiting_person" ? D.current : null; return D.feedback.some((f) => f.round === D.current) ? null : D.current; // no status: a page nobody answered } +function hasCards(r) { return ((r && r.data) || {}).decisions ? r.data.decisions.some((d) => (d.options || []).some((o) => o && o.frame)) : false; } +function stopMod(g) { // the module a stop's page opens on, from what it asks about: a gate ① page with no concept cards (1b, an outline-only + // gate ①) is the outline; E1 is the script (stopSub); the rest by its stop (GATE_MOD) + const b = gateBase(g), r = D && (D.rounds || []).find((x) => x.id === g); + if (b === "1" && r && !hasCards(r)) return "outline"; + return gateMod(g); +} +function stopSub(g) { return gateBase(g) === "E1" ? "script" : ""; } +function placeOf(r) { // {mod, sub} the page shows: the address's, else a page's own (gate/), else where the film waits + if (r.mod) return { mod: r.mod, sub: r.sub || "" }; + if (r.gate) return { mod: stopMod(r.gate), sub: stopSub(r.gate) }; + const g = waitingGate(); + return { mod: defaultMod(), sub: g ? stopSub(g) : "" }; +} +function keepAddress(r) { // the address names what is on screen: a module the page picked itself is written into it (no new history entry), + // so a click on that module in the rail is no change of address, and a reload stays on this page + if (r.mod || (r.gate && D && r.gate !== D.current)) return; // (an earlier page asked for by name keeps its own address) + const h = projHash(PKEY, MOD + (SUB ? "/" + SUB : "")); + if (location.hash !== h) history.replaceState(null, "", h); +} function defaultMod() { const g = waitingGate(); - if (g) return gateMod(g); + if (g) return stopMod(g); const cur = stations().find((s) => s.current && s.state !== "done" && s.state !== "skipped"); - if (cur && GATE_MOD[cur.id] && GATE_MOD[cur.id] !== "ship") return GATE_MOD[cur.id]; + if (cur && GATE_MOD[cur.id] && GATE_MOD[cur.id] !== "ship") return cur.id === "1" && cur.page ? stopMod(cur.page.replace(/^.*gate-|\.(html|json)$/g, "")) : GATE_MOD[cur.id]; if (filmDelivered()) return "ship"; if (filmPath() || cutShots().length) return "cut"; return "idea"; @@ -387,7 +409,9 @@ async function showProject(r) { clearTimeout(homeTimer); const switching = PKEY !== r.key || !D, was = MOD; if (switching) { leaveProject(); D = null; renderShellLoading(); if (!(await loadProject(r.key))) return; } - MOD = r.mod || defaultMod(); SUB = r.sub || ""; DOC = r.doc || DOC; GATE = r.gate || ""; + const pl = placeOf(r); + MOD = pl.mod; SUB = pl.sub; DOC = r.doc || DOC; GATE = r.gate || ""; + keepAddress(r); crumbs([{ text: t("m_space"), href: "#/" }, { text: D.project.title }]); renderFlow(); renderRail(); if (switching) { renderColumn(); clearInterval(liveTimer); pollLive(); liveTimer = setInterval(pollLive, 4000); } @@ -405,10 +429,10 @@ function renderColumn() { // the agent's being there is said when it waits (a desk wait); its absence is not news, so nothing is shown then $("#colHead").innerHTML = `${esc(t(dl ? "col_film" : "col_round"))}${esc(roundName)}${esc(t("live_on"))}`; const g = GV && GV.current && roundOpen() ? GV : null; // the cards while this round's stop is open (not passed or skipped) - const home = GATE_MOD[gateBase(ROUND.id)] || "cut", here = !g || MOD === home, n = (ROUND.data.decisions || []).length; + const home = stopMod(ROUND.id) || "cut", here = !g || MOD === home, n = (ROUND.data.decisions || []).length; const page = ROUND.page ? ` ${esc(t("static_page"))} ↗` : ""; const hd = handedNow(), H = hd && !REHAND[KEY]; // this stop's notes went (taken, or sent and not picked up yet): what went, not the cards as if nothing had - const decs = H ? handedHtml(hd) : g && !here ? `
    ${esc(n ? t("away_decide", { s: gateName(ROUND.id), n }) : t(earOf(ROUND.id) ? "away_listen" : "away_look", { s: gateName(ROUND.id) }))} →
    ` // another module: one line to the stop's own + const decs = H ? handedHtml(hd) : g && !here ? `
    ${esc(n ? t("away_decide", { s: gateName(ROUND.id), n }) : t(earOf(ROUND.id) ? "away_listen" : "away_look", { s: gateName(ROUND.id) }))} →
    ` // another module: one line to the stop's own : g && n ? `

    ${esc(t("c_decide"))}${n}${esc(t("c_rec"))}

    ${g.summary ? `

    ${esc(g.summary)}${page}

    ` : ""}
    ${g.cards}
    ` : g && g.summary ? `

    ${esc(g.summary)}${page}

    ` : `

    ${esc(t(filmDelivered() ? "col_done" : "round_quiet"))}

    `; // nothing to decide: one line ("最近定下的" is the ledger's) @@ -462,7 +486,7 @@ function handedHtml(f) { // each decision as it went, when; and the way to cha $("#colBody").addEventListener("click", (e) => { if (e.target.closest("#reHand")) { REHAND[KEY] = true; renderColumn(); } }); function syncPhoneDec() { // a phone lays the cut out picture, timeline, then the column: a bar above the picture goes to the decisions const pd = $("#phoneDec"); if (!pd || !D) return; - const g = GV && GV.current && roundOpen() ? GV : null, n = (ROUND.data.decisions || []).length, home = GATE_MOD[gateBase(ROUND.id)] || "cut"; + const g = GV && GV.current && roundOpen() ? GV : null, n = (ROUND.data.decisions || []).length, home = stopMod(ROUND.id) || "cut"; pd.hidden = !(g && n && MOD === home); pd.textContent = pd.hidden ? "" : `${t("away_decide", { s: gateName(ROUND.id), n })} ↓`; } @@ -491,7 +515,7 @@ function recentHtml() { // what was decided last, when nothing is open: REVIEW return R.length ? `

    ${esc(t("recent"))}

      ${R.map((x) => `
    • ·${esc(cut(x.k, 40))} ${esc(x.v)}
    • `).join("")}
    ` : ""; // two lines each; a click opens one } function renderMarks() { // the round's places in the film: on the round's own module (elsewhere its one line goes there) - const home = GATE_MOD[gateBase(ROUND.id)] || "cut", M = MOD === home ? gateMarks() : [], least = M.filter((m) => m.kind === "least"), listen = M.filter((m) => m.kind === "listen"); + const home = stopMod(ROUND.id) || "cut", M = MOD === home ? gateMarks() : [], least = M.filter((m) => m.kind === "least"), listen = M.filter((m) => m.kind === "listen"); const li = (m) => `
  • ${m.t != null ? esc(fmt(m.t) + (m.t1 != null ? "–" + fmt(m.t1) : "")) : ""}${m.id && !/^\s*\d/.test(m.id) ? `${esc(shotName(m.id))} ` : ""}${esc(m.note)}
  • `; // folded to their headings and counts: the decisions above take the room (their pros and costs whole); a click opens one, and it stays open const fold = (k, title, list) => `
    ${esc(title)}${list.length}
      ${list.map(li).join("")}
    `; @@ -499,6 +523,13 @@ function renderMarks() { // the round's places in the film: on the round's own $$("#cMarks details").forEach((d) => d.addEventListener("toggle", () => { COLOPEN[d.dataset.k] = d.open; })); } const COLOPEN = { least: false, listen: false }; +function goneNow(k) { // a draft's place no longer in the files (the agent rewrote the outline or the script since it was written) + if (!D) return false; + const [kind, id] = [k.split(":")[0], k.split(":").slice(1).join(":")]; + if (kind === "seg") return Array.isArray(D.outline) && D.outline.length > 0 && !D.outline.some((o) => String(o.id) === id); + if (kind === "cap") { const rows = (D.captions && D.captions.rows) || []; return rows.length > 0 && !rows.some((c) => String(c.id) === id); } + return false; +} function notesCount() { // the notes the person sees listed, the bar's count and the block's alike: each whole-film note its own (generalParts, // where the note box keeps several), else the overall words as one return myItems().length + (typeof generalParts === "function" ? generalParts().length : FB.general ? 1 : 0); @@ -507,7 +538,7 @@ function myItems() { return Object.entries(FB.items).filter(([, v]) => v && v.st function renderMine() { const items = myItems().sort((a, b) => (a[1].t != null ? a[1].t : 1e9) - (b[1].t != null ? b[1].t : 1e9)); const st = { ok: t("st_ok"), change: t("st_change"), ask: t("st_ask") }; - const row = ([k, v]) => `
  • ${v.t != null ? esc(fmt(v.t) + (v.t1 != null ? "–" + fmt(v.t1) : "")) : ""}${esc(cut(v.label || k, 40))} ${esc(v.text || st[v.status] || "")}
  • `; + const row = ([k, v]) => `
  • ${v.t != null ? esc(fmt(v.t) + (v.t1 != null ? "–" + fmt(v.t1) : "")) : ""}${esc(cut(v.label || k, 40))}${goneNow(k) ? `${esc(t("ho_gone"))}` : ""} ${esc(v.text || st[v.status] || "")}
  • `; const gen = FB.general ? `
  • ·${esc(t("c_whole_note"))} ${esc(FB.general)}
  • ` : ""; const none = !items.length && !gen; // none yet: the heading and how to start, on one line const n = notesCount(), subs = D ? (D.feedback || []) : []; @@ -611,7 +642,7 @@ function gotoTarget(target, tt, t1, label) { // a note or a mark in the column const kind = target.split(":")[0]; let mod = KIND_MOD[kind]; if (kind === "shot") mod = filmPath() || cutShots().length ? "cut" : "board"; - if (kind === "least" || kind === "dec") mod = ROUND.gate ? gateMod(ROUND.id) : MOD; + if (kind === "least" || kind === "dec") mod = ROUND.gate ? stopMod(ROUND.id) : MOD; if (tt != null && kind !== "cap" && (filmPath() || cutShots().length)) mod = "cut"; // a place with a time is on the cut's timeline const after = () => { if (mod === "cut" && CUT) { CUT.goto(target, tt, t1); return; } @@ -789,15 +820,23 @@ function save() { $$("#stage [data-mark]").forEach(markHost); } let LIVE = false; // a wait alive on the round that is out now (the status poll): it picks a submission up within the second +function busyHere() { // the person is in the middle of something a reload would cut short: typing, the sheet open, the film playing + const a = document.activeElement, v = $("#stage video"); + return !!(a && (/^(TEXTAREA|INPUT|SELECT)$/.test(a.tagName) || a.isContentEditable)) || !$("#confirm").hidden || !!(v && !v.paused); +} async function pollLive() { if (!PKEY || RELOADING) return; const r = await getJSON(`/api/p/${enc(PKEY)}/status`); const on = !!(r.ok && r.data && r.data.listening), el = $("#colHead .state"); const live = !!(r.ok && r.data && r.data.live && r.data.key === PKEY); if (live !== LIVE) { LIVE = live; renderMine(); } // who picks the notes up: said in the notes block - if (r.ok && r.data && D && r.data.key === PKEY && r.data.notes_stamp !== undefined && r.data.notes_stamp !== D.notes_stamp && !RELOADING) { // a note was saved or picked up: its state on screen follows + const mineNow = r.ok && r.data && D && r.data.key === PKEY && !RELOADING; + if (mineNow && !busyHere() && r.data.notes_stamp !== undefined && r.data.notes_stamp !== D.notes_stamp && r.data.round === (D.current || null)) { // a note was saved or picked up: its state on screen follows await reloadProject(false); return; } + if (mineNow && !busyHere() && r.data.files_stamp && D.files_stamp && r.data.files_stamp !== D.files_stamp && r.data.round === (D.current || null)) { // the agent changed the film's files: the page shows them, where it was + await reloadProject(false); toast(t("ho_files")); return; + } if (el) { el.classList.toggle("agent", on); el.hidden = !on; } AGENT.listening(on); // the conversation that waits for this stop in the background says so const mine = r.ok && r.data && r.data.key === PKEY, got = mine ? r.data.now || null : null; // not answered, or its state unreadable: said as unknown @@ -842,17 +881,19 @@ function renderModule() { const fn = { idea: mIdea, outline: () => ({ outline: vOutline, script: vScript, facts: vFacts }[cur] || vOutline)(), board: mBoard, sound: vSound, ship: () => (cur === "versions" ? vVersions() : vCheck()), assets: vAssets, ledger: () => ({ decisions: vLedger, history: vHistory, docs: vDocs }[cur] || vLedger)(), cut: () => "" }[MOD] || mIdea; - const page = stopPage(MOD); - area.innerHTML = `
    ${moduleHead(kickOf(MOD), "", "")}${page ? '
    ' : ""}${subtabs(MOD)}
    ${fn()}
    `; - if (page) loadGatePart(page); + // the stop's page: its one-line summary above the tabs, the rest (decided, delegated, appendices, not looked at) after the tab's + // content, so a tab clicked opens where the tabs are and what is reviewed stays at the top + const page = stopPage(MOD), pr = page && (D.rounds || []).find((x) => x.id === page), sum = pr && pr.data && pr.data.summary; + area.innerHTML = `
    ${moduleHead(kickOf(MOD), "", "")}${sum ? `

    ${esc(sum)}

    ` : ""}${subtabs(MOD)}
    ${fn()}
    ${page ? '
    ' : ""}
    `; + if (page) loadGatePart(page, {}); else { const link = pastPageLink(MOD); if (link) $(".mh", area).insertAdjacentHTML("beforeend", link); } $$("[data-mark]", area).forEach(markHost); ({ outline: cur === "script" ? wireScript : wireOutline, board: wireBoard, sound: wireSound }[MOD] || (() => {}))(); area.scrollTop = 0; } function stopPage(mod) { // the stop's page this module shows on top: the one asked for, else this round's while it is open here - if (GATE && gateMod(GATE) === mod) return GATE; - return D.current && roundOpen() && gateMod(D.current) === mod ? D.current : null; + if (GATE && stopMod(GATE) === mod) return GATE; + return D.current && roundOpen() && stopMod(D.current) === mod ? D.current : null; } function pastPageLink(mod) { const f = FLOW.find((x) => x.mod === mod); if (!f) return ""; @@ -866,7 +907,7 @@ async function loadGatePart(gid, V) { // V: the module draws the page's pictur const host = $("#gatePart"); if (!host) return; if (!r.ok || !r.data) { host.innerHTML = `

    ${esc((r.data && r.data.error) || "")}

    `; return; } const g = r.data, past = !g.current; - host.innerHTML = (past ? `

    ${esc(t("past", { g: gateName(g.gate, true) }))}${D.current ? ` ${esc(t("to_round"))}` : ""}

    ` : "") + g.html; + host.innerHTML = (past ? `

    ${esc(t("past", { g: gateName(g.gate, true) }))}${D.current ? ` ${esc(t("to_round"))}` : ""}

    ` : "") + g.html; const root = $(".gate", host); if (V) { // its heading is the module's; a missing file's warning stays const head = $(".g-head", root); diff --git a/tools/desk/test_page.py b/tools/desk/test_page.py index 07e4f373..ddc8eecb 100644 --- a/tools/desk/test_page.py +++ b/tools/desk/test_page.py @@ -91,6 +91,17 @@ def v(res, name): F.mark_consumed(late, [first]) # (as an agent's wait or desk feedback leaves it) fix = film("fix", E1) # nothing submitted yet: "先改" picked with no note busy = film("busy", dict(E1, least_sure=[{"id": f"c0{i}", "note": f"第 {i} 句会不会太书面,念出来像在读稿"} for i in range(1, 5)])) # eight notes kept beside a full column: the newest and the state line on screen at 1440 x 900 +# the window shows what the files say, and a stop opens on what it asks about +OUTLINE_AGAIN = {"summary": "大纲改成 3 段,再看一遍", "decisions": [{"id": "go", "question": "大纲能做分镜了吗?", "options": [{"id": "OK", "label": "可以"}, {"id": "FIX", "label": "先改"}], "recommend": "OK"}]} +reopen = film("reopen", E1) # gate ① decided, then the outline sent again (1b, no concept cards) +(reopen / "out" / "review" / "gate-1b.json").write_text(json.dumps(OUTLINE_AGAIN, ensure_ascii=False), encoding="utf-8") +subprocess.run(["bash", str(VH), "review", str(reopen), "1b"], capture_output=True, text=True, env=ENV, timeout=60, check=True) +script = film("script", E1) # the script's stop +follow = film("follow", E1) # open on the script; the agent sends the outline again meanwhile +files = film("files", E1) # open on the outline; the agent cuts it from 3 parts to 2 meanwhile +brief = (files / "BRIEF.md").read_text(encoding="utf-8") +two = re.sub(r"\n\| 3 \|[^\n]*", "", brief.replace("| 2 | 两个鼓包 | 9–21 s |", "| 2 | 两面都鼓 | 9–32 s |")) +tabs = film("tabs", E1) # the stop's page on the outline module: a tab clicked opens where the tabs are proc = subprocess.Popen([sys.executable, str(HERE / "fixtures" / "with_tty.py"), "bash", str(VH), "desk", "--root", str(T / "root"), "--port", "0", "--no-open", "--print-address"], stdout=subprocess.PIPE, stderr=subprocess.STDOUT, text=True, env=ENV, start_new_session=True) @@ -135,6 +146,34 @@ def v(res, name): "body: [B.top, B.bottom], text: h && h.innerText }; })())", "name": "busy_view"}, ] + WHERE = "JSON.stringify({ mod: ($('#stage [data-mod]') || {}).dataset && $('#stage [data-mod]').dataset.mod, hash: decodeURIComponent(location.hash), " \ + "tab: (($('nav.subtabs [aria-selected=true]') || { getAttribute: () => '' }).getAttribute('href')) || '', cards: !!$('.c-cards') })" + steps += [ + # bin/vh gate opens a stop at #/p//gate/: the outline's second page on the outline, its question in the column + {"go": f"#/p/{key(reopen)}/gate/1b", "after": 3000}, tab, {"eval": WHERE, "name": "reopen_at"}, + {"go": f"#/p/{key(script)}/gate/E1", "after": 3000}, {"eval": WHERE, "name": "script_at"}, + # the agent sends another page while the person is on the script: the page follows, and the address names what is shown + {"go": f"#/p/{key(follow)}/outline/script", "after": 2500}, + {"write": str(follow / "out" / "review" / "gate-1b.json"), "text": json.dumps(OUTLINE_AGAIN, ensure_ascii=False)}, + {"write": str(follow / "out" / "review" / "gate-1b.html"), "text": "1b"}, # (bin/vh gate writes the page with it) + {"write": str(follow / "out" / "review" / ".current"), "text": "1b\n"}, + {"until": f"location.hash === '#/p/{key(follow)}/outline' && $('#stage [data-mod=outline]') && !$('nav.subtabs [aria-selected=true][href$=\"/script\"]')", "name": "follow_at", "ms": 15000}, + {"reload": True}, {"eval": WHERE, "name": "follow_reload"}, + # the agent rewrites the outline while it is open, a note kept on its third part: the page shows two parts, says the note's place is gone + {"go": f"#/p/{key(files)}/outline", "after": 2500}, tab, + {"eval": "document.querySelectorAll('#stage [data-mark^=\"seg:\"]').length", "name": "files_before"}, + {"eval": KEEP.format(t="seg:3", x="第三段太长", lb="大纲 第 3 段"), "name": "keep3"}, + {"eval": "(document.activeElement && document.activeElement.blur(), true)", "name": "blur"}, + {"write": str(files / "BRIEF.md"), "text": two}, + {"until": "document.querySelectorAll('#stage [data-mark^=\"seg:\"]').length === 2 && /两面都鼓/.test($('#stage').innerText)", "name": "files_after", "ms": 15000}, + {"eval": "JSON.stringify({ hash: decodeURIComponent(location.hash), gone: /不在了/.test($('#cMine').innerText) })", "name": "files_where"}, + # the stop's page on the outline: clicking the script tab leaves the tab row where it was, and the page's rest comes after + {"go": f"#/p/{key(tabs)}/outline", "after": 2500}, + {"eval": "$('nav.subtabs').getBoundingClientRect().top", "name": "tabs_before"}, + {"click": "nav.subtabs a[href$='/outline/script']", "after": 2000}, + {"eval": "JSON.stringify({ top: $('nav.subtabs').getBoundingClientRect().top, body: $('#modBody') && $('#modBody').getBoundingClientRect().top, " + "rest: $('#gatePart') && $('#gatePart').getBoundingClientRect().top, script: !!$('nav.subtabs [aria-selected=true][href$=\"/script\"]') })", "name": "tabs_after"}, + ] res = drive(url, steps) finally: try: @@ -178,4 +217,28 @@ def seen(x): # inside the column's visible part, and inside the block's own except (TypeError, ValueError, KeyError): ok = False check("eight notes kept beside two decisions, four unsure places and three appendices at 1440 x 900: the notes' state line and the note kept last are on screen, no scrolling", ok, bv) + + +def js(name): + try: + return json.loads(v(res, name)) + except (TypeError, ValueError): + return {"raw": v(res, name)} + + +ra, sa, fr = js("reopen_at"), js("script_at"), js("follow_reload") +check("a stop opens on what it asks about: the outline sent again (no concept cards) on the outline with its question in the column, the script on the " + "outline's script tab; the address then names that module", + ra.get("mod") == "outline" and ra.get("hash", "").endswith("/outline") and ra.get("cards") and sa.get("mod") == "outline" + and sa.get("hash", "").endswith("/outline/script") and sa.get("tab", "").endswith("/script"), [ra, sa]) +check("a page the agent sends while the person is elsewhere: the window follows to it, the address names what is shown, and a reload stays there", + (res.get("follow_at") or {}).get("ok") and fr.get("mod") == "outline" and fr.get("hash", "").endswith("/outline"), [res.get("follow_at"), fr]) +fa, fw = res.get("files_after") or {}, js("files_where") +check("the agent rewrites the outline while it is open: within seconds the page shows the new parts, stays where it was, and a note kept on a part that " + "is gone says so", v(res, "files_before") == 3 and fa.get("ok") and fw.get("hash", "").endswith("/outline") and fw.get("gone"), [v(res, "files_before"), fa, fw]) +tb, ta = v(res, "tabs_before"), js("tabs_after") +check("the script tab clicked on a stop's page: the tab row is not pushed down, the tab's content starts right under it, and the page's decided, " + "delegated and appendices come after that content", + isinstance(tb, (int, float)) and ta.get("script") and ta.get("top", 1e9) <= tb + 4 and ta.get("body") and ta["body"] - ta["top"] < 80 + and ta.get("rest") and ta["rest"] > ta["body"], [tb, ta]) print("end", flush=True) From 1cb3f7fd123f33ba2e87d8b8ad3bb3826bf93605 Mon Sep 17 00:00:00 2001 From: zhanglinghao Date: Mon, 23 Nov 2026 17:44:08 +0800 Subject: [PATCH 5/7] Hand-over review: a note is picked up only once it was written; the notes block holds from 1280x720; A10 asks only when the page says so - feedback.py: a hand-over is two steps. claim() writes an unconfirmed claim (pid, when) under the lock; the note is written and flushed; only then confirm() makes it taken. A claim whose process is gone is no claim; a signal releases this process's claims; a closed or broken output releases them and ends the wait with 74. unread() counts every unconfirmed note; taken() only confirmed ones. A wait started orphaned hands nothing over. New submissions are looked at before the page-changed check, so exit 7's "nothing was submitted" is true. "late" needs a hand-over recorded by this version. One WAIT constant for desk wait and gate --wait. - status.py: the stop's row and next: name one command, bin/vh desk wait. - standing.py, agent.js, core.js: an outside agent is "open" on the film, never said to be working. - Studio: the column is two parts, what to decide scrolling above and the notes block below (at most half the column), so the block holds from 1280x720 in every theme and in English; drafts on a page the agent replaced are listed as not sent and go to that page's own round, or are dropped, on the person's click; A10 asks only for an option with needs_note (gate --init writes it on gate 3's FIX), documented with the gate JSON. - Checks: a wait killed in the claim-to-write gap (KILL, TERM, INT) and one with a closed output leave the note unread; two waits held at the claim and released together hand it over once (fails without the lock); the layout at both sizes, three themes, English; drafts of a replaced page; "no change" options never ask; the page check stops its own desk's process tree; the handoff group ends the stand-in it builds. - playbook 01 and the skill: on return, bin/vh status, then bin/vh desk wait; what to do when the host ended a wait. --- changes/studio-handover-trust.md | 9 +- playbook/01-pipeline.md | 4 +- .../.claude-plugin/plugin.json | 2 +- .../.codex-plugin/plugin.json | 2 +- plugins/open-video-harness/skills.sha256 | 2 +- .../skills/open-video-harness/SKILL.md | 2 +- skills/open-video-harness/SKILL.md | 2 +- tools/ci.sh | 4 +- tools/desk/README.md | 7 +- tools/desk/desk.py | 6 +- tools/desk/feedback.py | 188 +++++++++++++++--- tools/desk/page_driver.mjs | 2 + tools/desk/static/agent.js | 8 +- tools/desk/static/core.js | 12 +- tools/desk/static/studio.css | 8 +- tools/desk/static/studio.js | 54 ++++- tools/desk/test_agents.py | 105 +++++++++- tools/desk/test_page.py | 96 +++++++-- tools/gate.py | 5 +- tools/schemas/gate.schema.json | 3 +- tools/standing.py | 6 +- tools/status.py | 8 +- 22 files changed, 434 insertions(+), 101 deletions(-) diff --git a/changes/studio-handover-trust.md b/changes/studio-handover-trust.md index d7cd9d2d..6943d74c 100644 --- a/changes/studio-handover-trust.md +++ b/changes/studio-handover-trust.md @@ -3,7 +3,10 @@ - 每份提交只在三种状态里的一种,Studio、`bin/vh status` 和等着的 agent 说的一样:还没人取;取走了(什么时候、被哪个 agent 程序,记在 `out/review/feedback/.consumed`);答过了(REVIEW.md 里它那一节写了定了)。一轮被取走以后再写的意见是这一轮的补交,单独交、单独显示,不并进别的哪一页。 - `bin/vh desk wait` 和 `bin/vh gate --wait` 等的是一轮:一开始先把所有还没人取的意见交出来,哪一轮的都算(补交的写明);两个同时在等,同一份只有一个拿到;等的时候这一页换成了别的页,就说这一轮没人交、退出 7,不再把下一页的提交当成自己这一页的。超时、agent 没了、被停下,都不碰没人取的意见。默认等 12 小时(原来是 7100 秒,人睡一觉 agent 要醒好几次)。 - `bin/vh status`:有没人取的意见时,下一步先说它们(`unread:` 一行,`--json` 的 `review.unread`),一条 `bin/vh desk wait` 就全交出来;已经定了的关卡 ① 又发出一页(比如大纲复审 1b),这一页等人回,不再算成已定;`holder` 说开着这支片子的 agent 是哪个程序、在不在 Studio 窗口外面。 +- 这个版本以前的片子:agent 当时自己读了文件、在这一站自己的那一节里写了定了的提交,升级以后会被当成没人取的意见列一次(再跑一次 `bin/vh desk wait` 就交出去了);没有这个版本取走记录的轮次,不会被说成"补交"。什么都不会丢。 - 右栏的状态话只说真的:"正在取"只在有一个活着的等待、等的正是现在这一轮时说;页面在等人时右栏照样摆出这一页要定的事。 -- Studio 右栏:"你的意见"一块写清每份意见的状态(还没交几条;交了几条、还没人取,谁会来取;几点被谁取走),钉在写意见的框上面,1440×900 下决定卡片再多也不用滚就看得到刚记下的那一条。一轮被取走以后,按钮是"补交",交之前和交之后都说清这几条没人在等、什么时候会被取;有 AI 在等这一轮才说"马上会取"。 -- 选了"先改"却一条意见都没写,交之前问一句改哪里:"回去写"或"就这样交"。 -- 片子由 Studio 窗口外面的 agent(终端或桌面版里的 Claude Code、Codex)在做时,右栏直说它在窗口外面、在这里打的字它收不到;"在这里另起一个 AI 做这支片子"放到第二行,点了还要再确认一次;对话页第一句话发出之前也先问,点"另起一个 AI"才开始。 +- Studio 右栏:"你的意见"一块写清每份意见的状态(还没交几条;交了几条、还没人取,谁会来取;几点被谁取走),就在写意见的框上面。右栏分成上下两块:要定的事在上面自己滚,"你的意见"在下面,最多占右栏一半、自己滚;从 1280×720 起,决定卡片再多也不用滚就看得到刚记下的那一条(比这更矮时,上面那块至少留 6 行高)。一轮被取走以后,按钮是"补交",交之前和交之后都说清这几条没人在等、什么时候会被取;有 AI 在等这一轮才说"马上会取"。 +- 交一份意见分两步:先认领,写出去、flush 成功才算取走。等待在中间被停下、被杀,或者它的输出已经关掉(退出 74),这份意见照样算还没人取,页面不会说它被取走了,下一个等待把它交出去。 +- 人写了却没交的意见,agent 换了新的一页以后不再看不见:"你的意见"里列着"在旁白稿那一页写的 n 条,还没交",人点"交到旁白稿那一轮"才交出去,或者点"不要了"。 +- 选了"先改"却一条意见都没写,交之前问一句改哪里:"回去写"或"就这样交"。只有审阅页的 JSON 里这个选项写了 `needs_note: true` 才问(`bin/vh gate --init` 给关卡 ③ 的 FIX 写上了),不从选项的字面去猜;以前的页没有这一项,从来不问。 +- 片子开在 Studio 窗口外面的 agent(终端或桌面版里的 Claude Code、Codex)里时,右栏直说它在窗口外面、在这里打的字它收不到(只说它开着,不说它在做);"在这里另起一个 AI 做这支片子"放到第二行,点了还要再确认一次;对话页第一句话发出之前也先问,点"另起一个 AI"才开始。 diff --git a/playbook/01-pipeline.md b/playbook/01-pipeline.md index 2a67273d..e0e9426d 100644 --- a/playbook/01-pipeline.md +++ b/playbook/01-pipeline.md @@ -200,7 +200,7 @@ projects/2026-10-01-leo-doppler/ ``` - **必填**:`summary`,一句话说这页要你定什么、看完要多久;`decisions`,没有要定的写 `[]`。每个决定要有 `question`、`recommend` 和 `reply`(不写 `reply` 就用选项名拼)。选项的 `id` 别用纯数字,免得和决定的编号混在一起;同一页的几个决定也别共用 `id`(一个用 A / B,另一个用 H1 / H2),人随手回一个"A"才不会有歧义。 -- **选填**:`version`(骨架带的 1,不读)、`why`、`cost`,选项的 `label` / `pro` / `con`(文字里的换行照样换行)、`frame`(这张卡的那一帧,立意卡用它)、`titles` 和 `cover`(要发平台的片子,每张立意卡带的 2 个标题和 1 个封面版式,`playbook/10-hooks-and-packaging.md` 第 1 节;知识短视频的骨架写好了这两项,页面把它们排在卡上),决定的 `columns`(`pro`、`con` 两栏的标题,不写是"好处 / 代价";关卡 ① 的骨架写"这张卡讲什么 / 风险或代价");`decided` 和 `delegated`(都是列表,一项一条)、`not_reviewed`、`title`、`lang`(`zh` / `en`;不写就用 BRIEF 的 `Review language`)、`gate`(和文件名不一致时以文件名为准)、`film`(播哪支视频,不写取第一支)、`listen`(`[{"t": 秒, "note": "…"}]`,请人听这几处)。`music` 只有审阅台用(见下面的"审阅台")。 +- **选填**:`version`(骨架带的 1,不读)、`why`、`cost`,选项的 `label` / `pro` / `con`(文字里的换行照样换行)、`frame`(这张卡的那一帧,立意卡用它)、`needs_note`(`true`:选它就是要改,人选了却一条意见都没写时,Studio 交之前问一句改哪里;关卡 ③ 骨架的 FIX 带着它)、`titles` 和 `cover`(要发平台的片子,每张立意卡带的 2 个标题和 1 个封面版式,`playbook/10-hooks-and-packaging.md` 第 1 节;知识短视频的骨架写好了这两项,页面把它们排在卡上),决定的 `columns`(`pro`、`con` 两栏的标题,不写是"好处 / 代价";关卡 ① 的骨架写"这张卡讲什么 / 风险或代价");`decided` 和 `delegated`(都是列表,一项一条)、`not_reviewed`、`title`、`lang`(`zh` / `en`;不写就用 BRIEF 的 `Review language`)、`gate`(和文件名不一致时以文件名为准)、`film`(播哪支视频,不写取第一支)、`listen`(`[{"t": 秒, "note": "…"}]`,请人听这几处)。`music` 只有审阅台用(见下面的"审阅台")。 - `assets[].for` 写决定或分段的 `id`,图就挂在那件决定或那一段下;不写的进"材料"。视频加 `t0` / `t1` 只播一段,加 `poster` 指定封面帧。附录的 `text` 可以放简单的竖线表格(`| a | b |`、`|---|---|`)。 - `least_sure` 的 `id` 写镜头号(`S04`)或时间(`12.4 s`、`0–5 s`),也可以写 `t`、`t1` 秒数。镜头的 `note` 写"默认会这样改"。 - `include`:一个 JSON 文件(或几个的列表),路径相对项目,只补 gate JSON 没写的键,gate JSON 写了的优先;`bin/vh storyboard` 写的 `out/check/storyboard/review.json` 就是给它用的。 @@ -214,7 +214,7 @@ projects/2026-10-01-leo-doppler/ - **语言**:界面语言取 BRIEF 的 `Review language`(`zh` / `en`),按用户第一句话的语言定,建项目时用 `bin/vh new … --lang en`;这一轮的 gate JSON 写了 `lang` 时以它为准(和静态审阅页同一条规则);页面右上角也能切换。字幕和项目文档照旧用项目自己的语言。 - **出页**:运行 `bin/vh gate --desk`,把它打印的消息交给人,在这一关停住。命令会打开 Studio 到这一轮的视图。服务没起来时,静态页可以复制回复到聊天。 - **有后台唤醒的宿主**:可在后台运行 `bin/vh gate --desk --wait` 出页并等待。这条命令默认等 12 小时,先打印交给人的消息,收到反馈再打印并退出;人在已经被取走的一轮里补交的、别的轮还没人取的意见,它一开始就先交出来。退出 7 是这一页已经换成了别的页、这一轮没人交:跑 `bin/vh status`,在现在开着的那一轮上再等。此方式适合能在命令结束后唤醒 agent 的会话。不带 `--desk` 也行:这一站开在 Studio 里时 `--wait` 就等;`standard` 的这一站按默认落到静态页(Studio 没开)时,它照常出页、退出 5:没有人答复,这一轮停下,等人在聊天里回。 -- **Codex 或等待已超时的会话**:人在 Studio 提交后,回原对话说一声"我交了"(英文是"I've sent it";Studio 和 `bin/vh gate` 现在教人这么说;老说法"看审阅台""check the desk"也一样算)。继续时先跑 `bin/vh status `,再按 `next:` 读 `bin/vh desk feedback --round <实际轮次>`。适用的原话已写进 `REVIEW.md`,在同一节补"定了 / 改了";自己定的事记进 `DECISIONS.md`。没标的条目都算通过。 +- **Codex 或等待已超时的会话**:人在 Studio 提交后,回原对话说一声"我交了"(英文是"I've sent it";Studio 和 `bin/vh gate` 现在教人这么说;老说法"看审阅台""check the desk"也一样算)。继续时先跑 `bin/vh status `,按 `next:` 跑 `bin/vh desk wait `:还没人取的意见它立刻全交出来。宿主把等待停掉了(后台命令被结束、会话醒来时它已不在)也一样:先跑 `bin/vh status`,没人取的意见都还在。适用的原话已写进 `REVIEW.md`,在同一节补"定了 / 改了";自己定的事记进 `DECISIONS.md`。没标的条目都算通过。 - **页面读什么**:项目文件本身和 `bin/vh status`,每次刷新重读,不另存状态。表格怎么写才排得出来(BRIEF 的 Outline 表、SCRIPT 的字幕或旁白表、NOTES 素材清单、DECISIONS 的划线约定、REVIEW、`shots.json`)、gate JSON 给审阅台加的 `music`(音轨、节拍表、乐段的名字),以及提交的 JSON 格式,都在 `tools/desk/README.md`。读不出结构的文档不会消失:照原文排版显示在对应的模块和账本的"文档"里。人想随时看所有片子,`bin/vh desk` 不带项目开一个控制台就行(`--root <文件夹>` 加别处的项目)。 - **成片模块要的数据**:都是已有命令的输出,缺哪样那条轨道就空着、写着做它的命令。关卡 ③ 用审阅台时,片子出来后跑一次 `bin/vh thumbs ` 和 `bin/vh peaks `(只用 ffmpeg,几秒),人拖动时间线就能看到每一秒的画面和波形;镜头、旁白和节拍来自 `bin/vh timeline --resolved` 读的那几份文件,检查的问题来自 `bin/vh check` 的记录,第几版、改了哪里和上一版来自 `bin/vh versions`。 - **同一片段改完再审**:留好人点评的有声成片。新的一版检查通过后,用 `bin/vh desk revision` 把那条意见和两版成片发到 Studio 的「复审」。人打开就能在同一时间范围看改前改后,并切换试听。 diff --git a/plugins/open-video-harness/.claude-plugin/plugin.json b/plugins/open-video-harness/.claude-plugin/plugin.json index 882de5ce..8dd1b099 100644 --- a/plugins/open-video-harness/.claude-plugin/plugin.json +++ b/plugins/open-video-harness/.claude-plugin/plugin.json @@ -1,6 +1,6 @@ { "name": "open-video-harness", - "version": "1.0.1", + "version": "1.0.2", "description": "Make videos with code through the OpenVideoHarness workbench: say what film you want, an agent writes the code, renders it, checks it and stops for you at the decisions that are yours. This plugin is the pointer; on first use it asks before installing the workbench.", "author": { "name": "ZLHad", diff --git a/plugins/open-video-harness/.codex-plugin/plugin.json b/plugins/open-video-harness/.codex-plugin/plugin.json index ac1a6e40..a0826a6b 100644 --- a/plugins/open-video-harness/.codex-plugin/plugin.json +++ b/plugins/open-video-harness/.codex-plugin/plugin.json @@ -1,6 +1,6 @@ { "name": "open-video-harness", - "version": "1.0.1", + "version": "1.0.2", "description": "Make videos with code through the OpenVideoHarness workbench: say what film you want, an agent writes the code, renders it, checks it and stops for you at the decisions that are yours. This plugin is the pointer; on first use it asks before installing the workbench.", "author": { "name": "ZLHad", diff --git a/plugins/open-video-harness/skills.sha256 b/plugins/open-video-harness/skills.sha256 index 9b0e7898..a508fdce 100644 --- a/plugins/open-video-harness/skills.sha256 +++ b/plugins/open-video-harness/skills.sha256 @@ -1 +1 @@ -2e8351d729f312029abf914ac04058b14573beffbd6df30895463134e9909492 +1b2ef66cce56f6b1babe9158cac02d8cbfb89070cf3e03def00ebd2a632fd26b diff --git a/plugins/open-video-harness/skills/open-video-harness/SKILL.md b/plugins/open-video-harness/skills/open-video-harness/SKILL.md index b848fde5..2a707e2b 100644 --- a/plugins/open-video-harness/skills/open-video-harness/SKILL.md +++ b/plugins/open-video-harness/skills/open-video-harness/SKILL.md @@ -80,5 +80,5 @@ The harness prints paths and chat lines because every agent can read those. When - **Show the page and the film beside the chat.** If the host can display a local file next to the conversation (a side panel, a preview pane, a file card), open the stop's review page (`out/review/gate-.html`), the contact sheet and the draft or final film there when you stop or deliver. Give the path as well. - **Ask with the host's question tool.** If the host has a tool that asks the user a question with options (Claude Code's `AskUserQuestion`, for one), put the stop's decisions there: one question a decision, at most three, the options and the recommended one taken from the gate JSON, the recommended one first. What the user picks and any note they type are their words: copy them into `REVIEW.md` verbatim, as you would a chat reply. - **Carry on in the same turn.** When the answer comes back, record it and go on to the next step at once. Do not end the turn to say that you will. -- **Resume a Studio review in Codex.** Publish with `bin/vh gate --desk` and tell the reviewer to return to the conversation after submitting. On return, use `bin/vh status` and read the feedback for the reported round. Use `--wait` in hosts that wake the agent after the command completes. +- **Resume a Studio review in Codex.** Publish with `bin/vh gate --desk` and tell the reviewer to return to the conversation after submitting. On return, run `bin/vh status`: notes nobody has taken yet are listed first, and `bin/vh desk wait ` hands them all over at once. Use `--wait` in hosts that wake the agent after the command completes. - **No such tools** (a plain terminal, another agent): send the lines `bin/vh gate` prints and wait for the reply, as CLAUDE.md says. diff --git a/skills/open-video-harness/SKILL.md b/skills/open-video-harness/SKILL.md index b848fde5..2a707e2b 100644 --- a/skills/open-video-harness/SKILL.md +++ b/skills/open-video-harness/SKILL.md @@ -80,5 +80,5 @@ The harness prints paths and chat lines because every agent can read those. When - **Show the page and the film beside the chat.** If the host can display a local file next to the conversation (a side panel, a preview pane, a file card), open the stop's review page (`out/review/gate-.html`), the contact sheet and the draft or final film there when you stop or deliver. Give the path as well. - **Ask with the host's question tool.** If the host has a tool that asks the user a question with options (Claude Code's `AskUserQuestion`, for one), put the stop's decisions there: one question a decision, at most three, the options and the recommended one taken from the gate JSON, the recommended one first. What the user picks and any note they type are their words: copy them into `REVIEW.md` verbatim, as you would a chat reply. - **Carry on in the same turn.** When the answer comes back, record it and go on to the next step at once. Do not end the turn to say that you will. -- **Resume a Studio review in Codex.** Publish with `bin/vh gate --desk` and tell the reviewer to return to the conversation after submitting. On return, use `bin/vh status` and read the feedback for the reported round. Use `--wait` in hosts that wake the agent after the command completes. +- **Resume a Studio review in Codex.** Publish with `bin/vh gate --desk` and tell the reviewer to return to the conversation after submitting. On return, run `bin/vh status`: notes nobody has taken yet are listed first, and `bin/vh desk wait ` hands them all over at once. Use `--wait` in hosts that wake the agent after the command completes. - **No such tools** (a plain terminal, another agent): send the lines `bin/vh gate` prints and wait for the reply, as CLAUDE.md says. diff --git a/tools/ci.sh b/tools/ci.sh index 3cc0e9c8..f948cc22 100755 --- a/tools/ci.sh +++ b/tools/ci.sh @@ -3349,7 +3349,7 @@ desk_checks() { local pt k m; pt=$(mktemp -d "${TMPDIR:-/tmp}/vh-ci.XXXXXX") python3 tools/desk/test_page.py "$pt" > "$pt/out" 2>&1 while IFS=$'\t' read -r k m; do - case $k in ok) ok "Studio's page: $m" ;; bad) bad "Studio's page: $m" ;; skip) no_chrome "Studio's page (${m%%:*})" ;; esac + case $k in ok) ok "Studio's page: $m" ;; bad) bad "Studio's page: $m" ;; skip) case $m in *"no node"*) skip "Studio's page" "no node" ;; *) no_chrome "Studio's page (${m%%:*})" ;; esac ;; esac done < "$pt/out" grep -qx end "$pt/out" || bad "Studio's page: the test stopped: $(tail -n 3 "$pt/out" | tr '\n' ' ')" rm -rf "$pt" @@ -8503,7 +8503,7 @@ feedback.save(p, feedback.validate(p, {"round": "1", "lang": "zh", "decisions": "items": [{"target": "range:3-4.5", "status": "change", "text": "这里太快"}, {"target": "card:B", "status": "ok"}]})) PY b=$(st "$p" "1:waiting_agent 2:not_started 3:not_started deliver:not_started | agent" 'd["stations"][0]["feedback"]["pending"] == 1' \ - 'd["next_step"]["commands"][0].endswith(" --round 1")' \ + 'd["next_step"]["commands"][0].startswith("bin/vh desk wait ")' \ '[(i["target"], i["label"]) for i in d["open"]["review_items"]] == [("range:3-4.5", "片段 0:03.0–0:04.5")]') vh desk feedback "$p" >/dev/null c=$(st "$p" "1:waiting_agent 2:not_started 3:not_started deliver:not_started | agent" 'd["stations"][0]["feedback"]["handed"] == 1' 'len(d["open"]["review_items"]) == 1') diff --git a/tools/desk/README.md b/tools/desk/README.md index 394bc1a0..861191f1 100644 --- a/tools/desk/README.md +++ b/tools/desk/README.md @@ -13,7 +13,7 @@ bin/vh studio --install-icon [--no-shell] [--dir 文件夹] # OVH Studio:Stu bin/vh gate <项目> [--desk|--page|--chat] [--wait] [--print-address] # 一次停一条命令:查 gate-.json,出静态页并记成这一轮(审阅方式:旗子、LOCAL.md,再按档位:studio 是审阅台,standard 在 Studio 开着时也是,否则是静态页;--wait 而 `standard` 的这一站按默认落到静态页(Studio 没开)时,照常出页、退出 5:没有人答复,这一轮停下,等人在聊天里回;`OVH_GATE_STUDIO=0` 时不去找 Studio,`tools/ci.sh` 整个运行都这样设,它的检查不碰不是自己起的 Studio),审阅方式是审阅台时把这一站开在 Studio 的窗口里(Studio 在跑就用它,不在它文件夹里的片子先加进它的空间;Studio 没在跑才在后台起这个项目的审阅台,12 小时没人访问自己停),打印聊天消息;--wait 再像 desk wait 一样等 bin/vh desk [--root 文件夹 …] [--port N] [--no-open] [--print-address] # 控制台:bin/vh projects 找得到的所有项目($OVH_PROJECTS、<仓库>/projects、每个 --root);在终端里起时,起好就叫出它的窗口(--no-open 不开),agent 起的不开;终端里不显示地址,agent 和日志拿到的地址打开的页面只能看(--print-address 才把开门地址写到终端);同样的 roots 已经有一个在跑,就只说一声 bin/vh desk <项目> [--root 文件夹 …] [--port N] [--idle 秒] [--only] # 同一个页面,打开在这个项目上,空间里照样有 roots 下的每一支片子;只听 127.0.0.1;默认 8780–8799 里第一个空闲端口;这个项目已经有一个在跑,就只打印它的地址;--idle:这么久没人访问就自己停;--only:只服务这一个项目(bin/vh gate 在后台起的就是 --only --idle 43200) -bin/vh desk wait <项目> [--timeout 秒] # 等人提交:收到提交才打印反馈、退出码 0;超时退出码 3(默认 43200 s,12 小时);等的 agent 没了退出码 4;这一轮的页已经换成了别的页、没人交过退出码 7;一开始先交出所有还没人取的意见,哪一轮的都算 +bin/vh desk wait <项目> [--timeout 秒] # 等人提交:收到提交才打印反馈、退出码 0;超时退出码 3(默认 43200 s,12 小时);等的 agent 没了退出码 4;这一轮的页已经换成了别的页、没人交过退出码 7;输出被关掉、意见写不出去退出码 74(意见还算没人取);一开始先交出所有还没人取的意见,哪一轮的都算 bin/vh desk feedback <项目> [--round 1b] [--json] # 打印最近一次提交,并记为"已交给 agent" bin/vh desk data <项目> # 审阅台从项目里读出了什么(JSON),排查"为什么这一页是空的"时用 bin/vh desk link [<项目>] [--root 目录 …] [--force] [--print-address] # 重起它:停掉在跑的那一个,照原样再起,叫出新的窗口;之前的页面只能看(各有一个把窗口叫出来的按钮) @@ -243,6 +243,7 @@ bin/vh desk agents install # 装那一家的 ACP 适配器 - `listen`:"请你听这几处",`t` 是秒:关卡视图标尺上的记号(和静态页一样),声音页签里的按钮。 - `music`:声音页签播哪条音轨、读哪份节拍表、乐段在色块上叫什么(`labels` 把乐段的 `name` 换成人看得懂的名字)。不写时,读 `audio/` 里最新的 `*.beats.json`,音轨取同名的 `*_mix.wav`,没有再取 `*.wav`,谱面取同名的 `.roll/overview.png`。节拍表也用来把"小节"换成秒。只有审阅台用它。 +- 选项的 `needs_note`:`true` 是"选它就是要改"(关卡 ③ 骨架的 FIX 带着它):人选了它、却一条意见、一句整体意见都没写,交之前问一句改哪里("回去写"或"就这样交")。不带它的选项从来不问,Studio 不从选项的字面去猜。 - `film`:关卡视图顶上播哪支视频,逐秒点评页签也播它;不写就用 `assets` 里第一支视频,再没有用 `animatic`。时长从视频本身读。 路径都相对项目目录;审阅台只给项目目录里的文件(不给隐藏文件,不出项目目录)。 @@ -255,7 +256,7 @@ bin/vh desk agents install # 装那一家的 ACP 适配器 2. `REVIEW.md`:插一节 `## 审阅台反馈 · 关卡 <轮> · <日期 时间>`,把上面的文字整段原样放进代码块,下面留一行"定了: 改了:"给 agent 填;插在模板的"授权跳过怎么记"之前,没有这一节就接在文末; 3. `out/review/feedback/<轮>-.json`:最后写,原子替换。`bin/vh desk wait` 等的就是它。同一秒里的第二份、第三份加 `-2`、`-3`,按数字排。 -一份提交只在三种状态里的一种:**还没人取**(存好了,没交给任何 agent)、**取走了**(记在 `out/review/feedback/.consumed`:`files` 是名字,`taken` 记着每一份是什么时候、被哪一次运行(`bin/vh` 的活动记录里的 run)、在哪个 agent 程序下(claude、codex……)、怎么取走的(`wait` 或 `feedback`))、**答过了**(它在 REVIEW.md 里的那一节写了定了)。`bin/vh desk wait` 打印过的、`bin/vh desk feedback` 打印过的,都算取走了;认领在 `.consumed.lock` 的文件锁里做,两个 `wait` 同时看到同一份,只有一个拿到。一轮已经被取走以后人又交的,是这一轮的**补交**:照样是一份自己的提交,单独说,不并进别的哪一轮。`wait` 等的是一轮(`bin/vh gate --wait` 的那一页,否则是这一轮的页):一启动,先把所有还没人取、也还没答过的提交都交出来,不管是哪一轮的(补交的会写明,比如上一次 `wait` 超时以后人才交的,或者已经往后走了的那一轮的补交),有就立刻打印、退出 0;没有才开始等新的;等的时候这一轮的页换成了别的页,就说"这一轮没人交"、退出 7,agent 跑 `bin/vh status`、在现在开着的那一轮上再等。超时、agent 没了、被停下,都不碰没人取的意见:下一个 `wait` 和 `bin/vh status` 都看得到。`.listening`(有 agent 在等)和 `.desk.json`(服务在跑)里都记着项目目录的完整路径,从别的项目拷来的这两个文件不算数。`.listening` 只在三样都真的时候算有人在等:写它的 `wait` 进程还活着;这个 pid 没被后来的进程占去(进程开始的时间不晚于旗子的 `since`,`ps` 的 `lstart`,到秒);它等的那个 agent 还在(`wait` 启动时往上找最近的一个 agent 程序(claude、codex……,名字整个对上;或者跑着它们的 node),记成 `agent: {pid, start}`,`start` 是它开始的时刻(epoch 秒,用 `ps` 的 `etime` 算,不带时区);找不到就不记;读不出开始时间就不当成同一个进程)。那个 agent 没了,或者 `wait` 自己的父进程没了(被别的进程收养:起它的不管是什么程序,已经结束),`wait` 自己结束(退出 4,旗子拿走),不把意见交给没人读的地方。 +一份提交只在三种状态里的一种:**还没人取**(存好了,没交给任何 agent)、**取走了**(记在 `out/review/feedback/.consumed`:`files` 是名字,`taken` 记着每一份是什么时候、被哪一次运行(`bin/vh` 的活动记录里的 run)、在哪个 agent 程序下(claude、codex……)、怎么取走的(`wait` 或 `feedback`))、**答过了**(它在 REVIEW.md 里的那一节写了定了)。`bin/vh desk feedback` 打印过的算取走了;`bin/vh desk wait` 交一份分两步:先在 `.consumed.lock` 的文件锁里认领(`claims`:认领它的进程号和时刻,还不算取走),把这一份写出去、flush 成功了,才改成取走。两个 `wait` 同时看到同一份,只有一个认领得到;认领了还没写出去时 `wait` 被停下(TERM、INT、HUP),认领撤回;被 KILL、崩了,认领它的进程不在了,这份照样算还没人取;输出被关掉、写不出去,撤回认领、退出 74。页面、`bin/vh status` 和下一个 `wait` 说"取走了",只认写出去以后的那一步。一轮已经被取走以后人又交的,是这一轮的**补交**:照样是一份自己的提交,单独说,不并进别的哪一轮。`wait` 等的是一轮(`bin/vh gate --wait` 的那一页,否则是这一轮的页):一启动,先把所有还没人取、也还没答过的提交都交出来,不管是哪一轮的(补交的会写明,比如上一次 `wait` 超时以后人才交的,或者已经往后走了的那一轮的补交),有就立刻打印、退出 0;没有才开始等新的;等的时候这一轮的页换成了别的页,就说"这一轮没人交"、退出 7,agent 跑 `bin/vh status`、在现在开着的那一轮上再等。超时、agent 没了、被停下,都不碰没人取的意见:下一个 `wait` 和 `bin/vh status` 都看得到。`.listening`(有 agent 在等)和 `.desk.json`(服务在跑)里都记着项目目录的完整路径,从别的项目拷来的这两个文件不算数。`.listening` 只在三样都真的时候算有人在等:写它的 `wait` 进程还活着;这个 pid 没被后来的进程占去(进程开始的时间不晚于旗子的 `since`,`ps` 的 `lstart`,到秒);它等的那个 agent 还在(`wait` 启动时往上找最近的一个 agent 程序(claude、codex……,名字整个对上;或者跑着它们的 node),记成 `agent: {pid, start}`,`start` 是它开始的时刻(epoch 秒,用 `ps` 的 `etime` 算,不带时区);找不到就不记;读不出开始时间就不当成同一个进程)。那个 agent 没了,或者 `wait` 自己的父进程没了(被别的进程收养:起它的不管是什么程序,已经结束),`wait` 自己结束(退出 4,旗子拿走),不把意见交给没人读的地方。 JSON 的格式: @@ -388,7 +389,7 @@ JSON 的格式: - `next_step`:下一步,按项目停在哪一站算出来:`who`(`person`、`agent`、`nobody`、`unknown`)、`do`(一句话,还没填的 `{…}` 和 gate 骨架里的占位有几处都说出来;Director 写了 `x=own`、还没有记录的事排在最前面,记录是它那一站过了,或者 DECISIONS.md 里它那一行写了已定)、`commands`(能直接跑的命令,`` 这类尖括号是要换的)、`read`(该读的:`<文件>#<节>` 由 `bin/vh know --show` 打印,没有 `#` 的整篇读)、`unfilled`(`BRIEF.md`、`STYLE.md`、`STORYBOARD.md` 各还有几处 `{…}`,不算代码块和行内代码里的,也不算模板的 `{none}` 和 `{fill: #e33}` 这种带值的花括号;交付以后 `who` 是 `nobody`,这里是空的,没有要填的了)。 - `now`:这支片子现在怎么样,说给人听的(`tools/standing.py`,Studio 说的也是这些字;字都在它开头的 `WORDS` 表里,中英文挨着)。只说磁盘能证明的:最后记下的事和它在什么时候(命令的开始和结束、交出的意见、Studio 对话的事件、片子自己文件的改动)、现在有没有进程在跑、等着的进程和它等的 agent 活不活着、Studio 的一轮怎么结束的、一条命令是在哪个 agent 程序下跑的(那个 agent 还活着,就是有 agent 开着这支片子)。磁盘不知道 agent 是不是正在两条命令之间想事情,所以安静的片子只说"上一次动静:12 分钟前,渲染做完了",从不说没人在做;"停下了"要有正面的证据;"让 agent 接着做"是一个可以点的选项,不是"没人在做"的断言。字段:`code`、`who`(下一步该谁动,和 `waiting_on` 一致)、`you`(人跟它有什么事:`decide` 在等人定,`nudge` 要人说一声,`offer` 人可以点,`none`)、`tone`(点的颜色:`you` 琥珀、`busy` 紫、`quiet` 灰)、`say`(`{zh, en}` 一句短话,两秒读完)、`more`(`{zh, en}` 或 `null`:下面那一行)、`short`(`{zh, en}` 卡片上的几个字,不带路径,也不带不在词表里的命令名)、`act`(至多一件事:`{kind: "open", mod, sub, label}` 去 Studio 的哪个模块;`{kind: "settings", sub, label}` 去设置页的哪一节(片子等一家服务的 API Key 时:`code` 是 `needs_key`,`facts.keys` 是还没设的 key 名,`facts.service` 是哪一家,`facts.need` 是 key 拿来做什么:`voice`、`timing`、`music`、`image`;下面那一行按它和这台电脑有什么来说不用 key 的办法,没有就直说没有。从整份记录里找(`activity.key_stop`),不看最近几条:有一个 key 设上了、后来同类的活做成了(配音成了,配音和对时间的停都算过去)、或者后来有别的命令失败了,就不再这么说。只在终端的环境变量里设了 key、Studio 又是从别处打开的,Studio 看不到这个变量,会一直说在等,直到那条命令在那个终端里再跑一次);`{kind: "tell", label, text, confirm, secondary}` 对 agent 说的那句话,`confirm` 是先问一次(最近 30 分钟里还有动静,或者有 agent 开着),`secondary` 是它不是主要该做的事、写成第二行的小字;`{kind: "none"}`)、`facts`(`paths`:这些话里点到的项目文件,Studio 里点得开;还有 `stop`、`listening`、`pending`、`cmd`、`film`、`subtitles`、`version`、`keys`、`service` 这些)。 - `code` 按这个先后取第一个对上的:`paused`(REVIEW.md 写了暂停);`revision_ready`(有一条复审等人看);`waiting_you`(一站的页发出去了等人:`facts.listening` 按上面 `.listening` 的三样算,真就"你交了,agent 就接着做",不然"交了以后,要跟 agent 说一声";声音那一站是"等你听");有意见还没人取、又不只是这一站刚交的那一份时(补交的,或别的轮的),排在等人的页之前先说它们:`notes_late`("你在旁白稿那一轮被取走以后又交了 3 条,还没有 AI 来取。")或 `notes_left`,下面一行说谁会来取:一个活着的 `wait` 正等着现在这一轮,"正在等的 Claude Code 马上会取";做这支片子的 agent 在 Studio 窗口外面,"回到它那边说一声“我交了”";都没有,"现在没有 AI 在等。下次有 AI 接着做这支片子,会先拿到它们。";同时有页在等人,再加一句"大纲也出来了,等你看"。这一站刚交的那一份还没人取时,不管别的在不在跑都先说它:一个活着的 `wait` 正等着现在这一轮(`.listening` 里记着它等的 `round`)是 `notes_sent`,不然 `notes_unheard`(有命令在跑时写"渲染还在跑,但你 21:30 交的这一份没人取";做这支片子的 agent 在窗口外面时,说回到它那边说一声,不给另起一个的按钮);`notes_taken`(意见交到 agent 手里了,而且这会儿真有东西在为这支片子做:`bin/vh` 命令在跑,或 Studio 的一个对话拿着锁;没东西在跑时不说"正在改");`running`(`bin/vh` 命令在跑,带进度;pid 被后来的进程占去的不算在跑);`working`(Studio 的一个对话拿着锁,锁的 pid 也照这样核对);`delivered`(最新的一份交付记录:哪支成片、旁边的字幕、`versions` 里正好是它的那一版);`no_record`;然后是轮到 agent、现在没东西在跑的几种。先把所有动静排一遍(结束了的命令:做完了、结束时报了问题、被停下了、中断了;发出的审阅页;开始等你的意见;它取走了你的意见;Studio 对话的最后一件事;片子自己的文件里最新改的那个:先看片子的文件夹,再一层层往下(广度优先,四层),不看 `out/`、`media/`、`renders/` 和 Studio 自己写的 `REVIEW.md`;`assets/`、`audio/`、帧序列这种重的文件夹(按名字,或者一个文件夹里超过 300 项)只看文件夹自己的时间,不一个个看;看到 4000 项还没看完就停,这时说的是"看到的最近一次动静","之后没有别的动静"这种话不说),取最新的那一件:它是一条没有结束记录、进程也没了的命令,或者 Studio 的一轮被停下、出错、做到一半断了,而且没有 agent 开着,才是 `stopped`("agent 停下了:渲染中断了。",下面一行是什么时候、到第几帧、之后没有别的动静、下一站);做这支片子的 agent 还开着:它不是 Studio 自己那一列起的(往上找它的父进程,没有 `tools/desk/desk.py`),是 `agent_outside`("这支片子正由这个窗口外面的 Claude Code 在做;在这里打的字,它收不到。",下一行"要它接着做,回到它那边说一句。","在这里另起一个 AI 做这支片子"降成第二行,点之前先问一次,问的话就是"外面那个 Claude Code 还开着。两个一起做,可能改到同一处。"(`act.sure`、`act.sure_note`);`facts.program` 是它的程序名);是 Studio 自己那一列起的,是 `agent_open`("现在没有命令在跑;上次做这支片子的 agent 还开着。","让 agent 接着做"降成第二行、点之前先问一次):只在这个 agent 程序最近一次做的就是这支片子,或者这支片子最新的动静在 6 小时以内时这么说;一个开了很久、做过许多支片子的程序(比如 Studio 那一列背后的那个)不让它做过的每支片子都显得"开着",那些片子照常说它们自己的情况,再加一句"做过它的 agent 程序还开着,可能在忙别的片子。";各站都过了还没交付是 `ship_missing`;下一步是装引擎是 `setup`;其余是 `idle`("现在没有命令在跑。",下面一行"上一次动静:……")。一条命令出错结束(`check` 没过、`gate` 拒绝)是它的结果,不是停下了:写成"上一次动静:3 分钟前,检查查出 2 处要改",下一步还是 agent 的。 + `code` 按这个先后取第一个对上的:`paused`(REVIEW.md 写了暂停);`revision_ready`(有一条复审等人看);`waiting_you`(一站的页发出去了等人:`facts.listening` 按上面 `.listening` 的三样算,真就"你交了,agent 就接着做",不然"交了以后,要跟 agent 说一声";声音那一站是"等你听");有意见还没人取、又不只是这一站刚交的那一份时(补交的,或别的轮的),排在等人的页之前先说它们:`notes_late`("你在旁白稿那一轮被取走以后又交了 3 条,还没有 AI 来取。")或 `notes_left`,下面一行说谁会来取:一个活着的 `wait` 正等着现在这一轮,"正在等的 Claude Code 马上会取";做这支片子的 agent 在 Studio 窗口外面,"回到它那边说一声“我交了”";都没有,"现在没有 AI 在等。下次有 AI 接着做这支片子,会先拿到它们。";同时有页在等人,再加一句"大纲也出来了,等你看"。这一站刚交的那一份还没人取时,不管别的在不在跑都先说它:一个活着的 `wait` 正等着现在这一轮(`.listening` 里记着它等的 `round`)是 `notes_sent`,不然 `notes_unheard`(有命令在跑时写"渲染还在跑,但你 21:30 交的这一份没人取";做这支片子的 agent 在窗口外面时,说回到它那边说一声,不给另起一个的按钮);`notes_taken`(意见交到 agent 手里了,而且这会儿真有东西在为这支片子做:`bin/vh` 命令在跑,或 Studio 的一个对话拿着锁;没东西在跑时不说"正在改");`running`(`bin/vh` 命令在跑,带进度;pid 被后来的进程占去的不算在跑);`working`(Studio 的一个对话拿着锁,锁的 pid 也照这样核对);`delivered`(最新的一份交付记录:哪支成片、旁边的字幕、`versions` 里正好是它的那一版);`no_record`;然后是轮到 agent、现在没东西在跑的几种。先把所有动静排一遍(结束了的命令:做完了、结束时报了问题、被停下了、中断了;发出的审阅页;开始等你的意见;它取走了你的意见;Studio 对话的最后一件事;片子自己的文件里最新改的那个:先看片子的文件夹,再一层层往下(广度优先,四层),不看 `out/`、`media/`、`renders/` 和 Studio 自己写的 `REVIEW.md`;`assets/`、`audio/`、帧序列这种重的文件夹(按名字,或者一个文件夹里超过 300 项)只看文件夹自己的时间,不一个个看;看到 4000 项还没看完就停,这时说的是"看到的最近一次动静","之后没有别的动静"这种话不说),取最新的那一件:它是一条没有结束记录、进程也没了的命令,或者 Studio 的一轮被停下、出错、做到一半断了,而且没有 agent 开着,才是 `stopped`("agent 停下了:渲染中断了。",下面一行是什么时候、到第几帧、之后没有别的动静、下一站);做这支片子的 agent 还开着:它不是 Studio 自己那一列起的(往上找它的父进程,没有 `tools/desk/desk.py`),是 `agent_outside`("这支片子开在这个窗口外面的 Claude Code 里;在这里打的字,它收不到。",下一行"要它接着做,回到它那边说一句。","在这里另起一个 AI 做这支片子"降成第二行,点之前先问一次,问的话就是"外面那个 Claude Code 还开着。两个一起做,可能改到同一处。"(`act.sure`、`act.sure_note`);`facts.program` 是它的程序名);是 Studio 自己那一列起的,是 `agent_open`("现在没有命令在跑;上次做这支片子的 agent 还开着。","让 agent 接着做"降成第二行、点之前先问一次):只在这个 agent 程序最近一次做的就是这支片子,或者这支片子最新的动静在 6 小时以内时这么说;一个开了很久、做过许多支片子的程序(比如 Studio 那一列背后的那个)不让它做过的每支片子都显得"开着",那些片子照常说它们自己的情况,再加一句"做过它的 agent 程序还开着,可能在忙别的片子。";各站都过了还没交付是 `ship_missing`;下一步是装引擎是 `setup`;其余是 `idle`("现在没有命令在跑。",下面一行"上一次动静:……")。一条命令出错结束(`check` 没过、`gate` 拒绝)是它的结果,不是停下了:写成"上一次动静:3 分钟前,检查查出 2 处要改",下一步还是 agent 的。 终端里 `bin/vh status` 在 `next:`、`run:`、`read:` 那几行后面打印 `now: <英文那一句>`,有 `more` 时下一行缩进两格,要人在 Studio 里做的再一行("the person does this in Studio: …"):不写要对 agent 说的话,也不印 `bin/vh studio` 这种命令,读它的常常是 agent 自己。`idle`、`setup`、`agent_open`、`no_record` 时不打印,`next:` 那一行已经说了,这一屏要短。原来的各行(`stops:` 在第二行、`next:`、`read:`)字和先后都不变:agent 每一站都读它们。 - `plan`:这支片子的打算,一句(`{zh, en}`,比如"30 秒竖屏,有旁白,先看方向和初版"):BRIEF 的 Output 一行的时长(`exactly 30s`、`2 min 30 s`、`1:30`、`60–90s`,`tools/gatecheck.py` 的读法;还是模板的 `{…}` 不算)和画幅、Language 一行的 narration(这一格就是否定、或者以否定开头的(none (music only)、无旁白、不要)才是没有旁白,"TTS voice, no music""Charon,不要背景音乐"里的否定说的是别的,照样是有旁白;以 song / 歌开头是配一首歌;待定、TBD、? 这种说不清的不写;其余是说了一个声音,就是有旁白),和这支片子自己的停(`stops` 的 gates 和 checkpoints,不看档位:①③ 是"先看方向和初版",①②③ 是"立意、分镜、初版都给你看",带检查点时一个个列出来,比如"停在立意、锁时、初版",什么都不停是"中间不停,做完给你看")。只在 `--json` 和 Studio 里:终端那一屏的 `stops:` 已经说了在哪几处停。 diff --git a/tools/desk/desk.py b/tools/desk/desk.py index 9889aead..9fd37075 100644 --- a/tools/desk/desk.py +++ b/tools/desk/desk.py @@ -19,7 +19,8 @@ bin/vh desk wait [--timeout s] block until the reviewer submits, print the feedback, exit 0 (3 on timeout, default 43200 s: 12 h; 4 the agent it waits for is gone; 7 this round's page is no longer the one out: nothing came for it, run bin/vh - status and wait on the round open now). It waits for this round's page. + status and wait on the round open now; 74 its output is closed: the + notes stay unread). It waits for this round's page. An agent runs it in the background after each stop: its exit is the wake-up call. Every submission no agent has taken yet, of any round (a later batch on a round already taken says so), is printed at once; a @@ -95,7 +96,8 @@ def main(argv): ap.add_argument("--no-open", action="store_true", help="started in a terminal it shows Studio's window; this leaves it to " "bin/vh studio (started otherwise it never shows one)") elif sub == "wait": - ap.add_argument("--timeout", type=float, default=43200, help="seconds to wait (default 43200: 12 h)") + import feedback as F0 + ap.add_argument("--timeout", type=float, default=F0.WAIT, help=f"seconds to wait (default {F0.WAIT:.0f}: {F0.WAIT / 3600:g} h)") elif sub == "feedback": ap.add_argument("--round", help="only this gate page (1, 2b, E3 …)") ap.add_argument("--json", action="store_true", help="print the JSON record instead of the text") diff --git a/tools/desk/feedback.py b/tools/desk/feedback.py index 463782a1..32898549 100644 --- a/tools/desk/feedback.py +++ b/tools/desk/feedback.py @@ -26,6 +26,7 @@ NO_ROUND = "notes" # comments sent while no gate page is out WAIT = 43200 # s: how long bin/vh desk wait and gate --wait wait by default (12 h, the gate desk's own idle stop) MOVED_ON = 7 # wait's exit when this round's page is no longer the one out: nothing came for it +NOT_DELIVERED = 74 # wait's exit when the notes could not be written (its output closed): they stay unread REFERENCE = re.compile(r"^## (授权跳过怎么记|给人看的提示|How to record a waived gate|Notes for the reviewer)", re.M) WORDS = { "zh": dict(title="# 审阅反馈 · {round} · {at}", decision="决定 {id}:{v}", default="(按推荐,没改)", @@ -354,29 +355,103 @@ def _program(): return None -def mark_consumed(project, paths, by="feedback"): - """Claim these submissions for this process: add the ones no one has taken yet to feedback/.consumed, with when, by which - run and agent program; → the names this call claimed (oldest first, as given). The read-modify-write holds an flock on - feedback/.consumed.lock, so two bin/vh desk processes doing it at once both get their names in, and a submission two - waits see at once goes to exactly one of them.""" +def _who(by): + return {"t": round(time.time(), 3), "run": os.environ.get("OVH_ACTIVITY_RUN") or None, "program": _program(), "by": by} + + +def _locked(project, change): + """change(record) → (new record or None, result), under feedback/.consumed.lock (flock: other processes) and _lock (this + one's threads); the new record is written atomically. → result.""" fdir = Path(project) / "out" / "review" / "feedback" fdir.mkdir(parents=True, exist_ok=True) - who = {"t": round(time.time(), 3), "run": os.environ.get("OVH_ACTIVITY_RUN") or None, "program": _program(), "by": by} with _lock, open(fdir / ".consumed.lock", "a") as lk: fcntl.flock(lk.fileno(), fcntl.LOCK_EX) try: d = _consumed_record(project) - had = consumed(project) - info = {k: v for k, v in (d.get("taken") or {}).items() if k in had} if isinstance(d.get("taken"), dict) else {} - mine = [n for n in dict.fromkeys(Path(p).name for p in paths) if n not in had] - for n in mine: - info[n] = who - _write(fdir / ".consumed", json.dumps({"files": sorted(had | set(mine)), "taken": info}, ensure_ascii=False) + "\n") - return mine + files = d.get("files") if isinstance(d.get("files"), list) else [] + rec = {"files": sorted({n for n in files if isinstance(n, str)}), + "taken": {k: v for k, v in d.get("taken").items() if k in files} if isinstance(d.get("taken"), dict) else {}, + "claims": {k: v for k, v in d.get("claims").items() if isinstance(v, dict)} if isinstance(d.get("claims"), dict) else {}} + new, result = change(rec) + if new is not None: + _write(fdir / ".consumed", json.dumps(new, ensure_ascii=False) + "\n") + return result finally: fcntl.flock(lk.fileno(), fcntl.LOCK_UN) +def _claim_alive(c): + """A claim's process is still the one that made it (not gone, its pid not taken by a later one).""" + try: + return activity._alive(int(c.get("pid")), c.get("since")) + except (TypeError, ValueError): + return False + + +def mark_consumed(project, paths, by="feedback"): + """These submissions were handed over (printed and flushed): add the ones not on record yet to feedback/.consumed as taken, + with when, by which run and agent program, and drop any claim on them; → the names this call added (oldest first, as + given). The read-modify-write holds an flock on feedback/.consumed.lock, so two bin/vh desk processes doing it at once + both get their names in.""" + who, names = _who(by), list(dict.fromkeys(Path(p).name for p in paths)) + + def change(rec): + mine = [n for n in names if n not in rec["files"]] + for n in mine: + rec["taken"][n] = who + for n in names: + rec["claims"].pop(n, None) + rec["files"] = sorted(set(rec["files"]) | set(mine)) + return rec, mine + return _locked(project, change) + + +def claim(project, paths): + """The first of a hand-over's two steps: claim these submissions for this process, unconfirmed, with its pid and when; → + the names it claimed (none another live process holds, none already taken). A claim is only a claim: unread() still + counts the submission, nothing says it was picked up, and once the claiming process is gone (a crash, a kill) it is no + claim at all. confirm() makes it taken once the note was written and flushed; release() undoes it.""" + names = list(dict.fromkeys(Path(p).name for p in paths)) + me = {"pid": os.getpid(), "since": round(time.time(), 3)} + + def change(rec): + live = {k: v for k, v in rec["claims"].items() if _claim_alive(v)} + mine = [n for n in names if n not in rec["files"] and n not in live] + for n in mine: + live[n] = me + rec["claims"] = live + return rec, mine + return _locked(project, change) + + +def confirm(project, name, by="wait"): + """The second step: this process's claim on the submission becomes taken (when, which run, which agent program).""" + who = _who(by) + + def change(rec): + c = rec["claims"].get(name) + if c is not None and c.get("pid") != os.getpid(): + return None, False # (another process's claim: not ours to confirm) + rec["claims"].pop(name, None) + if name not in rec["files"]: + rec["files"] = sorted(set(rec["files"]) | {name}) + rec["taken"][name] = who + return rec, True + return _locked(project, change) + + +def release(project, names): + """Undo this process's unconfirmed claims on these submissions: they are unread again, for the next wait.""" + names = set(names) + + def change(rec): + gone = [n for n, c in rec["claims"].items() if n in names and c.get("pid") == os.getpid()] + for n in gone: + rec["claims"].pop(n) + return (rec if gone else None), gone + return _locked(project, change) if names else [] + + def current_round(project): """This round's page id (the one the desk shows as this round: reader.gate_pages' last readable page), or NO_ROUND.""" import reader @@ -415,14 +490,14 @@ def unread(project): """Every submission no agent has been handed and no agent has answered, of any round, oldest first: [(path, record, late)]. late: a submission of the same round was handed over before it (the person wrote more after the round was taken). These are what the next wait hands over first, and what bin/vh status puts before any other work.""" - done, ans = consumed(project), answered(project) + done, ans, took = consumed(project), answered(project), taken(project) recs = sorted(((f, j) for f, j in _records(project) if isinstance(j.get("round"), str) and ROUND.match(j["round"]) and isinstance(j.get("submitted_at"), str)), key=lambda x: _order(*x)) # (submissions as save() writes them: a stray or broken file is no note of the person's) out = [] for i, (f, j) in enumerate(recs): if f.name in done or f.name in ans: continue - late = any(g.name in done and k.get("round") == j.get("round") for g, k in recs[:i]) + late = any(g.name in done and (took.get(g.name) or {}).get("t") and k.get("round") == j.get("round") for g, k in recs[:i]) # (a hand-over recorded with its time: an older record's names say nothing of when) out.append((f, j, late)) return out @@ -461,17 +536,37 @@ def _handed(subs): [f for f, _ in subs]) +CLAIMED = set() # this process's claims not confirmed yet: a signal on the way out releases them + + +class NotDelivered(Exception): + """The notes could not be written to the agent (its output closed or broken): their claims were released.""" + + def _hand(project, subs, rid, out): - """Claim and print these [(path, record, late)]; → how many this process got (another wait may have claimed some).""" - mine = set(mark_consumed(project, [f for f, _, _ in subs], by="wait")) + """Hand these [(path, record, late)] over, each in two steps: claim them (unconfirmed), then for each one write it, flush, + and only then confirm it as taken. A write or flush that fails releases what is not confirmed and raises NotDelivered; + a signal releases it too (wait's handler). → how many this process handed over (another wait may hold some).""" + mine = set(claim(project, [f for f, _, _ in subs])) got = [(f, j, late) for f, j, late in subs if f.name in mine] - for f, j, late in got: - show(f, j, out, late=late) + CLAIMED.update(mine) + try: + for f, j, late in got: + show(f, j, out, late=late) # (it flushes) + confirm(project, f.name, by="wait") + CLAIMED.discard(f.name) + except (OSError, ValueError) as e: # a closed or broken output: not delivered + release(project, list(CLAIMED)) + CLAIMED.clear() + raise NotDelivered(str(e)) from e if got: - out.write(HANDED) - if rid is not None and not any(j.get("round") == rid for _, j, _ in got): - out.write(f"Nothing has come for round {rid} yet: once these are dealt with, wait for it again (bin/vh desk wait {project}).\n") - out.flush() + try: + out.write(HANDED) + if rid is not None and not any(j.get("round") == rid for _, j, _ in got): + out.write(f"Nothing has come for round {rid} yet: once these are dealt with, wait for it again (bin/vh desk wait {project}).\n") + out.flush() + except (OSError, ValueError): + pass # (the notes themselves went out and were confirmed) _handed([(f, j) for f, j, _ in got]) return len(got) @@ -503,19 +598,43 @@ def done(code): return code def stop(signum, _frame): + if CLAIMED: # claimed and not written: unread again for the next wait + try: + release(project, list(CLAIMED)) + finally: + CLAIMED.clear() raise SystemExit(done(128 + signum)) + + def undelivered(e): + try: + sys.stderr.write(f"the notes could not be written ({e}): they stay unread for the next wait and bin/vh status\n") + except (OSError, ValueError): + pass + if out is sys.stdout: # its output is gone: Python's own last flush would fail too, and turn this exit status into 120 + try: + os.dup2(os.open(os.devnull, os.O_WRONLY), sys.stdout.fileno()) + except (OSError, ValueError): + pass + return done(NOT_DELIVERED) # the handlers before the flag: a signal from the moment the flag is there (a client sees it) ends the wait with its # status in the activity log and takes the flag away for s in (signal.SIGTERM, signal.SIGINT, signal.SIGHUP): signal.signal(s, stop) fdir.mkdir(parents=True, exist_ok=True) + parent = os.getppid() # whatever program started it: a wait re-parented (its parent gone) has nobody to hand over to + if parent == 1: # started orphaned (or its starter already gone): nothing is handed to nobody + out.write("the program that started this wait is gone; nothing is handed over (the notes stay unread)\n") + out.flush() + return done(4) seen = {p.name for p in fdir.glob("*.json")} # first: a submission landing after this is either unread now or new early = unread(project) - if early and _hand(project, early, rid, out): - return 0 + try: + if early and _hand(project, early, rid, out): + return 0 + except NotDelivered as e: + return undelivered(e) start = time.time() agent = activity.agent_of(os.getpid()) - parent = os.getppid() # whatever program started it: a wait re-parented (its parent gone) has nobody to hand over to _write(flag, json.dumps({"pid": os.getpid(), "since": start, "until": start + timeout, "project": os.path.realpath(str(project)), "agent": agent, "round": rid})) looked = start @@ -533,18 +652,21 @@ def stop(signum, _frame): out.flush() return done(4) now = current_round(project) + new = [(f, j) for f, j in _records(project) if f.name not in seen] + if new: # first what came: its own round's, and any other but the new page's (that one is its own wait's) + seen |= {f.name for f, _ in new} + ids = {f.name for f, _ in new} + fresh = [(f, j, late) for f, j, late in unread(project) if f.name in ids and (now == rid or j.get("round") != now)] + try: + if fresh and _hand(project, fresh, rid, out): + return done(0) + except NotDelivered as e: + return undelivered(e) if now != rid: # another page went out: this round is over, nothing came for it, and the new page's notes are its own wait's out.write(f"the page for round {rid} is no longer the one out (round {now} is): nothing was submitted for {rid}, " "and this wait ends. Run bin/vh status, and wait on the round that is open now\n") out.flush() return done(MOVED_ON) - new = [(f, j) for f, j in _records(project) if f.name not in seen] - if new: - seen |= {f.name for f, _ in new} - ids = {f.name for f, _ in new} - fresh = [(f, j, late) for f, j, late in unread(project) if f.name in ids] - if fresh and _hand(project, fresh, rid, out): - return done(0) time.sleep(poll) out.write(f"no feedback within {timeout:.0f} s; the notes stay unread for the next wait or bin/vh status. Arm it again: bin/vh desk wait {project}\n") out.flush() diff --git a/tools/desk/page_driver.mjs b/tools/desk/page_driver.mjs index d9b2b894..79039823 100644 --- a/tools/desk/page_driver.mjs +++ b/tools/desk/page_driver.mjs @@ -6,6 +6,7 @@ // step: {"go": "#/p//outline"} set the address's hash (the page routes on it) // {"reload": true} reload the page and wait for it // {"wait": 500} milliseconds +// {"viewport": [1280, 720]} the window's size from now on // {"until": "", "ms": 8000, "name": "…"} wait until it is truthy: {name, ok, value} // {"eval": "", "name": "…"} evaluate in the page: {name, value} (awaited, as JSON) // {"write": "", "text": "…"} write a file (a project file the agent changes while the page is open) @@ -38,6 +39,7 @@ try { for (const st of input.steps) { try { if (st.go != null) { await evaluate(`location.hash = ${JSON.stringify(st.go)}`); await sleep(st.after || 1500); } + else if (st.viewport) { await send("Emulation.setDeviceMetricsOverride", { width: st.viewport[0], height: st.viewport[1], deviceScaleFactor: 1, mobile: false }); await sleep(st.after || 800); } else if (st.reload) await loaded(() => send("Page.reload", {})); else if (st.wait) await sleep(st.wait); else if (st.write) writeFileSync(st.write, st.text); diff --git a/tools/desk/static/agent.js b/tools/desk/static/agent.js index 0e75511a..0dfed921 100644 --- a/tools/desk/static/agent.js +++ b/tools/desk/static/agent.js @@ -38,8 +38,8 @@ const ASTR = { busy_command: "终端里正在跑 {x}。等它跑完再让 agent 动手。", busy_process: "终端里有 {x} 开在这支片子的文件夹里,它可能正在改东西。现在让 {a} 动手,两边可能改到同一处。", busy_waiting: "终端里有个 agent 在等你交这一站。现在让 {a} 动手,两边可能改到同一处。", busy_anyway: "仍然发这一句", busy_not: "先不发", - busy_outside: "这支片子正由这个窗口外面的 {x} 在做,在这里说的话它收不到。在这里发出去,会另起一个 AI 做同一支片子,两个可能改到同一处。", busy_outside_go: "另起一个 AI", - empty_outside: "这支片子正由这个窗口外面的 {x} 在做,在这里说的话它收不到。在这里发第一句,会另起一个 AI;要那边接着做,回到那边说。", ai_any: "AI", + busy_outside: "这支片子开在这个窗口外面的 {x} 里,在这里说的话它收不到。在这里发出去,会另起一个 AI 做同一支片子,两个可能改到同一处。", busy_outside_go: "另起一个 AI", + empty_outside: "这支片子开在这个窗口外面的 {x} 里,在这里说的话它收不到。在这里发第一句,会另起一个 AI;要那边接着做,回到那边说。", ai_any: "AI", perm_h: "{a} 想{v}", perm_toast: "{a} 想{v},等你批准", perm_wait: "等你批准", perm_by_person: "你选了:{o}", perm_by_stop: "你点了停止,取消了", perm_by_timeout: "没有页面开着,{m} 分钟后按“不行”处理了", perm_by_gone: "agent 停了,这一问不算了", perm_by_restart: "Studio 重启过,这一问不算了", perm_by_turn: "它这一句做完了,这一问不算了", perm_by_desk: "Studio 关了,这一问不算了", o_allow_once: "允许这一次", o_allow_always: "这个对话里同类的都允许", o_reject_once: "不允许", o_reject_always: "一直不允许", @@ -95,8 +95,8 @@ const ASTR = { busy_command: "{x} is running in a terminal. Let it finish before the agent starts.", busy_process: "{x} is open in this film's folder in a terminal and may be editing. If {a} starts now, both may edit the same thing.", busy_waiting: "An agent in a terminal is waiting for you to send this stop. If {a} starts now, both may edit the same thing.", busy_anyway: "Send this one anyway", busy_not: "Not now", - busy_outside: "{x} is making this film outside this window, and what you say here does not reach it. Sending here starts a second AI on the same film; the two may change the same thing.", busy_outside_go: "Start a second AI", - empty_outside: "{x} is making this film outside this window, and what you say here does not reach it. Your first message here starts a second AI; to have that one carry on, say so over there.", ai_any: "An AI", + busy_outside: "This film is open in {x} outside this window, and what you say here does not reach it. Sending here starts a second AI on the same film; the two may change the same thing.", busy_outside_go: "Start a second AI", + empty_outside: "This film is open in {x} outside this window, and what you say here does not reach it. Your first message here starts a second AI; to have that one carry on, say so over there.", ai_any: "An AI", perm_h: "{a} wants to {v}", perm_toast: "{a} wants to {v}: waiting for your OK", perm_wait: "Waiting for your OK", perm_by_person: "You chose: {o}", perm_by_stop: "Cancelled when you pressed Stop", perm_by_timeout: "No page was open; after {m} minutes it was refused", perm_by_gone: "The agent stopped, so this request no longer counts", perm_by_restart: "Studio restarted, so this request no longer counts", perm_by_turn: "Its reply ended, so this request no longer counts", perm_by_desk: "Studio closed, so this request no longer counts", o_allow_once: "Allow this once", o_allow_always: "Allow the same kind in this chat", o_reject_once: "Don't allow", o_reject_always: "Never allow", diff --git a/tools/desk/static/core.js b/tools/desk/static/core.js index eff028dc..3e267ad0 100644 --- a/tools/desk/static/core.js +++ b/tools/desk/static/core.js @@ -163,16 +163,18 @@ const STR = { // the notes and their state (draft, sent and not picked up, picked up), and who picks them up: the agent by its name, else AI ho_mine: "你的意见", ho_ai: "AI", ho_draft: "还没交 {n} 条", ho_unread: "交了 {n} 条,还没人取", ho_unread_late: "补交的 {n} 条,还没人取", ho_taken: "{at} 被 {a} 取走", ho_taken_n: "{n} 条", ho_who_live: "正在等的 {a} 马上会取。", - ho_who_out: "做这支片子的 {a} 在这个窗口外面:回到它那边说一声“我交了”,它就会来取。", + ho_who_out: "这支片子开在这个窗口外面的 {a} 里:回到它那边说一声“我交了”,它就会来取。", ho_who_next: "现在没有 AI 在等。下次有 AI 接着做这支片子,会先拿到它们。", ho_bar_late: "补充 {n} 条 · {s}已被取走,单独交", ho_bar_unread: "交了,还没人取", ho_bar_taken: "{a} 已经取走了", ho_submit_late: "补交", ho_sent_h: "交了,还没人取的", ho_d_late: "{s}已经被 {a} 取走了。这几条作为补交的意见单独交,不算进别的哪一页。", - ho_d_live: "正在等的 {a} 会马上取走。", ho_d_out: "做这支片子的 {a} 在这个窗口外面:交了以后,回到它那边说一声“我交了”。", + ho_d_live: "正在等的 {a} 会马上取走。", ho_d_out: "这支片子开在这个窗口外面的 {a} 里:交了以后,回到它那边说一声“我交了”。", ho_d_nobody: "现在没有 AI 在等这些意见:交了以后先存着,下次有 AI 接着做这支片子会先拿到。", ho_sent_live: "交了,正在等的 {a} 马上会取", ho_sent_kept: "交了,先存着。现在没有 AI 在等,下次有 AI 接着做会先拿到", ho_sent_out: "交了,先存着。回到 {a} 那边说一声“我交了”,它就来取", ho_fix_q: "你选了“{x}”,还没写改哪里。", ho_fix_b: "在页面上点要改的地方写一句,或者在上面的整体意见里写。", ho_fix_back: "回去写", ho_fix_go: "就这样交", ho_s_1: "立意", ho_s_outline: "大纲", ho_s_E0: "画风样张", ho_s_E1: "旁白稿", ho_s_2: "分镜", ho_s_E2: "配乐安排", ho_s_E3: "最终的声音", ho_s_3: "初版", ho_s_E4: "第一章样片", ho_s_E5: "定画面的版本", ho_s_notes: "随手写的意见", ho_s_other: "这一页", + ho_left: "在{s}那一页写的 {n} 条,还没交", ho_left_b: "那一页已经换成了新的一页。这几条不会自己交出去,也不算进现在这一页。", + ho_left_send: "交到{s}那一轮", ho_left_drop: "不要了", ho_left_fail: "没有交成功,这几条还留在这里。", }, en: { revisions: "Revisions", revision_pending: "Ready for review", revision_approved: "Accepted", revision_changes_requested: "Changes requested", @@ -331,16 +333,18 @@ const STR = { lk_agent_n: "An agent in Studio", lk_agent_s: "The Chat on the right can only show, not talk to an agent yet.", lk_agent_d: "Open a film and press “Set it up” in its Chat on the right.", ho_mine: "Your notes", ho_ai: "the AI", ho_draft: "{n} not sent yet", ho_unread: "{n} sent, not picked up yet", ho_unread_late: "{n} sent later, not picked up yet", ho_taken: "picked up by {a} at {at}", ho_taken_n: "{n} {n|note|notes}", ho_who_live: "The {a} that is waiting picks them up at once.", - ho_who_out: "{a}, outside this window, is making this film: tell it “I've sent it” over there and it picks them up.", + ho_who_out: "This film is open in {a} outside this window: tell it “I've sent it” over there and it picks them up.", ho_who_next: "No AI is waiting right now. The next AI to carry on with this film gets them first.", ho_bar_late: "{n} more {n|note|notes} · {s} was already picked up: these go on their own", ho_bar_unread: "Sent, not picked up yet", ho_bar_taken: "{a} has picked them up", ho_submit_late: "Send these too", ho_sent_h: "Sent, not picked up yet", ho_d_late: "{a} already picked up {s}. These go as later notes of their own, not counted with any other page.", - ho_d_live: "The {a} that is waiting picks them up at once.", ho_d_out: "{a}, outside this window, is making this film: once sent, tell it “I've sent it” over there.", + ho_d_live: "The {a} that is waiting picks them up at once.", ho_d_out: "This film is open in {a} outside this window: once sent, tell it “I've sent it” over there.", ho_d_nobody: "No AI is waiting for these notes: once sent they are kept, and the next AI to carry on with this film gets them first.", ho_sent_live: "Sent; the waiting {a} picks them up at once", ho_sent_kept: "Sent and kept. No AI is waiting; the next one to carry on gets them first", ho_sent_out: "Sent and kept. Tell {a} “I've sent it” and it picks them up", ho_fix_q: "You picked “{x}” but haven't said what to change.", ho_fix_b: "Click the place to change on the page and write a line, or write it in the overall box above.", ho_fix_back: "Go back and write it", ho_fix_go: "Send as it is", ho_s_1: "the concept", ho_s_outline: "the outline", ho_s_E0: "the style frames", ho_s_E1: "the script", ho_s_2: "the storyboard", ho_s_E2: "the sound plan", ho_s_E3: "the final sound", ho_s_3: "the first draft", ho_s_E4: "the first chapter", ho_s_E5: "the picture lock", ho_s_notes: "your loose notes", ho_s_other: "this page", + ho_left: "{n} {n|note|notes} written on {s}, not sent", ho_left_b: "A new page has replaced that one. These do not go by themselves, and they are not counted with this page.", + ho_left_send: "Send them with {s}", ho_left_drop: "Drop them", ho_left_fail: "Not sent; they are still here.", }, }; diff --git a/tools/desk/static/studio.css b/tools/desk/static/studio.css index 7920a4ac..923fde9c 100644 --- a/tools/desk/static/studio.css +++ b/tools/desk/static/studio.css @@ -210,10 +210,14 @@ html.shell-other .topbar{padding-right:calc(14px + 100vw - env(titlebar-area-x, .col-body .next .raw{color:var(--ink-3);font-size:var(--fs-label)} .col-body .quiet-line{color:var(--ink-2)} /* the notes and their state, pinned to the column's foot right above the note box: what was just kept is seen without scrolling */ -.col-body .c-mine{position:sticky;bottom:-14px;margin:0 -16px -14px;padding:10px 16px 12px;max-height:42vh;overflow:auto;background:var(--panel);border-top:1px solid var(--rule-2);z-index:1} +.col-body.split{display:flex;flex-direction:column;overflow:hidden;padding:0;gap:0} /* a film's column: two parts, each scrolling on its own */ +.col-body.split>.col-scroll{flex:1 1 auto;min-height:6rem;overflow:auto;padding:14px 16px 10px;display:grid;gap:10px;align-content:start} +.col-body.split>.c-mine{flex:0 1 auto;min-height:0;max-height:50%;overflow:auto;padding:10px 16px 12px;background:var(--panel);border-top:1px solid var(--rule-2)} /* at most half the column; below 1280×720 the part above keeps 6rem */ .col-body .c-mine .blk-h{position:sticky;top:-10px;margin:-10px 0 4px;padding:10px 0 4px;background:var(--panel);z-index:1} /* the state line stays while the notes scroll */ .col-body .c-mine .blk-h .tag{margin-left:auto;color:var(--wait)} .col-body .ho-batch{margin-top:8px} +.col-body .ho-st.left i{background:var(--you)} +.col-body .ho-acts{display:flex;gap:8px;margin:4px 0 0 14px} .col-body .ho-st{margin:0;display:flex;gap:8px;align-items:baseline;font-size:var(--fs-small);color:var(--ink-hi)} .col-body .ho-st i{flex:none;width:6px;height:6px;border-radius:50%;background:var(--wait);transform:translateY(-1px)} .col-body .ho-st.taken{color:var(--ink-2)}.col-body .ho-st.taken i{background:var(--rule-2)} @@ -222,6 +226,7 @@ html.shell-other .topbar{padding-right:calc(14px + 100vw - env(titlebar-area-x, .col-body details.ho-batch>summary{list-style:none;cursor:pointer}.col-body details.ho-batch>summary::-webkit-details-marker{display:none} .confirm .fix-ask{margin:8px 0 0;padding:8px 12px;border-left:2px solid var(--wait);background:var(--wait-soft)} .confirm .fix-ask .fix-q{margin:0 0 2px;font-size:var(--fs-small);color:var(--ink-hi)} +.col-scroll.more{-webkit-mask-image:linear-gradient(var(--ink) calc(100% - 36px),transparent);mask-image:linear-gradient(var(--ink) calc(100% - 36px),transparent)} .col-body.more{-webkit-mask-image:linear-gradient(var(--ink) calc(100% - 36px),transparent);mask-image:linear-gradient(var(--ink) calc(100% - 36px),transparent)} /* more below: the column fades out instead of ending under the bar */ .app .g-opt .id{display:none} /* the console says an option by its words; the static page keeps the codes its reply line uses */ .col-body .next code{display:inline;white-space:pre-wrap;overflow-wrap:anywhere;font-size:11.5px;color:var(--ink-2);background:none;padding:0} @@ -558,6 +563,7 @@ blockquote{margin:8px 0;padding:4px 14px;border-left:2px solid var(--rule-2);col .module{padding:16px} .col{border-left:0;border-top:1px solid var(--rule);border-radius:0!important} .col-body{overflow:visible} + .col-body.split{display:block;overflow:visible;padding:14px 16px}.col-body.split>.col-scroll,.col-body.split>.c-mine{overflow:visible;max-height:none;padding:0} /* a phone: the page scrolls, the notes after the rest */ .cut{display:block;height:auto} .lists{border-right:0;max-height:none} .screen{min-height:0;aspect-ratio:16/9;margin:0} diff --git a/tools/desk/static/studio.js b/tools/desk/static/studio.js index 6bf2cd25..81be5913 100644 --- a/tools/desk/static/studio.js +++ b/tools/desk/static/studio.js @@ -413,7 +413,9 @@ function renderColumn() { : g && g.summary ? `

    ${esc(g.summary)}${page}

    ` : `

    ${esc(t(filmDelivered() ? "col_done" : "round_quiet"))}

    `; // nothing to decide: one line ("最近定下的" is the ledger's) // what went is said in the notes block below, with its state (sent and not picked up, or picked up: when, by whom) - $("#colBody").innerHTML = `${decs}
    `; + // two parts: what to decide and look at scrolls above; the notes and their state below it, never squeezed out by the cards + $("#colBody").classList.add("split"); + $("#colBody").innerHTML = `
    ${decs}
    `; if (COLCTL) { COLCTL.destroy(); COLCTL = null; } const cards = $(".c-cards", $("#colBody")); if (cards) COLCTL = OVH.mount(cards, { initial: FB.decisions, onPick: pick, advance: true }); @@ -460,6 +462,40 @@ function handedHtml(f) { // each decision as it went, when; and the way to cha + `
      ${dec.join("")}
    `; } $("#colBody").addEventListener("click", (e) => { if (e.target.closest("#reHand")) { REHAND[KEY] = true; renderColumn(); } }); +function leftOver() { // drafts this browser keeps for an earlier page of this film (the agent sent a new page since): [{rid, fb, n, rows}] + if (!D || !PKEY) return []; + const out = [], pre = `desk:${PKEY}:`; + try { + for (let i = 0; i < localStorage.length; i++) { + const k = localStorage.key(i); if (!k || !k.startsWith(pre) || k === KEY) continue; + const rid = k.slice(pre.length), fb = store.get(k) || {}; + if (!/^[A-Za-z0-9_-]{1,24}$/.test(rid) || rid !== "notes" && !(D.rounds || []).some((r) => r.id === rid)) continue; // (a page still on file: one gone has no round to send to) + const rows = Object.entries(fb.items || {}).filter(([, v]) => v && v.status).map(([tg, v]) => ({ target: tg, label: v.label || tg, text: v.text || "", v })); + if (fb.general && String(fb.general).trim()) rows.push({ target: "", label: t("c_whole_note"), text: String(fb.general) }); + if (rows.length) out.push({ rid, fb, n: rows.length, rows }); + } + } catch (e) { /* no storage: nothing kept */ } + return out; +} +$("#colBody").addEventListener("click", async (e) => { // drafts of an earlier page: sent to that page's own round, or dropped, as the person says + const send = e.target.closest("[data-left-send]"), drop = e.target.closest("[data-left-drop]"); + if (!send && !drop) return; + const rid = (send || drop).dataset.leftSend || (send || drop).dataset.leftDrop, k = `desk:${PKEY}:${rid}`, x = leftOver().find((y) => y.rid === rid); + if (!x) return; + if (drop) { try { localStorage.removeItem(k); } catch (err) { /* no storage */ } renderMine(); return; } + const items = x.rows.filter((r) => r.target).map((r) => Object.assign({ target: r.target, status: r.v.status, label: fitLabel(r.label), text: r.text }, + r.v.suggest && r.v.suggest !== r.v.orig ? { suggest: r.v.suggest } : {}, r.v.orig && r.target.startsWith("cap:") ? { orig: r.v.orig } : {}, r.v.t != null ? { t: r.v.t } : {}, r.v.t1 != null ? { t1: r.v.t1 } : {})); + const p = { round: rid, lang: LANG, decisions: {}, defaulted: [], items, general: String(x.fb.general || "").trim(), pid: D.pid }; + let r = null; + try { r = await fetch(`/api/p/${enc(PKEY)}/feedback`, { method: "POST", headers: { "Content-Type": "application/json", "X-Desk-Token": TOKEN }, body: JSON.stringify(p) }); } catch (err) { r = null; } + if (r && r.ok) { + const j = await r.json(); + try { localStorage.removeItem(k); } catch (err) { /* no storage */ } + const h = D.status && D.status.holder; + toast(j.live ? t("ho_sent_live", { a: holderName() }) : h && h.outside ? t("ho_sent_out", { a: holderName() }) : t("ho_sent_kept")); + await reloadProject(false); + } else toast(t("ho_left_fail")); // (kept here: nothing is lost) +}); function syncPhoneDec() { // a phone lays the cut out picture, timeline, then the column: a bar above the picture goes to the decisions const pd = $("#phoneDec"); if (!pd || !D) return; const g = GV && GV.current && roundOpen() ? GV : null, n = (ROUND.data.decisions || []).length, home = GATE_MOD[gateBase(ROUND.id)] || "cut"; @@ -518,9 +554,11 @@ function renderMine() { unread.forEach((f) => { const k = f.round + (f.late ? ":late" : ""); (groups[k] = groups[k] || []).push(f); }); const unreadHtml = Object.values(groups).map((G) => { const c = G.reduce((a, f) => a + subCount(f), 0), late = G[0].late; return `
    ${st2("unread", `${t(late ? "ho_unread_late" : "ho_unread", { n: c })} · ${stepName(G[0].round)}`, whoTakes("ho_who"))}${G.map(sentList).join("")}
    `; }).join(""); + const leftHtml = leftOver().map((x) => `
    ${st2("left", t("ho_left", { n: x.n, s: stepName(x.rid) }), t("ho_left_b"))}
      ${x.rows.map((r) => `
    • ·${esc(cut(r.label, 40))} ${esc(r.text)}
    • `).join("")}
    ` + + `
    `).join(""); const takenHtml = took && !unread.some((f) => f.round === ROUND.id) ? `
    ${st2("taken", t("ho_taken", { at: takenAt(took), a: progName(took.taken && took.taken.program) }) + " · " + t("ho_taken_n", { n: subCount(took) }))}${sentList(took)}
    ` : ""; $("#cMine").innerHTML = `

    ${esc(t("ho_mine"))}${n ? `${esc(t("ho_draft", { n }))}` : ""}${none && !unreadHtml && !takenHtml ? `${esc(t(MOD === "cut" ? "c_mine_how" : "c_mine_how_m"))}` : ""}

    ` - + (none ? "" : `
      ${items.map(row).join("")}${gen}
    `) + unreadHtml + takenHtml; + + (none ? "" : `
      ${items.map(row).join("")}${gen}
    `) + leftHtml + unreadHtml + takenHtml; requestAnimationFrame(keepNewest); } function keepNewest() { // the note kept last is the one in view, however many there are (also once the column's tab shows the block) @@ -589,8 +627,8 @@ function renderRound() { // what the next submission would send, said plainly $("#openConfirm").addEventListener("click", openConfirm); requestAnimationFrame(fadeMore); } -function fadeMore() { const b = $("#colBody"); if (b) b.classList.toggle("more", b.scrollHeight - b.scrollTop - b.clientHeight > 6); } // more below: say so -$("#colBody").addEventListener("scroll", fadeMore); window.addEventListener("resize", fadeMore); +function fadeMore() { const b = $("#colScroll") || $("#colBody"); if (b) b.classList.toggle("more", b.scrollHeight - b.scrollTop - b.clientHeight > 6); } // more below: say so +$("#colBody").addEventListener("scroll", fadeMore, true); window.addEventListener("resize", fadeMore); // (capture: the part above the notes scrolls on its own) $("#colBody").addEventListener("click", (e) => { const x = e.target.closest("[data-del]"); if (x) { e.stopPropagation(); if (x.dataset.del === "#general") FB.general = ""; else delete FB.items[x.dataset.del]; save(); return; } @@ -734,13 +772,13 @@ function sheetWho() { // before sending: this round already picked up (these g const took = roundTaken(), pre = took ? t("ho_d_late", { s: stepName(ROUND.id), a: progName(took.taken && took.taken.program) }) + " " : ""; return pre + whoTakes("ho_d"); } -const CHANGE_ID = /^(fix|change|changes|redo|revise|rework|edit|改)/i, CHANGE_WORDS = /(先改|要改|改一下|重做|重写|修改|fix|change|redo|revise|rework)/i; -function fixPick(p) { // a picked option that asks for changes, sent with no note saying what: {label} (A10), else null +function fixPick(p) { // a picked option that says it needs a note (the gate JSON's needs_note: "fix first"), sent with no note saying what: + // {label}, else null. Nothing is guessed from an option's words: a page without the field never asks if ((p.items || []).length || p.general) return null; for (const d of ROUND.data.decisions || []) { const v = p.decisions[d.id]; if (!v || p.defaulted.includes(d.id)) continue; - const o = (d.options || []).find((x) => (x && x.id != null ? x.id : x) === v) || {}, label = typeof o === "string" ? o : String(o.label || v); - if (CHANGE_ID.test(String(v)) || CHANGE_WORDS.test(label)) return { label: cut(label.replace(/\*\*|`/g, ""), 30) }; + const o = (d.options || []).find((x) => x && typeof x === "object" && x.id === v); + if (o && o.needs_note === true) return { label: cut(String(o.label || v).replace(/\*\*|`/g, ""), 30) }; } return null; } diff --git a/tools/desk/test_agents.py b/tools/desk/test_agents.py index c48e3abc..d9570170 100644 --- a/tools/desk/test_agents.py +++ b/tools/desk/test_agents.py @@ -2415,6 +2415,105 @@ def nothing_left_behind(): # a wait that times out, then a submission: unread check("a wait that ends without a submission leaves every note for bin/vh status and the next wait, and \"正在取\" is said only for a live wait on " "the round that is out", nothing_left_behind) + # a wait driven from Python with hooks in its own copy of the hand-over: held in the gap between a claim and the note's + # line, or held at the claim itself; what the hooks do is in the driver below, nothing of it is in feedback.py + driver = T / "wait_driver.py" + driver.write_text("\n".join([ + "import os, sys, time", + f"sys.path.insert(0, {str(HERE)!r})", + "import feedback as F", + "project, mode, mark = sys.argv[1], sys.argv[2], sys.argv[3]", + "if mode == 'gap': # claimed, then held before the note is written", + " show = F.show", + " def slow(*a, **k):", + " open(mark, 'w').close(); time.sleep(60); return show(*a, **k)", + " F.show = slow", + "if mode == 'race': # both waits held at the claim, released together; the read-modify-write made slow", + " claim, write = F.claim, F._write", + " def held(*a, **k):", + " open(mark, 'w').close()", + " while not os.path.exists(mark + '.go'): time.sleep(0.02)", + " return claim(*a, **k)", + " def slow_write(path, text):", + " if path.name == '.consumed': time.sleep(0.6)", + " return write(path, text)", + " F.claim, F._write = held, slow_write", + "sys.exit(F.wait(project, 60, poll=0.2))", + ]) + "\n") + + def driven(p, mode, mark): + w = subprocess.Popen([sys.executable, str(driver), str(p), mode, str(mark)], stdout=subprocess.PIPE, stderr=subprocess.STDOUT, text=True, env=env) + BG.add(w.pid) + return w + + def until(f, secs=15): + t0 = time.time() + while time.time() - t0 < secs and not f(): + time.sleep(0.05) + return f() + + def gap_kills(): # a wait killed between its claim and the note's line (each signal), or whose output is closed: the note stays unread + import server + bad = [] + for sig in (signal.SIGKILL, signal.SIGTERM, signal.SIGINT): + p = film_at_script(f"gap-{sig.name}") + mark = T / f"gap-{sig.name}.mark" + w = driven(p, "gap", mark) + if not armed(p): + bad.append(f"{sig.name}: the wait did not start"); w.kill(); continue + f = submit(p, "E1", "在缝里被杀") + if not until(mark.exists): + bad.append(f"{sig.name}: the wait never reached the gap"); w.kill(); continue + os.kill(w.pid, sig) + w.wait(timeout=10) + un, took = [x.name for x, _, _ in F.unread(p)], list(F.taken(p)) + state = next((x.get("state") for x in server.project_data(p, ())["feedback"] if x["file"].endswith(f.name)), None) + o = status(p) + nxt = subprocess.run(["bash", str(vh), "desk", "wait", str(p), "--timeout", "10"], capture_output=True, text=True, env=env, timeout=60) + if f.name not in un or f.name in took or state != "unread" or not [x for x in o["review"]["unread"] if x["file"].endswith(f.name)] \ + or o["now"]["code"] not in ("notes_unheard", "notes_left", "notes_late") or nxt.returncode != 0 or "在缝里被杀" not in nxt.stdout: + bad.append(f"{sig.name}: unread {un}, page {state}, now {o['now']['code']}, next wait {nxt.returncode} {nxt.stdout[:300]!r}") + p = film_at_script("gap-closed") # a real bin/vh desk wait whose output is closed before anything comes + w = subprocess.Popen(["bash", str(vh), "desk", "wait", str(p), "--timeout", "60"], stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True, env=env) + BG.add(w.pid) + if not armed(p): + bad.append("closed: the wait did not start") + else: + w.stdout.close() + f = submit(p, "E1", "没人读得到") + w.wait(timeout=20) + un = [x.name for x, _, _ in F.unread(p)] + if w.returncode != F.NOT_DELIVERED or f.name not in un or f.name in F.taken(p): + bad.append(f"closed output: exit {w.returncode}, unread {un}, taken {list(F.taken(p))}") + return "; ".join(bad) or None + check("a wait killed between claiming a note and writing it (KILL, TERM, INT), or whose output is closed: the note stays unread (status says so, " + "the page never says it was picked up) and the next wait hands it over", gap_kills) + + def two_waits_held(): # two waits held at the claim and released together: exactly one hands the note over, and it is taken once + p = film_at_script("race-held") + m1, m2 = T / "race-1.mark", T / "race-2.mark" + ws = [driven(p, "race", m1), driven(p, "race", m2)] + if not armed(p, 2): + return "the waits did not start" + f = submit(p, "E1", "只交一次(同时放开)") + if not until(lambda: m1.exists() and m2.exists()): + for w in ws: + w.kill() + return "the waits never both reached the claim" + for m in (m1, m2): + Path(str(m) + ".go").touch() + time.sleep(4) + outs = [] + for w in ws: + if w.poll() is None: + w.kill() + outs.append((w.wait(), w.stdout.read() or "")) + got = [o for _, o in outs if "只交一次(同时放开)" in o] + if len(got) != 1 or f.name not in F.taken(p): + return f"{len(got)} waits handed it over; taken {list(F.taken(p))}; {[rc for rc, _ in outs]}" + check("two waits held at the claim and released together on one note: exactly one hands it over (the claim is under the lock, and written " + "before the note is)", two_waits_held) + def open_agent(): # an agent outside Studio's window that ran a command on the film and is still open: no "stopped"; said where it is, # that words typed in Studio do not reach it, and a second AI here only as a second line that asks once more in those words o = stage("open") @@ -2428,7 +2527,7 @@ def open_agent(): # an agent outside Studio's window that ran a command on the act = n["act"] if n["code"] != "agent_outside" or not act.get("secondary") or not act.get("confirm") or "没有 agent" in n["say"]["zh"] \ or "窗口外面的 Claude Code" not in n["say"]["zh"] or "收不到" not in n["say"]["zh"] or "另起一个 AI" not in act["label"]["zh"] \ - or "两个一起做" not in (act.get("sure_note") or {}).get("zh", "") or "outside this window" not in n["say"]["en"]: + or "两个一起做" not in (act.get("sure_note") or {}).get("zh", "") or "outside this window" not in n["say"]["en"] or "在做" in n["say"]["zh"]: return f"while it is open: {n}" if m["code"] in ("agent_open", "agent_outside"): return f"after it went: {m['code']}" @@ -2438,8 +2537,10 @@ def open_agent(): # an agent outside Studio's window that ran a command on the def studio_agent(): # an agent Studio's own column started (under tools/desk/desk.py): the old offer, no "outside" o = stage("own") cc = shutil.which("cc") - if not cc or fake_agent("true") is None: + made = fake_agent("true") if cc else None # (builds the stand-in program; this one ends at once, not left open) + if made is None: return None + made.kill(); made.wait() shim = T / "studio-shim" / "tools" / "desk" / "desk.py" # a stand-in desk server: its command line names tools/desk/desk.py shim.parent.mkdir(parents=True, exist_ok=True) shim.write_text("import subprocess, sys, time\np = subprocess.Popen(sys.argv[1:])\np.wait()\ntime.sleep(600)\n") diff --git a/tools/desk/test_page.py b/tools/desk/test_page.py index 07e4f373..0afcdab6 100644 --- a/tools/desk/test_page.py +++ b/tools/desk/test_page.py @@ -83,13 +83,16 @@ def v(res, name): sys.exit(0) E1 = {"summary": "旁白稿第一版,逐句看", "decisions": [{"id": "names", "question": "英文名念不念?", "options": [{"id": "N1", "label": "不念"}, {"id": "N2", "label": "念"}], "recommend": "N1"}, - {"id": "go", "question": "旁白稿能定吗?", "options": [{"id": "OK", "label": "可以,往下做"}, {"id": "FIX", "label": "先改"}], "recommend": "OK"}], + {"id": "go", "question": "旁白稿能定吗?", "options": [{"id": "OK", "label": "可以,往下做"}, {"id": "FIX", "label": "先改", "needs_note": True}], "recommend": "OK"}], "appendix": [{"title": "大纲", "text": "| 段落 | 时间 |\n|---|---|\n| 开场 | 0–9 s |"}, {"title": "事实清单", "text": "- 一天两次"}, {"title": "引用", "text": "- 某教材"}], "decided": ["立意:从海边讲起"], "delegated": ["配音用男声"]} late = film("late", E1) # the script's round was submitted and an agent took it; the person writes more first = F.save(late, F.validate(late, {"round": "E1", "lang": "zh", "decisions": {"names": "N1", "go": "OK"}, "items": [{"target": "seg:1", "status": "change", "text": "开头再短点"}]})) F.mark_consumed(late, [first]) # (as an agent's wait or desk feedback leaves it) -fix = film("fix", E1) # nothing submitted yet: "先改" picked with no note +KEEP_AS_IS = {"id": "keep", "question": "开头那句保留吗?", "options": [{"id": "K1", "label": "保留"}, {"id": "K2", "label": "不要改,保持不变,不用重做"}], "recommend": "K1"} +fix = film("fix", dict(E1, decisions=E1["decisions"] + [KEEP_AS_IS])) # nothing submitted yet: "先改" picked with no note; a "no change" option picked +moved = film("moved", E1) # notes kept on the script, never sent, then the agent sends the outline again +AGAIN = {"summary": "大纲改成 3 段,再看一遍", "decisions": [{"id": "go", "question": "大纲能做分镜了吗?", "options": [{"id": "OK", "label": "可以"}, {"id": "FIX", "label": "先改", "needs_note": True}], "recommend": "OK"}]} busy = film("busy", dict(E1, least_sure=[{"id": f"c0{i}", "note": f"第 {i} 句会不会太书面,念出来像在读稿"} for i in range(1, 5)])) # eight notes kept beside a full column: the newest and the state line on screen at 1440 x 900 proc = subprocess.Popen([sys.executable, str(HERE / "fixtures" / "with_tty.py"), "bash", str(VH), "desk", "--root", str(T / "root"), "--port", "0", "--no-open", "--print-address"], @@ -116,6 +119,10 @@ def v(res, name): {"click": "#doSubmit", "after": 3000}, {"until": "$('#cMine') && /补交的 1 条,还没人取/.test($('#cMine').innerText) && $('#colRound').innerText", "name": "late_after", "ms": 10000}, {"go": f"#/p/{key(fix)}/outline/script", "after": 2500}, tab, + {"eval": "(pick('keep', 'K2'), true)", "name": "pick_keep"}, + {"click": "#openConfirm"}, + {"eval": "JSON.stringify({ ask: ($('#fixAsk') || {}).innerText || '', back: !!$('#fixBack') })", "name": "keep_sheet"}, + {"click": "#noSubmit"}, {"eval": "(pick('go', 'FIX'), true)", "name": "pick"}, {"click": "#openConfirm"}, {"eval": "JSON.stringify({ ask: ($('#fixAsk') || {}).innerText || '', back: !!$('#fixBack'), go: ($('#doSubmit') || {}).innerText })", "name": "fix_sheet"}, @@ -130,17 +137,46 @@ def v(res, name): {"go": f"#/p/{key(busy)}/outline/script", "after": 2500}, tab, {"eval": "(" + ", ".join(KEEP.format(t=f"cap:c0{i}", x=f"第 {i} 句再口语一点", lb=f"字幕 c0{i}") for i in range(1, 9)) + ")", "name": "eight"}, {"wait": 800}, - {"eval": "JSON.stringify((() => { const m = $('#cMine'), h = $('#cMine .blk-h'), n = $('#cMine li[data-goto=\"cap:c08\"]'), r = (e) => e && e.getBoundingClientRect(); " - "const H = r(h), N = r(n), M = r(m), B = r($('#colBody')); return { h: H && [H.top, H.bottom], n: N && [N.top, N.bottom], m: M && [M.top, M.bottom], " - "body: [B.top, B.bottom], text: h && h.innerText }; })())", - "name": "busy_view"}, ] + steps += [ # drafts on a page the agent replaced: shown as not sent, sent to their own round on the person's word + {"go": f"#/p/{key(moved)}/outline/script", "after": 2500}, tab, + {"eval": KEEP.format(t="cap:c03", x="第三句别念英文", lb="字幕 c03"), "name": "moved_keep"}, + {"write": str(moved / "out" / "review" / "gate-1b.json"), "text": json.dumps(AGAIN, ensure_ascii=False)}, + {"write": str(moved / "out" / "review" / "gate-1b.html"), "text": "1b"}, + {"write": str(moved / "out" / "review" / ".current"), "text": "1b\n"}, + {"until": "/在旁白稿那一页写的 1 条,还没交/.test(($('#cMine') || {}).innerText || '')", "name": "moved_shown", "ms": 15000}, + {"click": "[data-left-send]", "after": 3000}, + {"until": "!/还没交/.test(($('#cMine') || {}).innerText || '') || /补交|还没人取/.test(($('#cMine') || {}).innerText || '')", "name": "moved_sent", "ms": 10000}, + {"go": f"#/p/{key(busy)}/outline/script", "after": 2500}, tab, {"wait": 800}, # (back to the film with eight notes kept, for the layout below) + ] + VIEW = ("JSON.stringify((() => { const m = $('#cMine'), h = $('#cMine .blk-h'), n = $('#cMine li[data-goto=\"cap:c08\"]'), r = (e) => e && e.getBoundingClientRect(); " + "const H = r(h), N = r(n), M = r(m), B = r($('#colBody')); return { h: H && [H.top, H.bottom], n: N && [N.top, N.bottom], m: M && [M.top, M.bottom], " + "body: [B.top, B.bottom], text: h && h.innerText, theme: document.documentElement.dataset.theme }; })())") + for size in ((1280, 720), (1440, 900)): + steps.append({"viewport": list(size)}) + for theme in ("darkfield", "prism", "bridge"): + steps += [{"eval": f"(document.documentElement.dataset.theme = {theme!r}, true)", "name": "theme"}, {"wait": 500}, + {"eval": VIEW, "name": f"busy_view {size[0]}x{size[1]} {theme}"}] + steps += [{"eval": "(document.documentElement.dataset.theme = 'darkfield', true)", "name": "theme"}, {"click": "#lang", "after": 1500}, tab] + for size in ((1280, 720), (1440, 900)): + steps += [{"viewport": list(size)}, {"eval": VIEW, "name": f"busy_view {size[0]}x{size[1]} en"}] + steps += [{"click": "#lang", "after": 1500}] res = drive(url, steps) -finally: - try: - os.killpg(proc.pid, signal.SIGTERM) - except OSError: - pass +finally: # the desk this check started, and everything under it (bin/vh desk runs on in its own session): by process tree, never by name + rows = [x.split() for x in subprocess.run(["ps", "-A", "-o", "pid=,ppid="], capture_output=True, text=True).stdout.splitlines()] + tree, grew = {proc.pid}, True + while grew: + more = {int(a) for a, b in (r for r in rows if len(r) == 2) if int(b) in tree} - tree + tree, grew = tree | more, bool(more) + for sig in (signal.SIGTERM, signal.SIGKILL): + for x in tree: + try: + os.kill(x, sig) + except OSError: + pass + t1 = time.time() + while time.time() - t1 < 5 and any(subprocess.run(["kill", "-0", str(x)], capture_output=True).returncode == 0 for x in tree): + time.sleep(0.2) proc.wait(timeout=10) @@ -160,8 +196,13 @@ def check(what, ok, why): ok = "先改" in fs["ask"] and "还没写改哪里" in fs["ask"] and fs["back"] and fs["go"] == "就这样交" and fb["hidden"] and fb["focus"] == "say" and not fn["back"] and not fn["ask"] except (TypeError, ValueError, KeyError): ok = False -check("\"先改\" picked with no note: the sheet asks what to change, \"回去写\" closes it with the note box ready, \"就这样交\" still sends; with a note it does not ask", - ok, [fs, fb, fn]) +try: + ks = json.loads(v(res, "keep_sheet")) + ok = ok and not ks["ask"] and not ks["back"] +except (TypeError, ValueError, KeyError): + ks, ok = v(res, "keep_sheet"), False +check("\"先改\" (an option whose gate JSON says needs_note) picked with no note: the sheet asks what to change, \"回去写\" closes it with the note box " + "ready, \"就这样交\" still sends; with a note it does not ask, nor for an option that means \"no change\" (\"不要改,保持不变,不用重做\")", ok, [fs, fb, fn, ks]) cn = v(res, "counts") try: c = json.loads(cn) @@ -169,13 +210,24 @@ def check(what, ok, why): except (TypeError, ValueError, KeyError): ok = False check("the bar's count, the notes block's count and the notes listed agree (two notes on lines and the overall words)", ok, cn) -bv = v(res, "busy_view") -try: - b = json.loads(bv) - def seen(x): # inside the column's visible part, and inside the block's own - return x[0] >= b["body"][0] - 1 and x[1] <= min(b["body"][1], b["m"][1]) + 1 - ok = b["h"] and b["n"] and seen(b["h"]) and seen(b["n"]) and b["n"][0] >= b["h"][1] - 2 and "还没交 8 条" in b["text"] -except (TypeError, ValueError, KeyError): - ok = False -check("eight notes kept beside two decisions, four unsure places and three appendices at 1440 x 900: the notes' state line and the note kept last are on screen, no scrolling", ok, bv) +sent = [json.loads(f.read_text(encoding="utf-8")) for f in (moved / "out" / "review" / "feedback").glob("*.json")] if (moved / "out" / "review" / "feedback").is_dir() else [] +check("notes kept on a page the agent then replaced (never sent): the notes block lists them as not sent, on that page; sent on the person's click " + "to that page's own round, never to the new page", (res.get("moved_shown") or {}).get("ok") and (res.get("moved_sent") or {}).get("ok") + and [(x.get("round"), [i.get("text") for i in x.get("items") or []]) for x in sent] == [("E1", ["第三句别念英文"])], [res.get("moved_shown"), res.get("moved_sent"), sent]) +bad_views = [] +for name in [k for k in res if k and k.startswith("busy_view")]: + try: + b = json.loads(v(res, name)) + + def seen(x): # inside the column's visible part, and inside the block's own + return x[0] >= max(b["body"][0], b["m"][0]) - 1 and x[1] <= min(b["body"][1], b["m"][1]) + 1 + ok = b["h"] and b["n"] and seen(b["h"]) and seen(b["n"]) and b["n"][0] >= b["h"][1] - 2 and b["m"][1] <= b["body"][1] + 1 \ + and b["m"][1] - b["m"][0] >= 3 * (b["h"][1] - b["h"][0]) and ("还没交 8 条" in b["text"] or "8 not sent yet" in b["text"]) + except (TypeError, ValueError, KeyError): + ok = False + if not ok: + bad_views.append([name, v(res, name)]) +ok = not bad_views and len([k for k in res if k and k.startswith("busy_view")]) == 8 +check("eight notes kept beside two decisions, four unsure places and three appendices, at 1280 x 720 and 1440 x 900, in the three themes and in English: " + "the notes' state line and the note kept last are on screen, apart, inside the column, the block never squeezed under three lines", ok, bad_views) print("end", flush=True) diff --git a/tools/gate.py b/tools/gate.py index 1bd61dc2..ad9319e2 100644 --- a/tools/gate.py +++ b/tools/gate.py @@ -137,7 +137,7 @@ def card(k): "options": [{"id": "OK", "label": "放行,出正式画质" if zh else "It passes: render the final", "pro": f("好处", "what it gains"), "con": f("代价", "what it costs")}, {"id": "FIX", "label": "改完下面几处再看" if zh else "Fix the places below, then look again", - "pro": f("好处", "what it gains"), "con": f("代价", "what it costs")}], + "pro": f("好处", "what it gains"), "con": f("代价", "what it costs"), "needs_note": True}], # (picked with no note, Studio asks what to fix) "recommend": f("OK 或 FIX", "OK or FIX"), "why": f("一句理由", "why, in one line"), "cost": "现在改:中 · 锁画面后改:高" if zh else "now: medium · after the picture lock: high"}] d["assets"] = [{"path": f("初版成片的路径,例如 out/draft.mp4", "the draft's path, e.g. out/draft.mp4"), "caption": f("初版:多长、什么画质", "the draft: its length and quality"), "for": "draft"}, @@ -309,7 +309,8 @@ def main(argv): for c in ("desk", "page", "chat"): how.add_argument(f"--{c}", dest="channel", action="store_const", const=c, help=f"review in the {c} this time") ap.add_argument("--wait", action="store_true", help="the desk only: then wait for the submission, like bin/vh desk wait") - ap.add_argument("--timeout", type=float, default=43200, help="with --wait: seconds (default 43200: 12 h)") + import feedback as F0 + ap.add_argument("--timeout", type=float, default=F0.WAIT, help=f"with --wait: seconds (default {F0.WAIT:.0f}: {F0.WAIT / 3600:g} h)") ap.add_argument("--port", type=int, help="the desk's port when it has to start (default: the first free of 8780–8799)") ap.add_argument("--print-address", action="store_true", help="the desk only, for a browser on another machine: open none, write an " "address that opens one page to your terminal alone (refused with no terminal, " diff --git a/tools/schemas/gate.schema.json b/tools/schemas/gate.schema.json index 8820c367..9951dbb2 100644 --- a/tools/schemas/gate.schema.json +++ b/tools/schemas/gate.schema.json @@ -49,7 +49,8 @@ "option": { "type": "object", "required": ["id"], - "properties": {"id": {"$ref": "#/$defs/text"}, "label": {"$ref": "#/$defs/text"}, "pro": {"$ref": "#/$defs/text"}, "con": {"$ref": "#/$defs/text"}} + "properties": {"id": {"$ref": "#/$defs/text"}, "label": {"$ref": "#/$defs/text"}, "pro": {"$ref": "#/$defs/text"}, "con": {"$ref": "#/$defs/text"}, + "needs_note": {"type": "boolean", "description": "true: an option that means \"change it\": picked with no note, Studio asks what to change before it is sent"}} }, "asset": { "type": "object", diff --git a/tools/standing.py b/tools/standing.py index ac48751b..f0443ac9 100644 --- a/tools/standing.py +++ b/tools/standing.py @@ -168,12 +168,12 @@ "notes_left": ("你交的 {n} 份意见还没有 AI 来取({s})。", "{N} {n_subs} you sent {are} not picked up by any AI yet ({s})."), "notes_left.short": ("意见还没人取", "notes not picked up yet"), "notes_left.live": ("正在等的 {a} 马上会取。", "The {a} that is waiting picks them up at once."), - "notes_left.outside": ("做这支片子的 {a} 在这个窗口外面:回到它那边说一声“我交了”,它就会来取。", "{A}, outside this window, is making this film: tell it \u201cI've sent it\u201d over there and it picks them up."), + "notes_left.outside": ("这支片子开在这个窗口外面的 {a} 里:回到它那边说一声“我交了”,它就会来取。", "This film is open in {A} outside this window: tell it \u201cI've sent it\u201d over there and it picks them up."), "notes_left.next": ("现在没有 AI 在等。下次有 AI 接着做这支片子,会先拿到它们。", "No AI is waiting right now. The next AI to carry on with this film gets them first."), "notes_left.also": ("{s}也出来了,等你{v}。", "{S} {be} out for you too."), - "agent_outside": ("这支片子正由这个窗口外面的 {a} 在做;在这里打的字,它收不到。", "{A} is making this film outside this window; what you type here does not reach it."), + "agent_outside": ("这支片子开在这个窗口外面的 {a} 里;在这里打的字,它收不到。", "This film is open in {A} outside this window; what you type here does not reach it."), "agent_outside.more": ("要它接着做,回到它那边说一句。", "To have it carry on, say so over there."), - "agent_outside.short": ("在窗口外面做", "made outside this window"), + "agent_outside.short": ("开在窗口外面", "open outside this window"), "act.second": ("在这里另起一个 AI 做这支片子", "Start a second AI on this film here"), "act.second_sure": ("确定,另起一个", "Yes, start a second one"), "act.second_note": ("外面那个 {a} 还开着。两个一起做,可能改到同一处。", "{A} outside is still open. Two working at once may change the same thing."), diff --git a/tools/status.py b/tools/status.py index 692c9ae1..8c5875d4 100644 --- a/tools/status.py +++ b/tools/status.py @@ -248,7 +248,7 @@ def on_file(s): st["note"] = "bin/vh gate refused this page, so that run sent the person nothing: fix it and send it again" elif latest is not None and pid == cur: if pend: - st["state"], st["note"] = "waiting_agent", f"{len(pend)} submission(s) not handed to the agent yet (bin/vh desk feedback)" + st["state"], st["note"] = "waiting_agent", f"{len(pend)} submission(s) not handed to the agent yet (bin/vh desk wait hands them over)" elif handed: st["state"], st["note"] = "waiting_agent", "the submission was handed over; REVIEW.md has no decision for it yet" else: @@ -260,7 +260,7 @@ def on_file(s): if key == "1" and st["state"] == "done" and latest is not None and pid == cur and len(plist) > 1 and pid != plist[0].stem[5:] \ and latest.with_suffix(".html").exists() and R.refusal(project, pid) is None and not (page_secs and G.record(page_secs[-1][1])[0]): if pend: - st["state"], st["note"] = "waiting_agent", f"{len(pend)} submission(s) for page {pid} not handed to the agent yet (bin/vh desk feedback)" + st["state"], st["note"] = "waiting_agent", f"{len(pend)} submission(s) for page {pid} not handed to the agent yet (bin/vh desk wait hands them over)" elif handed: st["state"], st["note"] = "waiting_agent", f"the submission for page {pid} was handed over; REVIEW.md has no decision for it yet" else: @@ -681,8 +681,8 @@ def scaffold_first(): if s["state"] == "waiting_agent": fb = s["feedback"] or {} if fb.get("pending"): - return out("agent", busy + f"read the person's submission for {s['name']}, then write what was decided into REVIEW.md", - [f"bin/vh desk feedback {p} --round {pid}"], [R_DESK]) + return out("agent", busy + f"read the person's submission for {s['name']} (bin/vh desk wait hands every note nobody took over at once, exit 0 " + "straight away), then write what was decided into REVIEW.md", [f"bin/vh desk wait {p}"], [R_DESK]) if fb.get("handed"): return out("agent", busy + f"write what was decided and changed under the desk's section for {s['name']} in REVIEW.md (定了 / 改了)", [], [R_DESK]) return out("agent", busy + (s["note"] or f"record the decision for {s['name']} in REVIEW.md"), [], [R_RECORD]) From 3bd782c500c6dce57160921d619cbdb8f0aba36e Mon Sep 17 00:00:00 2001 From: zhanglinghao Date: Mon, 23 Nov 2026 18:42:16 +0800 Subject: [PATCH 6/7] The agent column's attack check reads the project lock once and takes a lock that is gone as naming nothing (GitHub's macOS runner: the turn ended between the look and the read) --- tools/desk/test_agents.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/tools/desk/test_agents.py b/tools/desk/test_agents.py index d9570170..94f84d8d 100644 --- a/tools/desk/test_agents.py +++ b/tools/desk/test_agents.py @@ -1390,7 +1390,10 @@ def attack_checks(): if any(set(x) - {"ok", "opened", "how", "why", "code", "status"} or tok in json.dumps(x) for x in got.get("open") or [{}]): return f"/api/open answered {got.get('open')}" d.a(sid, "answer", {"request": got["rid"], "option": "reject"}) - lock = (proj / ".ovh" / "agent.lock").read_text() if (proj / ".ovh" / "agent.lock").exists() else "" + try: # (the turn may end and take its lock away between a look and the read: a lock that is gone names nothing) + lock = (proj / ".ovh" / "agent.lock").read_text() + except FileNotFoundError: + lock = "" if str(d.port) in lock or "http" in lock: return "the lock names the desk" leaked = [str(f) for f in proj.rglob("*") if f.is_file() and tok.encode() in f.read_bytes()] From 987127ab28ae4dd431e543155694d3520b7fac02 Mon Sep 17 00:00:00 2001 From: zhanglinghao Date: Mon, 23 Nov 2026 20:10:40 +0800 Subject: [PATCH 7/7] The window's review: notes carry what they were written on and follow it, the stamps are taken before the read, and a new page waits for typing MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - A kept note remembers its place's words (an outline part's title and words, a script line, a shot). After the files change it stays, goes where its content went (new number and time, "原来是第 3 段" once), or says its place changed (never drawn on what took it, no click, sent saying so) or is gone; putting the files back puts it back. - files_stamp and notes_stamp are taken before the film is read; the narration's timing is in the stamp; the status poll's round is the readable pages' own. - The scroll comes back after the stop's page part has loaded; busy is a text box typed in within 30 s, not focus; a new page is followed only when the person did not go elsewhere by choice (then a toast and the column's way there), with a history entry of its own. - A stop's summary above the tabs keeps to two lines, whole below. - New page checks for each, with conditions instead of fixed waits. --- changes/studio-window-follows-files.md | 7 +- tools/desk/README.md | 6 +- tools/desk/server.py | 15 ++- tools/desk/static/core.js | 4 + tools/desk/static/studio.css | 2 + tools/desk/static/studio.js | 125 +++++++++++++++--- tools/desk/test_page.py | 174 ++++++++++++++++++++----- 7 files changed, 275 insertions(+), 58 deletions(-) diff --git a/changes/studio-window-follows-files.md b/changes/studio-window-follows-files.md index 5dcd8175..2fa04ee0 100644 --- a/changes/studio-window-follows-files.md +++ b/changes/studio-window-follows-files.md @@ -1,6 +1,7 @@ **Studio 的窗口跟着文件走:agent 改了大纲、文案,窗口自己换成新的一版;一站开在它要审的东西上** - Why: 第一支真片子里,人对着已经不存在的 9 段大纲写意见,文案改到第四版窗口还是第一版,要按"显示 → 重新载入",重新载入又跳回别的页;六次开站有四次停错页(大纲复审停在立意,文案停在大纲页签);点下面的"字幕 / 旁白",内容却在上面展开,要审的旁白被挤到很下面。 -- agent 改了片子的文件(BRIEF、SCRIPT、NOTES、DECISIONS、REVIEW、镜头表、剪辑表、审阅页),开着的 Studio 几秒内自己换成新的,停在原来的模块、页签和位置,说一句"文件改了,这里换成了新的一版";人正在打字、交之前的那一页开着、片子在放时先不换。草稿对着的那一处没有了(大纲少了一段),草稿照留,写明"这一处已经不在了"。 +- agent 改了片子的文件(BRIEF、SCRIPT、NOTES、DECISIONS、REVIEW、镜头表、剪辑表、审阅页、旁白的时间),开着的 Studio 几秒内自己换成新的,停在原来的模块、页签和位置,说一句"文件改了,这里换成了新的一版";人正在打字(30 秒内敲过键)、交之前的那一页开着、片子在放时先不换,选了一个选项不算在打字。 +- 写了还没交的意见记着它写在什么上(大纲一段的名字和话、旁白的那一句、镜头的话)。agent 改了大纲:同样的那一段挪了位置,意见跟着走、换成新的段号和时间,说一次"原来是第 3 段";那一段改了名或改了话,意见不再画在占了原处的新段上,写明它写的时候对着什么、"这一处后来改了",交给 agent 时也这样写;删掉了,写明"这一处已经不在了"。 - 一站开在它要问的东西上:立意定了以后再发的大纲(1b)、没有立意卡的关卡 ① 开在大纲上,要定的事在右栏;文案(E1)开在大纲的"字幕 / 旁白"页签上。 -- 窗口自己挑的模块写进地址:agent 发来新的一页、窗口跟过去以后,左边点同一个模块不再没反应,重新载入也停在原处。 -- 关卡页的说明(已经定了的、替你定的、附录、没看没听的)放到页签内容的下面,页签上面只留一句摘要:点哪个页签,要审的东西都在页签下面紧挨着。 +- 窗口自己挑的模块写进地址:左边点同一个模块不再没反应,重新载入也停在原处。agent 发来新的一页:人自己走到别处的,留在那里,说一句"大纲那一页出来了",右栏顶上有去那一页的按钮;Studio 自己开着的,跟过去,后退能回来。写到一半、读不出来的审阅页不算新的一页,页面不再来回跳。 +- 关卡页的说明(已经定了的、替你定的、附录、没看没听的)放到页签内容的下面,页签上面只留摘要(最多两行,长的整句在下面):点哪个页签,要审的东西都在页签下面紧挨着。 diff --git a/tools/desk/README.md b/tools/desk/README.md index 59460fb0..20719d60 100644 --- a/tools/desk/README.md +++ b/tools/desk/README.md @@ -2,7 +2,7 @@ 审阅台是一个本地网页控制台,样子是 Studio 的外壳:左边一列模块,顶上这支片子走到哪一站,右边一列分两页:和这台机器上的 agent 说话(Claude Code、Codex、DeepSeek Harness),以及这一轮要人定的事和人的点评。不带项目打开,是这台机器上所有片子的空间;进了一个项目,打开在等人的那一站(立意、分镜或成片),成片模块把片子、镜头、旁白、音乐、检查和点评排在一条时间线上。人点卡片选选项、选中一处写一句、提交;agent 在后台等着,人一提交就接着做。它是 `studio` 档位默认的审阅界面;Studio 开着时,`standard` 的停也默认开在它里面(`bin/vh gate` 看到 Studio 在跑才这样,从不为此起 Studio);别的时候 `standard` 想用也可以(什么时候用、agent 怎么挂等待,见 `playbook/01-pipeline.md` 的"审阅台")。这一页讲它读什么、写什么,也就是项目文件要怎么写,审阅台才排得出来。 -**文件是唯一的事实来源。** 审阅台每次刷新都从项目文件重新读,自己不存状态;agent 改了片子的文件(文档、镜头表、剪辑表、审阅页),开着的页面几秒内自己重读,停在原来的模块、页签和滚动位置,说一句"文件改了";人正在打字、交之前的那一页开着、片子在放时,等这些停下再读。草稿对着的那一处在新文件里没有了(大纲改了段),草稿照留,写明"这一处已经不在了"。人的草稿只留在浏览器里,提交以后才落进项目。读不出结构的文档不会被藏起来:每份文档都在"文档"页原样排版,结构化的页面空着时,就地显示那份文档的原文,"文档"页顶上列出哪些没按约定读出来。 +**文件是唯一的事实来源。** 审阅台每次刷新都从项目文件重新读,自己不存状态;agent 改了片子的文件(文档、镜头表、剪辑表、审阅页、旁白的时间),开着的页面几秒内自己重读,停在原来的模块、页签和滚动位置(等这一站的页那一块排好了再回到原处),说一句"文件改了";人正在打字(写字的框里 30 秒内敲过键或在输入法里选字)、交之前的那一页开着、片子在放时,等这些停下再读;选了一个选项、焦点停在那里不算在打字。每条草稿记着它写在什么上(大纲一段的名字和那段的话、旁白一句的话、镜头的话):文件改了以后,同样的内容还在原处,草稿不动;挪到了别处,草稿跟着走,换成新的段号和时间,说一次"原来是第 3 段";原处的内容改了、别处也没有,草稿不画在占了原处的新内容上,写明它写的时候对着什么、"这一处后来改了",交的时候也这样写给 agent,人可以留着或删掉;整个没了,写明"这一处已经不在了"。人的草稿只留在浏览器里,提交以后才落进项目。读不出结构的文档不会被藏起来:每份文档都在"文档"页原样排版,结构化的页面空着时,就地显示那份文档的原文,"文档"页顶上列出哪些没按约定读出来。 ## 命令 @@ -69,7 +69,7 @@ bin/vh desk agents install # 装那一家的 ACP 适配器 - **样片墙**:片子下面是"照着样片开始":工作台自己做的四支片子(`showcase/` 里官网也放的那四支,同样的顺序:竖屏科普、数学讲解、手绘短片、发布短片),每张卡写类型、时长、竖屏还是横屏和尺寸、风格(库里有这个风格的,带上它的 id),一个按钮"照这个做一支"。按钮只把一句话写进对话那一列开新片子的框里,不发送、不开始任何事:和官网那张卡复制的一字不差(`tools/desk/test_wording.py` 对着官网查),点名库里的风格(`styles/`)和取自这支片子的配方;有要你填的空([在这里贴上它的链接])就选中它;框里原来写的,⌘Z 拿得回来;窄屏上那一列在下面,框会滚到眼前。框写不进去时不写:这一页只能看,就说这一页只能看;还没装 agent,就把这一句先留着,在那一列的"装上"那里说一声并滚到眼前,装好以后框上面有一个"写进框里",点了才写;空间里那段对话还在做、或在等你批准,不换走它,框上面说一句,等它停下再点"写进框里"。那段对话闲着时,换成开新片子的框,并说一声它在"历史"里。画面是官网的封面图(`docs/site/img/`);这份克隆里有这支片子(`tools/fetch_media.sh` 下载到 `tools/media.txt` 写的那个位置)时,鼠标停在卡上静音放 4 秒。空间里还没有片子时样片墙展开着,就是这一页;有了自己的片子,它收在片子下面成一行,点开再看;窄屏(900 px 以下,那一列在页面下面)也先收着,免得四张卡把框推到几屏以外。人自己点开、收起的,这个浏览器记住。 - **交出去以后**:这一站的意见交给 agent 以后(这一站在等 agent),"这一站"那一页不再摆着没选过似的卡片,而是"交给 agent 的":每件决定选了哪个、每条意见、什么时候交的,下面一个"改了再交",点了才把卡片摆回来;底下那一条写"已经交给 agent 了",按钮歇着,标签页上也不再写"等你定"。没交成功时,服务回一个 `reason`(`token`、`origin`、`page_changed`、`invalid`、`too_big`、`slow`、`moved`),页面照它用人的语言说发生了什么、该做什么,不把服务的英文原样放上去。 - **现在到哪了**:进了一支片子,右栏两页(对话、这一站)的上面是一句短话,说这支片子现在怎么样、轮到谁,下面一行小一点的字说细节(停在哪、留了什么、做好的文件,文件点得开),都是 `bin/vh status` 的 `now:` 那几行(中文或英文;英文和终端里一字不差),再下面至多一个按钮:要人看的一站是"去看初版"这种,转到那一站的模块(已经在那一页就不放);要 agent 接着做的(意见交了没人取、agent 停下了、引擎没装、暂停了)是"让 agent 来看意见""让 agent 接着做":点一下,在这支片子最近的对话里(没有就开一个)发一句写好的话:只用 `standing.py` 词表里的字、数字和时间拼成(命令名不在词表里时只认 `bin/vh` 命令名的样子),不放项目文件里的别的文字;输入框里人自己的草稿不动,这句话照样在对话记录里,记的是人说的。下面一行小字是这支片子的打算(`plan`:多长、竖屏横屏、有没有旁白、在哪几处停给人看),从 BRIEF 和停的计划读,模板里没填的不写。空间的卡片上写这一句的短的那一半("停下了""正在渲染,340 / 900 帧""意见还没人取"),轮到人的(等人看、意见没人取、停下了、暂停了)亮琥珀色。每种情况说什么,见下面"一个项目到哪了"的 `now`。 -- **一支片子**(`#/p/<键>[/<模块>]`):打开在等人的那一站的模块,按那一页问的是什么定(关卡 ① 有立意卡是立意,没有立意卡的(比如立意定了以后再发的大纲 1b)是大纲;脚本 E1 是大纲的"字幕 / 旁白"页签;② 分镜,③ 成片);页面自己挑的模块写进地址(不另加一条历史),所以左边点它不会没反应,重新载入也停在原处;没人等时打开正在做的那一站,再没有就是成片。关卡不再是另一页:等人那一站的模块就是这一轮的关卡页,要你定的事在右栏。照原型排的模块自己画关卡页的画面(立意卡、镜头),关卡页里其余的东西(替你定的、附录、别的图)接在模块下面;别的页签也一样:关卡页的一句话摘要在页签上面,其余的接在页签的内容下面,点页签不会把要看的东西挤下去;成片模块把关卡页的画面放在它的时间线上。`#/p/<键>/gate/<页>` 打开那一页问的那个模块和页签,之前的页只看不交。 +- **一支片子**(`#/p/<键>[/<模块>]`):打开在等人的那一站的模块,按那一页问的是什么定(关卡 ① 有立意卡是立意,没有立意卡的(比如立意定了以后再发的大纲 1b)是大纲;脚本 E1 是大纲的"字幕 / 旁白"页签;② 分镜,③ 成片);页面自己挑的模块写进地址,所以左边点它不会没反应,重新载入也停在原处。agent 发来新的一页时:人是自己走到现在这里的(点了链接、左边、后退),就留在这里,说一句"大纲那一页出来了",右栏顶上那一句有去那一页的按钮;是 Studio 自己开到这里的(`bin/vh gate` 把窗口送到一站),就跟过去,另加一条历史,后退回到原处;人正在打字或交之前的那一页开着,等停下再说。读不出来的审阅页(写到一半)不算新的一页;没人等时打开正在做的那一站,再没有就是成片。关卡不再是另一页:等人那一站的模块就是这一轮的关卡页,要你定的事在右栏。照原型排的模块自己画关卡页的画面(立意卡、镜头),关卡页里其余的东西(替你定的、附录、别的图)接在模块下面;别的页签也一样:关卡页的摘要在页签上面,最多两行(长的,整句在下面),其余的接在页签的内容下面,点页签不会把要看的东西挤下去;成片模块把关卡页的画面放在它的时间线上。`#/p/<键>/gate/<页>` 打开那一页问的那个模块和页签,之前的页只看不交。 - **其余模块**照原型排(`static/modules.js`、`modules.css`),画面在前,字少;每样东西都能选中再写点评,点评带着它是什么。数据只来自已有的命令和项目文件,缺的那一块照实说空,写上做它的命令。 - **模板里没填的不算写了**:BRIEF、NOTES 里原样留着的模板占位(整格只是一个 `{…}`,比如 `{the story in one sentence: …}`)当成还没写:立意、故事线、素材清单的那一行、大纲那一段都不显示,立意页写"立意卡还没出来,立意也还没写",底下一条写"立意还没定",大纲页写"大纲还没写";不会把刚 `bin/vh new` 出来的片子说成已经定了什么。 - **立意**:左边是 NOTES.md 素材清单里只属于这个题目的东西,按数字、物件、原话、矛盾、意外分组,和「点子」里那条同题的视频常见的样子;右边是最新一页关卡 ① 的立意卡(带画面的那件决定),各配一帧。关卡 ① 开着时,"选这张"就是这一轮的决定,和右栏同步;"再想一张像它的"要 agent,这一版把这半句话放进写点评的框。还没有关卡 ① 的页时,显示 BRIEF 写下的立意。 @@ -129,7 +129,7 @@ bin/vh desk agents install # 装那一家的 ACP 适配器 | `GET /api/p/<键>/data` | `bin/vh desk data` 的内容,加 `status`(`bin/vh status --json`)、`key`、`home`、`pid`(这个项目文件夹的身份:真实路径的 SHA-1,提交要带上)、`only`、`current`(这一轮的页名)、`round_open`(这一轮那一站还没定:不是 done、skipped;这时提交带上它还没交过、或交过以后改了的决定),`feedback` 里每份提交的 `state`(`unread` 还没人取、`taken` 取走了、`answered` 答过了;读不出时是 `null`,页面就不说)、`taken`(`t`、`program`、`by`)和 `late`(补交的),`notes_stamp`,和 `studio`(`film` 是成片模块播的那一支,只取在的文件;这一站没点名片子、`bin/vh status` 的那支又没有声音、BRIEF 也没说要无声片时,换成有声音、而且不比它旧的一支(分镜的 animatic、关卡页的 film 或 animatic,新的页在前;`bin/vh status` 本身不变);换了时 `film_instead` 是没放的那支,缩略图、波形和检查的问题都是那支的,不给(读数写明放的是哪个文件,不写第几版);`film_sound` 是它有没有声音(true、false,ffprobe 看不了是 null;一个文件只看一次,大小和时间不变就记着);要的那支不在时,`film_missing` 是它的路径;`sheet` 是最新的联系表;成片模块用的:`timeline` 是 `bin/vh timeline --resolved` 的内容;`thumbs`、`peaks` 是 `bin/vh thumbs`、`peaks` 做过才有的记录;`check` 和 `findings` 是最近一次检查的结论和带时间的问题,没过和要注意的;读不出来的那一样是 `null`,原因记在 `warnings`),和 `mods`(其余模块读的,都是已有命令写下的文件:`loudness` `{integrated, true_peak, lra, target, severity}` 和 `silences`、`checks`(最近一次检查的每条 finding:`kind, severity, message, t, t1`);`pace`(旁白时间轴里 `bin/vh pace` 写的 `reference, unit, speech, with_pauses` 和逐句的 `lines`)、`voice`(旁白用的音色)、`audition`(最新的 `audition.json`:`{file, provider, unit, text, voices: [{voice, file, duration, pitch_hz, speech_rate, misread, error}]}`)、`lifts`(最新的 `*.beats.json` 的候选落点);`covers` `[{path, ratio, id, text}]`、`subs`(字幕文件);`assets`(台账里没删的每一件:`{id, kind, path, there, system, license, license_name, source, url, aigc, used_by, note}`;`system` 是系统自带的字体(`/System/Library/…`、`/Library/Fonts/`、Windows 的 Fonts 这些),算在,不算在项目外;没有台账是 `null`)、`refs`(`research/refs.json`)、`digests` `[{id, path, bytes}]`;没有台账时 `assets_notes` `{file, rows: [{file, source, license, there}]}` 是 NOTES.md 里旧的素材台账表(`there` 对链接是 `null`);每一部分各读各的:读不出的那部分是空的,`errors` 写着它的文件和原因,别的照样有;只读项目里面的文件,指到项目外的链接不跟,和 `/f/` 一样) | | `GET /api/p/<键>/gate/<页>[?lang=zh\|en]` | 那一页的关卡视图:`{version, gate, current, this_round, title, lang, takeall, html, errors, warnings, decisions: [{id, question, recommend, options}], summary, cards, marks, not_reviewed}`;`html` 和静态页同一份标记,文件地址换成 `/f/<键>/…`;`cards` 是所有决定的选项卡(右栏用,同一份标记),`marks` 是没把握和请你听的地方 `[{kind: least \| listen, t, t1, id, note, target}]` | | `GET /api/p/<键>/stage` | 不等人时的画面:`{kind: "video", path, html}`(同一个播放器和标尺),或 `{kind: "image", path, href}`,或 `{kind: null}` | -| `GET /api/p/<键>/status` | `files_stamp`:页面读的那些文件(文档、`shots.json`、`edit.json`、审阅页和 `.current`)的修改时间和大小算成的一个戳,变了页面就重读;有没有 agent 在等这个项目的反馈(`round` 之外,`live`:等着的那个 `wait` 等的正是现在这一轮,一交就取走;`notes_stamp`:交了或取走了一份就变,页面据此重读每份意见的状态),这一轮的页名 `round`,和这支片子现在到哪了:`now`、`plan`(`bin/vh status --json` 的同名字段,按列表的读法算:不读素材台账、cast 和调研)。页面每 4 秒问一次,`now` 变了就换右栏顶上那一句 | +| `GET /api/p/<键>/status` | `files_stamp`:页面读的那些文件(文档、`shots.json`、`edit.json`、审阅页和 `.current`、旁白的时间 `audio/timeline.<语言>.json` 和 `out/edit.timeline.<语言>.json`)的修改时间和大小算成的一个戳,在读片子之前取(读的时候文件又变了,页面会再读一次),变了页面就重读;渲染出来的东西(成片里的镜头、缩略图、波形、最近一次 `bin/vh check`)不在里面,下一次重读时才换上;`round` 只算读得出来的审阅页;有没有 agent 在等这个项目的反馈(`round` 之外,`live`:等着的那个 `wait` 等的正是现在这一轮,一交就取走;`notes_stamp`:交了或取走了一份就变,页面据此重读每份意见的状态),这一轮的页名 `round`,和这支片子现在到哪了:`now`、`plan`(`bin/vh status --json` 的同名字段,按列表的读法算:不读素材台账、cast 和调研)。页面每 4 秒问一次,`now` 变了就换右栏顶上那一句 | | `POST /api/p/<键>/feedback` | 一次提交(格式见下面"写什么"),另带 `pid`:和这个地址现在指的文件夹对不上(或没带)就 409,不写进任何项目 | | `GET /f/<键>/<路径>` | 这个项目里的一个文件(支持 Range) | | `GET /v/<键>/<路径>` | 同一个文件放在一页里:顶上一条细栏写着文件名和它在项目里的位置;文本和 markdown 当文本显示(markdown 经 `reader.render_md`,一律先转义),图片、视频和音频的播放器、网页放在框里(仍受 `/f/` 的沙箱头管着),显示不了的种类说一句并说文件在哪。Studio 自己的应用把控制台里"在新页打开"的链接都开在这里,所以开出来的窗口不会是空的 | diff --git a/tools/desk/server.py b/tools/desk/server.py index 65d1ba39..1eb4e7bc 100644 --- a/tools/desk/server.py +++ b/tools/desk/server.py @@ -662,12 +662,15 @@ def _drop_missing(project, d, key): def files_stamp(project): """A stamp of the files the page is drawn from: the project's documents (reader.DOCS), its shot list and edit list, its - review pages and which one is this round. It changes when the agent writes one of them, and an open page then reads the - film again (renders, frames and other media do not change it).""" + review pages and which one is this round, and the narration's timing (audio/timeline..json, out/edit.timeline..json). + It changes when the agent writes one of them, and an open page then reads the film again. Renders, frames and other media do + not change it, nor does what the cut module reads from a render (the shots inside a rendered film, thumbnails, peaks, the + latest check): a page open during a render shows those after its next reload.""" project = Path(project) paths = [project / n for n in list(reader.DOCS) + ["shots.json", "edit.json"]] + [project / "out" / "review" / ".current"] try: paths += sorted((project / "out" / "review").glob("gate-*.json")) + paths += sorted((project / "audio").glob("timeline.*.json")) + sorted((project / "out").glob("edit.timeline.*.json")) # the narration's timing (a voice-over done again) except OSError: pass h = hashlib.sha1() @@ -686,6 +689,7 @@ def project_data(project, parts=("studio", "mods")): and what the other modules read (mods). A static review page asks for what its stop's modules need (tools/review.py). Raises what read_project raises; a part that cannot be read is null, the reason in warnings.""" revision_stamp = RV.stamp(project) + stamps = F.notes_stamp(project), files_stamp(project) # before the read: a file written during it leaves the page one reload behind, never stale for good data = reader.read_project(project) try: import status as S @@ -710,8 +714,7 @@ def project_data(project, parts=("studio", "mods")): fb["state"] = "taken" if t is not None else "unread" if n in un else "answered" fb["taken"] = {"t": t.get("t"), "program": t.get("program"), "by": t.get("by")} if t is not None else None fb["late"] = bool(un.get(n)) - data["notes_stamp"] = F.notes_stamp(project) - data["files_stamp"] = files_stamp(project) + data["notes_stamp"], data["files_stamp"] = stamps _drop_missing(project, data.get("shots"), "video") # the storyboard's animatic, and the pictures the gate pages name for r in data.get("rounds") or []: g = r.get("data") if isinstance(r, dict) and isinstance(r.get("data"), dict) else {} @@ -1149,7 +1152,6 @@ def do_GET(self): if what == "data": return self._data(project, key) if what == "status": # with this round's page: the console notices a new page the agent sent; and where the film stands now - pages = review.gate_pages(project) try: import status as S o = S.collect(project, light=True) @@ -1157,7 +1159,8 @@ def do_GET(self): except (Exception, SystemExit): # the page keeps what it has now = plan = None lis = F.listening(project) - cur = pages[-1].stem[5:] if pages else None + cur = F.current_round(project) # (the readable pages only, as the page's own rounds: a page half-written is not a new round) + cur = None if cur == F.NO_ROUND else cur return self._json(dict(lis, project=project.name, key=key, round=cur, revision_stamp=RV.stamp(project), now=now, plan=plan, live=bool(lis.get("listening")) and lis.get("round") is not None and lis.get("round") == F.current_round(project), notes_stamp=F.notes_stamp(project), files_stamp=files_stamp(project))) diff --git a/tools/desk/static/core.js b/tools/desk/static/core.js index ea01770c..5f912974 100644 --- a/tools/desk/static/core.js +++ b/tools/desk/static/core.js @@ -175,6 +175,8 @@ const STR = { ho_s_1: "立意", ho_s_outline: "大纲", ho_s_E0: "画风样张", ho_s_E1: "旁白稿", ho_s_2: "分镜", ho_s_E2: "配乐安排", ho_s_E3: "最终的声音", ho_s_3: "初版", ho_s_E4: "第一章样片", ho_s_E5: "定画面的版本", ho_s_notes: "随手写的意见", ho_s_other: "这一页", ho_files: "文件改了,这里换成了新的一版", ho_gone: "(这一处已经不在了)", + ho_changed: "(写的时候对着「{x}」,这一处后来改了)", ho_newpage: "{s}那一页出来了", ho_moved_seg: "(原来是第 {i} 段)", ho_moved: "(原来是 {i})", + ho_changed_here: "(这一处后来改了)", ho_left: "在{s}那一页写的 {n} 条,还没交", ho_left_b: "那一页已经换成了新的一页。这几条不会自己交出去,也不算进现在这一页。", ho_left_send: "交到{s}那一轮", ho_left_drop: "不要了", ho_left_fail: "没有交成功,这几条还留在这里。", }, @@ -347,6 +349,8 @@ const STR = { ho_s_1: "the concept", ho_s_outline: "the outline", ho_s_E0: "the style frames", ho_s_E1: "the script", ho_s_2: "the storyboard", ho_s_E2: "the sound plan", ho_s_E3: "the final sound", ho_s_3: "the first draft", ho_s_E4: "the first chapter", ho_s_E5: "the picture lock", ho_s_notes: "your loose notes", ho_s_other: "this page", ho_files: "The files changed; this shows the new version", ho_gone: " (no longer there)", + ho_changed: " (written on “{x}”; this place has changed since)", ho_newpage: "A new page is out: {s}", ho_moved_seg: " (was part {i})", ho_moved: " (was {i})", + ho_changed_here: " (changed since you wrote this)", ho_left: "{n} {n|note|notes} written on {s}, not sent", ho_left_b: "A new page has replaced that one. These do not go by themselves, and they are not counted with this page.", ho_left_send: "Send them with {s}", ho_left_drop: "Drop them", ho_left_fail: "Not sent; they are still here.", }, diff --git a/tools/desk/static/studio.css b/tools/desk/static/studio.css index d255fd00..866fd508 100644 --- a/tools/desk/static/studio.css +++ b/tools/desk/static/studio.css @@ -217,6 +217,8 @@ html.shell-other .topbar{padding-right:calc(14px + 100vw - env(titlebar-area-x, .col-body .c-mine .blk-h .tag{margin-left:auto;color:var(--wait)} .col-body .ho-batch{margin-top:8px} .col-body .note-list em.gone{font-style:normal;color:var(--wait);margin-left:4px} +.col-body .note-list em.moved{font-style:normal;color:var(--ink-3);margin-left:4px} +.module .page-sum{display:-webkit-box;-webkit-line-clamp:2;-webkit-box-orient:vertical;overflow:hidden} /* the stop's summary above the tabs: two lines at most, whole below */ .col-body .ho-st.left i{background:var(--you)} .col-body .ho-acts{display:flex;gap:8px;margin:4px 0 0 14px} .col-body .ho-st{margin:0;display:flex;gap:8px;align-items:baseline;font-size:var(--fs-small);color:var(--ink-hi)} diff --git a/tools/desk/static/studio.js b/tools/desk/static/studio.js index 89b1e9af..583e3eb9 100644 --- a/tools/desk/static/studio.js +++ b/tools/desk/static/studio.js @@ -85,7 +85,8 @@ async function route() { if (r.view === "settings") return SETTINGS.show(r.sec); return showProject(r); } -window.addEventListener("hashchange", route); +let CHOSE = false, PAGEGO = false; // the module on screen is one the person went to (a link, the rail, Back), not one the page or bin/vh gate picked +window.addEventListener("hashchange", () => { CHOSE = !PAGEGO; PAGEGO = false; route(); }); /* ---------- the shell: crumbs, the flow bar, the rail ---------- */ function crumbs(parts) { @@ -342,6 +343,7 @@ function applyProject(key, x) { KEY = `desk:${PKEY}:${ROUND.id}`; // the draft goes with the folder (its key), never with a folder of the same name FB = store.get(KEY) || { decisions: {}, items: {}, general: "" }; FB.items = FB.items || {}; FB.decisions = FB.decisions || {}; + if (D) reconcile(); // what the notes were written on, against the files as they are now setLang(pickLang(D.lang)); GV = x.gv; } @@ -363,12 +365,13 @@ async function reloadProject(follow) { // the same film read again (a submissi const r = follow ? { view: "project", key } : Object.assign(parse(), { key }); // follow: a new page opens on its own stop's module const pl = placeOf(r); MOD = pl.mod; SUB = pl.sub; DOC = r.doc || DOC; GATE = r.gate || ""; - keepAddress(r); + keepAddress(r, follow); crumbs([{ text: t("m_space"), href: "#/" }, { text: D.project.title }]); renderFlow(); renderRail(); renderColumn(); renderModule(); updateComposer(); liveTimer = setInterval(pollLive, 4000); if (at != null && CUT) CUT.seekTo(at); // the playhead where it was - $("#stage").scrollTop = s; window.scrollTo(0, y); + try { await GATELOAD; } catch (e) { /* the page part says its own error */ } // the stop's page in place first: the page has its height + if (!follow) { $("#stage").scrollTop = s; window.scrollTo(0, y); } // (a page followed to opens at its top) } function waitingGate() { // this round's page, when its stop waits for the person if (!D.current) return null; @@ -390,11 +393,13 @@ function placeOf(r) { // {mod, sub} the page shows: the address's, else a page const g = waitingGate(); return { mod: defaultMod(), sub: g ? stopSub(g) : "" }; } -function keepAddress(r) { // the address names what is on screen: a module the page picked itself is written into it (no new history entry), - // so a click on that module in the rail is no change of address, and a reload stays on this page +function keepAddress(r, moved) { // the address names what is on screen: a module the page picked itself is written into it, so a click on that module in + // the rail is no change of address and a reload stays on this page. moved: the page took the person somewhere (a new page): a history entry + // of its own, so Back returns; else the entry is the one they opened if (r.mod || (r.gate && D && r.gate !== D.current)) return; // (an earlier page asked for by name keeps its own address) const h = projHash(PKEY, MOD + (SUB ? "/" + SUB : "")); - if (location.hash !== h) history.replaceState(null, "", h); + if (location.hash !== h) history[moved ? "pushState" : "replaceState"](null, "", h); + if (moved) CHOSE = false; } function defaultMod() { const g = waitingGate(); @@ -563,11 +568,79 @@ function renderMarks() { // the round's places in the film: on the round's own const COLOPEN = { least: false, listen: false }; function goneNow(k) { // a draft's place no longer in the files (the agent rewrote the outline or the script since it was written) if (!D) return false; + const v = FB.items[k]; + if (v && v.drift) return v.drift === "gone"; const [kind, id] = [k.split(":")[0], k.split(":").slice(1).join(":")]; if (kind === "seg") return Array.isArray(D.outline) && D.outline.length > 0 && !D.outline.some((o) => String(o.id) === id); if (kind === "cap") { const rows = (D.captions && D.captions.rows) || []; return rows.length > 0 && !rows.some((c) => String(c.id) === id); } return false; } +/* a note carries what it was written on: an outline part's title and words, a script line's words, a shot's id and words. Ids are + places (an outline part is its row's number), so after the files change a note follows its content to where it went, and a + place whose content changed is never taken for the note's own */ +const ANCHORED = /^(seg|cap|shot):/; +function placeRows(kind) { + if (!D) return []; + if (kind === "seg") return (Array.isArray(D.outline) ? D.outline : []).map((o) => ({ id: String(o.id), title: String(o.title || ""), sig: `${o.title || ""}\n${o.know || ""}`, t0: o.t0, t1: o.t1 })); + if (kind === "cap") return ((D.captions && D.captions.rows) || []).map((c) => ({ id: String(c.id), title: cut(String(c.text || ""), 24), sig: String(c.text || ""), t0: c.t0, t1: c.t1 })); + if (kind === "shot") return ((D.shots && D.shots.items) || []).map((s) => ({ id: String(s.id), title: String(s.label || s.caption || ""), sig: `${s.label || ""}\n${s.caption || ""}`, t0: s.start, t1: s.end })); + return []; +} +function anchorOf(k) { // what this place says now: {title, sig}, or null when the place is not in the files + const kind = k.split(":")[0], id = k.slice(kind.length + 1), r = placeRows(kind).find((x) => x.id === id); + return r ? { title: r.title, sig: r.sig } : null; +} +function anchorNotes() { // a note kept without its anchor yet gets the one its place has now (save() runs as it is kept) + let n = 0; + for (const [k, v] of Object.entries(FB.items)) if (v && v.status && !v.at && !v.drift && ANCHORED.test(k)) { const a = anchorOf(k); if (a) { v.at = a; n++; } } + return n; +} +function relabel(kind, id, v) { // the note's label at its new place: the part's number changes, the words it was written on stay + if (kind === "seg") return t("l_seg", { i: id, x: v.at.title }); + const old = String(v.label || ""), from = String(v.from || ""); // (the id as a word of its own: "字幕 c03" → "字幕 c05") + if (!from) return old; + const re = new RegExp("(^|\\s)" + from.replace(/[.*+?^$()|[\]\\{}]/g, "\\$&") + "(?=\\s|$)"); + return old.replace(re, "$1" + id); +} +function changedWords(v) { // a note whose place changed: what it was written on, unless its label already names it ("大纲 第 4 段 月亮") + const x = String((v.at && v.at.title) || ""); + return x && !String(v.label || "").includes(x) ? t("ho_changed", { x: cut(x, 24) }) : t("ho_changed_here"); +} +function reconcile() { // after the files changed: each anchored note stays, follows its content, or says its place changed or went + if (!D || !FB) return; + let changed = false; + const rows = {}, R = (kind) => rows[kind] || (rows[kind] = placeRows(kind)); + const free = (key) => !(FB.items[key] && FB.items[key].status); + for (const v of Object.values(FB.items)) if (v && v.moved) { delete v.moved; changed = true; } // (a move is said once: from the reload that found it to the next) + // 1. a note whose place says something else now steps off it: the place is free for whatever the files put there + for (const [k, v] of Object.entries(Object.assign({}, FB.items))) { + if (!v || !v.at || v.was || !ANCHORED.test(k)) continue; + const kind = k.split(":")[0], id = k.slice(kind.length + 1), now = R(kind).find((x) => x.id === id); + if (now && now.sig === v.at.sig) continue; // the same content at the same place + let nk = `${k}~was`, n = 2; + while (FB.items[nk]) nk = `${k}~was${n++}`; + FB.items[nk] = Object.assign({}, v, { was: id }); delete FB.items[k]; changed = true; + } + // 2. each note off its place: back to it, to where its content went (and it says so), or said changed or gone, never on what took its place + for (const [k, v] of Object.entries(Object.assign({}, FB.items))) { + if (!v || !v.at || !v.was) continue; + const kind = k.split(":")[0], id = v.was; + const to = R(kind).find((x) => x.id === id && x.sig === v.at.sig && free(`${kind}:${x.id}`)) || R(kind).find((x) => x.sig === v.at.sig && free(`${kind}:${x.id}`)); + if (to) { + const nk = `${kind}:${to.id}`, n2 = Object.assign({}, v); + delete n2.drift; delete n2.was; + if (to.id !== id) { // its label and time are the new place's; the line says once where it was + Object.assign(n2, { from: id, moved: to.id, label: relabel(kind, to.id, Object.assign({}, v, { from: id })) }); + if (v.t != null && to.t0 != null) n2.t = +to.t0; + if (v.t1 != null && to.t1 != null) n2.t1 = +to.t1; + } + FB.items[nk] = n2; delete FB.items[k]; changed = true; continue; + } + const d = R(kind).some((x) => x.id === id) ? "changed" : "gone"; + if (v.drift !== d) { v.drift = d; changed = true; } + } + if (changed) store.set(KEY, FB); +} function notesCount() { // the notes the person sees listed, the bar's count and the block's alike: each whole-film note its own (generalParts) return myItems().length + generalParts().length; } @@ -583,7 +656,8 @@ function setGeneral(L) { FB.generalItems = L; FB.general = joinGeneral(L); } function renderMine() { const items = myItems().sort((a, b) => (a[1].t != null ? a[1].t : 1e9) - (b[1].t != null ? b[1].t : 1e9)); const st = { ok: t("st_ok"), change: t("st_change"), ask: t("st_ask") }; - const row = ([k, v]) => `
  • ${v.t != null ? esc(fmt(v.t) + (v.t1 != null ? "–" + fmt(v.t1) : "")) : ""}${esc(cut(v.label || k, 40))}${goneNow(k) ? `${esc(t("ho_gone"))}` : ""} ${esc(v.text || st[v.status] || "")}
  • `; + const row = ([k, v]) => v.drift ? `
  • ${esc(cut(v.label || k, 40))}${esc(v.drift === "changed" ? changedWords(v) : t("ho_gone"))} ${esc(v.text || st[v.status] || "")}
  • ` + : `
  • ${v.t != null ? esc(fmt(v.t) + (v.t1 != null ? "–" + fmt(v.t1) : "")) : ""}${esc(cut(v.label || k, 40))}${goneNow(k) ? `${esc(t("ho_gone"))}` : v.moved ? `${esc(t(k.startsWith("seg:") ? "ho_moved_seg" : "ho_moved", { i: v.from }))}` : ""} ${esc(v.text || st[v.status] || "")}
  • `; const gen = generalParts().map((g, i) => `
  • ·${esc(g.label || t("c_whole_note"))} ${esc(g.text)}
  • `).join(""); const none = !items.length && !gen; // none yet: the heading and how to start, on one line const n = notesCount(), subs = D ? (D.feedback || []) : []; @@ -772,7 +846,7 @@ function payload() { const ts = toSend(ROUND.data.decisions, FB.decisions, FB.sentDec, roundOpen()); if (D && roundTaken()) { ts.defaulted.forEach((k) => delete ts.decisions[k]); ts.defaulted = []; } // a later batch: only what the person picked, never the recommendations again const { decisions, defaulted } = ts; - const all = myItems().map(([k, v]) => Object.assign({ target: k, status: v.status, label: fitLabel(v.label || k), text: v.text || "" }, + const all = myItems().map(([k, v]) => Object.assign({ target: k, status: v.status, label: fitLabel((v.label || k) + (v.drift === "changed" ? changedWords(v) : v.drift === "gone" ? t("ho_gone") : "")), text: v.text || "" }, v.suggest && v.suggest !== v.orig ? { suggest: v.suggest } : {}, v.orig && k.startsWith("cap:") ? { orig: v.orig } : {}, v.t != null ? { t: v.t } : {}, v.t1 != null ? { t1: v.t1 } : {})); // an item feedback.py would refuse costs only itself, said before sending, never the round (its limits: tools/desk/feedback.py) const fits = (i) => targetOk(i.target) && cps(i.text).length <= 4000 && cps(i.suggest || "").length <= 2000 && cps(i.orig || "").length <= 2000; @@ -865,6 +939,7 @@ async function submit() { $("#confirm details").open = true; } function save() { + if (D) anchorNotes(); // (a note just kept takes what its place says now) store.set(KEY, FB); AGENT.tabs(); if (!D) return; renderMine(); renderRound(); @@ -872,9 +947,15 @@ function save() { $$("#stage [data-mark]").forEach(markHost); } let LIVE = false; // a wait alive on the round that is out now (the status poll): it picks a submission up within the second +let LASTKEY = 0, COMPOSING = false; // the last keystroke or text input anywhere, and an input method composing now +for (const ev of ["keydown", "input"]) document.addEventListener(ev, () => { LASTKEY = Date.now(); }, true); +document.addEventListener("compositionstart", () => { COMPOSING = true; LASTKEY = Date.now(); }, true); +document.addEventListener("compositionend", () => { COMPOSING = false; LASTKEY = Date.now(); }, true); +const TYPING_IDLE = 30000; // ms: a text box focused with no keystroke and no composition this long is not being typed in (a pause between two sentences is shorter) function busyHere() { // the person is in the middle of something a reload would cut short: typing, the sheet open, the film playing const a = document.activeElement, v = $("#stage video"); - return !!(a && (/^(TEXTAREA|INPUT|SELECT)$/.test(a.tagName) || a.isContentEditable)) || !$("#confirm").hidden || !!(v && !v.paused); + const texty = !!a && (a.tagName === "TEXTAREA" || a.isContentEditable || (a.tagName === "INPUT" && /^(text|search|url|email|tel|number|password)?$/i.test(a.getAttribute("type") || ""))); + return (texty && (COMPOSING || Date.now() - LASTKEY < TYPING_IDLE)) || !$("#confirm").hidden || !!(v && !v.paused); } async function pollLive() { if (!PKEY || RELOADING) return; @@ -895,8 +976,15 @@ async function pollLive() { if (D && D.status && (mine || !r.ok) && JSON.stringify([got, mine ? r.data.plan : D.status.plan]) !== JSON.stringify([D.status.now, D.status.plan])) { D.status.now = got; if (mine) D.status.plan = r.data.plan; renderNow(); // where it stands moved (a render's frames, the notes picked up) } - if (r.ok && r.data && D && r.data.round !== undefined && r.data.round !== (D.current || null) && r.data.key === PKEY) { // the agent sent a new page - toast(t("new_round", { g: r.data.round || "" })); + if (r.ok && r.data && D && r.data.round !== undefined && r.data.round !== (D.current || null) && r.data.key === PKEY) { // the agent sent a new page (a readable one: the server's round is) + if (busyHere()) return; // (not mid-typing, not with the sheet open: the next poll follows) + const nr = r.data.round; + if (CHOSE && nr) { // the person went where they are by their own choice: stay there and say so; the line at the top of the column has the way to the page + await reloadProject(false); + if (MOD !== stopMod(nr)) toast(t("ho_newpage", { s: stepName(nr) })); + return; + } + if (nr) toast(t("ho_newpage", { s: stepName(nr) })); await reloadProject(true); } else if (r.ok && r.data && D && r.data.key === PKEY && r.data.revision_stamp !== D.revision_stamp && !$(".revision-compare[open]")) { await reloadProject(false); @@ -907,7 +995,9 @@ async function pollLive() { function moduleHead(kick, title, sub) { return `
    ${esc(kick)}${title ? `

    ${esc(title)}

    ` : ""}${sub ? `

    ${esc(sub)}

    ` : ""}
    `; } +let GATELOAD = null; // the stop's page part loading into the module (reloadProject waits for it before it puts the scroll back) function renderModule() { + GATELOAD = null; if (PARTCTL) { PARTCTL.destroy(); PARTCTL = null; if (COLCTL && COLCTL.own) COLCTL.own(); } const bench = MOD === "cut" && !(GATE && GATE !== D.current); // the cut's workbench; an earlier page of its stop is shown as a page if (CUT && !bench) { CUT.destroy(); CUT = null; } @@ -922,7 +1012,7 @@ function renderModule() { if (page0) { // the rest of the stop's page: after the module, above its bar const bar = $(".mbar", area), gp = '
    '; if (bar) bar.insertAdjacentHTML("beforebegin", gp); else $(".m2", area).insertAdjacentHTML("beforeend", gp); - loadGatePart(page0, V); + GATELOAD = loadGatePart(page0, V); } else { const link = pastPageLink(MOD); if (link) $(".mh2", area).insertAdjacentHTML("beforeend", link); } $$("[data-mark]", area).forEach(markHost); if (V.wire) V.wire(); @@ -936,8 +1026,8 @@ function renderModule() { // the stop's page: its one-line summary above the tabs, the rest (decided, delegated, appendices, not looked at) after the tab's // content, so a tab clicked opens where the tabs are and what is reviewed stays at the top const page = stopPage(MOD), pr = page && (D.rounds || []).find((x) => x.id === page), sum = pr && pr.data && pr.data.summary; - area.innerHTML = `
    ${moduleHead(kickOf(MOD), "", "")}${sum ? `

    ${esc(sum)}

    ` : ""}${subtabs(MOD)}
    ${fn()}
    ${page ? '
    ' : ""}
    `; - if (page) loadGatePart(page, {}); + area.innerHTML = `
    ${moduleHead(kickOf(MOD), "", "")}${sum ? `

    ${esc(sum)}

    ` : ""}${subtabs(MOD)}
    ${fn()}
    ${page ? '
    ' : ""}
    `; + if (page) GATELOAD = loadGatePart(page, { drawn: (root) => { if (sum && sum.length > 120) root.insertAdjacentHTML("afterbegin", `

    ${esc(sum)}

    `); } }); // (a long summary, clamped above the tabs, whole here) else { const link = pastPageLink(MOD); if (link) $(".mh", area).insertAdjacentHTML("beforeend", link); } $$("[data-mark]", area).forEach(markHost); ({ outline: cur === "script" ? wireScript : wireOutline, board: wireBoard, sound: wireSound }[MOD] || (() => {}))(); @@ -981,7 +1071,7 @@ async function loadGatePart(gid, V) { // V: the module draws the page's pictur /* ✓ / ✎ / ? on an item (the desk's views, moved into the modules) */ function fbCtl(target, label, opt = {}) { - const v = FB.items[target] || {}, st = v.status || ""; + const v0 = FB.items[target] || {}, v = v0.drift ? {} : v0, st = v.status || ""; // (a note whose place changed is not drawn on what took it) const lab = opt.labels || [t("fb_ok"), t("fb_change"), t("fb_ask")]; return `
    @@ -1013,7 +1103,8 @@ function refreshFb(box) { const host = nb.closest("[data-mark]"); if (host) markHost(host); const ta = nb.querySelector("textarea"); if (ta && !nb.querySelector(".fb-more").hidden) ta.focus(); } -function markHost(host) { const st = (FB.items[host.dataset.mark] || {}).status; host.classList.toggle("marked", !!st); host.classList.toggle("st-ok", st === "ok"); host.classList.toggle("st-ask", st === "ask"); } +// (a note whose place changed is not this place's: not drawn on it) +function markHost(host) { const v = FB.items[host.dataset.mark] || {}, st = v.drift ? "" : v.status; host.classList.toggle("marked", !!st); host.classList.toggle("st-ok", st === "ok"); host.classList.toggle("st-ask", st === "ask"); } function fallback(note, file, onlySection) { const doc = docOf(file); if (!doc) return ""; @@ -1960,7 +2051,7 @@ async function claimCode() { function presence() { if (PRES || !TOKEN) return; PRES = new EventSource(`/api/presence?token=${encodeURIComponent(TOKEN)}&w=${encodeURIComponent(WIN)}`); - PRES.onmessage = (e) => { let d = {}; try { d = JSON.parse(e.data); } catch (x) { return; } if (typeof d.go === "string" && d.go.startsWith("/")) location.hash = d.go; }; + PRES.onmessage = (e) => { let d = {}; try { d = JSON.parse(e.data); } catch (x) { return; } if (typeof d.go === "string" && d.go.startsWith("/")) { PAGEGO = location.hash !== "#" + d.go; location.hash = d.go; } }; // (Studio sent to a stop: not the person's own move) PRES.onerror = () => { if (PRES && PRES.readyState === 2) { PRES = null; } }; // refused (no access any more): checkKey sees why } async function checkKey() { diff --git a/tools/desk/test_page.py b/tools/desk/test_page.py index c268dddd..cca8f592 100644 --- a/tools/desk/test_page.py +++ b/tools/desk/test_page.py @@ -100,11 +100,53 @@ def v(res, name): (reopen / "out" / "review" / "gate-1b.json").write_text(json.dumps(OUTLINE_AGAIN, ensure_ascii=False), encoding="utf-8") subprocess.run(["bash", str(VH), "review", str(reopen), "1b"], capture_output=True, text=True, env=ENV, timeout=60, check=True) script = film("script", E1) # the script's stop -follow = film("follow", E1) # open on the script; the agent sends the outline again meanwhile -files = film("files", E1) # open on the outline; the agent cuts it from 3 parts to 2 meanwhile -brief = (files / "BRIEF.md").read_text(encoding="utf-8") -two = re.sub(r"\n\| 3 \|[^\n]*", "", brief.replace("| 2 | 两个鼓包 | 9–21 s |", "| 2 | 两面都鼓 | 9–32 s |")) +follow = film("follow", E1) # opened by Studio on the script; the agent sends the outline again meanwhile: the page follows (Back returns) +stay = film("stay", E1) # the person went to 决定 themself; the agent sends the outline again: the page stays and says so +half = film("half", E1) # a page written halfway (not JSON yet): no new round, no reload, until it reads +scroll = film("scroll", E1) # scrolled down the script; an unrelated NOTES.md change: the page reads again and stays where it was +(scroll / "SCRIPT.md").write_text("# SCRIPT\n\n## 旁白\n\n| # | 时间 | 旁白 |\n|---|---|---|\n" + + "".join(f"| c{i:02d} | {i * 1.3:.1f}–{i * 1.3 + 1.2:.1f} s | 第 {i} 句旁白,讲海水和月亮。 |\n" for i in range(1, 25)), encoding="utf-8") +LONG = "这一页要定旁白稿能不能往下做。" + "每一句都对着画面再读一遍,看读不读得完," * 12 +longp = film("longsum", dict(E1, summary=LONG)) # a 400-character summary: two lines above the tabs, whole below tabs = film("tabs", E1) # the stop's page on the outline module: a tab clicked opens where the tabs are +# an outline of nine parts rewritten to five: removed in the middle, two in another order, one renamed, one's words rewritten +NINE = [("开场", "一天涨两次"), ("两个鼓包", "两面都鼓起来"), ("转一圈", "地球转一圈经过两次"), ("月亮", "月亮拉着近的一面"), ("太阳", "太阳也拉一点"), + ("大潮", "日月同向时最高"), ("小潮", "日月垂直时最低"), ("海岸", "海湾把潮差放大"), ("收尾", "回到刻度桩")] +FIVE = [("开场", "一天涨两次"), ("转一圈", "地球转一圈经过两次"), ("月亮的拉力", "月亮拉着近的一面"), ("收尾", "回到刻度桩"), ("太阳", "太阳的拉力只有月亮的一半")] + + +def outline(rows): + head = "| # | 段落 | 时间 | 观众看完知道 / 感到 | 关键画面 |\n|---|---|---|---|---|\n" + return head + "".join(f"| {i + 1} | {t} | {i * 4}–{i * 4 + 4} s | {k} | 画面{i + 1} |\n" for i, (t, k) in enumerate(rows)) + + +nine = film("nine", E1) +nb = (nine / "BRIEF.md").read_text(encoding="utf-8") +top, rest = nb.split("## Outline", 1) +tail = rest[rest.index("\n## ", 1):] if "\n## " in rest[1:] else "" +(nine / "BRIEF.md").write_text(top + "## Outline\n\n" + outline(NINE) + tail, encoding="utf-8") +five = top + "## Outline\n\n" + outline(FIVE) + tail +stamp = film("stamp", E1) # the stamp is taken before the read: a file written during the read leaves the page one reload behind + + +def stamp_before_read(): # (no browser: the server's own function, a write injected into its read) + import reader + real = reader.read_project + + def writing(project, *a, **k): + out = real(project, *a, **k) + with open(Path(project) / "BRIEF.md", "a", encoding="utf-8") as f: + f.write("\n\n") + return out + reader.read_project = writing + try: + d = server.project_data(stamp, ()) + finally: + reader.read_project = real + return d["files_stamp"] != server.files_stamp(stamp) + + +STAMP_OK = stamp_before_read() proc = subprocess.Popen([sys.executable, str(HERE / "fixtures" / "with_tty.py"), "bash", str(VH), "desk", "--root", str(T / "root"), "--port", "0", "--no-open", "--print-address"], stdout=subprocess.PIPE, stderr=subprocess.STDOUT, text=True, env=ENV, start_new_session=True) @@ -174,31 +216,71 @@ def v(res, name): steps += [{"click": "#lang", "after": 1500}] WHERE = "JSON.stringify({ mod: ($('#stage [data-mod]') || {}).dataset && $('#stage [data-mod]').dataset.mod, hash: decodeURIComponent(location.hash), " \ "tab: (($('nav.subtabs [aria-selected=true]') || { getAttribute: () => '' }).getAttribute('href')) || '', cards: !!$('.c-cards') })" + + def opened(f, ms=12000): # the film read and drawn, nothing reloading: a condition, never a fixed wait + return {"until": f"typeof D !== 'undefined' && D && PKEY === {key(f)!r} && !RELOADING && !!$('#stage [data-mod]')", "name": f"open {f.name}", "ms": ms} + + def page(f, rid, d): # the agent sends a page: its JSON, its HTML (bin/vh gate writes both), then it is this round + return [{"write": str(f / "out" / "review" / f"gate-{rid}.json"), "text": json.dumps(d, ensure_ascii=False)}, + {"write": str(f / "out" / "review" / f"gate-{rid}.html"), "text": "page"}, + {"write": str(f / "out" / "review" / ".current"), "text": f"{rid}\n"}] + COUNT = "(window.__reloads = 0, (() => { const o = reloadProject; reloadProject = async (...a) => { window.__reloads++; return o(...a); }; })(), true)" steps += [ # bin/vh gate opens a stop at #/p//gate/: the outline's second page on the outline, its question in the column - {"go": f"#/p/{key(reopen)}/gate/1b", "after": 3000}, tab, {"eval": WHERE, "name": "reopen_at"}, - {"go": f"#/p/{key(script)}/gate/E1", "after": 3000}, {"eval": WHERE, "name": "script_at"}, - # the agent sends another page while the person is on the script: the page follows, and the address names what is shown - {"go": f"#/p/{key(follow)}/outline/script", "after": 2500}, - {"write": str(follow / "out" / "review" / "gate-1b.json"), "text": json.dumps(OUTLINE_AGAIN, ensure_ascii=False)}, - {"write": str(follow / "out" / "review" / "gate-1b.html"), "text": "1b"}, # (bin/vh gate writes the page with it) - {"write": str(follow / "out" / "review" / ".current"), "text": "1b\n"}, - {"until": f"location.hash === '#/p/{key(follow)}/outline' && $('#stage [data-mod=outline]') && !$('nav.subtabs [aria-selected=true][href$=\"/script\"]')", "name": "follow_at", "ms": 15000}, - {"reload": True}, {"eval": WHERE, "name": "follow_reload"}, - # the agent rewrites the outline while it is open, a note kept on its third part: the page shows two parts, says the note's place is gone - {"go": f"#/p/{key(files)}/outline", "after": 2500}, tab, - {"eval": "document.querySelectorAll('#stage [data-mark^=\"seg:\"]').length", "name": "files_before"}, - {"eval": KEEP.format(t="seg:3", x="第三段太长", lb="大纲 第 3 段"), "name": "keep3"}, - {"eval": "(document.activeElement && document.activeElement.blur(), true)", "name": "blur"}, - {"write": str(files / "BRIEF.md"), "text": two}, - {"until": "document.querySelectorAll('#stage [data-mark^=\"seg:\"]').length === 2 && /两面都鼓/.test($('#stage').innerText)", "name": "files_after", "ms": 15000}, - {"eval": "JSON.stringify({ hash: decodeURIComponent(location.hash), gone: /不在了/.test($('#cMine').innerText) })", "name": "files_where"}, + {"go": f"#/p/{key(reopen)}/gate/1b", "after": 200}, opened(reopen), tab, {"eval": WHERE, "name": "reopen_at"}, + {"go": f"#/p/{key(script)}/gate/E1", "after": 200}, opened(script), {"eval": WHERE, "name": "script_at"}, + # opened by Studio itself (not the person's choice), a new page: the page follows it, the address names it, Back returns + {"go": f"#/p/{key(follow)}/outline/script", "after": 200}, opened(follow), {"eval": "(CHOSE = false, window.__h = history.length, true)", "name": "as studio"}, + *page(follow, "1b", OUTLINE_AGAIN), + {"until": f"location.hash === '#/p/{key(follow)}/outline' && D.current === '1b' && !RELOADING && !!$('#stage [data-mod=outline]')", "name": "follow_at", "ms": 15000}, + {"eval": "JSON.stringify({ grew: history.length - window.__h })", "name": "follow_history"}, + {"reload": True}, opened(follow), {"eval": WHERE, "name": "follow_reload"}, + {"eval": "(history.back(), true)", "name": "back"}, + {"until": f"location.hash === '#/p/{key(follow)}/outline/script'", "name": "follow_back", "ms": 8000}, + # the person went to 决定 themself: a new page leaves them there, says it is out + {"go": f"#/p/{key(stay)}/ledger", "after": 200}, opened(stay), *page(stay, "1b", OUTLINE_AGAIN), + {"until": "D.current === '1b' && !RELOADING", "name": "stay_round", "ms": 15000}, + {"eval": "JSON.stringify({ mod: MOD, hash: decodeURIComponent(location.hash), toast: $('#toast').innerText, now: ($('#colNow') || {}).innerText || '' })", "name": "stay_at"}, + # a page half-written: no new round, no reload for 10 s; once it reads, one follow + {"go": f"#/p/{key(half)}/outline/script", "after": 200}, opened(half), {"eval": COUNT, "name": "count"}, + {"write": str(half / "out" / "review" / "gate-E2.json"), "text": '{"summary": "配乐安排", "decisions": ['}, + {"write": str(half / "out" / "review" / ".current"), "text": "E2\n"}, + {"wait": 10000}, {"eval": "JSON.stringify({ reloads: window.__reloads, current: D.current, mod: MOD, toast: $('#toast').innerText })", "name": "half_wait"}, + # scrolled down the script, an unrelated NOTES.md change: read again, the same place on the page + {"go": f"#/p/{key(scroll)}/outline/script", "after": 200}, opened(scroll), {"until": "$('#gatePart .gate') && $('#stage').scrollHeight > $('#stage').clientHeight + 450", "name": "scroll_ready", "ms": 8000}, + {"eval": "($('#stage').scrollTop = $('#stage').scrollHeight, window.__st = D.files_stamp, $('#stage').scrollTop)", "name": "scroll_before"}, # (the very bottom: the stop's page part is there) + {"write": str(scroll / "NOTES.md"), "text": (scroll / "NOTES.md").read_text(encoding="utf-8") + "\n- 又查到一条\n"}, + {"until": "D.files_stamp !== window.__st && !RELOADING", "name": "scroll_reloaded", "ms": 15000}, {"wait": 600}, + {"eval": "$('#stage').scrollTop", "name": "scroll_after"}, + # a radio button picked (focus stays on it) is no typing: the page still follows a change; a text box with a keystroke just now holds it + tab, {"eval": "(($('.c-cards input[type=radio]') || $('#say')).focus(), window.__st = D.files_stamp, true)", "name": "radio_focus"}, + {"write": str(scroll / "NOTES.md"), "text": (scroll / "NOTES.md").read_text(encoding="utf-8") + "\n- 又查到两条\n"}, + {"until": "D.files_stamp !== window.__st && !RELOADING", "name": "radio_followed", "ms": 15000}, + {"eval": "($('#say').focus(), document.dispatchEvent(new KeyboardEvent('keydown', { key: 'a' })), window.__st = D.files_stamp, true)", "name": "typing"}, + {"write": str(scroll / "NOTES.md"), "text": (scroll / "NOTES.md").read_text(encoding="utf-8") + "\n- 又查到三条\n"}, + {"wait": 6000}, {"eval": "D.files_stamp === window.__st", "name": "typing_held"}, + {"eval": "(LASTKEY = Date.now() - 31000, true)", "name": "typing_idle"}, + {"until": "D.files_stamp !== window.__st && !RELOADING", "name": "typing_released", "ms": 15000}, + # a 400-character summary: two lines above the tabs, whole below + {"go": f"#/p/{key(longp)}/outline/script", "after": 200}, opened(longp), {"until": "$('#gatePart .round-h')", "name": "long_part", "ms": 8000}, + {"eval": "JSON.stringify({ h: $('.page-sum').getBoundingClientRect().height, lh: parseFloat(getComputedStyle($('.page-sum')).lineHeight), " + "tabs: $('nav.subtabs').getBoundingClientRect().top, whole: ($('#gatePart').innerText || '').includes($('.page-sum').getAttribute('title')) })", "name": "long_view"}, # the stop's page on the outline: clicking the script tab leaves the tab row where it was, and the page's rest comes after - {"go": f"#/p/{key(tabs)}/outline", "after": 2500}, + {"go": f"#/p/{key(tabs)}/outline", "after": 200}, opened(tabs), {"eval": "$('nav.subtabs').getBoundingClientRect().top", "name": "tabs_before"}, - {"click": "nav.subtabs a[href$='/outline/script']", "after": 2000}, + {"click": "nav.subtabs a[href$='/outline/script']", "after": 200}, {"until": "$('nav.subtabs [aria-selected=true][href$=\"/script\"]') && $('#gatePart .gate')", "name": "tabs_ready", "ms": 8000}, {"eval": "JSON.stringify({ top: $('nav.subtabs').getBoundingClientRect().top, body: $('#modBody') && $('#modBody').getBoundingClientRect().top, " "rest: $('#gatePart') && $('#gatePart').getBoundingClientRect().top, script: !!$('nav.subtabs [aria-selected=true][href$=\"/script\"]') })", "name": "tabs_after"}, + # nine parts rewritten to five, notes kept on six of them: each stays, follows its content, or says its place changed or went + {"go": f"#/p/{key(nine)}/outline", "after": 200}, opened(nine), tab, + {"eval": "(" + ", ".join(KEEP.format(t=f"seg:{i}", x=f"第 {i} 段的意见", lb=f"大纲 第 {i} 段 {NINE[i - 1][0]}") for i in (1, 3, 4, 5, 7, 9)) + ")", "name": "nine_keep"}, + {"eval": "(FB.items['seg:9'].t = 32, FB.items['seg:3'].t = 8, save(), document.activeElement && document.activeElement.blur(), window.__st = D.files_stamp, true)", "name": "nine_blur"}, # (the times the row gives as a note is kept) + {"write": str(nine / "BRIEF.md"), "text": five}, + {"until": "D.files_stamp !== window.__st && !RELOADING && document.querySelectorAll('#stage [data-mark^=\"seg:\"]').length === 5", "name": "nine_reloaded", "ms": 15000}, + {"eval": "JSON.stringify({ items: Object.fromEntries(Object.entries(FB.items).map(([k, v]) => [k, { drift: v.drift || '', moved: v.moved || '', label: v.label, t: v.t }])), " + "marked: [...document.querySelectorAll('#stage [data-mark^=\"seg:\"].marked')].map((e) => e.dataset.mark), " + "block: $('#cMine').innerText, drift_goto: [...document.querySelectorAll('#cMine li.drift')].filter((e) => e.dataset.goto).length, " + "sent: payload().items.map((i) => [i.target, i.label]) })", "name": "nine_after"}, ] res = drive(url, steps) finally: # the desk this check started, and everything under it (bin/vh desk runs on in its own session): by process tree, never by name @@ -278,19 +360,53 @@ def js(name): return {"raw": v(res, name)} -ra, sa, fr = js("reopen_at"), js("script_at"), js("follow_reload") +ra, sa = js("reopen_at"), js("script_at") check("a stop opens on what it asks about: the outline sent again (no concept cards) on the outline with its question in the column, the script on the " "outline's script tab; the address then names that module", ra.get("mod") == "outline" and ra.get("hash", "").endswith("/outline") and ra.get("cards") and sa.get("mod") == "outline" and sa.get("hash", "").endswith("/outline/script") and sa.get("tab", "").endswith("/script"), [ra, sa]) -check("a page the agent sends while the person is elsewhere: the window follows to it, the address names what is shown, and a reload stays there", - (res.get("follow_at") or {}).get("ok") and fr.get("mod") == "outline" and fr.get("hash", "").endswith("/outline"), [res.get("follow_at"), fr]) -fa, fw = res.get("files_after") or {}, js("files_where") -check("the agent rewrites the outline while it is open: within seconds the page shows the new parts, stays where it was, and a note kept on a part that " - "is gone says so", v(res, "files_before") == 3 and fa.get("ok") and fw.get("hash", "").endswith("/outline") and fw.get("gone"), [v(res, "files_before"), fa, fw]) +fr, fh = js("follow_reload"), js("follow_history") +check("a new page while Studio's own opening is on screen: the page follows it, the address names it (a history entry of its own: Back returns), and a " + "reload stays there", (res.get("follow_at") or {}).get("ok") and fh.get("grew") == 1 and fr.get("mod") == "outline" and fr.get("hash", "").endswith("/outline") + and (res.get("follow_back") or {}).get("ok"), [res.get("follow_at"), fh, fr, res.get("follow_back")]) +sa2 = js("stay_at") +check("a new page while the person is where they went themself: the page stays there, says the page is out, and the line above the tabs has the way to it", + (res.get("stay_round") or {}).get("ok") and sa2.get("mod") == "ledger" and sa2.get("hash", "").endswith("/ledger") and "大纲那一页出来了" in sa2.get("toast", "") + and "去看大纲" in sa2.get("now", ""), [res.get("stay_round"), sa2]) +hw = js("half_wait") +check("a page half-written: no new round and no word of a new page; at most the one quiet read a file change brings; the page as it was", + hw.get("reloads", 9) <= 1 and hw.get("current") == "E1" and hw.get("mod") == "outline" and "那一页出来了" not in hw.get("toast", "") and "E2" not in hw.get("toast", ""), hw) +check("the stamp is taken before the film is read: a file written during the read leaves the page one reload behind, never stale for good", STAMP_OK, STAMP_OK) +sb, sa3 = v(res, "scroll_before"), v(res, "scroll_after") +check("an unrelated file change while scrolled to the bottom of the script (the stop's page part below it): the page reads again and stays where it was", + (res.get("scroll_reloaded") or {}).get("ok") and isinstance(sb, (int, float)) and sb >= 300 and isinstance(sa3, (int, float)) and abs(sa3 - sb) <= 2, [sb, sa3]) +check("busy is typing, not focus: a picked radio button does not hold the page back; a text box with a keystroke just now does, and lets go once idle 30 s", + (res.get("radio_followed") or {}).get("ok") and v(res, "typing_held") is True and (res.get("typing_released") or {}).get("ok"), + [res.get("radio_followed"), v(res, "typing_held"), res.get("typing_released")]) +lv = js("long_view") +check("a 400-character summary keeps to two lines above the tabs, and is there whole below", lv.get("h", 1e9) <= 2 * lv.get("lh", 0) + 2 and lv.get("tabs", 1e9) < 260 + and lv.get("whole"), lv) tb, ta = v(res, "tabs_before"), js("tabs_after") check("the script tab clicked on a stop's page: the tab row is not pushed down, the tab's content starts right under it, and the page's decided, " "delegated and appendices come after that content", isinstance(tb, (int, float)) and ta.get("script") and ta.get("top", 1e9) <= tb + 4 and ta.get("body") and ta["body"] - ta["top"] < 80 and ta.get("rest") and ta["rest"] > ta["body"], [tb, ta]) +na = js("nine_after") +it, sent = na.get("items") or {}, dict(tuple(x) for x in na.get("sent") or []) +was = {k.split("~")[0]: x for k, x in it.items() if "~was" in k} +ok = ((res.get("nine_reloaded") or {}).get("ok") + and "seg:1" in it and not it["seg:1"]["drift"] # the same content at the same place: stays + and it.get("seg:2", {}).get("moved") == "2" and "第 2 段 转一圈" in it["seg:2"]["label"] and it["seg:2"].get("t") == 4 # moved up from 3: goes with it, takes its time, says so + and it.get("seg:4", {}).get("moved") == "4" and "第 4 段 收尾" in it["seg:4"]["label"] and it["seg:4"].get("t") == 12 # moved up from 9 (a reorder) + and was.get("seg:4", {}).get("drift") == "changed" # renamed: never drawn on what took its place + and was.get("seg:5", {}).get("drift") == "changed" # its words rewritten at the same place: changed + and was.get("seg:7", {}).get("drift") == "gone" # removed + and "seg:3" not in na.get("marked", []) and "seg:5" not in na.get("marked", []) and set(na.get("marked", [])) == {"seg:1", "seg:2", "seg:4"} + and na.get("drift_goto") == 0 + and "原来是第 3 段" in na.get("block", "") and "原来是第 9 段" in na.get("block", "") and "0:32" not in na.get("block", "") and "第 4 段 月亮(这一处后来改了)" in na.get("block", "") and "第 5 段 太阳(这一处后来改了)" in na.get("block", "") + and "不在了" in na.get("block", "") + and any("月亮" in lb and "这一处后来改了" in lb for lb in sent.values())) +check("an outline of nine parts rewritten to five (one removed in the middle, two in another order, one renamed, one's words rewritten): a note on the " + "same part stays; one whose part moved goes with it, takes its number and time, and says once where it was; one whose part was renamed or rewritten is never drawn on what took its place, " + "quotes what it was written on, goes nowhere on a click, and is sent saying so; one on a removed part says it is gone", ok, na) print("end", flush=True)