a200832cfb
docs/LETTER.md holds slots as comments only, so the player sees no change
until the author writes. The app bundles the letter at build time, a small
Markdown subset renders without {@html}, only https: and tel: become links,
and lint:copy now reads the letter. Review found turbo replaying a stale
build after the letter changed; docs/LETTER.md is now in its cache key.
38 lines
2.0 KiB
Markdown
38 lines
2.0 KiB
Markdown
# 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.
|