Skip to content

studio: measure the code block collapse the thread override prevents - #9464

Merged
danielhanchen merged 8 commits into
mainfrom
studio-code-block-flicker-harness
Aug 22, 2026
Merged

danielhanchen merged 8 commits into
mainfrom
studio-code-block-flicker-harness

Conversation

@danielhanchen

Copy link
Copy Markdown
Member

Adds the measurement for a rule that keeps getting re-litigated, and changes no behaviour.

Why

src/index.css forces content-visibility: visible on thread code blocks. That override has now been questioned or removed three separate times, and each time the argument has been made from reasoning rather than from a number, because nothing in the tree measures what the override prevents. This adds that measurement.

The failure it guards against is a one-frame collapse: a code block whose height drops to the contain-intrinsic-size placeholder band and then springs back, taking the scroll position with it. It reads as the chat area reloading for a frame.

What is here

  • studio/frontend/smoke-code-block-flicker{-main.tsx,.html} -- a fixture that mounts the real Thread, streams a reply ending in code fences, and samples every block's rendered height on every frame, along with what the tree actually computed for content-visibility and contain-intrinsic-size so a run records which CSS it measured.
  • tests/studio/playwright_code_block_flicker.py -- the driver. It runs four variants: tree (inject nothing, measure whatever index.css ships), legacy, released and streamdown (the library's own defaults). tree and legacy are required not to flicker; the others exist so a run that reports no collapses anywhere is visibly a broken harness rather than a pass.
  • tests/studio/_code_block_flicker_analysis.py -- the detector. Separates a genuine collapse to the placeholder band from a block that is merely still filling in as its content streams, and separately reports anchor shift.
  • tests/studio/test_code_block_flicker_contract.py -- 20 tests over the detector and the fixture, driven by hand-written frame logs, so the contract is checked without a browser in the loop.

Scope

src/ is untouched. The only edit to an existing file is one line added to tsconfig.app.json's include list for the new smoke entry; everything else is a new file. tests/studio/test_code_block_flicker_contract.py passes 20/20 against main unmodified.

The variant stylesheets are checked to have won the cascade before a result is believed, and the tree variant asserts the tree computes content-visibility: visible, which is the override doing its job. If someone drops the override, that assertion is what fails.

chatgpt-codex-connector[bot]

This comment was marked as resolved.

chatgpt-codex-connector[bot]

This comment was marked as resolved.

@danielhanchen

Copy link
Copy Markdown
Member Author

@codex review

1 similar comment
@danielhanchen

Copy link
Copy Markdown
Member Author

@codex review

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: d7c372fdf4

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment on lines +59 to +60
if previous >= TALL_PX and height <= previous * 0.5:
open_drop = (frame_index, previous)

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Detect collapses against a retained tall height

When a collapse is distributed across frames so that no adjacent step halves the height—for example, 1700 → 1000 → 600 → 350 → 200 → 350 → 600 → 1000 → 1700—this condition never opens a drop because it compares only with the immediately preceding height, which eventually falls below TALL_PX. The detector consequently reports zero collapses for a full transition to the placeholder and back; retain the last tall/reference height while evaluating a multi-frame descent.

Useful? React with 👍 / 👎.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

The arithmetic reproduces on the log you give, but a monotone multi-frame descent is not producible by the phenomenon being measured: the node is replaced and drops to the contain-intrinsic-size fallback in one frame, and heights otherwise only grow while a reply streams. The MUST_FLICKER positive controls would fail loudly if the detector went blind.

Comment on lines +93 to +96
"toFrame": None,
"heightBefore": before,
"heightAtFloor": height,
"frames": None,

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Preserve the true floor for timed-out drops

When an unrecovered drop bottoms out and then partially rebounds before exceeding RECOVERY_FRAMES—for example, 1700 → 200 → 500 held for 240 frames—this branch records heightAtFloor as 500 even though the floor was 200. The newly added per-frame worstDropPx update makes the artifact internally contradictory (worstDropPx is 1500 while the recorded floor implies only 1200); compute the minimum over the open drop here as the recovered and EOF branches do.

Useful? React with 👍 / 👎.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Reproduces, and it is inconsistent with the two sibling branches that use min(), but heightAtFloor is a diagnostic field in detail only. The pass/fail path is built from collapses, worstDropPx and blocks, so no verdict, crash or data loss turns on it.

for v in os.environ.get("SMOKE_FLICKER_VARIANTS", "tree,legacy,released,streamdown").split(",")
if v.strip()
]
REPEATS = int(os.environ.get("SMOKE_FLICKER_REPEATS", "3"))

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Reject zero repetitions before declaring success

With SMOKE_FLICKER_REPEATS=0, the selected variants still satisfy the new positive-control guard, but the inner repetition loop executes no cases, all_rows remains empty, every verdict is skipped, and the harness exits successfully with “every variant behaved.” Validate that REPEATS is positive so a configuration error cannot produce a clean result without measuring any positive control.

Useful? React with 👍 / 👎.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

The hole is real but it needs an operator to export SMOKE_FLICKER_REPEATS=0 explicitly. No CI step sets it, and a deliberate misconfiguration is not legitimate well-formed input.

