Skip to content

feat(files): list a pane folder's Markdown files in Files, opt-in (#1196) - #3073

Merged
devswha merged 6 commits into
mainfrom
feat/files-markdown-docs
Nov 5, 2026
Merged

devswha merged 6 commits into
mainfrom
feat/files-markdown-docs

Conversation

@devswha

@devswha devswha commented Nov 5, 2026 •

Copy link
Copy Markdown
Owner

What changes

Part of #1196. The first slice of the Markdown documents panel: list, search and open. The safe
write route of #771 (#3064) merged while this was in progress, and a document opened from the new
tab opens in that same file viewer: with Settings > Edit text files on, it can be edited and saved
there, with #3064's revision check. Creating and deleting a document are not in this PR (follow-ups
on #1196).

  • Settings > Chat > Documents in Files (a device setting, off by default). Off, Files is
    exactly as it is today: three tabs, no new request.
  • On, Files gets a fourth tab, Documents: the Markdown files (.md, .markdown) under the
    pane's folder, newest first, each with the folder it is in and when it changed. A Filter
    documents
    field narrows them by path (Escape clears it before it closes Files), a Refresh button
    reads the list again (nothing polls), and a row opens the file in the existing file viewer, which
    renders it with its outline. It works in the dialog, in Files beside the pane, and on a phone's
    sheet.
  • Server: new read-only route GET /api/pane/docs?pane_id= -> PaneDocuments
    (shared/files.ts). In a repository it asks git afresh (git ls-files -co --exclude-standard,
    the same safe invocation as @-mentions), so ignored build output and node_modules stay out and
    Refresh sees a file made a moment ago. Outside a repository, it walks with the same caps but
    counts only Markdown files, so a folder of other files cannot crowd a note out. Every file found
    is statted and the newest 500 kept. The reads run on a file thread (a new documents task),
    stop after 2 s (a fixed bound), and count as a scan in the file pool, so at most two
    threads run them and file routes keep the rest. The request's abort reaches the task.
    truncated says when a cap or the time limit left files out; the tab then says "Some Markdown
    files here are not listed." and never claims the newest are shown.
  • Access: the route is gated like /api/pane/files. It is refused (403 read_only) to a
    watching device, on this PC and through another PC's route. It is forwarded to other PCs
    (MACHINE_PROXY_PATH). On a herdr-core machine's own server, whose files are on another
    machine, it answers 501 unsupported.
  • Phone layout: four tabs do not fit beside the title and Close at 390px (66px over), or in
    the narrowest docked panel (320px). There, and only while the fourth tab is shown, the tabs take
    the row under the title. With three tabs (the setting off), the header is unchanged.
  • An older PC that does not know the route gets its own message ("This PC's bridge cannot list
    documents yet.").

No new control is visible by default: the tab exists only behind its setting, and the composer is
not touched.

Design reference: Paseo's paseo-markdown-viewer plugin (a read-only Markdown list beside the
agent that opens each file in a reader) and the Codex app's side panel, which opens a .md file
next to Review. This slice follows Paseo's read-only list, inside Files, and leaves editing to
#771. @vibewriter-hand offered to build the editing slice on #771's write API: this PR adds no
editor and no write route, so create, save-a-new-note and delete remain open for that slice.

Screenshots

Demo fixtures, setting on (scripts/files-documents-demo-regression.ts).

Light Dark
1280, dialog
1280, beside the pane at its narrowest (320px)
390, sheet (tabs on their own row)
1280, a row opened beside the pane
390, the setting (off by default)

