Repository navigation
Give a desktop page the keyboard once the window is key, not until it holds - #534
Merged
Merged
Conversation
… holds macOS makes the window key after the app activates, and Electron then restores the shell's focus, so a page focused while that activation is in flight loses the keyboard a moment later. The specs refocused until the page held it. focusPage in the desktop fixture activates the app, waits for the window's focus event, and only then focuses the shell and the page, once; the area-cycle spec then waits, without acting, for the page to keep the keyboard and the shell to admit it.
This was referenced Oct 5, 2026
Closed
yansfil
added a commit
that referenced
this pull request
Oct 5, 2026
…selects it (#565) Refs #433 ## Summary #534 뒤로 desktop `browser.spec.ts`의 `area cycle native`가 자주 실패하던 것을 고칩니다(fix-forward). page를 보이기 전에 focus하던 순서를, host가 page를 보이고 core snapshot이 그 page를 고른 뒤에 한 번 focus하는 순서로 바꿨습니다. 제품 코드는 바뀌지 않았습니다. - 실패는 두 번째 이후 focus(828행 tab click 뒤, 873행 설정 sheet를 Escape로 닫은 뒤)에서만 났습니다. 첫 번째 focus 앞에는 shell 조작이 없어서 통과합니다. - 원인(읽기): 첫 cycle이 Page B를 고른 뒤라 tab click 시점의 `한글 브라우저` page는 숨겨져 있고, 그 page를 보이고 고르는 일은 click의 core 왕복이 끝나야 옵니다. sheet도 덮는 동안 page를 숨깁니다. #534의 `focusPage`는 그 사이에 한 번 focus합니다. - 숨겨진 page에 준 focus는 page가 보인 뒤 keyboard로 남지 않아, hold 확인이 5초 안에 참이 되지 않습니다(789행 실패). - 보인 뒤에도 core snapshot이 아직 그 page를 고르지 않았으면, page가 시작한 hold를 shell이 받지 않고 끝냅니다(`web/src/keyboard.ts`의 `focusedSurface(...)?.id !== input.id` 분기). 그래서 cycle이 그려지지 않습니다(831행 `[data-cycle=area]` 없음). host log에 `browser.cycle_start_refused`가 없는 것도 page가 hold를 시작했다는 것과 맞습니다. - #534 전에는 focus를 되풀이하고 250ms 동안 유지되는지 보는 loop가 이 두 경합을 가렸습니다. - `browser.spec.ts`: `shownAndSelected`(host가 page를 보이고, tab bar에서 그 display가 선택됨)를 기다린 뒤 `focusPage` 한 번, 그다음 기존 확인(page가 keyboard를 쥐고 shell이 받아들임)을 기다립니다. 새 retry, timeout, sleep, allow는 없습니다. - `fixture.ts` `focusPage` 설명과 `docs/BUILD.md`에 "page가 보인 뒤에 focus한다"는 전제를 적었습니다. ## Review - **판단해 주세요**: tab bar의 `aria-selected`를 core snapshot이 고른 것으로 읽었습니다. tab click은 `view_layout` 하나를 보내고 화면은 snapshot으로만 그려져(낙관적 선택 없음, `web/src/AreaTree.tsx` `focus`), 선택이 보이면 core가 고른 것입니다. - **조심해서 볼 파일**: `desktop/e2e/fixture.ts` `focusPage` - 숨겨진 page를 받으면 지금은 그대로 focus합니다. 그 자리에서 실패하게(`view.getVisible()`로 throw) 하는 것은 zoom과 close-policy 호출까지 바뀌어 이 급한 수정에서 뺐습니다. - **질문**: 없음. ## Evidence - **확인한 것**: `verify-web.sh desktop typecheck`, `desktop lint`(test 크기 검사 포함) 통과. 실패 log 3개(pr-534 queue run 37339468790, #556 run 37344689288 attempt 1, 2)를 읽어 실패 행(828 다음 789, 831, 873 다음 789)과 host event를 확인했습니다. - **확인하지 못한 것**: `@needs-focus` test는 운영자의 창과 keyboard를 가로채므로 로컬에서 돌리지 않았습니다. 이 PR의 CI desktop e2e lane 결과로만 확인합니다. 원인은 log와 코드로 읽은 것이고, 숨겨진 view에 준 focus가 보인 뒤 남지 않는다는 부분은 재현하지 않았습니다.
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 #433
Summary
desktop e2e의 #433 allow 3개(
browser.spec.ts2,close-policy.spec.ts1)를 없앱니다. 세 곳 모두 browser page가 keyboard를 쥘 때까지 app 활성화, 창 focus, page focus를 되풀이했습니다. 이제 한 번 활성화하고, 창의focusevent를 기다린 뒤, page에 한 번 focus를 줍니다. 제품 코드는 바뀌지 않았습니다.desktop/e2e/fixture.tsfocusPage(app, { url } | { title }): macOS는 app이 활성화된 뒤에야 창을 key window로 만들고, 그때 Electron이 shell의 focus를 되돌립니다. 그 활성화가 끝나기 전에 page에 준 focus는 잠시 뒤 shell로 돌아갑니다. 그래서 창이 아직 key가 아니면focusevent를 기다리고(10초 한도, 넘으면 이유와 함께 실패), 그 뒤 shell, 그다음 page에 focus를 줍니다. page가 keyboard를 쥐지 못하면 그 자리에서 실패합니다.browser.spec.tsarea cycle:focusPage다음, page가 keyboard를 쥐고 있고 shell이 그 page를 받아들였다는 상태(holds와admitted)를 행동 없이 기다립니다. 이전에는 둘을 250ms 간격으로 확인하며 focus를 되풀이했습니다.browser.spec.tszoom,close-policy.spec.ts:focusPage한 번. close-policy는 page title이Close page가 되기를(page가 load됨) 먼저 기다립니다.docs/BUILD.md:@needs-focusspec이 page에 keyboard를 줄 때focusPage를 쓴다고 적었습니다.Review
focusevent를 기다리지 않습니다. key window는 app이 활성일 때만 될 수 있으므로, 그때는 기다릴 활성화가 없다고 봤습니다.desktop/e2e/fixture.ts- main process 안에서focusevent를 기다리는 Promise에 10초 한도를 두었습니다. 기다림의 상한이고 sleep이 아닙니다.Evidence
verify-web.sh desktop typecheck,desktop lint(test 크기 검사 포함) 통과.#433표시는 desktop e2e에 남지 않습니다.@needs-focustest는 app을 앞으로 가져와 운영자의 창과 keyboard를 가로채므로, macOS runner의 CI desktop e2e lane(전체 suite를 돌림) 결과로만 확인합니다. 그래서 부하 반복 결과도 없습니다. 고친 위험은 읽기로 판단한 위험입니다(활성화가 끝나기 전 page focus가 shell로 돌아가는 경합을 재시도가 가림).#433allow는 0입니다. overview의 hover card 하나는 #531에서 고유 이유가 적힌 예외로 남습니다.