danielhanchen and others added 4 commits August 22, 2026 06:47
The content-visibility override on thread code blocks in index.css has been
re-litigated three times because nothing measures what it prevents. This adds
the measurement and no behaviour change.

A Playwright fixture streams a reply ending in code fences and records every
block's rendered height per frame, across four injected CSS variants including
streamdown's own defaults, and a detector separates a collapse to the placeholder
band from a block that is simply still filling in. Against the tree as it ships
the run reports no collapses; against streamdown's defaults it reports them.

Nothing in src/ changes.
@danielhanchen
danielhanchen force-pushed the studio-code-block-flicker-harness branch from 8247aa1 to 877258c Compare August 22, 2026 06:48

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 877258cd0d

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment on lines +107 to +109
ENGINES = [
e.strip() for e in os.environ.get("SMOKE_FLICKER_ENGINES", "chromium").split(",") if e.strip()
]

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Reject an empty engine selection

When SMOKE_FLICKER_ENGINES is empty or contains only commas/whitespace, this comprehension produces an empty list. Both execution and verdict loops are then skipped, failures remains empty, and the harness returns success with an empty artifact despite running neither the positive control nor the tree variant. Validate that at least one engine remains after filtering.

Useful? React with 👍 / 👎.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Same shape as the SMOKE_FLICKER_REPEATS=0 item on this PR: it needs an operator to export SMOKE_FLICKER_ENGINES as empty or all-separators on purpose. No CI step does, and the step added in 72ca291 sets it explicitly to chromium. Deliberate misconfiguration is not legitimate well-formed input.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 72ca2916e4

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment on lines +135 to +138
moved = abs(
(current["anchorTop"] + current["scrollTop"])
- (previous["anchorTop"] + previous["scrollTop"])
)

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Preserve the viewport shift in the anchor metric

Because the streamed reply and all of its collapsing blocks are appended after anchor, that anchor's content-space position remains fixed while the visible jump appears as a change in the scroll container's scrollTop. Adding scrollTop to anchorTop cancels exactly that movement, so the default collapse scenario reports anchorShiftPx == 0 even when the viewport visibly jumps; measure the viewport-relative displacement, or another quantity that retains the scroll-position change.

Useful? React with 👍 / 👎.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Document space is the deliberate definition here, stated in the comment on the line and in the module docstring: the metric is movement of settled content that existed before the stream, and the viewport scrolling under an anchor is not that anchor moving. It also gates nothing, failures is built from collapses and blocks only, and this PR's own contract test asserts anchorShiftPx == 900.0 for a case where settled content really does move, so it is not structurally zero. Measuring viewport-relative displacement instead is a different quantity, not a fix to this one.

@unslothai unslothai deleted a comment from chatgpt-codex-connector Bot Aug 22, 2026
@unslothai unslothai deleted a comment from chatgpt-codex-connector Bot Aug 22, 2026
@unslothai unslothai deleted a comment from chatgpt-codex-connector Bot Aug 22, 2026
@unslothai unslothai deleted a comment from chatgpt-codex-connector Bot Aug 22, 2026
@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. Breezy!

Reviewed commit: 02bfe3a683

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

@danielhanchen

Copy link
Copy Markdown
Member Author

@codex review

1 similar comment
@danielhanchen

Copy link
Copy Markdown
Member Author

@codex review

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 4fc0d9f3d8

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

"The variant stylesheet did not win the cascade, so this run would have measured "
"the tree under another name."
)
page.evaluate("(m) => window.__flicker.park(m)", PARK)

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Apply edge parking after the run-start pin

When SMOKE_FLICKER_PARK=edge is selected, this parks the viewport before window.__flicker.run() appends the user message. That append emits thread.runStart, and the real Thread handles it in use-intent-aware-autoscroll.tsx by unconditionally calling pinToBottom("auto"), so the requested edge position is immediately overwritten; the park option copied into the fixture config is never read during the run. Consequently, edge-mode artifacts actually measure the same bottom-pinned scenario as the default, so apply the edge positioning after run start or otherwise prevent the subsequent pin.

Useful? React with 👍 / 👎.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

The mechanism is real and I confirmed both halves: config.park is never read, the fixture only reads chunkChars, fences, gapMs and linesPerFence, and the real Thread's use-intent-aware-autoscroll pins to bottom on thread.runStart unconditionally, clearing the detach flag first. It still does not clear the bar. PARK appears at exactly three sites and reaches no output: not the per-case row, not the JSON artifact, not the summary table. So no artifact says edge while holding bottom-pinned numbers, and no verdict moves, because the exit code comes from the MUST_FLICKER and MUST_NOT_FLICKER sets evaluated on whatever ran, which in edge mode is the default configuration complete with its positive controls. An opt-in knob that silently degrades to the validated default is dead code, not a wrong measurement, and this PR has already converged and had its final comment pass, so the bar for reopening it is a genuine correctness bug.

@danielhanchen
danielhanchen merged commit 0f1b989 into main Aug 22, 2026
36 checks passed
@danielhanchen
danielhanchen deleted the studio-code-block-flicker-harness branch August 22, 2026 17:21
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.

1 participant