Skip to content

feat: let agents drive browser displays over a scoped CDP endpoint - #373

Merged
yansfil merged 48 commits into
mainfrom
feature/browser-control
Oct 5, 2026
Merged

yansfil merged 48 commits into
mainfrom
feature/browser-control

Conversation

@yansfil

@yansfil yansfil commented Oct 4, 2026 •

Copy link
Copy Markdown
Contributor

Closes #156. Related: #158. Follow-up (not in this PR): #159.

Summary

  • 에이전트가 운영자가 보는 browser display를 표준 CDP로 조작합니다: hide browser connect [--display <id>]가 cdp_http_url과 browser_ws_url을 돌려줍니다.
  • 엔드포인트는 데스크톱 main process의 loopback 게이트웨이이고, 클라이언트 목록에는 browser display target만 보입니다. 셸 renderer attach는 거부됩니다.
  • 클라이언트의 new-target 요청은 같은 View area에 새 display를 엽니다. 클라이언트를 닫아도 display는 남고, display를 닫으면 그 클라이언트 세션이 끝납니다.
  • 에이전트가 붙은 display의 area 탭에 연결 배지가 보이고, 운영자는 그대로 조작할 수 있습니다.

에이전트가 붙은 browser display: 탭의 연결 배지, 한글 입력이 페이지에 반영됨

탭 제목 옆의 링크 배지가 에이전트가 붙어 있다는 표시입니다.

Review

  • 판단해 주세요: 지원 프로필은 직접 WebSocket discovery와 기존 context(noDefaults)입니다. MCP의 --browser-url은 capability prefix를 잃어 --wsEndpoint를 안내합니다.
  • 조심해서 볼 파일: desktop/src/main/browserCdp.ts, browser.ts - 세션 소유권과 네이티브 file: 접근 경계(HTTP/blank 페이지는 첫 load 전에 file 접근을 거부, 수동 파일 display는 유지).
  • 조심해서 볼 파일: herdr-core/src/runtime/{session,device_catalog,projects}.rs의 변경 꼬리 - capability를 coalesced 전달보다 먼저 회수하는 자리.
  • 조심해서 볼 파일: hided/src/server.rs, browser_control.rs - loopback 전용, capability gate, 실패 경로.
  • 비용 검토: 유휴 페이지는 discovery 작업이 없고, 게이트웨이 요청은 8개 admission cap과 16 KiB 응답 cap을 가집니다(docs/PERFORMANCE_TESTING.md).
  • 질문: 없음.

