Skip to content

fix(v4): refresh the stale twoslash hovers, and stop them going stale - #870

Merged
titouanmathis merged 1 commit into
mainfrom
fix/v4-twoslash-stale-cache
Aug 26, 2026
Merged

fix(v4): refresh the stale twoslash hovers, and stop them going stale#870
titouanmathis merged 1 commit into
mainfrom
fix/v4-twoslash-stale-cache

Conversation

@titouanmathis

Copy link
Copy Markdown
Contributor

The docblock links from #868 never reached the site. You spotted it as "missing links in the twoslash overlays" — the cause is one layer down.

The cache never invalidates on a type change

cacheHash(code, lang, options) => sha256(`${optionsHash}:${lang}:${code}`)

The key is the sample, not the types behind it. Change a docblock in src/, rebuild dist, and every cache still matches — so the overlay keeps serving the hover data captured when it was first written.

Nothing warns you. The build passes, the page renders, only the tooltip is out of date. Measured on the same commit and the same tree:

Build Doc URLs in the hovers
committed caches — what CI was deploying 0
TWOSLASH_INLINE_CACHE_IGNORE=1 587

Two fixes

Refresh now — all 96 files' caches regenerated, so a plain npm run docs:v4:build produces all 587.

Stop the drift — the deploy-v4 job sets TWOSLASH_INLINE_CACHE_IGNORE, so what gets published is always generated against current types instead of trusted from the repo. The committed caches keep their real job: making docs:v4:dev fast locally.

Cost: ~50s, a 32s build becoming 83s for ~200 samples.

What I considered and rejected

Folding a dist fingerprint into the twoslash options would auto-invalidate on any type change, which is neater in principle. But the options that feed getOptionsHash are shiki's CodeToHastOptions, not the plugin's own — there is no clean seam to inject a fingerprint, so it would mean patching the transformer.

A --check guard asserting "regenerating changes nothing" was the other candidate. It keeps builds fast and the repo honest, but it pays the same ~50s in CI and adds a failure mode where the fix is "run a command and commit the diff". Regenerating at deploy time gets the property that matters — published output is never stale — without that friction.

Note

deploy-v3 has the same latent issue with packages/docs, and I have not touched it: it would slow that build and it is not what this PR is about. Worth a look if v3 docblocks change.

Checks

npm run lint                                  → clean
npm run docs:v4:build                         → build complete, 587 doc URLs in hovers
TWOSLASH_INLINE_CACHE_IGNORE=1 …:build        → build complete, 587, 83s

🤖 Generated with Claude Code

https://claude.ai/code/session_012ioM9dGKVhexCv4NLUcbA7

The docblock links added in #868 never reached the site: every twoslash
overlay was serving hover data captured before those links existed.

A cache is keyed on `sha256(shikiOptions:lang:code)` — the sample, not
the types behind it. Changing a docblock in `src/` therefore invalidates
nothing, and the tooltip stays frozen at whatever the types were when the
cache was first written. Nothing warns you: the build passes, the page
renders, only the hover is out of date. Same commit, same tree:

  committed caches            ->   0 doc URLs in the hovers
  TWOSLASH_INLINE_CACHE_IGNORE -> 587

So this regenerates all 96 files' caches, and the deploy job now sets
TWOSLASH_INLINE_CACHE_IGNORE so what is published is always generated
against current types rather than trusted from the repo. The committed
caches keep their real job, which is making `docs:v4:dev` fast locally.

The cost is about 50s: a 32s docs build becomes 83s for ~200 samples.

Folding a `dist` fingerprint into the twoslash options to auto-invalidate
would be neater, but the options that feed the hash are shiki's, not the
plugin's, so there is no clean seam for it.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_012ioM9dGKVhexCv4NLUcbA7
@github-actions

Copy link
Copy Markdown

Code Review

Risk: Low — The workflow now regenerates v4 Twoslash caches during deployment, while the committed cache payloads refresh the visible examples; no blocking defect is evident in the reviewed diff.

This change updates the generated hover data in several v4 documentation examples and sets TWOSLASH_INLINE_CACHE_IGNORE for the v4 deployment build so published docs are generated against the current package types. The review was limited by the repository's skipped-file list, so the remaining cache refreshes and related documentation examples were not independently verified.


Review usage: 52,273 in (3,056 cached) / 309 out tokens — $0.0318 (openrouter/openai/gpt-5.6-luna, thinking: low)

