dsh-watch-together 0.0.7 → 0.1.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -3,6 +3,460 @@
3
3
  All notable changes to **dsh-watch-together** are documented here.
4
4
  This package starts its own version line at `0.0.7` — it is not a continuation of `dsh-video-storyboard`.
5
5
 
6
+ ## [0.1.0] - 2026-11-01
7
+
8
+ 首个发布版本。要求 `dsh-video-storyboard@^0.5.11`(字幕轨用到它的 `./transcript-pass` 子路径)。
9
+
10
+ ## [0.1.1] - 2026-11-01
11
+
12
+ **依赖升到 `dsh-video-storyboard@^0.6.0`。** 分镜从"固定宫格"改成"档位排布"——
13
+ 一格 = 一个镜头、格子大小跟切点密度走,`boardOptions()` 返回的参数从
14
+ `cells / sheets / minGap` 换成 `maxFrames / maxSheets / minFrames`。旧的参数名在 0.6.0 里已经不存在,
15
+ 所以这一版**必须**配 0.6.0 及以上,不能和 0.5.x 混装。
16
+
17
+ ### 台词写完之后不再递整段清单(防剧透)
18
+
19
+ 用户反馈"老是剧透后面的"。根因不是提示词不够狠:写台词时必须把整段 5 分钟的清单交出去,
20
+ 写完它仍然留在上下文里,模型就会把它当成"我知道后面"的凭据 —— 光说"不许提"压不住真实内容。
21
+ 现在台词一就绪就换成一句简报("台词已就绪,清单不再提供"),模型手里真的没有后面的信息。
22
+
23
+ 顺带在提示词里加了一句自问:「这句话是不是只有已经看过 xx 秒之后的人才写得出来?」
24
+ 不确定的事用"现在"而不是"接下来"。
25
+
26
+ ### Liquid glass, second pass — the window was still ugly (2026-11-01, later)
27
+
28
+ Verbatim feedback: "看一下 watch-together 的悬浮窗设计,太丑了现在" — the first liquid-glass pass
29
+ had the vocabulary right and the physics wrong. Five defects, all of them visible in a screenshot:
30
+
31
+ **The corners were not round.** `round_rect` and `squircle_mask` both used a superellipse with
32
+ `n = 5`, and at `n = 5` the curve is within 0.6% of the straight edge until the last few pixels —
33
+ a 22px radius rendered as a near-square corner with a tiny fillet. `squircle_mask` had a second,
34
+ independent bug: the row-solve was inverted (`x` grew from 0 instead of `r`), which cut the corners
35
+ out as *squares*. Both now use `n ≈ 2.2` and solve each row's span directly (O(h) instead of O(w·h),
36
+ and it buys 2× supersampling for free).
37
+
38
+ **The chrome was opaque.** The header was a `tk.Frame` and the composer a second one; Tk widgets
39
+ must have an opaque background, so the top and bottom strips of a "glass" window were dead black.
40
+ Both are now drawn on the canvas (status dot, title, count, `▾`/`✕` as hit-tested canvas items,
41
+ the input well as a rounded polygon). Only the `Entry` stays a real widget — it has to be opaque, so
42
+ it lives inside a deliberate *inset* well.
43
+
44
+ **Bubbles were paper.** Each one was filled with a flat `#3a4459`. They are now cut from the same
45
+ blurred backdrop as the panel (`plate()`), with only a white/blue wash on top — they transmit what
46
+ is behind them.
47
+
48
+ **Tint was global and blue.** One tint for the whole window, and a blue-grey `#171a21`, which fights
49
+ every colourful frame it sits on. Tint is now per-plate and *neutral*: measure that plate's mean
50
+ luminance and solve for "how opaque does the ink need to be to land under 84" (`a = (L-84)/(L-12)`).
51
+ Over a white page it darkens itself; over a dark scene it stays transparent.
52
+
53
+ **The sheen was made of lines.** Diagonals stacked with a 3px step left a visible weave across the
54
+ panel. Every gradient is now computed on a 16×16 canvas and upscaled bicubically.
55
+
56
+ Also added: **dispersion** (warm outside, cool inside, full strength around the whole chamfer and
57
+ stronger at the four corners, because a fillet has curvature everywhere but compound curvature at
58
+ the corners), **edge fading** in the message list (rows fade in/out across a 30px band instead of
59
+ popping at the clip boundary — suppressed on the side that has no more content, otherwise the newest
60
+ message is permanently the faintest), a **200ms entrance** per new bubble (8 frames: 10px rise +
61
+ alpha ramp + text colour lerp), and **smooth scrolling** (5 frames × 16ms) so the fade band has
62
+ something to fade across. The scrollbar moved out into the margin beside the panel.
63
+
64
+ Two long-standing bugs fell out of this: `Meta.paint` ended with a leftover `self.cv.tag_lower("bg")`
65
+ from the pre-canvas version — `Meta` has no `cv`, so the exception aborted `_reflow` mid-list and only
66
+ the newest message was ever visible; and the backdrop image was created after the messages without
67
+ `tag_lower`, so any repaint buried them.
68
+
69
+ ### Performance — the glass was re-baked on every frame (2026-11-01, same session)
70
+
71
+ "背景的模糊还是很卡" — measured, not guessed. One panel plate cost **520ms**, a slab 90ms,
72
+ a bubble 28ms. The culprit was `_ring`: it built **two full-size fill masks and subtracted them**,
73
+ and every plate needs five or six rings (rim, soft rim, bottom shade, warm, cool, edge weight), so
74
+ a 665×594 panel spent ~100ms in that one function plus ~15ms per `squircle_mask`.
75
+
76
+ Three fixes, in order of payoff:
77
+
78
+ - **Ring solved per row, no intermediate images.** A ring's row is just two short segments — left
79
+ and right — so the inner and outer x are solved directly (`_ring`), and middle rows are skipped
80
+ entirely. O(h) instead of O(w·h), and no subtraction allocations. 100ms → 3.7ms.
81
+ - **Everything smooth is computed at ¼ scale.** `_corner_weight`, `_edge_weight` and `refract`'s
82
+ bevel weight are soft blobs, not features: build them at 665/4 and upscale bilinearly. Gaussian
83
+ blur cost drops 16×, and the bevel mask (14 rectangle outlines over the full image) went from
84
+ ~20ms to ~1ms.
85
+ - **Supersampled masks now downsample with `Image.BOX`** instead of LANCZOS. For an exact 2×
86
+ reduction BOX *is* the 2×2 average — same result, ~4× faster. `squircle_mask` 15ms → 4.9ms.
87
+
88
+ Result: panel 520 → **50ms**, slab 90 → **6.8ms**, bubble 28 → **8ms**; `_paint` with a warm cache
89
+ **1.3ms**, `_reflow` **0.5ms**, cold repaint (backdrop changed) **76ms**, window open **387ms**.
90
+
91
+ Also: the R/B channel-scaled displacement (`chroma_edge`) is now **off by default**
92
+ (`DSH_WATCH_CHROMA_EDGE=1` turns it back on). It cost two full-size channel resizes per plate
93
+ (+18ms) and was invisible — the backdrop is already blurred and inked, so there is no contrast left
94
+ at the rim to disperse. The visible dispersion is the warm-outside/cool-inside tint pair, which stays.
95
+
96
+ Finally, resizing no longer re-bakes: while the resize grip is held the panel is a bilinear scale of
97
+ the last baked plate (1.2ms instead of 50ms), and a precise re-bake happens 300ms after release.
98
+
99
+ ### Performance, second pass — the backdrop was recomputed on every mouse release (2026-11-01)
100
+
101
+ "超级卡,绝对不止一两百毫秒" … "拖动根本不会刷新" … "碰到屏幕边缘松手百分百闪一下".
102
+
103
+ Measured, the picture was different from the first pass: `_paint` was already fast (1.3ms warm),
104
+ but **every time a drag or resize settled**, `_refresh_backdrop` cost **165ms** — and during the drag
105
+ the backdrop never updated at all, because refresh was debounced to 420ms after release.
106
+
107
+ What was actually slow, in order of payoff:
108
+
109
+ - **`_ring` built two full-size fill masks and subtracted them**, and every plate needs five or six
110
+ rings. Rewritten to solve each row's inner and outer x directly and draw two short segments —
111
+ O(h), no intermediate allocations. 100ms → 3.7ms per plate. (While rewriting it I dropped the
112
+ `width` argument on the floor: the band came out as "from the edge to `inset`", which made a
113
+ 1px highlight vanish entirely and pushed the inner shade line onto the rim, darkening it. The
114
+ tell was "the glass has no edge and looks grey". Fixed by solving both boundaries properly.)
115
+ - **Everything smooth is now built at ¼ scale and upscaled**: curvature weight, dispersion weight,
116
+ and the bevel weight in `refract`. They are blobs, not detail. Gaussian cost drops 16×.
117
+ - **The "light" layers are pure geometry** — sheen, rim, inner shade, warm/cool fringes do not
118
+ depend on the backdrop at all. They are composed once per size into `_light_overlay` and cached;
119
+ a re-bake now pays one `alpha_composite` instead of six.
120
+ - Tint and wash are both flat colours over flat colours, so they are blended into a single colour
121
+ and applied once. Mean luminance is measured on a 48×48 copy (the mean does not care about
122
+ resolution). 2× supersampled masks downsample with `Image.BOX` instead of LANCZOS.
123
+ - **The stage is now one full-screen capture at ¼ resolution**, taken at open while the window is
124
+ still withdrawn. Any later position is a *crop*, never a re-grab — the old "window + margin"
125
+ stage ran out of bounds whenever the widget was near a screen edge, and falling out of bounds
126
+ is exactly the "release → hitch → flash" the user was seeing.
127
+ - **Dragging refreshes live**: `_live_backdrop()` crops from the stage and `_paint_glass_only()`
128
+ swaps only the panel and the two slabs — the header, bubbles and composer do not move relative
129
+ to the window and are not redrawn. Throttled to 30ms (the mouse is 120Hz). Two hidden costs fell
130
+ out of this: `_window_rect()` calls `update_idletasks()`, which silently ran a *full* repaint on
131
+ every frame (+17ms), and position-only `<Configure>` events repainted the entire window.
132
+ - Bubble plates are invalidated by their own counter (`chat_glass_ver`), so a small drag no longer
133
+ re-bakes six bubbles per frame; only panel/slab caches are dropped.
134
+ - Edge-of-screen windows now only need to *overlap* the stage, not sit inside it; the off-screen
135
+ part is cropped short and padded. And a settle within 8s of the last capture does not re-capture
136
+ at all — the stage is refreshed for free while the window is hidden.
137
+
138
+ Numbers (665×594 panel, 150% DPI): a panel plate 520ms → **7.7ms**, slab 90 → **0.9ms**, bubble
139
+ 28 → **0.9ms**; `_paint` warm 1.3ms, `_reflow` 0.5ms; **dragging costs 24–28ms per frame (~38fps)
140
+ where it used to be frozen**; window open 510ms including the full-screen stage.
141
+
142
+ ### Fixed — optional services must go through `ctx.get()`
143
+
144
+ `ctx?.attachments?.saveImage` looks like a runtime probe but throws in a real host: cordis's `ctx`
145
+ is a Proxy whose `get` trap **throws** `cannot get property "xxx" without inject` when a service was
146
+ not declared in `inject`. `?.` only guards `null`/`undefined`, not exceptions.
147
+
148
+ All optional-service lookups now go through `serviceOf(ctx, name)` (in `src/timer.js`): it prefers
149
+ `ctx.get(name)` — cordis's documented way to ask for an optional dependency, returning `undefined`
150
+ when absent — and only falls back to property access inside a `try`.
151
+
152
+ ### Liquid-glass window, one stream, and a name you can change (2026-11-01)
153
+
154
+ Reported as: the scripted lines (warm amber, with a "台词" label) and the assistant's replies (cool
155
+ grey, labelled "陪看") read like two different people talking in one stream — and the window itself
156
+ looked like a plain dark panel.
157
+
158
+ **One stream, one look.** `ROLE` now maps `line` and `assistant` to the *same* colours, and the head
159
+ line shows **only the timestamp** — no "台词", no "陪看". Only the user's own messages keep a tint
160
+ (so you can still tell which side you are on).
161
+
162
+ **Timestamps are wall-clock now** (`HH:MM:SS`), for every role. Scripted lines used to show their
163
+ playback position (`01:26.0`) while everything else showed local time — two time bases in one
164
+ stream, so reading it meant converting in your head. Seconds are included because a segment runs
165
+ 2–5 minutes and several messages share the same minute; `HH:MM` alone would make the stamps useless
166
+ for telling them apart. A message with no `at` gets no head line at all (an empty label still eats
167
+ a full line of height).
168
+
169
+ **Liquid glass.** Three things carry the effect, because tkinter cannot blur what is behind it:
170
+
171
+ - **24px+ radius** — and `round_rect` no longer uses `smooth=True`, which renders a 22px radius as
172
+ roughly 14px (it smooths a polygon rather than following an arc). It now samples each corner arc
173
+ directly.
174
+ - **A refractive edge**: a 1px inner highlight along the top, plus an outer border split into a lit
175
+ upper half and a shadowed lower half — what a real piece of glass does.
176
+ - **Slight window transparency** (`-alpha 0.975`, `DSH_WATCH_GLASS_ALPHA` to tune, ≥1 disables).
177
+ The desktop shows through just enough to read as glass without competing with the text.
178
+
179
+ Buttons and the input field are **pills** now (`Pill` class + a Canvas-backed field): a square
180
+ "发送" button next to a 24px-rounded panel was the most obviously un-Apple thing left.
181
+
182
+ **The title is editable.** Click the name in the header, type, press Enter — saved as `name` in
183
+ `~/.dsh/watch-window.json` and restored next launch. Committing uses an explicit `_editing` flag
184
+ rather than `winfo_ismapped()`, which is still `False` on the frame right after `pack()` and would
185
+ silently swallow a fast Enter.
186
+
187
+ **Fixed:** `meta` entries (wake failures, mic status) were falling through to the assistant bubble
188
+ style — a screenful of `[一起看] 叫醒失败` rendered as full-size cards. They now use the grey
189
+ one-line `Meta` row that already existed for exactly this.
190
+
191
+ **Fixed:** the saved geometry was clamped against `sw - 120` instead of the window's own width, so a
192
+ 700px-wide window could be restored 580px off the right edge.
193
+
194
+ ### No more self-made "queued messages", one reminder per interjection, and a hideable window (2026-11-01)
195
+
196
+ Reported as three things that turned out to be one root cause plus two design gaps.
197
+
198
+ **The queue strip.** `wakeSession` delivers through `agent.followup()`, which lands in the host
199
+ inbox's `next-turn`. DSH's `QueueDock` renders **every** row of `next-turn` and does not filter by
200
+ `source.kind` — so the plugin's own instructions showed up in the input box as pending messages the
201
+ user never typed ("插话栏自动出现"). Two consequences fixed here:
202
+
203
+ - **The hangup note no longer goes through `followup`.** Closing the window is still a hangup (clock
204
+ stops, nothing is rebuilt, no lines are spoken), but the explanation is now written into
205
+ `watch.json` and handed to the model on its next tool result (`takeHangupNote`). The watch loop
206
+ already has the model blocked inside an interrupted tool call, so nothing is lost — and the queue
207
+ strip stays empty. `markHungUp(input, env, note)` carries the text; taking it clears it.
208
+ - **`[未回应]` is emitted once per interjection.** It used to be appended to *every* tool result
209
+ until the model answered with `say`, so one message from the user could be read as three separate
210
+ events ("大肥鱼已经重复了"). `noteInterjected` also no longer restarts the clock when the same
211
+ sentence arrives twice inside the 3-minute TTL.
212
+ - **The interjection prompt is two sentences, not a wall of ⚠️.** Same requirements
213
+ (`say` first, `speakNow`, lines in the same call), a fifth of the length — it is rendered in the
214
+ queue strip, so its size is user-visible.
215
+
216
+ ### `window: "hide" | "show"` — put the window away without ending the watch
217
+
218
+ Closing the window means "I am done watching". Hiding it does not: the process stays alive, the
219
+ clock keeps running, lines keep being spoken, nothing is marked as hung up. Reported as
220
+ "如果有其他功能隐藏悬浮窗会更好".
221
+
222
+ - `watch_together({ window: "hide" })` writes `hidden: true` into `~/.dsh/watch-window.json`;
223
+ `window.py` polls its config every 200 ms (`_sync_visible`) and does `withdraw()` / `deiconify()`.
224
+ `withdraw` rather than `iconify`: an always-on-top floating window should leave no taskbar entry
225
+ behind.
226
+ - `openFloatingWindow` clears `hidden` **before any early return**, so a window that was hidden when
227
+ the process died does not come back invisible.
228
+
229
+ ### Two-track prefetch (2026-11-01) — subtitles no longer wait for the pictures
230
+
231
+ The picture side is the slow one: a segment costs a download plus a scan (10–20 s, 20–90 s for the
232
+ first), while the text for the same window arrives in a few seconds (site CC: instant; local ASR
233
+ RTF 0.019 ≈ 6 s per 5-minute segment). They used to be produced and delivered as one package, so
234
+ the text sat in the slow batch's shadow. Now they are two independent tracks over the **same**
235
+ batch table and the **same** look-ahead window.
236
+
237
+ - **New subtitle track** (`transcribe` → `dsh-video-storyboard/transcript-pass`). Mirrors the picture
238
+ track line for line: same `plan.indexAt` / `windowAt`, its own `transcribed` set. "Whoever's window
239
+ is full stops first" falls out of `find()` returning `undefined` — no extra rule.
240
+ - **Two-part delivery.** When the text lands before its pictures, it is sent on its own
241
+ (`[一起来看·台词] 03:00–06:00` + one timestamped sentence per line). When the picture batch
242
+ arrives later it is built with `omitTranscript`, so the cells carry only times and the sentences are
243
+ not repeated (measured: 17k vs 26k tokens per 2 hours, +50% when repeated).
244
+ - **`feedTranscriptLeadMs`** (default 0 = send as soon as it lands). Raise it to ~20000 if the
245
+ two-part delivery feels chatty and you would rather wait for one combined message.
246
+ - **`transcriptTrack: false`** turns the whole track off.
247
+ - **Failures don't sink the loop.** A failed transcription is not marked as done, so the next tick
248
+ retries; three failures in a row blacklist that segment for 10 minutes (a missing ASR service
249
+ should not be hit every 2 seconds). The picture track is never blocked by it.
250
+ - **Cross-track timestamps now share one clock.** `transcribedAt` / blacklist times were stamped with
251
+ `Date.now()` while the tick compares against the injectable `deps.now()`; the difference was
252
+ negative by a trillion milliseconds, so the "skip for 10 minutes" and "wait N ms before feeding"
253
+ gates were both permanently bypassed (feeding never fired at all).
254
+
255
+ ### Experience pass (2026-11-01) — the minutes spent staring at nothing
256
+
257
+ Same code, same contract; what changes is what the user sees (or hears) while waiting.
258
+
259
+ - **A slow build now says something.** The first batch of a film needs a download plus a scan
260
+ (20–90 s) and a tool call cannot speak — so the window stayed empty and the only signal was
261
+ silence. After 4 s of building (`DSH_WATCH_SLOW_BUILD_MS`) one `meta` line is appended to the
262
+ stream: 「正在取 03:00–06:00 这一段…」. Fast segments write nothing.
263
+ - **The measured latency is finally used on the main path.** `latency.js` has been calibrating
264
+ "read position → result ready" for a while, but only the background clock (`shouldSpeak`) spent it;
265
+ the blocking call still waited until `segment end - lead`, so on the same machine the clock spoke
266
+ early and the tool call spoke late. `deliveryState` now uses `lead + aheadSeconds`, while the text
267
+ still reports `lead` (what is pulled earlier is the work, not the sentence).
268
+ - **Calibration only counts deliveries.** Not-yet calls take tens of milliseconds and are not samples;
269
+ recording them dragged the EWMA towards zero (and wrote `latency.json` on every poll).
270
+ - **The last batch is delivered at the tail.** The final segment's due point is `end - lead`, which for
271
+ the last batch sits past the end of the film — the position never reaches it, so the user watched
272
+ the ending and got nothing. Reaching/passing `dur - 1` now counts as due.
273
+ - **`speech` only lists lines that are still ahead.** It used to echo the whole draft, including the
274
+ lines the same call had just pruned as past — the model read them as "still going to be spoken".
275
+ - **Delivery guidance trimmed ~45%** (≈1150 → ≈640 chars). It is resent every batch; the loop/pacing
276
+ rules already live in the tool description, so only the hard rules stay here: write the lines,
277
+ no spoilers, one sentence, `say` is the only visible channel.
278
+
279
+ ### Reading pass over the loop (2026-11-01) — six real bugs, one hot path
280
+
281
+ No new features. Everything below was found by reading the code against its own comments and then
282
+ reproducing it; each fix carries a regression test that fails on the old code.
283
+
284
+ - **`lastDelivered: null` was read as batch 0.** A delivery blocked by the "no lines yet" gate writes
285
+ `lastDelivered: null`, and `Number(null)` is `0` — exactly the first batch's start. That batch then
286
+ counted as already delivered forever: `wait: true` woke up and answered "already delivered", image
287
+ and manifest never handed over. Empty now stays `NaN`.
288
+ - **Same film, two URL forms → the loop restarted.** `samePlan` compared the raw `input` string, but the
289
+ extension reports `…/BV1g3xN6hEuw/?trackid=…&spm_id_from=…` while the model usually holds the clean
290
+ link. Every second call therefore looked like a new source, wiping `spoken` and re-waking segments
291
+ that had already been delivered. It now compares `sessionKey()`.
292
+ - **`dur: null` became `0 s` on the bridge path.** `Number.isFinite(Number(s.dur))` passes for `null`,
293
+ so a report without a duration set the baseline to 0; the next real reading (600 s) then differed by
294
+ more than a second and was judged "video changed" — the clock stopped mid-film. `num()` in
295
+ `position-bridge.js` and the baseline update now treat empty as empty.
296
+ - **`waitForVideo` lost the hangup.** The input surface is prepared once (`prepared ??=`), and the
297
+ early pre-warm for `waitForVideo` passed no arguments — so `input`/`open` never reached it. Without
298
+ `input` the recorded hangup could not be matched, the window was re-opened, and the call went off to
299
+ wait for a video instead of returning `[hangup]`.
300
+ - **`dueLine` rewrote `watch.json` on every tick.** Its `dirty` flag was shared across segments: once one
301
+ batch had pinned its un-timed lines, every later batch was written back unchanged — a full state write
302
+ every 2 s for the rest of the film. The flag is per segment now.
303
+ - **`waitUntil` / `waitForRefill` lied about why they stopped.** Breaking out because the user paused (or
304
+ the film ended) still produced "waited to the cap". The text now names the real reason.
305
+
306
+ Hot path, same area:
307
+
308
+ - `cachedCues()` re-read and re-parsed the whole subtitle file on every tick (`dueLine` asks several
309
+ times per tick). It is memoised on `path + size + mtime` now, and returns the **same array** so that
310
+ `makeLagFn`'s memo can be keyed on array identity. `makeLagFn` additionally sorts once and looks up
311
+ by binary search instead of a linear scan of every cue. 2000 cues × 5400 lookups: **66.7 ms → 0.8 ms**
312
+ (×83), and the disk read/parse per tick is gone.
313
+ - `lines-util.js` had its own `cacheDir()` that fell back to `~/AppData/Local` on every platform, so on
314
+ Linux/macOS the subtitle cache landed in a directory that does not exist; it now uses the storyboard's
315
+ `cacheDir()`. `findCachedMedia()` likewise uses `tmpdir()` instead of `LOCALAPPDATA/Temp`.
316
+ - Dead exports removed: `plan.starts` (a 513-element array allocated on every `makePlan`),
317
+ `legacySessionKey`, `wasWritten`, `MATERIAL_PARTS`. The input surface failing to start no longer fails
318
+ the whole call — it is reported in the result instead.
319
+
320
+ Three rounds on 2026-10-31. The through-line: the plugin knew something, and the model (or the user)
321
+ never found out — plus one window that needed to look like something people want to keep on screen.
322
+
323
+ ### Long-video recap — merged, but opt-in
324
+
325
+ PR #2, after one round of review. Its first shape prepended a 420-character `[前情]` to **every**
326
+ delivery, partly built from the model's own scripted lines: second-hand context in a package whose
327
+ contract is "raw material only — never retell what the user just watched", at ~200 tokens per
328
+ segment, with no evidence it helped.
329
+
330
+ What shipped instead: off unless `recap: true` or `DSH_WATCH_RECAP=1` (`recap: false` beats the env
331
+ var); only **cached subtitle sentences**, never the model's lines; `recapSegments` 1–3 (default 2),
332
+ `recapMaxChars` 80–1200 (default 420); never reads past the current segment, never trims the live
333
+ transcript, no ASR, no network. Whether it actually reduces retelling is still **unmeasured** — it
334
+ stays opt-in until somebody measures it.
335
+
336
+ ### Observability: `statusOnly` can now answer "why is it slow"
337
+
338
+ Promised in issue #4. `pos + reason` says *what* the clock thinks, not *where it is stuck*.
339
+
340
+ - `segment { index, from, to, delivered, total }` — which batch, its bounds, how many were delivered
341
+ this session, how many the film has (`total` is `null` when the duration is unknown). The last batch
342
+ index is taken at `dur - 1 ms`, because a duration that lands exactly on a boundary would otherwise
343
+ report one batch too many.
344
+ - `speech { queued, lastLateSec, busyUntil }` — lines still waiting, how late the previous line was
345
+ (from `dueLine`'s new `meta: true`, which also keeps the plain-string return for old callers), and
346
+ when the serial voice engine frees up.
347
+ - `build { inflight, cached, lastMs }` — which batch is being built, how many are cached, how long the
348
+ last build took. The cache is passed into the loop for reporting only; it never influences a decision.
349
+ - `queued` needs a disk read, so it is filled in `statusOnly` only, and a failure there is reported as
350
+ `speech.queueError` instead of being swallowed (the first version of this swallowed a `ReferenceError`
351
+ from a missing import and looked exactly like "there are no lines").
352
+
353
+ ### The floating window, rebuilt
354
+
355
+ "这个悬浮窗太丑了" — fair. The old one was a borderless frame with a `Text` widget that painted
356
+ role-coloured **full-width stripes**, on a window Windows stretched from 96 dpi, reading the whole
357
+ `chat.jsonl` every 200 ms.
358
+
359
+ - **Real bubbles.** Each message is its own rounded card (Canvas background + wrapped Label), sized
360
+ to its content: script lines in amber with a left rule, the model in slate, the user's own words
361
+ right-aligned in blue. Above each one, a muted line saying who and when (`台词 04:12.3` for a
362
+ scripted line, `我 21:16` for chat).
363
+ - **Per-monitor DPI awareness** before the window exists, and every size/font derived from the real
364
+ scale factor. Unaware Tk windows are bitmap-stretched at 125/150%, which reads as "blurry and wrong".
365
+ - **Rounded window** via `-transparentcolor` (Windows only; falls back to square corners), a 1 px
366
+ border, and a hand-drawn 6 px scrollbar that only appears when the list actually scrolls.
367
+ - **Does not steal focus.** `focus_force()` at startup meant pressing space to pause the video landed
368
+ in the chat box; now the entry only takes focus inside the window.
369
+ - **Does not fight your scrolling.** New lines auto-scroll only if you were already at the bottom.
370
+ - **Incremental read.** Only the bytes appended since the last tick are parsed, and the first paint
371
+ replays just the last 60 entries.
372
+ - Resizable from the bottom-right grip; position and size persist in `~/.dsh/watch-window.json`.
373
+
374
+ ### Stop when the signal says stop: hangup, dead source, switched video
375
+
376
+ Reported as "换片或者我都关浏览器了还在念台词" and "关了悬浮窗 AI 还是会自动调出来,根本不会自动结束".
377
+ Both were the same shape: the plugin knew the source was gone, and kept talking anyway.
378
+
379
+ - **Speech now requires a believable position.** The line queue only fired when the position was
380
+ `fresh`, or `extrapolated` within `SAFETY_AFTER_MS` (20 s — the normal gap between probes).
381
+ Before, the only thing excluded was `paused`; `estimate()` happily extrapolates a dead source
382
+ forward and `pos` stays finite, so closing the browser kept reading lines out for minutes.
383
+ Nothing is spoken on an `unknown` position, and the position-unknown give-up dropped from
384
+ 10 min to 5 min (the watch should not sit there pretending).
385
+ - **Closing the floating window is a hangup, treated like an interjection.** The window is the only
386
+ way to talk mid-watch, so closing it means "I'm done":
387
+ - the clock stops and **really wakes the model** — `wake:false` (the default) used to silence this
388
+ too, because it shared the `wake` path with the segment-end reminder. User actions (hangup,
389
+ video changed, video ended, seek, unreadable position, high-frequency mode) now use a separate
390
+ always-real channel (`wakeSignal`), and the message says **do not call watch_together again and
391
+ do not read out any more lines**;
392
+ - the guard is stored on the loop and can be turned on later (`resumed` path used to freeze it,
393
+ so a window opened by an earlier call was never guarded);
394
+ - the next tool call **does nothing at all**: no frame, no clock, no window (`[hangup]` result).
395
+ `sameWatch` previously required `args.input`, which the model never sends — so every call looked
396
+ like "a new watch" and re-opened the window the user had just closed.
397
+ - `wakeWithRetry` called an undefined `note()` in its failure branch (a `ReferenceError` swallowed by
398
+ the ticker). Real wakes can fail, so it was reachable; now it records into `loop.logs`.
399
+
400
+ Tests: 247 pass, +4 in `test/hangup-guard.test.mjs` (dead source sends nothing, live source still
401
+ speaks, hangup wakes with the right wording, post-hangup call is inert).
402
+
403
+ ### Interjections: speak first, then look
404
+
405
+ Reported as "它一声不吭先去 zoom,回来才说话". The root cause was not the model: a normal reply
406
+ never reaches the floating window — only `say` does and only `say` is spoken. So "think, then look,
407
+ then answer" was, from the user's side, complete silence for tens of seconds.
408
+
409
+ - One wording, one place (`src/interject.js`) for all five entry points (during a build, during the
410
+ lookahead fill, during a blocking wait, `waitUntil`, `nextLine`). It now says exactly what to do:
411
+ `watch_together({ say: "我看一眼", speakNow: true })` — one call, words written before any frame
412
+ is built. `lines` and `say` can ride in the same call, so "台词优先" no longer means "stay silent".
413
+ - Unanswered interjections are **tracked**: the next tool result ends with `[未回应] …你还没回`,
414
+ until a call actually carries `say` (expires after 3 min). Previously the reminder existed only
415
+ inside the message that woke the model, which it had already scrolled past.
416
+ - `waitUntil` / `nextLine` called a function that **did not exist** (`chatResult`) — an interjection
417
+ during either wait threw `ReferenceError` and the tool failed. Defined, and it reuses the same wording.
418
+ - Waiting for a video to appear returned a result **without `text`**, which the host's `output.schema`
419
+ requires. That path now returns a proper result.
420
+
421
+ ### Reply vs. scripted line: 12-second guard
422
+
423
+ Reported as "说话和插话的回复离太近,把后面那句改一下". Two lines spoken back to back on a serial
424
+ TTS chain means the second one either drifts or is dropped by the adapter (queue > 3.5 s → `skipped`).
425
+
426
+ - `say` now marks the voice engine busy for its full spoken length (`src/reply-guard.js`), so the
427
+ loop stops feeding scripted lines while a reply is still playing. Previously only the loop's own
428
+ lines updated that clock — a reply was invisible to it.
429
+ - Lines scheduled within 12 s of a reply are **withdrawn from the batch and handed back** to the
430
+ model (`[lines·太近]`) with instructions to rewrite them around what was just said, or drop them.
431
+ Withdrawn, not silently deleted: the user asked for "改一下", not "少一句".
432
+
433
+ ### Switching videos is noticed in ~2 s, not ~15 s
434
+
435
+ - The per-tick bridge read (every 2 s) now does the switch / end-of-video / big-jump checks, and
436
+ keeps the `dur`/`url` baseline up to date. Before, all three lived in the 15-second CDP probe
437
+ branch only, so a switch could go unnoticed for a quarter of a minute — while the clock kept
438
+ computing segment boundaries against the old film.
439
+ - The blocking wait in `watch-run` now compares each read against the film it started with and
440
+ returns `[video-changed]` immediately. **This was the only reliable path**: the loop's wake goes
441
+ through `followup()`, which is delivered *after* the current tool call returns — and that call was
442
+ busy waiting.
443
+ - `sourceSwitched()` centralises the test, and `Number(null) === 0` is explicitly guarded: a
444
+ not-yet-known duration used to look like a "0-second film" and stop the watch instantly.
445
+
446
+ ### Cold start: don't wait a full minute for a video we can already identify
447
+
448
+ - The extension only reports while the tab is **visible** — and "一起看" is usually typed in another
449
+ window. The position went stale after 5 s, the plugin concluded "no video", and sat in the 60 s
450
+ wait. It now falls back to a **stale** sample (up to 2 min) to identify the film, marks the
451
+ position `stale`, and lets the next fresh reading correct it.
452
+ - Automatic waiting (no `waitForVideo`) dropped from 60 s to **20 s**; explicit `waitForVideo: true`
453
+ stays at 120 s.
454
+ - `probeBrowser()` is skipped when the extension already reports: one probe is `listTargets`
455
+ (1.2 s) plus up to 8×1.5 s of CDP round-trips — pure overhead for a `browser:` line the extension
456
+ just answered. The line now reads `browser: extension reporting <title> playing 03:20`.
457
+
458
+ Tests: 243 pass (`node --test`), 6 of them new in `test/interject-reply.test.mjs`.
459
+
6
460
  ## [0.0.7] — 2026-10-31 (first release)
7
461
 
8
462
  The first published version. One tool, `watch_together`: it follows the user's real playback