Skip to content

Open, edit and preview checkout files in the web shell - #139

Merged
yansfil merged 27 commits into
mainfrom
prd/web-shell-pivot-s3
Sep 23, 2026
Merged

yansfil merged 27 commits into
mainfrom
prd/web-shell-pivot-s3

Conversation

@yansfil

@yansfil yansfil commented Sep 23, 2026

Copy link
Copy Markdown
Contributor

Related: PRD agents/prd/web-shell-pivot-s3/prd.md · follows #132 (S2)

Summary

  • The web shell could run terminals but could not open a file: the sidebar listed directories only under $HOME, and nothing in the browser could read, edit, or save a file in a checkout.
  • hided now checks every Explorer path against the registered checkout roots by real path, refusing anything that resolves outside one (including through a symlink) with a reason code, and serves directory listings, a gitignore-aware file index, folder watches, file bytes, and attachment staging behind that one line.
  • The shell gains the Explorer tree (virtual rows, Seti icons, git colors), preview and pinned tabs, a CodeMirror editor with save, conflict choice, wrap, find and text scale, Markdown Live, and image, PDF and video viewers.
  • ⌘P opens a file by fuzzy name from the daemon's index, ⌘K searches the snapshot, and files dropped on a terminal pane or pasted from the clipboard become Herdr attachment tokens.
  • Unsaved buffers survive a disconnect in IndexedDB and are reconciled against the core's dirty documents on reconnect. herdr-core is unchanged.

Explorer tree with a preview tab open on main.ts; git status shows as a badge, wrap and find sit on the document header

clip.mp4 plays in the web shell; hided streams the bytes from inside the checkout boundary

Markdown Live hides the markup while the document stays editable

Review

  • 판단해 주세요: the boundary is the product decision in this PR - hided moves from "list directories under $HOME" to "read and write any path under a registered checkout". Everything else follows from accepting that line.
  • 조심해서 볼 파일:
    • hided/src/boundary.rs - the security line itself: real-path resolution, symlink escape, and the refusal codes a client can read.
    • hided/src/attachments.rs - the staging state machine; seven review rounds found a defect here each time, the last being release-on-disconnect and a cap charged to non-growing writes.
    • hided/src/server.rs - the frames that now carry file bytes and attachment chunks over the same socket as snapshot deltas.
    • hided/src/watch.rs and hided/src/index.rs - resident resources with caps (64 watched folders, 50,000 indexed files) that must report rather than degrade.
    • web/src/store.ts - the snapshot merge the Explorer and editor read from, on the high-frequency path.
  • 질문: is the accepted residual acceptable - the attachment module's own state-directory wipe follows a symlinked root (local process, same user)? And should the checkout boundary become configurable in S5 rather than derived from the snapshot's checkout list?

Evidence

  • 확인한 것: the sealed suite on head af5f914 (verify-cargo.sh test, verify-swift.sh test, verify-cargo.sh lint, all exit 0); 122 web unit tests; the full Playwright suite, 14 specs, each against an isolated pinned Herdr with a private HOME; hided 76 unit and 19 integration tests covering boundary escape (.., symlink, prefix sibling, unregistered root), staging lifecycle and byte caps; design-contract, workstation-identity and attribution checks. Terminal echo p95 median 0.89 ms against the Swift baseline 6.23 ms, 0 of 14,410 frames over the 16.7 ms budget.
  • 확인하지 못한 것: nobody has used this in a real session yet - the end condition (PRD B19: open a file from the Explorer in a live Herdr session, edit and save it, drop an image to an agent) is the user's own check and has not happened. There is no Playwright case for a boundary refusal because no UI path can name an outside-root path; that boundary is Rust-tested only. pr.yml CI runs from the pushed head for the first time here.
  • 생성물: design/hide.pen and design/tokens.json carry generated diffs from gen-pen.mjs and gen-tokens.mjs; the Seti subset font under web/public is a binary asset.

AI tooling: mostly AI tooling; the boundary module, the attachment state machine and every screenshot above were read by hand against the diff.

