Skip to content

feat(text): follow log files and search text pages - #899

Merged
umputun merged 14 commits into
masterfrom
log-follow-page
Nov 5, 2026
Merged

umputun merged 14 commits into
masterfrom
log-follow-page

Conversation

@umputun

@umputun umputun commented Nov 5, 2026

Copy link
Copy Markdown
Owner

A plain click on a .log or .out path now opens the themed text page in follow mode: up to the last 5,000 lines within a 2 MB read, following the file's end as it grows. A path:line click stays the static page, and so does a clicked log on a session another Mac presents. Every text page also gets a find box like the terminal's, with keys for everything.

  • a log page reads only the file's end (2 MB at most), so a log of any size opens at once. It checks the file once a second while following and on screen, and reads only when it changed. Rotation, copytruncate and a missing file are picked up; binary data keeps the last text, marked unreadable
  • scrolling up pauses following, scrolling back to the bottom or Resume follows again. F toggles follow, G or End goes to the bottom, g or Home to the top
  • the find box matches TerminalSearchBar: case-insensitive, matches across highlight spans, N of M in a fixed slot, chevrons, and an X that clears. / or Cmd-F focuses it, n/N or Return/Shift-Return step and wrap, Esc clears. Search covers the shown text, counts and steps through every match, and paints a window of up to 5,000 of them where WebKit has CSS Custom Highlights. A step pauses a following log; a log update keeps the current match on its line
  • Cmd-F now belongs to whatever is on top: a visible page or overlay over the focused pane, or the quick terminal, never the terminal behind it. A floating overlay used to leave Cmd-F to the pane under it
  • the terminal find bar gets the same fixed counter slot and field width, so neither bar changes size while the count updates
  • control: session overlay open --text FILE --tail N / --follow-file, session overlay follow on|off|toggle and session overlay search TEXT | --next | --prev | --close, read back on htmlOverlays[].text (tail, following, lines, clipped, waiting, unreadable, search). A log page and a search are refused on a slot shown on another Mac, whose page cannot carry that state
  • CLAUDE.md gets the UI consistency norm: one key does one thing for what the user sees, existing behavior next to a change that breaks that is fixed with it, and an existing control is reused or matched

LogTail.snapshot keeps the last whole lines of a bounded read from a log's end: it starts one byte before the window, keeps a line longer than the window as its clipped end, holds back an unfinished UTF-8 character and refuses NUL or invalid UTF-8. HtmlOverlay carries the log request and its live state, written by host-free store setters: a follow change emits tree.changed, a tick report does not.
session.overlay.open takes tail and followFile with a text file: a tail alone shows the file's last N lines, follow-file follows its end with TextPage.defaultTail lines unless a tail is given. Either without --text, with --line or a tail outside 1...maxTail is refused before any source dispatch. session.overlay.follow on|off|toggle [--pane] sets whether a log page follows and answers following or paused. The tree reads back tail, following, lines, clipped, waiting and unreadable on htmlOverlays[].text, omitted on a plain text page. The CLI gets --tail, --follow-file and overlay follow.
BoundedFile.readTail reads the last bytes of a file of any size plus the byte before them, and returns nothing after one fstat when the file still has the stamp it was given. LogFollower checks the file by path once a second while its page follows and is shown, so a rotated, truncated or recreated log is picked up by the next check; it caches the snapshot and the paused scroll offset, builds the document from a fresh read on open and explicit reload and from the cache on a theme change, holds ticks until a rebuilt renderer reports ready, and reports to the store. A failed first read shows an empty waiting page that the next good read fills. text.js draws a sticky follow bar with no gutter, pauses on a scroll the user starts and resumes at the bottom or on Resume, and drops highlighting past the highlight cap on every update. A log page the presenting Mac would be handed is refused rather than shown without its state.
A plain click on a .log or .out file opens the log page with the last TextPage.defaultTail lines and follow on, checked from the file's end so a log of any size opens. A path:line click keeps the static page at that line, and a session the presenting Mac shows keeps the static page it is handed today.
Open.validate and overlayContent each crossed the cyclomatic complexity limit with the tail and follow-file checks; those checks now sit in Open.validateLog and textOnlyRefusal, in the same order and with the same errors.
The user guide covers a clicked .log or .out file opening as a following log page; the command reference documents --tail, --follow-file, session overlay follow and the new read-back; the bundled skill gets a trigger, a section and reference entries; the control-api rules record the log page's model, follower and remote refusal.
- check NUL bytes after the line cap, and drop the NUL hole copytruncate leaves ahead of new text
- keep the file stamp for a binary end so an unchanged file is not read again
- a pause from control drops an earlier scroll offset
- a horizontal scroll never changes following
A key or gesture does one thing for what the user sees and never reaches a layer behind it; existing
behavior next to a change that breaks this is fixed with it; a control that exists elsewhere in the
app is reused or matched, and its rendered look is shown before tests are written.
… top

Every text page gets a find box in its bar that matches the terminal's: case-insensitive matching over the
whole text, highlights through the CSS Custom Highlight API with a 5,000-range window, a fixed counter, and
page keys (/, n, N, F, G, g, Home, End). A step pauses a following log; a log update keeps the current match
on its line using the snapshot's start offset. session.overlay.search sets, steps or closes it, reads back as
htmlOverlays[].text.search, and is refused for other occupants and slots shown on a presenting Mac.
TextPageBridge owns the page side of every local text page, with LogFollower inside it for a log page.
Cmd-F now belongs to whatever is on top: a visible page or overlay over the focused pane, or the quick
terminal, never the terminal behind it. The terminal find bar takes the same counter slot and field width.
The user guide covers the find box, its keys and Cmd-F going to what is on top, and drops the removed
line count; the command reference documents session overlay search and its read-back; the bundled skill
gets a trigger, a section and a reference entry; the control-api rules record the search model and the
bridge that owns every local text page.
…k the requested tail

- the page tracks queries its field sent and not yet echoed, so a control query arriving between a keystroke and
  its echo ends with field, model and counts on the same query; reports carry their query and a mismatch is dropped
- CRLF and lone CR are line breaks on both sides: pushed text is normalized like the first document, and the
  follower's dropped, cut and full-eviction counts use the same rule, so a highlighted CRLF log keeps searching
- opening a log page validates the tail it will show, not the default one
- the docs name the real refusals: no overlay, not an html page, no text page, remote page
Copilot AI balanced review requested due to automatic review settings November 5, 2026 22:25

Copilot AI 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.

Copilot was unable to review this pull request because the user who requested the review has insufficient remaining quota. Try requesting a review at a lower effort level.

@cloudflare-workers-and-pages

cloudflare-workers-and-pages Bot commented Nov 5, 2026 •

Copy link
Copy Markdown

Deploying agterm with  Cloudflare Pages  Cloudflare Pages

Latest commit: b7884db
Status: ✅  Deploy successful!
Preview URL: https://ebdd28c8.agterm.pages.dev
Branch Preview URL: https://log-follow-page.agterm.pages.dev

View logs

A sticky bar as wide as body scrolled away when a wide page scrolled sideways, and its 100vw width ran the find box under a scroll bar that takes layout width. The bar is fixed to both edges, with body padding keeping the page below it.
@umputun
umputun merged commit 82c9f00 into master Nov 5, 2026
9 checks passed
@umputun
umputun deleted the log-follow-page branch November 5, 2026 23:01
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.

2 participants