Skip to content

fix(content): read links and page length in time near their size - #1700

Merged
gkhngyk merged 1 commit into
mainfrom
fix/bound-link-and-length-reads
Oct 28, 2026
Merged

gkhngyk merged 1 commit into
mainfrom
fix/bound-link-and-length-reads

Conversation

@gkhngyk

@gkhngyk gkhngyk commented Oct 28, 2026

Copy link
Copy Markdown
Contributor

Summary

Bounds the work on long or unusual input in two small readers the Content Editor and the Content Agent use, so each runs in time near its input's size:

  • linkKey (server content-links.js, web link-targets.ts): drops a link path's trailing slashes by reading back from the end of the path.
  • textLength (server page-content.js) and its web twin pageTextLength (rules.ts): read each tag once, left to right, in three small passes that stand for the three tag regexes they replace.

Output is unchanged: the new code gives the same key and the same count as before on every input checked (the existing tests' inputs, the repo's test files and fixtures, and several hundred thousand generated snippets of well-formed and sloppy markup).

Related issue

None.

Type of change

  • feat — New feature
  • fix — Bug fix
  • chore — Maintenance / dependencies
  • docs — Documentation only
  • refactor — Code change that neither fixes a bug nor adds a feature
  • test — Adding or updating tests

How to test

  • cd server && npx vitest run src/lib/content-links.test.js src/lib/content-rewrite.test.js: new cases read long links and long pages with tags left open within a generous time bound.
  • cd web && npx vitest run src/lib/content/link-targets.test.ts src/lib/content/rules.test.ts: the same for the web copies.
  • Nothing changes in the UI: the Rules tab's length and the agent's links read as before.

Checklist

  • Branch follows the naming convention (feature/, fix/, chore/, docs/) — see CONTRIBUTING.md
  • Commits follow Conventional Commits
  • yarn lint passes (run from web/)
  • yarn typecheck passes (run from web/)
  • yarn format:check passes (run from web/)
  • Changes are focused — one concern per PR

🤖 Generated with Claude Code

linkKey (server and web) drops a path's trailing slashes by reading back
from its end, and textLength / pageTextLength read each tag once, left to
right, giving the same counts as before on any markup.
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