test(tui): make frame snapshots independent of the crate version - #525
Conversation
The header renders `agent-code <version>`, so the goldens embedded 0.27.0 and the v0.28.0 release bump turned all four frame snapshots red — on main, and on every branch that rebased onto it. assert_snapshot now masks this crate's version with a fixed placeholder before comparing (and before writing, so regeneration stays stable). The replacement keeps the same byte length, so column alignment and the style rows stay comparable across versions of differing width. Goldens regenerated: the diff is the version line in each of the four files and nothing else. Verified by bumping the crate version locally to 0.29.0 — snapshots still pass, so the next release cannot break them the same way.
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 50187b3f1c
ℹ️ 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".
| match version.len().cmp(&PLACEHOLDER.len()) { | ||
| // Keep the byte length identical so nothing shifts columns. | ||
| std::cmp::Ordering::Greater => { | ||
| replacement.push_str(&" ".repeat(version.len() - PLACEHOLDER.len())) | ||
| } |
There was a problem hiding this comment.
Normalize the placeholder to a fixed width
When a release version has a different byte length, such as 0.100.0, this branch pads x.y.z to that new length rather than the width stored in the goldens. The following header fields and their style cells are therefore still rendered at version-dependent columns, so all four snapshots will fail again despite the masking. Use a fixed test version before rendering, or normalize the corresponding glyph and style columns to a constant width.
Useful? React with 👍 / 👎.
Conflicts were the four frame goldens. main (#525) made them independent of the crate version by masking it to x.y.z, which is the better fix than the version bump this branch had pinned in; took main's side and dropped that commit's effect. Regenerating the goldens on this branch reproduces main's files byte-for-byte: none of the snapshot fixtures issues a TodoWrite, so the checklist never renders in these frames and the feature leaves them unchanged.
My previous commit reverted #525. Regenerating the goldens against a working tree that still held the pre-merge snapshot.rs, then staging everything, deleted mask_version and re-pinned all four headers to a concrete 0.28.0 — reintroducing precisely the breakage #525 landed to end, where a release bump turns every frame snapshot red. Review flagged it as a P1 and was right. snapshot.rs is taken verbatim from main; this branch never had a reason to touch that file. The goldens are regenerated on top of it, so they now carry both the x.y.z placeholder and this branch's palette routing. Verified the masking rather than assuming it: with crates/cli set to 0.29.0 the snapshot suite still passes, and every header reads agent-code x.y.z. Every style row that differs from main is accounted for by the colour routing, and no glyph moved in any of the four frames: - DarkGray becomes Rgb(92, 99, 112), one-dark's muted; - Gray becomes Rgb(124, 131, 144), one-dark's inactive; - White becomes Rgb(171, 178, 191), the text slot; - Green becomes Rgb(152, 195, 121), the success slot; - Black on the warning fill becomes Rgb(40, 44, 52), which is what on_fill picks for one-dark. transcript_basic also loses a legend entry, and its style row shifts from i to e: bold Green and bold success are now the same style, so the two entries dedupe into one. Same pixels, one fewer legend line. transcript_light resolves against solarized-light instead — muted #93a1a1 and inactive #819295 — which is the point of routing through the palette rather than naming colours. Taking main's copy of any file this PR has no intent to change is the rule I should have applied when resolving the merge in the first place.
Summary
agent-code 0.27.0in the header and the v0.28.0 release bumped the crate version.assert_snapshotnow masks this crate's version with a fixedx.y.zplaceholder before comparing (and before writing, so regeneration stays stable). The replacement is padded to the same byte length, so column alignment — and therefore the style rows — stay comparable across versions of differing width.Test plan
cargo test --all-targets— snapshot suite 9/9 green; full suite green apart from the 3 known environmentalbwrap_*failurescargo clippy --all-targets -- -D warnings,cargo fmt --all -- --checkorigin/mainbefore the fix (4 failures), and passes after