Skip to content

web: S2 tabs, splits, zoom, shortcuts, registration and pane input in the web shell - #132

Merged
yansfil merged 33 commits into
mainfrom
prd/web-shell-pivot-s2
Sep 22, 2026
Merged

yansfil merged 33 commits into
mainfrom
prd/web-shell-pivot-s2

Conversation

@yansfil

@yansfil yansfil commented Sep 21, 2026 •

Copy link
Copy Markdown
Contributor

Related: PRD agents/prd/web-shell-pivot-s2/prd.md · follows #130 (S1)

Summary

S1의 웹 셸은 pane 하나만 그렸다. S2는 브라우저 페이지에서 탭·분할·줌, 프로젝트/체크아웃 전환, 단축키, 워크스페이스 등록, pane 스크롤까지 Swift 셸과 같은 동작을 낸다.
스냅샷의 pane_layouts를 그대로 그리고, attach 상태인 탭의 pane은 보이지 않아도 xterm 인스턴스를 살려 두어 탭을 돌아오면 마지막 화면이 즉시 보인다(첫 실사용에서 잡힌 "탭 전환마다 새로 렌더링"의 수정, PRD 개정 1).
분할선 드래그·탭 드래그·닫기 확인·최근 순환 오버레이·휠 스크롤이 코어 이벤트 하나씩으로 나가고, 줌된 pane은 캔버스 전체를 차지한다(실사용에서 잡힌 "특정 영역만 확대"의 수정).
pane 안의 단일 클릭은 Swift와 같은 규칙으로 terminal_click 하나가 되어 코어가 프로그램에 마우스 보고를 넣고(실사용에서 잡힌 "Claude Code 창에서 클릭이 안 됨"의 수정, PRD 개정 2), 드래그 선택의 복사는 xterm 대신 셸이 조립해 행 끝 패딩을 잘라내고 소프트랩 행을 다시 이으며, 줄들이 공유하는 앞 여백은 상대 들여쓰기를 남기고 걷어낸다("복사하면 trimming", "앞에서 trim까지"의 수정, PRD 개정 3). 클릭 셀은 호스트 요소가 아니라 xterm의 .xterm-screen 격자에서 읽는다(실사용 2차 보고 "여전히 클릭이 안 됨": 호스트 사각형은 아래 가장자리에서 한 행 어긋나 Claude Code의 "Jump to bottom (click)" 행을 비껴갔다). 시트·찾기·순환을 닫는 Escape는 더 이상 pane에 ESC 바이트로 가지 않는다.
단축키는 명령 -> {browser, electron} 한 표(web/src/shortcuts.ts)에서 나오고, Chrome이 잡는 ⌘T/⌘W/⌘⇧T/⌃Tab/⌘⇧N은 ⌥ 계열로 옮겨 ⌘/ 시트에 "moved for Chrome"으로 표시된다.
워크스페이스 등록은 hided가 $HOME 경계 하나로 막는다: 로컬 디렉터리 목록(remote_file_list, target_id: local)과 create_workspace 경로는 홈 밖이면 path_refused 사유 코드로 거절되고 코어에 닿지 않는다.

두 번 분할한 탭: 활성 탭의 pane 세 개가 각각 xterm 인스턴스를 갖고, 헤더가 포커스 pane을 표시한다

⌘/ 시트: 한 표에서 생성되고 Chrome 예약 키에서 옮긴 명령은 이전 조합을 함께 보여준다

홈 밖 경로 등록 시도: 이벤트가 나가기 전에 셸이 한 줄로 거절한다

⌘⌥↩ 줌: 줌된 pane이 캔버스 전체를 차지하고 Herdr가 넓힌 PTY와 같은 폭으로 그려진다(수정 후)