Verification record
  • PRD: agents/prd/web-shell-pivot-s3/prd.md (sha256 1823074e2df972857ae9dcbc1ff0eb1150d58c4ec71e7a7a6fae00bcf5353103)
  • Base f8d031a → head af5f914, verified 2026-09-23T02:16:12.886Z: PASS
  • Verification report: agents/runs/web-shell-pivot-s3/verification-report.json and agents/runs/web-shell-pivot-s3/verification-report.md; source fingerprint 2b0044dfb1283206a4f6e72a55215e53a8269d2cb4b6fe0f8ba9e44f24c18c0f
  • Suites:
    • S1: GREEN bash scripts/verify-cargo.sh test (exit 0)
    • S2: GREEN bash scripts/verify-swift.sh test (exit 0)
    • S3: GREEN bash scripts/verify-cargo.sh lint (exit 0)
  • Reviews: seven advisory rounds (fidelity, code, security in parallel each round), heads b28854c, c623c8a, 19e3412, 586f9fb, cec3320, d2acdcb, 9430412. Fix now findings and their disposition:
    • b28854c: attachment request_id joined into a path unsanitized (arbitrary write as the daemon user); file_bytes spun forever on a file that shrank mid-read; the root refresh read "rest": null as present and wiped the boundary roots; a refused byte read never settled the viewer; the Markdown checkbox toggle was not reported as an edit. All fixed in c623c8a with tests.
    • c623c8a: client-sent terminal_attachment* still forwarded (arbitrary absolute-path read); a Lagged notify read as shutdown; staged attachments bounded by count rather than bytes; attachment caps checked after arrayBuffer(); unbounded folderChanges. All fixed in 19e3412 with tests.
    • 19e3412: staged bytes could differ from their declaration; a cancel could unlink a fresh commit. Fixed in 586f9fb.
    • 586f9fb: duplicate-id check outside the insert's critical section (cross-connection TOCTOU); staged files not single-owner across runs. Fixed in cec3320.
    • cec3320: a clipboard commit could be satisfied by a stage opened with clipboard: false; make_room could evict the stage being written. Fixed in d2acdcb.
    • d2acdcb: a failed write_all left the stage open with uncounted bytes on disk; staged files created with the inherited umask (0644/0755); a batch could name the same stage twice; clipboard stage ids unvalidated. Fixed in 9430412.
    • 9430412: the count cap was charged to non-growing writes (a legitimate chunk refused at 511 entries); a client disconnect released nothing (descriptor, partial file and accounting held until 64 later stages). Fixed in af5f914 with tests.
    • af5f914 (current head): no Fix now item remains. Accepted residual: the module's own state-directory wipe follows a symlinked root (local process, same user).
  • Gates on af5f914 (outside the sealed suite): pnpm --dir web typecheck, lint, test (122), build; the full Playwright suite 14 passed (s2 2, s3 9, shell 3), each fixture starting an isolated pinned Herdr with SHELL=/bin/zsh beside a private HOME; node scripts/check-design-contract.mjs; bash scripts/check-no-workstation-identity.sh; python3 scripts/check-no-attribution.py; hided 76 unit + 19 integration tests.
  • Perf on af5f914: terminal echo p95 median 0.89 ms against the Swift baseline 6.23 ms, 0 of 14,410 frames over the 16.7 ms budget.
  • Evidence: 3 registered (2 screenshot, 1 log); paths are local to the run directory
    • agents/runs/web-shell-pivot-s3/artifacts/slice-11-screens/s3-explorer-expanded.png
    • agents/runs/web-shell-pivot-s3/artifacts/slice-11-screens/s3-viewer-video.png
    • agents/runs/web-shell-pivot-s3/artifacts/slice-11-perf/manifest.json
  • Changed paths: 75 (see Files changed)

hided now holds the registered checkout roots and resolves every path event against them before it reaches the core: a path outside every root is refused with outside_checkout, an explorer operation whose root does not match the focused checkout is refused the same way, and an item name that could escape its parent is refused as invalid_path. Attachment paths are bounded to eight files and 4096 bytes each.

The roots are refreshed from the core snapshot on a 250 ms timer and seeded before the server accepts its first client.
The Explorer needs the contents of one folder inside a registered checkout, which the registration line cannot answer: remote_file_list lists a target's checkout as directories only and hides dotted names, while a folder view shows files, keeps hidden entries and drops .git alone. A new client event file_list carries the root and the folder, and is answered with the same directory_list frame, which now names the asking event in a required kind field so a client routes one answer to the registration input and the other to the folder it is showing.

Rows follow the Swift rule: directories first, then a case-insensitive comparison in which a run of digits compares by value, so file2.txt precedes File10.txt. No crate was added for it, the comparator lives beside the listing in hided/src/boundary.rs. Entry gained is_directory, so the shared listing shape always carries the kind of row, and the home line answers true for every entry it lists.

A folder outside every registered root, a root that is not registered, and a symlink that leaves its root are refused as outside_checkout before anything is read.

The web store keeps the Explorer's folders in a listings map keyed by the root path and capped at LISTING_CAP, and leaves directoryList to the registration flow.

The checkout roots are refreshed from the core change notification the daemon already consumes for snapshot deltas, not from a timer: the roots change exactly when a snapshot can change, and the seed before the first client is unchanged.
The Explorer draws one checkout folder at a time and a large folder can hold
thousands of rows, so the row list is virtualized rather than rendered whole.
The Seti glyph accents were 21 hex literals inside SetiFileIcon.swift, so the
web shell could not render the same colours as the Swift outline. Move the five
accents into HideTheme as fileIcon{Blue,Green,Orange,Yellow,Purple}Hex, claim
them in design/tokens.json and scripts/pen-token-map.json, and regenerate
web/src/tokens.css and design/hide-ui.lib.pen from that authority.

The glyph table keeps its codepoints and only reads its colour from the token,
so SetiFileIconTests.swift counts the same set as before.
The Explorer rows draw their glyph from the same Seti subset the macOS shell
bundles, so the web shell serves those bytes from /assets with a font/woff
content type and declares the face with font-display: block. The glyphs are
private-use codepoints, so a fallback face would draw tofu for every row until
the font landed.
The Explorer needs its rows as data before any view draws them. fileIcons.ts
ports the Seti catalog onto the seven file colour tokens, and explorer.ts turns
a folder listing plus the git decorations into the flat row list a virtual list
can draw, carrying the git letter, its title, the riskiest descendant behind a
folder dot, and the tooltip and accessibility strings.

snapshot.ts and store.ts learn the editor and changes sections the core already
sends, so decorations and open file tabs have somewhere to land; the merge runs
before the frame routing, which answers a listing or a refusal with an early
return.

Ten tests cover entry order as the daemon sent it, indent from expanded_paths,
a closed folder that keeps its listing, an expanded folder with no listing, the
letter and title, folder risk priority, no decoration under an unrelated folder,
the tooltip text, and the root-relative path.
@yansfil
yansfil merged commit 5d25eee into main Sep 23, 2026
6 checks passed
@yansfil
yansfil deleted the prd/web-shell-pivot-s3 branch September 23, 2026 16:41
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