3.6 KiB
Code
An agent's write tool can turn \u00a0 into a real non-breaking space
What happened. packages/content/src/copy-lint.ts was written with the regex
[\s\u00a0]. On disk the file held [\s + the bytes C2 A0 + ]: an actual U+00A0.
ESLint's no-irregular-whitespace caught it. Fixing it with sed, then with a
node -e replace, then with a quoted heredoc each wrote the same character back. The
fix that worked built both strings from char codes (String.fromCharCode(160),
String.fromCharCode(92) + 'u00a0').
Why it bit. Somewhere between the agent and the file, a single-backslash
\uXXXX in the input was decoded. A double-backslash \\u00a0 inside a JS string
(forbidden.ts) survived. The bug is invisible on screen: the two forms look the same.
How to apply it. Prefer \s or a named class over a literal Unicode escape in a
regex. When one is needed, check the bytes after writing.
This entry was itself written with two literal NBSPs where it named the escape, and was
fixed the same way. Check with grep -n $'\xc2\xa0' file (the two UTF-8 bytes) or
sed -n Np file | od -c. Do not use grep -P '\xA0': it matches the last byte of ≠
and other characters, and raised a false alarm on the review document. Keep
no-irregular-whitespace on.
A Svelte 5 effect that short-circuits never tracks what it skipped
What happened. Shell.svelte moved focus with
$effect(() => { if (moved) heading?.focus(); }). moved is a plain variable and was
false on the first run, so the effect never read heading and had no dependencies.
When the view changed and heading was bound to the new <h1>, nothing re-ran. The
Shell test caught it: the focus stayed on <body>.
Why it bit. An effect tracks only the state it actually reads on each run. A condition that returns early hides every read after it.
How to apply it. In an effect, read the state you depend on before any early
return or && (const target = heading; if (moved) target?.focus();). Test the
re-run, not just the first run.
Svelte 5 state is a Proxy, and IndexedDB cannot clone a Proxy
What happened. On 2026-11-02 the sunset town was never saved in a real browser. The
search results lived in $state, which wraps objects in a Proxy. The town passed to
save was that Proxy, and IndexedDB's structured clone threw DataCloneError. Every
unit test passed. The e2e suite found it: after a reload, the garden asked again.
Why it bit. Anything that crosses a structured-clone boundary (IndexedDB,
postMessage, BroadcastChannel, structuredClone) refuses a Proxy, and Svelte 5
hands out Proxies wherever state is deep.
How to apply it. At every storage or messaging boundary, write a plain copy built
field by field (in @rosea/storage, the same shape check used on reading). Keep lists
that are only passed along as $state.raw. Test the boundary with new Proxy(value, {}).
svelte/motion reads matchMedia when it is imported
What happened. On 2026-11-17 the gardener's walk used Tween from svelte/motion. Every UI
test file failed at import: jsdom has no window.matchMedia, and the module reads it at load (for
its reduced-motion store), not when a tween runs.
Why it bit. An import with side effects breaks every file that imports it, even transitively, and the error points at the module, not at the component that needed it.
How to apply it. In packages/ui, animate with a small setInterval easing inside an
$effect (packages/ui/src/scene/Planet.svelte), reading reduced motion once through a guarded
matchMedia call. If svelte/motion is wanted later, stub matchMedia in the test setup first.