Review

  • 판단해 주세요: 경계는 파일시스템에 홈 안의 경로만 묻는다. 홈 밖 경로와 홈 밖을 가리키는 심볼릭 링크는 존재 여부와 무관하게 outside_home 하나로 답하고, 홈 안을 가리키는 외부 링크도 거절된다. 이 엄격함을 받아들일지.
  • 판단해 주세요: attach 상태 pane 9개의 인스턴스를 숨긴 채 계속 먹이는 비용(렌더러 RSS 167~226 MB, hided 19 MB, 120 s 구동 후에도 증가 없음)을 받아들일지. D-05의 재검토 조건은 이 숫자가 B15 게이트를 넘을 때다.
  • 판단해 주세요: Chrome 예약 단축키를 ⌥T/⌥W/⌥⇧T/⌥`/⌥⇧N로 옮긴 배치와 시트의 "moved for Chrome (⌘T)" 문구.
  • 판단해 주세요: 복사의 소프트랩 판정은 "마지막 셀이 비어 있지 않은 행은 다음 행으로 이어진다"는 전폭 행 휴리스틱이다. Herdr의 terminal.frame 레코드(seq·encoding·width·height·full·bytes)에는 이어짐 플래그가 없어 폭을 정확히 채운 하드 라인도 합쳐진다. 이 정도를 받아들일지, Herdr에 플래그를 요청할지.
  • 판단해 주세요: 복사의 dedent는 드래그 시작 열이 0보다 크면 잘린 첫 줄을 여백 계산에서 빼고 나머지 줄로 여백을 정한다(단독 줄이면 그 줄의 앞 공백 전부). 이 규칙을 받아들일지.
  • 판단해 주세요: 코어의 포커스 규칙 - Herdr가 이전 요청의 확인을 다음 요청 뒤에 보내면 코어가 그 확인을 따라 포커스를 잠깐 이전 pane으로 되돌린다(CI 러너에서 ~200 ms). 이 PR은 e2e가 herdr pane current를 기다리도록만 했고 코어(herdr-core)는 범위 밖이라 그대로다. 후속으로 다룰지.
  • 판단해 주세요: 로컬 목록이 코어의 remote_file_list를 빌려 쓰는 결정(hided가 target_id: local만 가로채 directory_list로 답하고, 다른 target은 손대지 않고 전달).
  • 조심해서 볼 파일: web/src/terminals.ts - 고빈도 경로이자 ownership. 숨긴 탭의 청크도 파싱하고, 인스턴스 해제는 코어의 released·소멸에만 따른다(retainTerminals). 휠·클릭·복사는 각각 주인이 하나다: capture 리스너가 xterm보다 먼저 이벤트를 받아 애니메이션 프레임당 terminal_scroll 하나, 드래그하지 않은 누름-놓음당 terminal_click 하나를 내고, 복사 텍스트는 xterm의 것을 막고 selection.ts가 만든다. Herdr 프레임은 마우스 모드를 싣지 않으므로 xterm 자체 마우스 보고는 켜질 수 없다(격리 서버에서 프레임 바이트로 확인). 키보드 포커스 보고자도 하나다: 스냅샷을 따라 term.focus()를 부르는 동안(followingSnapshot) textarea focus 리스너는 focus_pane을 내지 않는다(CI에서 잡힌 셸↔코어 포커스 핑퐁의 수정).
  • 조심해서 볼 파일: hided/src/boundary.rs - 경계 그 자체. 홈부터 컴포넌트 하나씩 내려가며 심볼릭 링크 대상을 쓰인 그대로 홈과 비교한 뒤에야 따라간다. 리뷰 4라운드에서 세 번 조여졌다.
  • 조심해서 볼 파일: hided/src/server.rs apply_boundary - dispatch 경로의 유일한 필터. 여기서 빠지는 kind는 코어로 그대로 간다.
  • 조심해서 볼 파일: web/src/PaneGrid.tsx - 줌이면 줌된 pane 노드만 루트로 그린다; 분할선 놓을 때 resize_pane 한 번; 기하는 Herdr가 확정한 뒤 스냅샷으로 돌아온다.
  • 조심해서 볼 파일: web/src/store.ts - 델타마다 rest 구조 공유 walk가 붙는 고빈도 경로.
  • 조심해서 볼 파일: .github/workflows/pr.yml - e2e 실패 시 격리 fixture의 로그(hided, Herdr 서버, 각 에이전트 pane의 PTY 입력)와 Playwright 결과를 artifact로 올린다. 모두 fixture 전용 HOME 아래 것이고 저장소에는 들어가지 않는다.
  • 조심해서 볼 파일: contracts/hided-ws.schema.json - 서버 프레임에 directory_list, path_refused, error 셋이 늘었다(wire 계약).
  • 질문: 등록 필드의 최근 경로 5개를 localStorage에 두는 것으로 충분한지, 아니면 코어 workspace_registrations만으로 갈지.

Evidence

  • 확인한 것: B15 응답성(인스턴스 9개 유지, head 9ad830a; 이후 커밋은 인스턴스 해제 경로만 건드림) - 4분할 + 5탭 시나리오에서 echo p95 0.635/0.716/0.93 ms(중앙값 0.716 ms, 게이트 11.228 ms), 120 s 구동 창 14401 프레임 중 16.7 ms 초과 0, 최대 14.6 ms. 격리 herdr 0.9.1, 릴리스 hided, 한 번 측정. 메모리는 정착 후와 구동 후 두 번: 렌더러 167226 MB, hided 1819 MB, JS 힙 13→12 MB, 살아 있는 인스턴스 9개 그대로.
  • 확인한 것: e2e 5건(격리 herdr, headless Chromium) - 체크아웃 2개·탭 3개·분할 2개·줌(줌된 pane의 박스 = 캔버스 박스; 이 단언은 이전 렌더러에서 실패해 사용자 보고를 재현했다)·seq 1 100 뒤 휠 올림 → terminal_scroll {up, lines>1} 1건과 viewport 이동, 휠 내림 → 복귀, ⌥+휠 무시, 셸과 less(대체 화면) 모두에서 휠로 key 이벤트 0건(xterm의 커서키 변환 차단; 실사용 2차 보고의 수정)·분할선 드래그·탭 드래그·닫기·⌘/ 시트 25행·⌘F·재접속·탭을 떠났다 돌아올 때 클릭과 같은 tick에 마지막 화면 존재(new_view: false)·보이는 pane을 닫으면 인스턴스와 주차 요소가 사라짐·에이전트 pane의 (4,2) 셀 클릭 → focus_pane 뒤 terminal_click {column 4, row 2, modifiers 0} 1건, 그 pane의 PTY가 받은 바이트는 정확히 ESC[<0;5;3M ESC[<0;5;3m뿐(raw 모드 shim이 stdin을 파일로 기록)이고 key 이벤트 0건·드래그 선택은 클릭 0건이고 paneSelection과 navigator.clipboard가 모두 'w'×(cols+7) + '\nshort\n'(랩 행 합침, 패딩 제거, 빈 행 유지)· in/ deeper 두 줄 드래그의 클립보드가 in\n deeper(공유 여백 제거, 상대 들여쓰기 유지)·클릭 셀 계산의 호스트 대 화면 격자 차이를 매 실행 출력(로컬: 호스트 494×659 대 화면 488×656, 61×41 격자에서 마지막 행의 중심을 호스트로 읽으면 40행)·⌘/ 시트를 Escape로 닫을 때 key 0건·사이드바 숨긴 채 ⌥⇧N, 등록 1건 성공, 홈 밖·..·중복 거절. s2.spec은 Escape 수정 뒤 로컬 18회 연속 통과. CI의 web 레인은 67fae10·20f8516에서 붉었다: artifact로 올린 wire trace(20f8516)가 셸이 스냅샷의 포커스 pane을 다시 focus_pane으로 보고하는 핑퐁을 보여 주어 보고자를 하나로 줄였고(6daad15), 그 뒤 남은 한 번의 실패는 Herdr가 이전 요청의 확인을 늦게 보내 포커스가 잠깐 되돌아가는 것이어서 e2e가 5회 연속 같은 pane을 볼 때까지 기다린다(bdb3ace). d65a584에서 CI 6개 체크 통과와 web job 재실행 3회 모두 성공.
  • 확인한 것: 실제 Claude Code 2.1.278로 격리 pane에서 - PTY 원시 캡처로 요청 모드는 ?1000h ?1002h ?1003h ?1006h(SGR)이고, herdr terminal session control로 넣은 ESC 바이트는 걸러지지 않으며 press+release를 한 번의 write로 보내도 받는다: 휠을 올려 21행에 "Jump to bottom (click) ↓"가 뜬 상태에서 terminal.input 한 번(ESC[<0;37;22M ESC[<0;37;22m)으로 사라졌다(두 번 재현, agents/runs/web-shell-pivot-s2/click-probe/transcript.txt). 즉 전달 경로는 맞고 남은 원인은 셀 계산의 한 행 어긋남이었다.
  • 확인한 것: 경계 공격 - 홈 밖 심볼릭 링크(직접·중첩·끊긴 링크·상대 .. 링크·41단 체인·루프), .., %2e%2e, 파일 경로, 숨김 디렉터리, 홈 자체, 접두사 형제, 상대·빈·NUL 경로, 8000바이트 경로, 비문자열 JSON 필드, 대소문자 표기, HOME이 심볼릭 링크인 경우를 단위 테스트와 실제 WS 클라이언트로 쳤고 모두 거절 또는 무해. 홈 밖 경로의 존재 여부는 어떤 사유 코드로도 새지 않는다.
  • 확인한 것: 원격 target의 remote_file_list는 경계를 거치지 않고 코어에 닿는다(핸드셰이크 테스트가 코어의 remote.files.unknown_target 진단으로 확인).
  • 확인한 것: cargo test 워크스페이스·verify-swift test·clippy, web typecheck/lint/vitest 63건, check-design-contract, 구조 검사 스크립트 전부 통과.
  • 확인하지 못한 것: B18 하루 실사용 - 사용자의 실사용이 다섯 가지(탭 전환 지연, 줌 클리핑, 휠이 입력 이력을 넘김, 클릭 무반응, 복사 패딩)를 잡았고 이 PR이 고쳤지만, 고친 빌드(화면 격자 셀 계산)의 실사용 클릭 관찰은 아직 사용자 몫이다; 격리 pane의 실제 Claude Code에서는 바이트가 닿았다. 코어의 클릭 라우팅(감지된 Claude 에이전트에만 SGR)은 바꾸지 않았다. 실제 원격 기기의 목록 왕복도 미검증(코어 진단까지만 확인).
  • 확인하지 못한 것: 경계 검사와 코어의 git init 사이 TOCTOU(디렉터리를 심볼릭 링크로 바꿔치기)는 208k 요청의 실시간 경합에서 재현되지 않았고 fd 고정(openat) 걷기는 후속으로 남겼다.
  • 확인하지 못한 것: Electron 열은 비어 있고(등록만), 한국어 IME 조합 중 단축키 무시는 isComposing 분기와 단위 테스트로만 확인했다. 측정은 한 기계 한 번이며 다른 pane은 유휴 상태였다.

AI tooling: 대부분 AI 도구. PRD 결정 9개와 동작 20개를 코드·문서와 대조했고, Fidelity/Code/Security 리뷰(경계 4라운드 + B18 수정 5라운드)의 Fix now를 모두 반영한 뒤 verify를 다시 돌렸다.

Verification record
  • PRD: agents/prd/web-shell-pivot-s2/prd.md (sha256 7ecf1ff0bbfa423089092ca8b919c814a70613ee8213512154dcabd14cba194a)
  • Base 2b6f452 → head 84cee6b, verified 2026-09-22T04:19:06.833Z: PASS
  • Verification report: agents/runs/web-shell-pivot-s2/verification-report.json and agents/runs/web-shell-pivot-s2/verification-report.md; source fingerprint 541118bffe2754dd9e297bc3924c2724c84e51a2ab58a2a87e32cb5cb60ff4bc
  • Amendment 1 (human, 2026-09-22, recorded through sasu implement amend): D-05 instances stay alive for attached tabs, B5 reworded, B19 added (pane scrolling, zoom geometry); the earlier snapshot is archived as amendments/prd-1-superseded.md.
  • Amendment 2 (human, 2026-09-22, recorded through sasu implement amend): B20 added (pane click routing, selection copy, consumed Escape); the earlier snapshot is archived as amendments/prd-2-superseded.md.
  • Amendment 3 (human, 2026-09-22, recorded through sasu implement amend): B20 refined (dedented copy keeping relative indentation, click cell read from the xterm screen grid); the earlier snapshot is archived as amendments/prd-3-superseded.md.
  • 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 (advisory, fifteen heads, all native subagents):
    • Fidelity: 38eab30 Fix now none (follow-ups: non-local listing boundary, drag guide on reconnect, cycle overlay cap, ⌘⌫ wording); be4296f none; 0f4453a none; abe5a24 none, disposition: all 18 behaviors met, B18 left to the user by the PRD's own text.
    • Code: 38eab30 Fix now (1) non-local remote_file_list forced through the local boundary, fixed fc6ae6e; (2) registration field re-requested a listing on a stale answer, fixed be4296f. be4296f none (follow-ups: spawn_blocking for boundary I/O, overlay flag on a dropped dispatch, no test for the hidden-sidebar path, added 0f4453a). 0f4453a none (follow-up: depth cap before the walk). abe5a24 none (follow-ups: final canonicalize error mapping, queue growth note, normalize comment).
    • Security: 38eab30 Fix now (1) same scoping bug, fixed fc6ae6e; (2) canonicalize before containment leaked existence of any path on disk, fixed fc6ae6e (lexical test first). be4296f Fix now: existence leaked past an escaping symlink when the tail stops resolving, fixed 0f4453a. 0f4453a Fix now: a dangling symlink under home to an outside target leaked existence (ancestor walk only saw the parent), fixed abe5a24 (component walk from home, target tested as written). abe5a24 none; 208k live requests racing a dir/symlink swap produced no leak; follow-ups: fd-anchored walk (openat) for the TOCTOU class, case-insensitive spelling over-refuses, log volume.
    • 8d97a42 (fixture home /Users/me -> /home/me after CI's workstation-identity check): Code Fix now none; Fidelity and Security surfaces unchanged by a test constant, their abe5a24 dispositions stand.
    • 9ad830a (B18 fixes, amendment 1): Fidelity none (follow-ups: memory gate is informational, sign-convention comment); Security none (follow-ups: clamp lines to u16, int-cast the port; both done in c31b377); Code Fix now: a pane closed while shown was parked forever because retainTerminals ran before the view unmounted, fixed c31b377 (the park checks the attached list itself, one disposal path, e2e asserts the instance is gone).
    • c31b377: Code none (follow-ups: pass the observed rest through instead of re-reading the store; a reconnect snapshot that omits a pane disposes its instance and rebuilds it on reattach). Fidelity and Security surfaces unchanged by that delta.
    • fbd83d7 (B18 round 2: a wheel in a full-screen program also walked its input history because xterm turned the wheel into cursor-key bytes; the capture listener now stops the event before xterm): Code none, Fidelity none; Security surface unchanged (fewer bytes reach the PTY).
    • c46a91f (B18 round 3, amendment 2: a click in a pane now goes out as one terminal_click after focus_pane, mirroring the Swift pointer routing; a drag selection copies trimmed and unwrapped text assembled from the buffer cells; an Escape the shell answers stops at the window capture listener; hided logs ws.snapshot_failed): Fidelity none (follow-ups: rowContinues reads only the last cell, snapshot-failure log unthrottled, modifiers read at release); Code none (follow-ups: no unit test for log_snapshot_failure, press state cleared only by the next mousedown when released outside the pane); Security none (follow-ups: the core does not clamp column/row to the pane grid, a comment pinning that ws.snapshot_failed never carries pane content, a parked pane's stale selection is unreachable while hidden).
    • 67fae10 (e2e only: the click and the refocus wait for herdr pane current before typing, after CI's slower runner saw Herdr's late focus confirmation flip keyboard focus mid-command): Code none (follow-ups: the same wait at the first focus after ⌘D, a comment on the exempt sites, move the helper into the fixture); Fidelity and Security surfaces unchanged by a test wait.
    • 20f8516 (CI only: the web job keeps the daemon, Herdr server and PTY input logs and uploads them on failure, and HIDE_E2E_TRACE narrates the wire, after a second runner failure at the same step showed only screen text): Code none (follow-ups: the trace's focused_pane_id match reads the first tab layout in a frame, artifact retention is the repo default); Fidelity and Security surfaces unchanged.
    • 6daad15 (the shell reported keyboard focus back to the core when it only followed a snapshot, which the CI wire trace showed as a focus ping-pong between the two panes; the textarea focus listener now stays quiet while focusTerminal runs): Code none (follow-ups: the store guard compares against terminal.pane_id rather than the layout focus; a module flag would need rework if focusTerminal ever became async); Fidelity and Security surfaces unchanged.
    • d65a584 (B18 round 4: the click cell is read from xterm's .xterm-screen rect instead of the host element, which drifted a row at the bottom edge; the shell reports keyboard focus once, not again when it follows a snapshot; the copy is dedented; e2e waits for a settled focus; amendment 3): Fidelity none (follow-ups: the click-probe transcript lives only in the run directory, the host-vs-screen delta is printed not asserted); Code Fix now: dedent no-oped when the drag started past column 0 because the cut first line contributed an empty margin, fixed c9f4b9a (the cut line stays out of the margin unless alone, three vitest cases); Code follow-ups: cache the screen element at open, the null guard is unreachable; Security none (follow-ups: the workflow comment promised Playwright traces the config does not write, corrected c9f4b9a; a comment on why the auth frame never reaches the wire trace; assert HIDE_E2E_SCREENSHOT_DIR is absolute).
    • c9f4b9a: Code Fix now: the workflow comment now claimed screenshots under test-results that the Playwright config never writes, corrected 84cee6b; follow-up: a vitest case for a cut first row that continues, added 84cee6b.
    • 84cee6b: Code Fix now none, no follow-ups (the artifact comment matches Playwright 1.63 defaults; the joined-cut case hand-traced to its expectation).
  • Evidence: 29 registered (10 file, 9 screenshot, 10 log); paths are local to the run directory
    • agents/runs/web-shell-pivot-s2/measure/1/echo-summary.json
    • agents/runs/web-shell-pivot-s2/measure/1/frames-summary.json
    • agents/runs/web-shell-pivot-s2/measure/1/page.json
    • agents/runs/web-shell-pivot-s2/measure/1/identity.txt
    • agents/runs/web-shell-pivot-s2/e2e/s2-projects-two-checkouts.png
    • agents/runs/web-shell-pivot-s2/e2e/s2-two-splits.png
    • agents/runs/web-shell-pivot-s2/e2e/s2-zoomed.png
    • agents/runs/web-shell-pivot-s2/e2e/s2-shortcut-sheet.png
    • agents/runs/web-shell-pivot-s2/e2e/s2-registration-refused-outside-home.png
    • agents/runs/web-shell-pivot-s2/e2e/s2-registration-alpha.png
    • agents/runs/web-shell-pivot-s2/e2e/s2-after-reconnect.png
    • agents/runs/web-shell-pivot-s2/transcripts/web-unit.txt
    • agents/runs/web-shell-pivot-s2/transcripts/web-e2e.txt
    • agents/runs/web-shell-pivot-s2/e2e-2/web-e2e.txt
    • agents/runs/web-shell-pivot-s2/e2e-2/web-unit.txt
    • agents/runs/web-shell-pivot-s2/e2e-3/web-e2e.txt
    • agents/runs/web-shell-pivot-s2/e2e-3/web-unit.txt
    • agents/runs/web-shell-pivot-s2/measure/2/echo-summary.json
    • agents/runs/web-shell-pivot-s2/measure/2/frames-summary.json
    • agents/runs/web-shell-pivot-s2/measure/2/memory-settled.json
    • agents/runs/web-shell-pivot-s2/measure/2/memory-after-frames.json
    • agents/runs/web-shell-pivot-s2/measure/2/page.json
    • agents/runs/web-shell-pivot-s2/measure/2/identity.txt
    • agents/runs/web-shell-pivot-s2/e2e-4/web-e2e.txt
    • agents/runs/web-shell-pivot-s2/e2e-4/web-unit.txt
    • agents/runs/web-shell-pivot-s2/e2e-4/s2-zoomed.png
    • agents/runs/web-shell-pivot-s2/e2e-4/s2-two-splits.png
    • agents/runs/web-shell-pivot-s2/e2e-5/playwright-transcript.txt
    • agents/runs/web-shell-pivot-s2/click-probe/transcript.txt
  • Changed paths: 57 (see Files changed)

remote_file_list and create_workspace paths are resolved to their real
path and must sit under $HOME before they reach the core; a miss is
answered as a path_refused frame with a reason code and logged. The
local target's remote_file_list is answered by hided itself as a
directory_list frame (subdirectories only, no hidden names, no symlink
that leaves home, capped) because the core has no local listing event.
Both frames and the reason codes join contracts/hided-ws.schema.json.
The web shell has no other way to know $HOME; the answer's root_path is
the real directory, and ~/... registrations resolve the same way.
The store keeps the core's rest section structurally shared across
frames so an untouched workspace, tab or pane row keeps its reference
and its memoized row does not re-render. The center renders the tab's
layout as nested CSS grids; every leaf mounts its own xterm instance
and panes of other tabs have none. A divider drag moves a guide line
and sends one resize_pane on release, or nothing outside the core's
range. Zoom lifts the focused pane over the others. Text scale follows
the core's per-pane value and the new fit goes out as terminal_resize.
Tabs come from the checkout strip; a click focuses, + creates with the
core's next label, a drag that lands sends one reorder_tab. Closing a
tab or pane mirrors the Swift shell: an unknown activity status asks
for a refresh first, a working pane asks once, an idle one closes with
confirmed false. A close the core is still confirming shows closing…
from async_operations. Every command lives in actions.ts so a shortcut
and a button run the same code.
The Projects mode draws pinned rows, the activity list with the
inactive-project fold per device and the inactive-checkout fold per
project, with branch, PR badge and purpose read-only. A checkout row
sends focus_checkout; a project row goes to its last focused checkout.
The registration input lists directories from hided, offers recent
registrations first, refuses what the snapshot already answers under
the input, and shows hided's reason code in the same line.
One table maps each command to a browser chord; the Electron column is
empty until that host exists. Chords match on the physical key at the
window capture phase ahead of xterm and Chrome's defaults, never during
IME composition. The six chords Chrome reserves and ⌘⇧W moved to the ⌥
family and the sheet marks them. ⌥` and ⌥Tab cycle recent tabs and
projects while ⌥ is held and commit one focus event on release.
Two checkouts, three tabs and a fourth from ⌥T, the ⌥` cycle, a second
split from ⌘D, zoom, a divider drag that sends one resize_pane, a tab
reorder, ⌥⇧W and ⌥W closes, the ⌘/ sheet, ⌘F, a socket drop that comes
back with the layout, and a registration flow with a shell refusal, a
hided refusal and a duplicate. The fixture exposes the workspace, tab
and a CLI runner; hided's log is kept as run evidence when a directory
is given. The tab drag keeps its state in a ref because pointer events
outrun a continuous-priority render.
…and the multi-pane scenario

ARCHITECTURE's hided section gains the pane and attach rules of the
web shell, the $HOME boundary as hided enforces it, and the shortcut
registry table with an empty Electron column. The measurement harness
gets MEASURE_SCENARIO=multi (four splits beside the measured pane, five
attached tabs) and records the shape it started from in page.json; the
probe exposes the attached pane ids for that check. BUILD, CONTRIBUTING
and PERFORMANCE_TESTING name the command.
…-home paths before reading the disk

apply_boundary keyed only on the event kind, so a remote_file_list for a
remote target was checked against the local $HOME and refused or had its
root_path rewritten to a local canonical path. Only the local target is the
web shell's autocomplete; any other target now passes through as it came.

resolve_dir canonicalized before the containment test, so the refusal reason
(not_found vs outside_home) told a client whether an arbitrary path outside
home exists. The path as written is now tested against home (canonical and as
HOME spells it) before the filesystem is read; the real-path test still runs
for paths under home so an escaping symlink is refused.

The refusal log line caps the client-supplied path at LOGGED_PATH_CAP.
… when registering

The registration field cleared its pending-request mark on any listing that
arrived, so an answer to an earlier root let the same directory be requested
again; only the answer whose root_path matches the request clears it now.
The home request stays matched by being the field's first.

⌥⇧N opens the field inside the sidebar, so a hidden sidebar is made visible
by the same action instead of opening the field where it cannot be seen.
…⌥⇧N with the sidebar hidden

A path written under home that crosses a symlink leaving home and then
stops resolving answered not_found or not_a_directory from the OS error,
which described the disk beyond home. The nearest ancestor that resolves
now decides: outside home, the reason is outside_home whatever lies deeper.

The registration e2e hides the sidebar with ⌘B before ⌥⇧N and asserts the
sidebar returns with one ui_state_update and the field opens.
… target is tested as written

canonicalize() followed a symlink under home to a target outside home and
reported the OS error about that target, so a dangling symlink a client
planted under home answered not_found or outside_home depending on whether
the target exists. The walk now replaces a symlink by its target as written
and refuses a target outside home before reading anything there; the chain
is bounded by SYMLINK_HOPS and a loop is invalid_path. The accepted path is
still the OS canonical spelling.
check-no-workstation-identity refuses /Users/ in tracked files; the fixture
home is now /home/me.
…pane over the whole canvas, scroll through terminal_scroll

Leaving a tab disposed its xterm instances, so coming back showed an empty
'starting…' pane until a full frame arrived. An instance now lives as long
as the core streams its pane: parked in a hidden lot while its tab is not
shown, still fed, and re-parented on return so the last frame is on screen
in the same tick; only a released or vanished pane loses its instance.

The zoomed pane was positioned against its own split cell and clipped to
half the canvas while Herdr had already widened the PTY. A zoomed tab draws
only the zoomed pane, at canvas size, so its fit follows the full geometry.

A wheel over a pane becomes whole rows by the Swift PaneScrollPolicy and
goes out as one terminal_scroll per animation frame; xterm scrollback is 0
and the core's viewport frame is what the pane shows. ⌥ + wheel is the
browser's.

The S2 e2e asserts all three on an isolated Herdr: the zoomed pane's box
equals the canvas, seq 1 100 scrolls up and back, a tab switch leaves the
echoed text in the parked instance and shows it before any frame.
retainTerminals ran inside the store update, before React unmounted the
closed pane's view, so the shown instance was skipped and then parked for
good. The park now checks the core's attached list itself and disposes
right away; the attached list is one function in terminals.ts. A scroll
burst is clamped to the core's u16 line count, and the e2e asserts the
closed pane's instance is gone and the parking lot is empty.
xterm turns a wheel over a buffer without scrollback into cursor-key bytes
on the PTY, so a wheel in a full-screen program (and in the shell) walked
the program's history while terminal_scroll moved the viewport. The capture
listener now stops the event before xterm sees it; ⌥ + wheel is stopped
the same way and left to the browser. The e2e asserts no key event goes
out for a wheel in the shell and in less, on an isolated Herdr.
A single primary click in a pane that never left its cell is replayed on
release as one terminal_click with the pressed cell, after the focus_pane
the press sent, mirroring the Swift pointer routing: a drag selects
locally, option-press and a multi-click stay local. The core decides
whether the program gets a mouse report; xterm's own mouse reports never
fire because Herdr's frames carry no mouse mode.

Herdr redraws every row in place, padded to the full width, so xterm's
selection copied the padding and broke soft-wrapped lines. The copy is
assembled from the buffer cells instead: trailing whitespace trimmed, a
row whose last cell is non-blank joined onto the next, real line ends
kept. The frame record has no continuation flag, so a hard line that
exactly fills the width is joined too.

An Escape the shell answers (a cycle, a close confirmation, the sheet,
the find bar) stops at the window capture listener; the pane's textarea
keeps focus under the sheet and xterm sent the same press to the program
as an ESC byte, which a raw-mode program then read together with the next
key.

The e2e agent shim now reads the terminal raw and appends every byte it
gets to a per-pane log, so the test asserts the PTY received exactly the
SGR press and release the core produced and nothing else, that a drag
sends no click, that the clipboard holds the trimmed and unwrapped text,
and that the sheet's Escape sends no key.
A snapshot the daemon cannot produce (core owner thread gone, empty read,
undecodable bytes) ended the client loop with nothing recorded, and the
browser only saw a bare close. The failure is now a ws.snapshot_failed
record with its stage before the loop ends.
@yansfil yansfil changed the title Web shell S2: tabs, splits, zoom, checkout switching, shortcuts and the $HOME boundary S2: tabs, splits, zoom, checkout switching, shortcuts, registration, pane scroll and click Sep 22, 2026
The core moves keyboard focus on focus_pane and Herdr confirms later; a
confirmation still in flight when the next focus_pane goes out is
followed as a move of Herdr's own, which on the CI runner flipped focus
back to the clicked agent pane halfway through the command typed into
the shell pane. The click and the refocus now each wait until
`herdr pane current` names the pane before the test types.
A failed S2 flow on the runner showed only the screen text at the
assertion, which cannot say which side moved keyboard focus. The web job
now runs the e2e with a kept directory and uploads it on failure: the
daemon log, the fixture's Herdr server log, what each agent pane's PTY
received, and Playwright's own results. HIDE_E2E_TRACE narrates every
client event and received frame with a timestamp, which Playwright prints
for the failed test.
The pane view focuses its textarea when the layout's focused pane
changes, and the textarea's focus listener compared that against the
terminal section's pane id, a field the core moves at a different
moment, so the shell reported the core's own move back as an operator
focus_pane. On the CI runner, where Herdr confirms a focus later than the
next request goes out, the echo and the late confirmation kept two panes
trading focus indefinitely (the run's wire trace shows the p2/p6
alternation once a second) and a command typed into one pane landed in
the other. A snapshot-driven focus now sets a flag the listener honours;
the e2e asserts two operator focus changes are exactly two events.
…indented block

Herdr's confirmation of one focus request can reach the core after the
next request went out, naming the earlier pane for a moment; the shell
follows the snapshot, so keys typed in that moment go to that pane. A
CLI read of Herdr's focused pane cannot see the daemon's event reader
lag, so the click and the refocus also wait until the drawn focus has
held for a second.

The click and the drags address cells through xterm's screen element,
and the run prints the host-versus-screen delta. A second drag over two
indented lines checks the copy loses their shared margin and keeps the
indentation between them.
The cell under the pointer was derived from the pane host, which is
larger than xterm's grid by the fit's remainder, so a cell drifted by up
to one row and one column toward the far edge; a full-screen program's
one-row hint sits there, and the real-session clicks on Claude Code's
Jump-to-bottom hint missed. The grid now comes from xterm's screen
element. A probe with the real Claude Code in an isolated Herdr pane
shows the core's press and release at the hint's cell, written through
the control session in one input, jump the view to the bottom; Claude
Code requests ?1000/?1002/?1003/?1006, so SGR is the right encoding.

The copy removes the leading whitespace every non-blank line shares (the
program's margin) and keeps the indentation between lines; a single line
loses its leading spaces entirely.
The cut first line took part in the shared-margin computation, so a
selection starting past column 0 had no margin and the other lines kept
their indentation. The first line now stays out of the margin unless it is
the only line, and loses only what it still carries of it. Three vitest
cases pin the mid-line, inside-the-margin and lone-line starts; the CI
artifact comment names what Playwright actually writes.
…nues

The workflow comment promised screenshots under test-results, which the
Playwright config never writes; the specs' own screenshots go to the
fixture directory uploaded beside it. One more vitest case pins a drag
that starts mid-row on a row that continues onto the next.
@yansfil yansfil changed the title S2: tabs, splits, zoom, checkout switching, shortcuts, registration, pane scroll and click web: S2 tabs, splits, zoom, shortcuts, registration and pane input in the web shell Sep 22, 2026
@yansfil
yansfil merged commit c80eb3c into main Sep 22, 2026
6 checks passed
@yansfil
yansfil deleted the prd/web-shell-pivot-s2 branch September 22, 2026 05:18
yansfil added a commit that referenced this pull request Sep 23, 2026
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](https://github.com/yansfil/pr-assets/blob/main/hide/web-shell-pivot-s3/af5f914/s3-explorer-expanded.png?raw=true)

![clip.mp4 plays in the web shell; hided streams the bytes from inside
the checkout
boundary](https://github.com/yansfil/pr-assets/blob/main/hide/web-shell-pivot-s3/af5f914/s3-viewer-video.png?raw=true)

![Markdown Live hides the markup while the document stays
editable](https://github.com/yansfil/pr-assets/blob/main/hide/web-shell-pivot-s3/af5f914/s3-markdown-live.png?raw=true)

## 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.

<details><summary>Verification record</summary>

- 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)

</details>
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