Skip to content

Browser displays in View areas, drawn by the desktop app - #164

Merged
yansfil merged 13 commits into
mainfrom
quick/155-browser-display
Sep 26, 2026
Merged

yansfil merged 13 commits into
mainfrom
quick/155-browser-display

Conversation

@yansfil

@yansfil yansfil commented Sep 26, 2026 •

Copy link
Copy Markdown
Contributor

Closes #155

Summary

웹 페이지를 Herdr browser pane(chromux screencast) 대신 View area의 display로 엽니다.
core는 DisplayKind::Browser로 어떤 페이지가 어디 있는지를, desktop 앱 main process는 display마다 하나인 WebContentsView로 페이지 자체를 소유합니다.
여는 길은 hide browser open <url|path>, Explorer의 Open in Browser(HTML 파일), 페이지의 새 창, toolbar 주소창입니다.
⌘K, 메뉴, dialog, 탭 드래그가 페이지를 덮으면 페이지를 캡처한 still로 바꿔 overlay가 위에 그려지고, 일반 브라우저 탭에서는 조용한 안내와 Open in browser만 보입니다.
chromux 경로(plugins/browser, core chromux.rs/pane_content.rs, Swift Browser*.swift, BrowserPaneOpener)는 지웠습니다.

두 View area에 나란히 뜬 native 페이지, 페이지 안 입력란에 한글이 들어간 상태
⌘K palette가 still로 얼린 페이지 위에 그려진 상태
로드 실패: 주소와 Chromium 사유, Reload
일반 브라우저 탭의 안내와 Open in browser

Review

  • 판단해 주세요: toolbar와 상태 보드(p0Do2, Browser file diff toolbars)는 사람 승인 없이 그렸습니다. 모양과 문구를 봐 주세요.
  • 판단해 주세요: 다운로드는 Chromium 기본 동작(Downloads에 저장, 로그 browser.download만)입니다. 확인 창이나 위치 제한이 필요한지.
  • 판단해 주세요: checkout 안 file: 페이지가 제 링크로 checkout 밖 파일로 이동하면 그 view에는 보이고, core 기록만 boundary에서 거절됩니다(재실행 시 마지막 허용 주소). 페이지 이동도 막을지.
  • 판단해 주세요: 페이지에 포커스가 있을 때 창 단축키는 앱 메뉴가 가진 것만 동작합니다. 페이지 컨텍스트 메뉴는 없습니다.
  • 조심해서 볼 파일: desktop/src/main/browser.ts, browserSync.ts - failure path와 수명: 페이지 생성/숨김/파괴, 12개 live cap, IPC 신뢰 검사.
  • 조심해서 볼 파일: hided/src/server.rs browser_url, hided/src/file_url.rs - 경계: file: URL을 decode해 checkout root 검사 후 검사한 경로로 다시 씀.
  • 조심해서 볼 파일: herdr-core/src/runtime/view_areas.rs - runtime mutex 안의 일: open/navigate/state 기록, receipt 8개 cap, I/O 없음.
  • 조심해서 볼 파일: herdr-core/src/model.rs - snapshot wire: display의 url/title/load, status.browser_opens, status.chromux 삭제.
  • 질문: hide browser open은 실패 시 JSON을 찍고 exit 2입니다(기존 hide CLI 관례). agent가 쓰기에 이게 맞는지.

