Skip to content

feat: search every view that renders text, not only a document - #692

Merged
andiwand merged 2 commits into
mainfrom
feature/search-every-view
Aug 16, 2026
Merged

feat: search every view that renders text, not only a document#692
andiwand merged 2 commits into
mainfrom
feature/search-every-view

Conversation

@andiwand

Copy link
Copy Markdown
Member

🤖 Generated with Claude Code

odr.search(), searchNext(), searchPrevious() and resetSearch() shipped
inside document.js, so only a document view had them — a pdf, a plain text
file, an xml source view and an archive listing had no search at all, and a
host's search bar did nothing on any of them.

The search code moves into its own search.js, with the mark rules as
search.css, and every view that renders text writes the pair. It is
format-agnostic: it walks the page's text nodes and knows nothing about how
they got there. The font specimen, image and media views get nothing — a glyph
grid and a <video> have no text to find.

Per view

  • pdf — the glyph layer is aria-hidden, which the walker now rejects by
    the subtree, so a hit lands in the text layer only rather than in both. There
    mark takes color:inherit, or the browser's own mark colour would paint
    the layer that is meant to stay invisible, and mix-blend-mode:multiply, or
    an opaque highlight would cover the glyphs it marks. The service also serves
    the two shipped resources now, which it never had to before.
  • text — the line-number gutter is aria-hidden for the same reason: the
    numbers are ours, not the file's, and a search for 1 should not find them.
    The editor reads a caret position through a <mark> instead of past it, so
    editing an editable view still lands the change where the caret is while a
    search is active.
  • xml — a hit inside a folded <details> opens it. xml/AGENTS.md said
    the view carries no script; it now says its only one is the shared search.
  • archive listing — searches the entry paths.

Testing

  • html.linked_resources_are_served covers the pdf service too, which is the
    one that had to learn to answer for a shipped resource.
  • Search driven from the console in Chrome on all five view kinds: hit count,
    step, reset, the pdf highlight over both text modes, the gutter staying out
    of the results, and an insert through a mark in the text editor.
  • Reference output regenerated: every page gains the link and the script,
    document.css/document.js lose what moved out.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: e3c83f589f

ℹ️ About Codex in GitHub

Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

Comment thread src/odr/internal/html/frontend.cpp
Comment thread src/odr/internal/html/pdf_file.cpp
andiwand and others added 2 commits August 16, 2026 09:41
`odr.search()` and its siblings shipped with the document script, so a pdf, a
plain text file, an xml source view and an archive listing had no search at
all. The search code moves into its own `search.js` (plus the `mark` rules as
`search.css`) that every one of those views writes.

- a pdf's glyph layer is `aria-hidden` and rejected by the walker, so a hit
  lands in the text layer only; `color:inherit` keeps that layer invisible
  under the highlight and `mix-blend-mode` keeps the glyphs readable through it
- the text view's line numbers are `aria-hidden` for the same reason, and its
  editor reads a position through a `<mark>` instead of past it
- a hit inside a folded xml section opens it

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
Claude-Session: https://claude.ai/code/session_0192ViykqXESAC9VM8Pv2R3u
@andiwand
andiwand force-pushed the feature/search-every-view branch from d7397cf to 0f1b1ee Compare August 16, 2026 07:41
@andiwand
andiwand merged commit 734ceac into main Aug 16, 2026
36 checks passed
@andiwand
andiwand deleted the feature/search-every-view branch August 16, 2026 07:56
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