Reviewed by @weareikko/code-review v0.9.5 for commit 3f81200.

@github-actions

Copy link
Copy Markdown

Export size

Bundled per export with peer dependencies left external, dynamic imports excluded and the output minified; sizes are gzipped.

✅ No export size changes.

Unchanged (399)

@studiometa/js-toolkit

Export Size (gzip) Diff
(barrel) 17.48 kB
AbstractService 598 B
Base 9.1 kB
ComponentLoader 2.31 kB
DEFAULT_DIAGNOSTIC_PREFIX 102 B
DragService 2.02 kB
IDLE_TIMEOUT 57 B
KeyService 935 B
LoadService 666 B
MutationService 849 B
PointerService 1.13 kB
RafService 1020 B
ResizeService 1.12 kB
ScrollService 1.36 kB
VISIBLE_ROOT_MARGIN 72 B
autoload 2.4 kB
closestComponent 419 B
composeManifests 119 B
createApp 996 B
defineFeatures 326 B
defineManifest 512 B
fromMetaGlob 228 B
fromWebpackContext 131 B
getClosestParent 197 B
getDirectChildren 202 B
getInstanceFromElement 125 B
getInstances 187 B
getScopedGroups 104 B
importOnInteraction 926 B
importOnMediaQuery 243 B
importWhenIdle 225 B
importWhenPrefersMotion 271 B
importWhenVisible 935 B
isDirectChild 218 B
logTree 551 B
queryComponent 594 B
queryComponentAll 601 B
readEagerTokens 201 B
registerComponent 305 B
registerComponents 356 B
registerManifest 2.87 kB
registerManifests 2.89 kB
useDrag 2.05 kB
useKey 943 B
useLoad 676 B
useMutation 876 B
usePointer 1.15 kB
useRaf 1 kB
useResize 1.13 kB
useScroll 1.36 kB
utils 10.08 kB
utils/Queue 291 B
utils/SmartQueue 473 B
utils/addClass 240 B
utils/addStyle 239 B
utils/animate 3.34 kB
utils/boundingRectToCircle 206 B
utils/cache 208 B
utils/camelCase 405 B
utils/clamp 98 B
utils/clamp01 114 B
utils/collideCircleCircle 129 B
utils/collideCircleRect 192 B
utils/collidePointCircle 128 B
utils/collidePointRect 122 B
utils/collideRectRect 128 B
utils/createEaseInOut 123 B
utils/createEaseOut 91 B
utils/createElement 635 B
utils/createLocalStorage 1.32 kB
utils/createLocalStorageProvider 296 B
utils/createMemoryStorageProvider 174 B
utils/createNoopProvider 128 B
utils/createRange 115 B
utils/createSessionStorage 1.32 kB
utils/createSessionStorageProvider 288 B
utils/createStorage 1.3 kB
utils/createUrlSearchParamsInHashProvider 461 B
utils/createUrlSearchParamsInHashStorage 1.35 kB
utils/createUrlSearchParamsProvider 429 B
utils/createUrlSearchParamsStorage 1.34 kB
utils/damp 106 B
utils/dashCase 404 B
utils/debounce 122 B
utils/domScheduler 310 B
utils/ease 519 B
utils/easeInCirc 285 B
utils/easeInCubic 287 B
utils/easeInExpo 286 B
utils/easeInOutCirc 288 B
utils/easeInOutCubic 289 B
utils/easeInOutExpo 288 B
utils/easeInOutQuad 288 B
utils/easeInOutQuart 289 B
utils/easeInOutQuint 289 B
utils/easeInOutSine 288 B
utils/easeInQuad 285 B
utils/easeInQuart 286 B
utils/easeInQuint 286 B
utils/easeInSine 285 B
utils/easeLinear 77 B
utils/easeOutCirc 286 B
utils/easeOutCubic 288 B
utils/easeOutExpo 286 B
utils/easeOutQuad 286 B
utils/easeOutQuart 286 B
utils/easeOutQuint 286 B
utils/easeOutSine 286 B
utils/endsWith 128 B
utils/fold 168 B
utils/getAncestorWhere 123 B
utils/getAncestorWhereUntil 148 B
utils/getComponentResolver 140 B
utils/getOffsetSizes 194 B
utils/hasWindow 88 B
utils/historyPush 524 B
utils/historyReplace 526 B
utils/inertiaFinalValue 169 B
utils/isArray 63 B
utils/isBoolean 78 B
utils/isDefined 75 B
utils/isDev 78 B
utils/isEmpty 206 B
utils/isEmptyString 108 B
utils/isFunction 79 B
utils/isNull 68 B
utils/isNumber 91 B
utils/isObject 108 B
utils/isString 77 B
utils/keyCodes 122 B
utils/lerp 84 B
utils/loadElement 220 B
utils/loadIframe 241 B
utils/loadImage 241 B
utils/loadLink 237 B
utils/loadScript 251 B
utils/localStorageProvider 839 B
utils/lowerCase 404 B
utils/map 93 B
utils/matrix 136 B
utils/mean 126 B
utils/memo 130 B
utils/memoize 228 B
utils/memoryStorageProvider 843 B
utils/nextFrame 179 B
utils/nextMicrotask 133 B
utils/nextTick 148 B
utils/noop 62 B
utils/noopValue 76 B
utils/objectToURLSearchParams 322 B
utils/pascalCase 407 B
utils/random 93 B
utils/randomInt 113 B
utils/randomItem 234 B
utils/removeClass 242 B
utils/removeStyle 243 B
utils/round 95 B
utils/saveActiveElement 92 B
utils/scrollTo 2.31 kB
utils/sessionStorageProvider 838 B
utils/smoothTo 476 B
utils/snakeCase 406 B
utils/spring 154 B
utils/startsWith 125 B
utils/throttle 125 B
utils/toggleClass 242 B
utils/transform 347 B
utils/transition 1010 B
utils/trapFocus 441 B
utils/tween 1.72 kB
utils/untrapFocus 120 B
utils/upperCase 404 B
utils/urlSearchParamsInHashProvider 845 B
utils/urlSearchParamsProvider 839 B
utils/useScheduler 309 B
utils/wait 103 B
utils/withLeadingCharacters 135 B
utils/withLeadingSlash 142 B
utils/withTrailingCharacters 135 B
utils/withTrailingSlash 142 B
utils/withoutLeadingCharacters 122 B
utils/withoutLeadingCharactersRecursive 165 B
utils/withoutLeadingSlash 133 B
utils/withoutTrailingCharacters 122 B
utils/withoutTrailingCharactersRecursive 165 B
utils/withoutTrailingSlash 133 B
utils/wrap 122 B
version 56 B
withBreakpointManager 1.54 kB
withBreakpointObserver 1.71 kB
withDrag 2.18 kB
withExtraConfig 163 B
withFreezedOptions 187 B
withGroup 455 B
withIntersectionObserver 303 B
withMountOnMediaQuery 393 B
withMountWhenInView 347 B
withMountWhenPrefersMotion 431 B
withMutation 1010 B
withName 109 B
withRelativePointer 1.29 kB
withResponsiveOptions 2.4 kB
withScrolledInView 3.05 kB

