diff --git a/changes/studio-window-follows-files.md b/changes/studio-window-follows-files.md new file mode 100644 index 00000000..2fa04ee0 --- /dev/null +++ b/changes/studio-window-follows-files.md @@ -0,0 +1,7 @@ +**Studio 的窗口跟着文件走:agent 改了大纲、文案,窗口自己换成新的一版;一站开在它要审的东西上** +- Why: 第一支真片子里,人对着已经不存在的 9 段大纲写意见,文案改到第四版窗口还是第一版,要按"显示 → 重新载入",重新载入又跳回别的页;六次开站有四次停错页(大纲复审停在立意,文案停在大纲页签);点下面的"字幕 / 旁白",内容却在上面展开,要审的旁白被挤到很下面。 +- agent 改了片子的文件(BRIEF、SCRIPT、NOTES、DECISIONS、REVIEW、镜头表、剪辑表、审阅页、旁白的时间),开着的 Studio 几秒内自己换成新的,停在原来的模块、页签和位置,说一句"文件改了,这里换成了新的一版";人正在打字(30 秒内敲过键)、交之前的那一页开着、片子在放时先不换,选了一个选项不算在打字。 +- 写了还没交的意见记着它写在什么上(大纲一段的名字和话、旁白的那一句、镜头的话)。agent 改了大纲:同样的那一段挪了位置,意见跟着走、换成新的段号和时间,说一次"原来是第 3 段";那一段改了名或改了话,意见不再画在占了原处的新段上,写明它写的时候对着什么、"这一处后来改了",交给 agent 时也这样写;删掉了,写明"这一处已经不在了"。 +- 一站开在它要问的东西上:立意定了以后再发的大纲(1b)、没有立意卡的关卡 ① 开在大纲上,要定的事在右栏;文案(E1)开在大纲的"字幕 / 旁白"页签上。 +- 窗口自己挑的模块写进地址:左边点同一个模块不再没反应,重新载入也停在原处。agent 发来新的一页:人自己走到别处的,留在那里,说一句"大纲那一页出来了",右栏顶上有去那一页的按钮;Studio 自己开着的,跟过去,后退能回来。写到一半、读不出来的审阅页不算新的一页,页面不再来回跳。 +- 关卡页的说明(已经定了的、替你定的、附录、没看没听的)放到页签内容的下面,页签上面只留摘要(最多两行,长的整句在下面):点哪个页签,要审的东西都在页签下面紧挨着。 diff --git a/tools/desk/README.md b/tools/desk/README.md index a266f935..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 改了片子的文件(文档、镜头表、剪辑表、审阅页、旁白的时间),开着的页面几秒内自己重读,停在原来的模块、页签和滚动位置(等这一站的页那一块排好了再回到原处),说一句"文件改了";人正在打字(写字的框里 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/<键>[/<模块>]`):打开在等人的那一站的模块(关卡 ① 立意,② 分镜,③ 成片);没人等时打开正在做的那一站,再没有就是成片。关卡不再是另一页:等人那一站的模块就是这一轮的关卡页,要你定的事在右栏。照原型排的模块自己画关卡页的画面(立意卡、镜头),关卡页里其余的东西(替你定的、附录、别的图)接在模块下面;成片模块把关卡页的画面放在它的时间线上。`#/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` | 有没有 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 自己的应用把控制台里"在新页打开"的链接都开在这里,所以开出来的窗口不会是空的 | @@ -515,7 +515,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..1eb4e7bc 100644 --- a/tools/desk/server.py +++ b/tools/desk/server.py @@ -660,12 +660,36 @@ 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, 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() + 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) 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 @@ -690,7 +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["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 {} @@ -1128,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) @@ -1136,10 +1159,11 @@ 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))) + 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 63c11b4d..5f912974 100644 --- a/tools/desk/static/core.js +++ b/tools/desk/static/core.js @@ -174,6 +174,9 @@ 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: "(这一处已经不在了)", + 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: "没有交成功,这几条还留在这里。", }, @@ -345,6 +348,9 @@ 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)", + 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 e27be336..866fd508 100644 --- a/tools/desk/static/studio.css +++ b/tools/desk/static/studio.css @@ -216,6 +216,9 @@ 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 .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 4e33cc73..583e3eb9 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("/") : "" }; @@ -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; } @@ -361,12 +363,15 @@ 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, 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; @@ -374,11 +379,33 @@ 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, 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[moved ? "pushState" : "replaceState"](null, "", h); + if (moved) CHOSE = false; +} 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 +414,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 +434,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) @@ -500,7 +529,7 @@ $("#colBody").addEventListener("click", async (e) => { // drafts of an earlier }); 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 })} ↓`; } @@ -529,7 +558,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("")}
    `; @@ -537,6 +566,81 @@ 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 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; } @@ -552,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))} ${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 || []) : []; @@ -659,7 +764,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; } @@ -741,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; @@ -834,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(); @@ -841,23 +947,44 @@ 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"); + 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; 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 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); @@ -868,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; } @@ -883,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(); @@ -894,17 +1023,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) 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] || (() => {}))(); 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 ""; @@ -918,7 +1049,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); @@ -940,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 `
    @@ -972,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 ""; @@ -1919,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 0afcdab6..cca8f592 100644 --- a/tools/desk/test_page.py +++ b/tools/desk/test_page.py @@ -94,6 +94,59 @@ def v(res, name): 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 +# 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) # 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) @@ -161,6 +214,74 @@ def v(res, name): 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}] + 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": 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": 200}, opened(tabs), + {"eval": "$('nav.subtabs').getBoundingClientRect().top", "name": "tabs_before"}, + {"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 rows = [x.split() for x in subprocess.run(["ps", "-A", "-o", "pid=,ppid="], capture_output=True, text=True).stdout.splitlines()] @@ -230,4 +351,62 @@ def seen(x): # inside the column's visible part, and inside the block's own 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) + + +def js(name): + try: + return json.loads(v(res, name)) + except (TypeError, ValueError): + return {"raw": v(res, name)} + + +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]) +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)