Repository navigation
test(mecatui): stabilize streaming Markdown ANSI parity - #2673
Merged
Merged
Conversation
Normalize equivalent SGR runs after Chroma foreground masking to avoid the streaming parity flake in #2661. Preserve regression coverage for text, layout, styling, links, and final pen state. Co-authored-by: Mecatl <noreply@mecatl.dev>
Record the direct import added by the Markdown ANSI parity tests so module tidy leaves the checkout clean. Co-authored-by: Mecatl <noreply@mecatl.dev>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Fixes #2661.
Investigation and root-cause evidence
The palette-map tie is real, but it does not explain the reported token-run grouping: Chroma coalesces tokens before palette selection, and its terminal formatter writes each token separately.
A stronger mechanism is Chroma's regex timeout handling. In v2.27.0, regex matches have a 250 ms timeout, but
matchRulessilently treats matching errors as failed matches. If Bash's builtin rule times out onecho step 0\n, the generic text rule consumesecho, andCoalescemerges it withstep:With scratch-only copies of Chroma and regexp2, a controlled 600 ms pause after the timeout watch starts for the second builtin match makes the real regex timeout fire. Instrumentation records that error, and two full renders of the original 37-byte prefix at width 24 diverge at byte 347, exactly matching the issue's signature. Incremental rendering is not needed. The same controlled timeout passes with this comparison fix.
Evidence boundary: this establishes a matching failure mechanism on current-main dependencies, not retrospective proof of which regex timed out in the original uninstrumented run. Before the fix, 100 focused non-race repetitions and five repetitions of all streaming Markdown tests under race passed naturally; those passes do not establish that the dependency upgrade fixed the flake. No natural current-main reproduction was captured. An exploratory process-pause run timed out without a parity assertion and is not counted as flake evidence.
Scope of the fix
The test already intentionally discarded Chroma foreground-colour differences. It now also ignores changes in run segmentation that become equivalent after that masking. Meaningful differences outside that existing colour exclusion still fail.
This fixes the parity test's comparison contract, not Chroma's upstream timeout/error policy. Real syntax highlighting can still change under a lexer timeout; that production behaviour is not changed here. Other attribute changes, including those caused by lexer timeouts, remain observable to the parity test.
Validation
All final gates passed on this change:
timeout 1800 task --concurrency 3 testtimeout 1800 task --concurrency 3 test:racetimeout 600 task lint— zero issues across all modulesGOWORK=off go run ./cmd/mecademo— tool call/result and permission ask/approval presentGOMAXPROCS=2 GOWORK=off go test -race ./cmd/mecatui/ui -run '^TestNormalizeMarkdownANSI$|^TestStreamMarkdownMatchesFullRender/heading_and_fence_runs$' -count=25 -timeout=300s— passed in 103.061sansi.Stripmakes all 11 styling/link negative controls failgit diff --checkInitial lint and repeated-race attempts exhausted their outer budgets while full gates were compiling concurrently, without parity assertions. Both were rerun successfully after the full suites finished.
API compatibility
Test-only change. No remote-observable behaviour, wire/API contracts, Go public APIs, stored data, feature identifiers, or API major changes. No upgrade implications.