From 0f121636526bf488e45198f54f441ca62c151b9b Mon Sep 17 00:00:00 2001 From: jinyoung Date: Wed, 2 Dec 2026 12:02:29 +0900 Subject: [PATCH 01/12] =?UTF-8?q?feat(browser):=20PC=20=EA=B0=80=20?= =?UTF-8?q?=EC=BC=9C=EC=A0=B8=20=EC=9E=88=EC=96=B4=EB=8F=84=20=EC=84=9C?= =?UTF-8?q?=EB=B2=84=20=EB=B8=8C=EB=9D=BC=EC=9A=B0=EC=A0=80=EC=97=90?= =?UTF-8?q?=EC=84=9C=20=E2=80=94=20=EA=B8=B0=EB=B3=B8=EA=B0=92=20=E3=80=8C?= =?UTF-8?q?=EB=B8=8C=EB=9D=BC=EC=9A=B0=EC=A0=80=20=EC=9E=91=EC=97=85=20?= =?UTF-8?q?=EC=9C=84=EC=B9=98=E3=80=8D=20=C2=B7=20=E3=80=8C=EC=84=9C?= =?UTF-8?q?=EB=B2=84=EC=97=90=EC=84=9C=20=ED=95=B4=20=EC=A4=98=E3=80=8D=20?= =?UTF-8?q?=C2=B7=20=EC=B9=B4=EB=93=9C=EC=9D=98=20=E3=80=8C=EC=84=9C?= =?UTF-8?q?=EB=B2=84=EC=97=90=EC=84=9C=20=EC=9D=B4=EC=96=B4=EC=84=9C?= =?UTF-8?q?=E3=80=8D=20=C2=B7=20=EC=A4=84=20=EC=84=A0=20=EC=B9=B4=EB=93=9C?= =?UTF-8?q?=EC=9D=98=20=E3=80=8C=EC=84=9C=EB=B2=84=EC=97=90=EC=84=9C=20?= =?UTF-8?q?=EB=B0=94=EB=A1=9C=20=EC=8B=9C=EC=9E=91=E3=80=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 2026-12-02 사용자: 「pc 에 연결된 브라우저에서 동작하길 원치 않고 서버 파드에서 돌리고 싶은 경우도 지원」. - lib/browserWhere.js(새): 사람마다의 기본값 pc · server(pro_profile.browser_where, sql/076 — 없으면 모두 pc, 바꾸기는 503 no_column) - routeOf where · person: 한 작업의 선택 → 기본값 → PC 설정, PC 가 막은 작업은 어떤 선택으로도 그 PC 로 가지 않음 - browser_task 의 where(모델이 말을 읽음), 이어서 하는 카드는 서버를 고른 채로 - moveToServer: 일하는 PC 작업은 그 걸음을 멈추고 PC 를 놓고 toServer(asked), 줄 선 PC 작업은 route.where — POST /api/browser/route 가 받음 - 카드: 그림이 오지 않는 자리에 「서버에서 이어서」, 옛 PC 앱이면 진행 화면이 보이는 판(나온 뒤에만) 안내, 「서버 브라우저」 표시, 확장 화면 단추는 휴대폰에서 둘째 줄로(글자가 깨지지 않게) - 설정 「브라우저 작업 위치」(PC 우선 · 늘 서버, 어느 기기에서나) Co-Authored-By: Claude Opus 5.5 --- CHANGELOG.md | 2 + docs/browser-where/design.md | 54 ++++++ e2e/tests/feature/browser-where.spec.js | 192 +++++++++++++++++++ e2e/tests/feature/local-browser-card.spec.js | 15 +- openspec/specs/browser-handoff/spec.md | 50 ++++- server/index.js | 12 +- server/lib/agent.js | 14 +- server/lib/browser.js | 114 +++++++++-- server/lib/browserRemote.js | 25 ++- server/lib/browserWhere.js | 65 +++++++ server/lib/localAgents/chat.js | 4 +- server/lib/localAgents/desktopRelease.js | 2 + server/sql/076_browser_where.sql | 11 ++ server/test/browser-local.test.js | 73 +++++++ server/test/browserWhere.test.js | 93 +++++++++ src/components/LocalAgentsSettings.vue | 18 +- src/components/TaskCard.vue | 44 ++++- src/i18n/ko-en.json | 16 +- 18 files changed, 753 insertions(+), 51 deletions(-) create mode 100644 docs/browser-where/design.md create mode 100644 e2e/tests/feature/browser-where.spec.js create mode 100644 server/lib/browserWhere.js create mode 100644 server/sql/076_browser_where.sql create mode 100644 server/test/browserWhere.test.js diff --git a/CHANGELOG.md b/CHANGELOG.md index 9856bde0..44c8208b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,6 +7,8 @@ ### 바뀜 +- **PC 가 켜져 있어도 브라우저 작업을 서버 브라우저에서 할 수 있습니다. 설정 「브라우저 작업 위치」에서 기본값을 「PC 우선」 또는 「늘 서버」로 고르고(웹 · 휴대폰에서도 바꿈), 채팅에서 「서버에서 해 줘」라고 하면 그 작업만 서버에서 합니다. PC 에서 일하는 작업의 카드에는 「서버에서 이어서」가 있어, 누르면 서버 브라우저가 같은 페이지에서 이어서 하고, PC 를 기다리며 줄 선 작업에는 「서버에서 바로 시작」이 있습니다. PC 화면이 오지 않으면 카드에 「서버에서 이어서」와, 옛 PC 앱이면 진행 화면이 보이는 새 판(0.2.13 이 나온 뒤) 안내가 함께 나옵니다. 확장 화면의 단추는 휴대폰에서 글자가 두 줄로 깨지지 않고 둘째 줄로 넘어갑니다** (스펙 `browser-handoff` 「서버 브라우저를 고르기」, 설계 `docs/browser-where/design.md`, 서버 `lib/browserWhere.js`(새) · `lib/browserRemote.js routeOf`(`where` · `person`) · `lib/browser.js moveToServer · routeTo · liveUpdateOf` · `lib/agent.js`(`browser_task` 의 `where`) · `PUT /api/browser/where`, DB `server/sql/076_browser_where.sql`(`pro_profile.browser_where` — 없으면 모두 「PC 우선」, 바꾸기는 503), 화면 `TaskCard.vue` · `LocalAgentsSettings.vue`, 시험 `server/test/browserWhere.test.js` · `browser-local.test.js`(진짜 Electron 4개) · `e2e/tests/feature/browser-where.spec.js` F-BW-01…05 · F-LB-03 · 05 고침, 카탈로그 §105) + - **프로젝트 방의 산출물 더미에서 프로젝트 계획을 함께 봅니다 — 접힌 더미 이름은 「산출물 · 계획」이고, 펼치면 파일 위에 계획 카드가 있습니다. 파일마다 붙어 있던 「팀원에게 공유」 사람 아이콘은 모두 없애고, 공유 기능은 파일을 길게 누르거나(휴대폰) 오른쪽 클릭하면(컴퓨터) 나오는 메뉴로 옮겼습니다** (스펙 `chat-artifacts` 「프로젝트 방의 더미에는 계획도 있다」 · 「파일의 공유는 파일의 메뉴에 있다」, `project-room` · `messenger-drop-folder` · `answer-share`, 설계 `docs/chat-artifacts/design.md`, 화면 `ArtifactStack.vue` · `ProjectPlanView.vue` · `FileItemMenu.vue` · `ArtifactList.vue` · `Message.vue` · `FileGroupRow.vue` · `holdMenu.js` · `ProjectNote.vue`, 순수 규칙 `src/artifactScope.js`, 시험 AS-U-07 · 08 · F-SPL-01~07, 카탈로그 103절, 2026-12-02 사용자 — 「프로젝트 내에서 프로젝트 계획을 볼 수 있는 부분이 필요한데, 여기 산출물 열기를 했을 때 거기에 프로젝트 계획 보기 같은 게 있으면 같이 볼 수 있을 것 같아. 산출물 및 계획 뭐 이런 식으로 아이콘 줄어들었을 때 그 조그만한 다이얼로그 부분에는 그렇게 표시해주면 좋겠네.」 · 「그리고 지금 공유 버튼을 위해 가지고 팀원에게 공유하는 저 아이콘들, 뭐 대화방에도 있고 산출물 여기에도 있고, 저기 그 사람 아이콘 저거는 다 없애줘. 다 없애고 우클릭, 그러니까 모바일에서는 길게 클릭했을 때 나오는 컨텍스트 메뉴로 다 바꾸자.」): 프로젝트 계획은 방 맨 위의 칩으로만 열 수 있어서, 대화가 길어지면 칩이 위로 밀려 보이지 않았습니다. 이제 프로젝트 방에서 더미를 펼치면 맨 위에 목적이 보이는 「프로젝트 계획」 카드가 있고, 누르면 같은 상자 안에서 목적 · 쓰는 도구 · 만들 것 · 지킬 것 · 정한 것과 최근에 바뀐 것을 읽습니다. 긴 항목도 줄을 바꿔 휴대폰에서 다 보입니다. 고치기 · 바뀐 기록 · 되돌리기는 예전처럼 계획 시트에서 하며, 「고치기 · 바뀐 기록」을 누르면 시트가 열립니다. 넓은 화면의 오른쪽 산출물 목록 맨 위에도 계획 줄이 있습니다. 채팅의 더미는 예전처럼 「산출물」입니다. 더미의 파일, 오른쪽 목록의 행, 채팅의 파일 카드와 묶은 카드의 줄에서는 모두 파일 메뉴(열기 · 팀원에게 공유 · 폴더에 정리)의 「팀원에게 공유」로 공유합니다. 키보드로는 Shift+F10이나 메뉴 키로 열고, 더미의 파일과 목록의 행에도 채팅 카드처럼 포인터를 올리거나 키보드 초점을 맞추면 보이는 「⋯」이 있습니다. 같은 파일의 메뉴를 다시 열어도 폴더 판정을 다시 묻지 않습니다. 길게 눌러도 글자가 선택되거나 파일이 열리지 않습니다. 계획을 읽는 동안 Esc를 누르면 파일로 돌아가고, 휴대폰을 옆으로 들어도 상자가 화면 안에 있습니다. 여러 파일을 한 번에 보내는 「모두 공유」와 문서 편집기 머리의 「공유」 단추는 그대로입니다. 공유 권한 · 서버는 바뀌지 않았고 새 SQL은 없습니다. - **「내 PC」에서 도는 브라우저 작업 카드의 화면이 앞 작업의 페이지가 아니라 그 작업이 지금 있는 페이지를 보여 줍니다. 지금 페이지의 그림을 얻지 못하면 「PC 화면을 받지 못하고 있어요 — 작업은 이어서 해요」라고 표시합니다** (스펙 `browser-handoff` 「작업 카드의 화면은 그 작업이 지금 있는 페이지다」, 데스크톱 `desktop/src/browser/host.js` · `src/runner/index.js`(`caps.freshFrames`), 서버 `lib/browser.js` `dropStale` · `lib/browserRemote.js` `frameShot` · `lib/localAgents/devices.js`, 화면 `TaskCard.vue`, 시험 `desktop/test/browser.test.js` · `server/test/browserTabShot.test.js` · `browserDriver.test.js` · `browser-local.test.js` · LB-04 · F-LB-05, 카탈로그 102절, 설계 `docs/local-agents/design.md` 5.15, 2026-12-02 06:08 사용자(휴대폰 화면) — 「그리고 브라우저 다른탭에서 작업하는건지 화면에 기존 노트북 엘엠 화면이고 작업은 유튜브에서 작업중이라고 나온다. 화면 캡쳐가 다은탭을 보여주는건가?」): 유튜브 스튜디오에 영상을 올리는 작업의 카드에 앞 작업이 남긴 NotebookLM 홈이 보였습니다. 상태 알약의 제목(「승인 필요 · 채널 대시보드 - YouTu…」)은 맞았습니다. 다른 탭을 찍은 것이 아니었습니다. 작업은 앞 작업이 남긴 같은 탭에서 유튜브 스튜디오로 이동했는데, 그 탭의 창은 「이 PC에서 보기」로 보였다가 내려가 있어 새 화면을 그리지 않았고, PC 앱은 그 탭이 마지막으로 그린 그림(앞 작업의 NotebookLM)을 보냈습니다. 이제 PC 앱(0.2.13)은 그림마다 어느 페이지의 것인지 확인해 앞 페이지의 그림은 보내지 않습니다. 「이 PC에서 보기」로 보였다가 내려 두었거나 숨은 창은 그때마다 한 번 캡처해 지금 페이지를 찍으며(40ms 안팎 — 모델이 보는 그림도 비밀 칸을 칠한 뒤에 찍습니다), 그 뒤에는 창이 다시 화면을 그려 실시간 화면도 다시 들어옵니다. 한 번도 보이지 않은 숨은 창은 캡처하지 않습니다. 서버도 지금 페이지가 아닌 그림은 카드 · 끝난 카드의 마지막 화면에서 내리고, 0.2.12 이하의 PC 앱에는 카드용 그림도 「지금 그린 것이 아니면 없음」으로 요청합니다(2.5초까지 기다리고, 없다고 답한 주소에서는 PC가 다시 그리거나 주소가 바뀔 때까지 다시 묻지 않습니다). 주소의 물음표 뒤가 바뀌면(`/watch?v=`처럼) 다른 페이지로 봅니다. 따라서 PC 앱을 업데이트하기 전에도 앞 페이지는 보이지 않고, 창이 화면을 그리지 않는 동안에는 「PC 화면을 받지 못하고 있어요」가 보입니다. PC에서 작업의 창을 앞으로 띄우지는 않습니다. PC에 창을 보일지는 지금처럼 「이 PC에서 보기」로 사람이 정하고, 보이는 동안에는 늘 작업 중인 탭이 보입니다. 함께 고친 것: 페이지가 연 새 창(탭)을 「이 PC에서 보기」로 본 뒤 숨기면, 같은 주소의 새 숨은 탭이 문서 없이 만들어져 준비에 3초 넘게 걸렸고 서버가 기다리는 5초를 넘길 수 있었습니다(이번 시험에서 발견). 이제 0.6초 안팎입니다. diff --git a/docs/browser-where/design.md b/docs/browser-where/design.md new file mode 100644 index 00000000..cafc4a98 --- /dev/null +++ b/docs/browser-where/design.md @@ -0,0 +1,54 @@ +# PC 브라우저의 진행 화면 · 서버 브라우저 고르기 — 설계 노트 + +스펙: `openspec/specs/browser-handoff/spec.md` 「서버 브라우저를 고르기」 · 「PC 화면이 오지 않을 때」. 앞선 설계: `docs/local-agents/browser.md`. + +## 2026-12-02 — 처음 + +### 무엇을 받았나 +휴대폰 화면 두 장과 이 말을 받았다: 「Pc 에 연결된 브라우저 사용시 진행상태가 보이지 않음. 화면전환된 송출을 최적화하여 연결할 방법이 있나? 그리고 pc 에 연결된 브라우저에서 동작하길 원치 않고 서버 파드에서 돌리고 싶은 경우도 지원」. +- 11:31 화면: 카드에 「내 PC · uengineui-MacBookPro」 · 「브라우저 여는 중」이 있고 그림은 없다. 알약은 「페이지 읽는 중」이다. +- 11:35 화면: 확장 화면에 YouTube Studio 업로드 창 한 장이 있다. 단추줄은 「계획 / 2/6」 · 「직접 제 / 어」 · 「이 PC에서 / 보기」 · 「작업 취 / 소」처럼 글자가 두 줄로 깨진다. + +### 왜 안 보였나 +- 그 맥의 PC 앱은 **0.2.10** 이었다. 0.2.12 까지는 나와 있었지만 받지 않은 상태였고, 0.2.13(#188, 탭 그림)은 아직 나오지 않았다. +- 실시간 화면은 숨은 창의 CDP 스크린캐스트다. 이 PC 에 한 번도 보인 적 없는 숨은 창은 그림을 그린다. 그런데 **이 PC 에 보였다가 최소화된 창, 앱이 숨긴 창**은 아무것도 그리지 않는다(Electron, 2026-11-24 · 12-02 측정). 그날 아침 NotebookLM 작업 때 「이 PC에서 보기」로 띄운 창이 최소화된 채 남아 있었다. +- 그 상태에서 0.2.10 은 프레임을 하나도 보내지 못한다. 모델용 그림(걸음마다 한 장)도 비어서 카드에 그림이 없었다. 0.2.13 은 최소화된 창을 한 번 캡처해 모델의 그림과 카드의 한 장을 얻지만, 그다음 캡처까지는 실시간 화면을 채우지 못한다. +- 대역폭 문제는 아니었다. 송출은 이미 바뀐 화면만, 1초에 3장 이하로, 1024×640 JPEG(품질 50)으로 보낸다. 보낼 그림이 생기지 않은 것이 원인이다. + +### 바꾼 것 — 데스크톱(0.2.13 에 함께) +(측정 수치는 아래 「측정」에 적는다.) +- **진행 화면 받쳐 주기**: 작업 중인 탭이 이 PC 에 보였던 창이고 스크린캐스트가 1초쯤 아무것도 보내지 않으면, 약 1초마다 그 창을 캡처해 실시간 화면으로 보낸다. 직전에 보낸 것과 같은 그림은 다시 보내지 않고, 스크린캐스트가 다시 오면 캡처를 멈춘다. 한 번도 보이지 않은 숨은 창은 캡처하지 않는다. 그런 창을 캡처하면 그 창이 그리기를 멈추기 때문이다(2026-11-24). +- **작업 시작 때 새 창**: 이 PC 에 보였다가 지금은 최소화되었거나 숨은 창이면, 작업을 시작할 때 같은 주소의 새 숨은 탭으로 바꾼다. 그 작업의 실시간 화면이 처음부터 온다. 사람이 화면에 띄워 둔 창은 그대로 둔다. + +### 바꾼 것 — 서버 · 화면 +- 카드에 그림이 오지 않을 때(`noDraw`): + - 그 자리에 「서버에서 이어서」를 둔다. + - PC 앱이 진행 화면을 못 보내는 옛 판이면 「PC 앱을 <판> 버전으로 올리면 진행 화면이 보여요 · 내려받기」를 함께 보인다(`where.update`, `lib/browser.js liveUpdateOf`). 이 줄은 그 판(0.2.13)이 **나온 뒤에만** 보인다. 받을 수 없는 판을 안내하지 않기 위해서다. +- 확장 화면 단추줄: + - 휴대폰 폭에서 단추 글자가 두 줄로 깨지지 않게 했다. + - 다 들어가지 않으면 가운데 맞춘 둘째 줄로 넘긴다. 가로 스크롤은 쓰지 않았다. 처음에 가로 스크롤로 해 보니 새 단추 「서버에서 이어서」가 화면 밖에 숨었다. 동작 단추는 모두 보여야 하므로 줄 바꿈으로 바꿨다. +- **서버 브라우저 고르기** 네 길(`lib/browserRemote.js routeOf` 의 `where` · `person`): + 1. 기본값 「브라우저 작업 위치」: `pro_profile.browser_where`, `sql/076`, `lib/browserWhere.js`, `PUT /api/browser/where`. + 2. 한 작업의 말: `browser_task` 의 `where` 매개변수. 모델이 사람의 말을 읽고 정한다. + 3. 일하는 카드의 「서버에서 이어서」: `POST /api/browser/route {to:'server'}` → `moveToServer` → 작업 루프의 `task.moveTo` → `toServer(asked)`. PC 가 꺼졌을 때의 「서버에서 이어서」와 같은 길을 쓴다. + 4. 줄 선 카드의 「서버에서 바로 시작」(`content.pcLine`): 줄의 `route.where = 'server'`. + +### 결정(위임 판단) +- **기본값은 서버에 사람마다 저장하고, 어느 기기에서나 바꾼다.** + - PC 마다의 「브라우저 작업은 이 PC에서」는 그 PC 의 앱에서만 바꾼다. 서버가 PC 에 일을 더 보내게 만들 수 없어야 하기 때문이다. + - 「늘 서버」는 PC 에서 일을 빼기만 하므로 그 걱정이 없다. 또 사람이 PC 앞에 없을 때(휴대폰) 고르고 싶은 설정이다. + - 우선순위는 한 작업의 선택 → 기본값 → PC 설정이다. 어떤 선택도 PC 가 막은 작업을 그 PC 로 보내지 않는다. +- **한 작업의 말은 도구 매개변수로 받는다.** 라우터 모델이 사람의 말에서 `where` 를 정한다. 낱말 규칙(정규식)은 쓰지 않는다. +- **옮기기는 일하는 작업과 줄 선 작업만 한다.** + - 사람을 기다리는 작업(로그인 · 사람 확인 · 승인)은 그 자리에서 답한다. PC 의 로그인은 그 PC 의 것이기 때문이다. + - 옮긴 작업은 같은 카드에서 다시 해도 서버에서 돈다(`where.asked`). 사람이 PC 를 피한 데는 까닭이 있었다고 본다. +- **옛 PC 앱 안내는 카드에서, 그 판이 나온 뒤에만 한다.** 휴대폰으로 지켜보는 사람이 앱 설정 화면까지 가지 않아도 되게 한다. 0.2.12 의 auto mode 안내(`chat.js pcUpdateOf`)와 같은 방식이다. +- **잠긴 화면 · 꺼진 화면(디스플레이 잠자기)은 재지 않았다.** 이 맥에서는 다른 세션이 녹화를 하고 있어 화면을 재우거나 잠글 수 없었다. 그 상태에서는 캡처도 실패할 수 있다. 그때 카드는 지금처럼 「PC 화면을 받지 못하고 있어요 — 작업은 이어서 해요」와 「서버에서 이어서」를 보인다. + +### 측정 +(데스크톱 측정 결과를 여기에 채운다.) + +### 남은 것 +- 운영 SQL `076_browser_where.sql`(사용자 승인 필요). 적용 전에는 모두 「PC 우선」으로 돌고 설정 칸이 잠긴다. +- 데스크톱 0.2.13 출시(사용자 승인 필요). 받침 캡처와 작업 시작 때 새 창이 사용자의 맥에 닿는 시점이다. +- 운영 라우터 모델이 「서버에서 해 줘」를 `where: 'server'` 로 읽는지는 실제 모델로 확인하지 않았다(시험은 가짜 모델). diff --git a/e2e/tests/feature/browser-where.spec.js b/e2e/tests/feature/browser-where.spec.js new file mode 100644 index 00000000..a2326cfb --- /dev/null +++ b/e2e/tests/feature/browser-where.spec.js @@ -0,0 +1,192 @@ +// 브라우저 작업을 서버 브라우저로 — PC 가 켜져 있어도(스펙 browser-handoff 「서버 브라우저를 고르기」 · 「PC 화면이 오지 않을 때」, +// 2026-12-02 사용자: 「Pc 에 연결된 브라우저 사용시 진행상태가 보이지 않음 … pc 에 연결된 브라우저에서 동작하길 원치 않고 서버 파드에서 +// 돌리고 싶은 경우도 지원」). 모델 · 데스크톱 없이 고정 카드로, 단추가 보내는 것은 page.route 로 받아 본다. +// F-BW-01 휴대폰(390): PC 에서 일하는 카드의 확장 화면 — 「서버에서 이어서」 → /api/browser/route { taskId, to: 'server' }, 단추는 모두 화면 안에 +// (두 줄로 넘어가도) 단추 글자가 두 줄로 깨지지 않는다(전에는 「계획 / 2/6」 · 「작업 취 / 소」) +// F-BW-02 PC 화면이 오지 않는 카드(noDraw): 그 자리에 「서버에서 이어서」, PC 앱이 옛 판이면 「PC 앱을 0.2.13 버전으로 올리면 진행 화면이 +// 보여요」와 내려받기 — 옮길 수 없다는 답이면 까닭을 말한다 +// F-BW-03 PC 브라우저를 기다리며 줄 선 카드(pcLine): 「서버에서 바로 시작」 → /api/browser/route { taskId, to: 'server' } +// F-BW-04 설정 「브라우저 작업 위치」(웹 · 휴대폰에서도 바꿈): 「늘 서버」 → PUT /api/browser/where { where: 'server' }, 지금 어디서 +// 도는지 줄이 바뀐다 · 저장할 곳이 없으면(kept: false) 칸이 잠기고 그렇게 말한다 +// F-BW-05 서버 브라우저를 고른 작업의 카드(where.why asked · person)는 「서버 브라우저」라고 말한다 +// cd e2e && PGPT_URL=http://127.0.0.1:5273 API_URL=http://127.0.0.1:8873 npx playwright test --project=feature tests/feature/browser-where.spec.js +import fs from 'node:fs' +import path from 'node:path' +import { test, expect } from '../../lib/fixtures.js' +import { PNG } from '../../lib/seed.js' + +const PHONE = { viewport: { width: 390, height: 844 } } +const shot = PNG(640, 400, [40, 120, 200]).toString('base64') +const steps = [{ text: '상점 열기', done: true }, { text: '찾기', done: false }] +const onPc = { kind: 'local', device: '테스트 맥', deviceId: 'dev-1' } +async function photo(page, testInfo, name) { + const dir = process.env.BW_SHOTS || testInfo.outputDir + fs.mkdirSync(dir, { recursive: true }) + const file = path.join(dir, `${name}.png`) + await page.screenshot({ path: file }) + await testInfo.attach(name, { path: file, contentType: 'image/png' }) +} +const toChat = (page) => page.locator('button, a').filter({ hasText: /^채팅$/ }).first().click() +// what the card's buttons send (answered here: ok, or what the test says) +function listen(page, answer = () => ({ ok: true })) { + const sent = [] + page.route(/\/api\/browser\/(route|show|resume)$/, (route) => { + const r = route.request() + const name = r.url().split('/').pop() + sent.push([name, r.postDataJSON()]) + route.fulfill({ status: 200, contentType: 'application/json', body: JSON.stringify(name === 'route' ? answer() : { ok: true }) }) + }) + return sent +} + +test.describe('브라우저 작업 · 서버 브라우저를 고르기', () => { + test('F-BW-01 휴대폰: PC 에서 일하는 카드의 확장 화면 「서버에서 이어서」 — 단추는 모두 화면 안에, 글자가 깨지지 않는다', async ({ pageAs, db }, testInfo) => { + const page = await pageAs('bw-card-move', PHONE) + const th = await db.clearMain(page.user.id) + const [, task] = await db.addMessages(th, [ + { role: 'user', kind: 'text', content: { text: '가상 영상 사이트에 가상 영상 올려 줘' } }, + { role: 'agent', kind: 'task', content: { title: '가상 영상 올리기', goal: 'g', steps, state: 'running', shot, where: onPc } }, + ]) + const sent = listen(page) + await page.goto('/chat') + await toChat(page) + const card = page.locator(`.row[data-id="${task.id}"]`) + await expect(card.getByTestId('task-where')).toHaveText('내 PC · 테스트 맥', { timeout: 20_000 }) + await card.getByRole('button', { name: '확장' }).click() + const full = page.locator('.handoff') + await expect(full).toBeVisible() + const move = full.getByTestId('task-move-server') + await expect(move).toHaveText('서버에서 이어서') + // every pill one line high (40 px) — the row scrolls sideways instead + const pills = full.locator('.bar .pill') + const n = await pills.count() + expect(n).toBeGreaterThanOrEqual(5) + // (the full view grows in — measured once it has) + await expect.poll(async () => Math.round((await pills.first().boundingBox()).height)).toBe(40) + for (let i = 0; i < n; i++) expect(Math.round((await pills.nth(i).boundingBox()).height), `단추 ${i} 한 줄`).toBe(40) + // every pill on the screen (a second row when they do not fit one) + for (let i = 0; i < n; i++) { const b = await pills.nth(i).boundingBox(); expect(b.x >= 0 && b.x + b.width <= 390, `단추 ${i} 화면 안`).toBe(true) } + expect(await page.evaluate(() => document.documentElement.scrollWidth <= window.innerWidth)).toBe(true) + await page.waitForTimeout(600) + await photo(page, testInfo, 'bw-f01-full-move') + await move.scrollIntoViewIfNeeded() + await move.click() + await expect.poll(() => sent.filter(([n]) => n === 'route').length).toBe(1) + expect(sent.find(([n]) => n === 'route')[1]).toEqual({ taskId: task.id, to: 'server' }) + expect(page.errors).toEqual([]) + }) + + test('F-BW-02 PC 화면이 오지 않는 카드: 그 자리에 「서버에서 이어서」, 옛 PC 앱이면 새 판과 내려받기 — 옮길 수 없으면 까닭', async ({ pageAs, db }, testInfo) => { + const page = await pageAs('bw-card-nodraw', PHONE) + const th = await db.clearMain(page.user.id) + const where = { ...onPc, update: { have: '0.2.10', latest: '0.2.13', download: 'https://www.uengine.org/contents/processgptlite.html#desktop' } } + const [, task] = await db.addMessages(th, [ + { role: 'user', kind: 'text', content: { text: '가상 영상 사이트에 가상 영상 올려 줘' } }, + { role: 'agent', kind: 'task', content: { title: '가상 영상 올리기', goal: 'g', steps, state: 'running', where } }, + ]) + await page.route(/\/api\/browser\/frame\?taskId=/, (route) => route.fulfill({ status: 200, contentType: 'application/json', + body: JSON.stringify({ data: null, url: 'https://video.example/upload', running: true, taskId: task.id, where, noDraw: true }) })) + let answer = { ok: false } + const sent = listen(page, () => answer) + await page.goto('/chat') + await toChat(page) + const card = page.locator(`.row[data-id="${task.id}"]`) + const nd = card.getByTestId('task-nodraw') + await expect(nd.locator('.still')).toHaveText('PC 화면을 받지 못하고 있어요 — 작업은 이어서 해요', { timeout: 20_000 }) + await expect(card.getByTestId('task-pc-update')).toContainText('PC 앱을 0.2.13 버전으로 올리면 진행 화면이 보여요') + await expect(card.getByTestId('task-pc-update').getByRole('link', { name: '내려받기' })).toHaveAttribute('href', where.update.download) + await card.scrollIntoViewIfNeeded() + await photo(page, testInfo, 'bw-f02-nodraw-move') + // the server says it cannot move it now (it waits for an answer): said, not silent + await card.getByTestId('task-nodraw-move').click() + await expect(card.getByTestId('task-move-error')).toHaveText('지금은 옮길 수 없어요 — 답을 기다리는 중이거나 이미 끝났어요.') + answer = { ok: true } + await card.getByTestId('task-nodraw-move').click() + await expect.poll(() => sent.filter(([n]) => n === 'route').length).toBe(2) + expect(sent.filter(([n]) => n === 'route')[1][1]).toEqual({ taskId: task.id, to: 'server' }) + await expect(card.getByTestId('task-move-error')).toHaveCount(0) + // the screen-tap still opens the full view (the button did not) + await expect(page.locator('.handoff')).toHaveCount(0) + expect(page.errors).toEqual([]) + }) + + test('F-BW-03 PC 브라우저를 기다리며 줄 선 카드: 「서버에서 바로 시작」', async ({ pageAs, db }, testInfo) => { + const page = await pageAs('bw-card-queued', PHONE) + const th = await db.clearMain(page.user.id) + const [, task] = await db.addMessages(th, [ + { role: 'user', kind: 'text', content: { text: '가상 상점에서 가상 배 찾아 줘' } }, + { role: 'agent', kind: 'task', content: { title: '가상 상점에서 배 찾기', goal: 'g', steps, state: 'queued', pcLine: true, noFront: true, + reason: "PC 브라우저는 작업을 하나씩 해요. 앞 작업 '가상 영상 올리기'이(가) 끝나면 시작해요." } }, + ]) + const sent = listen(page) + await page.goto('/chat') + await toChat(page) + const card = page.locator(`.row[data-id="${task.id}"]`) + const go = card.getByTestId('task-q-server') + await expect(go).toHaveText('서버에서 바로 시작', { timeout: 20_000 }) + await expect(card.getByTestId('task-q-cancel')).toHaveText('취소') + await card.scrollIntoViewIfNeeded() + await photo(page, testInfo, 'bw-f03-queued-pc') + await go.click() + await expect.poll(() => sent.length).toBe(1) + expect(sent[0]).toEqual(['route', { taskId: task.id, to: 'server' }]) + expect(page.errors).toEqual([]) + }) + + test('F-BW-04 설정 「브라우저 작업 위치」: 웹 · 휴대폰에서 「늘 서버」로 — 저장할 곳이 없으면 칸이 잠긴다', async ({ pageAs }, testInfo) => { + const page = await pageAs('bw-settings', PHONE) + const pcFirst = { + person: 'pc', kept: true, + own: { where: 'local', why: null, device: { id: 'dev-1', name: '테스트 맥' } }, + unattended: { where: 'server', why: 'not-own', device: null }, + devices: [{ id: 'dev-1', name: '테스트 맥', browser: true, pref: 'own', enabled: true }], min: '0.2.6', + } + const always = { ...pcFirst, person: 'server', own: { where: 'server', why: 'person', device: null }, unattended: { where: 'server', why: 'person', device: null } } + const puts = [] + let first = pcFirst + await page.route(/\/api\/browser\/where$/, (route) => { + const r = route.request() + // (kept: the next look sees it, as the server's would) + if (r.method() === 'PUT') { puts.push(r.postDataJSON()); first = always; return route.fulfill({ status: 200, contentType: 'application/json', body: JSON.stringify(always) }) } + return route.fulfill({ status: 200, contentType: 'application/json', body: JSON.stringify(first) }) + }) + await page.goto('/settings/accounts') + const box = page.locator('[data-test=browser-local]') + const sel = box.locator('[data-test=browser-person-pref]') + await expect(sel).toHaveValue('pc', { timeout: 20_000 }) + await expect(box.locator('[data-test=browser-local-own]')).toContainText('「테스트 맥」의 브라우저에서 해요') + await sel.selectOption('server') + await expect.poll(() => puts.length).toBe(1) + expect(puts[0]).toEqual({ where: 'server' }) + await expect(box.locator('[data-test=browser-local-own]')).toContainText('「브라우저 작업 위치」를 「늘 서버」로 정했어요') + await expect(sel).toHaveValue('server') + // (the PCs' own settings stay read-only here) + await expect(box.locator('select')).toHaveCount(1) + await box.scrollIntoViewIfNeeded() + await photo(page, testInfo, 'bw-f04-settings') + // without its column (sql/076 not run): the field is locked and says why + first = { ...pcFirst, kept: false } + await page.reload() + await expect(sel).toBeDisabled({ timeout: 20_000 }) + await expect(box.locator('[data-test=browser-person]')).toContainText('이 설정을 저장할 곳이 아직 없어요') + expect(page.errors).toEqual([]) + }) + + test('F-BW-05 서버 브라우저를 고른 작업의 카드는 「서버 브라우저」', async ({ pageAs, db }) => { + const page = await pageAs('bw-card-server', PHONE) + const th = await db.clearMain(page.user.id) + const [, asked, person, plain] = await db.addMessages(th, [ + { role: 'user', kind: 'text', content: { text: '서버에서 가상 상점 열어 줘' } }, + { role: 'agent', kind: 'task', content: { title: '서버에서 열기', goal: 'g1', steps, state: 'running', shot, where: { kind: 'server', why: 'asked' } } }, + { role: 'agent', kind: 'task', content: { title: '기본값 서버', goal: 'g2', steps, state: 'running', shot, where: { kind: 'server', why: 'person' } } }, + { role: 'agent', kind: 'task', content: { title: 'PC 없음', goal: 'g3', steps, state: 'running', shot, where: { kind: 'server', why: 'no-desktop' } } }, + ]) + await page.goto('/chat') + await toChat(page) + await expect(page.locator(`.row[data-id="${asked.id}"]`).getByTestId('task-where')).toHaveText('서버 브라우저', { timeout: 20_000 }) + await expect(page.locator(`.row[data-id="${person.id}"]`).getByTestId('task-where')).toHaveText('서버 브라우저') + await expect(page.locator(`.row[data-id="${plain.id}"]`).getByTestId('task-where')).toHaveCount(0) + await expect(page.locator(`.row[data-id="${asked.id}"]`).getByTestId('task-nodraw-move')).toHaveCount(0) + expect(page.errors).toEqual([]) + }) +}) diff --git a/e2e/tests/feature/local-browser-card.spec.js b/e2e/tests/feature/local-browser-card.spec.js index 4ad6670f..4200778b 100644 --- a/e2e/tests/feature/local-browser-card.spec.js +++ b/e2e/tests/feature/local-browser-card.spec.js @@ -4,11 +4,13 @@ // (둘이 함께 보이지 않는다 — 검토 4), 「이 PC에서 보기」는 /api/browser/show 로 그 작업을 // F-LB-02 PC 연결이 끊긴 카드 — 「서버에서 이어서」 · 「PC가 다시 켜지면」 · 「멈추기」, 확장 화면에는 「서버에서 이어서」만(직접 제어 · 제어 돌려주기 없음), // 단추는 /api/browser/route 로 { taskId, to } -// F-LB-03 웹(휴대폰)의 설정은 읽기만: 내가 시킨 작업 · 단계 · 예약 작업이 지금 어디서 도는지와 PC 마다의 설정, 바꾸는 칸은 없다(바꾸기는 그 PC 의 앱에서) +// F-LB-03 웹(휴대폰)에서 PC 마다의 설정은 읽기만: 내가 시킨 작업 · 단계 · 예약 작업이 지금 어디서 도는지와 PC 마다의 설정, 그 칸은 없다(바꾸기는 그 +// PC 의 앱에서) — 여기서 바꾸는 칸은 내 기본값 「브라우저 작업 위치」 하나(PC 에서 빼기만 하는 설정 — browser-where.spec.js F-BW-04) // F-LB-04 PC 에서 사람이 필요한 채로 끝난 카드(pcKept): 「다시 시도」 옆에 「이 PC에서 보기」 → /api/browser/show 로 그 작업, 이유는 「직접 제어」가 아니라 // 「이 PC에서 보기」를 말한다 · 다른 작업이 그 브라우저를 쓰면(pcKept: false) 단추가 없다 (2026-11-25 재검토 N4) // F-LB-05 지금 페이지의 그림이 없는 카드(서버가 다른 페이지의 그림을 내림 — noDraw): 그림 자리에 「PC 화면을 받지 못하고 있어요 — 작업은 이어서 해요」, -// 카드에 남은 앞 그림(shot)도 보이지 않는다 (2026-12-02 「화면에 기존 노트북 엘엠 화면이고 작업은 유튜브에서 작업중이라고 나온다」) +// 카드에 남은 앞 그림(shot)도 보이지 않는다 (2026-12-02 「화면에 기존 노트북 엘엠 화면이고 작업은 유튜브에서 작업중이라고 나온다」) — 그 자리에 +// 「서버에서 이어서」도(F-BW-02) // cd e2e && PGPT_URL=http://127.0.0.1:5273 API_URL=http://127.0.0.1:8873 npx playwright test --project=feature tests/feature/local-browser-card.spec.js import fs from 'node:fs' import path from 'node:path' @@ -131,7 +133,7 @@ test.describe('PC 의 브라우저에서 도는 작업 · 카드와 설정', () expect(page.errors).toEqual([]) }) - test('F-LB-03 웹의 설정은 읽기만 — 지금 어디서 도는지와 PC 마다의 설정, 바꾸기는 그 PC 의 앱에서', async ({ pageAs }, testInfo) => { + test('F-LB-03 웹에서 PC 마다의 설정은 읽기만 — 지금 어디서 도는지와 PC 마다의 설정, 바꾸기는 그 PC 의 앱에서', async ({ pageAs }, testInfo) => { const page = await pageAs('lb-settings-web', PHONE) await page.route(/\/api\/browser\/where$/, (route) => route.fulfill({ status: 200, contentType: 'application/json', body: JSON.stringify({ own: { where: 'local', why: null, device: { id: 'dev-1', name: '테스트 맥' } }, @@ -154,7 +156,9 @@ test.describe('PC 의 브라우저에서 도는 작업 · 카드와 설정', () await expect(box.locator('[data-browser-device="dev-2"]')).toContainText('단계 · 예약 작업까지 모두') await expect(box.locator('[data-browser-device="dev-3"]')).toContainText('이 컴퓨터에서 단계 실행을 꺼서 쓰지 않음') await expect(page.locator('[data-test=local-browser-pref]')).toHaveCount(0) - await expect(box.locator('input, select')).toHaveCount(0) + // (the one field here is the person's own default — 「브라우저 작업 위치」; no PC's setting) + await expect(box.locator('input, select')).toHaveCount(1) + await expect(box.locator('[data-test=browser-person-pref]')).toHaveCount(1) await box.scrollIntoViewIfNeeded() await photo(page, testInfo, 'lb-f03-settings-web') // the server's browser for both, and why @@ -184,7 +188,8 @@ test.describe('PC 의 브라우저에서 도는 작업 · 카드와 설정', () await toChat(page) const card = page.locator(`.row[data-id="${task.id}"]`) await expect(card.getByTestId('task-where')).toHaveText('내 PC · 테스트 맥', { timeout: 20_000 }) - await expect(card.getByTestId('task-nodraw')).toHaveText('PC 화면을 받지 못하고 있어요 — 작업은 이어서 해요') + await expect(card.getByTestId('task-nodraw').locator('.still')).toHaveText('PC 화면을 받지 못하고 있어요 — 작업은 이어서 해요') + await expect(card.getByTestId('task-nodraw-move')).toHaveText('서버에서 이어서') await expect(card.locator('.screen img')).toHaveCount(0) await card.scrollIntoViewIfNeeded() await photo(page, testInfo, 'lb-f05-no-draw') diff --git a/openspec/specs/browser-handoff/spec.md b/openspec/specs/browser-handoff/spec.md index a6f74b54..07154e88 100644 --- a/openspec/specs/browser-handoff/spec.md +++ b/openspec/specs/browser-handoff/spec.md @@ -265,11 +265,12 @@ 시스템은 브라우저 작업이 브라우저를 받을 때, 그 작업의 사람이 이어 둔 데스크톱 앱(0.2.3 이상, `caps.browser`) 중 켜져 있고 그 PC 의 설정이 이 작업을 받는 것이 있으면 그 PC 의 브라우저에서 돌려야 한다(SHALL — 받는 PC 는 아래 「PC 마다 동의한 작업만 그 PC 로 간다」). 아니면 지금처럼 서버 브라우저에서 돈다(휴대폰만 쓸 때, 0.2.2 이하의 데스크톱, 그 PC 가 받지 않음). 근거는 사용자 질문 「이 부분도 일렉트론 버전에서는 로컬 브라우저를 이용하는게 더 효율적이지 않을까?」와 「그래도 순수 모바일에서는 이 작업이 가능해야하니」(2026-11-24)다. - 에이전트 루프(계획 · 모델 · 판정 · 보관함 · 스킬 · 카드 · 감시 · 걸음마다 한도 · 「다시 시도」 · 「그만두기」)는 서버에 하나다. 바뀌는 것은 페이지를 움직이는 드라이버뿐이다 — 서버의 Chromium, 또는 그 사람 데스크톱의 링크 너머 브라우저. 두 드라이버는 같은 동작(열기 · 읽기 · 요소 이름 · 누르기 · 입력 · 키 · 스크롤 · 보관함 값 · 그림 · 낱말 · 멈추기 · 파일 넣기 · 직접 제어 · 페이지의 대화 상자)을 같게 해야 한다(SHALL). -- 어디서 돌지는 작업이 브라우저를 받을 때 한 번 정한다. PC 의 브라우저가 30초 안에 열리지 않으면 그 작업은 서버 브라우저가 맡고 카드에 그렇게 남긴다. 서버 브라우저도 열리지 않으면 카드는 「브라우저를 열지 못해 작업을 시작하지 못했어요 …」로 실패로 끝나고 줄 선 다음 작업이 시작해야 한다(SHALL) — 「진행 중」으로 남거나 줄이 멈추지 않는다. 시작한 작업은 저절로 다른 곳으로 옮기지 않는다(MUST NOT — 아래 「PC 가 꺼지면 …」). +- 어디서 돌지는 작업이 브라우저를 받을 때 한 번 정한다. PC 의 브라우저가 30초 안에 열리지 않으면 그 작업은 서버 브라우저가 맡고 카드에 그렇게 남긴다. 서버 브라우저도 열리지 않으면 카드는 「브라우저를 열지 못해 작업을 시작하지 못했어요 …」로 실패로 끝나고 줄 선 다음 작업이 시작해야 한다(SHALL) — 「진행 중」으로 남거나 줄이 멈추지 않는다. 시작한 작업은 저절로 다른 곳으로 옮기지 않는다(MUST NOT — 아래 「PC 가 꺼지면 …」). 사람이 고르면 옮긴다(아래 「서버 브라우저를 고르기」). - PC 의 브라우저는 데스크톱 앱 안의 숨은 창이고, 사람마다의 세션에 로그인이 남는다(그 PC 를 떠나지 않는다). 「이 PC에서 보기」를 누르면 그 창이 PC 에 보이고, 사람은 그 창에서 직접 할 수 있다(그 PC 에서의 직접 제어). 닫으면 다시 숨는다. 웹 · 휴대폰의 카드에는 지금처럼 실시간 화면(1초에 3장까지, 1024×640)이 온다. - 데스크톱은 서버가 보낸 코드를 돌리지 않는다(MUST NOT). 이름 붙은 동작만 자기 코드로 하고, 그 데스크톱에 로그인한 사람의 작업만 받는다. 페이지는 웹 주소(http · https)로만 가고 그 PC 의 파일은 열지 않는다. 사이트는 카메라 · 마이크 · 화면 · 위치 · 알림 · 클립보드 읽기를 받지 못한다. - PC 에서 받은 파일은 서버 브라우저에서 받은 것과 같은 파일 카드로 올라온다. -- 카드: PC 에서 도는 작업은 화면 왼쪽 위에 「내 PC · <기기 이름>」, 확장 화면과 사람을 기다릴 때의 단추에 「이 PC에서 보기」가 있다. 서버에서만 도는 작업에는 표시가 없다. 확장 화면의 단추줄에는 「서버에서 이어서」(PC 가 꺼졌을 때) · 「직접 제어」 · 「제어 돌려주기」(직접 제어 중) 가운데 하나만 있다(MUST — 2026-11-25 검토: 「직접 제어」와 「제어 돌려주기」가 함께 보였다). +- 카드: PC 에서 도는 작업은 화면 왼쪽 위에 「내 PC · <기기 이름>」, 확장 화면과 사람을 기다릴 때의 단추에 「이 PC에서 보기」가 있다. 서버에서만 도는 작업에는 표시가 없다(사람이 서버를 골랐으면 「서버 브라우저」 — 아래 「서버 브라우저를 고르기」). 확장 화면의 단추줄에서 손으로 하는 자리에는 「서버에서 이어서」(PC 가 꺼졌을 때) · 「직접 제어」 · 「제어 돌려주기」(직접 제어 중) 가운데 하나만 있다(MUST — 2026-11-25 검토: 「직접 제어」와 「제어 돌려주기」가 함께 보였다). PC 에서 일하는 동안에는 그 밖에 옮기기 단추 「서버에서 이어서」가 있다. +- 단추줄은 휴대폰 폭(390)에서도 단추 글자가 두 줄로 깨지지 않고, 한 줄에 다 들어가지 않으면 가운데 맞춘 둘째 줄로 넘어가 모든 단추가 화면 안에 보여야 한다(SHALL — 2026-12-02 휴대폰 화면: 「계획 / 2/6」 · 「작업 취 / 소」). #### Scenario: 데스크톱이 켜져 있다 - **GIVEN** 윤태호의 맥에서 데스크톱 앱 0.2.3 이 켜져 있다(「테스트 맥」) @@ -288,7 +289,7 @@ #### Scenario: 확장 화면의 단추줄 - **GIVEN** PC 에서 도는 작업의 카드를 휴대폰에서 확장했다 -- **THEN** 단추줄에 「직접 제어」만 있고 「제어 돌려주기」 · 「서버에서 이어서」는 없다 +- **THEN** 손으로 하는 자리에는 「직접 제어」만 있고 「제어 돌려주기」와 PC 가 꺼졌을 때의 「서버에서 이어서」는 없다 - **WHEN** 「직접 제어」를 누른다 - **THEN** 「제어 돌려주기」만 있고, 누르면 다시 「직접 제어」만 있다(`e2e/tests/feature/local-browser-card.spec.js` F-LB-01) @@ -302,7 +303,7 @@ - **THEN** 둘 다 같은 결과다(`server/test/browserDriver.test.js`) ### Requirement: PC 마다 동의한 작업만 그 PC 로 간다 -시스템은 PC 마다 그 PC 의 데스크톱 앱에서 정한 「브라우저 작업은 이 PC에서」 — 「내가 시킨 작업만」(`own`, 기본) · 「단계 · 예약 작업까지 모두」(`all`) · 「쓰지 않음」(`off`) — 를 따라야 한다(SHALL). 이 설정은 그 PC 의 앱이 실행 설정과 함께 저장하고 링크로 알린다(서버에는 저장하지 않는다 — 운영 SQL 없음). 웹 · 휴대폰의 설정은 PC 마다 무엇으로 정했는지와 지금 어디서 도는지를 읽기만 하고, 바꾸는 칸을 두지 않는다(MUST NOT — 바꾸기는 그 PC 의 앱에서). +시스템은 PC 마다 그 PC 의 데스크톱 앱에서 정한 「브라우저 작업은 이 PC에서」 — 「내가 시킨 작업만」(`own`, 기본) · 「단계 · 예약 작업까지 모두」(`all`) · 「쓰지 않음」(`off`) — 를 따라야 한다(SHALL). 이 설정은 그 PC 의 앱이 실행 설정과 함께 저장하고 링크로 알린다(서버에는 저장하지 않는다). 웹 · 휴대폰의 설정은 PC 마다 무엇으로 정했는지와 지금 어디서 도는지를 읽기만 하고, PC 의 설정을 바꾸는 칸을 두지 않는다(MUST NOT — 바꾸기는 그 PC 의 앱에서). 사람의 기본값 「브라우저 작업 위치」는 PC 에서 빼기만 하는 설정이라 어느 기기에서나 바꾼다(아래 「서버 브라우저를 고르기」). - 그 PC 에서 「이 컴퓨터에서 단계 실행」을 껐으면(`enabled: false`) 브라우저 설정이 무엇이든 그 PC 로 브라우저 작업을 보내지 않는다(MUST NOT). - 그 사람이 자기 채팅에서 시킨 작업만 기본으로 PC 로 간다. 사람이 없는 작업(프로세스 단계 · 예약 · MCP · 다른 사람이 시킨 것 · 회사가 정한 루틴을 묻지 않고 하는 자동 실행)은 그 PC 가 명시적으로 「단계 · 예약 작업까지 모두」일 때만 간다(정하지 않았거나 모르는 값이면 서버). @@ -337,7 +338,7 @@ #### Scenario: 웹은 읽기만 - **WHEN** 휴대폰에서 설정 › 계정 › 내 컴퓨터의 에이전트를 연다 -- **THEN** 「내가 시킨 브라우저 작업」 · 「단계 · 예약 브라우저 작업」이 지금 어디서 도는지와 PC 마다의 설정(「… — 바꾸기는 그 PC 의 앱에서」)이 보이고, 바꾸는 칸은 없다 +- **THEN** 「내가 시킨 브라우저 작업」 · 「단계 · 예약 브라우저 작업」이 지금 어디서 도는지와 PC 마다의 설정(「… — 바꾸기는 그 PC 의 앱에서」)이 보이고, PC 의 설정을 바꾸는 칸은 없다(있는 칸은 내 기본값 「브라우저 작업 위치」 하나 — F-LB-03) - **AND** 앱에서 바꾸면 서버가 곧바로 그대로 따르고, 앱의 다른 칸(실행 전에 묻기)을 바꿔도 그 설정은 남는다 ### Requirement: PC 의 브라우저는 작업이 쥔 동안만 일하고, 끝이 있다 @@ -450,6 +451,45 @@ - **WHEN** 데스크톱이 켜진 사람이 Lite 서버 자신의 페이지를 시작 주소로 브라우저 작업을 시킨다 - **THEN** 작업은 서버 브라우저에서 돈다(`where.why: 'lite-page'`) — 다른 시작 주소는 지금처럼 그 PC 에서(`server/test/browserRoute.test.js`) +### Requirement: 서버 브라우저를 고르기 +시스템은 사람의 PC 가 켜져 있어도 사람이 고르면 브라우저 작업을 서버 브라우저에서 돌려야 한다(SHALL). 근거는 사용자 지시 「pc 에 연결된 브라우저에서 동작하길 원치 않고 서버 파드에서 돌리고 싶은 경우도 지원」(2026-12-02)이다. 고르는 길은 넷이다. + +- 기본값: 설정 › 계정 › 내 컴퓨터의 에이전트 「브라우저 작업 위치」 — 「PC 우선」(기본, 지금까지와 같음) · 「늘 서버」. 그 사람의 것으로 서버에 저장하고(`pro_profile.browser_where`), 웹 · 휴대폰 · 앱 어디서나 바꾼다. 「늘 서버」면 그 사람의 작업은 PC 가 켜져 있어도 서버 브라우저에서 돈다(`where.why: 'person'`). +- 한 작업의 말: 채팅에서 그 작업을 서버에서 하라고 하면(「서버에서 해 줘」) 그 작업만 서버에서(`where.why: 'asked'`), PC 에서 하라고 하면 기본값이 「늘 서버」여도 그 작업은 PC 에서 돈다. 말을 읽는 것은 모델이다(낱말 규칙이 아니다). +- 일하는 카드의 「서버에서 이어서」: PC 에서 일하는 작업의 카드(그림이 오지 않는 자리와 확장 화면)에서 누르면 하던 걸음을 바로 멈추고(그 걸음은 작업의 한 번으로 세지 않는다), PC 의 브라우저를 놓고(실시간 화면을 멈추고 페이지를 비움), 서버 브라우저가 마지막 주소를 열어 같은 작업을 잇는다. 모델에게 「사람이 PC 에서 서버로 옮겼고, PC 의 로그인은 이 브라우저에 없다」고 알린다. 카드는 「서버 브라우저에서 이어서」. 사람을 기다리는 작업 · 이미 옮기는 중인 작업 · 서버에서 도는 작업은 옮기지 않고(답 `ok: false`), 화면은 「지금은 옮길 수 없어요 — …」라고 말한다. +- 줄 선 카드의 「서버에서 바로 시작」: PC 의 브라우저를 기다리며 줄 선 작업(「PC 브라우저는 작업을 하나씩 해요 …」)은 그 단추로 자리가 나는 대로 서버 브라우저에서 시작한다. + +규칙: +- 한 작업의 선택이 먼저, 그다음 기본값, 그다음 PC 의 설정이다. 어떤 선택도 PC 의 설정이 막은 작업을 그 PC 로 보내지 않는다(MUST NOT — 「PC 에서 해 줘」라고 해도 「쓰지 않음」인 PC 로는 가지 않는다). +- 서버로 옮긴(또는 서버를 고른) 작업은 같은 카드에서 다시 하거나 이어서 해도 서버에서 돈다. +- 사람이 서버를 고른 작업의 카드 왼쪽 위에는 「서버 브라우저」라고 쓴다. PC 가 없어 서버에서 도는 작업에는 표시가 없다. +- 기본값을 저장할 곳(`sql/076_browser_where.sql`)이 없는 설치에서는 모두 「PC 우선」으로 돌고, 바꾸기는 503(`no_column`)으로 거절되며 설정 칸이 잠겨 「이 설정을 저장할 곳이 아직 없어요 — 관리자에게 알려 주세요」라고 말한다(MUST NOT — 저장되지 않은 것을 저장했다고 하지 않는다). + +#### Scenario: 일하는 PC 작업을 서버로 +- **GIVEN** 윤태호의 「테스트 맥」에서 브라우저 작업이 가상 상점의 한 페이지에서 일하고 있다 +- **WHEN** 휴대폰의 카드에서 「서버에서 이어서」를 누른다 +- **THEN** 그 걸음이 바로 멈추고 PC 의 브라우저가 놓이며, 서버 브라우저가 같은 주소를 열어 작업이 끝까지 간다. 카드는 「서버 브라우저에서 이어서」 +- **AND** 같은 카드를 다시 하면 서버 브라우저에서 돈다 +- **AND** 옮기는 중에 한 번 더 누르면 다시 옮기지 않는다(`server/test/browser-local.test.js`) + +#### Scenario: 늘 서버 +- **WHEN** 윤태호가 「브라우저 작업 위치」를 휴대폰에서 「늘 서버」로 바꾼다 +- **THEN** 「테스트 맥」이 켜져 있어도 다음 작업은 서버 브라우저에서 돌고, 설정에 「서버 브라우저에서 해요 — 「브라우저 작업 위치」를 「늘 서버」로 정했어요 …」, 카드에 「서버 브라우저」 +- **AND** 「PC 에서 해 줘」라고 한 작업만 「테스트 맥」에서 돈다 + +#### Scenario: 이 작업만 서버에서 +- **WHEN** 「테스트 맥」이 켜져 있고 기본값이 「PC 우선」인데 채팅에서 「서버에서 가상 상점 열어 줘」라고 한다 +- **THEN** 그 작업만 서버 브라우저에서 돌고 카드에 「서버 브라우저」 + +#### Scenario: 줄 선 작업을 서버에서 바로 +- **GIVEN** 한 작업이 「테스트 맥」에서 일하고, 다음 작업이 그 PC 를 기다리며 줄 섰다 +- **WHEN** 줄 선 카드의 「서버에서 바로 시작」을 누른다 +- **THEN** 앞 작업이 PC 에서 일하는 동안 그 작업이 서버 브라우저에서 시작해 끝난다 + +#### Scenario: 저장할 곳이 없는 설치 +- **WHEN** `pro_profile.browser_where` 가 없는 설치에서 「브라우저 작업 위치」를 연다 +- **THEN** 칸이 잠겨 있고 그 까닭을 말하며, 작업은 「PC 우선」으로 돈다 + ### Requirement: PC 가 꺼지면 작업은 멈추고, 어디서 이을지는 사람이 고른다 시스템은 PC 에서 돌던 작업의 데스크톱 링크가 끊기면, 하던 걸음을 바로 끝내고 작업을 멈춰 카드에 `need: 'offline'` 과 이유를 보여야 한다(SHALL). 알약은 「PC 연결 끊김 · <사이트>」, 이유는 「「<기기>」의 PC 앱 연결이 끊겨 브라우저 작업을 멈췄어요. 「서버에서 이어서」를 누르면 …」, 단추는 「서버에서 이어서」 · 「PC가 다시 켜지면」 · 「멈추기」다. 다른 곳으로 저절로 옮기지 않는다(MUST NOT). diff --git a/server/index.js b/server/index.js index e8cfdcc1..ada8e565 100644 --- a/server/index.js +++ b/server/index.js @@ -25,6 +25,7 @@ import { ruleOf, removeRule, settleRuleConfirm } from './lib/roomRules.js' import * as vault from './lib/vault.js' import * as browser from './lib/browser.js' import * as browserRemote from './lib/browserRemote.js' +import * as browserWhere from './lib/browserWhere.js' import { listSchedules, deleteSchedule, ontoTimer, startScheduleTicker } from './lib/scheduler.js' import { generatePanel, revisePanel, savePanelData, proxyFetch } from './lib/panels.js' import { chat } from './lib/llm.js' @@ -1301,7 +1302,8 @@ app.post('/api/browser/queue', auth, async (req, res) => { }) // 다시 시도 on a card whose step stalled (content.stall): that step is left and the turn starts again from a fresh look app.post('/api/browser/retry', auth, (req, res) => { res.json({ ok: browser.retryStep(req.user.id, req.body?.taskId ? String(req.body.taskId) : undefined) }) }) -// a browser task on the person's PC whose PC went off (lib/browser.js whenOffline): 「서버에서 이어서」 (to: 'server') · 「PC가 다시 켜지면」 (to: 'wait') +// a browser task on the person's PC (lib/browser.js routeTo): 「서버에서 이어서」 (to: 'server') — one paused because the PC went off, one +// working there now, or one in line for it · 「PC가 다시 켜지면」 (to: 'wait') — a paused one app.post('/api/browser/route', auth, async (req, res) => { const to = req.body?.to === 'server' ? 'server' : req.body?.to === 'wait' ? 'wait' : null if (!to) return res.status(400).json({ error: 'to: server | wait' }) @@ -1314,6 +1316,14 @@ app.post('/api/browser/show', auth, async (req, res) => { // 「브라우저 작업은 내 PC에서」 (Settings › 계정 › 내 컴퓨터의 에이전트): where the person's browser tasks run (lib/browserRemote.js) — each PC's // own setting, kept by the desktop app and sent with its link; shown here, changed only on that PC app.get('/api/browser/where', auth, async (req, res) => res.json(await browserRemote.whereFor(req.user))) +// 「브라우저 작업 위치」: the person's own default — 'pc' (their PC when its app is on, as each PC's setting says) · 'server' (this server's +// browser even with a PC on) — lib/browserWhere.js. It only ever keeps tasks off a PC, so any of their devices may change it. +app.put('/api/browser/where', auth, async (req, res) => { + try { + await browserWhere.setPersonWhere(req.user, String(req.body?.where || '')) + res.json(await browserRemote.whereFor(req.user)) + } catch (e) { res.status(e.status || 500).json({ error: e.message, ...(e.code ? { code: e.code } : {}) }) } +}) // the run journal: the person's own record of a browser task or a chat (routes/journal.js) app.use('/api', journalRoutes(auth)) // ---------- search ---------- diff --git a/server/lib/agent.js b/server/lib/agent.js index a941892b..e1d8f5c2 100644 --- a/server/lib/agent.js +++ b/server/lib/agent.js @@ -103,6 +103,7 @@ const ROUTER_TOOLS = [ goal: { type: 'string', description: 'Self-contained: what to do and on what, with the links (and the names of files) the person gave for it — from earlier messages too when this message refers to them' }, start_url: { type: 'string', description: 'An address to open first. With a skill, leave it out unless the person gave a page on that site: the skill knows where to start' }, skill: { type: 'string', description: 'The exact name of the browser skill (listed in the system message) for this work, if one is for it' }, + where: { type: 'string', enum: ['server', 'pc'], description: "Only when the person says which browser to use for this: 'server' — the server's browser, not the one on their PC; 'pc' — the browser on their own PC. Leave it out otherwise (their settings decide)" }, ack: { type: 'string', description: '해요체 한두 문장으로 무엇을 할지 알림' } }, required: ['goal', 'ack'] }, }, }, @@ -385,18 +386,19 @@ const taskHandler = (what) => ({ kind: 'browser', label: `${L('브라우저', 'B // the browser tasks this server started, newest last (what the tests read: the skill is passed on as chosen) export const browserStarts = [] // (the ack is already in the chat; the turn it replaces stops alongside — the card need not wait for that) -function runBrowser({ user, session, threadId, goal, startUrl, skill, files = [], room, asked, replaces = true, background = '', said = [] }) { +// where: the browser the person asked for this task in their words ('server' · 'pc' — lib/browserRemote.js routeOf), else their settings +function runBrowser({ user, session, threadId, goal, startUrl, skill, files = [], room, asked, replaces = true, background = '', said = [], where = '' }) { const userId = user.id if (replaces) replaceEarlier({ user, session, threadId, room, text: asked?.text ?? goal, why: replacedText(startUrl) }) .catch((e) => console.warn('[replace]', e.message)) - console.log(`[browser] start thread=${String(threadId).slice(0, 8)} skill=${skill || '-'} url=${startUrl || '-'} files=${files.length}`) + console.log(`[browser] start thread=${String(threadId).slice(0, 8)} skill=${skill || '-'} url=${startUrl || '-'} files=${files.length}${where ? ` where=${where}` : ''}`) const own = !turnCtx.getStore()?.auto // (the person's own words go with it: what a purchase may do is set by what they asked, never by a goal a model wrote — lib/browser.js // purchaseGate; a turn nobody typed — a routine done without asking — has none: its goal decides, as before) // (a turn the server composed — a teammate's words picked up, a Home card's action: none of it is the person's own asking, so a purchase // control waits for their approval — review PR #105 round 3) const words = own ? (turnCtx.getStore()?.composed ? [] : [String(asked?.text ?? ''), ...said.filter(Boolean)]) : null - browserStarts.push({ threadId, goal, startUrl: startUrl || '', skill: skill || '', files: files.map((f) => f.name), own, background, said: words }) + browserStarts.push({ threadId, goal, startUrl: startUrl || '', skill: skill || '', files: files.map((f) => f.name), own, background, said: words, where: where || '' }) if (browserStarts.length > 20) browserStarts.shift() // the person's words go along (behind a task that waits for them, its card offers them as that task's answer — the first choice // is what the judge found likeliest: lib/browserQueue.js queueDefault); a task this turn finishes first comes before it @@ -404,7 +406,7 @@ function runBrowser({ user, session, threadId, goal, startUrl, skill, files = [] const queue = { asked: String(asked?.text ?? '').trim() || goal, default: st?.waitRead?.default || 'after' } // (the conversation of the turn that starts it, when it has one — the card is that sub-topic's: lib/projectTopics.js taskRows) const conv = st?.turn?.conv && !String(st.turn.conv).startsWith('none:') ? String(st.turn.conv) : null - runBrowserTask({ userId, threadId, goal, startUrl, files, skill, own, queue, background, ...(conv ? { conv } : {}), ...(words ? { said: words } : {}), ...(st?.after ? { after: st.after.taskId } : {}) }) + runBrowserTask({ userId, threadId, goal, startUrl, files, skill, own, queue, background, ...(conv ? { conv } : {}), ...(words ? { said: words } : {}), ...(st?.after ? { after: st.after.taskId } : {}), ...(where ? { where } : {}) }) .then((r) => postBrowserResult(userId, threadId, r)) .catch((e) => { console.warn('[browser]', e.message); addMessage(userId, threadId, 'agent', 'text', { text: L('브라우저 작업을 시작하지 못했어요. 잠시 후 다시 시도해 주세요.', "I couldn't start the browser task. Please try again in a moment."), failed: true }) }) } @@ -1045,7 +1047,9 @@ async function handleTurn({ user, session, threadId, text, context, onDelta, fil if (args.skill && !skill) console.warn(`[router] browser skill '${args.skill}' is not installed`) TP.handler(store?.turn, browserHandler(skill?.name)) const startUrl = skill?.startUrl ? (sameHost(args.start_url, skill.startUrl) ? args.start_url : skill.startUrl) : args.start_url - runBrowser({ user, session, threadId, goal: args.goal || text, startUrl: startUrl || undefined, skill: skill?.name, files, room, asked: { text, files }, background: planText }) + // (the browser the person named for it — the router reads their words: where) + const where = ['server', 'pc'].includes(args.where) ? args.where : '' + runBrowser({ user, session, threadId, goal: args.goal || text, startUrl: startUrl || undefined, skill: skill?.name, files, room, asked: { text, files }, background: planText, where }) break } case 'schedule_task': { diff --git a/server/lib/browser.js b/server/lib/browser.js index d67983ec..9d7547ff 100644 --- a/server/lib/browser.js +++ b/server/lib/browser.js @@ -33,6 +33,8 @@ import { judge } from './judge.js' import { STEP, StepError, isStop, bounded, pause, watchdog, lockHolder, profilesRunning } from './browserSteps.js' import { ServerDriver, within, blankOf, lookAt } from './browserServer.js' import { RemoteDriver, routeFor, routeOf, privateAddress, browsesHere } from './browserRemote.js' +import { personWhere } from './browserWhere.js' +import { latestDesktop, older as olderVersion, offersOff as desktopOffersOff, DOWNLOAD as DESKTOP_DOWNLOAD } from './localAgents/desktopRelease.js' import { PARALLEL, capacity } from './browserCapacity.js' import { maskUrl, withoutMasked } from './urlTokens.js' import { signInPlaces, onPlaces } from './signInSteps.js' @@ -331,9 +333,10 @@ const placeFor = (s, { toPc = false } = {}) => capacity({ mine: s.lanes.size, al // the person's tasks working now (their plan made: a lane still planning has none) — whose screen or stop is meant, when no task is named const working = (s) => lanesOf(s).filter((l) => l.task?.id) // where a task would run, as takeBrowser decides it (routeFor): the PC's browser, which takes one task at a time — or this server's -const wantsPc = (userId, { own = true, startUrl = '', fresh = false } = {}) => { +// (where · person: this task's own choice and the person's default — lib/browserRemote.js routeOf) +const wantsPc = (userId, { own = true, startUrl = '', fresh = false, where = '', person = '' } = {}) => { if (fresh) return false - try { return routeOf({ links: H.linksOf(config.tenantId, userId), own, startUrl }).kind === 'local' } catch { return false } + try { return routeOf({ links: H.linksOf(config.tenantId, userId), own, startUrl, where, person }).kind === 'local' } catch { return false } } // A place was given back: the tasks in line start in the order they came — everyone's, the server-wide cap being everyone's —, first the @@ -444,6 +447,18 @@ export function claimPc(ln) { ln.pc = true return true } +// A PC app older than the one whose live view keeps coming while its window there is minimized, hidden or covered (desktop LIVE_SINCE — +// 2026-12-02 사용자: 「Pc 에 연결된 브라우저 사용시 진행상태가 보이지 않음」, his Mac had 0.2.10): the card says which version brings it, +// with the download — only once a release of it is out (never an update that cannot be had). → { have, latest, download } | null +export const LIVE_SINCE = '0.2.13' +export function liveUpdateOf(link) { + const have = String(link?.appVersion || '') + if (!have || !olderVersion(have, LIVE_SINCE) || desktopOffersOff()) return null + const newest = latestDesktop() + if (!newest || olderVersion(newest, LIVE_SINCE)) return null + return { have, latest: newest, download: DESKTOP_DOWNLOAD } +} + // This server's browser for a lane: its first tab when no other task works there (as one task at a time had it: the page a task left // stays for the next one, and a task that goes on from that card finds it), else a tab of its own beside it — a tab kept for the card it // goes on from (reuse: keepTab) is taken again @@ -473,7 +488,8 @@ async function serverFor(ln, { reuse = null } = {}) { // fresh: a browser of its own with nothing stored — no sign-ins, no cookies — on this server, closed when the task is over (a task the agent // started with nobody watching: it sees what anyone sees). Never the person's PC. // ln: the lane it is for (its driver is set here; s.driver, the session's, follows it) · reuse: the card it goes on from (its kept tab) -async function takeBrowser(userId, ln, { own = true, unattended = false, startUrl = '', noPrivate = false, fresh = false, reuse = null } = {}) { +// where · person: this task's own choice ('server' · 'pc') and the person's default (lib/browserWhere.js) — routeOf +async function takeBrowser(userId, ln, { own = true, unattended = false, startUrl = '', noPrivate = false, fresh = false, reuse = null, where = '', person = '' } = {}) { const s = ln.session if (fresh) { const dir = fs.mkdtempSync(path.join(os.tmpdir(), 'pgl-fresh-')) @@ -489,7 +505,7 @@ async function takeBrowser(userId, ln, { own = true, unattended = false, startUr throw e } } - let r = await routeFor(userId, { own, startUrl }).catch((e) => { console.warn('[browser] route', e.message); return { kind: 'server', why: 'error' } }) + let r = await routeFor(userId, { own, startUrl, where, person }).catch((e) => { console.warn('[browser] route', e.message); return { kind: 'server', why: 'error' } }) // (the PC's browser takes one task at a time: one that finds it taken — the PC came on meanwhile — runs on this server). The claim is made // here, before anything is awaited, so two tasks never both open it if (r.kind === 'local' && !claimPc(ln)) r = { kind: 'server', why: 'pc-busy' } @@ -500,7 +516,8 @@ async function takeBrowser(userId, ln, { own = true, unattended = false, startUr await ln.driver.healthy() releaseKept(userId, s) await ln.driver.begin({ noPrivate: !!noPrivate || !!unattended || !own }) - return { kind: 'local', device: ln.driver.device.name, deviceId: ln.driver.device.id } + const update = liveUpdateOf(r.link) + return { kind: 'local', device: ln.driver.device.name, deviceId: ln.driver.device.id, ...(update ? { update } : {}) } } catch (e) { console.warn(`[browser] the browser on ${r.link.name} did not open (${e.message}) — this server's browser takes the task`) ln.pc = false @@ -973,7 +990,7 @@ function refreshQueue(userId, s) { const nf = !frontFor(s, task.threadId) const front = nf !== !!e.noFront ? { noFront: nf ? true : null } : {} e.noFront = nf - updateMessage(userId, task.id, { reason: queueReason(ahead || task, blocker, task.afterTitle, room.ok ? null : room.why, s), blocked: blockedOf(blocker), ...front }).catch(() => {}) + updateMessage(userId, task.id, { reason: queueReason(ahead || task, blocker, task.afterTitle, room.ok ? null : room.why, s), blocked: blockedOf(blocker), pcLine: !room.ok && room.why === 'pc' ? true : null, ...front }).catch(() => {}) ahead = task } } @@ -998,7 +1015,7 @@ export const keptFiles = (files) => (files || []).filter((f) => f?.name && (f.ur // sign-in hosts — lib/agentBrowser.js startTask): another host opens only after the person approves it on a card (leaveGate) // noChat: the task has no chat in Lite (an agent of Process GPT's own chat asked for it): its card lives in this server's memory (looseCard) // readOnlyWhy: why a task the agent started only reads (lib/agentBrowser.js startTask) — kept on its card beside readOnly -async function runBrowserTaskNow({ userId, threadId, goal, startUrl, onAction, unattended, own = !unattended, gates = config.browserGates, files = [], skill, resume = null, from = null, instruction = '', after = null, queue = null, background = '', said = null, onCard = null, byAgent = false, noVault = false, sites = null, confined = null, noChat = false, readOnlyWhy = '', conv = null, askFirst = '', joined = () => {} }) { +async function runBrowserTaskNow({ userId, threadId, goal, startUrl, onAction, unattended, own = !unattended, gates = config.browserGates, files = [], skill, resume = null, from = null, instruction = '', after = null, queue = null, background = '', said = null, onCard = null, byAgent = false, noVault = false, sites = null, confined = null, noChat = false, readOnlyWhy = '', conv = null, askFirst = '', where: whereArg = '', joined = () => {} }) { const s = sessionRec(userId) const t0 = Date.now() // (a task with no chat in Lite has no thread, and no card to go on from) @@ -1022,6 +1039,9 @@ async function runBrowserTaskNow({ userId, threadId, goal, startUrl, onAction, u // (…and stays on the room rule's sites when that is all it had — confined) if (!confined && Array.isArray(e.confined)) confined = e.confined } + // this task's own place (lib/browserRemote.js routeOf where): what the person asked for it ('server' · 'pc'), else — a task that goes on + // from a card — the server when that card was there by their choice (asked for, or moved there with 「서버에서 이어서」) + const whereAsked = ['server', 'pc'].includes(whereArg) ? whereArg : e?.where?.kind === 'server' && (e.where.why === 'asked' || e.where.asked) ? 'server' : '' const sk = skill ? browserSkill(skill) : null if (skill && !sk) console.warn('[browser] no browser skill named', skill) startUrl = startUrl || sk?.startUrl || '' @@ -1052,7 +1072,9 @@ async function runBrowserTaskNow({ userId, threadId, goal, startUrl, onAction, u // (the person's PC or this server: takeBrowser), its page checked (a page a task before left stuck: a fresh tab or browser — healthy) — // and the start page opens in it while the plan is being made (that page is this task's alone: its own tab, or the first tab when no // other task works there) - const route = { own, startUrl, fresh } + // (where: this task's own — the person's words for it, or the card it goes on from moved to this server; person: their default) + const person = await personWhere(userId) + const route = { own, startUrl, fresh, where: whereAsked, person } let toPc = wantsPc(userId, route) lane = !after && placeFor(s, { toPc }).ok ? addLane(s, card.id, firstLine(goal), { toPc, threadId }) : null let earlyTab = null // the tab the start page was opened in @@ -1061,7 +1083,7 @@ async function runBrowserTaskNow({ userId, threadId, goal, startUrl, onAction, u // (nobody watches it: unattended, or not the person's own — not their PC's own network; nor a task the agent started) const guarded = noPrivateFor({ unattended, own, byAgent }) const reuse = resume || from || null - ready = lane ? takeBrowser(userId, lane, { own, unattended, startUrl, noPrivate: guarded, fresh, reuse }).then((w) => { where = w }, (e) => { notTaken = e; console.warn('[browser] take', e.message) }) : null + ready = lane ? takeBrowser(userId, lane, { own, unattended, startUrl, noPrivate: guarded, fresh, reuse, where: route.where, person }).then((w) => { where = w }, (e) => { notTaken = e; console.warn('[browser] take', e.message) }) : null // (not this PC's own network for a task nobody watches: the start page waits for the check below) // (a task the agent started, the person there: a start address on a site they did not name is judged before it opens — not opened early) const leaving = !!byAgent && !unattended && !!startUrl && !onNamedSite(hostnameOf(startUrl), sites) @@ -1109,7 +1131,9 @@ async function runBrowserTaskNow({ userId, threadId, goal, startUrl, onAction, u const noFront = queued && !frontFor(s, threadId) await updateMessage(userId, card.id, { title: p.title, ...(resume ? {} : { steps: p.steps.map((t) => ({ text: t, done: false })) }), state: queued ? 'queued' : 'running', - ...(queued ? { reason: queueReason(ahead, blocker, afterTitle, room.ok ? null : room.why, s), blocked: blockedOf(blocker), offer, order: afterTitle ? { n: 2, after: afterTitle } : null, ...(noFront ? { noFront: true } : {}) } : {}), + ...(queued ? { reason: queueReason(ahead, blocker, afterTitle, room.ok ? null : room.why, s), blocked: blockedOf(blocker), offer, order: afterTitle ? { n: 2, after: afterTitle } : null, ...(noFront ? { noFront: true } : {}), + // (in line for the PC's browser: its card offers 「서버에서 바로 시작」 — moveToServer) + ...(!room.ok && room.why === 'pc' ? { pcLine: true } : {}) } : {}), ...(sk ? { skill: sk.name } : {}), startUrl, files: keptFiles(files), }) const task = { id: card.id, userId, threadId, goal, files, title: p.title, steps: p.steps, cancelled: false, waiting: null, notes: [...(resume ? e.notes || [] : [])], @@ -1156,7 +1180,8 @@ async function runBrowserTaskNow({ userId, threadId, goal, startUrl, onAction, u // the browser could not be had (this server's Chromium did not start): the card says so and the next task in line goes on — never a // card left running and a queue held (2026-11-25 review) if (!where) { - try { where = await takeBrowser(userId, ln, { own, unattended, startUrl, noPrivate: guarded, fresh, reuse }) } catch (err) { notTaken = err } + // (route.where: a card in line moved to this server — 「서버에서 바로 시작」 — says so there: routeTo) + try { where = await takeBrowser(userId, ln, { own, unattended, startUrl, noPrivate: guarded, fresh, reuse, where: route.where, person }) } catch (err) { notTaken = err } } if (!where) { console.warn(`[browser] task ${card.id}: no browser — ${notTaken?.message}`) @@ -1381,6 +1406,23 @@ async function drive(s, task, { messages, onAction, stop = () => false }) { turn-- continue } + // the person moved it from their PC to this server's browser (「서버에서 이어서」 on its card while it worked there — moveToServer) + if (task.moveTo === 'server') { + task.moveTo = null + // (moving: a second 「서버에서 이어서」 while this one is on its way is not another move) + task.moving = true + try { + if (s.driver.kind === 'local') { + const was = s.driver + const url = was.url() + // (the PC's browser lets go of it: no more frames, its page cleared — the PC is free for the next task) + await was.idle?.().catch(() => {}) + await toServer(s, task, messages, { url, device: was.device || {}, asked: true }).catch((e) => console.warn(`[browser] task ${task.id}: to the server`, e.message)) + } + } finally { task.moving = false } + turn-- + continue + } // this server's browser closed under the task (it crashed: every tab of it went with it): the task ends saying so — the next task opens // the browser again if (s.driver.kind === 'server' && (s.driver.closed || (s.gen != null && s.driver.browser?.gen !== s.gen))) { @@ -2318,8 +2360,10 @@ async function whenOffline(s, task, messages) { return {} } -// 「서버에서 이어서」: this server's browser takes the task from the page it was on (the card says so, and so does the agent) -async function toServer(s, task, messages, { url, device }) { +// 「서버에서 이어서」: this server's browser takes the task from the page it was on (the card says so, and so does the agent). asked: the +// person moved it while their PC was on (moveToServer) — a task that goes on from this card stays on this server (where.asked); else +// their PC went off (whenOffline) +async function toServer(s, task, messages, { url, device, asked = false }) { s.session.driver = await serverFor(s) await s.driver.healthy().catch((e) => console.warn('[browser] health check', e.message)) s.gen = s.driver.browser?.gen ?? null @@ -2327,27 +2371,30 @@ async function toServer(s, task, messages, { url, device }) { s.pc = false s.toPc = false pump() - task.where = { kind: 'server', from: 'local', device: device.name || '' } - jot(task, 'to_server', { device: device.name || null }) + task.where = { kind: 'server', from: 'local', device: device.name || '', ...(asked ? { asked: true } : {}) } + jot(task, 'to_server', { device: device.name || null, ...(asked ? { asked: true } : {}) }) task.moves = (task.moves || 0) + 1 await updateMessage(task.userId, task.id, { where: task.where }) if (url && !/^about:/.test(url)) { say(task, L(`서버 브라우저에서 ${hostOf(url)} 여는 중`, `Opening ${hostOf(url)} in the server's browser`)) await s.driver.navigate(url, { signal: task.abort.signal }).catch(() => {}) } - console.log(`[browser] task ${task.id}: goes on in this server's browser at ${shown(url) || '(no address)'} (the person chose it; ${device.name} is off)`) - messages.push({ role: 'user', content: `[The person's PC went offline. The task goes on in the server's browser, which opened ${shown(url) || 'a blank page'} again. Sign-ins made on the PC are not in this browser: a page that needs one may ask to sign in now.]` }) + console.log(`[browser] task ${task.id}: goes on in this server's browser at ${shown(url) || '(no address)'} (the person chose it; ${device.name} ${asked ? 'is on' : 'is off'})`) + messages.push({ role: 'user', content: `[${asked ? "The person moved this task from their PC's browser to the server's browser." : "The person's PC went offline."} The task goes on in the server's browser, which opened ${shown(url) || 'a blank page'} again. Sign-ins made on the PC are not in this browser: a page that needs one may ask to sign in now.]` }) task.prev = null task.judged = null await pushFrame(task.userId, s) return {} } -// The person's choice on a paused task's card (POST /api/browser/route): 'server' — this server's browser takes it now; -// 'wait' — it waits for the PC (the card says so). → false when that task is not paused for its PC. +// The person's choice on a card (POST /api/browser/route): 'server' — this server's browser takes it now: a task paused for its PC that +// went off, one working on their PC (moveToServer — 2026-12-02 사용자: 「pc 에 연결된 브라우저에서 동작하길 원치 않고 서버 파드에서 돌리고 +// 싶은 경우도 지원」), or one in line for their PC's browser (it starts on this server as soon as there is room); 'wait' — a paused one waits +// for the PC (the card says so). → false when that task is none of these. export async function routeTo(userId, taskId, to) { const s = sessions.get(userId) const t = taskId ? taskById(s, taskId) : tasksOf(s).find((x) => x.offline) + if (to === 'server' && taskId && !t?.offline) return moveToServer(userId, String(taskId)) if (!t?.offline || !t.waiting) return false if (to === 'server') { t.waiting(TO_SERVER); return true } if (to === 'wait') { @@ -2358,6 +2405,35 @@ export async function routeTo(userId, taskId, to) { return false } +// 「서버에서 이어서」 on the card of a task working on the person's PC: the step under way ends, and the next turn goes on in this server's +// browser from the page it was on (the loop: task.moveTo). A task in line for their PC's browser starts on this server instead. Not one that +// waits for the person — they answer it where it is (a sign-in on the PC is that PC's), nor one already on this server. → true when moved +export async function moveToServer(userId, taskId) { + const s = sessions.get(userId) + if (!s || !taskId) return false + const queued = s.queue.find((e) => e.task?.id === taskId) + if (queued) { + if (!queued.toPc && queued.route?.where !== 'pc') return false + // (the same object the waiting task reads when it starts — takeBrowser route.where) + if (queued.route) queued.route.where = 'server' + else queued.route = { where: 'server' } + queued.toPc = false + jot(queued.task, 'to_server', { asked: true, queued: true }) + await updateMessage(userId, taskId, { where: { kind: 'server', why: 'asked' }, pcLine: null }).catch(() => {}) + pump() + if (s.queue.length) refreshQueue(userId, s) + return true + } + const ln = laneById(s, taskId) + const t = ln?.task + if (!t || t.cancelled || t.waiting || t.moveTo || t.moving || ln.driver?.kind !== 'local' || ln.driver.lost) return false + t.moveTo = 'server' + say(t, L('서버 브라우저로 옮기는 중', "Moving to the server's browser")) + // (the step under way stops at once — it does not count as one of the agent's turns, like a PC that went off part way) + if (t.retry) { t.lostTurn = true; t.retry.abort('retry') } + return true +} + // An error that ended the task, in words the person can act on. function failReason(e) { const m = String(e?.message || '') diff --git a/server/lib/browserRemote.js b/server/lib/browserRemote.js index 30fa71c4..295bf346 100644 --- a/server/lib/browserRemote.js +++ b/server/lib/browserRemote.js @@ -11,8 +11,11 @@ // · a task that starts on a page of this Lite server itself (a share page, a preview Lite showed): this server — the PC's agent // browser does not open the Lite it is linked to (desktop/src/policy.js agentMay; lib/liteOwn.js liteOwnPage) // · a desktop older than 0.2.6 (no caps.browserGuard — its browser neither keeps off the Lite app nor marks its requests): this server +// · the person chose this server (2026-12-02): for every task (their default — lib/browserWhere.js, 'person'), or for this one (their +// words for it, or 「서버에서 이어서」 on its card — 'asked'). A choice of theirs never sends a task to a PC whose setting keeps it off. // Else this server, as before (phones only, an older desktop). Decided when a task gets the browser; a task never moves by itself after -// that — a PC that goes off pauses it and the person chooses (lib/browser.js whenOffline). +// that — a PC that goes off pauses it and the person chooses (lib/browser.js whenOffline), and the person may move a task working on +// their PC to this server (lib/browser.js moveToServer). // // Secrets: a vault value goes to the desktop only for one fill, only over the link this task runs on — which is the task's own // person's (checked at open and at each fill) — and the desktop types it into the field without keeping or logging it. What the @@ -26,6 +29,7 @@ import { maskUrl } from './urlTokens.js' import * as BL from './localAgents/browserLink.js' import * as H from './localAgents/hub.js' import { liteOwnPage } from './liteOwn.js' +import { personWhere, canKeep } from './browserWhere.js' import { config } from '../config.js' export const LinkLost = BL.LinkLost @@ -74,7 +78,12 @@ export const prefOf = (link) => (link?.prefs?.enabled === false ? 'off' : ['off' export { liteOwnPage } from './liteOwn.js' // startUrl: where the task starts — a page of this Lite server keeps it on this server even when a PC would take it ('lite-page') -export function routeOf({ links = [], own = true, startUrl = '' } = {}) { +// where: this task's own choice — 'server': the person asked for this server's browser (their words, or 「서버에서 이어서」 on its card: +// 'asked'); 'pc': they asked for their PC (their default does not hold it back) · person: their default (lib/browserWhere.js) — 'server': +// this server's browser even with a PC on ('person'). Neither ever sends a task to a PC its own setting keeps it off. +export function routeOf({ links = [], own = true, startUrl = '', where = '', person = '' } = {}) { + if (where === 'server') return { kind: 'server', why: 'asked' } + if (where !== 'pc' && person === 'server') return { kind: 'server', why: 'person' } if (!links.length) return { kind: 'server', why: 'no-desktop' } const able = links.filter(browsesHere).sort((a, b) => b.since - a.since) if (!able.length) return { kind: 'server', why: 'old-desktop' } @@ -85,16 +94,20 @@ export function routeOf({ links = [], own = true, startUrl = '' } = {}) { if (startUrl && liteOwnPage(startUrl)) return { kind: 'server', why: 'lite-page' } return { kind: 'local', link: ok[0] } } -export async function routeFor(userId, { own = true, startUrl = '' } = {}) { - return routeOf({ links: H.linksOf(config.tenantId, userId), own, startUrl }) +export async function routeFor(userId, { own = true, startUrl = '', where = '', person = '' } = {}) { + return routeOf({ links: H.linksOf(config.tenantId, userId), own, startUrl, where, person }) } // what the settings show, everywhere (web · phone · the app): each linked desktop's own setting, and where the person's own tasks and the // ones nobody watches run now. Changed only on that PC (the app's settings), never from here. +// person: the person's own default (lib/browserWhere.js — changed from any device) · kept: whether it can be changed here (sql/076) export async function whereFor(user) { const links = H.linksOf(config.tenantId, user.id) - const own = routeOf({ links, own: true }) - const unattended = routeOf({ links, own: false }) + const person = await personWhere(user.id) + const own = routeOf({ links, own: true, person }) + const unattended = routeOf({ links, own: false, person }) return { + person, + kept: canKeep(), own: { where: own.kind, why: own.why || null, device: own.link ? { id: own.link.id, name: own.link.name } : null }, unattended: { where: unattended.kind, why: unattended.why || null, device: unattended.link ? { id: unattended.link.id, name: unattended.link.name } : null }, devices: links.map((l) => ({ id: l.id, name: l.name, browser: browsesHere(l), pref: prefOf(l), enabled: l.prefs?.enabled !== false })), diff --git a/server/lib/browserWhere.js b/server/lib/browserWhere.js new file mode 100644 index 00000000..6eb78f0a --- /dev/null +++ b/server/lib/browserWhere.js @@ -0,0 +1,65 @@ +// Where a person's browser tasks run by default (설정 › 계정 › 내 컴퓨터의 에이전트 「브라우저 작업 위치」, sql/076 pro_profile.browser_where): +// 'pc' — their PC's browser when their desktop app is on (each PC's own 「브라우저 작업은 이 PC에서」 decides which tasks: lib/browserRemote.js +// routeOf), else this server's. The default, as before. +// 'server' — this server's browser even with the PC on (2026-12-02 사용자: 「pc 에 연결된 브라우저에서 동작하길 원치 않고 서버 파드에서 +// 돌리고 싶은 경우도 지원」). +// One task can go elsewhere by itself: the person's words for it (browser_task where — lib/agent.js) or 「서버에서 이어서」 on a running card +// (lib/browser.js moveToServer). That choice wins over this one. Changing this never makes a PC take more: a PC takes a task only by its own +// setting (changed only on that PC), so this setting can only move tasks off the PC — which is why it may be changed from any device. +// Read when a task starts (kept a minute: another replica's change shows within it). Without the column (sql/076 not run yet) everyone is +// 'pc' and a change is refused (503 no_column) — never a change said to be saved that is not. +import { q } from './supa.js' + +export const WHERE = ['pc', 'server'] +const CACHE_MS = 60_000 +const cache = new Map() // userId → { where, at } +let noColumn = false // (the column is not there: read as 'pc' without asking each time — until a change is tried again) + +const UNDEFINED_COLUMN = '42703' + +// the person's choice now → 'pc' | 'server' +export async function personWhere(userId) { + if (!userId) return 'pc' + const id = String(userId) + const c = cache.get(id) + if (c && Date.now() - c.at < CACHE_MS) return c.where + if (noColumn) return 'pc' + try { + const [r] = await q('select browser_where from pro_profile where user_id=$1', [id]) + const where = r?.browser_where === 'server' ? 'server' : 'pc' + cache.set(id, { where, at: Date.now() }) + if (cache.size > 5000) cache.delete(cache.keys().next().value) + return where + } catch (e) { + if (e?.code === UNDEFINED_COLUMN) { noColumn = true; return 'pc' } + // (the database did not answer: as before — the PC when it is on) + console.warn('[browser-where] read', e.message) + return 'pc' + } +} + +// whether the choice can be kept (the column is there), as last seen +export const canKeep = () => !noColumn + +// → 'pc' | 'server' as kept. Throws { status: 400 } for another value, { status: 503, code: 'no_column' } without the column. +export async function setPersonWhere(user, where) { + if (!WHERE.includes(where)) throw Object.assign(new Error(`where: ${WHERE.join(' | ')}`), { status: 400 }) + const id = String(user.id) + try { + // (null for the default: a row that never chose stays as it was) + await q(`insert into pro_profile(user_id, email, browser_where) values ($1, $2, $3) + on conflict (user_id) do update set browser_where = excluded.browser_where`, [id, user.email || null, where === 'server' ? 'server' : null]) + } catch (e) { + if (e?.code === UNDEFINED_COLUMN) { + noColumn = true + throw Object.assign(new Error('브라우저 작업 위치를 저장할 곳이 아직 없어요(데이터베이스 076). 관리자에게 알려 주세요.'), { status: 503, code: 'no_column' }) + } + throw e + } + noColumn = false + cache.set(id, { where, at: Date.now() }) + return where +} + +// (tests) +export function _forget() { cache.clear(); noColumn = false } diff --git a/server/lib/localAgents/chat.js b/server/lib/localAgents/chat.js index 2a98bd6a..7d01bbd3 100644 --- a/server/lib/localAgents/chat.js +++ b/server/lib/localAgents/chat.js @@ -35,14 +35,14 @@ import * as D from './devices.js' import * as R from './relay.js' import * as ST from './steps.js' import { josa, eulReul } from '../josa.js' -import { latestDesktop, older, offersOff } from './desktopRelease.js' +import { latestDesktop, older, offersOff, DOWNLOAD } from './desktopRelease.js' import { pageRefs } from '../attachments.js' const T = () => config.tenantId export const KIND = 'chat' // what the picker offers (OpenHands is found but not run yet — design §9) export const AGENTS = ['claude-code', 'codex'] -export const DOWNLOAD = 'https://www.uengine.org/contents/processgptlite.html#desktop' +export { DOWNLOAD } from './desktopRelease.js' const LIVE = ['queued', 'offered', 'running'] const RECAP_N = 10 const CARDS_MAX = 8 diff --git a/server/lib/localAgents/desktopRelease.js b/server/lib/localAgents/desktopRelease.js index b2b3a93f..d77fc994 100644 --- a/server/lib/localAgents/desktopRelease.js +++ b/server/lib/localAgents/desktopRelease.js @@ -26,6 +26,8 @@ export function older(a, b) { return false } export const DESKTOP_REPO = 'uengine-oss/process-gpt-lite-desktop' +// where a person gets the desktop app (the home page's download section) +export const DOWNLOAD = 'https://www.uengine.org/contents/processgptlite.html#desktop' export const LITE_REPO = 'uengine-oss/process-gpt-lite' // the highest app version among published releases (drafts and pre-releases are not offered). tags: 'desktop' — only desktop-vX.Y.Z // (this repository, where vX.Y.Z is the server); 'app' — vX.Y.Z or desktop-vX.Y.Z (the desktop app's own repository) diff --git a/server/sql/076_browser_where.sql b/server/sql/076_browser_where.sql new file mode 100644 index 00000000..bdfd7e9b --- /dev/null +++ b/server/sql/076_browser_where.sql @@ -0,0 +1,11 @@ +-- 브라우저 작업을 어디서 할지(사람마다, 설정 › 계정 › 내 컴퓨터의 에이전트 「브라우저 작업 위치」): 비어 있으면 PC 앱이 켜져 있을 때 +-- 그 PC 의 브라우저(지금까지와 같음 — 각 PC 의 「브라우저 작업은 이 PC에서」 설정을 따름), 'server' 면 PC 가 켜져 있어도 서버 브라우저 +-- (lib/browserWhere.js). 한 작업만 서버에서 하는 길은 따로 있다 — 채팅에서 「서버에서 해 줘」, 실행 중인 카드의 「서버에서 이어서」. +-- 이 열이 없으면 모두 PC 우선으로 돌고, 바꾸기는 503(no_column)으로 거절한다. +-- Idempotent: safe to run again. + +alter table pro_profile add column if not exists browser_where text; +do $$ begin + alter table pro_profile add constraint pro_profile_browser_where_check check (browser_where is null or browser_where in ('pc', 'server')); +exception when duplicate_object then null; +end $$; diff --git a/server/test/browser-local.test.js b/server/test/browser-local.test.js index 576ef936..ac9a5197 100644 --- a/server/test/browser-local.test.js +++ b/server/test/browser-local.test.js @@ -325,6 +325,79 @@ test('PC 가 꺼진 채 「서버에서 이어서」: 서버 브라우저가 같 await startPc() }) +// ---- 서버 브라우저를 고르기 (2026-12-02 사용자: 「pc 에 연결된 브라우저에서 동작하길 원치 않고 서버 파드에서 돌리고 싶은 경우도 지원」) ---- +test('PC 에서 일하는 작업의 「서버에서 이어서」(PC 는 켜진 채): 그 걸음은 바로 멈추고 서버 브라우저가 같은 페이지에서 이어서 끝낸다 — PC 의 브라우저는 놓이고, 모델은 옮긴 까닭을 듣고, 같은 카드를 다시 하면 서버에서', { skip }, async () => { + if (!pcLink()) await startPc() + const goal = 'PC 에서 서버로 옮기기' + let told = '' + const from = (sentTo.get(user) || []).length + const p = run(goal, [ + 'hang', + (b) => { told = b.messages.filter((m) => m.role === 'user' && typeof m.content === 'string' && m.content.includes('moved this task')).map((m) => m.content).join(' '); return ['note', { text: lastSnap(b).url }] }, + ['finish', { summary: '서버에서 이어서 끝냈어요.' }], + ], { startUrl: `${site.url}/shop?from=pc-move` }) + // working on the PC, its model step under way + const c = await until(async () => { const x = await card(goal); return x?.content?.where?.kind === 'local' && scripts[goal].i >= 1 ? x : null }) + assert.ok(c, 'PC 에서 일하는 중') + assert.equal(await browser.routeTo(user, c.id, 'server'), true) + assert.equal(await browser.routeTo(user, c.id, 'server'), false, '이미 옮기는 중이면 다시 옮기지 않는다') + const r = await p + assert.equal(r.state, 'done', JSON.stringify(r).slice(0, 300)) + assert.deepEqual(r.where, { kind: 'server', from: 'local', device: '시험 PC', asked: true }) + assert.equal(r.notes.at(-1), `${site.url}/shop?from=pc-move`, '서버 브라우저가 같은 페이지를 열었다') + assert.match(told, /moved this task from their PC's browser to the server's browser/) + assert.ok(await until(() => scripts[goal].dropped === 1, 3000), 'PC 에서 기다리던 모델 걸음은 버렸다') + const ops = (sentTo.get(user) || []).slice(from).map((m) => JSON.parse(m).op).filter(Boolean) + assert.ok(ops.includes('idle'), `PC 의 브라우저를 놓았다: ${ops.join(',')}`) + const done = await card(goal) + assert.deepEqual(done.content.where, { kind: 'server', from: 'local', device: '시험 PC', asked: true }) + // the same card again: on this server (the person moved it there), not back on the PC + scripts[goal] = { i: 0, moves: [['finish', { summary: '다시 했어요.' }]] } + const again = await browser.runBrowserTask({ userId: user, threadId, resume: c.id, gates: false }) + assert.deepEqual(again.where, { kind: 'server', why: 'asked' }) +}) + +test('채팅에서 이 작업만 서버로(browser_task where: server): PC 가 켜져 있어도 서버 브라우저 — 카드에 그렇게 남는다', { skip }, async () => { + if (!pcLink()) await startPc() + const r = await run('말로 서버', [['note', { text: '서버' }], ['finish', { summary: '서버에서 했어요.' }]], { where: 'server' }) + assert.deepEqual(r.where, { kind: 'server', why: 'asked' }) + assert.deepEqual((await card('말로 서버')).content.where, { kind: 'server', why: 'asked' }) +}) + +test('설정 「브라우저 작업 위치」 = 늘 서버: PC 가 켜져 있어도 서버에서, 「PC 에서 해 줘」라고 한 작업만 PC — 되돌리면 다시 PC', { skip }, async () => { + if (!pcLink()) await startPc() + const W = await import('../lib/browserWhere.js') + await W.setPersonWhere({ id: user }, 'server') + try { + assert.deepEqual((await R.whereFor({ id: user })).own, { where: 'server', why: 'person', device: null }) + let r = await run('기본값 서버', [['note', { text: '서버' }], ['finish', { summary: '서버에서 했어요.' }]]) + assert.deepEqual(r.where, { kind: 'server', why: 'person' }) + r = await run('기본값 서버인데 PC', [['note', { text: 'PC' }], ['finish', { summary: 'PC 에서 했어요.' }]], { where: 'pc' }) + assert.equal(r.where.kind, 'local', '이 작업은 PC 에서라고 한 말이 먼저') + } finally { await W.setPersonWhere({ id: user }, 'pc') } + const r = await run('기본값 PC', [['note', { text: 'PC' }], ['finish', { summary: 'PC 에서 했어요.' }]]) + assert.equal(r.where.kind, 'local') +}) + +test('PC 브라우저를 기다리며 줄 선 작업의 「서버에서 바로 시작」: 앞 작업이 PC 에서 일하는 동안 서버에서 시작해 끝낸다', { skip }, async () => { + if (!pcLink()) await startPc() + let release + const hold = new Promise((r) => { release = r }) + const a = run('줄 앞 PC', [async () => { await hold; return ['note', { text: 'A' }] }, ['finish', { summary: 'A 끝' }]]) + try { + assert.ok(await until(async () => (await card('줄 앞 PC'))?.content?.where?.kind === 'local'), '앞 작업이 PC 에서 일한다') + const b = run('줄 뒤 서버로', [['note', { text: 'B' }], ['finish', { summary: 'B 끝' }]]) + const qc = await until(async () => { const x = await card('줄 뒤 서버로'); return x?.content?.state === 'queued' && x.content.pcLine ? x : null }) + assert.ok(qc, 'PC 를 기다리며 줄 섰다 — 카드가 「서버에서 바로 시작」을 낸다(pcLine)') + assert.equal(await browser.routeTo(user, qc.id, 'server'), true) + const rb = await b + assert.equal(rb.state, 'done', JSON.stringify(rb).slice(0, 300)) + assert.deepEqual(rb.where, { kind: 'server', why: 'asked' }) + assert.equal((await card('줄 뒤 서버로')).content.pcLine ?? null, null) + } finally { release() } + assert.equal((await a).where.kind, 'local') +}) + // this PC's own setting, as the desktop app reports it with its runner settings (caps.prefs — desktop/src/settings.js runnerPrefs) const setPc = (prefs) => H.receive(pcLink(), { type: 'caps', prefs: { enabled: true, ...prefs } }) diff --git a/server/test/browserWhere.test.js b/server/test/browserWhere.test.js new file mode 100644 index 00000000..ce19d98b --- /dev/null +++ b/server/test/browserWhere.test.js @@ -0,0 +1,93 @@ +// 브라우저 작업을 어디서 할지 — 사람의 기본값(설정 「브라우저 작업 위치」, sql/076)과 한 작업의 선택(채팅의 말 · 카드의 「서버에서 이어서」)이 +// PC 의 설정 위에서 어떻게 겹치는지, 그리고 PC 앱이 진행 화면을 못 보내는 옛 판일 때 카드가 무엇을 알리는지 +// (2026-12-02 사용자: 「Pc 에 연결된 브라우저 사용시 진행상태가 보이지 않음 … pc 에 연결된 브라우저에서 동작하길 원치 않고 서버 파드에서 +// 돌리고 싶은 경우도 지원」). +// Run: node --test test/browserWhere.test.js (로컬 DB — pro_profile.browser_where 열: sql/076) +import test, { after } from 'node:test' +import assert from 'node:assert/strict' +import crypto from 'node:crypto' + +const { routeOf } = await import('../lib/browserRemote.js') +const W = await import('../lib/browserWhere.js') +const B = await import('../lib/browser.js') +const DR = await import('../lib/localAgents/desktopRelease.js') +const { q, pool } = await import('../lib/supa.js') + +const pc = (id, since, prefs = {}) => ({ id, name: id, since: new Date(since), caps: { browser: true, browserGuard: true }, prefs }) +const user = { id: crypto.randomUUID(), email: 'where-test@example.test' } + +after(async () => { + await q('delete from pro_profile where user_id=$1', [user.id]).catch(() => {}) + await pool.end() +}) + +test('어디서 도나: 한 작업의 선택이 먼저, 그다음 사람의 기본값, 그다음 PC 의 설정 — 사람의 선택은 PC 가 막은 작업을 PC 로 보내지 않는다', () => { + const on = [pc('a', 1)] + assert.equal(routeOf({ links: on }).kind, 'local', '정한 것 없음: 켜진 PC') + assert.deepEqual(routeOf({ links: on, where: 'server' }), { kind: 'server', why: 'asked' }, '이 작업은 서버에서(말 · 카드)') + assert.deepEqual(routeOf({ links: on, person: 'server' }), { kind: 'server', why: 'person' }, '기본값 「늘 서버 브라우저」') + assert.equal(routeOf({ links: on, person: 'server', where: 'pc' }).kind, 'local', '이 작업은 PC 에서라고 하면 기본값보다 먼저') + assert.deepEqual(routeOf({ links: [pc('a', 1, { browser: 'off' })], where: 'pc' }), { kind: 'server', why: 'off' }, 'PC 가 끈 작업은 「PC 에서」라고 해도 서버') + assert.deepEqual(routeOf({ links: on, own: false, where: 'pc' }), { kind: 'server', why: 'not-own' }, '사람이 없는 작업은 그 PC 가 「모두」일 때만') + assert.deepEqual(routeOf({ links: [], where: 'pc' }), { kind: 'server', why: 'no-desktop' }) + assert.deepEqual(routeOf({ links: [], person: 'server' }), { kind: 'server', why: 'person' }, '기본값을 서버로 정했으면 PC 가 없어도 그렇게 말한다') + assert.equal(routeOf({ links: on, person: 'pc' }).kind, 'local') + assert.equal(routeOf({ links: on, where: 'anything' }).kind, 'local', '모르는 값은 정하지 않은 것') +}) + +test('사람의 기본값은 저장되고(어느 기기에서나 바꿀 수 있음) 다음 작업부터 읽힌다 — 다른 값은 400, 지우면 PC 우선', async () => { + W._forget() + assert.equal(await W.personWhere(user.id), 'pc', '정한 적 없음 = PC 우선') + assert.equal(await W.setPersonWhere(user, 'server'), 'server') + W._forget() + assert.equal(await W.personWhere(user.id), 'server', '다시 읽어도 서버') + const [row] = await q('select browser_where, email from pro_profile where user_id=$1', [user.id]) + assert.equal(row.browser_where, 'server') + await assert.rejects(W.setPersonWhere(user, 'pod'), (e) => e.status === 400) + assert.equal(await W.setPersonWhere(user, 'pc'), 'pc') + W._forget() + assert.equal(await W.personWhere(user.id), 'pc') + const [back] = await q('select browser_where from pro_profile where user_id=$1', [user.id]) + assert.equal(back.browser_where, null, '기본값은 비워 둔다') + assert.equal(W.canKeep(), true) +}) + +test('설정 화면이 보는 것(whereFor): 기본값과 그것으로 정해진 곳', async () => { + const R = await import('../lib/browserRemote.js') + await W.setPersonWhere(user, 'server') + let w = await R.whereFor(user) + assert.equal(w.person, 'server') + assert.equal(w.kept, true) + assert.deepEqual(w.own, { where: 'server', why: 'person', device: null }) + assert.deepEqual(w.unattended, { where: 'server', why: 'person', device: null }) + await W.setPersonWhere(user, 'pc') + w = await R.whereFor(user) + assert.equal(w.person, 'pc') + assert.deepEqual(w.own, { where: 'server', why: 'no-desktop', device: null }) +}) + +test('PC 앱이 진행 화면을 못 보내는 옛 판이면 카드가 새 판을 알린다 — 그 판이 나온 뒤에만, 꺼 둔 설치에서는 알리지 않는다', () => { + const keep = { latest: process.env.PRO_DESKTOP_LATEST, repo: process.env.PRO_DESKTOP_RELEASES_REPO } + try { + delete process.env.PRO_DESKTOP_RELEASES_REPO + process.env.PRO_DESKTOP_LATEST = '0.2.13' + assert.deepEqual(B.liveUpdateOf({ appVersion: '0.2.10' }), { have: '0.2.10', latest: '0.2.13', download: DR.DOWNLOAD }) + process.env.PRO_DESKTOP_LATEST = '0.2.15' + assert.equal(B.liveUpdateOf({ appVersion: '0.2.12' }).latest, '0.2.15', '나온 것 중 가장 새 판') + assert.equal(B.liveUpdateOf({ appVersion: '0.2.13' }), null, '이미 그 판') + assert.equal(B.liveUpdateOf({ appVersion: '' }), null, '판을 모름') + process.env.PRO_DESKTOP_LATEST = '0.2.12' + assert.equal(B.liveUpdateOf({ appVersion: '0.2.10' }), null, '그 판이 아직 안 나왔으면 알리지 않는다(받을 수 없는 판)') + delete process.env.PRO_DESKTOP_LATEST + process.env.PRO_DESKTOP_RELEASES_REPO = 'off' + assert.equal(B.liveUpdateOf({ appVersion: '0.2.10' }), null, '새 판 알림을 끈 설치') + } finally { + if (keep.latest === undefined) delete process.env.PRO_DESKTOP_LATEST; else process.env.PRO_DESKTOP_LATEST = keep.latest + if (keep.repo === undefined) delete process.env.PRO_DESKTOP_RELEASES_REPO; else process.env.PRO_DESKTOP_RELEASES_REPO = keep.repo + } +}) + +test('옮기기는 그 사람의 일하는 PC 작업만 — 없는 작업 · 남의 작업은 false', async () => { + assert.equal(await B.moveToServer(user.id, crypto.randomUUID()), false) + assert.equal(await B.routeTo(user.id, crypto.randomUUID(), 'server'), false) +}) diff --git a/src/components/LocalAgentsSettings.vue b/src/components/LocalAgentsSettings.vue index 457ece7e..e1de952b 100644 --- a/src/components/LocalAgentsSettings.vue +++ b/src/components/LocalAgentsSettings.vue @@ -2,7 +2,9 @@ // 설정 › 계정 › 내 컴퓨터의 에이전트 (server lib/localAgents, desktop/src/runner): in the desktop app, this computer — linked or not, its // CLI agents (Claude Code · Codex · OpenHands: installed, version, signed in) and the person's two switches (local runs on/off, ask before // each run, 「브라우저 작업은 이 PC에서」); everywhere, the person's desktops with 「연결 해제」(the token is revoked, the link closes) and where -// their browser tasks run now (server lib/browserRemote.js — each PC's own setting, changed only on that PC: read-only elsewhere). +// their browser tasks run now (server lib/browserRemote.js — each PC's own setting, changed only on that PC: read-only elsewhere), and the +// person's own 「브라우저 작업 위치」 (server lib/browserWhere.js — PC first, or always this server's browser: changed from any device, since +// it only ever keeps tasks off a PC). // Inside a desktop app too old to link this computer (no runner bridge), or older than the newest release, the newest app's link. import { ref, computed, onMounted } from 'vue' import { api } from '../api.js' @@ -18,7 +20,7 @@ const busy = ref('') const st = computed(() => runner.status) const here = computed(() => st.value?.deviceId || null) const clis = computed(() => Object.entries(st.value?.clis || {})) -const web = ref(null) // { own: {where, why, device}, unattended: {…}, devices: [{id, name, browser, pref, enabled}], min } +const web = ref(null) // { person: 'pc' | 'server', kept, own: {where, why, device}, unattended: {…}, devices: [{id, name, browser, pref, enabled}], min } async function load() { devices.value = await api('/local-agents/devices').catch((e) => { err.value = e.message; return [] }) web.value = await api('/browser/where').catch(() => null) @@ -41,8 +43,13 @@ const permissionHint = computed(() => { if (p === 'edits') return `작업 폴더 안의 파일 고치기는 묻지 않고, 명령은 CLI 가 물어요. ${scope}` return `CLI 가 안전한 일은 스스로 판단해 진행하고, 위험한 일만 물어요${without.length ? ` — ${eunNeun(without.join(' · '))} 자동 모드가 없는 판이라 「편집만 허락」으로 돌아요` : ''}. ${scope}` }) +// 「브라우저 작업 위치」: the person's default — 2026-12-02 사용자 「pc 에 연결된 브라우저에서 동작하길 원치 않고 서버 파드에서 돌리고 싶은 경우도 +// 지원」. One task can still go elsewhere (their words for it, 「서버에서 이어서」 on its card) +const PLACES = [['pc', 'PC 우선'], ['server', '늘 서버']] +const setPerson = (where) => run('person', async () => { web.value = await api('/browser/where', { method: 'PUT', body: { where } }) }) const whereLine = (w, nobody) => { if (!w) return '' + if (w.why === 'person') return '서버 브라우저에서 해요 — 「브라우저 작업 위치」를 「늘 서버」로 정했어요. PC 에서 한 로그인은 서버 브라우저에 없어요' if (w.where === 'local') return `「${w.device?.name || 'PC'}」의 브라우저에서 해요 — 그 PC 에서 한 로그인을 그대로 쓰고, 로그인은 그 PC 에 남아요` if (w.why === 'old-desktop') return `서버 브라우저에서 해요 — PC 앱을 ${web.value?.min} 이상으로 올리면 그 PC 의 브라우저에서 할 수 있어요` if (w.why === 'off') return '서버 브라우저에서 해요 — PC 앱에서 「브라우저 작업은 이 PC에서」를 껐어요' @@ -128,6 +135,13 @@ const cliLine = (c) => (!c.installed ? '설치돼 있지 않아요' : [c.version
데스크톱 앱에서 연결해요Process GPT Lite 데스크톱 앱으로 로그인하면 그 컴퓨터의 Claude Code · Codex 가 내 단계를 실행할 수 있어요
+ +
+
브라우저 작업 위치{{ web.kept === false ? '이 설정을 저장할 곳이 아직 없어요 — 관리자에게 알려 주세요' : 'PC 우선: PC 앱이 켜져 있으면 그 PC 의 브라우저에서 해요. 한 작업만 서버에서 하려면 채팅에서 「서버에서 해 줘」라고 하거나 실행 중인 카드의 「서버에서 이어서」를 눌러요' }}
+ +
내가 시킨 브라우저 작업{{ whereLine(web.own) }}
diff --git a/src/components/TaskCard.vue b/src/components/TaskCard.vue index 8568b1c2..8839e6ab 100644 --- a/src/components/TaskCard.vue +++ b/src/components/TaskCard.vue @@ -80,8 +80,28 @@ const where = computed(() => c.value.where || null) const onPc = computed(() => where.value?.kind === 'local') // a task that ended needing the person: its page is kept on their PC for 「이 PC에서 보기」 (until another task takes that browser) const pcKept = computed(() => onPc.value && ended.value && c.value.pcKept === true) -const whereText = computed(() => (onPc.value ? `내 PC · ${where.value.device || 'PC'}` : where.value?.from === 'local' ? '서버 브라우저에서 이어서' : '')) +// (this server's, by the person's choice — their words for it, their default (설정 › 브라우저 작업 위치), 「서버에서 바로 시작」 in line: why) +const whereText = computed(() => (onPc.value ? `내 PC · ${where.value.device || 'PC'}` : where.value?.from === 'local' ? '서버 브라우저에서 이어서' + : ['asked', 'person'].includes(where.value?.why) ? '서버 브라우저' : '')) const pcErr = ref('') +// a PC app older than the one whose live view keeps coming while its window there is minimized or covered (server lib/browser.js +// liveUpdateOf — said only once that version is out): the screen that does not come says which version brings it +const liveUpdate = computed(() => (onPc.value ? where.value?.update || null : null)) +// 「서버에서 이어서」 while it works on the person's PC, 「서버에서 바로 시작」 while it waits in line for that PC's browser (server lib/browser.js +// moveToServer — 2026-12-02 사용자: 「pc 에 연결된 브라우저에서 동작하길 원치 않고 서버 파드에서 돌리고 싶은 경우도 지원」). The server's +// browser goes on from the page it was on; what was signed in on the PC is not there (it asks, as any task does) +const canMove = computed(() => onPc.value && running.value) +const moving = ref(false) +async function moveServer() { + const inLine = queued.value + pcErr.value = '' + qErr.value = '' + moving.value = true + try { + const r = await api('/browser/route', { method: 'POST', body: { taskId: props.msg.id, to: 'server' } }) + if (!r?.ok) (inLine ? qErr : pcErr).value = inLine ? '지금은 옮길 수 없어요 — 곧 시작하거나 이미 시작했어요.' : '지금은 옮길 수 없어요 — 답을 기다리는 중이거나 이미 끝났어요.' + } catch (e) { (inLine ? qErr : pcErr).value = e.message } finally { moving.value = false } +} async function showOnPc() { pcErr.value = '' try { @@ -178,15 +198,17 @@ const queueActs = computed(() => { after: { key: 'q-after', label: '앞 작업 뒤에 줄 세우기', run: () => queueDo('after') }, } const drop = { key: 'q-cancel', label: '취소', run: cancel } + // (in line for the PC's browser — server content.pcLine: this server's browser may take it now instead) + const server = c.value.pcLine ? [{ key: 'q-server', label: '서버에서 바로 시작', run: moveServer }] : [] if (offer.value) { // (a task ahead that waits for an approval or a sign-in takes no answer from here: offer.answer false) // (nothing of this room's under way to stop for it — content.noFront: no 「앞 작업 멈추고 이것부터」) const keys = ['answer', 'first', 'after'].filter((k) => (k !== 'answer' || offer.value.answer !== false) && (k !== 'first' || !c.value.noFront)) const d = keys.includes(offer.value.default) ? offer.value.default : 'after' - return [{ ...all[d], big: true }, ...keys.filter((k) => k !== d).map((k) => all[k]), drop] + return [{ ...all[d], big: true }, ...keys.filter((k) => k !== d).map((k) => all[k]), ...server, drop] } // (in line only for the server's places, nothing of the person's is under way to stop for it: server content.noFront) - return c.value.noFront ? [drop] : [all.first, drop] + return c.value.noFront ? [...server, drop] : [all.first, ...server, drop] }) // repetitive work that keeps changing the page (deleting one item after another): how many rounds so far, not a stop const progressN = computed(() => (running.value || needs.value ? c.value.progress?.count || 0 : 0)) @@ -287,7 +309,9 @@ watch(() => app.clicks[props.msg.id]?.n, () => {
-
{{ onPc ? 'PC 화면을 받지 못하고 있어요 — 작업은 이어서 해요' : '화면을 받지 못하고 있어요 — 작업은 이어서 해요' }}{{ running ? '브라우저 여는 중' : queued ? (c.order ? '② 대기 중' : '대기 중') : c.title }}
+
{{ onPc ? 'PC 화면을 받지 못하고 있어요 — 작업은 이어서 해요' : '화면을 받지 못하고 있어요 — 작업은 이어서 해요' }} + PC 앱을 {{ liveUpdate.latest }} 버전으로 올리면 진행 화면이 보여요 내려받기 +
{{ running ? '브라우저 여는 중' : queued ? (c.order ? '② 대기 중' : '대기 중') : c.title }}
진행 중 · {{ progressN }}개 처리 {{ whereText }} @@ -357,9 +381,11 @@ watch(() => app.clicks[props.msg.id]?.n, () => { +

{{ takeErr }}

+

{{ pcErr }}

@@ -373,6 +399,11 @@ watch(() => app.clicks[props.msg.id]?.n, () => { .screen.takeover { box-shadow: 0 0 0 3px var(--color-attention), var(--shadow-card); cursor: crosshair; } .blank { position: absolute; inset: 0; display: grid; place-items: center; background: #f3f5fa; font-size: 15px; --text-tertiary: rgba(29 29 31 / .3); --text-primary: #1d1d1f; } .blank .still { color: rgba(29 29 31 / .45); } +/* the PC's screen is not coming: why, which app version brings it, and the server's browser instead */ +.nodraw { display: flex; flex-direction: column; align-items: center; gap: 10px; padding: 0 20px; text-align: center; } +.nodraw .upd { font-size: 13px; color: rgba(29 29 31 / .6); } +.nodraw .upd a { color: var(--color-attention); font-weight: 500; } +.nodraw .mv { height: 36px; padding: 0 16px; border-radius: 9999px; background: #fff; color: #1d1d1f; font-size: 14px; font-weight: 500; box-shadow: 0 2px 10px rgba(0 0 0 / .1); } .screen.bare { aspect-ratio: auto; height: 64px; } /* where it runs: the person's own PC (or this server, when it moved there) — a small label at the screen's top left */ .where { position: absolute; left: 12px; top: 12px; max-width: 60%; height: 28px; padding: 0 12px; border-radius: 9999px; display: inline-flex; align-items: center; @@ -442,7 +473,10 @@ watch(() => app.clicks[props.msg.id]?.n, () => { li.done .dot { background: #0F9D58; } .full .screen { width: min(92vw, 1024px, 112vh); margin: 0 auto; } /* keeps 16/10, the browser's own shape: nothing cropped, and a click lands where it is seen */ .bar { display: flex; justify-content: center; gap: 8px; margin-top: 16px; } -.pill { height: 40px; padding: 0 16px; border-radius: 9999px; background: rgba(255 255 255 / .92); color: #1d1d1f; display: flex; align-items: center; gap: 6px; font-size: 14px; font-weight: 500; } +/* a phone's width: the pills stay one line each and wrap to a second row, centred — every way on in sight, never a pill whose words + break in two (2026-12-02 phone screenshot: 「계획 / 2/6」, 「작업 취 / 소」) */ +@media (max-width: 640px) { .bar { flex-wrap: wrap; width: 100vw; max-width: 100vw; box-sizing: border-box; padding: 0 16px; } } +.pill { flex: none; white-space: nowrap; height: 40px; padding: 0 16px; border-radius: 9999px; background: rgba(255 255 255 / .92); color: #1d1d1f; display: flex; align-items: center; gap: 6px; font-size: 14px; font-weight: 500; } .pill.on { background: var(--color-attention); color: #fff; } .kbd { display: block; width: min(92vw, 520px); height: 48px; margin: 12px auto 0; padding: 0 18px; border-radius: 24px; border: 0; outline: 0; font-size: 16px; color: #1d1d1f; background: rgba(255 255 255 / .94); box-shadow: 0 0 0 2px var(--color-attention); } diff --git a/src/i18n/ko-en.json b/src/i18n/ko-en.json index 939eb376..82362c1e 100644 --- a/src/i18n/ko-en.json +++ b/src/i18n/ko-en.json @@ -4265,7 +4265,17 @@ "무엇인지 확실하지 않은 동작": "An action that is unclear", "바꾸는 중이거나, 바꾼 결과를 카드에 적지 못했어요. 설정에서 확인해 주세요.": "Being changed, or the outcome could not be written on this card. Check it in Settings.", "메시지 · 메일 보내기의 설정을 따라요": "Follows the setting for sending messages or mail", - "관리자에게 알리는 중이에요.": "Telling an administrator." + "관리자에게 알리는 중이에요.": "Telling an administrator.", + "서버에서 바로 시작": "Start on the server now", + "서버 브라우저": "Server browser", + "지금은 옮길 수 없어요 — 답을 기다리는 중이거나 이미 끝났어요.": "Can't move it now — it's waiting for an answer or already over.", + "지금은 옮길 수 없어요 — 곧 시작하거나 이미 시작했어요.": "Can't move it now — it's about to start or has already started.", + "브라우저 작업 위치": "Where browser tasks run", + "이 설정을 저장할 곳이 아직 없어요 — 관리자에게 알려 주세요": "There's nowhere to save this setting yet — tell your administrator", + "PC 우선": "PC first", + "늘 서버": "Always the server", + "PC 우선: PC 앱이 켜져 있으면 그 PC 의 브라우저에서 해요. 한 작업만 서버에서 하려면 채팅에서 「서버에서 해 줘」라고 하거나 실행 중인 카드의 「서버에서 이어서」를 눌러요": "PC first: tasks run in the PC's browser while its app is on. To run just one task on the server, say \"do it on the server\" in the chat or press \"Continue on the server\" on its running card", + "서버 브라우저에서 해요 — 「브라우저 작업 위치」를 「늘 서버」로 정했어요. PC 에서 한 로그인은 서버 브라우저에 없어요": "In the server's browser — you set \"Where browser tasks run\" to \"Always the server\". Sign-ins made on the PC aren't there" }, "patterns": [ [ @@ -9815,6 +9825,10 @@ [ "{0}줄", "{0} lines" + ], + [ + "PC 앱을 {0} 버전으로 올리면 진행 화면이 보여요", + "Update the desktop app to {0} to see the progress screen" ] ], "context": [ From 238c7f8c9eafcfce59a9caf18d4a527d0538d5c9 Mon Sep 17 00:00:00 2001 From: jinyoung Date: Wed, 2 Dec 2026 12:03:39 +0900 Subject: [PATCH 02/12] =?UTF-8?q?fix(agent):=20browserStarts=20=EC=97=90?= =?UTF-8?q?=EB=8A=94=20where=20=EB=A5=BC=20=EC=A0=95=ED=96=88=EC=9D=84=20?= =?UTF-8?q?=EB=95=8C=EB=A7=8C=20=E2=80=94=20=EA=B8=B0=EC=A1=B4=20=EB=AA=A8?= =?UTF-8?q?=EC=96=91=20=EA=B7=B8=EB=8C=80=EB=A1=9C(browser-replaces-turn?= =?UTF-8?q?=20=EC=8B=9C=ED=97=98)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-Authored-By: Claude Opus 5.5 --- server/lib/agent.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/server/lib/agent.js b/server/lib/agent.js index e1d8f5c2..437c1111 100644 --- a/server/lib/agent.js +++ b/server/lib/agent.js @@ -398,7 +398,7 @@ function runBrowser({ user, session, threadId, goal, startUrl, skill, files = [] // (a turn the server composed — a teammate's words picked up, a Home card's action: none of it is the person's own asking, so a purchase // control waits for their approval — review PR #105 round 3) const words = own ? (turnCtx.getStore()?.composed ? [] : [String(asked?.text ?? ''), ...said.filter(Boolean)]) : null - browserStarts.push({ threadId, goal, startUrl: startUrl || '', skill: skill || '', files: files.map((f) => f.name), own, background, said: words, where: where || '' }) + browserStarts.push({ threadId, goal, startUrl: startUrl || '', skill: skill || '', files: files.map((f) => f.name), own, background, said: words, ...(where ? { where } : {}) }) if (browserStarts.length > 20) browserStarts.shift() // the person's words go along (behind a task that waits for them, its card offers them as that task's answer — the first choice // is what the judge found likeliest: lib/browserQueue.js queueDefault); a task this turn finishes first comes before it From 4d5b059fdc8a00159bb20785750b62534ca99a0d Mon Sep 17 00:00:00 2001 From: jinyoung Date: Wed, 2 Dec 2026 12:14:12 +0900 Subject: [PATCH 03/12] =?UTF-8?q?fix(browser):=20=E3=80=8C=EB=82=B4=20PC?= =?UTF-8?q?=E3=80=8D=20=EB=B8=8C=EB=9D=BC=EC=9A=B0=EC=A0=80=EC=9D=98=20?= =?UTF-8?q?=EC=A7=84=ED=96=89=20=ED=99=94=EB=A9=B4=EC=9D=B4=20=EB=81=8A?= =?UTF-8?q?=EA=B8=B0=EC=A7=80=20=EC=95=8A=EA=B2=8C=20=E2=80=94=20=EC=B5=9C?= =?UTF-8?q?=EC=86=8C=ED=99=94=20=C2=B7=20=EC=95=B1=20=EC=88=A8=EA=B9=80=20?= =?UTF-8?q?=EC=B0=BD=EC=9D=98=20=EC=83=88=20=ED=8E=98=EC=9D=B4=EC=A7=80(5?= =?UTF-8?q?=EC=B4=88=200=EC=9E=A5=20=E2=86=92=2015=EC=9E=A5),=20=EB=8B=A4?= =?UTF-8?q?=EC=9D=8C=20=EC=9E=91=EC=97=85=EC=9D=80=20=EC=83=88=20=EC=88=A8?= =?UTF-8?q?=EC=9D=80=20=ED=83=AD,=20=EA=B7=B8=EB=A6=BC=20=EC=97=86?= =?UTF-8?q?=EB=8A=94=20PC=20=EC=9E=91=EC=97=85=EC=9D=80=20=E3=80=8C?= =?UTF-8?q?=EB=B0=9B=EC=A7=80=20=EB=AA=BB=ED=95=98=EA=B3=A0=20=EC=9E=88?= =?UTF-8?q?=EC=96=B4=EC=9A=94=E3=80=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 2026-12-02 사용자: 「Pc 에 연결된 브라우저 사용시 진행상태가 보이지 않음. 화면전환된 송출을 최적화하여 연결할 방법이 있나?」 - desktop host.js startLive: 작업 중 이 PC 에 보였던 탭의 스크린캐스트가 1초 조용하면 약 1초마다 캡처를 실시간 프레임으로(같은 그림은 다시 안 보냄 · 간격 4초까지, 새 프레임에 밀리거나 다른 문서면 버림, 한 번도 보이지 않은 탭은 캡처하지 않음) - desktop host.js begin: 보였다가 최소화 · 숨은 창이면 같은 주소의 새 숨은 탭에서 작업(화면에 띄운 창은 그대로) - server dropStale: 그림이 한 장도 없는 PC 작업도 noDraw(0.2.10 에도 닿음) - 측정(설계 노트) · 스펙 「PC 화면이 오지 않을 때에도 진행 화면이 이어진다」 · 카탈로그 §105 Co-Authored-By: Claude Opus 5.5 --- CHANGELOG.md | 2 + desktop/src/browser/host.js | 66 ++++++++- desktop/test/browser.test.js | 178 +++++++++++++++++++++++- desktop/test/helpers/browser-host.js | 29 +++- docs/browser-where/design.md | 20 ++- e2e/README.md | 40 +++++- openspec/specs/browser-handoff/spec.md | 31 +++++ server/lib/browser.js | 13 +- server/test/browser-local.test.js | 4 +- server/test/browserDriver.test.js | 71 +++++++++- server/test/browserTabShot.test.js | 28 ++++ server/test/fixtures/desktopBrowser.mjs | 5 +- server/test/fixtures/drivers.mjs | 3 + 13 files changed, 465 insertions(+), 25 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 44c8208b..ac54ea49 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,6 +7,8 @@ ### 바뀜 +- **「내 PC」 브라우저 작업의 진행 화면이 끊기지 않습니다. 이 PC 에 보였다가 최소화했거나 앱을 숨긴 창에서 작업이 새 페이지로 가면, 실시간 화면이 5초에 0장이던 것이 15장으로 늘었습니다. 그런 창에서 다음 작업이 시작하면 같은 주소의 새 숨은 탭에서 일합니다. 그림이 한 장도 오지 않는 PC 작업의 카드는 「브라우저 여는 중」에 머물지 않고 「PC 화면을 받지 못하고 있어요」를 보입니다** (스펙 `browser-handoff` 「PC 화면이 오지 않을 때에도 진행 화면이 이어진다」, 설계 `docs/browser-where/design.md`(측정), 데스크톱 `desktop/src/browser/host.js` `startLive`(받쳐 주는 캡처, `LIVE_STILL_MS`) · `begin` — 데스크톱 0.2.13 에 함께 나감, 서버 `lib/browser.js dropStale`, 시험 `desktop/test/browser.test.js` 6개 · `server/test/browserDriver.test.js` 진짜 Electron 2개 · `browserTabShot.test.js`, 카탈로그 §105) + - **PC 가 켜져 있어도 브라우저 작업을 서버 브라우저에서 할 수 있습니다. 설정 「브라우저 작업 위치」에서 기본값을 「PC 우선」 또는 「늘 서버」로 고르고(웹 · 휴대폰에서도 바꿈), 채팅에서 「서버에서 해 줘」라고 하면 그 작업만 서버에서 합니다. PC 에서 일하는 작업의 카드에는 「서버에서 이어서」가 있어, 누르면 서버 브라우저가 같은 페이지에서 이어서 하고, PC 를 기다리며 줄 선 작업에는 「서버에서 바로 시작」이 있습니다. PC 화면이 오지 않으면 카드에 「서버에서 이어서」와, 옛 PC 앱이면 진행 화면이 보이는 새 판(0.2.13 이 나온 뒤) 안내가 함께 나옵니다. 확장 화면의 단추는 휴대폰에서 글자가 두 줄로 깨지지 않고 둘째 줄로 넘어갑니다** (스펙 `browser-handoff` 「서버 브라우저를 고르기」, 설계 `docs/browser-where/design.md`, 서버 `lib/browserWhere.js`(새) · `lib/browserRemote.js routeOf`(`where` · `person`) · `lib/browser.js moveToServer · routeTo · liveUpdateOf` · `lib/agent.js`(`browser_task` 의 `where`) · `PUT /api/browser/where`, DB `server/sql/076_browser_where.sql`(`pro_profile.browser_where` — 없으면 모두 「PC 우선」, 바꾸기는 503), 화면 `TaskCard.vue` · `LocalAgentsSettings.vue`, 시험 `server/test/browserWhere.test.js` · `browser-local.test.js`(진짜 Electron 4개) · `e2e/tests/feature/browser-where.spec.js` F-BW-01…05 · F-LB-03 · 05 고침, 카탈로그 §105) - **프로젝트 방의 산출물 더미에서 프로젝트 계획을 함께 봅니다 — 접힌 더미 이름은 「산출물 · 계획」이고, 펼치면 파일 위에 계획 카드가 있습니다. 파일마다 붙어 있던 「팀원에게 공유」 사람 아이콘은 모두 없애고, 공유 기능은 파일을 길게 누르거나(휴대폰) 오른쪽 클릭하면(컴퓨터) 나오는 메뉴로 옮겼습니다** (스펙 `chat-artifacts` 「프로젝트 방의 더미에는 계획도 있다」 · 「파일의 공유는 파일의 메뉴에 있다」, `project-room` · `messenger-drop-folder` · `answer-share`, 설계 `docs/chat-artifacts/design.md`, 화면 `ArtifactStack.vue` · `ProjectPlanView.vue` · `FileItemMenu.vue` · `ArtifactList.vue` · `Message.vue` · `FileGroupRow.vue` · `holdMenu.js` · `ProjectNote.vue`, 순수 규칙 `src/artifactScope.js`, 시험 AS-U-07 · 08 · F-SPL-01~07, 카탈로그 103절, 2026-12-02 사용자 — 「프로젝트 내에서 프로젝트 계획을 볼 수 있는 부분이 필요한데, 여기 산출물 열기를 했을 때 거기에 프로젝트 계획 보기 같은 게 있으면 같이 볼 수 있을 것 같아. 산출물 및 계획 뭐 이런 식으로 아이콘 줄어들었을 때 그 조그만한 다이얼로그 부분에는 그렇게 표시해주면 좋겠네.」 · 「그리고 지금 공유 버튼을 위해 가지고 팀원에게 공유하는 저 아이콘들, 뭐 대화방에도 있고 산출물 여기에도 있고, 저기 그 사람 아이콘 저거는 다 없애줘. 다 없애고 우클릭, 그러니까 모바일에서는 길게 클릭했을 때 나오는 컨텍스트 메뉴로 다 바꾸자.」): 프로젝트 계획은 방 맨 위의 칩으로만 열 수 있어서, 대화가 길어지면 칩이 위로 밀려 보이지 않았습니다. 이제 프로젝트 방에서 더미를 펼치면 맨 위에 목적이 보이는 「프로젝트 계획」 카드가 있고, 누르면 같은 상자 안에서 목적 · 쓰는 도구 · 만들 것 · 지킬 것 · 정한 것과 최근에 바뀐 것을 읽습니다. 긴 항목도 줄을 바꿔 휴대폰에서 다 보입니다. 고치기 · 바뀐 기록 · 되돌리기는 예전처럼 계획 시트에서 하며, 「고치기 · 바뀐 기록」을 누르면 시트가 열립니다. 넓은 화면의 오른쪽 산출물 목록 맨 위에도 계획 줄이 있습니다. 채팅의 더미는 예전처럼 「산출물」입니다. 더미의 파일, 오른쪽 목록의 행, 채팅의 파일 카드와 묶은 카드의 줄에서는 모두 파일 메뉴(열기 · 팀원에게 공유 · 폴더에 정리)의 「팀원에게 공유」로 공유합니다. 키보드로는 Shift+F10이나 메뉴 키로 열고, 더미의 파일과 목록의 행에도 채팅 카드처럼 포인터를 올리거나 키보드 초점을 맞추면 보이는 「⋯」이 있습니다. 같은 파일의 메뉴를 다시 열어도 폴더 판정을 다시 묻지 않습니다. 길게 눌러도 글자가 선택되거나 파일이 열리지 않습니다. 계획을 읽는 동안 Esc를 누르면 파일로 돌아가고, 휴대폰을 옆으로 들어도 상자가 화면 안에 있습니다. 여러 파일을 한 번에 보내는 「모두 공유」와 문서 편집기 머리의 「공유」 단추는 그대로입니다. 공유 권한 · 서버는 바뀌지 않았고 새 SQL은 없습니다. diff --git a/desktop/src/browser/host.js b/desktop/src/browser/host.js index 0ab473a9..b9fb13dc 100644 --- a/desktop/src/browser/host.js +++ b/desktop/src/browser/host.js @@ -37,6 +37,9 @@ const MAX_TABS = 8 const STILL_MS = 1200 // a capture of a tab that shows nothing ends here (one a picture: the server waits 8 s for the model's picture) const WAKE_MS = 2500 +// the live view of a tab shown on this PC whose screencast sent nothing this long: a capture (startLive), about this often — less often +// while the picture stays the same (up to four times this) +const LIVE_STILL_MS = 1000 const KEYS = { Enter: [13, '\r'], Tab: [9, ''], Escape: [27, ''], Backspace: [8, ''], Delete: [46, ''], ArrowLeft: [37, ''], ArrowUp: [38, ''], ArrowRight: [39, ''], ArrowDown: [40, ''], Home: [36, ''], End: [35, ''], PageUp: [33, ''], PageDown: [34, ''], ' ': [32, ' '], Space: [32, ' '], @@ -417,23 +420,40 @@ function createBrowserHost({ electron, log = () => {}, tmp = path.join(os.tmpdir // Every picture of a tab that draws comes from it — the live view (to the server, at most one per live.minMs, always the newest, made // 1024×640) and the model's picture (the next frame after the page changed). Never a capture of such a tab: a capture of a hidden // window leaves it hidden after, and a hidden window draws nothing — scrolls then waited 1.2 s each and the live view stopped - // (measured 2026-11-24). Only a tab that shows nothing is captured (freshFrame · wake, 2026-12-02). Each frame is - // acknowledged once, at most ten a second (the screencast sends the next frame only after that). + // (measured 2026-11-24). Only a tab shown on this PC is captured: one that shows nothing (freshFrame · wake, 2026-12-02), and one + // whose live view went still during a task (below). Each frame is acknowledged once, at most ten a second (the screencast sends the + // next frame only after that). // A frame shows one document of the tab (doc): a frame of an earlier one never goes out as the page — not to the live view, not as // a picture (2026-12-02 사용자: 「화면에 기존 노트북 엘엠 화면이고 작업은 유튜브에서 작업중이라고 나온다」 — a window shown on this PC // and then minimized drew nothing, and the last picture it drew, an earlier task's NotebookLM, stood for YouTube Studio). + // A window shown on this PC and then minimized, or with the app hidden (⌘H), goes on drawing the page it shows, but no new document: + // from the next page on its screencast sends nothing (2026-12-02 사용자: 「Pc 에 연결된 브라우저 사용시 진행상태가 보이지 않음」 — the + // card stayed on 「브라우저 여는 중」 for minutes). Measured 2026-12-02, a page that changes every 250 ms, live frames in 5 s: a hidden tab + // never shown here 15, shown 15, shown under another window that covers all of it 14–15 (a new page too), minimized or the app hidden + // on the page it showed 14–15 — and 0 once it went to another page, or the next task began in it. So while a task holds the + // browser, a tab shown here whose screencast sent nothing for LIVE_STILL_MS gets one capture (wake) about that often as its live frame: + // of this document only, not when it is the picture sent last (then less often), never after a newer frame of the screencast, and none + // once the screencast sends again. Never a tab not shown here (a capture of a hidden window that draws stopped it drawing — 2026-11-24). + // (begin: the next task does not start in such a window at all — a fresh hidden tab takes it) const ACK_MS = 100 async function startLive(t) { stopLive(t) let lastSent = 0, lastAck = 0, timer = null, ackTimer = null, unacked = [], first = true + // (castAt: the screencast's last frame out — from now · casts: how many went · capAt: the last capture begun · gap: how long after + // it the next may be · capSent: the capture sent last, while nothing of the screencast went after it) + let castAt = Date.now(), casts = 0, capAt = 0, gap = 0, capturing = false, capSent = null, still = null + t.liveSent = null + const out = (data) => { t.liveSent = data; host.emit({ type: 'browser-frame', data, url: maskUrl(t.wc.getURL()), tab: t.id }) } const ackAll = () => { ackTimer = null; lastAck = Date.now(); for (const f of unacked.splice(0)) t.cdp.send('Page.screencastFrameAck', { sessionId: f.sessionId }).catch(() => {}) } const send = () => { timer = null const f = t.latest if (!f || f.sent || state.active !== t || !state.busy || f.doc !== t.doc) return f.sent = true - lastSent = Date.now() - host.emit({ type: 'browser-frame', data: smaller(f.data), url: maskUrl(t.wc.getURL()), tab: t.id }) + lastSent = castAt = Date.now() + casts++ + capSent = null + out(smaller(f.data)) } const onFrame = (method, p) => { if (method !== 'Page.screencastFrame') return @@ -450,9 +470,30 @@ function createBrowserHost({ electron, log = () => {}, tmp = path.join(os.tmpdir const sendIn = lastSent + state.live.minMs - Date.now() if (sendIn <= 0) { clearTimeout(timer); send() } else if (!timer) timer = setTimeout(send, sendIn) } + // (a tab shown here that sent nothing a while: its picture now — above) + const stand = async () => { + const now = Date.now(), ms = state.live.stillMs || LIVE_STILL_MS + if (capturing || t.cast !== cast || !state.busy || state.active !== t || !t.shownOnce || now - castAt < ms || now - capAt < Math.max(ms, gap)) return + capturing = true + capAt = now + const doc = t.doc, sent = casts + try { + const pic = await wake(t) + // (not once the screencast sent a newer frame, the page went on or the task let go — and not the same picture again) + if (!pic || t.cast !== cast || !state.busy || state.active !== t || t.doc !== doc || casts !== sent) return + const data = pic === capSent ? t.liveSent : smaller(pic) + if (data === t.liveSent) { gap = Math.min(4 * ms, Math.max(ms, gap) * 2); return } + gap = 0 + capSent = pic + out(data) + } finally { capturing = false } + } t.waiters ||= [] t.cdp.on('event', onFrame) - t.cast = { stop: () => { clearTimeout(timer); clearTimeout(ackTimer); ackAll(); t.cdp.off('event', onFrame); t.cdp.send('Page.stopScreencast').catch(() => {}) } } + const cast = { stop: () => { clearTimeout(timer); clearTimeout(ackTimer); clearInterval(still); ackAll(); t.cdp.off('event', onFrame); t.cdp.send('Page.stopScreencast').catch(() => {}) } } + t.cast = cast + still = setInterval(() => { stand().catch(() => {}) }, Math.max(20, Math.round((state.live.stillMs || LIVE_STILL_MS) / 4))) + still.unref?.() await t.cdp.send('Page.startScreencast', { format: 'jpeg', quality: 50, maxWidth: VIEW.width, maxHeight: VIEW.height, everyNthFrame: 1 }) } function stopLive(t) { if (t?.cast) { t.cast.stop(); t.cast = null } } @@ -765,6 +806,21 @@ function createBrowserHost({ electron, log = () => {}, tmp = path.join(os.tmpdir state.dialogs = [] state.refused = [] await ensureTab() + // A window shown on this PC that nobody sees now — minimized, or the app hidden (⌘H) — draws no new document: the next task's pages + // sent no live frame at all (2026-12-02 사용자: 「Pc 에 연결된 브라우저 사용시 진행상태가 보이지 않음」 — shown here in the morning and + // minimized, the card stayed on 「브라우저 여는 중」; measured the same day: 0 frames in 5 s, 15 in a hidden tab never shown). It is + // taken as not shown, as when the person hides it (show): the task works in a fresh hidden tab at its address, muted. One the person + // has on the screen stays as it is. (At most 10 s here — the server waits 15 s for begin; the operations after it wait for the tab.) + const was = state.active + if (state.shown && was && showsNothing(was)) { + log(`[browser] tab ${was.id} was shown on this PC and nobody sees it now (minimized or hidden): the task goes on in a fresh hidden tab`) + state.shown = false + for (const x of state.tabs) { try { x.wc.setAudioMuted(true) } catch { /* gone */ } } + try { was.win.hide() } catch { /* gone */ } + state.replacing = refresh(was).then((f) => follow(f)).finally(() => { state.replacing = null }) + await withTimeout(state.replacing, 10_000, 'a fresh tab').catch((e) => log('[browser] a fresh tab for the task', e.message)) + host.emit({ type: 'browser-event', kind: 'hidden' }) + } if (state.active && !state.active.cast) await startLive(state.active).catch(() => {}) return true }, diff --git a/desktop/test/browser.test.js b/desktop/test/browser.test.js index bac51fc0..93505726 100644 --- a/desktop/test/browser.test.js +++ b/desktop/test/browser.test.js @@ -458,7 +458,9 @@ test('앱 서버의 포트(80 · 443 이 아님)로 가는 요청에는 이름 // A tab of the person's browser with a screencast the test drives: frames are put in by hand (frame), the page goes to another document // (go — what cdp.js 'navigated' does), the page's tick answers as the test says (tick: a time — it drew · 'still' — it drew nothing · // null — no answer; ticks() — how often it was asked), its capture is what the test says (captured), and the PC's log lines (logs). -function screenHost({ tick = () => Date.now(), captured = () => null } = {}) { +// stillMs: how long the live view waits for the screencast before it captures a tab shown here (the app's 1 s — long here unless a test +// is about it); every frame out is kept with when it went (out[].at). +function screenHost({ tick = () => Date.now(), captured = () => null, stillMs = 60_000 } = {}) { const { EventEmitter } = require('node:events') const out = [], logs = [] let ticks = 0 @@ -468,8 +470,8 @@ function screenHost({ tick = () => Date.now(), captured = () => null } = {}) { let url = 'https://notebooklm.example/' const tab = { id: 1, doc: 0, win, cdp, cast: null, opener: null, wc: { getURL: () => url, getTitle: () => '', capturePage: async () => { const c = await captured(); if (!c) throw new Error('no capture'); return c } } } const host = createBrowserHost({ electron: { BrowserWindow: class {}, session: { fromPartition: () => ({}) } }, tmp: os.tmpdir(), log: (...a) => logs.push(a.join(' ')) }) - host.emit = (m) => { if (m.type === 'browser-frame') out.push(m); return true } - Object.assign(host.state, { partition: 'persist:pgl-browser-u-1', user: 'u-1', tabs: [tab], active: tab, live: { minMs: 0, width: 1024, height: 640 }, step: { ...host.state.step, shotMs: 300 } }) + host.emit = (m) => { if (m.type === 'browser-frame') out.push({ ...m, at: Date.now() }); return true } + Object.assign(host.state, { partition: 'persist:pgl-browser-u-1', user: 'u-1', tabs: [tab], active: tab, live: { minMs: 0, width: 1024, height: 640, stillMs }, step: { ...host.state.step, shotMs: 300 } }) let n = 0 const frame = (data) => cdp.emit('event', 'Page.screencastFrame', { data, sessionId: ++n, metadata: { timestamp: Date.now() / 1000 } }) const go = (to) => { url = to; tab.doc++ } @@ -601,3 +603,173 @@ test('캡처하는 사이에 페이지가 다른 문서로 가면 그 캡처는 setTimeout(() => g.frame(b64('B')), 80) assert.equal(text(await g.host.shot()), 'B') }) + +// ---- the live view of a window shown on this PC that draws nothing (2026-12-02 사용자: 「Pc 에 연결된 브라우저 사용시 진행상태가 보이지 +// 않음. 화면전환된 송출을 최적화하여 연결할 방법이 있나?」 — the card stayed on 「브라우저 여는 중」 with no picture for minutes). Measured +// with Electron the same day (a page that changes every 250 ms, frames in 5 s): a window shown here and minimized, or the app hidden, +// sends 0 once its page goes to another document (15 hidden, shown, or covered by another window). Electron itself: +// server/test/browserDriver.test.js 「local: 작업 중에 이 PC 에 보인 창을 내려 두고 …」 · 「local: … 다음 작업이 시작하면 새 숨은 탭에서 …」. +const until = async (fn, ms = 2000) => { const end = Date.now() + ms; for (;;) { const v = fn(); if (v || Date.now() > end) return v; await new Promise((r) => setTimeout(r, 10)) } } + +test('이 PC 에 보였던 창의 실시간 화면이 멈추면(스크린캐스트가 1초 넘게 보내지 않음) 작업 동안 그 창을 한 장씩 찍어 보낸다 — 지금 페이지 · 그 탭 · 1초에 한 번쯤', async () => { + let n = 0 + const f = screenHost({ stillMs: 60, captured: () => capture(`P${++n}`) }) + await f.host.begin({}) + f.frame(b64('NOTEBOOK')) + f.go('https://studio.youtube.example/upload') + f.minimize() + const t0 = Date.now() + assert.ok(await until(() => f.out.length >= 4), `찍은 그림이 온다: ${f.sent().map(text).join(' ')}`) + const caps = f.out.slice(1) + assert.deepEqual(caps.map((m) => text(m.data)), caps.map((_m, i) => `P${i + 1}@1280`), '찍은 그대로, 차례대로(1280 폭 — 서버에 가는 1024 로 줄이는 것은 smaller)') + assert.ok(caps.every((m) => m.url === 'https://studio.youtube.example/upload' && m.tab === 1), '지금 페이지의 주소 · 그 탭') + assert.ok(caps[0].at - t0 >= 50, `스크린캐스트를 stillMs 기다린 뒤에: ${caps[0].at - t0} ms`) + for (let i = 1; i < caps.length; i++) assert.ok(caps[i].at - caps[i - 1].at >= 55, `한 장씩 stillMs 마다: ${caps.map((m) => m.at - t0).join(',')}`) + await f.host.idle({ keep: true }) + const k = f.out.length + await new Promise((r) => setTimeout(r, 250)) + assert.equal(f.out.length, k, '작업이 끝나면(idle) 찍지도 보내지도 않는다') +}) + +test('같은 그림은 다시 보내지 않고 덜 자주 찍는다 — 그림이 바뀌면 다시 한 장씩', async () => { + let asked = 0, label = 'SAME' + const f = screenHost({ stillMs: 40, captured: () => { asked++; return capture(label) } }) + await f.host.begin({}) + f.minimize() + await new Promise((r) => setTimeout(r, 700)) + assert.deepEqual(f.sent().map(text), ['SAME@1280'], '한 번만 보낸다') + // (40 ms each would be about 16; doubling up to 160 ms after the same picture: about 6) + assert.ok(asked >= 3 && asked <= 9, `같은 그림이면 덜 자주 찍는다: ${asked}번`) + label = 'CHANGED' + assert.ok(await until(() => f.sent().length === 2, 1000), '바뀐 그림은 보낸다') + assert.equal(text(f.sent()[1]), 'CHANGED@1280') +}) + +test('이 PC 에 한 번도 보이지 않은 숨은 탭은 찍지 않는다(찍으면 그리기를 멈춘 창 — 2026-11-24) — 스크린캐스트가 멈춰도', async () => { + let asked = 0 + const f = screenHost({ stillMs: 30, captured: () => { asked++; return capture('X') } }) + await f.host.begin({}) + f.frame(b64('A')) + f.go('https://b.example/') + await new Promise((r) => setTimeout(r, 300)) + assert.equal(asked, 0) + assert.deepEqual(f.sent(), [b64('A')]) +}) + +test('스크린캐스트가 다시 보내면 찍기를 멈추고, 찍는 동안 스크린캐스트가 보낸 더 새 그림 뒤에 찍은 그림을 보내지 않는다', async () => { + let f, asked = 0, once = true + f = screenHost({ stillMs: 50, captured: async () => { + asked++ + // (while the first capture is under way the screencast sends a frame of this page: newer than the capture) + if (once) { once = false; f.frame(b64('DRAWN')) } + return capture(`C${asked}`) + } }) + await f.host.begin({}) + f.minimize() + assert.ok(await until(() => asked >= 1, 1000)) + await new Promise((r) => setTimeout(r, 10)) + assert.deepEqual(f.sent().map(text), ['DRAWN'], '스크린캐스트의 그림 뒤에 그보다 앞서 찍은 그림은 가지 않는다') + // frames flow: no capture while they do + const a0 = asked + const drawing = setInterval(() => f.frame(b64(`F${Date.now()}`)), 15) + await new Promise((r) => setTimeout(r, 300)) + clearInterval(drawing) + assert.equal(asked, a0, '스크린캐스트가 보내는 동안에는 찍지 않는다') + assert.ok(f.sent().slice(1).every((d) => text(d).startsWith('F'))) + // they stop again: captures again, after stillMs + assert.ok(await until(() => f.sent().some((d) => /^C\d+@1280$/.test(text(d))), 1000), '멈추면 다시 찍는다') +}) + +test('찍는 사이에 페이지가 다른 문서로 가면 그 그림은 실시간 화면으로 가지 않는다 — 다음 장은 새 페이지의 것', async () => { + let f, n = 0 + f = screenHost({ stillMs: 40, captured: () => { n++; if (n === 1) f.go('https://studio.youtube.example/next'); return capture(`S${n}`) } }) + await f.host.begin({}) + f.go('https://studio.youtube.example/') + f.minimize() + assert.ok(await until(() => f.out.length >= 1, 1500)) + assert.deepEqual(f.sent().map(text).slice(0, 1), ['S2@1280'], '앞 문서에서 찍은 첫 장은 버린다') + assert.equal(f.out[0].url, 'https://studio.youtube.example/next') +}) + +// A host whose windows are stand-ins (no Electron): each window made is a tab whose debugger answers what a tab's start asks; minimize · +// show · hide do what the person (or the app) does to it, and isVisible says whether it is on the screen +function windowHost() { + const { EventEmitter } = require('node:events') + const made = [], out = [], logs = [] + class Win extends EventEmitter { + constructor() { + super() + made.push(this) + Object.assign(this, { visible: false, minimized: false, destroyed: false, url: '' }) + const win = this + const dbg = Object.assign(new EventEmitter(), { + attached: false, isAttached() { return this.attached }, attach() { this.attached = true }, + sendCommand: async (method, params = {}) => { + if (method === 'Page.getFrameTree') return { frameTree: { frame: { id: `F${made.indexOf(win)}` } } } + if (method === 'Runtime.evaluate') return { result: { value: 'complete' } } + if (method === 'Page.navigate') win.url = params.url + return {} + }, + }) + this.webContents = Object.assign(new EventEmitter(), { debugger: dbg, muted: null, setAudioMuted(m) { this.muted = m }, setWindowOpenHandler() {}, + getURL: () => win.url, loadURL: async (u) => { win.url = u }, getTitle: () => '' }) + } + isDestroyed() { return this.destroyed } + destroy() { if (!this.destroyed) { this.destroyed = true; this.emit('closed') } } + show() { this.visible = true; this.minimized = false } + hide() { this.visible = false } + focus() {} + minimize() { this.minimized = true } + isMinimized() { return this.minimized } + isVisible() { return this.visible && !this.minimized } + setTitle() {} + getContentSize() { return [1280, 800] } + } + const ses = { setPermissionRequestHandler() {}, setPermissionCheckHandler() {}, setDisplayMediaRequestHandler() {}, on() {} } + const host = createBrowserHost({ electron: { BrowserWindow: Win, session: { fromPartition: () => ses } }, tmp: os.tmpdir(), log: (...a) => logs.push(a.join(' ')) }) + host.emit = (m) => { out.push(m); return true } + return { host, made, out, logs } +} + +test('이 PC 에 보였다가 내려 둔 창(또는 앱을 가린 창)에서 다음 작업이 시작하면 그 창은 보이지 않은 것으로 — 같은 주소의 새 숨은 탭에서, 소리 없이. 화면에 보이는 창은 그대로', async () => { + for (const how of ['minimize', 'hide-app']) { + const { host, made, out, logs } = windowHost() + await host.open({ user: 'u-1' }) + const first = host.state.active + first.win.url = 'https://studio.youtube.example/upload' + await host.begin({}) + await host.idle({ keep: true }) + // the person shows it here (「이 PC에서 보기」) and then minimizes it — or hides the app (⌘H: the window is not on the screen) + await host.show({ on: true }) + assert.equal(first.win.isVisible(), true) + if (how === 'minimize') first.win.minimize() + else first.win.visible = false + await host.begin({}) + const now = host.state.active + assert.notEqual(now, first, `${how}: 새 탭`) + assert.equal(host.state.shown, false, `${how}: 보이지 않은 것으로`) + assert.ok(first.win.isDestroyed(), `${how}: 내려 둔 창은 닫는다`) + assert.deepEqual([now.shownOnce, now.win.visible], [undefined, false], `${how}: 이 PC 에 보인 적 없는 숨은 창`) + assert.equal(now.wc.getURL(), 'https://studio.youtube.example/upload', `${how}: 같은 주소`) + assert.equal(now.wc.muted, true, `${how}: 소리 없이`) + assert.deepEqual(host.state.tabs, [now]) + assert.ok(now.cast, `${how}: 새 탭의 실시간 화면`) + assert.ok(out.some((m) => m.type === 'browser-event' && m.kind === 'hidden'), `${how}: 서버에 「숨김」`) + assert.ok(logs.some((l) => /tab 1 was shown on this PC and nobody sees it now .*fresh hidden tab/.test(l)), logs.join(' | ')) + assert.equal(made.length, 2) + await host.idle({}) + } + // a window the person has on the screen: the task works in it, as it is (they watch it there) + const { host, made } = windowHost() + await host.open({ user: 'u-1' }) + const first = host.state.active + await host.show({ on: true }) + await host.begin({}) + assert.equal(host.state.active, first) + assert.deepEqual([host.state.shown, first.win.isVisible(), made.length], [true, true, 1]) + // and one hidden by the person (show off) is already a fresh hidden tab: begin makes no other + await host.show({ on: false }) + const fresh = host.state.active + await host.begin({}) + assert.deepEqual([host.state.active, made.length], [fresh, 2]) +}) diff --git a/desktop/test/helpers/browser-host.js b/desktop/test/helpers/browser-host.js index 44f39809..708df7a2 100644 --- a/desktop/test/helpers/browser-host.js +++ b/desktop/test/helpers/browser-host.js @@ -41,19 +41,36 @@ app.whenReady().then(async () => { }) process.stdin.on('end', () => app.exit(0)) // (a line on stdin does to the window of the tab the work is in what the person does on this PC — 「minimize」 · 「restore」 — and says so: -// 「window minimized」 · 「window restored」 — server/test/browserDriver.test.js, 2026-12-02: a window shown here and minimized draws nothing) -let lines = '' +// 「window minimized」 · 「window restored」 — server/test/browserDriver.test.js, 2026-12-02: a window shown here and minimized draws nothing. +// And (2026-12-02, measuring the live view): 「cover」 · 「uncover」 — another app's opaque window over it, the whole of it, and gone again; +// 「hide-app」 · 「show-app」 — the app hidden (⌘H) and back; 「state」 — nothing done. These say 「window : ok (visible=… minimized=…)」.) +let lines = '', cover = null +const said = (w) => `(visible=${w.isVisible()} minimized=${w.isMinimized()})` process.stdin.on('data', (d) => { lines += d for (let i; (i = lines.indexOf('\n')) >= 0;) { const line = lines.slice(0, i).trim() lines = lines.slice(i + 1) - if (line !== 'minimize' && line !== 'restore') continue + if (!['minimize', 'restore', 'cover', 'uncover', 'hide-app', 'show-app', 'state'].includes(line)) continue const w = global.__pglHost?.state.active?.win if (!w || w.isDestroyed()) { console.log(`window ${line}: none`); continue } - if (line === 'minimize') w.minimize() - else w.restore() - console.log(`window ${line}d`) + if (line === 'minimize' || line === 'restore') { + if (line === 'minimize') w.minimize() + else w.restore() + console.log(`window ${line}d`) + continue + } + if (line === 'cover') { + const { BrowserWindow } = require('electron') + try { cover?.destroy() } catch { /* gone */ } + cover = new BrowserWindow({ ...w.getBounds(), frame: false, alwaysOnTop: true, focusable: false, backgroundColor: '#202020', show: true }) + cover.setAlwaysOnTop(true, 'floating') + } + if (line === 'uncover') { try { cover?.destroy() } catch { /* gone */ } cover = null } + if (line === 'hide-app') app.hide() + if (line === 'show-app') app.show() + // (the system tells the window what changed a moment later) + setTimeout(() => console.log(`window ${line}: ok ${w.isDestroyed() ? '(gone)' : said(w)}`), line === 'state' ? 0 : 400) } }) process.stdin.resume() diff --git a/docs/browser-where/design.md b/docs/browser-where/design.md index cafc4a98..a10527f5 100644 --- a/docs/browser-where/design.md +++ b/docs/browser-where/design.md @@ -11,7 +11,7 @@ ### 왜 안 보였나 - 그 맥의 PC 앱은 **0.2.10** 이었다. 0.2.12 까지는 나와 있었지만 받지 않은 상태였고, 0.2.13(#188, 탭 그림)은 아직 나오지 않았다. -- 실시간 화면은 숨은 창의 CDP 스크린캐스트다. 이 PC 에 한 번도 보인 적 없는 숨은 창은 그림을 그린다. 그런데 **이 PC 에 보였다가 최소화된 창, 앱이 숨긴 창**은 아무것도 그리지 않는다(Electron, 2026-11-24 · 12-02 측정). 그날 아침 NotebookLM 작업 때 「이 PC에서 보기」로 띄운 창이 최소화된 채 남아 있었다. +- 실시간 화면은 숨은 창의 CDP 스크린캐스트다. 이 PC 에 한 번도 보인 적 없는 숨은 창은 그림을 그린다. 그런데 **이 PC 에 보였다가 최소화된 창, 앱이 숨긴(⌘H) 창**은 보이던 페이지는 계속 그리지만 **새 문서**(다음 페이지, 다음 작업)는 그리지 않는다(아래 「측정」). 그날 아침 NotebookLM 작업 때 「이 PC에서 보기」로 띄운 창이 최소화된 채 남아 있었다. - 그 상태에서 0.2.10 은 프레임을 하나도 보내지 못한다. 모델용 그림(걸음마다 한 장)도 비어서 카드에 그림이 없었다. 0.2.13 은 최소화된 창을 한 번 캡처해 모델의 그림과 카드의 한 장을 얻지만, 그다음 캡처까지는 실시간 화면을 채우지 못한다. - 대역폭 문제는 아니었다. 송출은 이미 바뀐 화면만, 1초에 3장 이하로, 1024×640 JPEG(품질 50)으로 보낸다. 보낼 그림이 생기지 않은 것이 원인이다. @@ -21,6 +21,7 @@ - **작업 시작 때 새 창**: 이 PC 에 보였다가 지금은 최소화되었거나 숨은 창이면, 작업을 시작할 때 같은 주소의 새 숨은 탭으로 바꾼다. 그 작업의 실시간 화면이 처음부터 온다. 사람이 화면에 띄워 둔 창은 그대로 둔다. ### 바꾼 것 — 서버 · 화면 +- 그림이 한 장도 오지 않은 PC 작업: 웹 페이지의 그림을 얻지 못하면 카드에 `noDraw`를 한 번 보낸다(`dropStale`). 지금까지는 앞서 보이던 그림이 있을 때만 「받지 못하고 있어요」로 바꾸어서, 그림이 처음부터 없는 작업은 작업 내내 「브라우저 여는 중」에 머물렀다. 이 고침은 서버에만 있으므로 0.2.10 에도 바로 닿는다. - 카드에 그림이 오지 않을 때(`noDraw`): - 그 자리에 「서버에서 이어서」를 둔다. - PC 앱이 진행 화면을 못 보내는 옛 판이면 「PC 앱을 <판> 버전으로 올리면 진행 화면이 보여요 · 내려받기」를 함께 보인다(`where.update`, `lib/browser.js liveUpdateOf`). 이 줄은 그 판(0.2.13)이 **나온 뒤에만** 보인다. 받을 수 없는 판을 안내하지 않기 위해서다. @@ -46,7 +47,22 @@ - **잠긴 화면 · 꺼진 화면(디스플레이 잠자기)은 재지 않았다.** 이 맥에서는 다른 세션이 녹화를 하고 있어 화면을 재우거나 잠글 수 없었다. 그 상태에서는 캡처도 실패할 수 있다. 그때 카드는 지금처럼 「PC 화면을 받지 못하고 있어요 — 작업은 이어서 해요」와 「서버에서 이어서」를 보인다. ### 측정 -(데스크톱 측정 결과를 여기에 채운다.) +2026-12-02, 진짜 Electron 시험 도우미에서 잼. 시험 페이지 `/tick` 은 250ms 마다 바뀌고, 작업이 브라우저를 쥔 채 5초 동안 서버에 닿은 실시간 프레임을 셌다. 모든 프레임은 지금 페이지의 그림이었다. + +| 상태 | 고치기 전 | 고친 뒤 | +|---|---|---| +| 한 번도 보이지 않은 숨은 탭 — 같은 페이지 / 새 페이지 | 15 / 15 | 15 / 15 | +| 보이는 창 — 같은 페이지 / 새 페이지 | 15 / 15 | 15 / 15 | +| 보였다가 최소화 — 같은 페이지 | 14 | 14 | +| 보였다가 최소화 — **새 페이지** | **0** | **15** | +| 늘 위에 있는 불투명 창에 완전히 가려짐 — 같은 페이지 / 새 페이지 | 14~15 / 15 | 15 / 15 | +| 앱 숨김(⌘H) — 같은 페이지 | 15 | 15 | +| 앱 숨김 — **새 페이지** | **0** | **15** | +| 최소화된 창에서 **다음 작업 시작** | **0** | **15** | + +- 가려진 창은 계속 그리고 `isVisible()` 도 참이었다. 그래서 받쳐 주는 캡처의 조건은 창의 상태가 아니라 「스크린캐스트가 조용함」으로 잡았다. +- 최소화 · 앱 숨김에서 새 페이지로 간 경우 캡처는 페이지마다 한 번뿐이었다. 그 캡처 한 번으로 창이 다시 그리기 시작했고, 그 뒤로는 스크린캐스트가 이어받았다. +- 측정 스크립트는 세션의 작업 폴더에 두었다(`livecast/measure.mjs`, 저장소에는 넣지 않음). ### 남은 것 - 운영 SQL `076_browser_where.sql`(사용자 승인 필요). 적용 전에는 모두 「PC 우선」으로 돌고 설정 칸이 잠긴다. diff --git a/e2e/README.md b/e2e/README.md index 51b01e9f..d34319ef 100644 --- a/e2e/README.md +++ b/e2e/README.md @@ -550,9 +550,9 @@ ProcessGPT 포털의 설정 › 테마 설정 「휴대폰 화면」에서 「 | 단계 | 파일 | 시험 수 | |---|---|---| | smoke | `tests/smoke/*.spec.js` (6개) | 74 | -| feature | `tests/feature/*.spec.js` (110개) | 798 (브라우저 에이전트 가드레일 F-GR-01…04, 산출물 더미의 계획 · 공유 메뉴 F-SPL-01…07의 10개, 브라우저 작업 카드의 「PC 화면을 받지 못하고 있어요」 F-LB-05, 방 규칙이 있는 방에 링크만 F-AB-07 PC · 휴대폰, 「이 영상」 서버 시험 F-UT-09, 실행 카드 「전체 화면」 · 오래된 PC 앱 안내 F-CA-14 · 15, 채팅의 프로세스 시작 F-CPM-01 · 02, 내 PC CLI 「멈추기」 F-LV-11, 작업 기록 F-RJ-01…07, 정식 프로세스 F-PO-24…36과 검토 반영 F-PO-25b · 26b · 28a · 30b 17개, 내 PC CLI 시작 대기 F-LA-01…05, 「프로세스」 화면 제목 F-NAV-04 포함 · 프로세스 지도 F-PO-01…23, 방 규칙 F-RR-01…04, 후행 습관 F-FU-01…10, 서버 단위 시험 4묶음, 회의 F-MT-01…08, 팀 맥락 공유 F-TC-01…10, 포털에서 넘어온 휴대폰 F-PT-01…03, 대화 속 그림 · 소리 · 영상 F-MP-01…08, … 에이전트가 호출하는 내장 브라우저 F-AB-01…06의 8개 포함) | +| feature | `tests/feature/*.spec.js` (111개) | 803 (서버 브라우저 고르기 F-BW-01…05, 브라우저 에이전트 가드레일 F-GR-01…04, 산출물 더미의 계획 · 공유 메뉴 F-SPL-01…07의 10개, 브라우저 작업 카드의 「PC 화면을 받지 못하고 있어요」 F-LB-05, 방 규칙이 있는 방에 링크만 F-AB-07 PC · 휴대폰, 「이 영상」 서버 시험 F-UT-09, 실행 카드 「전체 화면」 · 오래된 PC 앱 안내 F-CA-14 · 15, 채팅의 프로세스 시작 F-CPM-01 · 02, 내 PC CLI 「멈추기」 F-LV-11, 작업 기록 F-RJ-01…07, 정식 프로세스 F-PO-24…36과 검토 반영 F-PO-25b · 26b · 28a · 30b 17개, 내 PC CLI 시작 대기 F-LA-01…05, 「프로세스」 화면 제목 F-NAV-04 포함 · 프로세스 지도 F-PO-01…23, 방 규칙 F-RR-01…04, 후행 습관 F-FU-01…10, 서버 단위 시험 4묶음, 회의 F-MT-01…08, 팀 맥락 공유 F-TC-01…10, 포털에서 넘어온 휴대폰 F-PT-01…03, 대화 속 그림 · 소리 · 영상 F-MP-01…08, … 에이전트가 호출하는 내장 브라우저 F-AB-01…06의 8개 포함) | | agent | `tests/agent/*.spec.js` (14개) | 33 (회의 A-14, 후행 습관 A-FU-01) | -| 합계 | | 905 (2026-11-28에 `npx playwright test --list`로 집계한 846에 2026-11-29 F-AB-06의 2개, F-PO-24…32 · 25b · 26b · 28a · 30b의 13개, F-LA-01…05의 5개, 2026-11-30 F-NAV-04의 1개 · F-PO-33 · 34 · 35의 3개, 2026-12-01 F-CA-13의 1개 · F-RS-05의 2개 · F-RS-06의 1개 · F-PO-36의 1개 · F-RJ-01…07의 7개 · F-LV-11의 1개 · F-CPM-01 · 02의 2개, 2026-12-02 F-CA-14 · 15의 2개 · F-AB-07의 2개 · F-UT-09의 1개 · F-LB-05의 1개 · F-SPL-01…07의 10개 · F-GR-01…04의 4개를 더한 값 — 데스크톱 단계의 LB-04 는 이 표에 세지 않음) | +| 합계 | | 910 (2026-11-28에 `npx playwright test --list`로 집계한 846에 2026-11-29 F-AB-06의 2개, F-PO-24…32 · 25b · 26b · 28a · 30b의 13개, F-LA-01…05의 5개, 2026-11-30 F-NAV-04의 1개 · F-PO-33 · 34 · 35의 3개, 2026-12-01 F-CA-13의 1개 · F-RS-05의 2개 · F-RS-06의 1개 · F-PO-36의 1개 · F-RJ-01…07의 7개 · F-LV-11의 1개 · F-CPM-01 · 02의 2개, 2026-12-02 F-CA-14 · 15의 2개 · F-AB-07의 2개 · F-UT-09의 1개 · F-LB-05의 1개 · F-SPL-01…07의 10개 · F-GR-01…04의 4개 · F-BW-01…05의 5개를 더한 값 — 데스크톱 단계의 LB-04 는 이 표에 세지 않음) | openspec 명세 13개의 요구사항 112개: 덮음 73 · 일부 20 · 공백 19. 명세 밖의 기능 요건(영상·최근 추가 기능: 대화 목록·산출물 스택·로봇 버튼·끊김 복구·유휴 타임아웃·DB 풀·멘션·예약·설치 번들 등) 31개: 덮음 27 · 일부 1 · 공백 3. @@ -2965,3 +2965,39 @@ cd e2e && ~/.claude/tools/lite/reclock.sh run guardrails -- npx playwright test - 산출물 스택의 더미는 늘 흔들립니다(애니메이션) — `click({ force: true })`, 펼친 뒤 잠깐 기다렸다 누릅니다. - 이음오피스 시트는 문서를 다 읽으면 키보드 포커스를 가져갑니다 — 다이얼 입력 전에 문서 준비를 기다립니다. - agent 단계는 모델 답이 흔들리므로 한 번 더 시도합니다(`retries: 1`). `[flaky]` 표시가 붙은 시험은 실패해도 같은 단계의 다른 시험과 함께 판단하세요. + +### 105. PC 브라우저의 진행 화면이 이어지고, PC 가 켜져 있어도 서버 브라우저를 고른다 (스펙 `browser-handoff` 「서버 브라우저를 고르기」 · 「PC 화면이 오지 않을 때에도 진행 화면이 이어진다」, 설계 `docs/browser-where/design.md`) + +근거: 2026-12-02 11:31 · 11:35 사용자(휴대폰 화면 — 「내 PC · uengineui-MacBookPro」 카드가 「브라우저 여는 중」에서 머묾, 확장 화면 단추 글자가 두 줄로 깨짐) — 「Pc 에 연결된 브라우저 사용시 진행상태가 보이지 않음. 화면전환된 송출을 최적화하여 연결할 방법이 있나? 그리고 pc 에 연결된 브라우저에서 동작하길 원치 않고 서버 파드에서 돌리고 싶은 경우도 지원」. 그 맥은 0.2.10 이었고, 아침에 보였다가 최소화된 창이 새 페이지를 그리지 않았다(측정은 설계 노트). 진짜 Electron 시험은 시험 도우미의 stdin 「minimize」 · 「hide-app」 · 「cover」로 사람의 창 조작을 흉내 내고, 시험 페이지 `/tick` 은 250ms 마다 바뀐다. 기본값은 로컬 DB 에 `server/sql/076_browser_where.sql` 이 있어야 한다. 사람은 지어낸 윤태호 · 「테스트 맥」. + +```bash +cd desktop && npm test # 받쳐 주는 캡처 · 작업 시작 때 새 탭(가짜 탭 6개 포함) +cd server && node --test test/browserWhere.test.js test/browserTabShot.test.js # 어디서 도나 · 기본값 저장 · 옛 PC 앱 안내 · 그림 없는 PC 작업(로컬 DB) +cd server && ~/.claude/tools/lite/reclock.sh run livecast -- node --test test/browserDriver.test.js # 진짜 Electron(최소화 · 새 페이지 · 다음 작업) +cd server && ~/.claude/tools/lite/reclock.sh run livecast -- node --test test/browser-local.test.js # 에이전트 루프 전체: 옮기기 · 말 · 기본값 · 줄 선 작업 +cd e2e && PGPT_URL=http://127.0.0.1:5273 API_URL=http://127.0.0.1:8873 npx playwright test --project=feature tests/feature/browser-where.spec.js tests/feature/local-browser-card.spec.js +``` + +| 요건 | 근거 | 시험 | 단계 | 상태 | +|---|---|---|---|---| +| 최소화된 · 앱을 숨긴 창이 새 페이지로 가도 실시간 화면이 옴(5초 0장 → 15장): 스크린캐스트가 1초 조용하면 약 1초마다 캡처, 같은 그림은 다시 보내지 않고 간격을 4초까지 늘림, 새 프레임에 밀린 캡처 · 다른 문서의 캡처는 버림, 프레임이 다시 오면 멈춤 | 사용자 12-02 | `desktop/test/browser.test.js` 6개 · `browserDriver.test.js` 「최소화 …새 페이지」 | 단위(Electron) | ✅ | +| 한 번도 보이지 않은 숨은 탭은 받쳐 주는 캡처도 하지 않음 | 2026-11-24 실측 | `desktop/test/browser.test.js` | 단위 | ✅ | +| 최소화된 창으로 다음 작업이 시작하면 같은 주소의 새 숨은 탭에서(캡처 없이 4초에 8장 이상), 화면에 띄워 둔 창은 그대로 | 사용자 12-02 | `browserDriver.test.js` 「begin …」 · `browser-local.test.js` 「앞 작업이 남긴 페이지 · 이 PC 에서 내려 둔 창 …」 | 단위(Electron) | ✅ | +| 다른 창에 완전히 가려진 창은 계속 그림(측정 14~15장, 받쳐 주기 불필요) | 측정 | `scratchpad/livecast/measure.mjs`(측정만) | — | ✅(측정) | +| PC 작업에 그림이 한 장도 오지 않으면 카드는 「브라우저 여는 중」 대신 「PC 화면을 받지 못하고 있어요」 — 한 번만, 빈 페이지 · 서버 브라우저는 아님 | 사용자 12-02 | `browserTabShot.test.js` 「PC 작업에 그림이 한 장도 …」 | 단위 | ✅ | +| 옛 PC 앱 안내(`where.update`): 0.2.13 이 나온 뒤에만 · 이미 그 판이면 · 판을 모르면 · 알림을 끈 설치면 없음 | 설계 | `browserWhere.test.js` | 단위 | ✅ | +| 어디서 도나: 한 작업의 선택 → 기본값 → PC 설정, 「PC 에서」라고 해도 「쓰지 않음」 · 사람이 없는 작업은 PC 로 가지 않음 | 사용자 12-02 | `browserWhere.test.js` | 단위 | ✅ | +| 기본값 「브라우저 작업 위치」 저장 · 다시 읽기 · 다른 값 400 · 「PC 우선」은 비워 둠 · 설정 화면이 보는 것(`person` · `kept` · 그 까닭 `person`) | 사용자 12-02 | `browserWhere.test.js` | 단위(로컬 DB) | ✅ | +| PC 에서 일하는 작업의 「서버에서 이어서」: 그 걸음이 바로 멈춤(버린 모델 요청 1) · PC 에 `idle` · 서버 브라우저가 같은 주소 · 모델이 까닭을 들음 · 카드 `where.asked` · 옮기는 중 두 번째는 false · 같은 카드를 다시 하면 서버(`why: 'asked'`) | 사용자 12-02 | `browser-local.test.js` 「PC 에서 일하는 작업의 「서버에서 이어서」…」 | 단위(Electron) | ✅ | +| 채팅의 말(`browser_task where: server`)이면 PC 가 켜져 있어도 서버 · 카드에 남음 | 사용자 12-02 | 「채팅에서 이 작업만 서버로 …」 | 단위(Electron) | ✅ | +| 기본값 「늘 서버」 → 서버(`why: 'person'`), 「PC 에서」라고 한 작업만 PC, 되돌리면 PC | 사용자 12-02 | 「설정 「브라우저 작업 위치」 = 늘 서버 …」 | 단위(Electron) | ✅ | +| PC 를 기다리며 줄 선 작업(`pcLine`)의 「서버에서 바로 시작」 → 앞 작업이 PC 에서 일하는 동안 서버에서 끝남 · `pcLine` 지워짐 | 사용자 12-02 | 「PC 브라우저를 기다리며 줄 선 작업 …」 | 단위(Electron) | ✅ | +| 없는 작업 · 남의 작업은 옮기지 않음(false) | 설계 | `browserWhere.test.js` | 단위 | ✅ | +| 390 확장 화면: 「서버에서 이어서」 → `route {taskId, to:'server'}` · 단추 다섯 개가 모두 한 줄 높이(40px) · 모두 화면 안(둘째 줄) · 옆으로 넘치지 않음 | 사용자 12-02 | F-BW-01 | feature | ✅ | +| 390 그림이 오지 않는 카드: 「PC 화면을 받지 못하고 있어요」 · 「PC 앱을 0.2.13 버전으로 올리면 진행 화면이 보여요」 · 「내려받기」 링크 · 「서버에서 이어서」, 옮길 수 없다는 답이면 그 까닭, 다시 누르면 보냄 · 확장 화면이 열리지 않음 | 사용자 12-02 | F-BW-02 | feature | ✅ | +| 390 줄 선 카드(`pcLine`)의 「서버에서 바로 시작」 · 「취소」 | 사용자 12-02 | F-BW-03 | feature | ✅ | +| 390 설정 「브라우저 작업 위치」: 「PC 우선」 → 「늘 서버」 → `PUT {where:'server'}` → 줄이 「「늘 서버」로 정했어요」, PC 의 설정 칸은 없음, 저장할 곳이 없으면(`kept: false`) 칸이 잠기고 까닭 | 사용자 12-02 | F-BW-04 · F-LB-03 | feature | ✅ | +| 카드의 「서버 브라우저」(서버를 고른 까닭 `asked` · `person`), PC 가 없어 서버인 작업은 표시 없음 | 설계 | F-BW-05 | feature | ✅ | +| 화면이 잠들거나 잠긴 맥 · 다른 데스크톱 공간 · Windows | 설계 | — | — | ✗(이 맥에서 화면을 재우거나 잠글 수 없어 재지 못함 — 캡처가 안 되면 「받지 못하고 있어요」와 「서버에서 이어서」) | +| 운영 라우터 모델이 「서버에서 해 줘」를 `where: 'server'` 로 읽는지 | 사용자 12-02 | — | — | ✗(실제 모델로 확인 — 이번 시험은 가짜 모델) | +| 운영 DB 에 `076_browser_where.sql` · 사용자 PC 에 0.2.13 | — | — | — | ✗(승인 뒤) | diff --git a/openspec/specs/browser-handoff/spec.md b/openspec/specs/browser-handoff/spec.md index 07154e88..5a0d9b81 100644 --- a/openspec/specs/browser-handoff/spec.md +++ b/openspec/specs/browser-handoff/spec.md @@ -416,6 +416,37 @@ - **WHEN** 작업이 시작할 때 탭에 앞 작업의 페이지가 있고, 작업이 다른 페이지로 간 뒤 스크린캐스트가 앞 페이지의 그림을 다시 내놓는다 - **THEN** 그 그림은 서버로 가지 않고, 다음에 그린 프레임부터 간다. 그사이 다른 페이지로 간 탭의 재시작 첫 프레임도 보내지 않는다(`desktop/test/browser.test.js` 「실시간 화면은 그 탭의 지금 문서의 프레임만 …」 외 5개) +### Requirement: PC 화면이 오지 않을 때에도 진행 화면이 이어진다 +시스템은 PC 에서 일하는 작업의 실시간 화면이 작업 내내 이어지도록 해야 한다(SHALL). 근거는 사용자 지시 「Pc 에 연결된 브라우저 사용시 진행상태가 보이지 않음. 화면전환된 송출을 최적화하여 연결할 방법이 있나?」(2026-12-02)와 그 휴대폰 화면이다. 카드는 몇 분 동안 「브라우저 여는 중」에 머물렀다. 원인은 송출량이 아니었다. 송출은 이미 바뀐 화면만, 1초에 3장 이하로, 1024×640 JPEG 으로 보낸다. 원인은 그릴 그림이 생기지 않은 것이다. 이 PC 에 보였다가 최소화된 창이나 앱을 숨긴(⌘H) 창은 보이던 페이지는 계속 그리지만, 새 문서(다음 페이지, 다음 작업)는 그리지 않는다. 2026-12-02 측정에서 5초 동안의 실시간 프레임은 다음과 같았다: 한 번도 보이지 않은 숨은 탭 15, 보이는 창 15, 다른 창에 완전히 가려진 창 14~15, 최소화 · 앱 숨김에서 같은 페이지 14~15, 새 페이지 0, 그런 창에서 시작한 다음 작업 0. + +- 작업 시작(데스크톱 0.2.13): 이 PC 에 보였던 창이 지금 최소화되었거나 숨어 있으면(아무도 보고 있지 않으면), 그 작업은 같은 주소의 새 숨은 탭에서 한다. 사람이 「이 PC에서 보기」 창을 닫았을 때와 같다. 소리를 끄고, 서버에 `hidden` 을 알린다. 사람이 화면에 띄워 둔 창은 그대로 둔다(MUST NOT 바꾸지 않는다). +- 받쳐 주는 캡처(데스크톱 0.2.13): 작업이 브라우저를 쥔 동안, 이 PC 에 보였던 탭의 스크린캐스트가 1초쯤 아무것도 보내지 않으면 약 1초마다 그 탭을 캡처해 실시간 프레임으로 보낸다. + - 지금 문서의 그림만 보낸다. + - 직전에 보낸 것과 같은 그림은 다시 보내지 않고, 그동안은 캡처 간격을 4초까지 늘린다. + - 캡처하는 사이에 스크린캐스트의 새 프레임이 나가면 그 캡처는 버린다. + - 스크린캐스트가 다시 오면 캡처를 멈춘다. + - 한 번도 보이지 않은 숨은 탭은 캡처하지 않는다(MUST NOT — 그런 탭을 캡처하면 그 뒤로 그리지 않았다, 2026-11-24). + - 최소화된 창에서 새 페이지로 간 경우, 측정에서는 캡처 한 번으로 창이 다시 그리기 시작해 스크린캐스트가 이어받았다(5초에 15장). +- 서버: PC 에서 일하는 작업에 그림이 한 장도 오지 않은 채 웹 페이지의 그림을 얻지 못하면, 카드는 「브라우저 여는 중」 대신 「PC 화면을 받지 못하고 있어요 — 작업은 이어서 해요」(`noDraw`)를 한 번 보낸다. 빈 페이지에서는 아직 말하지 않고, 서버 브라우저에서는 말하지 않는다. 0.2.13 전 데스크톱에서도 그렇다. +- 카드: 그림이 오지 않는 자리에 「서버에서 이어서」를 둔다(위 「서버 브라우저를 고르기」). PC 앱이 0.2.13 보다 오래되었고 0.2.13 이상이 나와 있으면 「PC 앱을 <판> 버전으로 올리면 진행 화면이 보여요」와 「내려받기」를 함께 보인다(`where.update`). 그 판이 아직 나오지 않았거나 새 판 알림을 끈 설치에서는 보이지 않는다(MUST NOT). +- 재지 못한 것: 화면이 잠들거나 잠긴 맥, 다른 데스크톱 공간 · 전체 화면 앱 뒤의 창, Windows PC. 받쳐 주는 캡처는 창의 상태가 아니라 스크린캐스트가 조용한 것을 보고 시작하므로 이런 경우에도 캡처가 되면 화면이 온다. 캡처가 안 되면 카드는 위의 말과 「서버에서 이어서」를 보인다. + +#### Scenario: 최소화된 창에서 다음 페이지로 간다 +- **GIVEN** 「테스트 맥」에서 작업의 창을 「이 PC에서 보기」로 본 뒤 최소화했다 +- **WHEN** 작업이 다른 페이지(250ms 마다 바뀌는 시험 페이지)로 간다 +- **THEN** 실시간 화면이 4초에 3장 이상 오고, 모두 지금 페이지의 그림이며 같은 그림이 거듭 오지 않는다(`server/test/browserDriver.test.js`) +- **AND** 앱을 숨긴(⌘H) 경우도 같다(5초에 15장 — 측정) + +#### Scenario: 최소화된 창으로 다음 작업이 시작한다 +- **GIVEN** 앞 작업에서 「이 PC에서 보기」로 본 창을 최소화해 두었다 +- **WHEN** 휴대폰에서 다음 작업을 시킨다 +- **THEN** 그 작업은 새 숨은 탭에서 하고, 실시간 화면이 4초에 8장 이상 온다(캡처 없이). 이 PC 의 로그에 「was shown on this PC and nobody sees it now … the task goes on in a fresh hidden tab」(`browserDriver.test.js` · `browser-local.test.js`) + +#### Scenario: 그림이 한 장도 오지 않는 옛 PC 앱 +- **GIVEN** 윤태호의 맥은 0.2.10 이고 0.2.13 이 나와 있다 +- **WHEN** 그 맥에서 일하는 작업이 그림을 한 장도 보내지 못한다 +- **THEN** 카드는 「PC 화면을 받지 못하고 있어요 — 작업은 이어서 해요」, 「PC 앱을 0.2.13 버전으로 올리면 진행 화면이 보여요」 · 「내려받기」, 「서버에서 이어서」를 보인다(`browserTabShot.test.js` · F-BW-02) + ### Requirement: PC 의 브라우저는 Lite 앱과 그 로그인 주소를 열지 않는다 시스템은 서버의 에이전트가 모는 PC 의 브라우저가 그 데스크톱 앱이 연결한 Lite 서버의 주소(그 출처 — 이 PC 에 있는 서버면 같은 포트의 이 PC 의 다른 이름 · 주소도)와 그 서버의 로그인(Supabase) 주소를 열거나 그리로 요청을 보내지 않게 해야 한다(MUST NOT, 데스크톱 0.2.6). 에이전트의 열기, 그리로 보내는 사이트, 페이지의 링크 · 새 창 · 프레임 · 폼, 페이지의 요청(fetch · 그림 · sendBeacon · 소켓 · 서비스 워커의 fetch)이 모두 그렇고, 「이 PC에서 보기」로 사람이 넘겨받은 창에서도 같다. `about:blank` 와 다른 사이트(Google 계정 화면을 포함)는 그대로 연다. diff --git a/server/lib/browser.js b/server/lib/browser.js index 9d7547ff..3ecd5e95 100644 --- a/server/lib/browser.js +++ b/server/lib/browser.js @@ -151,8 +151,19 @@ export function samePage(a, b) { // 유튜브에서 작업중이라고 나온다」 — a PC's window that drew nothing kept an earlier task's NotebookLM on the card while the task worked // in YouTube Studio). When no new picture came and the one shown is of another page than the task's now, it goes: the card says the // screen is not coming (noDraw) and keeps nothing of that page — not the live view, not the card's last screen. ln: the task's lane +// A task on the person's PC that has had no picture at all (a PC app before 0.2.13 whose window there was shown and then minimized draws +// nothing for a new page — 2026-12-02 사용자: 「Pc 에 연결된 브라우저 사용시 진행상태가 보이지 않음」, his card stood on 「브라우저 여는 중」): +// once a picture of a page it is on did not come, the card says so (noDraw) — with 「서버에서 이어서」 and, for that PC app, the version +// that brings it (TaskCard.vue) — rather than 「브라우저 여는 중」 for the whole task. function dropStale(userId, ln) { - if (!ln?.frame || !ln.driver) return + if (!ln?.driver) return + if (!ln.frame) { + const at = ln.driver.kind === 'local' ? String(ln.driver.url() || '') : '' + if (ln.noDraw || !/^https?:/i.test(at)) return + ln.noDraw = true + if (ln.task) showFrame(userId, ln.task, null, shown(at), { noDraw: true }) + return + } const now = shown(ln.driver.url() || '') if (samePage(ln.frameUrl, now)) return ln.frame = null diff --git a/server/test/browser-local.test.js b/server/test/browser-local.test.js index ac9a5197..f8fc7dfd 100644 --- a/server/test/browser-local.test.js +++ b/server/test/browser-local.test.js @@ -658,7 +658,9 @@ test('앞 작업이 남긴 페이지 · 이 PC 에서 내려 둔 창: 다음 작 assert.equal(colorOf(pics.at(-1).data), 'blue', '카드의 마지막 그림') assert.ok(c2.content.shot, '끝난 카드에 마지막 화면') assert.equal(colorOf(c2.content.shot), 'blue', '끝난 카드의 마지막 화면은 파란 페이지') - assert.match(pc.output().slice(from), /shows nothing on this PC: its picture is a capture/, '그 그림은 캡처였다(이 PC 의 로그)') + // (desktop 0.2.13: the next task does not work in the window the person minimized — it goes on in a fresh hidden tab, which draws: + // no capture needed — 2026-12-02 측정, desktop/src/browser/host.js begin) + assert.match(pc.output().slice(from), /was shown on this PC and nobody sees it now .*: the task goes on in a fresh hidden tab/, '내려 둔 창 대신 새 숨은 탭(이 PC 의 로그)') } finally { off() await pc.window('restore').catch(() => {}) diff --git a/server/test/browserDriver.test.js b/server/test/browserDriver.test.js index 88652314..c3f8d12b 100644 --- a/server/test/browserDriver.test.js +++ b/server/test/browserDriver.test.js @@ -675,7 +675,7 @@ const colorOf = (pic) => { const [r, g, b] = [img.data[o], img.data[o + 1], img.data[o + 2]] return r > 150 && g < 80 && b < 80 ? 'red' : b > 150 && r < 80 && g < 80 ? 'blue' : `other(${r},${g},${b})` } -test('local: 앞 작업이 남긴 페이지에서, 이 PC 에 보였다가 내린 창으로 다음 작업이 다른 사이트에 가도 카드의 그림은 그 사이트다 — 앞 페이지의 그림은 한 장으로도 실시간 화면으로도 오지 않고, 창은 다시 그린다', local, async () => { +test('local: 앞 작업이 남긴 페이지에서, 이 PC 에 보였다가 내린 창으로 다음 작업이 다른 사이트에 가도 카드의 그림은 그 사이트다 — 앞 페이지의 그림은 한 장으로도 실시간 화면으로도 오지 않고, 작업은 새 숨은 탭에서 그린다', local, async () => { const pics = () => (seen.local.pics ||= []) await rd.begin() await rd.navigate(`${site.url}/red`) @@ -698,12 +698,14 @@ test('local: 앞 작업이 남긴 페이지에서, 이 PC 에 보였다가 내 const one = await rd.frameShot() assert.ok(one, '한 장이 온다') assert.equal(colorOf(one), 'blue', '카드용 한 장은 지금 페이지(파랑)') - assert.match(pc.output().slice(from), /shows nothing on this PC: its picture is a capture/, '캡처로 찍었다(이 PC 의 로그)') + // (2026-12-02, desktop 0.2.13: the minimized window is taken as not shown when the task begins — the task works in a fresh hidden tab, + // which draws every page: 「local: … 다음 작업이 시작하면 새 숨은 탭에서 …」 below) + assert.match(pc.output().slice(from), /was shown on this PC and nobody sees it now .*: the task goes on in a fresh hidden tab/, '새 숨은 탭에서(이 PC 의 로그)') // the model's picture too (the secret fields painted over first — drawn after that) const shot = await rd.shot() assert.ok(shot, '모델의 그림도 온다') assert.equal(colorOf(shot), 'blue') - // the window draws again after it: the live view comes, of the blue page — and nothing red came after the task went there + // the tab draws: the live view comes, of the blue page — and nothing red came after the task went there assert.ok(await until(() => pics().slice(n1).some((f) => colorOf(f.data) === 'blue'), 5000), `실시간 화면이 다시 온다: ${pics().slice(n0).map((f) => colorOf(f.data)).join(' ')}`) const red = pics().slice(n1).filter((f) => colorOf(f.data) === 'red') assert.equal(red.length, 0, `파랑으로 간 뒤 빨강 프레임 ${red.length}장`) @@ -740,3 +742,66 @@ test('local: 이 PC 에 보였다가 내려 둔 창에서도 모델의 그림은 await rd.begin() } }) + +// ---- the live view of a window shown on this PC that nobody sees (2026-12-02 사용자: 「Pc 에 연결된 브라우저 사용시 진행상태가 보이지 않음. +// 화면전환된 송출을 최적화하여 연결할 방법이 있나?」 — the card stayed on 「브라우저 여는 중」 for minutes). Measured that day with /tick (a page +// that changes every 250 ms), live frames in 5 s: hidden 15, shown 15, covered by another window 14–15, minimized or the app hidden 14–15 on +// the page it showed — and 0 once it went to another page there, or the next task began in it (0.2.13 before this). ---- +test('local: 작업 중에 이 PC 에 보인 창을 내려 두고 다른 페이지로 가도 실시간 화면은 계속 온다 — 지금 페이지의 그림으로, 앞 페이지의 그림 없이', local, async () => { + const pics = () => (seen.local.pics ||= []) + await rd.begin() + await rd.navigate(`${site.url}/red`) + await rd.show(true) + assert.equal(await pc.window('minimize'), 'minimize') + await new Promise((r) => setTimeout(r, 600)) + try { + const n0 = pics().length + const r = await rd.navigate(`${site.url}/tick`) + assert.equal(r.ok, true, JSON.stringify(r)) + const t0 = Date.now() + // (no frameShot · shot here: only the live view itself) + await new Promise((res) => setTimeout(res, 4000)) + const got = pics().slice(n0).filter((f) => f.at >= t0) + assert.ok(got.length >= 3, `내려 둔 창의 새 페이지에서도 실시간 화면이 4초에 ${got.length}장(고치기 전: 0)`) + assert.ok(got.every((f) => f.url.endsWith('/tick') && colorOf(f.data) === 'blue'), `지금 페이지(파랑)의 그림만: ${got.map((f) => colorOf(f.data)).join(' ')}`) + assert.ok(new Set(got.map((f) => f.data)).size === got.length, '같은 그림은 두 번 오지 않는다') + } finally { + await pc.window('restore').catch(() => {}) + await rd.show(false) + await rd.begin() + } +}) + +test('local: 이 PC 에 보였다가 내려 둔 창에서 다음 작업이 시작하면 새 숨은 탭에서 — 실시간 화면이 처음부터 온다(고치기 전: 한 장도 없었다)', local, async () => { + const pics = () => (seen.local.pics ||= []) + await rd.begin() + await rd.navigate(`${site.url}/red`) + // the task ends needing the person; they show it on this PC and minimize it — then the next task begins + await rd.idle({ keep: true }) + await rd.show(true) + assert.equal(await pc.window('minimize'), 'minimize') + await new Promise((r) => setTimeout(r, 600)) + const from = pc.output().length + let fresh = false + try { + await rd.begin() + fresh = /was shown on this PC and nobody sees it now .*: the task goes on in a fresh hidden tab/.test(pc.output().slice(from)) + assert.ok(fresh, `새 숨은 탭에서(이 PC 의 로그): ${pc.output().slice(from).slice(-400)}`) + assert.equal(await pc.window('state'), 'state') + assert.match(pc.output().slice(from), /window state: ok \(visible=false minimized=false\)/, '새 탭의 창은 이 PC 에 보이지 않는다') + const n0 = pics().length + const r = await rd.navigate(`${site.url}/tick`) + assert.equal(r.ok, true, JSON.stringify(r)) + const t0 = Date.now() + await new Promise((res) => setTimeout(res, 4000)) + const got = pics().slice(n0).filter((f) => f.at >= t0) + assert.ok(got.length >= 8, `새 숨은 탭의 실시간 화면 4초에 ${got.length}장`) + assert.ok(got.every((f) => f.url.endsWith('/tick') && colorOf(f.data) === 'blue'), got.map((f) => colorOf(f.data)).join(' ')) + assert.doesNotMatch(pc.output().slice(from), /its picture is a capture/, '찍지 않아도 그린다') + } finally { + // (the minimized window is gone when begin swapped it; otherwise it is put back and hidden) + if (!fresh) await pc.window('restore').catch(() => {}) + await rd.show(false) + await rd.begin() + } +}) diff --git a/server/test/browserTabShot.test.js b/server/test/browserTabShot.test.js index 36446886..30546005 100644 --- a/server/test/browserTabShot.test.js +++ b/server/test/browserTabShot.test.js @@ -72,6 +72,34 @@ test('작업이 다른 페이지로 갔는데 새 그림이 없으면, 앞 페 } finally { ev.off(); browser._dropLane(ln) } }) +test('PC 작업에 그림이 한 장도 오지 않으면(0.2.10 의 내려 둔 창) 카드는 「브라우저 여는 중」이 아니라 「화면을 받지 못하고 있어요」 — 한 번만, 빈 페이지 · 서버 브라우저는 아님, 그림이 오면 그 그림', async () => { + // (2026-12-02 사용자: 「Pc 에 연결된 브라우저 사용시 진행상태가 보이지 않음」 — the card stood on 「브라우저 여는 중」 for the whole task) + const { userId, ln, d } = lane({ url: 'about:blank' }) + const ev = events(userId) + try { + assert.equal(await browser._pushFrame(userId, ln), null) + assert.equal(ev.got.length, 0, '빈 페이지에서는 아직 말하지 않는다(여는 중)') + d.at = STUDIO + assert.equal(await browser._pushFrame(userId, ln), null) + assert.deepEqual([ev.got.at(-1).data, ev.got.at(-1).noDraw, ev.got.at(-1).url], [null, true, STUDIO], '그림 없음이 카드로 간다') + const last = browser.lastFrame(userId, ln.id) + assert.deepEqual([last.data, last.noDraw], [null, true], '나중에 연 카드도 그림 없음을 본다') + assert.equal(await browser._pushFrame(userId, ln), null) + assert.equal(ev.got.filter((e) => e.noDraw).length, 1, '같은 말을 거듭 보내지 않는다') + d.frameShot = async () => 'STUDIO-JPEG' + assert.equal(await browser._pushFrame(userId, ln), 'STUDIO-JPEG') + assert.deepEqual([ev.got.at(-1).data, ev.got.at(-1).noDraw], ['STUDIO-JPEG', undefined]) + } finally { ev.off(); browser._dropLane(ln) } + // this server's own browser: no such line (its picture is the screencast's, and a missing one is a passing hitch) + const s2 = lane({ url: STUDIO }) + s2.d.kind = 'server' + const ev2 = events(s2.userId) + try { + assert.equal(await browser._pushFrame(s2.userId, s2.ln), null) + assert.equal(ev2.got.length, 0) + } finally { ev2.off(); browser._dropLane(s2.ln) } +}) + test('같은 페이지(# 뒤만 바뀜)에서 새 그림이 오지 않으면 보이던 그림은 그대로 — 물음표 뒤로 고른 다른 영상으로 가면 내린다', async () => { const { userId, ln, d } = lane({ url: 'https://www.youtube.example/watch?v=aaa' }) const ev = events(userId) diff --git a/server/test/fixtures/desktopBrowser.mjs b/server/test/fixtures/desktopBrowser.mjs index 4a454ea0..f67e5184 100644 --- a/server/test/fixtures/desktopBrowser.mjs +++ b/server/test/fixtures/desktopBrowser.mjs @@ -36,11 +36,12 @@ export function startDesktopBrowser({ server, token, userData = fs.mkdtempSync(p return { proc, ready, userData, output: () => out, - // what the person does to the window of the tab the work is in on that PC: 'minimize' · 'restore' (helpers/browser-host.js) + // what the person does to the window of the tab the work is in on that PC: 'minimize' · 'restore' — and 'cover' · 'uncover' (another + // window over all of it), 'hide-app' · 'show-app' (⌘H), 'state' (nothing) (helpers/browser-host.js) → what, or null: no window window: (what) => new Promise((resolve, reject) => { const from = out.length const t = setTimeout(() => reject(new Error(`the desktop browser did not ${what} its window:\n${out.slice(-500)}`)), 5000) - const on = () => { const said = out.slice(from); if (new RegExp(`window ${what}(d|: none)`).test(said)) { clearTimeout(t); proc.stdout.off('data', on); resolve(/: none/.test(said) ? null : what) } } + const on = () => { const said = out.slice(from); if (new RegExp(`window ${what}(d|: ok|: none)`).test(said)) { clearTimeout(t); proc.stdout.off('data', on); resolve(/: none/.test(said) ? null : what) } } proc.stdout.on('data', on) proc.stdin.write(`${what}\n`) }), diff --git a/server/test/fixtures/drivers.mjs b/server/test/fixtures/drivers.mjs index 1116a3b9..b6d5cbd6 100644 --- a/server/test/fixtures/drivers.mjs +++ b/server/test/fixtures/drivers.mjs @@ -15,6 +15,7 @@ // /keys 같은 로그인 폼(Enter 로 보냄), 칸마다 받은 글자 키를 센다(「keys u= p=」) // /inner iframe 안쪽(다른 출처) // /red · /blue 온통 빨강 · 파랑인 페이지(「앞 작업의 페이지」 · 「이 작업의 페이지」 — 그림이 어느 페이지의 것인지 색으로 본다) +// /tick 0.25초마다 바뀌는 파랑 페이지(짙은 파랑 · 파랑이 번갈아, 숫자가 하나씩) — 실시간 화면이 계속 오는지 센다 import http from 'node:http' export const PASSWORD = 'pl-Secret-7731!' @@ -35,6 +36,8 @@ const page = (origin2) => ({ `), '/red': html('앞 작업의 페이지', '

앞 작업의 페이지

'), '/blue': html('이 작업의 페이지', '

이 작업의 페이지

'), + '/tick': html('바뀌는 페이지', `

0

+`), '/inner': html('안쪽', `

안쪽 글

`), '/long': html('긴 페이지', `

긴 페이지 맨 위

${Array.from({ length: 120 }, (_, i) => `

줄 ${i + 1}

`).join('')}

맨 아래 줄

`), From b529d19dc73db8131bd2aac478f089531bb7d90f Mon Sep 17 00:00:00 2001 From: jinyoung Date: Wed, 2 Dec 2026 12:18:13 +0900 Subject: [PATCH 04/12] =?UTF-8?q?docs(browser):=20=EC=84=A4=EA=B3=84=20?= =?UTF-8?q?=EB=85=B8=ED=8A=B8=20=C2=B7=20=EC=8A=A4=ED=8E=99=20=C2=B7=20?= =?UTF-8?q?=EC=B9=B4=ED=83=88=EB=A1=9C=EA=B7=B8=20=C2=A7105=20=C2=B7=20?= =?UTF-8?q?=EB=B3=80=EA=B2=BD=20=EA=B8=B0=EB=A1=9D=20=EC=9C=A4=EB=AC=B8(co?= =?UTF-8?q?dex=20astra,=20=EB=B0=94=EB=80=90=20=EC=A4=84=EB=A7=8C)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-Authored-By: Claude Opus 5.5 --- CHANGELOG.md | 4 +- docs/browser-where/design.md | 62 ++++++++++----------- e2e/README.md | 40 +++++++------- openspec/specs/browser-handoff/spec.md | 74 +++++++++++++------------- 4 files changed, 90 insertions(+), 90 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index ac54ea49..4f4e2208 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,9 +7,9 @@ ### 바뀜 -- **「내 PC」 브라우저 작업의 진행 화면이 끊기지 않습니다. 이 PC 에 보였다가 최소화했거나 앱을 숨긴 창에서 작업이 새 페이지로 가면, 실시간 화면이 5초에 0장이던 것이 15장으로 늘었습니다. 그런 창에서 다음 작업이 시작하면 같은 주소의 새 숨은 탭에서 일합니다. 그림이 한 장도 오지 않는 PC 작업의 카드는 「브라우저 여는 중」에 머물지 않고 「PC 화면을 받지 못하고 있어요」를 보입니다** (스펙 `browser-handoff` 「PC 화면이 오지 않을 때에도 진행 화면이 이어진다」, 설계 `docs/browser-where/design.md`(측정), 데스크톱 `desktop/src/browser/host.js` `startLive`(받쳐 주는 캡처, `LIVE_STILL_MS`) · `begin` — 데스크톱 0.2.13 에 함께 나감, 서버 `lib/browser.js dropStale`, 시험 `desktop/test/browser.test.js` 6개 · `server/test/browserDriver.test.js` 진짜 Electron 2개 · `browserTabShot.test.js`, 카탈로그 §105) +- **「내 PC」 브라우저 작업의 진행 화면이 끊기지 않습니다. 이 PC에 보였다가 최소화했거나 앱을 숨긴 창에서 작업이 새 페이지로 가면, 실시간 화면이 5초에 0장이던 것이 15장으로 늘었습니다. 그런 창에서 다음 작업이 시작하면 같은 주소의 새 숨은 탭에서 일합니다. 그림이 한 장도 오지 않는 PC 작업의 카드는 「브라우저 여는 중」에 머물지 않고 「PC 화면을 받지 못하고 있어요」를 보여 줍니다** (스펙 `browser-handoff` 「PC 화면이 오지 않을 때에도 진행 화면이 이어진다」, 설계 `docs/browser-where/design.md`(측정), 데스크톱 `desktop/src/browser/host.js` `startLive`(받쳐 주는 캡처, `LIVE_STILL_MS`) · `begin` — 데스크톱 0.2.13에 함께 나감, 서버 `lib/browser.js dropStale`, 시험 `desktop/test/browser.test.js` 6개 · `server/test/browserDriver.test.js` 실제 Electron 2개 · `browserTabShot.test.js`, 카탈로그 §105) -- **PC 가 켜져 있어도 브라우저 작업을 서버 브라우저에서 할 수 있습니다. 설정 「브라우저 작업 위치」에서 기본값을 「PC 우선」 또는 「늘 서버」로 고르고(웹 · 휴대폰에서도 바꿈), 채팅에서 「서버에서 해 줘」라고 하면 그 작업만 서버에서 합니다. PC 에서 일하는 작업의 카드에는 「서버에서 이어서」가 있어, 누르면 서버 브라우저가 같은 페이지에서 이어서 하고, PC 를 기다리며 줄 선 작업에는 「서버에서 바로 시작」이 있습니다. PC 화면이 오지 않으면 카드에 「서버에서 이어서」와, 옛 PC 앱이면 진행 화면이 보이는 새 판(0.2.13 이 나온 뒤) 안내가 함께 나옵니다. 확장 화면의 단추는 휴대폰에서 글자가 두 줄로 깨지지 않고 둘째 줄로 넘어갑니다** (스펙 `browser-handoff` 「서버 브라우저를 고르기」, 설계 `docs/browser-where/design.md`, 서버 `lib/browserWhere.js`(새) · `lib/browserRemote.js routeOf`(`where` · `person`) · `lib/browser.js moveToServer · routeTo · liveUpdateOf` · `lib/agent.js`(`browser_task` 의 `where`) · `PUT /api/browser/where`, DB `server/sql/076_browser_where.sql`(`pro_profile.browser_where` — 없으면 모두 「PC 우선」, 바꾸기는 503), 화면 `TaskCard.vue` · `LocalAgentsSettings.vue`, 시험 `server/test/browserWhere.test.js` · `browser-local.test.js`(진짜 Electron 4개) · `e2e/tests/feature/browser-where.spec.js` F-BW-01…05 · F-LB-03 · 05 고침, 카탈로그 §105) +- **PC가 켜져 있어도 브라우저 작업을 서버 브라우저에서 할 수 있습니다. 설정 「브라우저 작업 위치」에서 기본값을 「PC 우선」 또는 「늘 서버」로 고르고(웹 · 휴대폰에서도 바꿈), 채팅에서 「서버에서 해 줘」라고 하면 그 작업만 서버에서 합니다. PC에서 일하는 작업의 카드에는 「서버에서 이어서」가 있어, 누르면 서버 브라우저가 같은 페이지에서 이어서 합니다. PC를 기다리며 줄 선 작업에는 「서버에서 바로 시작」이 있습니다. PC 화면이 오지 않으면 카드에 「서버에서 이어서」가 나오고, 옛 PC 앱이면 진행 화면을 볼 수 있는 새 판(0.2.13이 나온 뒤) 안내가 함께 나옵니다. 확장 화면의 단추는 휴대폰에서 글자가 두 줄로 갈라지지 않고 둘째 줄로 넘어갑니다** (스펙 `browser-handoff` 「서버 브라우저를 고르기」, 설계 `docs/browser-where/design.md`, 서버 `lib/browserWhere.js`(새) · `lib/browserRemote.js routeOf`(`where` · `person`) · `lib/browser.js moveToServer · routeTo · liveUpdateOf` · `lib/agent.js`(`browser_task`의 `where`) · `PUT /api/browser/where`, DB `server/sql/076_browser_where.sql`(`pro_profile.browser_where` — 없으면 모두 「PC 우선」, 변경은 503), 화면 `TaskCard.vue` · `LocalAgentsSettings.vue`, 시험 `server/test/browserWhere.test.js` · `browser-local.test.js`(실제 Electron 4개) · `e2e/tests/feature/browser-where.spec.js` F-BW-01…05 · F-LB-03 · 05 고침, 카탈로그 §105) - **프로젝트 방의 산출물 더미에서 프로젝트 계획을 함께 봅니다 — 접힌 더미 이름은 「산출물 · 계획」이고, 펼치면 파일 위에 계획 카드가 있습니다. 파일마다 붙어 있던 「팀원에게 공유」 사람 아이콘은 모두 없애고, 공유 기능은 파일을 길게 누르거나(휴대폰) 오른쪽 클릭하면(컴퓨터) 나오는 메뉴로 옮겼습니다** (스펙 `chat-artifacts` 「프로젝트 방의 더미에는 계획도 있다」 · 「파일의 공유는 파일의 메뉴에 있다」, `project-room` · `messenger-drop-folder` · `answer-share`, 설계 `docs/chat-artifacts/design.md`, 화면 `ArtifactStack.vue` · `ProjectPlanView.vue` · `FileItemMenu.vue` · `ArtifactList.vue` · `Message.vue` · `FileGroupRow.vue` · `holdMenu.js` · `ProjectNote.vue`, 순수 규칙 `src/artifactScope.js`, 시험 AS-U-07 · 08 · F-SPL-01~07, 카탈로그 103절, 2026-12-02 사용자 — 「프로젝트 내에서 프로젝트 계획을 볼 수 있는 부분이 필요한데, 여기 산출물 열기를 했을 때 거기에 프로젝트 계획 보기 같은 게 있으면 같이 볼 수 있을 것 같아. 산출물 및 계획 뭐 이런 식으로 아이콘 줄어들었을 때 그 조그만한 다이얼로그 부분에는 그렇게 표시해주면 좋겠네.」 · 「그리고 지금 공유 버튼을 위해 가지고 팀원에게 공유하는 저 아이콘들, 뭐 대화방에도 있고 산출물 여기에도 있고, 저기 그 사람 아이콘 저거는 다 없애줘. 다 없애고 우클릭, 그러니까 모바일에서는 길게 클릭했을 때 나오는 컨텍스트 메뉴로 다 바꾸자.」): 프로젝트 계획은 방 맨 위의 칩으로만 열 수 있어서, 대화가 길어지면 칩이 위로 밀려 보이지 않았습니다. 이제 프로젝트 방에서 더미를 펼치면 맨 위에 목적이 보이는 「프로젝트 계획」 카드가 있고, 누르면 같은 상자 안에서 목적 · 쓰는 도구 · 만들 것 · 지킬 것 · 정한 것과 최근에 바뀐 것을 읽습니다. 긴 항목도 줄을 바꿔 휴대폰에서 다 보입니다. 고치기 · 바뀐 기록 · 되돌리기는 예전처럼 계획 시트에서 하며, 「고치기 · 바뀐 기록」을 누르면 시트가 열립니다. 넓은 화면의 오른쪽 산출물 목록 맨 위에도 계획 줄이 있습니다. 채팅의 더미는 예전처럼 「산출물」입니다. 더미의 파일, 오른쪽 목록의 행, 채팅의 파일 카드와 묶은 카드의 줄에서는 모두 파일 메뉴(열기 · 팀원에게 공유 · 폴더에 정리)의 「팀원에게 공유」로 공유합니다. 키보드로는 Shift+F10이나 메뉴 키로 열고, 더미의 파일과 목록의 행에도 채팅 카드처럼 포인터를 올리거나 키보드 초점을 맞추면 보이는 「⋯」이 있습니다. 같은 파일의 메뉴를 다시 열어도 폴더 판정을 다시 묻지 않습니다. 길게 눌러도 글자가 선택되거나 파일이 열리지 않습니다. 계획을 읽는 동안 Esc를 누르면 파일로 돌아가고, 휴대폰을 옆으로 들어도 상자가 화면 안에 있습니다. 여러 파일을 한 번에 보내는 「모두 공유」와 문서 편집기 머리의 「공유」 단추는 그대로입니다. 공유 권한 · 서버는 바뀌지 않았고 새 SQL은 없습니다. diff --git a/docs/browser-where/design.md b/docs/browser-where/design.md index a10527f5..210ffe35 100644 --- a/docs/browser-where/design.md +++ b/docs/browser-where/design.md @@ -5,49 +5,49 @@ ## 2026-12-02 — 처음 ### 무엇을 받았나 -휴대폰 화면 두 장과 이 말을 받았다: 「Pc 에 연결된 브라우저 사용시 진행상태가 보이지 않음. 화면전환된 송출을 최적화하여 연결할 방법이 있나? 그리고 pc 에 연결된 브라우저에서 동작하길 원치 않고 서버 파드에서 돌리고 싶은 경우도 지원」. -- 11:31 화면: 카드에 「내 PC · uengineui-MacBookPro」 · 「브라우저 여는 중」이 있고 그림은 없다. 알약은 「페이지 읽는 중」이다. -- 11:35 화면: 확장 화면에 YouTube Studio 업로드 창 한 장이 있다. 단추줄은 「계획 / 2/6」 · 「직접 제 / 어」 · 「이 PC에서 / 보기」 · 「작업 취 / 소」처럼 글자가 두 줄로 깨진다. +휴대폰 화면 두 장과 다음 말을 받았다: 「Pc 에 연결된 브라우저 사용시 진행상태가 보이지 않음. 화면전환된 송출을 최적화하여 연결할 방법이 있나? 그리고 pc 에 연결된 브라우저에서 동작하길 원치 않고 서버 파드에서 돌리고 싶은 경우도 지원」. +- 11:31 화면: 카드에 「내 PC · uengineui-MacBookPro」 · 「브라우저 여는 중」이 있고 그림은 없다. 알약에는 「페이지 읽는 중」이 표시된다. +- 11:35 화면: 확장 화면에 YouTube Studio 업로드 창 한 장이 있다. 단추줄은 「계획 / 2/6」 · 「직접 제 / 어」 · 「이 PC에서 / 보기」 · 「작업 취 / 소」처럼 글자가 두 줄로 갈라진다. ### 왜 안 보였나 -- 그 맥의 PC 앱은 **0.2.10** 이었다. 0.2.12 까지는 나와 있었지만 받지 않은 상태였고, 0.2.13(#188, 탭 그림)은 아직 나오지 않았다. -- 실시간 화면은 숨은 창의 CDP 스크린캐스트다. 이 PC 에 한 번도 보인 적 없는 숨은 창은 그림을 그린다. 그런데 **이 PC 에 보였다가 최소화된 창, 앱이 숨긴(⌘H) 창**은 보이던 페이지는 계속 그리지만 **새 문서**(다음 페이지, 다음 작업)는 그리지 않는다(아래 「측정」). 그날 아침 NotebookLM 작업 때 「이 PC에서 보기」로 띄운 창이 최소화된 채 남아 있었다. -- 그 상태에서 0.2.10 은 프레임을 하나도 보내지 못한다. 모델용 그림(걸음마다 한 장)도 비어서 카드에 그림이 없었다. 0.2.13 은 최소화된 창을 한 번 캡처해 모델의 그림과 카드의 한 장을 얻지만, 그다음 캡처까지는 실시간 화면을 채우지 못한다. -- 대역폭 문제는 아니었다. 송출은 이미 바뀐 화면만, 1초에 3장 이하로, 1024×640 JPEG(품질 50)으로 보낸다. 보낼 그림이 생기지 않은 것이 원인이다. +- 그 맥의 PC 앱은 **0.2.10**이었다. 0.2.12까지 나와 있었지만 받지 않은 상태였고, 0.2.13(#188, 탭 그림)은 아직 나오지 않았다. +- 실시간 화면은 숨은 창의 CDP 스크린캐스트다. 이 PC에 한 번도 보인 적 없는 숨은 창은 그림을 그린다. 그런데 **이 PC에 보였다가 최소화된 창, 앱을 숨긴(⌘H) 창**은 보이던 페이지는 계속 그리지만 **새 문서**(다음 페이지, 다음 작업)는 그리지 않는다(아래 「측정」). 그날 아침 NotebookLM 작업 때 「이 PC에서 보기」로 띄운 창이 최소화된 채 남아 있었다. +- 그 상태에서 0.2.10은 프레임을 하나도 보내지 못한다. 모델용 그림(걸음마다 한 장)도 비어 있어 카드에 그림이 없었다. 0.2.13은 최소화된 창을 한 번 캡처해 모델용 그림과 카드에 쓸 그림 한 장을 얻지만, 그다음 캡처까지는 실시간 화면을 채우지 못한다. +- 대역폭 문제는 아니었다. 송출은 이미 바뀐 화면만 1초에 3장 이하로, 1024×640 JPEG(품질 50)으로 보낸다. 보낼 그림이 생기지 않은 것이 원인이다. -### 바꾼 것 — 데스크톱(0.2.13 에 함께) +### 바꾼 것 — 데스크톱(0.2.13에 함께) (측정 수치는 아래 「측정」에 적는다.) -- **진행 화면 받쳐 주기**: 작업 중인 탭이 이 PC 에 보였던 창이고 스크린캐스트가 1초쯤 아무것도 보내지 않으면, 약 1초마다 그 창을 캡처해 실시간 화면으로 보낸다. 직전에 보낸 것과 같은 그림은 다시 보내지 않고, 스크린캐스트가 다시 오면 캡처를 멈춘다. 한 번도 보이지 않은 숨은 창은 캡처하지 않는다. 그런 창을 캡처하면 그 창이 그리기를 멈추기 때문이다(2026-11-24). -- **작업 시작 때 새 창**: 이 PC 에 보였다가 지금은 최소화되었거나 숨은 창이면, 작업을 시작할 때 같은 주소의 새 숨은 탭으로 바꾼다. 그 작업의 실시간 화면이 처음부터 온다. 사람이 화면에 띄워 둔 창은 그대로 둔다. +- **진행 화면 받쳐 주기**: 작업 중인 탭이 이 PC에 보였던 창에 있고 스크린캐스트가 1초쯤 아무것도 보내지 않으면, 약 1초마다 그 창을 캡처해 실시간 화면으로 보낸다. 직전에 보낸 것과 같은 그림은 다시 보내지 않고, 스크린캐스트가 다시 오면 캡처를 멈춘다. 한 번도 보이지 않은 숨은 창은 캡처하지 않는다. 그런 창을 캡처하면 그 창이 그리기를 멈추기 때문이다(2026-11-24). +- **작업 시작 때 새 창**: 이 PC에 보였다가 지금은 최소화되었거나 숨은 창이면, 작업을 시작할 때 같은 주소의 새 숨은 탭으로 바꾼다. 그러면 그 작업의 실시간 화면이 처음부터 온다. 사람이 화면에 띄워 둔 창은 그대로 둔다. ### 바꾼 것 — 서버 · 화면 -- 그림이 한 장도 오지 않은 PC 작업: 웹 페이지의 그림을 얻지 못하면 카드에 `noDraw`를 한 번 보낸다(`dropStale`). 지금까지는 앞서 보이던 그림이 있을 때만 「받지 못하고 있어요」로 바꾸어서, 그림이 처음부터 없는 작업은 작업 내내 「브라우저 여는 중」에 머물렀다. 이 고침은 서버에만 있으므로 0.2.10 에도 바로 닿는다. +- 그림이 한 장도 오지 않은 PC 작업: 웹 페이지의 그림을 얻지 못하면 카드에 `noDraw`를 한 번 보낸다(`dropStale`). 지금까지는 앞서 보이던 그림이 있을 때만 「받지 못하고 있어요」로 바꾸었으므로, 그림이 처음부터 없는 작업은 작업 내내 「브라우저 여는 중」에 머물렀다. 이 수정은 서버에만 적용되므로 0.2.10에도 바로 반영된다. - 카드에 그림이 오지 않을 때(`noDraw`): - 그 자리에 「서버에서 이어서」를 둔다. - - PC 앱이 진행 화면을 못 보내는 옛 판이면 「PC 앱을 <판> 버전으로 올리면 진행 화면이 보여요 · 내려받기」를 함께 보인다(`where.update`, `lib/browser.js liveUpdateOf`). 이 줄은 그 판(0.2.13)이 **나온 뒤에만** 보인다. 받을 수 없는 판을 안내하지 않기 위해서다. + - PC 앱이 진행 화면을 못 보내는 옛 판이면 「PC 앱을 <판> 버전으로 올리면 진행 화면이 보여요 · 내려받기」를 함께 보여 준다(`where.update`, `lib/browser.js liveUpdateOf`). 이 줄은 그 판(0.2.13)이 **나온 뒤에만** 보인다. 받을 수 없는 판을 안내하지 않기 위해서다. - 확장 화면 단추줄: - - 휴대폰 폭에서 단추 글자가 두 줄로 깨지지 않게 했다. - - 다 들어가지 않으면 가운데 맞춘 둘째 줄로 넘긴다. 가로 스크롤은 쓰지 않았다. 처음에 가로 스크롤로 해 보니 새 단추 「서버에서 이어서」가 화면 밖에 숨었다. 동작 단추는 모두 보여야 하므로 줄 바꿈으로 바꿨다. -- **서버 브라우저 고르기** 네 길(`lib/browserRemote.js routeOf` 의 `where` · `person`): + - 휴대폰 폭에서 단추 글자가 두 줄로 갈라지지 않게 했다. + - 다 들어가지 않으면 가운데로 맞춘 둘째 줄로 넘긴다. 가로 스크롤은 쓰지 않았다. 처음에 가로 스크롤로 해 보니 새 단추 「서버에서 이어서」가 화면 밖에 숨었다. 동작 단추는 모두 보여야 하므로 줄 바꿈으로 바꿨다. +- **서버 브라우저 고르기**의 네 가지 방법(`lib/browserRemote.js routeOf`의 `where` · `person`): 1. 기본값 「브라우저 작업 위치」: `pro_profile.browser_where`, `sql/076`, `lib/browserWhere.js`, `PUT /api/browser/where`. - 2. 한 작업의 말: `browser_task` 의 `where` 매개변수. 모델이 사람의 말을 읽고 정한다. - 3. 일하는 카드의 「서버에서 이어서」: `POST /api/browser/route {to:'server'}` → `moveToServer` → 작업 루프의 `task.moveTo` → `toServer(asked)`. PC 가 꺼졌을 때의 「서버에서 이어서」와 같은 길을 쓴다. + 2. 개별 작업에 대한 말: `browser_task`의 `where` 매개변수. 모델이 사람의 말을 읽고 정한다. + 3. 작업 중인 카드의 「서버에서 이어서」: `POST /api/browser/route {to:'server'}` → `moveToServer` → 작업 루프의 `task.moveTo` → `toServer(asked)`. PC가 꺼졌을 때의 「서버에서 이어서」와 같은 경로를 쓴다. 4. 줄 선 카드의 「서버에서 바로 시작」(`content.pcLine`): 줄의 `route.where = 'server'`. ### 결정(위임 판단) - **기본값은 서버에 사람마다 저장하고, 어느 기기에서나 바꾼다.** - - PC 마다의 「브라우저 작업은 이 PC에서」는 그 PC 의 앱에서만 바꾼다. 서버가 PC 에 일을 더 보내게 만들 수 없어야 하기 때문이다. - - 「늘 서버」는 PC 에서 일을 빼기만 하므로 그 걱정이 없다. 또 사람이 PC 앞에 없을 때(휴대폰) 고르고 싶은 설정이다. - - 우선순위는 한 작업의 선택 → 기본값 → PC 설정이다. 어떤 선택도 PC 가 막은 작업을 그 PC 로 보내지 않는다. -- **한 작업의 말은 도구 매개변수로 받는다.** 라우터 모델이 사람의 말에서 `where` 를 정한다. 낱말 규칙(정규식)은 쓰지 않는다. -- **옮기기는 일하는 작업과 줄 선 작업만 한다.** - - 사람을 기다리는 작업(로그인 · 사람 확인 · 승인)은 그 자리에서 답한다. PC 의 로그인은 그 PC 의 것이기 때문이다. - - 옮긴 작업은 같은 카드에서 다시 해도 서버에서 돈다(`where.asked`). 사람이 PC 를 피한 데는 까닭이 있었다고 본다. -- **옛 PC 앱 안내는 카드에서, 그 판이 나온 뒤에만 한다.** 휴대폰으로 지켜보는 사람이 앱 설정 화면까지 가지 않아도 되게 한다. 0.2.12 의 auto mode 안내(`chat.js pcUpdateOf`)와 같은 방식이다. -- **잠긴 화면 · 꺼진 화면(디스플레이 잠자기)은 재지 않았다.** 이 맥에서는 다른 세션이 녹화를 하고 있어 화면을 재우거나 잠글 수 없었다. 그 상태에서는 캡처도 실패할 수 있다. 그때 카드는 지금처럼 「PC 화면을 받지 못하고 있어요 — 작업은 이어서 해요」와 「서버에서 이어서」를 보인다. + - PC마다 정하는 「브라우저 작업은 이 PC에서」는 그 PC의 앱에서만 바꾼다. 서버가 PC에 일을 더 보내도록 바꿀 수 없어야 하기 때문이다. + - 「늘 서버」는 PC에서 일을 빼기만 하므로 그 걱정이 없다. 또 사람이 PC 앞에 없을 때(휴대폰) 고르고 싶은 설정이다. + - 우선순위는 개별 작업의 선택 → 기본값 → PC 설정이다. 어떤 선택도 PC가 막은 작업을 그 PC로 보내지 않는다. +- **개별 작업에 대한 말은 도구 매개변수로 받는다.** 라우터 모델이 사람의 말에서 `where`를 정한다. 낱말 규칙(정규식)은 쓰지 않는다. +- **작업 중이거나 줄 선 작업만 옮긴다.** + - 사람을 기다리는 작업(로그인 · 사람 확인 · 승인)은 그 자리에서 답한다. PC의 로그인은 그 PC의 것이기 때문이다. + - 옮긴 작업은 같은 카드에서 다시 해도 서버에서 돈다(`where.asked`). 사람이 PC를 피한 데는 까닭이 있었다고 본다. +- **옛 PC 앱 안내는 카드에서, 그 판이 나온 뒤에만 한다.** 휴대폰으로 지켜보는 사람이 앱 설정 화면까지 가지 않아도 되게 한다. 0.2.12의 auto mode 안내(`chat.js pcUpdateOf`)와 같은 방식이다. +- **잠긴 화면 · 꺼진 화면(디스플레이 잠자기)은 측정하지 않았다.** 이 맥에서는 다른 세션이 녹화를 하고 있어 화면을 재우거나 잠글 수 없었다. 그 상태에서는 캡처도 실패할 수 있다. 그때 카드는 지금처럼 「PC 화면을 받지 못하고 있어요 — 작업은 이어서 해요」와 「서버에서 이어서」를 보여 준다. ### 측정 -2026-12-02, 진짜 Electron 시험 도우미에서 잼. 시험 페이지 `/tick` 은 250ms 마다 바뀌고, 작업이 브라우저를 쥔 채 5초 동안 서버에 닿은 실시간 프레임을 셌다. 모든 프레임은 지금 페이지의 그림이었다. +2026-12-02, 실제 Electron 시험 도우미에서 측정했다. 시험 페이지 `/tick`은 250ms마다 바뀌며, 작업이 브라우저를 사용하는 동안 5초에 걸쳐 서버에 도착한 실시간 프레임을 셌다. 모든 프레임은 현재 페이지의 그림이었다. | 상태 | 고치기 전 | 고친 뒤 | |---|---|---| @@ -60,11 +60,11 @@ | 앱 숨김 — **새 페이지** | **0** | **15** | | 최소화된 창에서 **다음 작업 시작** | **0** | **15** | -- 가려진 창은 계속 그리고 `isVisible()` 도 참이었다. 그래서 받쳐 주는 캡처의 조건은 창의 상태가 아니라 「스크린캐스트가 조용함」으로 잡았다. -- 최소화 · 앱 숨김에서 새 페이지로 간 경우 캡처는 페이지마다 한 번뿐이었다. 그 캡처 한 번으로 창이 다시 그리기 시작했고, 그 뒤로는 스크린캐스트가 이어받았다. +- 가려진 창은 계속 그림을 그렸고 `isVisible()`도 참이었다. 그래서 받쳐 주는 캡처의 조건은 창의 상태가 아니라 「스크린캐스트가 조용함」으로 잡았다. +- 최소화하거나 앱을 숨긴 상태에서 새 페이지로 간 경우 캡처는 페이지마다 한 번뿐이었다. 그 캡처 한 번으로 창이 다시 그리기 시작했고, 그 뒤로는 스크린캐스트가 이어받았다. - 측정 스크립트는 세션의 작업 폴더에 두었다(`livecast/measure.mjs`, 저장소에는 넣지 않음). ### 남은 것 - 운영 SQL `076_browser_where.sql`(사용자 승인 필요). 적용 전에는 모두 「PC 우선」으로 돌고 설정 칸이 잠긴다. -- 데스크톱 0.2.13 출시(사용자 승인 필요). 받침 캡처와 작업 시작 때 새 창이 사용자의 맥에 닿는 시점이다. -- 운영 라우터 모델이 「서버에서 해 줘」를 `where: 'server'` 로 읽는지는 실제 모델로 확인하지 않았다(시험은 가짜 모델). +- 데스크톱 0.2.13 출시(사용자 승인 필요). 받쳐 주는 캡처와 작업 시작 때 새 창을 여는 기능이 사용자의 맥에 적용되는 시점이다. +- 운영 라우터 모델이 「서버에서 해 줘」를 `where: 'server'`로 읽는지는 실제 모델로 확인하지 않았다(시험은 가짜 모델). diff --git a/e2e/README.md b/e2e/README.md index d34319ef..7e5bf43e 100644 --- a/e2e/README.md +++ b/e2e/README.md @@ -552,7 +552,7 @@ ProcessGPT 포털의 설정 › 테마 설정 「휴대폰 화면」에서 「 | smoke | `tests/smoke/*.spec.js` (6개) | 74 | | feature | `tests/feature/*.spec.js` (111개) | 803 (서버 브라우저 고르기 F-BW-01…05, 브라우저 에이전트 가드레일 F-GR-01…04, 산출물 더미의 계획 · 공유 메뉴 F-SPL-01…07의 10개, 브라우저 작업 카드의 「PC 화면을 받지 못하고 있어요」 F-LB-05, 방 규칙이 있는 방에 링크만 F-AB-07 PC · 휴대폰, 「이 영상」 서버 시험 F-UT-09, 실행 카드 「전체 화면」 · 오래된 PC 앱 안내 F-CA-14 · 15, 채팅의 프로세스 시작 F-CPM-01 · 02, 내 PC CLI 「멈추기」 F-LV-11, 작업 기록 F-RJ-01…07, 정식 프로세스 F-PO-24…36과 검토 반영 F-PO-25b · 26b · 28a · 30b 17개, 내 PC CLI 시작 대기 F-LA-01…05, 「프로세스」 화면 제목 F-NAV-04 포함 · 프로세스 지도 F-PO-01…23, 방 규칙 F-RR-01…04, 후행 습관 F-FU-01…10, 서버 단위 시험 4묶음, 회의 F-MT-01…08, 팀 맥락 공유 F-TC-01…10, 포털에서 넘어온 휴대폰 F-PT-01…03, 대화 속 그림 · 소리 · 영상 F-MP-01…08, … 에이전트가 호출하는 내장 브라우저 F-AB-01…06의 8개 포함) | | agent | `tests/agent/*.spec.js` (14개) | 33 (회의 A-14, 후행 습관 A-FU-01) | -| 합계 | | 910 (2026-11-28에 `npx playwright test --list`로 집계한 846에 2026-11-29 F-AB-06의 2개, F-PO-24…32 · 25b · 26b · 28a · 30b의 13개, F-LA-01…05의 5개, 2026-11-30 F-NAV-04의 1개 · F-PO-33 · 34 · 35의 3개, 2026-12-01 F-CA-13의 1개 · F-RS-05의 2개 · F-RS-06의 1개 · F-PO-36의 1개 · F-RJ-01…07의 7개 · F-LV-11의 1개 · F-CPM-01 · 02의 2개, 2026-12-02 F-CA-14 · 15의 2개 · F-AB-07의 2개 · F-UT-09의 1개 · F-LB-05의 1개 · F-SPL-01…07의 10개 · F-GR-01…04의 4개 · F-BW-01…05의 5개를 더한 값 — 데스크톱 단계의 LB-04 는 이 표에 세지 않음) | +| 합계 | | 910 (2026-11-28에 `npx playwright test --list`로 집계한 846에 2026-11-29 F-AB-06의 2개, F-PO-24…32 · 25b · 26b · 28a · 30b의 13개, F-LA-01…05의 5개, 2026-11-30 F-NAV-04의 1개 · F-PO-33 · 34 · 35의 3개, 2026-12-01 F-CA-13의 1개 · F-RS-05의 2개 · F-RS-06의 1개 · F-PO-36의 1개 · F-RJ-01…07의 7개 · F-LV-11의 1개 · F-CPM-01 · 02의 2개, 2026-12-02 F-CA-14 · 15의 2개 · F-AB-07의 2개 · F-UT-09의 1개 · F-LB-05의 1개 · F-SPL-01…07의 10개 · F-GR-01…04의 4개 · F-BW-01…05의 5개를 더한 값 — 데스크톱 단계의 LB-04는 이 표에서 세지 않음) | openspec 명세 13개의 요구사항 112개: 덮음 73 · 일부 20 · 공백 19. 명세 밖의 기능 요건(영상·최근 추가 기능: 대화 목록·산출물 스택·로봇 버튼·끊김 복구·유휴 타임아웃·DB 풀·멘션·예약·설치 번들 등) 31개: 덮음 27 · 일부 1 · 공백 3. @@ -2966,9 +2966,9 @@ cd e2e && ~/.claude/tools/lite/reclock.sh run guardrails -- npx playwright test - 이음오피스 시트는 문서를 다 읽으면 키보드 포커스를 가져갑니다 — 다이얼 입력 전에 문서 준비를 기다립니다. - agent 단계는 모델 답이 흔들리므로 한 번 더 시도합니다(`retries: 1`). `[flaky]` 표시가 붙은 시험은 실패해도 같은 단계의 다른 시험과 함께 판단하세요. -### 105. PC 브라우저의 진행 화면이 이어지고, PC 가 켜져 있어도 서버 브라우저를 고른다 (스펙 `browser-handoff` 「서버 브라우저를 고르기」 · 「PC 화면이 오지 않을 때에도 진행 화면이 이어진다」, 설계 `docs/browser-where/design.md`) +### 105. PC 브라우저의 진행 화면이 이어지고, PC가 켜져 있어도 서버 브라우저를 고른다 (스펙 `browser-handoff` 「서버 브라우저를 고르기」 · 「PC 화면이 오지 않을 때에도 진행 화면이 이어진다」, 설계 `docs/browser-where/design.md`) -근거: 2026-12-02 11:31 · 11:35 사용자(휴대폰 화면 — 「내 PC · uengineui-MacBookPro」 카드가 「브라우저 여는 중」에서 머묾, 확장 화면 단추 글자가 두 줄로 깨짐) — 「Pc 에 연결된 브라우저 사용시 진행상태가 보이지 않음. 화면전환된 송출을 최적화하여 연결할 방법이 있나? 그리고 pc 에 연결된 브라우저에서 동작하길 원치 않고 서버 파드에서 돌리고 싶은 경우도 지원」. 그 맥은 0.2.10 이었고, 아침에 보였다가 최소화된 창이 새 페이지를 그리지 않았다(측정은 설계 노트). 진짜 Electron 시험은 시험 도우미의 stdin 「minimize」 · 「hide-app」 · 「cover」로 사람의 창 조작을 흉내 내고, 시험 페이지 `/tick` 은 250ms 마다 바뀐다. 기본값은 로컬 DB 에 `server/sql/076_browser_where.sql` 이 있어야 한다. 사람은 지어낸 윤태호 · 「테스트 맥」. +근거: 2026-12-02 11:31 · 11:35 사용자(휴대폰 화면 — 「내 PC · uengineui-MacBookPro」 카드가 「브라우저 여는 중」에 머묾, 확장 화면 단추 글자가 두 줄로 갈라짐) — 「Pc 에 연결된 브라우저 사용시 진행상태가 보이지 않음. 화면전환된 송출을 최적화하여 연결할 방법이 있나? 그리고 pc 에 연결된 브라우저에서 동작하길 원치 않고 서버 파드에서 돌리고 싶은 경우도 지원」. 그 맥은 0.2.10이었고, 아침에 보였다가 최소화된 창이 새 페이지를 그리지 않았다(측정은 설계 노트). 실제 Electron 시험은 시험 도우미의 stdin 「minimize」 · 「hide-app」 · 「cover」로 사람의 창 조작을 흉내 내고, 시험 페이지 `/tick`은 250ms마다 바뀐다. 기본값을 쓰려면 로컬 DB에 `server/sql/076_browser_where.sql`이 있어야 한다. 시험에 쓰인 윤태호 · 「테스트 맥」은 지어낸 것이다. ```bash cd desktop && npm test # 받쳐 주는 캡처 · 작업 시작 때 새 탭(가짜 탭 6개 포함) @@ -2980,24 +2980,24 @@ cd e2e && PGPT_URL=http://127.0.0.1:5273 API_URL=http://127.0.0.1:8873 npx playw | 요건 | 근거 | 시험 | 단계 | 상태 | |---|---|---|---|---| -| 최소화된 · 앱을 숨긴 창이 새 페이지로 가도 실시간 화면이 옴(5초 0장 → 15장): 스크린캐스트가 1초 조용하면 약 1초마다 캡처, 같은 그림은 다시 보내지 않고 간격을 4초까지 늘림, 새 프레임에 밀린 캡처 · 다른 문서의 캡처는 버림, 프레임이 다시 오면 멈춤 | 사용자 12-02 | `desktop/test/browser.test.js` 6개 · `browserDriver.test.js` 「최소화 …새 페이지」 | 단위(Electron) | ✅ | +| 최소화했거나 앱을 숨긴 창이 새 페이지로 가도 실시간 화면이 옴(5초 0장 → 15장): 스크린캐스트가 1초 동안 아무것도 보내지 않으면 약 1초마다 캡처, 같은 그림은 다시 보내지 않고 간격을 4초까지 늘림, 새 프레임에 밀린 캡처 · 다른 문서의 캡처는 버림, 프레임이 다시 오면 멈춤 | 사용자 12-02 | `desktop/test/browser.test.js` 6개 · `browserDriver.test.js` 「최소화 …새 페이지」 | 단위(Electron) | ✅ | | 한 번도 보이지 않은 숨은 탭은 받쳐 주는 캡처도 하지 않음 | 2026-11-24 실측 | `desktop/test/browser.test.js` | 단위 | ✅ | -| 최소화된 창으로 다음 작업이 시작하면 같은 주소의 새 숨은 탭에서(캡처 없이 4초에 8장 이상), 화면에 띄워 둔 창은 그대로 | 사용자 12-02 | `browserDriver.test.js` 「begin …」 · `browser-local.test.js` 「앞 작업이 남긴 페이지 · 이 PC 에서 내려 둔 창 …」 | 단위(Electron) | ✅ | -| 다른 창에 완전히 가려진 창은 계속 그림(측정 14~15장, 받쳐 주기 불필요) | 측정 | `scratchpad/livecast/measure.mjs`(측정만) | — | ✅(측정) | -| PC 작업에 그림이 한 장도 오지 않으면 카드는 「브라우저 여는 중」 대신 「PC 화면을 받지 못하고 있어요」 — 한 번만, 빈 페이지 · 서버 브라우저는 아님 | 사용자 12-02 | `browserTabShot.test.js` 「PC 작업에 그림이 한 장도 …」 | 단위 | ✅ | -| 옛 PC 앱 안내(`where.update`): 0.2.13 이 나온 뒤에만 · 이미 그 판이면 · 판을 모르면 · 알림을 끈 설치면 없음 | 설계 | `browserWhere.test.js` | 단위 | ✅ | -| 어디서 도나: 한 작업의 선택 → 기본값 → PC 설정, 「PC 에서」라고 해도 「쓰지 않음」 · 사람이 없는 작업은 PC 로 가지 않음 | 사용자 12-02 | `browserWhere.test.js` | 단위 | ✅ | -| 기본값 「브라우저 작업 위치」 저장 · 다시 읽기 · 다른 값 400 · 「PC 우선」은 비워 둠 · 설정 화면이 보는 것(`person` · `kept` · 그 까닭 `person`) | 사용자 12-02 | `browserWhere.test.js` | 단위(로컬 DB) | ✅ | -| PC 에서 일하는 작업의 「서버에서 이어서」: 그 걸음이 바로 멈춤(버린 모델 요청 1) · PC 에 `idle` · 서버 브라우저가 같은 주소 · 모델이 까닭을 들음 · 카드 `where.asked` · 옮기는 중 두 번째는 false · 같은 카드를 다시 하면 서버(`why: 'asked'`) | 사용자 12-02 | `browser-local.test.js` 「PC 에서 일하는 작업의 「서버에서 이어서」…」 | 단위(Electron) | ✅ | -| 채팅의 말(`browser_task where: server`)이면 PC 가 켜져 있어도 서버 · 카드에 남음 | 사용자 12-02 | 「채팅에서 이 작업만 서버로 …」 | 단위(Electron) | ✅ | +| 최소화된 창에서 다음 작업이 시작하면 같은 주소의 새 숨은 탭에서 진행(캡처 없이 4초에 8장 이상), 화면에 띄워 둔 창은 그대로 | 사용자 12-02 | `browserDriver.test.js` 「begin …」 · `browser-local.test.js` 「앞 작업이 남긴 페이지 · 이 PC 에서 내려 둔 창 …」 | 단위(Electron) | ✅ | +| 다른 창에 완전히 가려진 창은 계속 그림을 그림(측정 14~15장, 받쳐 주기 불필요) | 측정 | `scratchpad/livecast/measure.mjs`(측정만) | — | ✅(측정) | +| PC 작업에 그림이 한 장도 오지 않으면 카드는 「브라우저 여는 중」 대신 「PC 화면을 받지 못하고 있어요」를 표시 — 한 번만, 빈 페이지 · 서버 브라우저는 제외 | 사용자 12-02 | `browserTabShot.test.js` 「PC 작업에 그림이 한 장도 …」 | 단위 | ✅ | +| 옛 PC 앱 안내(`where.update`): 0.2.13이 나온 뒤에만 표시 · 이미 그 판이면 · 판을 모르면 · 알림을 끈 설치면 없음 | 설계 | `browserWhere.test.js` | 단위 | ✅ | +| 어디서 도나: 개별 작업의 선택 → 기본값 → PC 설정, 「PC 에서」라고 해도 「쓰지 않음」 · 사람이 없는 작업은 PC로 가지 않음 | 사용자 12-02 | `browserWhere.test.js` | 단위 | ✅ | +| 기본값 「브라우저 작업 위치」 저장 · 다시 읽기 · 다른 값은 400 · 「PC 우선」은 비워 둠 · 설정 화면에서 보는 값(`person` · `kept` · 그 까닭 `person`) | 사용자 12-02 | `browserWhere.test.js` | 단위(로컬 DB) | ✅ | +| PC에서 일하는 작업의 「서버에서 이어서」: 그 걸음이 바로 멈춤(버린 모델 요청 1) · PC에 `idle` · 서버 브라우저가 같은 주소를 엶 · 모델이 까닭을 들음 · 카드에 `where.asked` · 옮기는 중 두 번째 요청은 false · 같은 카드에서 다시 하면 서버(`why: 'asked'`) | 사용자 12-02 | `browser-local.test.js` 「PC 에서 일하는 작업의 「서버에서 이어서」…」 | 단위(Electron) | ✅ | +| 채팅의 말(`browser_task where: server`)이면 PC가 켜져 있어도 서버 · 카드에 남음 | 사용자 12-02 | 「채팅에서 이 작업만 서버로 …」 | 단위(Electron) | ✅ | | 기본값 「늘 서버」 → 서버(`why: 'person'`), 「PC 에서」라고 한 작업만 PC, 되돌리면 PC | 사용자 12-02 | 「설정 「브라우저 작업 위치」 = 늘 서버 …」 | 단위(Electron) | ✅ | -| PC 를 기다리며 줄 선 작업(`pcLine`)의 「서버에서 바로 시작」 → 앞 작업이 PC 에서 일하는 동안 서버에서 끝남 · `pcLine` 지워짐 | 사용자 12-02 | 「PC 브라우저를 기다리며 줄 선 작업 …」 | 단위(Electron) | ✅ | +| PC를 기다리며 줄 선 작업(`pcLine`)의 「서버에서 바로 시작」 → 앞 작업이 PC에서 진행되는 동안 서버에서 끝남 · `pcLine` 지워짐 | 사용자 12-02 | 「PC 브라우저를 기다리며 줄 선 작업 …」 | 단위(Electron) | ✅ | | 없는 작업 · 남의 작업은 옮기지 않음(false) | 설계 | `browserWhere.test.js` | 단위 | ✅ | -| 390 확장 화면: 「서버에서 이어서」 → `route {taskId, to:'server'}` · 단추 다섯 개가 모두 한 줄 높이(40px) · 모두 화면 안(둘째 줄) · 옆으로 넘치지 않음 | 사용자 12-02 | F-BW-01 | feature | ✅ | -| 390 그림이 오지 않는 카드: 「PC 화면을 받지 못하고 있어요」 · 「PC 앱을 0.2.13 버전으로 올리면 진행 화면이 보여요」 · 「내려받기」 링크 · 「서버에서 이어서」, 옮길 수 없다는 답이면 그 까닭, 다시 누르면 보냄 · 확장 화면이 열리지 않음 | 사용자 12-02 | F-BW-02 | feature | ✅ | +| 390 확장 화면: 「서버에서 이어서」 → `route {taskId, to:'server'}` · 단추 다섯 개가 모두 한 줄 높이(40px) · 모두 화면 안에 표시(둘째 줄) · 옆으로 넘치지 않음 | 사용자 12-02 | F-BW-01 | feature | ✅ | +| 390 그림이 오지 않는 카드: 「PC 화면을 받지 못하고 있어요」 · 「PC 앱을 0.2.13 버전으로 올리면 진행 화면이 보여요」 · 「내려받기」 링크 · 「서버에서 이어서」, 옮길 수 없다는 답이면 그 까닭을 표시, 다시 누르면 보냄 · 확장 화면이 열리지 않음 | 사용자 12-02 | F-BW-02 | feature | ✅ | | 390 줄 선 카드(`pcLine`)의 「서버에서 바로 시작」 · 「취소」 | 사용자 12-02 | F-BW-03 | feature | ✅ | -| 390 설정 「브라우저 작업 위치」: 「PC 우선」 → 「늘 서버」 → `PUT {where:'server'}` → 줄이 「「늘 서버」로 정했어요」, PC 의 설정 칸은 없음, 저장할 곳이 없으면(`kept: false`) 칸이 잠기고 까닭 | 사용자 12-02 | F-BW-04 · F-LB-03 | feature | ✅ | -| 카드의 「서버 브라우저」(서버를 고른 까닭 `asked` · `person`), PC 가 없어 서버인 작업은 표시 없음 | 설계 | F-BW-05 | feature | ✅ | -| 화면이 잠들거나 잠긴 맥 · 다른 데스크톱 공간 · Windows | 설계 | — | — | ✗(이 맥에서 화면을 재우거나 잠글 수 없어 재지 못함 — 캡처가 안 되면 「받지 못하고 있어요」와 「서버에서 이어서」) | -| 운영 라우터 모델이 「서버에서 해 줘」를 `where: 'server'` 로 읽는지 | 사용자 12-02 | — | — | ✗(실제 모델로 확인 — 이번 시험은 가짜 모델) | -| 운영 DB 에 `076_browser_where.sql` · 사용자 PC 에 0.2.13 | — | — | — | ✗(승인 뒤) | +| 390 설정 「브라우저 작업 위치」: 「PC 우선」 → 「늘 서버」 → `PUT {where:'server'}` → 줄에 「「늘 서버」로 정했어요」를 표시, PC의 설정 칸은 없음, 저장할 곳이 없으면(`kept: false`) 칸이 잠기고 까닭을 표시 | 사용자 12-02 | F-BW-04 · F-LB-03 | feature | ✅ | +| 카드의 「서버 브라우저」(서버를 고른 까닭 `asked` · `person`), PC가 없어 서버에서 도는 작업은 표시 없음 | 설계 | F-BW-05 | feature | ✅ | +| 화면이 잠들거나 잠긴 맥 · 다른 데스크톱 공간 · Windows | 설계 | — | — | ✗(이 맥에서 화면을 재우거나 잠글 수 없어 측정하지 못함 — 캡처가 안 되면 「받지 못하고 있어요」와 「서버에서 이어서」를 표시) | +| 운영 라우터 모델이 「서버에서 해 줘」를 `where: 'server'`로 읽는지 | 사용자 12-02 | — | — | ✗(실제 모델로 확인 — 이번 시험은 가짜 모델) | +| 운영 DB에 `076_browser_where.sql` · 사용자 PC에 0.2.13 | — | — | — | ✗(승인 뒤) | diff --git a/openspec/specs/browser-handoff/spec.md b/openspec/specs/browser-handoff/spec.md index 5a0d9b81..549f318e 100644 --- a/openspec/specs/browser-handoff/spec.md +++ b/openspec/specs/browser-handoff/spec.md @@ -265,12 +265,12 @@ 시스템은 브라우저 작업이 브라우저를 받을 때, 그 작업의 사람이 이어 둔 데스크톱 앱(0.2.3 이상, `caps.browser`) 중 켜져 있고 그 PC 의 설정이 이 작업을 받는 것이 있으면 그 PC 의 브라우저에서 돌려야 한다(SHALL — 받는 PC 는 아래 「PC 마다 동의한 작업만 그 PC 로 간다」). 아니면 지금처럼 서버 브라우저에서 돈다(휴대폰만 쓸 때, 0.2.2 이하의 데스크톱, 그 PC 가 받지 않음). 근거는 사용자 질문 「이 부분도 일렉트론 버전에서는 로컬 브라우저를 이용하는게 더 효율적이지 않을까?」와 「그래도 순수 모바일에서는 이 작업이 가능해야하니」(2026-11-24)다. - 에이전트 루프(계획 · 모델 · 판정 · 보관함 · 스킬 · 카드 · 감시 · 걸음마다 한도 · 「다시 시도」 · 「그만두기」)는 서버에 하나다. 바뀌는 것은 페이지를 움직이는 드라이버뿐이다 — 서버의 Chromium, 또는 그 사람 데스크톱의 링크 너머 브라우저. 두 드라이버는 같은 동작(열기 · 읽기 · 요소 이름 · 누르기 · 입력 · 키 · 스크롤 · 보관함 값 · 그림 · 낱말 · 멈추기 · 파일 넣기 · 직접 제어 · 페이지의 대화 상자)을 같게 해야 한다(SHALL). -- 어디서 돌지는 작업이 브라우저를 받을 때 한 번 정한다. PC 의 브라우저가 30초 안에 열리지 않으면 그 작업은 서버 브라우저가 맡고 카드에 그렇게 남긴다. 서버 브라우저도 열리지 않으면 카드는 「브라우저를 열지 못해 작업을 시작하지 못했어요 …」로 실패로 끝나고 줄 선 다음 작업이 시작해야 한다(SHALL) — 「진행 중」으로 남거나 줄이 멈추지 않는다. 시작한 작업은 저절로 다른 곳으로 옮기지 않는다(MUST NOT — 아래 「PC 가 꺼지면 …」). 사람이 고르면 옮긴다(아래 「서버 브라우저를 고르기」). +- 어디서 돌지는 작업이 브라우저를 받을 때 한 번 정한다. PC의 브라우저가 30초 안에 열리지 않으면 그 작업은 서버 브라우저가 맡고 카드에 그렇게 남긴다. 서버 브라우저도 열리지 않으면 카드는 「브라우저를 열지 못해 작업을 시작하지 못했어요 …」를 표시하며 실패로 끝나고 줄 선 다음 작업이 시작해야 한다(SHALL) — 「진행 중」으로 남거나 줄이 멈추지 않는다. 시작한 작업은 저절로 다른 곳으로 옮기지 않는다(MUST NOT — 아래 「PC 가 꺼지면 …」). 사람이 고르면 옮긴다(아래 「서버 브라우저를 고르기」). - PC 의 브라우저는 데스크톱 앱 안의 숨은 창이고, 사람마다의 세션에 로그인이 남는다(그 PC 를 떠나지 않는다). 「이 PC에서 보기」를 누르면 그 창이 PC 에 보이고, 사람은 그 창에서 직접 할 수 있다(그 PC 에서의 직접 제어). 닫으면 다시 숨는다. 웹 · 휴대폰의 카드에는 지금처럼 실시간 화면(1초에 3장까지, 1024×640)이 온다. - 데스크톱은 서버가 보낸 코드를 돌리지 않는다(MUST NOT). 이름 붙은 동작만 자기 코드로 하고, 그 데스크톱에 로그인한 사람의 작업만 받는다. 페이지는 웹 주소(http · https)로만 가고 그 PC 의 파일은 열지 않는다. 사이트는 카메라 · 마이크 · 화면 · 위치 · 알림 · 클립보드 읽기를 받지 못한다. - PC 에서 받은 파일은 서버 브라우저에서 받은 것과 같은 파일 카드로 올라온다. -- 카드: PC 에서 도는 작업은 화면 왼쪽 위에 「내 PC · <기기 이름>」, 확장 화면과 사람을 기다릴 때의 단추에 「이 PC에서 보기」가 있다. 서버에서만 도는 작업에는 표시가 없다(사람이 서버를 골랐으면 「서버 브라우저」 — 아래 「서버 브라우저를 고르기」). 확장 화면의 단추줄에서 손으로 하는 자리에는 「서버에서 이어서」(PC 가 꺼졌을 때) · 「직접 제어」 · 「제어 돌려주기」(직접 제어 중) 가운데 하나만 있다(MUST — 2026-11-25 검토: 「직접 제어」와 「제어 돌려주기」가 함께 보였다). PC 에서 일하는 동안에는 그 밖에 옮기기 단추 「서버에서 이어서」가 있다. -- 단추줄은 휴대폰 폭(390)에서도 단추 글자가 두 줄로 깨지지 않고, 한 줄에 다 들어가지 않으면 가운데 맞춘 둘째 줄로 넘어가 모든 단추가 화면 안에 보여야 한다(SHALL — 2026-12-02 휴대폰 화면: 「계획 / 2/6」 · 「작업 취 / 소」). +- 카드: PC에서 도는 작업은 화면 왼쪽 위에 「내 PC · <기기 이름>」, 확장 화면과 사람을 기다릴 때의 단추에 「이 PC에서 보기」가 있다. 서버에서만 도는 작업에는 표시가 없다(사람이 서버를 골랐으면 「서버 브라우저」 — 아래 「서버 브라우저를 고르기」). 확장 화면의 단추줄에서 직접 조작하는 자리에는 「서버에서 이어서」(PC가 꺼졌을 때) · 「직접 제어」 · 「제어 돌려주기」(직접 제어 중) 가운데 하나만 있다(MUST — 2026-11-25 검토: 「직접 제어」와 「제어 돌려주기」가 함께 보였다). PC에서 일하는 동안에는 그 밖에 옮기기 단추 「서버에서 이어서」가 있다. +- 단추줄은 휴대폰 폭(390)에서도 단추 글자가 두 줄로 갈라지지 않고, 한 줄에 다 들어가지 않으면 가운데로 맞춘 둘째 줄로 넘어가 모든 단추가 화면 안에 보여야 한다(SHALL — 2026-12-02 휴대폰 화면: 「계획 / 2/6」 · 「작업 취 / 소」). #### Scenario: 데스크톱이 켜져 있다 - **GIVEN** 윤태호의 맥에서 데스크톱 앱 0.2.3 이 켜져 있다(「테스트 맥」) @@ -289,7 +289,7 @@ #### Scenario: 확장 화면의 단추줄 - **GIVEN** PC 에서 도는 작업의 카드를 휴대폰에서 확장했다 -- **THEN** 손으로 하는 자리에는 「직접 제어」만 있고 「제어 돌려주기」와 PC 가 꺼졌을 때의 「서버에서 이어서」는 없다 +- **THEN** 직접 조작하는 자리에는 「직접 제어」만 있고 「제어 돌려주기」와 PC가 꺼졌을 때의 「서버에서 이어서」는 없다 - **WHEN** 「직접 제어」를 누른다 - **THEN** 「제어 돌려주기」만 있고, 누르면 다시 「직접 제어」만 있다(`e2e/tests/feature/local-browser-card.spec.js` F-LB-01) @@ -303,7 +303,7 @@ - **THEN** 둘 다 같은 결과다(`server/test/browserDriver.test.js`) ### Requirement: PC 마다 동의한 작업만 그 PC 로 간다 -시스템은 PC 마다 그 PC 의 데스크톱 앱에서 정한 「브라우저 작업은 이 PC에서」 — 「내가 시킨 작업만」(`own`, 기본) · 「단계 · 예약 작업까지 모두」(`all`) · 「쓰지 않음」(`off`) — 를 따라야 한다(SHALL). 이 설정은 그 PC 의 앱이 실행 설정과 함께 저장하고 링크로 알린다(서버에는 저장하지 않는다). 웹 · 휴대폰의 설정은 PC 마다 무엇으로 정했는지와 지금 어디서 도는지를 읽기만 하고, PC 의 설정을 바꾸는 칸을 두지 않는다(MUST NOT — 바꾸기는 그 PC 의 앱에서). 사람의 기본값 「브라우저 작업 위치」는 PC 에서 빼기만 하는 설정이라 어느 기기에서나 바꾼다(아래 「서버 브라우저를 고르기」). +시스템은 PC마다 그 PC의 데스크톱 앱에서 정한 「브라우저 작업은 이 PC에서」 — 「내가 시킨 작업만」(`own`, 기본) · 「단계 · 예약 작업까지 모두」(`all`) · 「쓰지 않음」(`off`) — 를 따라야 한다(SHALL). 이 설정은 그 PC의 앱이 실행 설정과 함께 저장하고 링크로 알린다(서버에는 저장하지 않는다). 웹 · 휴대폰의 설정에서는 PC마다 무엇으로 정했는지와 지금 어디서 도는지를 읽기만 하고, PC의 설정을 바꾸는 칸을 두지 않는다(MUST NOT — 바꾸기는 그 PC의 앱에서). 사람의 기본값 「브라우저 작업 위치」는 PC에서 일을 빼기만 하는 설정이라 어느 기기에서나 바꾼다(아래 「서버 브라우저를 고르기」). - 그 PC 에서 「이 컴퓨터에서 단계 실행」을 껐으면(`enabled: false`) 브라우저 설정이 무엇이든 그 PC 로 브라우저 작업을 보내지 않는다(MUST NOT). - 그 사람이 자기 채팅에서 시킨 작업만 기본으로 PC 로 간다. 사람이 없는 작업(프로세스 단계 · 예약 · MCP · 다른 사람이 시킨 것 · 회사가 정한 루틴을 묻지 않고 하는 자동 실행)은 그 PC 가 명시적으로 「단계 · 예약 작업까지 모두」일 때만 간다(정하지 않았거나 모르는 값이면 서버). @@ -338,7 +338,7 @@ #### Scenario: 웹은 읽기만 - **WHEN** 휴대폰에서 설정 › 계정 › 내 컴퓨터의 에이전트를 연다 -- **THEN** 「내가 시킨 브라우저 작업」 · 「단계 · 예약 브라우저 작업」이 지금 어디서 도는지와 PC 마다의 설정(「… — 바꾸기는 그 PC 의 앱에서」)이 보이고, PC 의 설정을 바꾸는 칸은 없다(있는 칸은 내 기본값 「브라우저 작업 위치」 하나 — F-LB-03) +- **THEN** 「내가 시킨 브라우저 작업」 · 「단계 · 예약 브라우저 작업」이 지금 어디서 도는지와 PC별 설정(「… — 바꾸기는 그 PC 의 앱에서」)이 보이고, PC의 설정을 바꾸는 칸은 없다(있는 칸은 내 기본값 「브라우저 작업 위치」 하나 — F-LB-03) - **AND** 앱에서 바꾸면 서버가 곧바로 그대로 따르고, 앱의 다른 칸(실행 전에 묻기)을 바꿔도 그 설정은 남는다 ### Requirement: PC 의 브라우저는 작업이 쥔 동안만 일하고, 끝이 있다 @@ -417,35 +417,35 @@ - **THEN** 그 그림은 서버로 가지 않고, 다음에 그린 프레임부터 간다. 그사이 다른 페이지로 간 탭의 재시작 첫 프레임도 보내지 않는다(`desktop/test/browser.test.js` 「실시간 화면은 그 탭의 지금 문서의 프레임만 …」 외 5개) ### Requirement: PC 화면이 오지 않을 때에도 진행 화면이 이어진다 -시스템은 PC 에서 일하는 작업의 실시간 화면이 작업 내내 이어지도록 해야 한다(SHALL). 근거는 사용자 지시 「Pc 에 연결된 브라우저 사용시 진행상태가 보이지 않음. 화면전환된 송출을 최적화하여 연결할 방법이 있나?」(2026-12-02)와 그 휴대폰 화면이다. 카드는 몇 분 동안 「브라우저 여는 중」에 머물렀다. 원인은 송출량이 아니었다. 송출은 이미 바뀐 화면만, 1초에 3장 이하로, 1024×640 JPEG 으로 보낸다. 원인은 그릴 그림이 생기지 않은 것이다. 이 PC 에 보였다가 최소화된 창이나 앱을 숨긴(⌘H) 창은 보이던 페이지는 계속 그리지만, 새 문서(다음 페이지, 다음 작업)는 그리지 않는다. 2026-12-02 측정에서 5초 동안의 실시간 프레임은 다음과 같았다: 한 번도 보이지 않은 숨은 탭 15, 보이는 창 15, 다른 창에 완전히 가려진 창 14~15, 최소화 · 앱 숨김에서 같은 페이지 14~15, 새 페이지 0, 그런 창에서 시작한 다음 작업 0. +시스템은 PC에서 일하는 작업의 실시간 화면이 작업 내내 이어지도록 해야 한다(SHALL). 근거는 사용자 지시 「Pc 에 연결된 브라우저 사용시 진행상태가 보이지 않음. 화면전환된 송출을 최적화하여 연결할 방법이 있나?」(2026-12-02)와 그 휴대폰 화면이다. 카드는 몇 분 동안 「브라우저 여는 중」에 머물렀다. 원인은 송출량이 아니었다. 송출은 이미 바뀐 화면만 1초에 3장 이하로, 1024×640 JPEG으로 보낸다. 원인은 그릴 그림이 생기지 않은 것이다. 이 PC에 보였다가 최소화된 창이나 앱을 숨긴(⌘H) 창은 보이던 페이지는 계속 그리지만, 새 문서(다음 페이지, 다음 작업)는 그리지 않는다. 2026-12-02 측정에서 5초 동안의 실시간 프레임 수는 다음과 같았다: 한 번도 보이지 않은 숨은 탭 15, 보이는 창 15, 다른 창에 완전히 가려진 창 14~15, 최소화 · 앱 숨김에서 같은 페이지 14~15, 새 페이지 0, 그런 창에서 시작한 다음 작업 0. -- 작업 시작(데스크톱 0.2.13): 이 PC 에 보였던 창이 지금 최소화되었거나 숨어 있으면(아무도 보고 있지 않으면), 그 작업은 같은 주소의 새 숨은 탭에서 한다. 사람이 「이 PC에서 보기」 창을 닫았을 때와 같다. 소리를 끄고, 서버에 `hidden` 을 알린다. 사람이 화면에 띄워 둔 창은 그대로 둔다(MUST NOT 바꾸지 않는다). -- 받쳐 주는 캡처(데스크톱 0.2.13): 작업이 브라우저를 쥔 동안, 이 PC 에 보였던 탭의 스크린캐스트가 1초쯤 아무것도 보내지 않으면 약 1초마다 그 탭을 캡처해 실시간 프레임으로 보낸다. - - 지금 문서의 그림만 보낸다. +- 작업 시작(데스크톱 0.2.13): 이 PC에 보였던 창이 지금 최소화되었거나 숨어 있으면(아무도 보고 있지 않으면), 그 작업은 같은 주소의 새 숨은 탭에서 한다. 사람이 「이 PC에서 보기」 창을 닫았을 때와 같다. 소리를 끄고, 서버에 `hidden`을 알린다. 사람이 화면에 띄워 둔 창은 그대로 둔다(MUST NOT 바꾸지 않는다). +- 받쳐 주는 캡처(데스크톱 0.2.13): 작업이 브라우저를 사용하는 동안, 이 PC에 보였던 탭의 스크린캐스트가 1초쯤 아무것도 보내지 않으면 약 1초마다 그 탭을 캡처해 실시간 프레임으로 보낸다. + - 현재 문서의 그림만 보낸다. - 직전에 보낸 것과 같은 그림은 다시 보내지 않고, 그동안은 캡처 간격을 4초까지 늘린다. - 캡처하는 사이에 스크린캐스트의 새 프레임이 나가면 그 캡처는 버린다. - 스크린캐스트가 다시 오면 캡처를 멈춘다. - 한 번도 보이지 않은 숨은 탭은 캡처하지 않는다(MUST NOT — 그런 탭을 캡처하면 그 뒤로 그리지 않았다, 2026-11-24). - 최소화된 창에서 새 페이지로 간 경우, 측정에서는 캡처 한 번으로 창이 다시 그리기 시작해 스크린캐스트가 이어받았다(5초에 15장). -- 서버: PC 에서 일하는 작업에 그림이 한 장도 오지 않은 채 웹 페이지의 그림을 얻지 못하면, 카드는 「브라우저 여는 중」 대신 「PC 화면을 받지 못하고 있어요 — 작업은 이어서 해요」(`noDraw`)를 한 번 보낸다. 빈 페이지에서는 아직 말하지 않고, 서버 브라우저에서는 말하지 않는다. 0.2.13 전 데스크톱에서도 그렇다. -- 카드: 그림이 오지 않는 자리에 「서버에서 이어서」를 둔다(위 「서버 브라우저를 고르기」). PC 앱이 0.2.13 보다 오래되었고 0.2.13 이상이 나와 있으면 「PC 앱을 <판> 버전으로 올리면 진행 화면이 보여요」와 「내려받기」를 함께 보인다(`where.update`). 그 판이 아직 나오지 않았거나 새 판 알림을 끈 설치에서는 보이지 않는다(MUST NOT). -- 재지 못한 것: 화면이 잠들거나 잠긴 맥, 다른 데스크톱 공간 · 전체 화면 앱 뒤의 창, Windows PC. 받쳐 주는 캡처는 창의 상태가 아니라 스크린캐스트가 조용한 것을 보고 시작하므로 이런 경우에도 캡처가 되면 화면이 온다. 캡처가 안 되면 카드는 위의 말과 「서버에서 이어서」를 보인다. +- 서버: PC에서 일하는 작업에 그림이 한 장도 오지 않은 채 웹 페이지의 그림을 얻지 못하면, 카드는 「브라우저 여는 중」 대신 「PC 화면을 받지 못하고 있어요 — 작업은 이어서 해요」(`noDraw`)를 한 번 보낸다. 빈 페이지에서는 아직 알리지 않고, 서버 브라우저에서는 알리지 않는다. 0.2.13 이전 데스크톱에서도 그렇다. +- 카드: 그림이 오지 않는 자리에 「서버에서 이어서」를 둔다(위 「서버 브라우저를 고르기」). PC 앱이 0.2.13보다 오래되었고 0.2.13 이상이 나와 있으면 「PC 앱을 <판> 버전으로 올리면 진행 화면이 보여요」와 「내려받기」를 함께 보여 준다(`where.update`). 그 판이 아직 나오지 않았거나 새 판 알림을 끈 설치에서는 보여 주지 않는다(MUST NOT). +- 측정하지 못한 것: 화면이 잠들거나 잠긴 맥, 다른 데스크톱 공간 · 전체 화면 앱 뒤의 창, Windows PC. 받쳐 주는 캡처는 창의 상태가 아니라 스크린캐스트가 아무것도 보내지 않는 것을 보고 시작하므로 이런 경우에도 캡처가 되면 화면이 온다. 캡처가 안 되면 카드는 위의 말과 「서버에서 이어서」를 보여 준다. #### Scenario: 최소화된 창에서 다음 페이지로 간다 - **GIVEN** 「테스트 맥」에서 작업의 창을 「이 PC에서 보기」로 본 뒤 최소화했다 -- **WHEN** 작업이 다른 페이지(250ms 마다 바뀌는 시험 페이지)로 간다 -- **THEN** 실시간 화면이 4초에 3장 이상 오고, 모두 지금 페이지의 그림이며 같은 그림이 거듭 오지 않는다(`server/test/browserDriver.test.js`) +- **WHEN** 작업이 다른 페이지(250ms마다 바뀌는 시험 페이지)로 간다 +- **THEN** 실시간 화면이 4초에 3장 이상 오고, 모두 현재 페이지의 그림이며 같은 그림이 거듭 오지 않는다(`server/test/browserDriver.test.js`) - **AND** 앱을 숨긴(⌘H) 경우도 같다(5초에 15장 — 측정) -#### Scenario: 최소화된 창으로 다음 작업이 시작한다 +#### Scenario: 최소화된 창에서 다음 작업이 시작한다 - **GIVEN** 앞 작업에서 「이 PC에서 보기」로 본 창을 최소화해 두었다 - **WHEN** 휴대폰에서 다음 작업을 시킨다 -- **THEN** 그 작업은 새 숨은 탭에서 하고, 실시간 화면이 4초에 8장 이상 온다(캡처 없이). 이 PC 의 로그에 「was shown on this PC and nobody sees it now … the task goes on in a fresh hidden tab」(`browserDriver.test.js` · `browser-local.test.js`) +- **THEN** 그 작업은 새 숨은 탭에서 하고, 실시간 화면이 4초에 8장 이상 온다(캡처 없이). 이 PC의 로그에 「was shown on this PC and nobody sees it now … the task goes on in a fresh hidden tab」가 남는다(`browserDriver.test.js` · `browser-local.test.js`) #### Scenario: 그림이 한 장도 오지 않는 옛 PC 앱 -- **GIVEN** 윤태호의 맥은 0.2.10 이고 0.2.13 이 나와 있다 +- **GIVEN** 윤태호의 맥은 0.2.10이고 0.2.13이 나와 있다 - **WHEN** 그 맥에서 일하는 작업이 그림을 한 장도 보내지 못한다 -- **THEN** 카드는 「PC 화면을 받지 못하고 있어요 — 작업은 이어서 해요」, 「PC 앱을 0.2.13 버전으로 올리면 진행 화면이 보여요」 · 「내려받기」, 「서버에서 이어서」를 보인다(`browserTabShot.test.js` · F-BW-02) +- **THEN** 카드는 「PC 화면을 받지 못하고 있어요 — 작업은 이어서 해요」, 「PC 앱을 0.2.13 버전으로 올리면 진행 화면이 보여요」 · 「내려받기」, 「서버에서 이어서」를 보여 준다(`browserTabShot.test.js` · F-BW-02) ### Requirement: PC 의 브라우저는 Lite 앱과 그 로그인 주소를 열지 않는다 시스템은 서버의 에이전트가 모는 PC 의 브라우저가 그 데스크톱 앱이 연결한 Lite 서버의 주소(그 출처 — 이 PC 에 있는 서버면 같은 포트의 이 PC 의 다른 이름 · 주소도)와 그 서버의 로그인(Supabase) 주소를 열거나 그리로 요청을 보내지 않게 해야 한다(MUST NOT, 데스크톱 0.2.6). 에이전트의 열기, 그리로 보내는 사이트, 페이지의 링크 · 새 창 · 프레임 · 폼, 페이지의 요청(fetch · 그림 · sendBeacon · 소켓 · 서비스 워커의 fetch)이 모두 그렇고, 「이 PC에서 보기」로 사람이 넘겨받은 창에서도 같다. `about:blank` 와 다른 사이트(Google 계정 화면을 포함)는 그대로 연다. @@ -483,43 +483,43 @@ - **THEN** 작업은 서버 브라우저에서 돈다(`where.why: 'lite-page'`) — 다른 시작 주소는 지금처럼 그 PC 에서(`server/test/browserRoute.test.js`) ### Requirement: 서버 브라우저를 고르기 -시스템은 사람의 PC 가 켜져 있어도 사람이 고르면 브라우저 작업을 서버 브라우저에서 돌려야 한다(SHALL). 근거는 사용자 지시 「pc 에 연결된 브라우저에서 동작하길 원치 않고 서버 파드에서 돌리고 싶은 경우도 지원」(2026-12-02)이다. 고르는 길은 넷이다. +시스템은 사람의 PC가 켜져 있어도 사람이 고르면 브라우저 작업을 서버 브라우저에서 돌려야 한다(SHALL). 근거는 사용자 지시 「pc 에 연결된 브라우저에서 동작하길 원치 않고 서버 파드에서 돌리고 싶은 경우도 지원」(2026-12-02)이다. 고르는 방법은 넷이다. -- 기본값: 설정 › 계정 › 내 컴퓨터의 에이전트 「브라우저 작업 위치」 — 「PC 우선」(기본, 지금까지와 같음) · 「늘 서버」. 그 사람의 것으로 서버에 저장하고(`pro_profile.browser_where`), 웹 · 휴대폰 · 앱 어디서나 바꾼다. 「늘 서버」면 그 사람의 작업은 PC 가 켜져 있어도 서버 브라우저에서 돈다(`where.why: 'person'`). -- 한 작업의 말: 채팅에서 그 작업을 서버에서 하라고 하면(「서버에서 해 줘」) 그 작업만 서버에서(`where.why: 'asked'`), PC 에서 하라고 하면 기본값이 「늘 서버」여도 그 작업은 PC 에서 돈다. 말을 읽는 것은 모델이다(낱말 규칙이 아니다). -- 일하는 카드의 「서버에서 이어서」: PC 에서 일하는 작업의 카드(그림이 오지 않는 자리와 확장 화면)에서 누르면 하던 걸음을 바로 멈추고(그 걸음은 작업의 한 번으로 세지 않는다), PC 의 브라우저를 놓고(실시간 화면을 멈추고 페이지를 비움), 서버 브라우저가 마지막 주소를 열어 같은 작업을 잇는다. 모델에게 「사람이 PC 에서 서버로 옮겼고, PC 의 로그인은 이 브라우저에 없다」고 알린다. 카드는 「서버 브라우저에서 이어서」. 사람을 기다리는 작업 · 이미 옮기는 중인 작업 · 서버에서 도는 작업은 옮기지 않고(답 `ok: false`), 화면은 「지금은 옮길 수 없어요 — …」라고 말한다. -- 줄 선 카드의 「서버에서 바로 시작」: PC 의 브라우저를 기다리며 줄 선 작업(「PC 브라우저는 작업을 하나씩 해요 …」)은 그 단추로 자리가 나는 대로 서버 브라우저에서 시작한다. +- 기본값: 설정 › 계정 › 내 컴퓨터의 에이전트 「브라우저 작업 위치」 — 「PC 우선」(기본, 지금까지와 같음) · 「늘 서버」. 그 사람의 설정으로 서버에 저장하고(`pro_profile.browser_where`), 웹 · 휴대폰 · 앱 어디서나 바꾼다. 「늘 서버」면 그 사람의 작업은 PC가 켜져 있어도 서버 브라우저에서 돈다(`where.why: 'person'`). +- 개별 작업에 대한 말: 채팅에서 그 작업을 서버에서 하라고 하면(「서버에서 해 줘」) 그 작업만 서버에서 돌고(`where.why: 'asked'`), PC에서 하라고 하면 기본값이 「늘 서버」여도 그 작업은 PC에서 돈다. 말을 읽는 것은 모델이다(낱말 규칙이 아니다). +- 작업 중인 카드의 「서버에서 이어서」: PC에서 일하는 작업의 카드(그림이 오지 않는 자리와 확장 화면)에서 누르면 하던 걸음을 바로 멈추고(그 걸음은 작업의 한 번으로 세지 않는다), PC의 브라우저를 놓고(실시간 화면을 멈추고 페이지를 비움), 서버 브라우저가 마지막 주소를 열어 같은 작업을 잇는다. 모델에게 「사람이 PC 에서 서버로 옮겼고, PC 의 로그인은 이 브라우저에 없다」고 알린다. 카드는 「서버 브라우저에서 이어서」를 표시한다. 사람을 기다리는 작업 · 이미 옮기는 중인 작업 · 서버에서 도는 작업은 옮기지 않고(답 `ok: false`), 화면은 「지금은 옮길 수 없어요 — …」라고 알린다. +- 줄 선 카드의 「서버에서 바로 시작」: PC의 브라우저를 기다리며 줄 선 작업(「PC 브라우저는 작업을 하나씩 해요 …」)은 그 단추를 누르면 자리가 나는 대로 서버 브라우저에서 시작한다. 규칙: -- 한 작업의 선택이 먼저, 그다음 기본값, 그다음 PC 의 설정이다. 어떤 선택도 PC 의 설정이 막은 작업을 그 PC 로 보내지 않는다(MUST NOT — 「PC 에서 해 줘」라고 해도 「쓰지 않음」인 PC 로는 가지 않는다). +- 개별 작업의 선택이 먼저, 그다음 기본값, 그다음 PC의 설정이다. 어떤 선택도 PC의 설정이 막은 작업을 그 PC로 보내지 않는다(MUST NOT — 「PC 에서 해 줘」라고 해도 「쓰지 않음」인 PC로는 가지 않는다). - 서버로 옮긴(또는 서버를 고른) 작업은 같은 카드에서 다시 하거나 이어서 해도 서버에서 돈다. -- 사람이 서버를 고른 작업의 카드 왼쪽 위에는 「서버 브라우저」라고 쓴다. PC 가 없어 서버에서 도는 작업에는 표시가 없다. -- 기본값을 저장할 곳(`sql/076_browser_where.sql`)이 없는 설치에서는 모두 「PC 우선」으로 돌고, 바꾸기는 503(`no_column`)으로 거절되며 설정 칸이 잠겨 「이 설정을 저장할 곳이 아직 없어요 — 관리자에게 알려 주세요」라고 말한다(MUST NOT — 저장되지 않은 것을 저장했다고 하지 않는다). +- 사람이 서버를 고른 작업의 카드 왼쪽 위에는 「서버 브라우저」라고 쓴다. PC가 없어 서버에서 도는 작업에는 표시가 없다. +- 기본값을 저장할 곳(`sql/076_browser_where.sql`)이 없는 설치에서는 모두 「PC 우선」으로 돌고, 변경은 503(`no_column`)으로 거절되며 설정 칸이 잠겨 「이 설정을 저장할 곳이 아직 없어요 — 관리자에게 알려 주세요」라고 알린다(MUST NOT — 저장되지 않은 것을 저장했다고 하지 않는다). -#### Scenario: 일하는 PC 작업을 서버로 -- **GIVEN** 윤태호의 「테스트 맥」에서 브라우저 작업이 가상 상점의 한 페이지에서 일하고 있다 +#### Scenario: 진행 중인 PC 작업을 서버로 +- **GIVEN** 윤태호의 「테스트 맥」에서 브라우저 작업이 가상 상점의 한 페이지에서 진행 중이다 - **WHEN** 휴대폰의 카드에서 「서버에서 이어서」를 누른다 -- **THEN** 그 걸음이 바로 멈추고 PC 의 브라우저가 놓이며, 서버 브라우저가 같은 주소를 열어 작업이 끝까지 간다. 카드는 「서버 브라우저에서 이어서」 -- **AND** 같은 카드를 다시 하면 서버 브라우저에서 돈다 +- **THEN** 그 걸음이 바로 멈추고 PC의 브라우저가 놓이며, 서버 브라우저가 같은 주소를 열어 작업이 끝까지 이어진다. 카드는 「서버 브라우저에서 이어서」를 표시한다 +- **AND** 같은 카드에서 다시 하면 서버 브라우저에서 돈다 - **AND** 옮기는 중에 한 번 더 누르면 다시 옮기지 않는다(`server/test/browser-local.test.js`) #### Scenario: 늘 서버 - **WHEN** 윤태호가 「브라우저 작업 위치」를 휴대폰에서 「늘 서버」로 바꾼다 -- **THEN** 「테스트 맥」이 켜져 있어도 다음 작업은 서버 브라우저에서 돌고, 설정에 「서버 브라우저에서 해요 — 「브라우저 작업 위치」를 「늘 서버」로 정했어요 …」, 카드에 「서버 브라우저」 +- **THEN** 「테스트 맥」이 켜져 있어도 다음 작업은 서버 브라우저에서 돌고, 설정에 「서버 브라우저에서 해요 — 「브라우저 작업 위치」를 「늘 서버」로 정했어요 …」, 카드에 「서버 브라우저」가 표시된다 - **AND** 「PC 에서 해 줘」라고 한 작업만 「테스트 맥」에서 돈다 #### Scenario: 이 작업만 서버에서 - **WHEN** 「테스트 맥」이 켜져 있고 기본값이 「PC 우선」인데 채팅에서 「서버에서 가상 상점 열어 줘」라고 한다 -- **THEN** 그 작업만 서버 브라우저에서 돌고 카드에 「서버 브라우저」 +- **THEN** 그 작업만 서버 브라우저에서 돌고 카드에 「서버 브라우저」가 표시된다 #### Scenario: 줄 선 작업을 서버에서 바로 -- **GIVEN** 한 작업이 「테스트 맥」에서 일하고, 다음 작업이 그 PC 를 기다리며 줄 섰다 +- **GIVEN** 한 작업이 「테스트 맥」에서 진행 중이고, 다음 작업이 그 PC를 기다리며 줄 섰다 - **WHEN** 줄 선 카드의 「서버에서 바로 시작」을 누른다 -- **THEN** 앞 작업이 PC 에서 일하는 동안 그 작업이 서버 브라우저에서 시작해 끝난다 +- **THEN** 앞 작업이 PC에서 진행되는 동안 그 작업이 서버 브라우저에서 시작해 끝난다 #### Scenario: 저장할 곳이 없는 설치 -- **WHEN** `pro_profile.browser_where` 가 없는 설치에서 「브라우저 작업 위치」를 연다 -- **THEN** 칸이 잠겨 있고 그 까닭을 말하며, 작업은 「PC 우선」으로 돈다 +- **WHEN** `pro_profile.browser_where`가 없는 설치에서 「브라우저 작업 위치」를 연다 +- **THEN** 칸이 잠겨 있고 그 까닭을 알려 주며, 작업은 「PC 우선」으로 돈다 ### Requirement: PC 가 꺼지면 작업은 멈추고, 어디서 이을지는 사람이 고른다 시스템은 PC 에서 돌던 작업의 데스크톱 링크가 끊기면, 하던 걸음을 바로 끝내고 작업을 멈춰 카드에 `need: 'offline'` 과 이유를 보여야 한다(SHALL). 알약은 「PC 연결 끊김 · <사이트>」, 이유는 「「<기기>」의 PC 앱 연결이 끊겨 브라우저 작업을 멈췄어요. 「서버에서 이어서」를 누르면 …」, 단추는 「서버에서 이어서」 · 「PC가 다시 켜지면」 · 「멈추기」다. 다른 곳으로 저절로 옮기지 않는다(MUST NOT). From 817ab78e1694f09aa540fcf2982c7699c8932ba9 Mon Sep 17 00:00:00 2001 From: jinyoung Date: Wed, 2 Dec 2026 12:31:44 +0900 Subject: [PATCH 05/12] =?UTF-8?q?fix(browser):=20=EB=8F=85=EB=A6=BD=20?= =?UTF-8?q?=EA=B2=80=ED=86=A0=20=EB=B0=98=EC=98=81=20=E2=80=94=20=EC=98=AE?= =?UTF-8?q?=EA=B8=B0=EA=B8=B0=EB=8A=94=20=ED=95=98=EB=8D=98=20=EB=8F=99?= =?UTF-8?q?=EC=9E=91=EC=9D=B4=20=EB=81=9D=EB=82=9C=20=EB=92=A4=20=C2=B7=20?= =?UTF-8?q?=EC=84=9C=EB=B2=84=20=EB=B8=8C=EB=9D=BC=EC=9A=B0=EC=A0=80=20?= =?UTF-8?q?=EB=A8=BC=EC=A0=80=20=EC=97=B4=EA=B3=A0=20PC=20=EB=A5=BC=20?= =?UTF-8?q?=EB=86=93=EC=9D=8C=20=C2=B7=20=EC=97=B4=20=EC=97=86=EC=9D=8C=20?= =?UTF-8?q?=ED=8C=90=EB=8B=A8=EC=9D=80=201=EB=B6=84=20=C2=B7=20=EB=81=9D?= =?UTF-8?q?=EB=82=98=20=EA=B0=80=EB=8A=94=20=EC=9E=91=EC=97=85=20=C2=B7=20?= =?UTF-8?q?=EC=A7=80=EC=9D=80=20=ED=84=B4=EC=9D=98=20where=20=C2=B7=20?= =?UTF-8?q?=EB=8B=A4=EB=A5=B8=20=ED=83=AD=20=EB=8B=AB=EA=B8=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - moveToServer → 루프: task.acting 이 끝나기를 30초까지(MOVE_SETTLE), 끝나지 않으면 PC 에서 이어서(그렇게 말함) - fillSecret: 동작이 시작된 브라우저가 아니면 입력하지 않음 - toServer(from): serverFor 먼저 → 다른 탭 닫기 → idle, 열리지 않으면 아무것도 바뀌지 않고 PC 에서 · 카드 줄 쓰기 실패는 옮기기를 막지 않음 - browserWhere: noColumn 을 1분만, 503 문구 L() - agent.js: own · composed 아닌 턴의 where 는 버림 - 설정: 저장 실패 뒤 저장된 값으로 다시 읽기, pcLine 은 줄을 떠나면 지움 - 시험: browser-local 「검토 1 · 2」(진짜 Electron, /slow 페이지), browserWhere 「검토 3」 Co-Authored-By: Claude Opus 5.5 --- docs/browser-where/design.md | 10 +++++ e2e/README.md | 4 ++ server/lib/agent.js | 3 ++ server/lib/browser.js | 56 ++++++++++++++++++------- server/lib/browserWhere.js | 26 +++++++----- server/test/browser-local.test.js | 58 ++++++++++++++++++++++++++ server/test/browserWhere.test.js | 13 ++++++ server/test/fixtures/drivers.mjs | 5 +++ src/components/LocalAgentsSettings.vue | 5 ++- 9 files changed, 155 insertions(+), 25 deletions(-) diff --git a/docs/browser-where/design.md b/docs/browser-where/design.md index 210ffe35..5f1829ba 100644 --- a/docs/browser-where/design.md +++ b/docs/browser-where/design.md @@ -46,6 +46,16 @@ - **옛 PC 앱 안내는 카드에서, 그 판이 나온 뒤에만 한다.** 휴대폰으로 지켜보는 사람이 앱 설정 화면까지 가지 않아도 되게 한다. 0.2.12의 auto mode 안내(`chat.js pcUpdateOf`)와 같은 방식이다. - **잠긴 화면 · 꺼진 화면(디스플레이 잠자기)은 측정하지 않았다.** 이 맥에서는 다른 세션이 녹화를 하고 있어 화면을 재우거나 잠글 수 없었다. 그 상태에서는 캡처도 실패할 수 있다. 그때 카드는 지금처럼 「PC 화면을 받지 못하고 있어요 — 작업은 이어서 해요」와 「서버에서 이어서」를 보여 준다. +### 독립 검토 반영 +검토자 한 명이 바뀐 코드를 처음부터 읽었다. 고친 것: +1. **옮길 때 하던 동작이 남는다(심각).** 멈춤은 동작을 기다리는 것만 끝내고 동작 자체는 계속된다. 그래서 남은 호출(상자 찾기 다음의 보관함 값 입력)이 새 서버 브라우저의 다른 사이트 페이지나, 그사이 PC 에서 시작한 다음 작업의 페이지에 닿을 수 있었다. 이제 옮기기는 그 동작(`task.acting`)이 끝나기를 30초까지 기다린다. 끝나지 않으면 옮기지 않고 그렇게 말한다. 보관함 값은 동작이 시작된 브라우저에만 넣는다. +2. **실패한 옮기기가 반쯤 옮긴 채 남는다.** 전에는 PC 를 먼저 놓고 서버 브라우저를 열었다. 이제 서버 브라우저를 먼저 열고, 열린 뒤에 PC 의 다른 탭을 닫고 놓는다. 열리지 않으면 아무것도 바뀌지 않고 PC 에서 잇는다. 카드 줄을 쓰지 못해도 옮기기는 이어지고, 모델은 옮긴 사실을 듣는다. +3. **열이 없다는 판단이 굳는다.** 배포 뒤에 076 을 돌려도 재시작 전까지 설정이 잠겨 있었다. 이제 1분 뒤 다시 본다. +4. 끝나 가는 작업에는 「옮김」이라고 답하지 않는다. +5. 옮길 때 그 작업이 PC 에 연 다른 탭(로그인 창 같은)도 닫는다. +6. 사람이 직접 입력하지 않은 턴(지은 말 · 자동)의 `where` 는 쓰지 않는다. +- 작은 것: 저장에 실패하면 설정 칸을 저장된 값으로 되돌림, 503 문구 영어판, 줄을 떠난 카드의 `pcLine` 지움. + ### 측정 2026-12-02, 실제 Electron 시험 도우미에서 측정했다. 시험 페이지 `/tick`은 250ms마다 바뀌며, 작업이 브라우저를 사용하는 동안 5초에 걸쳐 서버에 도착한 실시간 프레임을 셌다. 모든 프레임은 현재 페이지의 그림이었다. diff --git a/e2e/README.md b/e2e/README.md index 7e5bf43e..0e60bef3 100644 --- a/e2e/README.md +++ b/e2e/README.md @@ -2993,6 +2993,10 @@ cd e2e && PGPT_URL=http://127.0.0.1:5273 API_URL=http://127.0.0.1:8873 npx playw | 기본값 「늘 서버」 → 서버(`why: 'person'`), 「PC 에서」라고 한 작업만 PC, 되돌리면 PC | 사용자 12-02 | 「설정 「브라우저 작업 위치」 = 늘 서버 …」 | 단위(Electron) | ✅ | | PC를 기다리며 줄 선 작업(`pcLine`)의 「서버에서 바로 시작」 → 앞 작업이 PC에서 진행되는 동안 서버에서 끝남 · `pcLine` 지워짐 | 사용자 12-02 | 「PC 브라우저를 기다리며 줄 선 작업 …」 | 단위(Electron) | ✅ | | 없는 작업 · 남의 작업은 옮기지 않음(false) | 설계 | `browserWhere.test.js` | 단위 | ✅ | +| 하던 동작(느린 페이지 열기) 중에 옮기면 그 동작의 PC 호출 뒤에 PC 를 놓고, 놓은 뒤에는 그 작업의 동작이 PC 로 가지 않음 · 보관함 값은 동작이 시작된 브라우저에만(바뀌었으면 입력하지 않음) · 30초 안에 끝나지 않으면 옮기지 않음 | 독립 검토 #1 | `browser-local.test.js` 「검토 1: …」 | 단위(Electron) | ✅ | +| 서버 브라우저가 열리지 않으면 옮기지 않고 PC 에서 끝냄 — PC 는 놓이지 않음, 카드는 「내 PC」 그대로 · 카드 줄을 못 써도 옮기기는 이어짐 | 독립 검토 #2 | 「검토 2: …」 | 단위(Electron) | ✅ | +| 열이 없다고 본 것은 1분 뒤 다시 봄(배포 뒤 076 을 돌려도 재시작 없이 켜짐) | 독립 검토 #3 | `browserWhere.test.js` 「검토 3: …」 | 단위(로컬 DB) | ✅ | +| 끝나 가는 작업(turns 끝) · 자동 · 지은 턴의 `where` 는 쓰지 않음 · 옮길 때 PC 의 다른 탭도 닫음 · 저장 실패 뒤 설정 칸은 저장된 값으로 | 독립 검토 #4 · #5 · #6 | 코드 읽기 | — | ◐(시험 없음 — 조건 한 줄씩) | | 390 확장 화면: 「서버에서 이어서」 → `route {taskId, to:'server'}` · 단추 다섯 개가 모두 한 줄 높이(40px) · 모두 화면 안에 표시(둘째 줄) · 옆으로 넘치지 않음 | 사용자 12-02 | F-BW-01 | feature | ✅ | | 390 그림이 오지 않는 카드: 「PC 화면을 받지 못하고 있어요」 · 「PC 앱을 0.2.13 버전으로 올리면 진행 화면이 보여요」 · 「내려받기」 링크 · 「서버에서 이어서」, 옮길 수 없다는 답이면 그 까닭을 표시, 다시 누르면 보냄 · 확장 화면이 열리지 않음 | 사용자 12-02 | F-BW-02 | feature | ✅ | | 390 줄 선 카드(`pcLine`)의 「서버에서 바로 시작」 · 「취소」 | 사용자 12-02 | F-BW-03 | feature | ✅ | diff --git a/server/lib/agent.js b/server/lib/agent.js index 437c1111..2cab08ba 100644 --- a/server/lib/agent.js +++ b/server/lib/agent.js @@ -398,6 +398,9 @@ function runBrowser({ user, session, threadId, goal, startUrl, skill, files = [] // (a turn the server composed — a teammate's words picked up, a Home card's action: none of it is the person's own asking, so a purchase // control waits for their approval — review PR #105 round 3) const words = own ? (turnCtx.getStore()?.composed ? [] : [String(asked?.text ?? ''), ...said.filter(Boolean)]) : null + // (where the browser runs is the person's own word only: a turn nobody typed — composed, automatic — keeps their settings (review + // 2026-12-02 #6: a router's 'pc' on a picked-up teammate's words went past the person's 「늘 서버」)) + if (!own || turnCtx.getStore()?.composed) where = '' browserStarts.push({ threadId, goal, startUrl: startUrl || '', skill: skill || '', files: files.map((f) => f.name), own, background, said: words, ...(where ? { where } : {}) }) if (browserStarts.length > 20) browserStarts.shift() // the person's words go along (behind a task that waits for them, its card offers them as that task's answer — the first choice diff --git a/server/lib/browser.js b/server/lib/browser.js index 3ecd5e95..8a3deed0 100644 --- a/server/lib/browser.js +++ b/server/lib/browser.js @@ -1184,7 +1184,7 @@ async function runBrowserTaskNow({ userId, threadId, goal, startUrl, onAction, u } return { state: 'cancelled', summary: '', notes: [], stats: task.stats, taskId: task.id } } - if (queued) await updateMessage(userId, card.id, { state: 'running', reason: '', blocked: null, offer: null, order: null, ...(noFront ? { noFront: null } : {}) }) + if (queued) await updateMessage(userId, card.id, { state: 'running', reason: '', blocked: null, offer: null, order: null, pcLine: null, ...(noFront ? { noFront: null } : {}) }) // a page left stuck by the task before (a script that never returns) is not this task's problem: a fresh tab or browser // (taken and checked already when a place was free at the start; a task that waited in line takes it now) if (ready) await ready @@ -1423,12 +1423,24 @@ async function drive(s, task, { messages, onAction, stop = () => false }) { // (moving: a second 「서버에서 이어서」 while this one is on its way is not another move) task.moving = true try { - if (s.driver.kind === 'local') { - const was = s.driver - const url = was.url() - // (the PC's browser lets go of it: no more frames, its page cleared — the PC is free for the next task) - await was.idle?.().catch(() => {}) - await toServer(s, task, messages, { url, device: was.device || {}, asked: true }).catch((e) => console.warn(`[browser] task ${task.id}: to the server`, e.message)) + if (s.driver.kind === 'local' && !s.driver.lost) { + // the action under way ends first — the stop ended the wait for it, not the action: what is left of it (a box looked up, a + // value typed) must never land on the next browser, nor on the next task's page on this PC (review 2026-12-02 #1). One that + // does not end in time: the task stays on the PC, and says so + const settled = !task.acting || await Promise.race([task.acting.then(() => true, () => true), pause(MOVE_SETTLE.ms).then(() => false, () => false)]) + if (!settled) { + console.warn(`[browser] task ${task.id}: not moved — its action on the PC did not end within ${MOVE_SETTLE.ms} ms`) + jot(task, 'to_server_failed', { why: 'action' }) + say(task, L('지금 하던 동작이 끝나지 않아 PC 에서 이어서 해요', 'The action under way did not finish, so it goes on on the PC')) + } else { + const was = s.driver + const moved = await toServer(s, task, messages, { url: was.url(), device: was.device || {}, asked: true, from: was }) + .then(() => true, (e) => { console.warn(`[browser] task ${task.id}: to the server`, e.message); return false }) + if (!moved) { + jot(task, 'to_server_failed', { why: 'server' }) + say(task, L('서버 브라우저를 열지 못해 PC 에서 이어서 해요', "The server's browser didn't open, so it goes on on the PC")) + } + } } } finally { task.moving = false } turn-- @@ -1524,7 +1536,11 @@ async function drive(s, task, { messages, onAction, stop = () => false }) { try { // one action has a limit (a navigation it starts has its own on top); the ones that wait — on the page, on the // person — have their own ends and stop on 다시 시도 or 작업 취소 - out = await actWithin(task, act(s, task, name, args), LONG_TOOLS.has(name) ? Infinity : STEP.actMs + (name === 'goto' ? STEP.navMs + STEP.settleMs : 0), signal, name) + // (task.acting: the action itself — a stop ends the wait for it, not the action: a move to this server waits for it — moveToServer) + const acting = act(s, task, name, args) + task.acting = acting + acting.then(() => {}, () => {}).finally(() => { if (task.acting === acting) task.acting = null }) + out = await actWithin(task, acting, LONG_TOOLS.has(name) ? Infinity : STEP.actMs + (name === 'goto' ? STEP.navMs + STEP.settleMs : 0), signal, name) } catch (e) { if (isStop(e)) throw e if (e instanceof StepError) task.stats.step_timeouts++ @@ -2286,6 +2302,8 @@ const SPECIAL = new Set([OFFLINE, TO_SERVER, PC_BACK, GAVE_UP, 'cancelled']) export const choseLine = (label) => `The user chose: ${label}. Continue with that choice.` // how long a paused task waits for its PC before it stops (tests shorten it) export const OFFLINE_WAIT = { ms: 30 * 60 * 1000 } +// how long a move to this server (moveToServer) waits for the action under way on the PC to end (tests shorten it) +export const MOVE_SETTLE = { ms: 30_000 } // times a task reopens the browser of a PC that is still linked (its window gone, the app restarting it) before it pauses export const MAX_REOPENS = 3 function brokenReason(device, host) { @@ -2374,9 +2392,16 @@ async function whenOffline(s, task, messages) { // 「서버에서 이어서」: this server's browser takes the task from the page it was on (the card says so, and so does the agent). asked: the // person moved it while their PC was on (moveToServer) — a task that goes on from this card stays on this server (where.asked); else // their PC went off (whenOffline) -async function toServer(s, task, messages, { url, device, asked = false }) { +// from: the PC's driver to let go of once this server's browser is there (asked — the PC is still on): its other tabs closed, then idle +// (no frames, its page cleared). This server's browser comes first: when it does not open, nothing has changed and the task stays on the +// PC (review 2026-12-02 #2) +async function toServer(s, task, messages, { url, device, asked = false, from = null }) { s.session.driver = await serverFor(s) await s.driver.healthy().catch((e) => console.warn('[browser] health check', e.message)) + if (from && from !== s.driver) { + await from.closeOtherTabs?.().catch(() => {}) + await from.idle?.().catch(() => {}) + } s.gen = s.driver.browser?.gen ?? null // (the PC's place is free: a task in line for it may start) s.pc = false @@ -2385,7 +2410,8 @@ async function toServer(s, task, messages, { url, device, asked = false }) { task.where = { kind: 'server', from: 'local', device: device.name || '', ...(asked ? { asked: true } : {}) } jot(task, 'to_server', { device: device.name || null, ...(asked ? { asked: true } : {}) }) task.moves = (task.moves || 0) + 1 - await updateMessage(task.userId, task.id, { where: task.where }) + // (the card's line is not the move: one that cannot be written now does not stop it — the agent is told below either way) + await updateMessage(task.userId, task.id, { where: task.where }).catch((e) => console.warn(`[browser] task ${task.id}: card`, e.message)) if (url && !/^about:/.test(url)) { say(task, L(`서버 브라우저에서 ${hostOf(url)} 여는 중`, `Opening ${hostOf(url)} in the server's browser`)) await s.driver.navigate(url, { signal: task.abort.signal }).catch(() => {}) @@ -2437,7 +2463,7 @@ export async function moveToServer(userId, taskId) { } const ln = laneById(s, taskId) const t = ln?.task - if (!t || t.cancelled || t.waiting || t.moveTo || t.moving || ln.driver?.kind !== 'local' || ln.driver.lost) return false + if (!t || t.cancelled || t.over || t.waiting || t.moveTo || t.moving || ln.driver?.kind !== 'local' || ln.driver.lost) return false t.moveTo = 'server' say(t, L('서버 브라우저로 옮기는 중', "Moving to the server's browser")) // (the step under way stops at once — it does not count as one of the agent's turns, like a PC that went off part way) @@ -2909,7 +2935,7 @@ async function doAct(s, task, name, a) { card_cvv: sec.cvv, card_name: sec.name }[a.field] if (!val) return `the saved ${kind} has no ${a.field}` await point(s, task, a.i, 'type') - await fillSecret(s, a.i, val, task) + await fillSecret(s, a.i, val, task, d) if (kind === 'login') task.used[site] = item.id return 'filled ' + a.field } @@ -3245,9 +3271,11 @@ async function streamCopy(url) { // Fill a vault value into the page: the element remembers it (so the page guard does not "capture" it back) and is masked // on screen. On the person's PC the value goes to their own desktop for this one fill (lib/browserRemote.js). -async function fillSecret(s, i, value, task) { +// d: the browser the action began on — a value is never typed into another one (the task moved meanwhile: review 2026-12-02 #1) +async function fillSecret(s, i, value, task, d = s.driver) { + if (s.driver !== d) throw new Error('the browser changed under this action — the value was not typed') remember(task, String(value)) - await s.driver.fillSecret(i, String(value)) + await d.fillSecret(i, String(value)) } // Values filled during the task are blanked out of anything the model reads, should the page echo diff --git a/server/lib/browserWhere.js b/server/lib/browserWhere.js index 6eb78f0a..edebb7b5 100644 --- a/server/lib/browserWhere.js +++ b/server/lib/browserWhere.js @@ -7,13 +7,16 @@ // (lib/browser.js moveToServer). That choice wins over this one. Changing this never makes a PC take more: a PC takes a task only by its own // setting (changed only on that PC), so this setting can only move tasks off the PC — which is why it may be changed from any device. // Read when a task starts (kept a minute: another replica's change shows within it). Without the column (sql/076 not run yet) everyone is -// 'pc' and a change is refused (503 no_column) — never a change said to be saved that is not. +// 'pc' and a change is refused (503 no_column) — never a change said to be saved that is not. A missing column is looked for again after +// a minute: sql/076 run after the deploy turns the setting on without a restart (review 2026-12-02 #3). import { q } from './supa.js' +import { L } from './lang.js' export const WHERE = ['pc', 'server'] const CACHE_MS = 60_000 const cache = new Map() // userId → { where, at } -let noColumn = false // (the column is not there: read as 'pc' without asking each time — until a change is tried again) +let noColumnAt = 0 // (when the column was found missing: read as 'pc' without asking each time — for CACHE_MS) +const noColumn = () => noColumnAt > 0 && Date.now() - noColumnAt < CACHE_MS const UNDEFINED_COLUMN = '42703' @@ -23,7 +26,7 @@ export async function personWhere(userId) { const id = String(userId) const c = cache.get(id) if (c && Date.now() - c.at < CACHE_MS) return c.where - if (noColumn) return 'pc' + if (noColumn()) return 'pc' try { const [r] = await q('select browser_where from pro_profile where user_id=$1', [id]) const where = r?.browser_where === 'server' ? 'server' : 'pc' @@ -31,15 +34,15 @@ export async function personWhere(userId) { if (cache.size > 5000) cache.delete(cache.keys().next().value) return where } catch (e) { - if (e?.code === UNDEFINED_COLUMN) { noColumn = true; return 'pc' } + if (e?.code === UNDEFINED_COLUMN) { noColumnAt = Date.now(); return 'pc' } // (the database did not answer: as before — the PC when it is on) console.warn('[browser-where] read', e.message) return 'pc' } } -// whether the choice can be kept (the column is there), as last seen -export const canKeep = () => !noColumn +// whether the choice can be kept (the column is there), as last seen within the minute +export const canKeep = () => !noColumn() // → 'pc' | 'server' as kept. Throws { status: 400 } for another value, { status: 503, code: 'no_column' } without the column. export async function setPersonWhere(user, where) { @@ -51,15 +54,18 @@ export async function setPersonWhere(user, where) { on conflict (user_id) do update set browser_where = excluded.browser_where`, [id, user.email || null, where === 'server' ? 'server' : null]) } catch (e) { if (e?.code === UNDEFINED_COLUMN) { - noColumn = true - throw Object.assign(new Error('브라우저 작업 위치를 저장할 곳이 아직 없어요(데이터베이스 076). 관리자에게 알려 주세요.'), { status: 503, code: 'no_column' }) + noColumnAt = Date.now() + throw Object.assign(new Error(L('브라우저 작업 위치를 저장할 곳이 아직 없어요(데이터베이스 076). 관리자에게 알려 주세요.', + 'There is nowhere to save where browser tasks run yet (database 076). Tell your administrator.')), { status: 503, code: 'no_column' }) } throw e } - noColumn = false + noColumnAt = 0 cache.set(id, { where, at: Date.now() }) return where } // (tests) -export function _forget() { cache.clear(); noColumn = false } +export function _forget() { cache.clear(); noColumnAt = 0 } +// (tests) as if the column had been found missing ms ago +export function _missingSince(ms) { noColumnAt = Date.now() - ms } diff --git a/server/test/browser-local.test.js b/server/test/browser-local.test.js index f8fc7dfd..d42bfc6a 100644 --- a/server/test/browser-local.test.js +++ b/server/test/browser-local.test.js @@ -357,6 +357,64 @@ test('PC 에서 일하는 작업의 「서버에서 이어서」(PC 는 켜진 assert.deepEqual(again.where, { kind: 'server', why: 'asked' }) }) +test('검토 1: 하던 동작(느린 페이지 열기)이 끝난 뒤에 PC 를 놓고 서버로 옮긴다 — 남은 동작이 서버 브라우저나 PC 의 다음 작업에 닿지 않는다', { skip }, async () => { + if (!pcLink()) await startPc() + const goal = '느린 동작 중 옮기기' + const slow = `${site.url}/slow?ms=3000&from=move-slow` + const from = (sentTo.get(user) || []).length + const p = run(goal, [ + ['goto', { url: slow }], + (b) => ['note', { text: lastSnap(b).url }], + ['finish', { summary: '서버에서 끝냈어요.' }], + ]) + // the slow page is on its way on the PC + assert.ok(await until(() => (sentTo.get(user) || []).slice(from).some((m) => m.includes('/slow?ms=3000'))), 'PC 가 느린 페이지를 열기 시작했다') + const c = await card(goal) + const movedAt = Date.now() + assert.equal(await browser.routeTo(user, c.id, 'server'), true) + const r = await p + assert.equal(r.state, 'done', JSON.stringify(r).slice(0, 300)) + assert.equal(r.where.kind, 'server') + // (the PC is let go after the action's own calls — the desktop runs them in order — and none of that action comes after it) + const sent = (sentTo.get(user) || []).slice(from).map((m) => JSON.parse(m)) + const idle = sent.findIndex((m) => m.op === 'idle') + const nav = sent.findIndex((m) => m.op === 'navigate' && String(m.args?.url || '').includes('/slow')) + assert.ok(nav >= 0 && idle > nav, `느린 페이지 열기 뒤에 놓았다: ${sent.map((m) => m.op).join(',')}`) + assert.ok(!sent.slice(idle + 1).some((m) => ['click', 'fill', 'fillSecret', 'navigate', 'type', 'key'].includes(m.op)), `놓은 뒤 PC 에 간 동작 없음: ${sent.slice(idle + 1).map((m) => m.op).join(',')}`) + assert.ok(r.stats.ms >= 2500 || Date.now() - movedAt >= 1500, '느린 페이지가 끝날 때까지 기다렸다') +}) + +test('검토 2: 서버 브라우저가 열리지 않으면 옮기지 않고 PC 에서 이어서 끝낸다 — PC 는 놓이지 않는다', { skip }, async () => { + if (!pcLink()) await startPc() + const { ServerDriver } = await import('../lib/browserServer.js') + const keepOpen = ServerDriver.open, keepRelaunch = ServerDriver.prototype.relaunch + const probe = browser._laneFor(user) + const sess = probe.session + browser._dropLane(probe) + const goal = '서버가 안 열릴 때 옮기기' + const from = (sentTo.get(user) || []).length + const p = run(goal, ['hang', ['note', { text: 'PC 에서 이어서' }], ['finish', { summary: 'PC 에서 끝냈어요.' }]], { startUrl: `${site.url}/shop?from=move-fail` }) + try { + const c = await until(async () => { const x = await card(goal); return x?.content?.where?.kind === 'local' && scripts[goal].i >= 1 ? x : null }) + assert.ok(c) + const fail = async () => { throw new Error('launch failed (test)') } + ServerDriver.open = fail + ServerDriver.prototype.relaunch = fail + if (sess.server && !sess.server.closed) await sess.server.ctx.close().catch(() => {}) + assert.equal(await browser.routeTo(user, c.id, 'server'), true) + const r = await p + assert.equal(r.state, 'done', JSON.stringify(r).slice(0, 300)) + assert.equal(r.where.kind, 'local', 'PC 에서 끝났다') + const ops = (sentTo.get(user) || []).slice(from).map((m) => JSON.parse(m).op).filter(Boolean) + const firstIdle = ops.indexOf('idle') + assert.ok(firstIdle === -1 || firstIdle === ops.length - 1 || ops.slice(firstIdle + 1).every((o) => o === 'idle'), `작업이 끝나기 전에는 PC 를 놓지 않았다: ${ops.join(',')}`) + assert.equal((await card(goal)).content.where.kind, 'local') + } finally { + ServerDriver.open = keepOpen + ServerDriver.prototype.relaunch = keepRelaunch + } +}) + test('채팅에서 이 작업만 서버로(browser_task where: server): PC 가 켜져 있어도 서버 브라우저 — 카드에 그렇게 남는다', { skip }, async () => { if (!pcLink()) await startPc() const r = await run('말로 서버', [['note', { text: '서버' }], ['finish', { summary: '서버에서 했어요.' }]], { where: 'server' }) diff --git a/server/test/browserWhere.test.js b/server/test/browserWhere.test.js index ce19d98b..ec800e3f 100644 --- a/server/test/browserWhere.test.js +++ b/server/test/browserWhere.test.js @@ -52,6 +52,19 @@ test('사람의 기본값은 저장되고(어느 기기에서나 바꿀 수 있 assert.equal(W.canKeep(), true) }) +test('검토 3: 열이 없다고 본 것은 1분 뒤 다시 본다 — 배포 뒤에 076 을 돌려도 재시작 없이 켜진다', async () => { + W._forget() + W._missingSince(10_000) + assert.equal(W.canKeep(), false, '1분 안에는 없다고 본 그대로') + assert.equal(await W.personWhere(crypto.randomUUID()), 'pc') + W._missingSince(61_000) + assert.equal(W.canKeep(), true, '1분이 지나면 다시 본다') + await W.setPersonWhere(user, 'server') + W._forget() + assert.equal(await W.personWhere(user.id), 'server', '열이 있으면 다시 읽힌다') + await W.setPersonWhere(user, 'pc') +}) + test('설정 화면이 보는 것(whereFor): 기본값과 그것으로 정해진 곳', async () => { const R = await import('../lib/browserRemote.js') await W.setPersonWhere(user, 'server') diff --git a/server/test/fixtures/drivers.mjs b/server/test/fixtures/drivers.mjs index b6d5cbd6..7543e6a5 100644 --- a/server/test/fixtures/drivers.mjs +++ b/server/test/fixtures/drivers.mjs @@ -100,6 +100,11 @@ export async function startDriverSite() { const server = http.createServer((req, res) => { const u = new URL(req.url, 'http://x') if (u.pathname === '/hang.png') { hung.add(res); req.on('close', () => hung.delete(res)); return } + // a page that answers after ?ms= (at most 10 s): an action under way while the test does something else + if (u.pathname === '/slow') { + const ms = Math.min(10_000, Number(u.searchParams.get('ms')) || 2000) + return setTimeout(() => { res.writeHead(200, { 'Content-Type': 'text/html; charset=utf-8' }); res.end('느린 페이지

느린 페이지

') }, ms) + } if (u.pathname === '/probe') { probes.push(u.search.slice(1) || '-') res.writeHead(200, { 'Content-Type': 'image/gif', 'Access-Control-Allow-Origin': '*' }) diff --git a/src/components/LocalAgentsSettings.vue b/src/components/LocalAgentsSettings.vue index e1de952b..621c8cda 100644 --- a/src/components/LocalAgentsSettings.vue +++ b/src/components/LocalAgentsSettings.vue @@ -46,7 +46,10 @@ const permissionHint = computed(() => { // 「브라우저 작업 위치」: the person's default — 2026-12-02 사용자 「pc 에 연결된 브라우저에서 동작하길 원치 않고 서버 파드에서 돌리고 싶은 경우도 // 지원」. One task can still go elsewhere (their words for it, 「서버에서 이어서」 on its card) const PLACES = [['pc', 'PC 우선'], ['server', '늘 서버']] -const setPerson = (where) => run('person', async () => { web.value = await api('/browser/where', { method: 'PUT', body: { where } }) }) +// (not kept — 503 · an error: the field goes back to what is kept, beside the message) +const setPerson = (where) => run('person', async () => { + try { web.value = await api('/browser/where', { method: 'PUT', body: { where } }) } catch (e) { await load(); throw e } +}) const whereLine = (w, nobody) => { if (!w) return '' if (w.why === 'person') return '서버 브라우저에서 해요 — 「브라우저 작업 위치」를 「늘 서버」로 정했어요. PC 에서 한 로그인은 서버 브라우저에 없어요' From ba85ed77f121a9afb3e55acd39b1d34079316c04 Mon Sep 17 00:00:00 2001 From: jinyoung Date: Wed, 2 Dec 2026 12:32:15 +0900 Subject: [PATCH 06/12] =?UTF-8?q?docs(browser):=20=EB=8F=85=EB=A6=BD=20?= =?UTF-8?q?=EA=B2=80=ED=86=A0=20=EB=B0=98=EC=98=81=20=EC=A0=88=20=EC=9C=A4?= =?UTF-8?q?=EB=AC=B8(codex=20astra)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-Authored-By: Claude Opus 5.5 --- docs/browser-where/design.md | 14 +++++++------- e2e/README.md | 8 ++++---- 2 files changed, 11 insertions(+), 11 deletions(-) diff --git a/docs/browser-where/design.md b/docs/browser-where/design.md index 5f1829ba..21edf34d 100644 --- a/docs/browser-where/design.md +++ b/docs/browser-where/design.md @@ -47,14 +47,14 @@ - **잠긴 화면 · 꺼진 화면(디스플레이 잠자기)은 측정하지 않았다.** 이 맥에서는 다른 세션이 녹화를 하고 있어 화면을 재우거나 잠글 수 없었다. 그 상태에서는 캡처도 실패할 수 있다. 그때 카드는 지금처럼 「PC 화면을 받지 못하고 있어요 — 작업은 이어서 해요」와 「서버에서 이어서」를 보여 준다. ### 독립 검토 반영 -검토자 한 명이 바뀐 코드를 처음부터 읽었다. 고친 것: -1. **옮길 때 하던 동작이 남는다(심각).** 멈춤은 동작을 기다리는 것만 끝내고 동작 자체는 계속된다. 그래서 남은 호출(상자 찾기 다음의 보관함 값 입력)이 새 서버 브라우저의 다른 사이트 페이지나, 그사이 PC 에서 시작한 다음 작업의 페이지에 닿을 수 있었다. 이제 옮기기는 그 동작(`task.acting`)이 끝나기를 30초까지 기다린다. 끝나지 않으면 옮기지 않고 그렇게 말한다. 보관함 값은 동작이 시작된 브라우저에만 넣는다. -2. **실패한 옮기기가 반쯤 옮긴 채 남는다.** 전에는 PC 를 먼저 놓고 서버 브라우저를 열었다. 이제 서버 브라우저를 먼저 열고, 열린 뒤에 PC 의 다른 탭을 닫고 놓는다. 열리지 않으면 아무것도 바뀌지 않고 PC 에서 잇는다. 카드 줄을 쓰지 못해도 옮기기는 이어지고, 모델은 옮긴 사실을 듣는다. -3. **열이 없다는 판단이 굳는다.** 배포 뒤에 076 을 돌려도 재시작 전까지 설정이 잠겨 있었다. 이제 1분 뒤 다시 본다. +검토자 한 명이 바뀐 코드를 처음부터 읽었다. 고친 내용: +1. **옮길 때 하던 동작이 남는다(심각).** 멈추면 동작을 기다리기만 끝내고 동작 자체는 계속된다. 그래서 남은 호출(상자 찾기 다음의 보관함 값 입력)이 새 서버 브라우저의 다른 사이트 페이지나 그사이 PC에서 시작한 다음 작업의 페이지에 닿을 수 있었다. 이제 옮길 때는 그 동작(`task.acting`)이 끝나기를 30초까지 기다린다. 끝나지 않으면 옮기지 않고 그 사실을 알린다. 보관함 값은 동작이 시작된 브라우저에만 넣는다. +2. **옮기기에 실패하면 반쯤 옮긴 채로 남는다.** 전에는 PC를 먼저 놓고 서버 브라우저를 열었다. 이제 서버 브라우저를 먼저 열고, 열린 뒤에 PC의 다른 탭을 닫고 PC를 놓는다. 열리지 않으면 아무것도 바뀌지 않고 PC에서 이어 간다. 카드 줄을 쓰지 못해도 옮기기는 이어지고, 모델은 옮긴 사실을 전달받는다. +3. **열이 없다는 판단이 굳어진다.** 배포 뒤에 076을 돌려도 재시작 전까지 설정이 잠겨 있었다. 이제 1분 뒤 다시 확인한다. 4. 끝나 가는 작업에는 「옮김」이라고 답하지 않는다. -5. 옮길 때 그 작업이 PC 에 연 다른 탭(로그인 창 같은)도 닫는다. -6. 사람이 직접 입력하지 않은 턴(지은 말 · 자동)의 `where` 는 쓰지 않는다. -- 작은 것: 저장에 실패하면 설정 칸을 저장된 값으로 되돌림, 503 문구 영어판, 줄을 떠난 카드의 `pcLine` 지움. +5. 옮길 때 그 작업이 PC에 연 다른 탭(로그인 창 같은 탭)도 닫는다. +6. 사람이 직접 입력하지 않은 턴(지은 말 · 자동)의 `where`는 쓰지 않는다. +- 작은 수정: 저장에 실패하면 설정 칸을 저장된 값으로 되돌림, 503 문구 영어판, 줄을 떠난 카드의 `pcLine` 지움. ### 측정 2026-12-02, 실제 Electron 시험 도우미에서 측정했다. 시험 페이지 `/tick`은 250ms마다 바뀌며, 작업이 브라우저를 사용하는 동안 5초에 걸쳐 서버에 도착한 실시간 프레임을 셌다. 모든 프레임은 현재 페이지의 그림이었다. diff --git a/e2e/README.md b/e2e/README.md index 0e60bef3..fe2478fb 100644 --- a/e2e/README.md +++ b/e2e/README.md @@ -2993,10 +2993,10 @@ cd e2e && PGPT_URL=http://127.0.0.1:5273 API_URL=http://127.0.0.1:8873 npx playw | 기본값 「늘 서버」 → 서버(`why: 'person'`), 「PC 에서」라고 한 작업만 PC, 되돌리면 PC | 사용자 12-02 | 「설정 「브라우저 작업 위치」 = 늘 서버 …」 | 단위(Electron) | ✅ | | PC를 기다리며 줄 선 작업(`pcLine`)의 「서버에서 바로 시작」 → 앞 작업이 PC에서 진행되는 동안 서버에서 끝남 · `pcLine` 지워짐 | 사용자 12-02 | 「PC 브라우저를 기다리며 줄 선 작업 …」 | 단위(Electron) | ✅ | | 없는 작업 · 남의 작업은 옮기지 않음(false) | 설계 | `browserWhere.test.js` | 단위 | ✅ | -| 하던 동작(느린 페이지 열기) 중에 옮기면 그 동작의 PC 호출 뒤에 PC 를 놓고, 놓은 뒤에는 그 작업의 동작이 PC 로 가지 않음 · 보관함 값은 동작이 시작된 브라우저에만(바뀌었으면 입력하지 않음) · 30초 안에 끝나지 않으면 옮기지 않음 | 독립 검토 #1 | `browser-local.test.js` 「검토 1: …」 | 단위(Electron) | ✅ | -| 서버 브라우저가 열리지 않으면 옮기지 않고 PC 에서 끝냄 — PC 는 놓이지 않음, 카드는 「내 PC」 그대로 · 카드 줄을 못 써도 옮기기는 이어짐 | 독립 검토 #2 | 「검토 2: …」 | 단위(Electron) | ✅ | -| 열이 없다고 본 것은 1분 뒤 다시 봄(배포 뒤 076 을 돌려도 재시작 없이 켜짐) | 독립 검토 #3 | `browserWhere.test.js` 「검토 3: …」 | 단위(로컬 DB) | ✅ | -| 끝나 가는 작업(turns 끝) · 자동 · 지은 턴의 `where` 는 쓰지 않음 · 옮길 때 PC 의 다른 탭도 닫음 · 저장 실패 뒤 설정 칸은 저장된 값으로 | 독립 검토 #4 · #5 · #6 | 코드 읽기 | — | ◐(시험 없음 — 조건 한 줄씩) | +| 동작(느린 페이지 열기) 중에 옮기면 그 동작의 PC 호출 뒤에 PC를 놓고, 놓은 뒤에는 그 작업의 동작이 PC로 가지 않음 · 보관함 값은 동작이 시작된 브라우저에만 입력함(바뀌었으면 입력하지 않음) · 30초 안에 끝나지 않으면 옮기지 않음 | 독립 검토 #1 | `browser-local.test.js` 「검토 1: …」 | 단위(Electron) | ✅ | +| 서버 브라우저가 열리지 않으면 옮기지 않고 PC에서 끝냄 — PC는 놓이지 않음, 카드는 「내 PC」 그대로 · 카드 줄을 못 써도 옮기기는 이어짐 | 독립 검토 #2 | 「검토 2: …」 | 단위(Electron) | ✅ | +| 열이 없다고 판단한 경우 1분 뒤 다시 확인함(배포 뒤 076을 돌려도 재시작 없이 켜짐) | 독립 검토 #3 | `browserWhere.test.js` 「검토 3: …」 | 단위(로컬 DB) | ✅ | +| 끝나 가는 작업(turns 끝) · 자동 · 지은 턴의 `where`는 쓰지 않음 · 옮길 때 PC의 다른 탭도 닫음 · 저장 실패 뒤 설정 칸은 저장된 값으로 되돌림 | 독립 검토 #4 · #5 · #6 | 코드 읽기 | — | ◐(시험 없음 — 조건 한 줄씩) | | 390 확장 화면: 「서버에서 이어서」 → `route {taskId, to:'server'}` · 단추 다섯 개가 모두 한 줄 높이(40px) · 모두 화면 안에 표시(둘째 줄) · 옆으로 넘치지 않음 | 사용자 12-02 | F-BW-01 | feature | ✅ | | 390 그림이 오지 않는 카드: 「PC 화면을 받지 못하고 있어요」 · 「PC 앱을 0.2.13 버전으로 올리면 진행 화면이 보여요」 · 「내려받기」 링크 · 「서버에서 이어서」, 옮길 수 없다는 답이면 그 까닭을 표시, 다시 누르면 보냄 · 확장 화면이 열리지 않음 | 사용자 12-02 | F-BW-02 | feature | ✅ | | 390 줄 선 카드(`pcLine`)의 「서버에서 바로 시작」 · 「취소」 | 사용자 12-02 | F-BW-03 | feature | ✅ | From 13cb5c2012e9a37ec0193b4f369fd23824d14b7e Mon Sep 17 00:00:00 2001 From: jinyoung Date: Wed, 2 Dec 2026 12:32:28 +0900 Subject: [PATCH 07/12] =?UTF-8?q?docs(browser):=20=EA=B8=B0=EA=B8=B0=20?= =?UTF-8?q?=EC=9D=B4=EB=A6=84=20=EB=8C=80=EC=8B=A0=20=EC=9E=90=EB=A6=AC?= =?UTF-8?q?=ED=91=9C=EC=8B=9C=EC=9E=90?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-Authored-By: Claude Opus 5.5 --- docs/browser-where/design.md | 2 +- e2e/README.md | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/docs/browser-where/design.md b/docs/browser-where/design.md index 21edf34d..de0aa101 100644 --- a/docs/browser-where/design.md +++ b/docs/browser-where/design.md @@ -6,7 +6,7 @@ ### 무엇을 받았나 휴대폰 화면 두 장과 다음 말을 받았다: 「Pc 에 연결된 브라우저 사용시 진행상태가 보이지 않음. 화면전환된 송출을 최적화하여 연결할 방법이 있나? 그리고 pc 에 연결된 브라우저에서 동작하길 원치 않고 서버 파드에서 돌리고 싶은 경우도 지원」. -- 11:31 화면: 카드에 「내 PC · uengineui-MacBookPro」 · 「브라우저 여는 중」이 있고 그림은 없다. 알약에는 「페이지 읽는 중」이 표시된다. +- 11:31 화면: 카드에 「내 PC · <사용자의 맥>」 · 「브라우저 여는 중」이 있고 그림은 없다. 알약에는 「페이지 읽는 중」이 표시된다. - 11:35 화면: 확장 화면에 YouTube Studio 업로드 창 한 장이 있다. 단추줄은 「계획 / 2/6」 · 「직접 제 / 어」 · 「이 PC에서 / 보기」 · 「작업 취 / 소」처럼 글자가 두 줄로 갈라진다. ### 왜 안 보였나 diff --git a/e2e/README.md b/e2e/README.md index fe2478fb..49873bd7 100644 --- a/e2e/README.md +++ b/e2e/README.md @@ -2968,7 +2968,7 @@ cd e2e && ~/.claude/tools/lite/reclock.sh run guardrails -- npx playwright test ### 105. PC 브라우저의 진행 화면이 이어지고, PC가 켜져 있어도 서버 브라우저를 고른다 (스펙 `browser-handoff` 「서버 브라우저를 고르기」 · 「PC 화면이 오지 않을 때에도 진행 화면이 이어진다」, 설계 `docs/browser-where/design.md`) -근거: 2026-12-02 11:31 · 11:35 사용자(휴대폰 화면 — 「내 PC · uengineui-MacBookPro」 카드가 「브라우저 여는 중」에 머묾, 확장 화면 단추 글자가 두 줄로 갈라짐) — 「Pc 에 연결된 브라우저 사용시 진행상태가 보이지 않음. 화면전환된 송출을 최적화하여 연결할 방법이 있나? 그리고 pc 에 연결된 브라우저에서 동작하길 원치 않고 서버 파드에서 돌리고 싶은 경우도 지원」. 그 맥은 0.2.10이었고, 아침에 보였다가 최소화된 창이 새 페이지를 그리지 않았다(측정은 설계 노트). 실제 Electron 시험은 시험 도우미의 stdin 「minimize」 · 「hide-app」 · 「cover」로 사람의 창 조작을 흉내 내고, 시험 페이지 `/tick`은 250ms마다 바뀐다. 기본값을 쓰려면 로컬 DB에 `server/sql/076_browser_where.sql`이 있어야 한다. 시험에 쓰인 윤태호 · 「테스트 맥」은 지어낸 것이다. +근거: 2026-12-02 11:31 · 11:35 사용자(휴대폰 화면 — 「내 PC · <사용자의 맥>」 카드가 「브라우저 여는 중」에 머묾, 확장 화면 단추 글자가 두 줄로 갈라짐) — 「Pc 에 연결된 브라우저 사용시 진행상태가 보이지 않음. 화면전환된 송출을 최적화하여 연결할 방법이 있나? 그리고 pc 에 연결된 브라우저에서 동작하길 원치 않고 서버 파드에서 돌리고 싶은 경우도 지원」. 그 맥은 0.2.10이었고, 아침에 보였다가 최소화된 창이 새 페이지를 그리지 않았다(측정은 설계 노트). 실제 Electron 시험은 시험 도우미의 stdin 「minimize」 · 「hide-app」 · 「cover」로 사람의 창 조작을 흉내 내고, 시험 페이지 `/tick`은 250ms마다 바뀐다. 기본값을 쓰려면 로컬 DB에 `server/sql/076_browser_where.sql`이 있어야 한다. 시험에 쓰인 윤태호 · 「테스트 맥」은 지어낸 것이다. ```bash cd desktop && npm test # 받쳐 주는 캡처 · 작업 시작 때 새 탭(가짜 탭 6개 포함) From 733a6a6f694e27170418041ed6493f4af2bf777f Mon Sep 17 00:00:00 2001 From: jinyoung Date: Wed, 2 Dec 2026 12:49:01 +0900 Subject: [PATCH 08/12] =?UTF-8?q?fix(browser):=20=EC=98=AE=EA=B8=B0?= =?UTF-8?q?=EA=B8=B0=EB=8A=94=20=EB=8F=99=EC=9E=91=EC=9D=84=20=EB=81=8A?= =?UTF-8?q?=EC=A7=80=20=EC=95=8A=EB=8A=94=EB=8B=A4=20=E2=80=94=20=EC=9D=BD?= =?UTF-8?q?=EA=B8=B0=20=C2=B7=20=EC=82=AC=EC=A7=84=20=C2=B7=20=EB=AA=A8?= =?UTF-8?q?=EB=8D=B8=EC=9D=98=20=EB=8B=B5=EB=A7=8C=20=EB=B0=94=EB=A1=9C=20?= =?UTF-8?q?=EB=A9=88=EC=B6=94=EA=B3=A0,=20=EB=8F=99=EC=9E=91=EC=9D=80=20?= =?UTF-8?q?=EB=81=9D=EB=82=9C=20=EB=92=A4=20=ED=84=B4=20=EC=82=AC=EC=9D=B4?= =?UTF-8?q?=EC=97=90=EC=84=9C=20=EC=98=AE=EA=B9=80(=ED=99=95=EC=9D=B8=20?= =?UTF-8?q?=EA=B2=80=ED=86=A0)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 확인 검토: 30초 제한은 동작 안의 승인 카드 · 메일 코드 기다림(멈춤을 듣지 않음)보다 짧아, 늦게 누른 승인이 다음 턴의 다른 요소에 닿을 수 있었다. - moveToServer: 동작이 없을 때만 그 턴을 멈춤(read · shot · model), 동작 중이면 끝나게 둠 - 루프: task.actions(아직 도는 동작 모두)가 비었을 때만 옮김 — 남은 동작이 있으면 「하던 동작이 끝나면 서버 브라우저로 옮겨요」 - 옮기기를 누른 뒤에는 새 동작을 시작하지 않음(signal 확인), MOVE_SETTLE 없앰, 턴이 끝난 작업(task.ending)은 옮기지 않음 - 시험 「검토 1」: 느린 페이지 열기 중 옮기기 → 그 동작의 답이 stopped 가 아님 · 그 뒤 옮김(앞 판은 이 시험에서 실패) Co-Authored-By: Claude Opus 5.5 --- docs/browser-where/design.md | 2 +- e2e/README.md | 2 +- openspec/specs/browser-handoff/spec.md | 4 +- server/lib/browser.js | 55 +++++++++++++------------- server/test/browser-local.test.js | 21 ++++++---- 5 files changed, 46 insertions(+), 38 deletions(-) diff --git a/docs/browser-where/design.md b/docs/browser-where/design.md index de0aa101..5ec1c821 100644 --- a/docs/browser-where/design.md +++ b/docs/browser-where/design.md @@ -48,7 +48,7 @@ ### 독립 검토 반영 검토자 한 명이 바뀐 코드를 처음부터 읽었다. 고친 내용: -1. **옮길 때 하던 동작이 남는다(심각).** 멈추면 동작을 기다리기만 끝내고 동작 자체는 계속된다. 그래서 남은 호출(상자 찾기 다음의 보관함 값 입력)이 새 서버 브라우저의 다른 사이트 페이지나 그사이 PC에서 시작한 다음 작업의 페이지에 닿을 수 있었다. 이제 옮길 때는 그 동작(`task.acting`)이 끝나기를 30초까지 기다린다. 끝나지 않으면 옮기지 않고 그 사실을 알린다. 보관함 값은 동작이 시작된 브라우저에만 넣는다. +1. **옮길 때 하던 동작이 남는다(심각).** 멈추면 동작을 기다리기만 끝내고 동작 자체는 계속된다. 그래서 남은 호출(상자 찾기 다음의 보관함 값 입력)이 새 서버 브라우저의 다른 사이트 페이지나 그사이 PC에서 시작한 다음 작업의 페이지에 닿을 수 있었다. 처음 고친 판은 그 동작이 끝나기를 30초까지 기다렸다. 그런데 확인 검토에서 동작 안의 승인 카드 · 메일로 오는 코드 기다림은 30초를 넘고 멈춤도 듣지 않아, 늦게 누른 승인이 다음 턴의 다른 요소에 닿을 수 있음을 찾았다. 그래서 방식을 바꿨다. 옮기기는 동작을 끊지 않는다. 읽기 · 사진 · 모델의 답만 바로 멈추고, 동작(`task.actions`)은 스스로 끝나게 둔 뒤 턴 사이에서만 옮긴다(제한 시간이 지나 남은 동작이 있으면 그것도 끝날 때까지 옮기기를 미룬다). 옮기기를 누른 뒤에는 새 동작을 시작하지 않는다. 보관함 값은 동작이 시작된 브라우저에만 넣는다. 2. **옮기기에 실패하면 반쯤 옮긴 채로 남는다.** 전에는 PC를 먼저 놓고 서버 브라우저를 열었다. 이제 서버 브라우저를 먼저 열고, 열린 뒤에 PC의 다른 탭을 닫고 PC를 놓는다. 열리지 않으면 아무것도 바뀌지 않고 PC에서 이어 간다. 카드 줄을 쓰지 못해도 옮기기는 이어지고, 모델은 옮긴 사실을 전달받는다. 3. **열이 없다는 판단이 굳어진다.** 배포 뒤에 076을 돌려도 재시작 전까지 설정이 잠겨 있었다. 이제 1분 뒤 다시 확인한다. 4. 끝나 가는 작업에는 「옮김」이라고 답하지 않는다. diff --git a/e2e/README.md b/e2e/README.md index 49873bd7..cc0de0cd 100644 --- a/e2e/README.md +++ b/e2e/README.md @@ -2993,7 +2993,7 @@ cd e2e && PGPT_URL=http://127.0.0.1:5273 API_URL=http://127.0.0.1:8873 npx playw | 기본값 「늘 서버」 → 서버(`why: 'person'`), 「PC 에서」라고 한 작업만 PC, 되돌리면 PC | 사용자 12-02 | 「설정 「브라우저 작업 위치」 = 늘 서버 …」 | 단위(Electron) | ✅ | | PC를 기다리며 줄 선 작업(`pcLine`)의 「서버에서 바로 시작」 → 앞 작업이 PC에서 진행되는 동안 서버에서 끝남 · `pcLine` 지워짐 | 사용자 12-02 | 「PC 브라우저를 기다리며 줄 선 작업 …」 | 단위(Electron) | ✅ | | 없는 작업 · 남의 작업은 옮기지 않음(false) | 설계 | `browserWhere.test.js` | 단위 | ✅ | -| 동작(느린 페이지 열기) 중에 옮기면 그 동작의 PC 호출 뒤에 PC를 놓고, 놓은 뒤에는 그 작업의 동작이 PC로 가지 않음 · 보관함 값은 동작이 시작된 브라우저에만 입력함(바뀌었으면 입력하지 않음) · 30초 안에 끝나지 않으면 옮기지 않음 | 독립 검토 #1 | `browser-local.test.js` 「검토 1: …」 | 단위(Electron) | ✅ | +| 동작(느린 페이지 열기) 중에 옮기면 그 동작은 끊지 않고 끝까지(답이 「stopped」가 아님) 한 뒤 옮기고, PC 를 놓은 뒤에는 그 작업의 동작이 PC 로 가지 않음 · 보관함 값은 동작이 시작된 브라우저에만 입력함(바뀌었으면 입력하지 않음) · 모델의 답을 기다리던 걸음은 바로 멈춤(「켜진 채」 시험) | 독립 검토 #1 · 확인 검토 | `browser-local.test.js` 「검토 1: …」 | 단위(Electron) | ✅ | | 서버 브라우저가 열리지 않으면 옮기지 않고 PC에서 끝냄 — PC는 놓이지 않음, 카드는 「내 PC」 그대로 · 카드 줄을 못 써도 옮기기는 이어짐 | 독립 검토 #2 | 「검토 2: …」 | 단위(Electron) | ✅ | | 열이 없다고 판단한 경우 1분 뒤 다시 확인함(배포 뒤 076을 돌려도 재시작 없이 켜짐) | 독립 검토 #3 | `browserWhere.test.js` 「검토 3: …」 | 단위(로컬 DB) | ✅ | | 끝나 가는 작업(turns 끝) · 자동 · 지은 턴의 `where`는 쓰지 않음 · 옮길 때 PC의 다른 탭도 닫음 · 저장 실패 뒤 설정 칸은 저장된 값으로 되돌림 | 독립 검토 #4 · #5 · #6 | 코드 읽기 | — | ◐(시험 없음 — 조건 한 줄씩) | diff --git a/openspec/specs/browser-handoff/spec.md b/openspec/specs/browser-handoff/spec.md index 549f318e..567e1655 100644 --- a/openspec/specs/browser-handoff/spec.md +++ b/openspec/specs/browser-handoff/spec.md @@ -487,7 +487,7 @@ - 기본값: 설정 › 계정 › 내 컴퓨터의 에이전트 「브라우저 작업 위치」 — 「PC 우선」(기본, 지금까지와 같음) · 「늘 서버」. 그 사람의 설정으로 서버에 저장하고(`pro_profile.browser_where`), 웹 · 휴대폰 · 앱 어디서나 바꾼다. 「늘 서버」면 그 사람의 작업은 PC가 켜져 있어도 서버 브라우저에서 돈다(`where.why: 'person'`). - 개별 작업에 대한 말: 채팅에서 그 작업을 서버에서 하라고 하면(「서버에서 해 줘」) 그 작업만 서버에서 돌고(`where.why: 'asked'`), PC에서 하라고 하면 기본값이 「늘 서버」여도 그 작업은 PC에서 돈다. 말을 읽는 것은 모델이다(낱말 규칙이 아니다). -- 작업 중인 카드의 「서버에서 이어서」: PC에서 일하는 작업의 카드(그림이 오지 않는 자리와 확장 화면)에서 누르면 하던 걸음을 바로 멈추고(그 걸음은 작업의 한 번으로 세지 않는다), PC의 브라우저를 놓고(실시간 화면을 멈추고 페이지를 비움), 서버 브라우저가 마지막 주소를 열어 같은 작업을 잇는다. 모델에게 「사람이 PC 에서 서버로 옮겼고, PC 의 로그인은 이 브라우저에 없다」고 알린다. 카드는 「서버 브라우저에서 이어서」를 표시한다. 사람을 기다리는 작업 · 이미 옮기는 중인 작업 · 서버에서 도는 작업은 옮기지 않고(답 `ok: false`), 화면은 「지금은 옮길 수 없어요 — …」라고 알린다. +- 작업 중인 카드의 「서버에서 이어서」: PC에서 일하는 작업의 카드(그림이 오지 않는 자리와 확장 화면)에서 누르면 다음 턴부터 서버 브라우저에서 한다. 페이지 읽기 · 화면 사진 · 모델의 답을 기다리던 중이면 그 걸음을 바로 멈춘다(작업의 한 번으로 세지 않는다). 하던 동작(누르기 · 입력 · 이동 · 그 안의 승인 · 메일로 오는 코드)은 끊지 않는다(MUST NOT). 그 동작이 스스로 끝난 뒤에 옮기므로, 동작의 남은 호출이 서버 브라우저나 PC 의 다음 작업 페이지에 닿지 않는다. 옮길 때는 서버 브라우저를 먼저 열고, 열린 뒤에 PC 에서 그 작업이 연 다른 탭을 닫고 PC 의 브라우저를 놓는다(실시간 화면을 멈추고 페이지를 비움). 서버 브라우저가 마지막 주소를 열어 같은 작업을 잇는다. 서버 브라우저가 열리지 않으면 아무것도 바꾸지 않고 PC 에서 잇는다. 모델에게 「사람이 PC 에서 서버로 옮겼고, PC 의 로그인은 이 브라우저에 없다」고 알린다. 카드는 「서버 브라우저에서 이어서」를 표시한다. 사람을 기다리는 작업 · 이미 옮기는 중인 작업 · 서버에서 도는 작업은 옮기지 않고(답 `ok: false`), 화면은 「지금은 옮길 수 없어요 — …」라고 알린다. - 줄 선 카드의 「서버에서 바로 시작」: PC의 브라우저를 기다리며 줄 선 작업(「PC 브라우저는 작업을 하나씩 해요 …」)은 그 단추를 누르면 자리가 나는 대로 서버 브라우저에서 시작한다. 규칙: @@ -499,7 +499,7 @@ #### Scenario: 진행 중인 PC 작업을 서버로 - **GIVEN** 윤태호의 「테스트 맥」에서 브라우저 작업이 가상 상점의 한 페이지에서 진행 중이다 - **WHEN** 휴대폰의 카드에서 「서버에서 이어서」를 누른다 -- **THEN** 그 걸음이 바로 멈추고 PC의 브라우저가 놓이며, 서버 브라우저가 같은 주소를 열어 작업이 끝까지 이어진다. 카드는 「서버 브라우저에서 이어서」를 표시한다 +- **THEN** 모델의 답을 기다리던 걸음은 바로 멈추고, 느린 페이지를 열던 동작은 끝까지 한 뒤에 PC 의 브라우저가 놓이며, 서버 브라우저가 같은 주소를 열어 작업이 끝까지 이어진다. 카드는 「서버 브라우저에서 이어서」를 표시한다 - **AND** 같은 카드에서 다시 하면 서버 브라우저에서 돈다 - **AND** 옮기는 중에 한 번 더 누르면 다시 옮기지 않는다(`server/test/browser-local.test.js`) diff --git a/server/lib/browser.js b/server/lib/browser.js index 8a3deed0..b937f0dd 100644 --- a/server/lib/browser.js +++ b/server/lib/browser.js @@ -1263,6 +1263,8 @@ async function runBrowserTaskNow({ userId, threadId, goal, startUrl, onAction, u if (skills) messages.push({ role: 'user', content: skills }) let { result, ended } = task.cancelled ? { result: { state: 'cancelled', summary: '' }, ended: true } : await drive(ln, task, { messages, onAction }) + // (its turns are over: a move to this server is not taken any more — moveToServer) + task.ending = true // (a file the last action started to download is in the result's account: at most two seconds for it) await downloadsKept(task) // its turns are over: words said from now on are not for it (they go the way of an ended task — lib/agent.js readResume) @@ -1418,28 +1420,24 @@ async function drive(s, task, { messages, onAction, stop = () => false }) { continue } // the person moved it from their PC to this server's browser (「서버에서 이어서」 on its card while it worked there — moveToServer) - if (task.moveTo === 'server') { + // Only between turns, with no action of this task still running: what is left of an action (a box looked up, then a value typed, an + // approval answered late, a mailed code) never lands on the next browser, nor on the next task's page on this PC (review 2026-12-02 #1 + // and its verification). An action left running after its time limit holds the move until it ends — the turns go on meanwhile. + if (task.moveTo === 'server' && task.actions?.size) { + if (!task.moveHeld) { task.moveHeld = true; say(task, L('하던 동작이 끝나면 서버 브라우저로 옮겨요', "Moving to the server's browser once the action under way ends")) } + } else if (task.moveTo === 'server') { task.moveTo = null + task.moveHeld = false // (moving: a second 「서버에서 이어서」 while this one is on its way is not another move) task.moving = true try { if (s.driver.kind === 'local' && !s.driver.lost) { - // the action under way ends first — the stop ended the wait for it, not the action: what is left of it (a box looked up, a - // value typed) must never land on the next browser, nor on the next task's page on this PC (review 2026-12-02 #1). One that - // does not end in time: the task stays on the PC, and says so - const settled = !task.acting || await Promise.race([task.acting.then(() => true, () => true), pause(MOVE_SETTLE.ms).then(() => false, () => false)]) - if (!settled) { - console.warn(`[browser] task ${task.id}: not moved — its action on the PC did not end within ${MOVE_SETTLE.ms} ms`) - jot(task, 'to_server_failed', { why: 'action' }) - say(task, L('지금 하던 동작이 끝나지 않아 PC 에서 이어서 해요', 'The action under way did not finish, so it goes on on the PC')) - } else { - const was = s.driver - const moved = await toServer(s, task, messages, { url: was.url(), device: was.device || {}, asked: true, from: was }) - .then(() => true, (e) => { console.warn(`[browser] task ${task.id}: to the server`, e.message); return false }) - if (!moved) { - jot(task, 'to_server_failed', { why: 'server' }) - say(task, L('서버 브라우저를 열지 못해 PC 에서 이어서 해요', "The server's browser didn't open, so it goes on on the PC")) - } + const was = s.driver + const moved = await toServer(s, task, messages, { url: was.url(), device: was.device || {}, asked: true, from: was }) + .then(() => true, (e) => { console.warn(`[browser] task ${task.id}: to the server`, e.message); return false }) + if (!moved) { + jot(task, 'to_server_failed', { why: 'server' }) + say(task, L('서버 브라우저를 열지 못해 PC 에서 이어서 해요', "The server's browser didn't open, so it goes on on the PC")) } } } finally { task.moving = false } @@ -1536,10 +1534,13 @@ async function drive(s, task, { messages, onAction, stop = () => false }) { try { // one action has a limit (a navigation it starts has its own on top); the ones that wait — on the page, on the // person — have their own ends and stop on 다시 시도 or 작업 취소 - // (task.acting: the action itself — a stop ends the wait for it, not the action: a move to this server waits for it — moveToServer) + // (a move to this server asked for meanwhile — moveToServer stopped the turn before its action: the action does not start) + if (signal.aborted) throw new StepError(signal.reason === 'retry' ? 'retry' : 'cancel', name) + // (task.actions: the actions still running — a stop ends the wait for one, not the action itself: a move to this server waits for + // every one of them to end — moveToServer · the loop's task.moveTo) const acting = act(s, task, name, args) - task.acting = acting - acting.then(() => {}, () => {}).finally(() => { if (task.acting === acting) task.acting = null }) + ;(task.actions ||= new Set()).add(acting) + acting.then(() => {}, () => {}).finally(() => task.actions.delete(acting)) out = await actWithin(task, acting, LONG_TOOLS.has(name) ? Infinity : STEP.actMs + (name === 'goto' ? STEP.navMs + STEP.settleMs : 0), signal, name) } catch (e) { if (isStop(e)) throw e @@ -2302,8 +2303,6 @@ const SPECIAL = new Set([OFFLINE, TO_SERVER, PC_BACK, GAVE_UP, 'cancelled']) export const choseLine = (label) => `The user chose: ${label}. Continue with that choice.` // how long a paused task waits for its PC before it stops (tests shorten it) export const OFFLINE_WAIT = { ms: 30 * 60 * 1000 } -// how long a move to this server (moveToServer) waits for the action under way on the PC to end (tests shorten it) -export const MOVE_SETTLE = { ms: 30_000 } // times a task reopens the browser of a PC that is still linked (its window gone, the app restarting it) before it pauses export const MAX_REOPENS = 3 function brokenReason(device, host) { @@ -2442,8 +2441,9 @@ export async function routeTo(userId, taskId, to) { return false } -// 「서버에서 이어서」 on the card of a task working on the person's PC: the step under way ends, and the next turn goes on in this server's -// browser from the page it was on (the loop: task.moveTo). A task in line for their PC's browser starts on this server instead. Not one that +// 「서버에서 이어서」 on the card of a task working on the person's PC: the next turn goes on in this server's browser from the page it was on +// (the loop: task.moveTo). A look, the model's picture or the model's answer under way stops at once (none of them changes the page); an +// action is never cut — it ends on its own and the move comes right after it. A task in line for their PC's browser starts on this server instead. Not one that // waits for the person — they answer it where it is (a sign-in on the PC is that PC's), nor one already on this server. → true when moved export async function moveToServer(userId, taskId) { const s = sessions.get(userId) @@ -2463,11 +2463,12 @@ export async function moveToServer(userId, taskId) { } const ln = laneById(s, taskId) const t = ln?.task - if (!t || t.cancelled || t.over || t.waiting || t.moveTo || t.moving || ln.driver?.kind !== 'local' || ln.driver.lost) return false + if (!t || t.cancelled || t.over || t.ending || t.waiting || t.moveTo || t.moving || ln.driver?.kind !== 'local' || ln.driver.lost) return false t.moveTo = 'server' say(t, L('서버 브라우저로 옮기는 중', "Moving to the server's browser")) - // (the step under way stops at once — it does not count as one of the agent's turns, like a PC that went off part way) - if (t.retry) { t.lostTurn = true; t.retry.abort('retry') } + // (a look, a picture or the model's answer under way stops at once — it does not count as one of the agent's turns, like a PC that went + // off part way; an action under way is left to end) + if (t.retry && !t.actions?.size) { t.lostTurn = true; t.retry.abort('retry') } return true } diff --git a/server/test/browser-local.test.js b/server/test/browser-local.test.js index d42bfc6a..d8a98344 100644 --- a/server/test/browser-local.test.js +++ b/server/test/browser-local.test.js @@ -357,31 +357,38 @@ test('PC 에서 일하는 작업의 「서버에서 이어서」(PC 는 켜진 assert.deepEqual(again.where, { kind: 'server', why: 'asked' }) }) -test('검토 1: 하던 동작(느린 페이지 열기)이 끝난 뒤에 PC 를 놓고 서버로 옮긴다 — 남은 동작이 서버 브라우저나 PC 의 다음 작업에 닿지 않는다', { skip }, async () => { +test('검토 1: 하던 동작(느린 페이지 열기)은 끊지 않고 끝까지 하고, 그 뒤에 서버로 옮긴다 — 놓은 PC 에는 그 작업의 동작이 가지 않는다', { skip }, async () => { if (!pcLink()) await startPc() const goal = '느린 동작 중 옮기기' const slow = `${site.url}/slow?ms=3000&from=move-slow` const from = (sentTo.get(user) || []).length + let result = '', told = '' const p = run(goal, [ ['goto', { url: slow }], - (b) => ['note', { text: lastSnap(b).url }], + (b) => { + // the goto's own answer, and what the agent was told after it + result = String([...b.messages].reverse().find((m) => m.role === 'tool')?.content || '') + told = b.messages.filter((m) => m.role === 'user' && typeof m.content === 'string' && m.content.includes('moved this task')).map((m) => m.content).join(' ') + return ['note', { text: lastSnap(b).url }] + }, ['finish', { summary: '서버에서 끝냈어요.' }], ]) - // the slow page is on its way on the PC + // the slow page is on its way on the PC: the move is asked for in the middle of that action assert.ok(await until(() => (sentTo.get(user) || []).slice(from).some((m) => m.includes('/slow?ms=3000'))), 'PC 가 느린 페이지를 열기 시작했다') const c = await card(goal) - const movedAt = Date.now() assert.equal(await browser.routeTo(user, c.id, 'server'), true) const r = await p assert.equal(r.state, 'done', JSON.stringify(r).slice(0, 300)) assert.equal(r.where.kind, 'server') - // (the PC is let go after the action's own calls — the desktop runs them in order — and none of that action comes after it) + assert.doesNotMatch(result, /^stopped/, `그 동작은 끊기지 않았다: ${result.slice(0, 120)}`) + assert.match(told, /moved this task from their PC's browser/) + assert.equal(r.notes.at(-1), slow, '서버 브라우저가 같은 페이지를 열었다') + // (the PC is let go after that action — and no action of this task goes to it after) const sent = (sentTo.get(user) || []).slice(from).map((m) => JSON.parse(m)) const idle = sent.findIndex((m) => m.op === 'idle') const nav = sent.findIndex((m) => m.op === 'navigate' && String(m.args?.url || '').includes('/slow')) assert.ok(nav >= 0 && idle > nav, `느린 페이지 열기 뒤에 놓았다: ${sent.map((m) => m.op).join(',')}`) - assert.ok(!sent.slice(idle + 1).some((m) => ['click', 'fill', 'fillSecret', 'navigate', 'type', 'key'].includes(m.op)), `놓은 뒤 PC 에 간 동작 없음: ${sent.slice(idle + 1).map((m) => m.op).join(',')}`) - assert.ok(r.stats.ms >= 2500 || Date.now() - movedAt >= 1500, '느린 페이지가 끝날 때까지 기다렸다') + assert.ok(!sent.slice(idle + 1).some((m) => ['click', 'fill', 'fillSecret', 'navigate', 'type', 'key', 'attach'].includes(m.op)), `놓은 뒤 PC 에 간 동작 없음: ${sent.slice(idle + 1).map((m) => m.op).join(',')}`) }) test('검토 2: 서버 브라우저가 열리지 않으면 옮기지 않고 PC 에서 이어서 끝낸다 — PC 는 놓이지 않는다', { skip }, async () => { From 64b6aa4b845a8cb5de19d259334e5a32fe8d5f13 Mon Sep 17 00:00:00 2001 From: jinyoung Date: Wed, 2 Dec 2026 12:49:41 +0900 Subject: [PATCH 09/12] =?UTF-8?q?docs(browser):=20=EC=98=AE=EA=B8=B0?= =?UTF-8?q?=EA=B8=B0=20=EA=B7=9C=EC=B9=99=20=EC=A4=84=20=EC=9C=A4=EB=AC=B8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-Authored-By: Claude Opus 5.5 --- docs/browser-where/design.md | 2 +- e2e/README.md | 2 +- openspec/specs/browser-handoff/spec.md | 4 ++-- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/docs/browser-where/design.md b/docs/browser-where/design.md index 5ec1c821..5885ba96 100644 --- a/docs/browser-where/design.md +++ b/docs/browser-where/design.md @@ -48,7 +48,7 @@ ### 독립 검토 반영 검토자 한 명이 바뀐 코드를 처음부터 읽었다. 고친 내용: -1. **옮길 때 하던 동작이 남는다(심각).** 멈추면 동작을 기다리기만 끝내고 동작 자체는 계속된다. 그래서 남은 호출(상자 찾기 다음의 보관함 값 입력)이 새 서버 브라우저의 다른 사이트 페이지나 그사이 PC에서 시작한 다음 작업의 페이지에 닿을 수 있었다. 처음 고친 판은 그 동작이 끝나기를 30초까지 기다렸다. 그런데 확인 검토에서 동작 안의 승인 카드 · 메일로 오는 코드 기다림은 30초를 넘고 멈춤도 듣지 않아, 늦게 누른 승인이 다음 턴의 다른 요소에 닿을 수 있음을 찾았다. 그래서 방식을 바꿨다. 옮기기는 동작을 끊지 않는다. 읽기 · 사진 · 모델의 답만 바로 멈추고, 동작(`task.actions`)은 스스로 끝나게 둔 뒤 턴 사이에서만 옮긴다(제한 시간이 지나 남은 동작이 있으면 그것도 끝날 때까지 옮기기를 미룬다). 옮기기를 누른 뒤에는 새 동작을 시작하지 않는다. 보관함 값은 동작이 시작된 브라우저에만 넣는다. +1. **옮길 때 하던 동작이 남는다(심각).** 멈추면 동작을 기다리는 것만 끝나고 동작 자체는 계속된다. 그래서 남은 호출(상자 찾기 다음의 보관함 값 입력)이 새 서버 브라우저의 다른 사이트 페이지나 그사이 PC에서 시작한 다음 작업의 페이지에 닿을 수 있었다. 처음 고친 판은 그 동작이 끝나기를 30초까지 기다렸다. 그런데 확인 검토에서 동작 안의 승인 카드 · 메일로 오는 코드를 기다리는 시간이 30초를 넘고 멈춤도 작동하지 않아, 늦게 누른 승인이 다음 턴의 다른 요소에 닿을 수 있음을 발견했다. 그래서 방식을 바꿨다. 옮기기는 동작을 끊지 않는다. 읽기 · 사진 · 모델의 답만 바로 멈추고, 동작(`task.actions`)은 스스로 끝나게 둔 뒤 턴 사이에서만 옮긴다(제한 시간이 지나 남은 동작이 있으면 그것도 끝날 때까지 옮기기를 미룬다). 옮기기를 누른 뒤에는 새 동작을 시작하지 않는다. 보관함 값은 동작이 시작된 브라우저에만 넣는다. 2. **옮기기에 실패하면 반쯤 옮긴 채로 남는다.** 전에는 PC를 먼저 놓고 서버 브라우저를 열었다. 이제 서버 브라우저를 먼저 열고, 열린 뒤에 PC의 다른 탭을 닫고 PC를 놓는다. 열리지 않으면 아무것도 바뀌지 않고 PC에서 이어 간다. 카드 줄을 쓰지 못해도 옮기기는 이어지고, 모델은 옮긴 사실을 전달받는다. 3. **열이 없다는 판단이 굳어진다.** 배포 뒤에 076을 돌려도 재시작 전까지 설정이 잠겨 있었다. 이제 1분 뒤 다시 확인한다. 4. 끝나 가는 작업에는 「옮김」이라고 답하지 않는다. diff --git a/e2e/README.md b/e2e/README.md index cc0de0cd..b280d77d 100644 --- a/e2e/README.md +++ b/e2e/README.md @@ -2993,7 +2993,7 @@ cd e2e && PGPT_URL=http://127.0.0.1:5273 API_URL=http://127.0.0.1:8873 npx playw | 기본값 「늘 서버」 → 서버(`why: 'person'`), 「PC 에서」라고 한 작업만 PC, 되돌리면 PC | 사용자 12-02 | 「설정 「브라우저 작업 위치」 = 늘 서버 …」 | 단위(Electron) | ✅ | | PC를 기다리며 줄 선 작업(`pcLine`)의 「서버에서 바로 시작」 → 앞 작업이 PC에서 진행되는 동안 서버에서 끝남 · `pcLine` 지워짐 | 사용자 12-02 | 「PC 브라우저를 기다리며 줄 선 작업 …」 | 단위(Electron) | ✅ | | 없는 작업 · 남의 작업은 옮기지 않음(false) | 설계 | `browserWhere.test.js` | 단위 | ✅ | -| 동작(느린 페이지 열기) 중에 옮기면 그 동작은 끊지 않고 끝까지(답이 「stopped」가 아님) 한 뒤 옮기고, PC 를 놓은 뒤에는 그 작업의 동작이 PC 로 가지 않음 · 보관함 값은 동작이 시작된 브라우저에만 입력함(바뀌었으면 입력하지 않음) · 모델의 답을 기다리던 걸음은 바로 멈춤(「켜진 채」 시험) | 독립 검토 #1 · 확인 검토 | `browser-local.test.js` 「검토 1: …」 | 단위(Electron) | ✅ | +| 동작(느린 페이지 열기) 중에 옮기면 그 동작은 끊지 않고 끝까지 마친 뒤(답이 「stopped」가 아님) 옮기고, PC 사용을 끝낸 뒤에는 그 작업의 동작이 PC로 가지 않음 · 보관함 값은 동작이 시작된 브라우저에만 입력함(바뀌었으면 입력하지 않음) · 모델의 답을 기다리던 단계는 바로 멈춤(「켜진 채」 시험) | 독립 검토 #1 · 확인 검토 | `browser-local.test.js` 「검토 1: …」 | 단위(Electron) | ✅ | | 서버 브라우저가 열리지 않으면 옮기지 않고 PC에서 끝냄 — PC는 놓이지 않음, 카드는 「내 PC」 그대로 · 카드 줄을 못 써도 옮기기는 이어짐 | 독립 검토 #2 | 「검토 2: …」 | 단위(Electron) | ✅ | | 열이 없다고 판단한 경우 1분 뒤 다시 확인함(배포 뒤 076을 돌려도 재시작 없이 켜짐) | 독립 검토 #3 | `browserWhere.test.js` 「검토 3: …」 | 단위(로컬 DB) | ✅ | | 끝나 가는 작업(turns 끝) · 자동 · 지은 턴의 `where`는 쓰지 않음 · 옮길 때 PC의 다른 탭도 닫음 · 저장 실패 뒤 설정 칸은 저장된 값으로 되돌림 | 독립 검토 #4 · #5 · #6 | 코드 읽기 | — | ◐(시험 없음 — 조건 한 줄씩) | diff --git a/openspec/specs/browser-handoff/spec.md b/openspec/specs/browser-handoff/spec.md index 567e1655..48ae852e 100644 --- a/openspec/specs/browser-handoff/spec.md +++ b/openspec/specs/browser-handoff/spec.md @@ -487,7 +487,7 @@ - 기본값: 설정 › 계정 › 내 컴퓨터의 에이전트 「브라우저 작업 위치」 — 「PC 우선」(기본, 지금까지와 같음) · 「늘 서버」. 그 사람의 설정으로 서버에 저장하고(`pro_profile.browser_where`), 웹 · 휴대폰 · 앱 어디서나 바꾼다. 「늘 서버」면 그 사람의 작업은 PC가 켜져 있어도 서버 브라우저에서 돈다(`where.why: 'person'`). - 개별 작업에 대한 말: 채팅에서 그 작업을 서버에서 하라고 하면(「서버에서 해 줘」) 그 작업만 서버에서 돌고(`where.why: 'asked'`), PC에서 하라고 하면 기본값이 「늘 서버」여도 그 작업은 PC에서 돈다. 말을 읽는 것은 모델이다(낱말 규칙이 아니다). -- 작업 중인 카드의 「서버에서 이어서」: PC에서 일하는 작업의 카드(그림이 오지 않는 자리와 확장 화면)에서 누르면 다음 턴부터 서버 브라우저에서 한다. 페이지 읽기 · 화면 사진 · 모델의 답을 기다리던 중이면 그 걸음을 바로 멈춘다(작업의 한 번으로 세지 않는다). 하던 동작(누르기 · 입력 · 이동 · 그 안의 승인 · 메일로 오는 코드)은 끊지 않는다(MUST NOT). 그 동작이 스스로 끝난 뒤에 옮기므로, 동작의 남은 호출이 서버 브라우저나 PC 의 다음 작업 페이지에 닿지 않는다. 옮길 때는 서버 브라우저를 먼저 열고, 열린 뒤에 PC 에서 그 작업이 연 다른 탭을 닫고 PC 의 브라우저를 놓는다(실시간 화면을 멈추고 페이지를 비움). 서버 브라우저가 마지막 주소를 열어 같은 작업을 잇는다. 서버 브라우저가 열리지 않으면 아무것도 바꾸지 않고 PC 에서 잇는다. 모델에게 「사람이 PC 에서 서버로 옮겼고, PC 의 로그인은 이 브라우저에 없다」고 알린다. 카드는 「서버 브라우저에서 이어서」를 표시한다. 사람을 기다리는 작업 · 이미 옮기는 중인 작업 · 서버에서 도는 작업은 옮기지 않고(답 `ok: false`), 화면은 「지금은 옮길 수 없어요 — …」라고 알린다. +- 작업 중인 카드의 「서버에서 이어서」: PC에서 진행 중인 작업의 카드(그림이 표시되지 않는 자리와 확장 화면)에서 누르면 다음 턴부터 서버 브라우저에서 진행한다. 페이지 읽기 · 화면 사진 · 모델의 답을 기다리던 중이면 그 단계를 바로 멈춘다(작업 횟수로 세지 않는다). 하던 동작(누르기 · 입력 · 이동 · 그 안의 승인 · 메일로 오는 코드)은 끊지 않는다(MUST NOT). 그 동작이 스스로 끝난 뒤에 옮기므로, 동작의 남은 호출이 서버 브라우저나 PC의 다음 작업 페이지에 닿지 않는다. 옮길 때는 서버 브라우저를 먼저 열고, 열린 뒤에 PC에서 그 작업이 연 다른 탭을 닫고 PC의 브라우저 사용을 끝낸다(실시간 화면을 멈추고 페이지를 비움). 서버 브라우저가 마지막 주소를 열어 같은 작업을 잇는다. 서버 브라우저가 열리지 않으면 아무것도 바꾸지 않고 PC에서 잇는다. 모델에게 「사람이 PC 에서 서버로 옮겼고, PC 의 로그인은 이 브라우저에 없다」고 알린다. 카드는 「서버 브라우저에서 이어서」를 표시한다. 사람을 기다리는 작업 · 이미 옮기는 중인 작업 · 서버에서 실행 중인 작업은 옮기지 않고(답 `ok: false`), 화면은 「지금은 옮길 수 없어요 — …」라고 알린다. - 줄 선 카드의 「서버에서 바로 시작」: PC의 브라우저를 기다리며 줄 선 작업(「PC 브라우저는 작업을 하나씩 해요 …」)은 그 단추를 누르면 자리가 나는 대로 서버 브라우저에서 시작한다. 규칙: @@ -499,7 +499,7 @@ #### Scenario: 진행 중인 PC 작업을 서버로 - **GIVEN** 윤태호의 「테스트 맥」에서 브라우저 작업이 가상 상점의 한 페이지에서 진행 중이다 - **WHEN** 휴대폰의 카드에서 「서버에서 이어서」를 누른다 -- **THEN** 모델의 답을 기다리던 걸음은 바로 멈추고, 느린 페이지를 열던 동작은 끝까지 한 뒤에 PC 의 브라우저가 놓이며, 서버 브라우저가 같은 주소를 열어 작업이 끝까지 이어진다. 카드는 「서버 브라우저에서 이어서」를 표시한다 +- **THEN** 모델의 답을 기다리던 단계는 바로 멈추고, 느린 페이지를 열던 동작은 끝까지 마친 뒤에 PC의 브라우저 사용이 끝나며, 서버 브라우저가 같은 주소를 열어 작업이 끝까지 이어진다. 카드는 「서버 브라우저에서 이어서」를 표시한다 - **AND** 같은 카드에서 다시 하면 서버 브라우저에서 돈다 - **AND** 옮기는 중에 한 번 더 누르면 다시 옮기지 않는다(`server/test/browser-local.test.js`) From 4e18b26ac1a2c317c408f2bd2f5bd5400e089404 Mon Sep 17 00:00:00 2001 From: jinyoung Date: Wed, 2 Dec 2026 13:00:05 +0900 Subject: [PATCH 10/12] =?UTF-8?q?fix(browser):=20=ED=99=95=EC=9D=B8=20?= =?UTF-8?q?=EA=B2=80=ED=86=A0=20=E2=80=94=20=EC=9D=BD=EA=B8=B0=EB=A7=8C=20?= =?UTF-8?q?=ED=95=98=EB=8A=94=20=EA=B8=B0=EB=8B=A4=EB=A6=BC=EC=9D=80=20?= =?UTF-8?q?=EC=98=AE=EA=B8=B0=EA=B8=B0=EB=A1=9C=20=EB=81=9D=EB=82=A8=20?= =?UTF-8?q?=C2=B7=20=EB=81=9D=EB=82=98=EC=A7=80=20=EC=95=8A=EB=8A=94=20?= =?UTF-8?q?=EB=8F=99=EC=9E=91=EC=9D=80=202=EB=B6=84=20=EB=92=A4=20?= =?UTF-8?q?=EC=98=AE=EA=B8=B0=EA=B8=B0=EB=A5=BC=20=EA=B7=B8=EB=A7=8C?= =?UTF-8?q?=EB=91=A0=20=C2=B7=20=ED=95=9C=EB=8F=84=EB=B3=B4=EB=8B=A4=20?= =?UTF-8?q?=EC=98=AE=EA=B8=B0=EA=B8=B0=EA=B0=80=20=EB=A8=BC=EC=A0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - waitForPage · 다른 작업의 로그인 기다림: task.moveTo 면 곧 끝남(「stopped: the person moved this task …」) - MOVE_HOLD(2분): 아직 도는 동작이 옮기기를 붙잡으면 그만두고 「하던 동작이 끝나지 않아 서버로 옮기지 못했어요」 - 루프 맨 앞에서 옮기기 → 한도 확인: 마지막 동작 중에 누른 옮기기가 버려지지 않음 - 시험 「확인 검토: 페이지를 기다리는 동작 …」(진짜 Electron) Co-Authored-By: Claude Opus 5.5 --- e2e/README.md | 1 + server/lib/browser.js | 65 +++++++++++++++++++------------ server/test/browser-local.test.js | 22 +++++++++++ 3 files changed, 63 insertions(+), 25 deletions(-) diff --git a/e2e/README.md b/e2e/README.md index b280d77d..967a00d6 100644 --- a/e2e/README.md +++ b/e2e/README.md @@ -2995,6 +2995,7 @@ cd e2e && PGPT_URL=http://127.0.0.1:5273 API_URL=http://127.0.0.1:8873 npx playw | 없는 작업 · 남의 작업은 옮기지 않음(false) | 설계 | `browserWhere.test.js` | 단위 | ✅ | | 동작(느린 페이지 열기) 중에 옮기면 그 동작은 끊지 않고 끝까지 마친 뒤(답이 「stopped」가 아님) 옮기고, PC 사용을 끝낸 뒤에는 그 작업의 동작이 PC로 가지 않음 · 보관함 값은 동작이 시작된 브라우저에만 입력함(바뀌었으면 입력하지 않음) · 모델의 답을 기다리던 단계는 바로 멈춤(「켜진 채」 시험) | 독립 검토 #1 · 확인 검토 | `browser-local.test.js` 「검토 1: …」 | 단위(Electron) | ✅ | | 서버 브라우저가 열리지 않으면 옮기지 않고 PC에서 끝냄 — PC는 놓이지 않음, 카드는 「내 PC」 그대로 · 카드 줄을 못 써도 옮기기는 이어짐 | 독립 검토 #2 | 「검토 2: …」 | 단위(Electron) | ✅ | +| 페이지를 기다리는 동작(`wait_for_page` 5분) · 다른 작업의 로그인 기다림은 읽기만 하므로 옮기기를 누르면 곧 끝나고(15초 안) 옮김 · 아직 도는 동작이 끝나지 않으면 2분 뒤 옮기기를 그만두고 그렇다고 말함 · 동작 한도의 마지막 동작 중에 누른 옮기기도 한도보다 먼저 처리 | 확인 검토 | `browser-local.test.js` 「확인 검토: …」(기다림) · 코드 읽기(2분 · 한도 순서) | 단위(Electron) | ◐(기다림만 시험) | | 열이 없다고 판단한 경우 1분 뒤 다시 확인함(배포 뒤 076을 돌려도 재시작 없이 켜짐) | 독립 검토 #3 | `browserWhere.test.js` 「검토 3: …」 | 단위(로컬 DB) | ✅ | | 끝나 가는 작업(turns 끝) · 자동 · 지은 턴의 `where`는 쓰지 않음 · 옮길 때 PC의 다른 탭도 닫음 · 저장 실패 뒤 설정 칸은 저장된 값으로 되돌림 | 독립 검토 #4 · #5 · #6 | 코드 읽기 | — | ◐(시험 없음 — 조건 한 줄씩) | | 390 확장 화면: 「서버에서 이어서」 → `route {taskId, to:'server'}` · 단추 다섯 개가 모두 한 줄 높이(40px) · 모두 화면 안에 표시(둘째 줄) · 옆으로 넘치지 않음 | 사용자 12-02 | F-BW-01 | feature | ✅ | diff --git a/server/lib/browser.js b/server/lib/browser.js index b937f0dd..069f322c 100644 --- a/server/lib/browser.js +++ b/server/lib/browser.js @@ -1398,6 +1398,40 @@ async function drive(s, task, { messages, onAction, stop = () => false }) { task.told ||= [] try { for (let turn = 0; !task.cancelled; turn++) { + // Only between turns, with no action of this task still running: what is left of an action (a box looked up, then a value typed, an + // approval answered late, a mailed code) never lands on the next browser, nor on the next task's page on this PC (review 2026-12-02 #1 + // and its verification). An action left running after its time limit holds the move until it ends — the turns go on meanwhile. + // (before the budget: a move asked for during the last action of the budget is not dropped — the task ends on this server) + // An action that never ends (cut by 다시 시도 or words in the chat, its card replaced) holds the move for at most MOVE_HOLD: then the + // move is given up, saying so — never 「옮기는 중」 for good + if (task.moveTo === 'server' && task.actions?.size && !s.driver.lost) { + task.moveHeldAt ||= Date.now() + if (Date.now() - task.moveHeldAt > MOVE_HOLD.ms) { + task.moveTo = null + task.moveHeldAt = 0 + jot(task, 'to_server_failed', { why: 'action' }) + say(task, L('하던 동작이 끝나지 않아 서버로 옮기지 못했어요 — PC 에서 이어서 해요', "The action under way didn't end, so it wasn't moved — it goes on on the PC")) + } else if (!task.moveHeld) { task.moveHeld = true; say(task, L('하던 동작이 끝나면 서버 브라우저로 옮겨요', "Moving to the server's browser once the action under way ends")) } + } else if (task.moveTo === 'server' && !s.driver.lost) { + task.moveTo = null + task.moveHeld = false + task.moveHeldAt = 0 + // (moving: a second 「서버에서 이어서」 while this one is on its way is not another move) + task.moving = true + try { + if (s.driver.kind === 'local' && !s.driver.lost) { + const was = s.driver + const moved = await toServer(s, task, messages, { url: was.url(), device: was.device || {}, asked: true, from: was }) + .then(() => true, (e) => { console.warn(`[browser] task ${task.id}: to the server`, e.message); return false }) + if (!moved) { + jot(task, 'to_server_failed', { why: 'server' }) + say(task, L('서버 브라우저를 열지 못해 PC 에서 이어서 해요', "The server's browser didn't open, so it goes on on the PC")) + } + } + } finally { task.moving = false } + turn-- + continue + } // the budget: BLOCK actions, one more block at a time while the last one made progress (lib/browserProgress.js), never past HARD if (turn >= task.budget) { const b = budgetAfter(task.trail, turn, task.budget) @@ -1420,30 +1454,6 @@ async function drive(s, task, { messages, onAction, stop = () => false }) { continue } // the person moved it from their PC to this server's browser (「서버에서 이어서」 on its card while it worked there — moveToServer) - // Only between turns, with no action of this task still running: what is left of an action (a box looked up, then a value typed, an - // approval answered late, a mailed code) never lands on the next browser, nor on the next task's page on this PC (review 2026-12-02 #1 - // and its verification). An action left running after its time limit holds the move until it ends — the turns go on meanwhile. - if (task.moveTo === 'server' && task.actions?.size) { - if (!task.moveHeld) { task.moveHeld = true; say(task, L('하던 동작이 끝나면 서버 브라우저로 옮겨요', "Moving to the server's browser once the action under way ends")) } - } else if (task.moveTo === 'server') { - task.moveTo = null - task.moveHeld = false - // (moving: a second 「서버에서 이어서」 while this one is on its way is not another move) - task.moving = true - try { - if (s.driver.kind === 'local' && !s.driver.lost) { - const was = s.driver - const moved = await toServer(s, task, messages, { url: was.url(), device: was.device || {}, asked: true, from: was }) - .then(() => true, (e) => { console.warn(`[browser] task ${task.id}: to the server`, e.message); return false }) - if (!moved) { - jot(task, 'to_server_failed', { why: 'server' }) - say(task, L('서버 브라우저를 열지 못해 PC 에서 이어서 해요', "The server's browser didn't open, so it goes on on the PC")) - } - } - } finally { task.moving = false } - turn-- - continue - } // this server's browser closed under the task (it crashed: every tab of it went with it): the task ends saying so — the next task opens // the browser again if (s.driver.kind === 'server' && (s.driver.closed || (s.gen != null && s.driver.browser?.gen !== s.gen))) { @@ -2303,6 +2313,8 @@ const SPECIAL = new Set([OFFLINE, TO_SERVER, PC_BACK, GAVE_UP, 'cancelled']) export const choseLine = (label) => `The user chose: ${label}. Continue with that choice.` // how long a paused task waits for its PC before it stops (tests shorten it) export const OFFLINE_WAIT = { ms: 30 * 60 * 1000 } +// how long a move to this server waits for an action of the task that is still running before it is given up (tests shorten it) +export const MOVE_HOLD = { ms: 2 * 60 * 1000 } // times a task reopens the browser of a PC that is still linked (its window gone, the app restarting it) before it pauses export const MAX_REOPENS = 3 function brokenReason(device, host) { @@ -2531,6 +2543,8 @@ async function waitForPage(s, task, a) { for (let n = 0; ; n++) { if (task.cancelled) return 'cancelled' if (task.over?.()) return 'done: this task is over' + // (only reads the page: a move to this server ends it — moveToServer) + if (task.moveTo) return 'stopped: the person moved this task to another browser; look at the page again' const text = await pageWords(s) if (text !== null && until && text.includes(until)) return `done: "${until}" is on the page now` if (text !== null && gone && !text.includes(gone)) return `done: "${gone}" is no longer on the page` @@ -3065,7 +3079,8 @@ async function signInTurn(ln, host) { task?.dog?.hold() say(task, L(`'${other.task?.title || other.title}' 작업이 ${k}에 로그인하는 중이라 기다리는 중`, `Waiting: '${other.task?.title || other.title}' is signing in to ${k}`)) try { - while ((other = holder()) && Date.now() - t0 < SIGNIN_WAIT.ms) await pause(SIGNIN_WAIT.everyMs, task?.signal) + // (a move to this server ends the wait: the sign-in it waited for is on the PC's browser — moveToServer) + while ((other = holder()) && !task?.moveTo && Date.now() - t0 < SIGNIN_WAIT.ms) await pause(SIGNIN_WAIT.everyMs, task?.signal) } finally { task?.dog?.go('read', L('페이지 읽기', 'reading the page')) } console.log(`[browser] task ${task?.id}: waited ${Math.round((Date.now() - t0) / 1000)} s for another task's sign-in to ${k}`) } diff --git a/server/test/browser-local.test.js b/server/test/browser-local.test.js index d8a98344..bfd50452 100644 --- a/server/test/browser-local.test.js +++ b/server/test/browser-local.test.js @@ -391,6 +391,28 @@ test('검토 1: 하던 동작(느린 페이지 열기)은 끊지 않고 끝까 assert.ok(!sent.slice(idle + 1).some((m) => ['click', 'fill', 'fillSecret', 'navigate', 'type', 'key', 'attach'].includes(m.op)), `놓은 뒤 PC 에 간 동작 없음: ${sent.slice(idle + 1).map((m) => m.op).join(',')}`) }) +test('확인 검토: 페이지를 기다리는 동작(wait_for_page, 5분)은 옮기기를 누르면 곧 끝나고 서버로 옮긴다 — 읽기만 하는 기다림은 옮기기를 붙잡지 않는다', { skip }, async () => { + if (!pcLink()) await startPc() + const goal = '기다리는 중 옮기기' + let result = '' + const p = run(goal, [ + ['wait_for_page', { minutes: 5, until_text: '절대 나오지 않는 글' }], + (b) => { result = String([...b.messages].reverse().find((m) => m.role === 'tool')?.content || ''); return ['note', { text: lastSnap(b).url }] }, + ['finish', { summary: '서버에서 끝냈어요.' }], + ], { startUrl: `${site.url}/shop?from=move-wait` }) + // the wait is under way on the PC (the model asked for it) + const c = await until(async () => { const x = await card(goal); return x?.content?.where?.kind === 'local' && scripts[goal].i >= 1 ? x : null }) + assert.ok(c) + await sleep(1500) + const t0 = Date.now() + assert.equal(await browser.routeTo(user, c.id, 'server'), true) + const r = await p + assert.equal(r.state, 'done', JSON.stringify(r).slice(0, 300)) + assert.equal(r.where.kind, 'server') + assert.ok(Date.now() - t0 < 15_000, `5분 기다림을 다 채우지 않았다(${Date.now() - t0} ms)`) + assert.match(result, /^stopped: the person moved this task/, result.slice(0, 120)) +}) + test('검토 2: 서버 브라우저가 열리지 않으면 옮기지 않고 PC 에서 이어서 끝낸다 — PC 는 놓이지 않는다', { skip }, async () => { if (!pcLink()) await startPc() const { ServerDriver } = await import('../lib/browserServer.js') From 664010865358090f076a58c9bf3056cd82e6ef85 Mon Sep 17 00:00:00 2001 From: jinyoung Date: Wed, 2 Dec 2026 13:00:15 +0900 Subject: [PATCH 11/12] =?UTF-8?q?docs(browser):=20=ED=99=95=EC=9D=B8=20?= =?UTF-8?q?=EA=B2=80=ED=86=A0=20=EC=A4=84=20=EC=9C=A4=EB=AC=B8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-Authored-By: Claude Opus 5.5 --- e2e/README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/e2e/README.md b/e2e/README.md index 967a00d6..4d513bdb 100644 --- a/e2e/README.md +++ b/e2e/README.md @@ -2995,7 +2995,7 @@ cd e2e && PGPT_URL=http://127.0.0.1:5273 API_URL=http://127.0.0.1:8873 npx playw | 없는 작업 · 남의 작업은 옮기지 않음(false) | 설계 | `browserWhere.test.js` | 단위 | ✅ | | 동작(느린 페이지 열기) 중에 옮기면 그 동작은 끊지 않고 끝까지 마친 뒤(답이 「stopped」가 아님) 옮기고, PC 사용을 끝낸 뒤에는 그 작업의 동작이 PC로 가지 않음 · 보관함 값은 동작이 시작된 브라우저에만 입력함(바뀌었으면 입력하지 않음) · 모델의 답을 기다리던 단계는 바로 멈춤(「켜진 채」 시험) | 독립 검토 #1 · 확인 검토 | `browser-local.test.js` 「검토 1: …」 | 단위(Electron) | ✅ | | 서버 브라우저가 열리지 않으면 옮기지 않고 PC에서 끝냄 — PC는 놓이지 않음, 카드는 「내 PC」 그대로 · 카드 줄을 못 써도 옮기기는 이어짐 | 독립 검토 #2 | 「검토 2: …」 | 단위(Electron) | ✅ | -| 페이지를 기다리는 동작(`wait_for_page` 5분) · 다른 작업의 로그인 기다림은 읽기만 하므로 옮기기를 누르면 곧 끝나고(15초 안) 옮김 · 아직 도는 동작이 끝나지 않으면 2분 뒤 옮기기를 그만두고 그렇다고 말함 · 동작 한도의 마지막 동작 중에 누른 옮기기도 한도보다 먼저 처리 | 확인 검토 | `browser-local.test.js` 「확인 검토: …」(기다림) · 코드 읽기(2분 · 한도 순서) | 단위(Electron) | ◐(기다림만 시험) | +| 페이지를 기다리는 동작(`wait_for_page` 5분) · 다른 작업의 로그인 기다림은 읽기만 하므로 옮기기를 누르면 곧 끝나고(15초 안) 옮김 · 아직 실행 중인 동작이 끝나지 않으면 2분 뒤 옮기기를 그만두고 그 사실을 알림 · 동작 한도의 마지막 동작 중에 누른 옮기기도 한도보다 먼저 처리 | 확인 검토 | `browser-local.test.js` 「확인 검토: …」(기다림) · 코드 읽기(2분 · 한도 순서) | 단위(Electron) | ◐(기다림만 시험) | | 열이 없다고 판단한 경우 1분 뒤 다시 확인함(배포 뒤 076을 돌려도 재시작 없이 켜짐) | 독립 검토 #3 | `browserWhere.test.js` 「검토 3: …」 | 단위(로컬 DB) | ✅ | | 끝나 가는 작업(turns 끝) · 자동 · 지은 턴의 `where`는 쓰지 않음 · 옮길 때 PC의 다른 탭도 닫음 · 저장 실패 뒤 설정 칸은 저장된 값으로 되돌림 | 독립 검토 #4 · #5 · #6 | 코드 읽기 | — | ◐(시험 없음 — 조건 한 줄씩) | | 390 확장 화면: 「서버에서 이어서」 → `route {taskId, to:'server'}` · 단추 다섯 개가 모두 한 줄 높이(40px) · 모두 화면 안에 표시(둘째 줄) · 옆으로 넘치지 않음 | 사용자 12-02 | F-BW-01 | feature | ✅ | From 91578942e0aff53883027c02c367a2c817314bde Mon Sep 17 00:00:00 2001 From: jinyoung Date: Wed, 2 Dec 2026 13:00:26 +0900 Subject: [PATCH 12/12] =?UTF-8?q?docs(browser):=20=EC=84=A4=EA=B3=84=20?= =?UTF-8?q?=EB=85=B8=ED=8A=B8=EC=97=90=20=EB=91=90=20=EB=B2=88=EC=A7=B8=20?= =?UTF-8?q?=ED=99=95=EC=9D=B8=20=EA=B2=80=ED=86=A0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-Authored-By: Claude Opus 5.5 --- docs/browser-where/design.md | 1 + 1 file changed, 1 insertion(+) diff --git a/docs/browser-where/design.md b/docs/browser-where/design.md index 5885ba96..42946ced 100644 --- a/docs/browser-where/design.md +++ b/docs/browser-where/design.md @@ -54,6 +54,7 @@ 4. 끝나 가는 작업에는 「옮김」이라고 답하지 않는다. 5. 옮길 때 그 작업이 PC에 연 다른 탭(로그인 창 같은 탭)도 닫는다. 6. 사람이 직접 입력하지 않은 턴(지은 말 · 자동)의 `where`는 쓰지 않는다. +- 두 번째 확인 검토: 동작을 끊지 않게 하자, 읽기만 하는 긴 기다림(페이지 기다리기는 30분까지, 다른 작업의 로그인은 10분까지)이 옮기기를 붙잡았다. 이제 이 둘은 옮기기를 누르면 곧 끝난다. 끝나지 않는 동작(「다시 시도」나 채팅의 말로 끊긴 뒤 카드가 바뀐 것)이 옮기기를 영영 붙잡지 않도록, 2분이 지나면 옮기기를 그만두고 그렇다고 알린다. 동작 한도의 마지막 동작 중에 누른 옮기기는 한도 확인보다 먼저 처리한다. - 작은 수정: 저장에 실패하면 설정 칸을 저장된 값으로 되돌림, 503 문구 영어판, 줄을 떠난 카드의 `pcLine` 지움. ### 측정