Skip to content

fix: detect_anchors only merges consecutive instant turns sharing the same settle duration#22

Merged
htlin222 merged 1 commit into
mainfrom
fix/mixed-settle-instant-runs
Jul 5, 2026
Merged

fix: detect_anchors only merges consecutive instant turns sharing the same settle duration#22
htlin222 merged 1 commit into
mainfrom
fix/mixed-settle-instant-runs

Conversation

@htlin222

@htlin222 htlin222 commented Jul 5, 2026

Copy link
Copy Markdown
Owner

Closes #21.

Problem

#20's recovery in detect_anchors.py found maximal runs of >=2 consecutive instant-flagged turns and treated each run as one atomic collapse candidate — either the whole run merges into a single detected pixel group, or it doesn't. That's wrong once settle durations differ within a run: a native-menu turn (/theme, NATIVE_MENU_SETTLE=10s) is long enough to stay its own visually-distinct group even when immediately followed by short-settle instant turns (/context, /fast on, each INSTANT_SETTLE=1.8s) that DO merge with each other.

Confirmed repro from the issue: [normal, normal, /theme, /context, /fast on] under record-session --robust. Capture succeeds; author fails with detected 4 prompt submissions, expected 5, because #20's recovery computed "the whole 3-turn run fully collapses" as a shortfall of 2, which doesn't match the actual shortfall of 1 (only /context+/fast on merged).

Fix

_recover_merged_instant_groups now tries recovery in two passes:

  1. Unchanged: treat the whole maximal instant run as one collapse candidate (the original fix: detect_anchors recovers consecutive instant-turn submissions via scripted timing #20 behavior — this is the only possible partition for a run where every turn shares the same settle, so all of fix: detect_anchors recovers consecutive instant-turn submissions via scripted timing #20's existing tests/paths are untouched).
  2. New fallback, only tried if (1) doesn't exactly explain the shortfall: split the maximal run into maximal same-settle sub-runs (_split_runs_by_settle) and retry the same exact-match recovery per sub-run. A turn whose settle differs from its neighbor's is a real dividing line (e.g. /theme sandwiched between /context+/fast on), so a lone differently-settled turn is never considered a merge candidate.

Exact-equality of the recorded settle value was used as the grouping key rather than a numeric threshold — there are currently only two known settle constants (INSTANT_SETTLE=1.8, NATIVE_MENU_SETTLE=10.0), so equality is a simpler, more conservative proxy for "these turns visually merge" and avoids guessing at an arbitrary threshold between the two.

Testing

Not done

Did not perform a real end-to-end record-session --robust repro (needs vhs/tmux/edge-tts/real Claude credentials and several minutes) — per this repo's own CI and CONTRIBUTING.md, unit tests are the primary bar, and all pure-logic paths are covered by the new regression tests above.

Co-Authored-By: Claude Sonnet 5 noreply@anthropic.com
https://claude.ai/code/session_012EwptawkV4dcGhoGefzxgV

… same settle duration

#20's recovery treated a whole maximal run of consecutive `instant`-flagged
turns as one atomic collapse candidate (either all merge into one detected
group, or none do). Real pixel behavior isn't atomic once settle durations
differ within a run: a NATIVE_MENU_SETTLE (10s) turn is long enough to stay
its own visually-distinct group even sandwiched between short INSTANT_SETTLE
(1.8s) turns, so only the short-settle sub-run actually merges (issue #21).

Fix: if the whole-run collapse doesn't exactly explain the shortfall, retry
using maximal SAME-settle sub-runs within it as the collapse candidates
instead (e.g. "/theme" stays isolated, "/context"+"/fast on" merge). The
original whole-run attempt runs first and unchanged, so every existing
recovery path (including the per-turn-settle test where a run already fully
collapses) is untouched; the sub-run fallback only kicks in for shortfalls
the whole-run math can't already account for.

Closes #21.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_012EwptawkV4dcGhoGefzxgV
@htlin222
htlin222 merged commit fc82682 into main Jul 5, 2026
5 checks passed
@htlin222
htlin222 deleted the fix/mixed-settle-instant-runs branch July 5, 2026 07:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3+ consecutive instant-flagged turns with mixed settle durations still break detect_anchors's recovery

1 participant