Validation

  • Failing first: the new rows in server/device-access.contract.test.ts (a watching device refused
    on this PC, its alias and another PC's route; a driving one answered), server/machine-proxy.test.ts
    (never forwarded for a watching device), server/hc-machines.test.ts (501 on a herdr-core
    machine's own server) and the paneDocuments cases in server/files.test.ts (newest first with
    sizes and times, skipped folders and git-ignored files left out, the cap and truncated) failed
    on the base (2d8581e) and pass now. New src/components/MarkdownDocuments.test.tsx (server order,
    open by absolute path, filter, an older PC's 404 told apart from a missing pane) and the
    filesDocuments rows in src/lib/settings.test.ts (off by default, kept in its own key).
  • New scripts/files-documents-demo-regression.ts (added to scripts/ci-browser.sh): off by
    default no Documents tab; on, the list in order, the folder named, no sideways scroll, the filter
    and Escape, a row opening the viewer; in the dialog, beside the pane at 320px and on a 390px sheet,
    where it checks that the four tabs and Close fit; light and dark.
  • Review round (7ff0796): server/files.test.ts gained a repository of 2,000 old notes plus a newer
    zz-newest.md (listed first), a non-git folder of 1,000 .txt files plus z-note.md (listed, not
    cut) and the 2 s budget (a zero budget answers cut); server/file-pool.test.ts gained "a Markdown
    listing counts as a scan". The three behaviour tests failed on 9456ed6 and pass now.
  • Second round (c94745f): server/file-pool.test.ts "runs one Markdown listing at a time, and a stuck one
    leaves commands scans both their threads" failed on b8d4fa7 and passes now.
  • bun run check fast: passed at c94745f (origin/main merged): workflow syntax, generated files,
    typecheck, build, unit tests 12420 pass, 0 fail.
  • Reviews: omo CLEAR at c94745f; Codex Terra (xhigh) CLEAR at c94745f after two fix rounds (findings
    and resolutions in the PR comments).
  • Browser regressions for the touched shared components (Files dialog and panel, file viewer,
    Settings) in the self-hosted CI runner image (herdr-ci-runner:local,
    scripts/ci-browser-parallel.ts, after bun run build, inside bun run check run), 12/12
    passed at 9456ed6 (files-documents again at 7ff0796, 4/4 locally): files-documents, files-panel, files-prompt, file-viewer, file-viewer-mobile,
    deep-link, diff-find, diff-line-notes, palette-local-page, settings-pages, file-text-size,
    text-file-edit.
  • Skipped locally: bun run check integration and the full browser lane (CI runs them).

)

Settings > Chat > Documents in Files (off by default) adds a Documents tab to
Files: the .md/.markdown files under the pane's folder, newest first, with a
filter and Refresh; a row opens the file viewer. Read only.

GET /api/pane/docs filters the @-mention inventory and reads sizes and times
on a file thread, capped at 2,000 names looked at and 500 listed. It is gated
like /api/pane/files: refused to a watching device, forwarded to other PCs,
501 on a herdr-core machine's own server.
# Conflicts:
#	server/file-pool.ts
#	server/file-tasks.ts
#	server/machine-api.ts
#	shared/files.ts
#	src/lib/api.ts
#	src/lib/i18n.test.ts
#	src/lib/i18n/files.ja.ts
#	src/lib/i18n/files.ko.ts
#	src/lib/i18n/files.zh.ts
#	src/lib/settings.legacy-fixture.ts
#	src/lib/settings.ts
@coderabbitai

coderabbitai Bot commented Nov 5, 2026 •

Copy link
Copy Markdown

Warning

Review limit reached

You've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository.

Next included review available in 42 minutes.

Check out review usage here.

View limit details

Limit details: You’ve used all 4 included reviews currently available.

Learn how review limits work.

Review configuration:

Run configuration

Commits

Reviewing files that changed from the base of the PR and between c72a895 and 336d218.

Files selected for processing: 35

  • DESIGN.md
  • changelog.d/files-documents-tab.md
  • docs/development.md
  • scripts/ci-browser.sh
  • scripts/files-documents-demo-regression.ts
  • server/device-access.contract.test.ts
  • server/dispatch.ts
  • server/file-pool.test.ts
  • server/file-pool.ts
  • server/file-tasks.ts
  • server/files.test.ts
  • server/files.ts
  • server/hc-machines.test.ts
  • server/machine-api.ts
  • server/machine-proxy.test.ts
  • server/pane-routes.ts
  • shared/files.ts
  • shared/protocol.ts
  • site/demo/transport.ts
  • src/components/FilesDialog.css
  • src/components/FilesDialog.tsx
  • src/components/FilesPanelRow.tsx
  • src/components/MarkdownDocuments.css
  • src/components/MarkdownDocuments.test.tsx
  • src/components/MarkdownDocuments.tsx
  • src/components/SettingsDialog.tsx
  • src/lib/api.ts
  • src/lib/i18n.test.ts
  • src/lib/i18n/files.ja.ts
  • src/lib/i18n/files.ko.ts
  • src/lib/i18n/files.zh.ts
  • src/lib/machineContext.tsx
  • src/lib/settings.legacy-fixture.ts
  • src/lib/settings.test.ts
  • src/lib/settings.ts
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

Share

… wherever it sorts (#1196)

Review round: a listing reads on its file thread for at most 2 s and counts
as a scan (at most two threads), and the request's abort reaches it. It
stats every Markdown file git lists, asked afresh, instead of the first
2,000 names, and outside a repository walks Markdown files only, so other
files no longer crowd a note out; any cap or the time limit marks the list
cut, which the tab says without claiming the newest are shown.
# Conflicts:
#	src/lib/settings.legacy-fixture.ts
#	src/lib/settings.ts
@devswha

devswha commented Nov 5, 2026

Copy link
Copy Markdown
Owner Author

Review round (omo + Codex Terra) on 9456ed6, fixed in 7ff0796:

  • HIGH (Codex, resource): a listing's stat loop ran on past its deadline, so a few listings on a slow disk could hold every file thread. Fixed with a fixed bound: a listing reads for at most 2 s, then answers what it read, marked cut. It counts as a scan in the file pool, so at most two threads run listings and file routes keep the others. The request's abort signal now reaches the task. Test: file-pool.test.ts "counts a Markdown listing as a scan" (failed before), plus the zero-budget case in files.test.ts.
  • MEDIUM (both, reproduced): the first 2,000 names were taken in path order, so a newer file past them was never seen while the tab said "newest". Fixed: every Markdown file git lists is statted and the newest 500 are kept. Test: 2,000 old notes plus zz-newest.md (failed before).
  • MEDIUM (both, reproduced): outside a repository, the shared walk's 1,000-per-folder share dropped a note behind other files, and truncated stayed false. Fixed: the listing walks Markdown files only, and any walk cap sets truncated. Test: 1,000 .txt files plus z-note.md (failed before). The cut-list note now reads "Some Markdown files here are not listed." instead of claiming the newest are shown.
  • LOW (both): Refresh within 5 s missed a new file (inventory cache). Fixed as a side effect: the listing asks git afresh.
  • Not changed, MEDIUM (Codex) / not a defect (omo): a tracked .md symlink pointing outside the folder is listed with its target's size and time. A driving device can already open that target through /api/fs/file, so nothing new is exposed, and in-folder links such as CLAUDE.md -> AGENTS.md stay listed. Not reproduced as user-facing harm, so no follow-up issue.

CodeRabbit hit its review limit on this PR, so it did not review this head.

A listing counted against the two scan threads, so two stalled listings
left a commands scan waiting until it timed out. It now runs only while no
other listing does, outside the scan count: commands scans keep both their
threads and file tasks keep one.
@devswha

devswha commented Nov 5, 2026

Copy link
Copy Markdown
Owner Author

Second review round on b8d4fa7 (omo: CLEAR; Codex Terra: BLOCK on one HIGH), fixed in c94745f:

  • HIGH (Codex, reproduced with the held-thread fixture): round one made Markdown listings count against the two scan threads, so two stalled listings left a commands scan waiting until it timed out. Fixed with a fixed cap: a listing now runs only while no other listing does, outside the scan count. Commands scans keep both their threads and file tasks keep one. Test: server/file-pool.test.ts "runs one Markdown listing at a time, and a stuck one leaves commands scans both their threads" failed on b8d4fa7 and passes now. Codex re-checked c94745f: CLEAR. A waiting listing starts when the running one returns, and an expired one keeps its slot until its thread answers.

Left as they are (MEDIUM/LOW, not user-facing in normal use; no follow-up issue):

  • When git's listing fails or passes its 16 MB cap (a repository of a few hundred thousand files), the listing falls back to the Markdown walk, which does not read .gitignore. An ignored .md can then be listed. A driving device can already browse and open those files.
  • The 2 s budget is checked between folders, not inside one: reading one very large folder can run past it. A single 30,000-file folder took 73 ms.
  • Cancelling the request does not stop the git ls-files it started. That process is bounded by its own 3 s deadline and 16 MB cap.
  • Each request starts its own git listing, and 64 queued listings behind a stuck one can fill the file pool's shared waiting queue. Reaching that takes dozens of concurrent requests from driving devices, and the existing file ops share the same queue limit.

# Conflicts:
#	src/components/SettingsDialog.tsx
#	src/lib/i18n.test.ts
#	src/lib/i18n/files.ja.ts
#	src/lib/i18n/files.ko.ts
#	src/lib/i18n/files.zh.ts
#	src/lib/settings.legacy-fixture.ts
#	src/lib/settings.ts
@devswha

devswha commented Nov 5, 2026

Copy link
Copy Markdown
Owner Author

Local merge gate (owner-approved): origin/main merged (settings/i18n lists only), bun run check fast passed at this head (12439/0), omo CLEAR at this head (Codex CLEAR earlier; two reproduced HIGHs closed by fixed caps), threads resolved; Files/Settings browser regressions 12/12 in the CI runner image. Opt-in Documents tab, off by default; GET /api/pane/docs is read-only, refused for watch devices, 501 on hc machine servers. Part of #1196. Merged without waiting for GitHub CI.

@devswha
devswha merged commit ff0b3d8 into main Nov 5, 2026
23 checks passed
@devswha
devswha deleted the feat/files-markdown-docs branch November 5, 2026 22:42
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