@studiometa/js-toolkit-v4

Export Size (gzip) Diff
(barrel) 22.73 kB
BREAKPOINTS 778 B
Base 8.59 kB
DIAGNOSTICS 714 B
DRAG_MODES 162 B
EVENTS 153 B
MOUNT_ATTRIBUTE 69 B
SWAP_MODES 129 B
children 244 B
component 11.66 kB
createContext 472 B
createFallbackProvider 1.33 kB
createGroup 1.07 kB
createLocalStorage 2.33 kB
createMemoryStorageProvider 1.21 kB
createService 640 B
createServiceMixin 1015 B
createSessionStorage 2.33 kB
createStorage 2.3 kB
createUrlSearchParamsInHashProvider 1.21 kB
createUrlSearchParamsInHashStorage 2.34 kB
createUrlSearchParamsProvider 1.21 kB
createUrlSearchParamsStorage 2.34 kB
defaultScheduler 1.5 kB
defineManifest 983 B
domUpdate 1.23 kB
emitExtendable 1.09 kB
fromMetaGlob 203 B
fromWebpackContext 131 B
getBreakpoints 776 B
getInstance 131 B
getInstances 2.87 kB
getMountedInstances 2.87 kB
getUnmountedInstances 2.88 kB
inject 176 B
injectContext 675 B
injectContextSync 634 B
jsonSerializer 95 B
localStorageProvider 1.21 kB
memoryStorageProvider 1.21 kB
namespaceQualifier 120 B
nextFrame 115 B
on 8.93 kB
perTarget 322 B
provide 185 B
provideContext 704 B
provideRootContext 748 B
read 126 B
registerComponent 11.27 kB
registerComponents 11.27 kB
registerManifest 11.33 kB
reportDiagnostic 329 B
sessionStorageProvider 1.21 kB
setBreakpoints 806 B
signal 925 B
subscribeContext 1.44 kB
swap 2.9 kB
test 11.77 kB
toggle 177 B
until 172 B
urlSearchParamsInHashProvider 1.21 kB
urlSearchParamsProvider 1.21 kB
useBreakpoint 1.44 kB
useDrag 3.36 kB
useInView 1.43 kB
useKey 1.47 kB
useMediaQuery 1.06 kB
useMutation 1.4 kB
usePointer 1.85 kB
usePrefersReducedMotion 1.09 kB
useRaf 1.95 kB
useResize 1.43 kB
useScroll 2.67 kB
useScrollProgress 3.64 kB
useWindowScroll 2.66 kB
useWindowSize 1.43 kB
utils 9.25 kB
utils/DEFAULT_DAMP_FACTOR 109 B
utils/INERTIA_FRAME 97 B
utils/MAX_SPRING_RATIO 100 B
utils/SCROLL_ALIGNMENTS 117 B
utils/SCROLL_AXES 100 B
utils/TRANSFORM_PROPS 137 B
utils/TRANSITION_OPTIONS 132 B
utils/camelCase 449 B
utils/capitalize 119 B
utils/clamp 133 B
utils/clamp01 149 B
utils/clampDampFactor 157 B
utils/createEaseInOut 120 B
utils/createEaseOut 91 B
utils/createElement 638 B
utils/createRange 205 B
utils/damp 211 B
utils/debounce 121 B
utils/decayOver 162 B
utils/deepmerge 312 B
utils/easeInCirc 94 B
utils/easeInCubic 81 B
utils/easeInExpo 97 B
utils/easeInOutCirc 150 B
utils/easeInOutCubic 141 B
utils/easeInOutExpo 150 B
utils/easeInOutQuad 139 B
utils/easeInOutQuart 140 B
utils/easeInOutQuint 140 B
utils/easeInOutSine 156 B
utils/easeInQuad 80 B
utils/easeInQuart 81 B
utils/easeInQuint 81 B
utils/easeInSine 104 B
utils/easeLinear 77 B
utils/easeOutCirc 121 B
utils/easeOutCubic 111 B
utils/easeOutExpo 124 B
utils/easeOutQuad 110 B
utils/easeOutQuart 112 B
utils/easeOutQuint 111 B
utils/easeOutSine 132 B
utils/enterTransition 679 B
utils/fold 200 B
utils/getOffsetSizes 268 B
utils/historyPush 391 B
utils/historyReplace 392 B
utils/inertiaDecay 199 B
utils/inertiaFinalValue 187 B
utils/inertiaStep 232 B
utils/inertiaTimeConstant 178 B
utils/isBoolean 90 B
utils/isDefined 87 B
utils/isFunction 86 B
utils/isNull 78 B
utils/isNumber 103 B
utils/isObject 115 B
utils/isString 89 B
utils/kebabCase 421 B
utils/leaveTransition 679 B
utils/lerp 120 B
utils/loadImage 245 B
utils/loadLink 776 B
utils/loadScript 697 B
utils/lockScroll 565 B
utils/lowerCase 84 B
utils/map 128 B
utils/matrix 150 B
utils/mean 147 B
utils/memo 217 B
utils/noop 62 B
utils/noopValue 76 B
utils/objectToURLSearchParams 266 B
utils/pascalCase 434 B
utils/random 93 B
utils/randomInt 132 B
utils/randomItem 163 B
utils/round 130 B
utils/saveActiveElement 571 B
utils/scrollPosition 857 B
utils/scrollTo 1.86 kB
utils/selectorFor 2.78 kB
utils/setClassesOrStyles 218 B
utils/smoothTo 2.83 kB
utils/snakeCase 421 B
utils/spring 343 B
utils/throttle 151 B
utils/transform 286 B
utils/transition 577 B
utils/trapFocus 717 B
utils/untrapFocus 587 B
utils/upperCase 84 B
utils/wait 103 B
utils/withLeadingCharacters 142 B
utils/withLeadingSlash 152 B
utils/withTrailingCharacters 143 B
utils/withTrailingSlash 153 B
utils/withoutLeadingCharacters 127 B
utils/withoutLeadingCharactersRecursive 144 B
utils/withoutLeadingSlash 138 B
utils/withoutTrailingCharacters 129 B
utils/withoutTrailingCharactersRecursive 147 B
utils/withoutTrailingSlash 140 B
utils/wrap 154 B
viewTransition 1.66 kB
warn 321 B
watchAttributeNamespace 2.54 kB
watchAttributes 2.02 kB
whenDOMSettled 2.35 kB
withDrag 4.02 kB
withInView 2.11 kB
withKey 2.15 kB
withMutation 2.09 kB
withPointer 2.52 kB
withRaf 2.62 kB
withResize 2.1 kB
withScroll 3.33 kB
withScrollProgress 4.33 kB
write 124 B

