mirror of
https://github.com/HKUDS/DeepTutor.git
synced 2026-12-02 05:39:20 +08:00
Selecting text and pressing 翻译成中文 did nothing at all — no request, no spinner, no error. Two components were fighting over one piece of state and the toolbar lost. `AnnotationPopover` implements outside-dismiss with a document-level, CAPTURE-phase `pointerdown` listener, and `onDismiss` was `() => setSelection(null)`. The toolbar is a sibling far outside the popover's ref, so pressing one of its buttons ran: pointerdown captured at `document` → selection cleared → React flushes at the microtask checkpoint between `pointerdown` and `mousedown` → the button re-renders `disabled`, because the four selection-gated actions declare `requires: ["selection"]` → and a disabled control is sent none of the rest of the activation sequence. The click never happened. It is not only translation: 引导我, 翻译成英文, 翻译成中文 and 解释词汇 are all selection-gated and all equally unreachable, in every render mode. The two the user did not report broken — 测一测 and 朗读 — are exactly the two with no selection gate. Nor is it new in v1.6.5: the popover's listener dates to v1.5.14 and the toolbar to v1.6.0, so these actions have never been clickable. Escape routed to the same handler, so there was no way around it. So "there is a selection" and "the popover is open" become two states. The mount condition has to move with it — gating on `selection` alone would leave Escape and outside-click unable to close the popover at all. Two more that would have bitten immediately afterwards. The bar sent the viewport locator while the selection carried its own, and the server verifies the quote against the text of the unit it is told about — so the first working click would have been a 400. And `busy` was a single global key, so one action disabled all six for up to the 30s server timeout, wearing the same dead 50%-opacity look as the bug. The result-reset effect is split in two: a result is keyed on the material (scrolling one page used to erase a card being read), while speech keeps both keys, because it must stop the moment the reader navigates away. The regression test mounts the reader and clicks the real button. Nothing could have caught this before: the unit test is regex-over-source, and all three Playwright audits that drive the reader stub /api/reading/extensions to [], which makes the toolbar render nothing at all.