Repository navigation
emrg: closing the annotation panel hides it instead of destroying it - #3310
Merged
Merged
Conversation
added 2 commits
December 3, 2026 21:47
The panel is built once, when the document loads, and the close button took it out of the DOM: `ui.host.remove()`. Nothing rebuilt it, so after one close the page had no annotation interface for the rest of its life — the host closed the panel, selected another paragraph, and nothing appeared. Closing is hiding now. `hide()` sets `display: none`, `show()` puts it back where it was (pulled inside the viewport if the page was resized meanwhile), and the selection handler calls `show()` after it records an annotation — selecting text is this layer's only gesture, so it is also the only way back. Sending hides too, and a close keeps annotations that were not sent: their marks are still on the page, and a panel that discarded them would leave marks explaining nothing. Guarded by a new case in `test/annotation-wiring.test.js`: no `ui.host.remove()` in the preload, close bound to `hide`, `display: none` as the hiding mechanism, and `show()` reached from the selection handler.
The preload captured the selected text as `exact` and then dropped it when it
built the payload, so a batch sent `{paragraph, body, selector}` and the message
the model received quoted the whole containing block. A screenshot of one real
batch showed the cost: two annotations, one with 「本地」 picked out of a
paragraph and one with 「capabilityType=EXPERT_SKILL 的那些」 out of a table cell,
and neither appeared anywhere in the message. The opinion arrived attached to a
block with nothing saying which part of it was meant.
`exact` travels now and `composeMessage` renders it as its own line between the
quote and the annotation — `选中:本地`. A separate line rather than emphasis
inside the quote: marking would need the words to occur exactly once in the
flattened block, and a selection that crosses an element boundary flattens
differently, so a wrong mark would be worse than none. The line is omitted when
the selection is the whole block, and when the caller had no selection text at
all, so a message composed from blocks alone is byte-identical to what it was.
Both entries carry it: the page panel through `Shell.tsx`, and the transcript's
own annotation mode, which had the same gap.
Guarded: a new case in `test/annotation-wiring.test.js` pins `exact: i.exact`
in the preload's payload and its passage through `Shell.tsx`; four cases in
`lib/annotation.test.ts` pin the composed shape, including the omitted line.
Owner
Author
|
The host waived the three-vote rule for this pull request at 2026-12-03T22:03:58+08:00 (「豁免」, session Reading at head Why it goes out without the gate: both defects are in the annotation panel the host has installed (0.3.90), and a fix reaches the host only through a release. |
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.
The defect
The annotation panel could be opened exactly once per page load. The close button ran
ui.host.remove(), and nothing builds the panel again:buildPanel()runs once frommain(), which runs once when the document loads. So after the host closed the panel, selecting another paragraph did nothing at all — the selection was recorded, the mark was drawn, and no interface appeared to write the annotation in.Measured on the shipped v0.3.90: the panel is created on
DOMContentLoaded, the onlyui.host.remove()calls were the close button and the send path, and nothing re-inserted the host.The change
Closing hides.
hide()setsdisplay: none;show()restores it and callsplace()first, with the stored box pulled inside the viewport, so a window resized while the panel was hidden does not put it off screen.Selecting text is the way back. The selection handler is this layer's only gesture, so it now ends with
show(): making an annotation and reopening the panel are the same act. Sending hides the panel as well, which is what it should always have done.A close keeps what was not sent. The annotations still in the panel have marks on the page; a close that discarded them would leave marks explaining nothing, and the host would have to find the marks and delete them by hand.
Guard
test/annotation-wiring.test.jsgains one case: noui.host.remove()anywhere in the preload,ui.closebound tohide,display: noneas the hiding mechanism, andshow()reached from the selection handler. It fails against the v0.3.90 preload.Measured
cd emrg/gui && npm test— 284 tests, 276 pass, 8 skipped, 0 failcd emrg/gui/renderer && npm run typecheck && npm test—tsc --noEmitclean, 1283 passscripts/check-node-test-count.py—OK: Agent.md documents 1283 renderer + 283 GUI teststests/test_doc_counts.py— 82 passednode --check emrg/gui/annotation-preload.js— clean