feat(v2): pcControl keys go behind a window when they can, else in front for a moment

User decision 2026-11-19 (mixed way). agent-desktop only presses keys in the
window in front, so the app now picks one way before any key is sent:

- behind: one key without modifiers that types or moves is posted to the
  window's one shown text control (Edit, RichEdit, RichEditD2DPT, Scintilla);
  the person's screen and focus stay. Windows does not tell a background
  thread's focused control (win-ci VM: GetFocus is null even attached), so
  only windows with exactly one text control get keys behind.
- in front for a moment: combinations, other keys and every other window;
  the window that was in front is brought back after (also after a failed
  press). A window already in front gets the keys there.
- never in front while game mode is on or the window in front is full screen.
- never both ways, so a key is never pressed twice.

Specs: admin.spec.md "PC control" (Keys), pc-features.md, pc_control.spec.md.
Tests: six new fake-desktop tests in pc.rs; tests/pc_keys_windows.rs on a real
desktop (win-ci VM: letters behind Notepad with Character Map kept in front,
ctrl+a in front and back, the classic Calculator in front and back).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
javis-bot
2026-11-19 10:41:05 +09:00
parent 999c432216
commit 378ccfafad
5 changed files with 509 additions and 15 deletions

View File

@@ -226,6 +226,11 @@ LLM과 STT를 함께 켠 측정(M0 `gamemode_stt`, 게임 없음). STT를 먼저
- 프로그램 조작은 [agent-desktop](https://github.com/vercel-labs/agent-desktop)(Apache-2.0, Windows UI Automation)으로 합니다. 앱 설치 파일에 실행 파일(약 4MB)을 함께 넣습니다.
- 창의 버튼·입력칸·메뉴 목록을 글자로 읽고, 고른 항목을 직접 누르거나 값을 넣습니다. 화면 좌표를 쓰지 않으므로 해상도·배율·창 위치가 바뀌어도 맞게 누릅니다.
- 기본은 마우스 커서를 움직이지 않고 포커스도 가져오지 않습니다. 사용자가 다른 창에서 작업하는 중에도 뒤에 있는 창을 조작할 수 있습니다. 최소화된 창은 조작하지 못하므로 먼저 되돌립니다.
- 키 누르기는 섞어 씁니다(2026-11-19 사용자 결정). agent-desktop은 앞에 있는 창에만 키를 보낼 수 있어서, 뒤 창으로 보내는 부분은 앱이 Windows 기능으로 직접 합니다.
- 기본은 뒤 창에 바로 보냅니다. 조합키가 아닌 키 하나(글자, 숫자, Enter, Tab, 방향키 등)를 그 창의 글 입력칸에 보내고, 사용자 화면과 포커스는 그대로 둡니다. Windows는 뒤 창의 어느 칸에 포커스가 있는지 알려 주지 않으므로, 글 입력칸이 하나뿐인 창(메모장 등)에만 이렇게 보냅니다.
- 조합키(Ctrl·Alt·Shift·Win)이거나, 글 입력칸이 하나뿐인 창이 아닐 때(계산기, 스토어·WinUI 앱, 크롬 계열, 파이어폭스 등)만 그 창을 잠깐 앞으로 가져와 키를 누르고, 원래 앞에 있던 창으로 바로 되돌립니다. 그 순간 사용자가 치던 키가 그 창으로 들어갈 수 있습니다.
- 게임 중이거나 전체 화면일 때는 앞으로 가져오지 않고 못 한다고 답합니다.
- 처음부터 키와 프로그램을 보고 한 가지 방식만 고릅니다. 한 방식이 안 됐다고 다른 방식으로 다시 누르지 않으므로 같은 키가 두 번 눌리지 않습니다. 결과는 창을 다시 읽어 확인합니다.
- 누르거나 넣은 뒤 화면을 다시 읽어 결과를 확인하고, 확인된 것만 "했습니다"라고 말합니다.
- Alt+F4, Win+R, Ctrl+Shift+Esc 같은 위험 단축키는 agent-desktop이 기본으로 막습니다. 이 막음을 푸는 옵션(`--force`)은 쓰지 않습니다.
- 관리자 권한으로 실행된 창은 Windows가 막아서 조작하지 못합니다. 그때는 못 한다고 답합니다.