Evidence

  • 확인한 것: 고정된 실제 클라이언트 3종이 격리된 앱에서 통과했습니다: agent-browser 0.38.2(open, snapshot, fill, click, screenshot), chrome-devtools-mcp 1.10.1(navigate, snapshot, fill, click), Browser Use 0.13.10(연결, DOM 읽기, 연결 해제). 연결 해제 뒤에도 페이지가 남았습니다.
  • 확인한 것: desktop/e2e/browser-cdp.spec.ts 8개 케이스를 로컬 격리 환경에서 통과했습니다(셸 target 비노출, 닫기 순서, 파일 경계, 다운로드 취소 포함).
  • 확인한 것: 현재 main(Place a tab Hide created under the checkout it was created for #420 포함)을 병합한 head에서 required verify가 통과했습니다. Linux 탭 projection 실패는 재현되지 않았습니다.
  • 확인한 것: Rust workspace 테스트 1,922개 통과(lint 포함), web 1,004개와 desktop 147개 단위 테스트 통과.
  • 확인하지 못한 것: 수동 파일 열기 page_wait_timeout은 CI에서만 났고 로컬에서는 재현되지 않아 원인을 특정하지 못했습니다. 이번 head의 CI에서는 통과했습니다. 실패 시 core 진단이 출력되도록 e2e 진단만 보강했습니다.
  • 확인하지 못한 것: Playwright와 Browser Use의 기본 흐름(watchdog, CLI)은 지원하지 않고 문서에 적었습니다. #159의 hide browser snapshot/click은 이 PR 범위가 아닙니다.
  • 확인하지 못한 것: 첫 verify 실행의 Linux 1/6 agent-tab-names.spec.ts:6(탭 이름 입력 focus)은 이 PR이 닿지 않는 경로의 실패입니다. 이 브랜치에서 로컬 10회 모두 통과했고 실패한 job만 재실행해 통과했습니다.
추가 증거
  • 클라이언트 fixture는 new-target에 area 범위 capability(hide browser connect)를 쓰도록 고쳤습니다. display 전용 capability는 new-target을 거부하는 보안 경계 그대로입니다.
  • hide-agent-hooks fixture 변경은 #156에 필요 없어 이 PR에서 뺐습니다.

yansfil added 30 commits October 4, 2026 02:42
@yansfil

yansfil commented Oct 4, 2026

Copy link
Copy Markdown
Contributor Author

진단 13줄 커밋 6ed75a77을 push했고 격리 재현 프로세스를 모두 정리했습니다; Linux 1/6·desktop 실패 판단은 새 CI 로그로 이어가며, 추가 native8/clients3 검증은 실행하지 않았습니다.

@yansfil

yansfil commented Oct 4, 2026

Copy link
Copy Markdown
Contributor Author

9aa32f0 push: native file 완료 보고를 pinned root의 등록 경로로 매핑하도록 수정했고 회귀 테스트 RED→PASS(외부 파일·symlink 탈출·nested root 교체 거부 포함)를 확인했습니다; 원래 desktop e2e 해소는 새 CI 확인 대기이며, Windows/#361·Linux fs flake·native8/clients3 추가 QA는 제외했습니다.

@yansfil

yansfil commented Oct 4, 2026

Copy link
Copy Markdown
Contributor Author

origin/main(5286f69, #361 d1d9c1d 포함)을 3db3e546으로 병합·push했습니다. cwd 갱신과 pending-workspace 식별 및 양쪽 테스트를 모두 보존하고 workspace_control 테스트 import 충돌만 정리했습니다. diff·형식 검사 PASS, 작업 트리 clean, 원격/PR head 일치; 추가 로컬 QA는 실행하지 않았고 새 verify 결과는 미확인입니다.

@yansfil

yansfil commented Oct 4, 2026

Copy link
Copy Markdown
Contributor Author

리드 판단으로 이번 마무리에서 #373을 보류하고 draft로 유지합니다.
추가 수정, push, 로컬 재현 및 native/client QA는 진행하지 않습니다.
현재 head는 cb8b710e4e3103f2cc824409d7e59b31ea373074입니다.

  • 확인한 별칭 경로 문제: 등록된 checkout 경로와 native file: 보고의 물리 경로 표기가 다르면 기존 boundary가 보고를 outside_checkout으로 거부할 수 있었습니다.
    격리 재현에서 직접 경로와 별칭 경로의 결과 차이를 확인했고, 해당 경로 회귀 테스트는 37581f0e에서 RED, 9aa32f0b에서 PASS였습니다.
  • 반영한 수정: 9aa32f0b는 browser_state 보고에만 등록 root의 고정된 물리 identity를 이용한 별칭 매핑을 적용했습니다.
    기존 파일 열기 admission과 root 교체 및 symlink escape 거부는 유지했습니다.
    이 수정만으로 CI 실패가 해소되지는 않았습니다.
  • 최신 desktop CI job 111369602444의 남은 실패는 두 건입니다.
    browser-cdp.spec.ts:641의 native file 보안 테스트는 fromPane 호출에서 page_wait_timeout으로 실패했고, native file 로딩은 끝났지만 core 상태가 pending으로 남았습니다.
    browser-cdp.spec.ts:436의 originating-area 테스트는 expandViews가 [data-menu-item="panel:expanded"]를 클릭하려다 Timeout 30000ms exceeded로 실패했습니다.
    첫 실패의 잔여 원인과 두 번째 실패의 수정은 미완료입니다.

최신 CI의 진단 JSON 원문:

{"reason":"page_wait_timeout","state":"pending","load":1791091798492,"native":[{"protocol":"http","loading":false,"manual":false},{"protocol":"file","loading":false,"manual":true}],"events":[{"event":"browser.cdp_started"},{"event":"browser.control_registered"},{"event":"browser.view_created"},{"event":"browser.cdp_connected"},{"event":"browser.cdp_request_failed","method":"Page.navigate","code":-32000},{"event":"browser.cdp_connected"},{"event":"browser.cdp_request_failed","method":"Target.createTarget","code":-32000},{"event":"browser.cdp_disconnected"},{"event":"browser.cdp_request_failed","method":"Network.loadNetworkResource","code":-32000},{"event":"browser.view_created"}]}

위 세 cdp_request_failed는 테스트가 file: 접근을 시도한 명령의 거부 기록입니다.
이 기록만으로 남은 load 전달 실패의 원인을 확정할 수 없습니다.
verify는 실패 상태이며, 재개 시 현재 head와 이 CI 로그에서 두 실패를 이어서 진단해야 합니다.

yansfil added a commit that referenced this pull request Oct 4, 2026
Related: #299, #377

## Summary

- macOS의 순차 클릭 40회가 보류 요청의 기존 5초 제한을 넘겨, coalescing 대신 unknown 이후 동작을
검증했습니다.
- 같은 20쌍의 실제 Chromium 마우스 입력을 순서대로 묶어 보내 브라우저 왕복 지연을 제거합니다.
- 실제 전송된 포커스 변경의 코어 수락을 확인한 뒤 gate를 해제해, 마지막 진단과 시각에 의존하던 판정을 교체합니다.

## Review

- **조심해서 볼 파일**: `web/e2e/pane-focus-ordering.spec.ts` - 입력은 CDP의 실제
mouse events이며 DOM 이벤트나 dispatch를 대체하지 않습니다.
- **비용 검토**: burst당 120개 입력 명령, 관측 프레임 64개, CDP 세션은 `finally`에서 해제합니다.
- 단일 요청 상한, 마지막 pane의 실제 키 입력, Herdr 최종 포커스, 외부 포커스 추종 검증은 유지합니다.
- 클릭 횟수, timeout, retry, skip, quarantine을 변경하지 않습니다.

## Evidence

- **원인 확인**: 세 macOS 실패의 hided 로그 모두에서 첫 요청이 5001~5002ms에 unknown으로 끝난 뒤
클릭이 계속됐습니다.
- [#372
실패](https://github.com/modakbul-gongbang/hide/actions/runs/37179805703/job/111370084688),
[#373
실패](https://github.com/modakbul-gongbang/hide/actions/runs/37179682304/job/111369954345),
[#378
실패](https://github.com/modakbul-gongbang/hide/actions/runs/37179657967/job/111369590200)의
원본 로그와 artifacts를 보존했습니다.
- **macOS 실제 동작**: 격리된 pinned Herdr/hided/Chromium에서 두 focus 사례가 통과했습니다.
rapid 12.6s, unknown 14.4s.
- held burst의 마지막 코어 수락은 첫 요청 후 251ms였고, 첫 요청은 526ms에 superseded, 최종
pane은 confirmed로 끝났습니다.
- `scripts/verify-web.sh` PASS: web 904개, desktop 99개, hcoord unit
59개/e2e 36개와 typecheck/lint/build.
- `scripts/verify-cargo.sh cli`, design contract, workstation identity,
attribution 검사 PASS. 모든 격리 실행 프로세스를 정리했습니다.
- **미실행**: Linux E2E, 전체 Rust suite, native QA. PR의 필수 `verify`는 CI에서
확인합니다.

<details><summary>추가 증거</summary>

- Base: `5286f6958df7af0ea52556451406733d6e2073f2`; tested/pushed head:
`0b87fc5355300f6ebe249451356c2399b8729115`.
- 실행: `pnpm --dir web exec playwright test
e2e/pane-focus-ordering.spec.ts --workers=1 --max-failures=1
--trace=on`.
- 기존 test 30s / assertion 5s 제한을 유지했으며, 두 사례의 trace와 입력 관측은 로컬 ignored
run에 보존했습니다.
- 이번 변경 경로는 위 테스트 파일 하나입니다. 제품 source와 Herdr pin은 변경하지 않았습니다.

</details>
yansfil added a commit that referenced this pull request Oct 4, 2026
Related: #373 (원래 이 수정이 들어 있던 PR, 보류 중)

## Summary

새 plain pane은 `pane_created` 시점에 셸이 시작되기 전 물려받은 작업 폴더를 cwd로 들고 있을 수
있습니다.
core는 `agent.list`가 읽어 온 실제 cwd를 같은 pane 기록에 반영하지 않아, 그 pane이 엉뚱한
checkout으로 분류될 수 있었습니다.
#373에서 Linux `web/e2e/checkout-owner.spec.ts` 실패의 원인으로 찾은 수정을 따로 뗀 것입니다.
`agent.list` 갱신 때 같은 workspace·tab에 있는 같은 pane의 cwd만 갱신하고, 목록이 topology를
만들거나 옮기지는 못하게 했습니다.

## Review

- **조심해서 볼 파일**: `herdr-core/src/session_sync/replica.rs` - Herdr가 주는
cwd를 core 기록에 반영하는 자리(Herdr/core ownership). workspace·tab이 다르면 반영하지
않습니다.

## Evidence

- **확인한 것**: 새 회귀 테스트
`agent_refresh_reconciles_a_plain_new_panes_live_checkout_cwd`가 수정 전
FAILED, 수정 후 ok.
- **확인한 것**: `agent_refresh_does_not_move_a_pane_or_clear_its_known_cwd`
포함 `session_sync` 테스트 51개 통과(1개 기존 ignored), rustfmt check 통과.
- **확인하지 못한 것**: 이 PR의 첫 CI에서도 `checkout-owner.spec.ts:80`(기대 3, 실제 2)이
실패했습니다. 이 수정만으로 그 e2e가 풀린다는 근거는 아직 없습니다. 실패 job을 다시 돌려 flaky인지 확인 중입니다.
@yansfil yansfil changed the title feat: add scoped browser display control feat: let agents drive browser displays over a scoped CDP endpoint Oct 5, 2026
@yansfil
yansfil marked this pull request as ready for review October 5, 2026 03:49
@yansfil
yansfil merged commit fcb3f39 into main Oct 5, 2026
56 of 58 checks passed
@yansfil
yansfil deleted the feature/browser-control branch October 5, 2026 03:49
yansfil added a commit that referenced this pull request Oct 5, 2026
## Summary

Two pull requests that were each green broke `main` together (#435 and
#373): `verify` is required, but with strict status checks off nothing
checks the two merged.
The merge queue will check that, once enabled in the repository settings
after this merges; the required `verify` check then has to run on the
queue's group commit too.
This adds the `merge_group` trigger (`checks_requested`) to `pr.yml`,
and `ci-plan.py` plans a group from `merge_group.base_sha` to the
group's commit: the tree `main` becomes, so a group queued behind others
plans for their changes too.
The `plan` step fetches that base (it can be several queued merges back,
past the checkout's depth); a base it cannot fetch leaves the comparison
unavailable, which plans every lane as before.

## Review

- **판단해 주세요**: a group is planned by the same path rules as a pull
request (not every lane); every lane still runs on the push to `main`
that follows, as today.
- **판단해 주세요**: the push to `main` keeps its full `verify` run. It is the
only run whose rust-cache saves (`save-if` main; caches a group saves
would be scoped to its temporary `gh-readonly-queue/...` ref, which
later pull requests cannot read), and it is the net under a narrowed
plan.
- **조심해서 볼 파일**: `.github/workflows/pr.yml` `on:` and the `plan` step:
`BASE` is `merge_group.base_sha`, or `HEAD^1` for a pull request as
before; `concurrency` is unchanged (a group's `github.ref` is its own,
and only `pull_request` cancels), with its comment corrected: a newer
main run replaces a pending one, which is what happened to 25 of 26
cancelled main runs on 2026-10-05.
- **질문**: none; the merge queue setting (ruleset or branch protection,
merge commits) is switched on separately after this merges.

## Evidence

- **확인한 것**:
`test_a_merge_group_plans_every_queued_change_from_its_base` builds a
repository with two pull requests merged in queue order (a `desktop/src`
change, then a docs change): the second group's own merge plans `policy`
alone, the group from its base plans `policy`, `desktop-checks`,
`desktop-e2e`, and a base the checkout lacks plans every lane. Against
`main`'s `ci-plan.py` the test fails (the group planned every lane).
- **확인한 것**: `test_the_merge_queue_runs_verify_from_the_groups_base`
holds the trigger, the base expression and the `pull_request`-only
cancellation in `pr.yml`.
- **확인한 것**: `python3 -m unittest discover -s scripts/tests` passes (127
tests); `actionlint` 1.7.12 reports nothing for `pr.yml`, `web-e2e.yml`,
`os-contract.yml`.
- **확인하지 못한 것**: no `merge_group` event has run, because the queue is
not enabled yet; the first queued pull request after enabling it is that
check (its `plan` summary should list the group's paths, and `verify`
should report on the `gh-readonly-queue/main/...` commit).
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: let agents drive browser displays over a scoped CDP endpoint

1 participant