Evidence

  • 확인한 것: desktop/e2e/browser.spec.ts가 직접 띄운 desktop 앱과 private hided, 격리된 Herdr(HERDR_SOCKET_PATH)에서 한 흐름을 끝까지 돕니다.
  • 확인한 것: CLI --pane으로 열기, native view bounds = slot bounds, 한글 insertText, split과 창 resize에서 renderer pid와 페이지 마커 유지.
  • 확인한 것: ⌘K 동안 보이는 view < 2와 still 표시, Escape로 복귀, 주소 입력과 Back, window.open이 새 display(창 1개 유지).
  • 확인한 것: 127.0.0.1:1 실패 안내와 Reload, Explorer의 리포트 1.html 열기, checkout 밖 파일 outside_checkout 거절.
  • 확인한 것: display 닫으면 renderer 종료, 재실행 후 Page A 복원, 일반 브라우저 탭 안내. 캡처는 창 id로 찍었고 운영자 앱은 건드리지 않았습니다.
  • 확인한 것: cargo fmt/clippy와 1277개 테스트, Swift 533개, web 329개, desktop 29개, design contract, workstation identity 등 정적 gate.
  • 확인한 것: Code, Fidelity, Security 리뷰 모두 Fix now 없음. follow-up 중 web 상태 map 정리와 stale report 진단은 이 PR에서 반영했습니다.
  • 확인한 것: head 3f6b1ee6에서 PR check 7개(verify run 36211315961의 job 6개와 Design contract)가 모두 통과했고, runner에서 desktop e2e 6개가 통과했습니다.
  • 확인한 것: 직전 run 36209912790은 runner 화면이 1024pt라 View area가 좁아 Split right가 비활성으로 떨어졌습니다. spec이 창을 1024x640으로 고정해 확인합니다.
  • 확인한 것: split과 resize 단계는 Views only에서 Explorer를 숨긴 채 돕니다. 로컬 1024x640에서 실패를 먼저 재현한 뒤 browser spec 3/3, desktop e2e 6/6을 통과시켰습니다.
  • 확인한 것: 같은 조사에서 제품 버그를 하나 고쳤습니다. 주소창에 포커스한 뒤 한 프레임 안에 입력하면 새 주소가 기존 주소 뒤에 붙었는데, 이제 전체 주소를 같은 commit에서 선택합니다.
  • 확인한 것: Run the macOS pane chords in the desktop app, brought across from the Swift app once #160, web: group the ⌘K palette in the Swift search form and add the sidebar Search field #161, #162가 들어온 main을 merge commit e4cffeb3로 합쳤습니다. 충돌은 desktop bridge(reportBindings와 browser를 함께 유지), channel, preload, e2e bridge 키, ARCHITECTURE 한 줄이었습니다.
  • 확인한 것: main의 새 테스트가 지워진 chromux_enabled를 쓰고 있어 고쳤습니다. hided-ws.ts는 generator 출력과 같고, 디자인 라이브러리는 두 부모의 보드(p0Do2, weekly usage)를 모두 가집니다.
  • 확인한 것: merge 뒤 로컬에서 cargo lint와 테스트 1283개, web unit 346개, web e2e 62/62, desktop unit 31개, desktop e2e 8/8(#160의 keys spec 포함)이 통과했습니다.
  • 확인한 것: merge head e4cffeb3에서 PR check 7개(verify run 36213739656의 job 6개와 Design contract)가 모두 통과했고, runner에서 web e2e 63개와 desktop e2e 8개가 통과했습니다.
  • 확인한 것: #163이 들어온 main(83321656)을 merge commit 8a2ce77d로 다시 합쳤습니다(충돌 없음, desktop/core 변경 없음). 로컬 web typecheck, lint, unit 352개, e2e 63/63이 통과했습니다.
  • 확인한 것: head 8a2ce77d에서 PR check 7개(verify run 36215350833의 job 6개와 Design contract)가 모두 통과했고, runner에서 web e2e 63개와 desktop e2e 8개가 통과했습니다.
  • 확인하지 못한 것: 실제 macOS 한글 IME 조합(후보창, 조합 중 백스페이스)은 insertText로만 확인했습니다.
  • 확인하지 못한 것: 설치된 앱에서의 동작과 원격 device checkout의 Open in Browser 비활성 상태는 코드와 단위 테스트로만 확인했습니다.
  • 확인하지 못한 것: desktop e2e의 lifetime 테스트가 재실행 중 한 번 firstWindow timeout으로 실패했고 재시도 3번은 통과했습니다(이 변경 전부터 있는 흐름).
  • 생성물: design/hide-ui.lib.pen의 p0Do2 시트 하나만 바뀌었습니다(Pen 헤드리스로 생성).

Breaking change

  • 이 빌드가 workspace-views.json에 browser display를 저장한 뒤 이전 빌드로 되돌리면, 이전 빌드는 그 파일을 읽지 못해 옆으로 치우고 Main에서 시작합니다.

AI tooling: 대부분 AI 도구. e2e 스크린샷, 리뷰 결과, 문서와 코드의 대응을 손으로 대조했습니다.

The browser moves into View areas as a desktop-drawn display, so the
Herdr plugin pane that screencast a chromux profile goes: the
`plugins/browser` host, the core's per-pane content and `status.chromux`,
the Swift browser canvas, CDP session, pane controller and opener, the
Explorer's Open in Browser Pane item, and the bundling of the host into
the app. Reopen no longer prunes browser leaves from a closed tab.

The operator's installed `hide.browser` plugin is left as it is.
A View area display gains a third kind, `browser`: a page with an
address, a title and a runtime-only load stamp, and no document or tab,
so the reconcile never binds or removes one and a restart shows it again
at the address it last reported.

- `browser_open` opens a page in the Workspace the payload names, else
  the one the pane `pane_id` works in, else the one in front, in its area
  in use; the same address again shows that page loaded again. A request
  that names itself gets a bounded receipt in `status.browser_opens`.
- `view_layout` navigate loads a typed address; `browser_state` records
  where a page went and its title without loading anything.
- The core holds only http, https, file and about:blank addresses, and
  refuses a file address in a Workspace on another device.
- hided checks a `file:` address like any path: it decodes it, requires
  it under a registered checkout root, and forwards the URL of the checked
  path, or answers `path_refused`.
- `hide browser open <url-or-path> [--pane <id>]` attaches to the running
  daemon (never starts one), sends one `browser_open` over the WebSocket,
  and prints the receipt or the refusal as one JSON line. The pane comes
  from `--pane` or `HERDR_PANE_ID`.
The desktop main process owns one WebContentsView per browser display
the shell has shown, in a persistent `persist:hide-browser` session with
a sandboxed renderer, context isolation, no Node and no preload. The
shell reports where each display of the front Workspace sits through
the `hideHost.browser` bridge; a page is created when first shown,
hidden but kept alive while off screen (a move between areas never
loads it again), closed with its display, which ends its renderer, and
evicted past twelve live pages while hidden.

- The bridge is bounded on both sides: every sync, capture and command
  is checked for shape, and only the top frame of the daemon-served
  shell may send one.
- A shell overlay that meets a page (the palette, a menu, a dialog, a
  popover, a tab drag) cannot draw over a native view, so the page is
  captured, its still drawn in its place, and the page hidden until the
  overlay goes.
- The display has a toolbar with Back, Forward, Reload or Stop and an
  address field; a failed load says so with Reload; a page's new window
  opens another browser display.
- The Explorer offers Open in Browser on an HTML file of this Mac.
- In a plain browser tab a browser display is a quiet notice with the
  address and, for the web, Open in browser.
The Browser chrome sheet loses the pane header a Herdr browser pane
carried: the address toolbar is now a View area display's own strip,
tab-strip high on the background with a bottom hairline, holding Back,
Forward, Reload and the address field. The sheet adds its Loading
(Reload turns to Stop), Load failed and Plain browser tab states.
The address field drops a web address's scheme until it is edited, so
an area a third of the window wide still shows the host and port;
focusing it selects the whole address.

The browser e2e opens a window large enough for two View areas, closes
a display through its menu's `close_view`, and launches with
`--disable-backgrounding-occluded-windows`: the test window sits behind
the operator's windows, and Chromium stops painting an occluded window,
so a capture by window id showed a stale frame.
docs/BROWSER_PANES.md becomes docs/BROWSER_DISPLAYS.md: who owns a page
(the core, hided, the web shell, the desktop app), the ways to open one,
the `file:` address boundary, the page's session, permissions and
lifetime, the overlay freeze, the states, and the e2e that verifies it.

ARCHITECTURE gains the browser display kind in the View areas section,
the `navigate` action, the receipts, the older-build compatibility of
the layout file, and the `file:` URL check in the checkout boundary; the
desktop host's bridge now names `browser`. UI_BEHAVIOR describes the
view as the operator sees it, and loses the Browser plugin surfaces the
chromux path had.
With the browser pane gone, no pane carries a content consequence, so
the pane prompt's special case, the tab and workspace prompts' appended
sentences, and the test built on a hosted viewer go with it.
check-no-workstation-identity.sh allows /Users/example only.
The web kept what each page said, and the last report it sent, for
every display id it had seen; both now drop a front Workspace's display
once the layout no longer holds it, which is when the desktop app
closes its page. A `browser_state` for a display that is gone, a page's
last report racing its close, leaves a `browser.state_stale` diagnostic
instead of nothing.

The browser e2e also drives a page's `window.open`: it becomes another
browser display of the Workspace, and the app keeps one window.
Focusing the address field swaps the shown host for the whole address,
and replacing an input's value drops its selection; the select ran a
frame later, so a key typed within that frame, or a select-then-focus
fill, landed after the old address instead of replacing it. The field
now selects in the layout effect of the commit that swaps the value.
The spec sized its window to the screen, so a runner's 1024-point
screen gave the View areas too little room beside the Agents area and
the Explorer, and Split right was disabled. The window is now a fixed
1024x640, asserted after it is set; the split and resize steps run in
Views only with the Explorer hidden, and the Explorer shows only for
its own step.

Each wait for a page to sit on its slot now reads the slot on every
poll: the expected bounds were read once, right after the resize and
before the shell laid out again. The address step clicks the field and
checks the whole address before typing, as a person does.
Brings in the ⌘K palette (#161), weekly usage (#162) and the desktop
app's macOS pane chords (#160).

The desktop bridge keeps both sides: `reportBindings` from #160 beside
`browser`, the channels of both, and the e2e's bridge keys list all
four. The bindings listener now uses the host's one shell-frame check,
`fromShell`, which the browser channels already use. main's new
shortcut import test no longer names the removed `chromux_enabled`.
The contract carries both sides and web/src/generated/hided-ws.ts is
the generator's output; the design library holds both parents' boards,
the browser toolbars sheet from this branch and the weekly usage sheet
from main.
Brings in the web Projects tab (#163). No conflicts: it and this branch
both add to web/src/actions.ts, web/src/snapshot.ts and
docs/UI_BEHAVIOR.md in different places, and #163 touches nothing under
desktop/, herdr-core/ or hided/.
@yansfil
yansfil merged commit 4110164 into main Sep 26, 2026
7 checks passed
@yansfil
yansfil deleted the quick/155-browser-display branch September 26, 2026 03:56
yansfil added a commit that referenced this pull request Sep 26, 2026
…PATH (#166)

Related: #149 (the desktop host)

## Summary

Finder나 Dock에서 연 패키지 hide.app은 launchd의
PATH(`/usr/bin:/bin:/usr/sbin:/sbin`)로 시작합니다.
운영자 머신에서 5초 로그인 셸 조회가 실제 zsh rc(웜 2.4초, 콜드는 더 김)에 타임아웃됐고, 창이 "hide CLI
not found"에 머물렀습니다.
이제 CLI 탐색 순서는 `HIDE_CLI_PATH` -> (비패키지) 워크트리 빌드 -> PATH -> 마지막으로 붙은 CLI
-> 로그인 셸 PATH(패키지만, 10초) -> `~/.local/bin`, `/opt/homebrew/bin`,
`/usr/local/bin`입니다.
붙은 CLI는 프로필의 `cli-path.json`에 기억되어, 두 번째 실행부터는 느린 로그인 셸을 부르지 않습니다.
실패 화면은 그대로이고, 시도한 경로는 모두 한 번씩 로그에 남습니다.

## Review

- **판단해 주세요**: 기억한 경로를 PATH 뒤, 로그인 셸 앞에 둔 순서. 로그인 셸이 운영자 의도의 권위지만 비싸서,
기억한 경로가 그 캐시 역할을 합니다
- **판단해 주세요**: 로그인 셸 타임아웃 10초(VS Code
`shellEnvironmentResolutionTimeout` 기본값). 실패는 캐시하지 않아 Retry가 다시 묻습니다
- **조심해서 볼 파일**: `desktop/src/main/cli.ts` - `resolveCli`가 async가 됐고 로그인
셸은 앞 단계가 모두 빗나갈 때만 호출됩니다
- **조심해서 볼 파일**: `desktop/src/main/host.ts` - failure path: 로그인 셸 조회 중
quit/Retry, `hide connect` 성공 뒤에만 기억을 씁니다
- **조심해서 볼 파일**: `desktop/src/main/env.ts` - `HOME`을 레지스트리에 추가. Electron
`app.getPath("home")`은 `HOME`을 무시해 격리 QA가 운영자 CLI를 찾았습니다
- **조심해서 볼 파일**: `desktop/e2e/fixture.ts` - 이미 떠 있는 데몬에 다시 붙는 relaunch는
`relaunch()`로 메인 프로세스에서 창을 읽습니다(아래 Evidence)
- 로그인 셸은 shell-env처럼 `/usr/bin/env DISABLE_AUTO_UPDATE=true
ZSH_TMUX_AUTOSTART*=...`로 감싸 Oh My Zsh 업데이트 프롬프트와 tmux 자동 시작을 막습니다
- 설치 디렉터리 목록은 Swift 앱 `RuntimeEnvironment.swift`의 fallback과 같습니다.
`jsonFile.ts`는 `windowState.ts`의 원자적 쓰기를 뽑아낸 것입니다

## Evidence

- **확인한 것**: `pnpm --dir desktop typecheck`, `lint`, `test`(30개, 새 순서
테스트 6개와 기억 파일 파싱, 실제 `/bin/sh` 로그인 조회 포함) 통과
- **확인한 것**: `pnpm --dir desktop e2e` 8/8, 새 `discovery` 테스트: PATH를
launchd 값으로, `HIDE_CLI_PATH` 없이, 워크트리 밖으로 복사한 앱에서 `~/.local/bin`으로 붙고
`cli-path.json`을 쓴 뒤 재실행은 `remembered`로 붙음
- **확인한 것**: 패키지 앱(`pnpm --dir desktop package`)을 `env -i`로 launchd 같은
환경, 비공개 HOME/state/profile/socket으로 세 번 실행
- 3초 걸리는 가짜 로그인 셸 -> `login`으로 붙고 기억 (`cli.login_path` elapsed 3243ms)
- 멈추는 셸 + 기억 있음 -> 셸을 부르지 않고 `remembered`로 0.1초 안에 붙음
- 멈추는 셸 + 기억 없음 -> 10004ms에 타임아웃, `~/.local/bin`에서 `well-known`으로 붙음. 사건
시나리오 그대로
- 각 실행 뒤 비공개 데몬을 `hide stop`, 남은 프로세스 없음. 운영자 hided와 상태 디렉터리는 건드리지 않음
- `python3 -m unittest discover -s scripts/tests`(39),
`check-no-workstation-identity.sh`, `check-no-attribution.py` 통과
- **확인한 것**: #164 병합 뒤 CI의 `discovery` 실패는 relaunch 경합이었습니다. 로컬 반복에서 기존
`lifetime`도 같은 모양으로 실패했습니다
- 재실행이 수십 ms 만에 붙으면 Playwright가 status 페이지 -> 데몬 origin 렌더러 교체를 놓칩니다.
page가 `file://`에 머물거나 window 이벤트가 안 옵니다
- 탐침 스펙으로 확인: 놓친 경우에도 창은 데몬 URL, 로딩 끝, 보임, 셸 DOM 있음. 제품 문제가 아니라 테스트 관측
문제입니다
- 그래서 두 relaunch는 메인 프로세스로 창을 읽고, cleanup의 `rmSync`는 ENOTEMPTY를
재시도합니다(main에서도 16회 중 1회 재현)
- 고친 뒤 `lifetime`/`discovery` 반복 30회 통과(운영자 화면 때문에 중간에 멈춤). e2e 창은 여전히
화면에 뜨며, 숨김 실행은 이 PR에 넣지 않았습니다
- **확인하지 못한 것**: Finder/Dock에서 실제로 연 실행(launchd가 준 환경 그대로)과 운영자의 실제 zsh
rc. 위 검증은 `env -i`와 가짜 셸로 흉내낸 것입니다
- **확인하지 못한 것**: Playwright는 앱을 비패키지로 띄우므로 e2e는 로그인 셸 단계를 지나지 않습니다. 그
자리는 단위 테스트와 위 패키지 수동 실행이 덮습니다
- **확인하지 못한 것**: Rust, Swift, web 레인은 이 diff가 건드리지 않아 로컬에서 돌리지 않았습니다.
CI가 돌립니다
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.

desktop: browser displays in View areas, drawn by an Electron WebContentsView

1 participant