Repository navigation
Pay a blur-cancelled page's keyboard after the window's own return - #586
Merged
Merged
Conversation
On macOS a window's focus event is it becoming main again, and Electron restores the focus it stored on blur just before emitting it. The host paid the debt as soon as the window read as key and the page was shown, so a page shown while the window was key but not yet main got the keyboard and then lost it to that restore, the shell the hold had given it; and a window that came back while the page was covered and became key only after the show was never paid. The debt now waits for the window's focus event since its blur, whichever of that and the show comes last.
This was referenced Oct 6, 2026
yansfil
added a commit
that referenced
this pull request
Oct 6, 2026
…598) Part of #511 ## Summary The desktop e2e `area cycle native` still fails its first attempt at `browser.spec.ts:857` on main after #586 (run 37403778186 on `0f3739a7`: attempt 1 failed with `browser.window_return page_focused:true` logged, the retry passed). The log cannot say what took the keyboard after the host paid it, because it records only the payment. This adds host log events for the window's blur and focus, the page's blur and the shell's focus, so the next failing attempt shows the order; no behavior changes. ## Review - **조심해서 볼 파일**: `desktop/src/main/browser.ts` - four `log.event` calls in focus/blur listeners; they fire at operator-click rate, none carries page content. ## Evidence - **확인한 것**: desktop typecheck, lint and 155 unit tests pass. - **확인하지 못한 것**: that the new events explain the failure; that needs a failing desktop e2e attempt in CI. The `@needs-focus` spec was not run locally.
This was referenced Nov 10, 2026
HyunjunJeon
pushed a commit
to HyunjunJeon/hide
that referenced
this pull request
Nov 12, 2026
…here (with-hide#2366) Closes with-hide/hide-private#808 Closes with-hide/hide-private#507 Closes with-hide/hide-private#404 Refs with-hide/hide-private#129 Refs with-hide/hide-private#135 Refs with-hide/hide-private#171 Refs with-hide/hide-private#442 Closes with-hide/hide-private#500 Refs with-hide/hide-private#586 Closes with-hide/hide-private#544 ## Summary 데스크톱에서 웹 페이지가 스스로 다시 로드되는 동안 조작자가 키보드를 터미널로 옮기면, 로드가 끝나는 순간 페이지가 키보드를 도로 가져가 터미널로 돌아오지 않았습니다 (제품 결함, with-hide#507 #808). 호스트는 "로드가 시작될 때 키보드를 누가 쥐고 있었나"로 판단했는데, 이제 로드 중인 문서마다 표시를 두고 "페이지가 포커스를 받는 그 순간 누가 쥐고 있나"로 판단합니다. 테스트 쪽 원인도 하나로 모았습니다. e2e의 `focusPage`는 페이지 로드 도중에 포커스를 줘서, 호스트가 이를 정상적으로 "로드가 키보드를 가로챔"으로 보고 쉘에 되돌렸고 쉘은 페이지가 키보드를 받았다는 말을 듣지 못했습니다 (with-hide#404 #808 with-hide#129, Command W가 페이지가 아니라 터미널에 간 경우). 이제 로드가 멈춘 같은 턴에 포커스를 줍니다. Windows 첫 페이지 로드가 10초를 넘는 일(with-hide#135 with-hide#171)은 원인을 찾지 못해 테스트는 건드리지 않았고, 이슈는 열어 둡니다. 화면(web/src)은 바뀌지 않아 스크린샷은 없습니다. ## Review - **판단해 주세요**: 같은 "로드가 키보드를 가로챔" 규칙을 제품은 그대로 두고 테스트 헬퍼가 규칙에 맞추도록 했습니다. 규칙 자체(운영자의 클릭이 아닌 포커스는 로드 중이면 되돌린다)는 맞다고 봤습니다. - **조심해서 볼 파일**: `desktop/src/main/browser.ts` - 포커스 이벤트 처리 경로(`contents.on("focus")`, `undoGrab`), 고빈도는 아니고 문서 로드당 한 번. - **닫지 않은 이슈**: with-hide#129 with-hide#135 with-hide#171 with-hide#442 #586은 `Refs`입니다. 무엇을 확인했고 무엇이 남았는지는 아래 Evidence의 "확인하지 못한 것"에 있습니다. 원인을 고친 #808 with-hide#507 #404와, 이미 #2149가 고친 원인이 반복에서 재발하지 않은 with-hide#500 #544만 `Closes`입니다. ## Evidence - **확인한 것**: - 호스트 로그로 원인 증명: 야간 42730366343의 `browser.page_focus ... navigating:true` 다음 `navigation_focus_returned`(쉘이 못 들음), 같은 로그의 첫 시도는 `navigating:false`로 로드가 시작될 때 페이지가 키보드를 쥔 경우(제품 결함 모양). - 새 단위 테스트(`browser.test.ts`)는 수정 없이 실패하고 수정 후 통과합니다. 데스크톱 단위 32개, 데스크톱 typecheck와 lint 통과. - 임시 커밋 231062f(되돌림 c0d51b3)에서 재시도 없이 반복한 CI 실행 (그 실행의 head는 231062f14이고, 이 PR의 최종 head 1f2678713과는 `browser.spec.ts`의 첫 로드 대기, 진단 덤프, 임시 변경의 되돌림만 다릅니다) https://github.com/with-hide/hide/actions/runs/42785031933 : - macOS 데스크톱 browser·close-policy·new-tab 스펙 x10: 4개 샤드 모두 통과, 각 50개, 합 200개 (jobs 129725125529, 129725125682, 129725125745, 129725125916). - Windows 데스크톱 페이지 폭 2개와 device size x10: 30개 통과, 같은 job의 진단 시험 10개를 합쳐 40개 (job 129725125921). 이 반복은 `openUntilLoaded`가 있던 231062f14에서 돌렸고, 최종 코드(대기는 main 그대로)는 일반 CI에서만 통과를 확인했습니다. - Windows 웹 pane-focus-ordering, stale-snapshot-focus, shell 스펙 x20: 통과 (jobs 129727940499, 129727940557). 같은 job의 20개 실패는 grep(`shell.spec`)에 같이 걸린 `sidebar-shell.spec.ts:46`으로, Windows 경로 표기(`\` 대 `/`) 때문에 매번 실패하는 이 노드 밖의 결함입니다. - Linux 웹 같은 스펙 x20: 통과, 260개 (jobs 129728372563, 129728372677). - with-hide#500 with-hide#544 with-hide#586(30초 시간 초과)와 with-hide#442(30초)는 모두 11-05 이전이고, 호스트 로그의 `task_operation.busy`로 둘째 에이전트 시작이 거절된 모양이었습니다. 11-06의 with-hide#2149(첫 에이전트가 시작된 뒤에 다음을 시작)가 이미 이를 고쳤고 그 뒤 재발이 없습니다. 이 PR의 반복은 그 수정이 유지됨을 보이며, 새 웹 수정은 없습니다. - **확인하지 못한 것**: - with-hide#135 with-hide#171: Windows에서 첫 페이지 로드가 CLI `--wait`의 10초를 넘는 원인은 못 찾았습니다. 진단 시험(새 세션의 프록시 해석과 로드)은 10회 모두 0.5초 안이었습니다. 이 PR은 이 부분을 바꾸지 않았고 한도도 그대로입니다. 남은 일: Windows 러너에서 첫 로드의 어느 구간이 느린지 측정. - #129의 첫 모양(후보 앱 메인 프로세스가 90초 멈춤, 10-26 한 번)과 #586의 `ERR_NO_BUFFER_SPACE`(11-07 한 번), #442의 11-09 `h1:p2` 없음(Windows)은 원인 미확정입니다. #442는 다음 실패에 페이지가 무엇을 그렸는지 남도록 덤프를 달았습니다. - macOS @needs-focus 테스트를 로컬에서는 돌리지 않았습니다 (OS 포커스를 가져가므로). <details><summary>Verification record</summary> - base: main (fetch 시점 ab0cd44 이후), head: 1f26787 - 변경 경로: desktop/src/main/browser.ts, browser.test.ts, desktop/e2e/fixture.ts, new-tab.spec.ts, web/e2e/pane-focus-ordering.spec.ts, docs/BROWSER_DISPLAYS.md - 단위: 데스크톱 browser.test.ts 32개 통과 (새 테스트는 수정 없이 실패), 데스크톱 typecheck와 lint 통과 - 반복 CI: run 42785031933, head 231062f, 재시도 0. macOS 데스크톱 x10 200개, Windows 데스크톱 30개(+진단 10개), Windows 웹 x20, Linux 웹 x20 260개 통과 - 일반 CI: head c0d51b327의 run 42794038744 통과(web and desktop checks, web e2e linux 6/6, windows desktop, windows e2e, windows check), 최종 head 1f2678713의 CI는 Hide가 기록 - 리뷰: m46-reviewer 1차 fail(대기 연장, 원인 미확정 Closes) 후 반영, 재리뷰 pass - 실행하지 않음: macOS @needs-focus 테스트의 로컬 실행 </details>
HyunjunJeon
pushed a commit
to HyunjunJeon/hide
that referenced
this pull request
Nov 12, 2026
Closes with-hide/hide-private#526 Closes with-hide/hide-private#599 Refs with-hide/hide-private#395, with-hide/hide-private#530, with-hide/hide-private#117, with-hide/hide-private#586 Refs with-hide/hide-private#832 ## Summary - Start the checkout PR flow on Main after its setup has focused another workspace. - Prevent Windows test browsers from losing local page or resource requests during shell startup. - Retain the failed row and pointer state for a separate, unreproduced late card-hover failure. ## Review - **Risky files**: browser-launch.cjs merges installed runner defaults; the desktop preload extends effective flags. - **Risky files**: checkout-pr.spec.ts retains discovery's connection, then resets first-run selection before Main. - **Risky files**: desktop browser.spec.ts uses the shared arguments for its plain Chromium launch and checks the applied features through CDP. - **Decide**: The narrow upstream fix uses the locked runner's internal argument API; a changed shape fails startup. - An entire runner upgrade would also replace the browser revision and is outside this stabilization change. - **Cost**: The hover observer exists only for one test phase, retains 32 transitions, and is removed on every exit. - **Cost**: Splitting the plain-browser notice from the native-view lifecycle adds one isolated fixture start so Windows CI checks that launcher too; its existing notice assertions are retained. - [Windows run 41016473655](https://github.com/with-hide/hide/actions/runs/41016473655/job/123933953907), tracked by [private with-hide#130](with-hide/hide-private#130), records the same document-load error. - [with-hide#832](with-hide/hide-private#832) tracks one later card-hover failure; this PR does not claim its cause is fixed. ## Tests - **Layer**: Unit feature merging; real browser startup and desktop recovery cross the actual host launch boundary. - The desktop plain-browser case checks the effective final disabled-feature list, retained runner defaults and the Windows loopback fix before opening the shell. - It passed its first Windows CI attempt on the final head in [the desktop lane](https://github.com/with-hide/hide/actions/runs/42860546110/job/129985854339). - Units cannot observe which feature list the launched browser applies; the startup check reads that applied state. - **Catches**: Removing the Windows feature fix failed two merge checks; restoring it passed all three. - **Repeat**: Linux/macOS: five flows x20, [100 passed each](https://github.com/with-hide/hide/actions/runs/42832076296). - Desktop recovery/relaunch: each x10 on macOS/Windows, retries 0, [40 passed](https://github.com/with-hide/hide/actions/runs/42831271844). - Final Windows: five flows x20, retries 0, [100 passed](https://github.com/with-hide/hide/actions/runs/42844846265/job/129929485236). - **Waits**: No new wait, delay, retry, timeout or threshold; the existing Main assertion follows explicit state setup. ## Evidence - **Verified**: Local startup/checkout flows, desktop recovery/relaunch, unit 3, lint, types, builds and policy checks. - **Verified**: The split desktop plain-browser and native-view flows passed locally without retries; desktop lint and typecheck passed. - **Verified**: A controlled trigger replacement preserved the original failure and captured mounts=2 before teardown. - **Verified**: [Required CI](https://github.com/with-hide/hide/actions/runs/42860546110) and independent review passed on final head c532660. - **Not verified**: The historical reference-only causes and the late hover cause. <details><summary>Failure evidence and review boundaries</summary> - with-hide#526's run 42780431716 drew Workspace while the test expected Main after setup focused its agents. - with-hide#599's run 42080456072 had an unmounted shell, a successful document and a failed entry script with ERR_NO_BUFFER_SPACE. - Private with-hide#130 is handled separately by public PR with-hide#2372; its Windows host log recorded window.load_failed ERR_NO_BUFFER_SPACE after a normal daemon start. - The test-only startup fix follows [the upstream fix](microsoft/playwright#43605) and [the browser defect](https://issues.chromium.org/issues/572515601). - The locked runner 1.63 lacks that fix. The helper reads its installed defaults rather than copying a version-specific list. - with-hide#395's run 42140863283 attached its daemon before its shell wait failed, with no page-side or failed-load signature for that exact wait. Its initial report used the retired fixture startup path; neither identifies this PR's connection cause. - with-hide#530's original failure drew Main with a failed sidebar boundary. A controlled stylesheet abort reproduced that screen and a missing CSS-token diagnostic, but the original artifact retained no asset-failure signature. - with-hide#117's latest retained record has only a whole-test timeout. Its historical lost step remains unidentified. - with-hide#586's run 42359435922 explicitly reports the loopback error, but its initial whole-test timeout and its separate focus flow were not resolved by the targeted repetitions. - For those next failures, inspect pageSide screen/project state, request status, failed requests, renderFailures and renderDiagnostics. The dump now retains failed regions and the newest eight relevant render diagnostics. Each reference-only issue has a comment with its confirmed facts, remaining gaps and next dump. - with-hide#536 was closed separately because commit 8be1505 deleted its Home collision test. The current no-project startup spec does not replace that behavior. - The first Windows repetition had 99/100 passes: checkout-pr.spec.ts:273 failed at the final light-theme hover after the shell, row, PR glyph and browser display had already drawn. - A diagnostic-only repeat at 5eefccb passed 100/100: all 20 checkout attempts retained one trigger mount, had PR facts ready and hit that row with the pointer. The card opened after its normal hover delay. This did not reproduce or establish the cause of the earlier failure. - The replacement diagnostic captures the failing state inside that step, before teardown can add a disconnected banner and move the row. It records the checkout key, mounts, pointer hit, geometry, focus, visibility, drag marks and tooltip state, preserves the original error, and reports independent cleanup failures. - The old conversation-date fixture also caused automatic sleep of the Main setup agent in the failed run. A current-clock proposal removes that sleep locally, but its relationship to the hover failure is unconfirmed. It remains an uncommitted local patch documented in with-hide#832. - No product input, runtime mutex, snapshot wire or rendering path changes. The operator's installed application was untouched. </details> <details><summary>Verification record</summary> - Final head: c532660. - Startup repeat candidate 4231d60: Linux/macOS each five flows x20, no retry. - Desktop repeat candidate ce0dffe: JSON reports on each OS show expected=20, unexpected=0, skipped=0, flaky=0, repeatEach=10 and retries=0. - Diagnostic-only Windows candidate 5eefccb: run 42838637529, five flows x20, no retry, 100 passed. The temporary early observer and trace flag were reverted. - Final Windows repeat candidate 49b560a: run 42844846265, five flows x20, retries=0, 100 passed; job log confirms the exact tested commit. - All temporary workflow changes are reverted. The repeated specs, shared startup fixtures and guide match the final Windows repeat candidate; the later desktop browser.spec.ts regression and its smaller size baseline are the only differences in those test trees. - Head 1933d66 is a source-identical verification commit after f45c106, added to regenerate the synthetic merge against the corrected base. - Review follow-up c532660 applies the shared launch settings to the desktop plain browser and separates that existing notice contract into a Windows-covered case. - Local current source: checkout hover flow passed without retries; a controlled browser replacement captured the original failure and two mounts; web lint and test-size budget passed. - Earlier unchanged-source checks: web build; web/desktop lint; desktop typecheck; startup/checkout 3; desktop recovery/relaunch 2; merge unit 3; design contract and policy checks passed. - Manual repeat dispatches that skipped every test and draft-only verify failures are excluded from verification evidence. - Independent review and required CI 42860546110 passed on c532660. - Ready run 42849933157 checked synthetic merge 83a0f35 against base 8284fb6, which predates with-hide#2398. - That merge still waited on the retired status.herdr field; current main uses status.engine. All hard web failures were at that restart boundary. One required failed-job rerun was started. - The regenerated merge f4ed9d1 includes the corrected status.engine wait. - Final run 42860546110 tests merge 6b977ba containing c532660; completed job logs confirm that checkout. - Its Linux suite has 412 passes and eight Windows-only skips, the retry-free changed-spec repeat has 80 passes, Windows web has 85 passes, and Windows desktop has 24 passes and one existing platform skip. The new plain-browser startup case passed its first attempt in 6.9 seconds. </details>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Refs #511
Summary
area cycle native가 #565 뒤에도 가끔 첫 시도에 실패하던 원인을 제품(desktop host)에서 고칩니다.실패는 #565가 다룬 tab click이나 sheet 뒤 focus가 아니라 857행, 즉 window blur로 취소된 hold 뒤 window가 돌아왔을 때 page가 keyboard를 되찾는 단계였습니다.
focusevent는 window가 main이 될 때 나오고, Electron은 그 직전에blur때 저장해 둔 focus를 되돌립니다(BrowserWindow::OnWindowFocus의RestoreFocus). hold 중에는 host가 keyboard를 shell에 넘겨 두므로, 저장된 focus는 shell입니다. 그런데 host는 "window가 key이고(isFocused(), 즉isKeyWindow) page가 보이면" 빚을 갚았습니다.browser.window_return page_focused:true가 찍힌 뒤 857행이 5초 동안 false였던 것과 맞습니다(run 37360697791, 37372899600, 그리고 #511의 첫 run 37304329630).focus가 먼저 오고 page가 보인 뒤에야 key가 되면, key 전환에는 JS event가 없어 빚을 영영 갚지 않습니다.window_return이 없는 run 37357410267과 맞습니다.desktop/src/main/browser.ts): "window가 돌아왔다"를isFocused()가 아니라 window 자신의blur/focusevent로 셉니다(windowBack). 빚은focusevent와 page의 보임 중 늦게 온 쪽에서 한 번 갚습니다. Electron의 되돌림은 언제나blur뒤의focus직전에 오므로, 갚은 뒤에 shell로 되돌아가지 않습니다.browser.test.ts: 두 경우를 한 test로 더했습니다(key지만 아직 돌아오지 않은 window에서 보인 page는 받지 않고focus에서 한 번 받음, 덮인 채 돌아온 window에서 key 전에 보인 page는 받음). 기존 test 하나는 제목을 "window가 돌아온 뒤에만"으로 고쳤습니다.docs/BROWSER_DISPLAYS.md: 빚을 갚는 조건을 같은 말로 고쳤습니다.browser.spec.ts)는 바꾸지 않았습니다. 새 retry, timeout, sleep, allow는 없습니다.Review
OnWindowIsKeyChanged)은SetActive만 하고 focus를 되돌리지 않는다는 데 기댑니다(Electron 44 소스 확인).desktop/src/main/browser.tswindowBack-blur마다 false,focus마다 true입니다. 빚이 없을 때는 아무것도 하지 않습니다.Evidence
verify-web.sh desktop typecheck,desktop lint,desktop test(155 통과) 통과.browser.test.ts14개 통과.this.window?.isFocused()로 되돌리자 새 test가 "page가 window 돌아오기 전에 focus를 받음"으로 실패. 되돌리면 통과.electron_api_browser_window.cc의OnWindowBlur/OnWindowFocus,electron_ns_window_delegate.mm의 main/key 알림,native_window_mac.mm의Focus/IsFocused).@needs-focustest는 운영자의 창과 keyboard를 가로채므로 로컬에서 돌리지 않았습니다. CI desktop e2e lane 결과로만 확인합니다. 857행 실패는 run 몇 번에 한 번 꼴이라, 녹색 run 하나는 재발이 없다는 증거가 되지 못합니다.