@codecov

codecov Bot commented Aug 26, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 97.06%. Comparing base (4dc7e8b) to head (3f81200).

Additional details and impacted files
@@           Coverage Diff           @@
##             main     #870   +/-   ##
=======================================
  Coverage   97.06%   97.06%           
=======================================
  Files         176      176           
  Lines        4561     4561           
  Branches     1331     1331           
=======================================
  Hits         4427     4427           
  Misses        122      122           
  Partials       12       12           
Flag Coverage Δ
eslint-plugin-js-toolkit 94.55% <ø> (ø)
js-toolkit 97.93% <ø> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@github-actions

Copy link
Copy Markdown

v4 mount benchmarks

Base and head measured on this runner, alternating over 3 rounds each; every value is the median of the round medians. Running both sides on one machine is what removes cross-machine noise — a cached baseline from another runner would put it back.

A move under 25%, or on a benchmark under 5 ms, is not reported as a change: it is inside the measured noise of a shared runner.

No benchmark moved beyond the noise floor.

Within noise (18)
Group Benchmark Base Head us / component Change
mount 1000 components, one insertion control — declared but unregistered 1.80 ms 1.90 ms 1.90 +5.6%
mount 1000 components, one insertion flat 17.8 ms 16.8 ms 16.80 -5.6%
mount 1000 components, one insertion in-view — one controller per element 30.2 ms 27.7 ms 27.70 -8.3%
mount 1000 components, one insertion nested 4 deep 14.9 ms 14.1 ms 14.10 -5.4%
mount 1000 components, one insertion realistic — 5 refs, 3 options, 4 handlers 74.1 ms 73.2 ms 73.20 -1.2%
mount 1000 components, one insertion responsive option — breakpoint cascade per mount 16.9 ms 16.5 ms 16.50 -2.4%
mount 1000 flat components, 1 vs 10 insertions 1 insertion 11.4 ms 12.3 ms 12.30 +7.9%
mount 1000 flat components, 1 vs 10 insertions 10 insertions 12.5 ms 13.2 ms 13.20 +5.6%
mount 5000 components, one insertion control — declared but unregistered 18.1 ms 18.1 ms 3.62 +0.0%
mount 5000 components, one insertion flat 67.6 ms 65.0 ms 13.00 -3.8%
mount 5000 components, one insertion in-view — one controller per element 167.1 ms 155.4 ms 31.08 -7.0%
mount 5000 components, one insertion nested 4 deep 66.5 ms 67.1 ms 13.42 +0.9%
mount 5000 components, one insertion realistic — 5 refs, 3 options, 4 handlers 356.7 ms 337.3 ms 67.46 -5.4%
mount 5000 components, one insertion responsive option — breakpoint cascade per mount 81.9 ms 84.5 ms 16.90 +3.2%
mount 5000 flat components, 1 vs 10 insertions 1 insertion 66.0 ms 68.3 ms 13.66 +3.5%
mount 5000 flat components, 1 vs 10 insertions 10 insertions 66.2 ms 71.6 ms 14.32 +8.2%
unmount 1000 flat components, one removal flat 2.30 ms 2.40 ms 2.40 +4.3%
unmount 5000 flat components, one removal flat 16.3 ms 13.8 ms 2.76 -15.3%

@titouanmathis
titouanmathis merged commit 7f65a75 into main Aug 26, 2026
12 checks passed
@titouanmathis
titouanmathis deleted the fix/v4-twoslash-stale-cache branch August 26, 2026 18:19
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