Skip to content

test(mobile): de-flake the cold Shiki highlighting test - #233

Merged
tusharbhardwaj-bk merged 1 commit into
expbkmainfrom
t3code/perf-20-deflake-shiki-test
Sep 27, 2026
Merged

tusharbhardwaj-bk merged 1 commit into
expbkmainfrom
t3code/perf-20-deflake-shiki-test

Conversation

@tusharbhardwaj-bk

Copy link
Copy Markdown
Collaborator

Problem

apps/mobile/src/features/review/shikiReviewHighlighter.test.ts › "initializes source and snippet highlighting without a warmup" failed validate on #222 twice and on #231. It passes locally, in isolation and in a full local mobile run (181 files, 1,669 tests).

The failing assertion compared the cold highlightSourceFile tokens with the highlightCodeSnippet tokens exactly. Shiki's codeToTokens has a tokenizeTimeLimit of 500 ms by default (@shikijs/primitive 4.2.0). On a loaded runner the first tokenization can exceed it, and Shiki then emits the rest of the line as one token. The CI diff showed exactly that: "42;" as one token instead of "42" + ";".

Fix

The test now asserts what it's named for: both paths initialise without a warmup, reproduce the source text and apply colours. Token boundaries under a time limit are no longer part of the test. Production code is unchanged.

Evidence

NODE_ENV=test vp test run src/features/review/shikiReviewHighlighter.test.ts: 7 pass.

Model/harness: Claude Opus 5.5 via Claude Code in T3 Code.

🤖 Generated with Claude Code

"initializes source and snippet highlighting without a warmup" compared the
cold source-file tokens with the snippet tokens exactly. On a loaded CI
runner the first, cold tokenization can exceed Shiki's 500 ms
tokenizeTimeLimit and emit the rest of the line as one token ("42;" rather
than "42" + ";"), which failed validate on several perf PRs (#222 twice,
#231) while passing locally and in a full local mobile run.

The test now checks what it is about: both paths initialise without a
warmup, reproduce the source and apply colours.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@github-actions github-actions Bot added vouch:trusted PR author is trusted by repo permissions or the VOUCHED list. size:S labels Sep 27, 2026
@tusharbhardwaj-bk
tusharbhardwaj-bk merged commit 6565afa into expbkmain Sep 27, 2026
9 of 18 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

size:S vouch:trusted PR author is trusted by repo permissions or the VOUCHED list.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants