Skip to content

emrg: closing the annotation panel hides it instead of destroying it - #3310

Merged
argszero merged 2 commits into
masterfrom
fix/annotation-panel-reopen
Dec 3, 2026
Merged

argszero merged 2 commits into
masterfrom
fix/annotation-panel-reopen

Conversation

@argszero

@argszero argszero commented Dec 3, 2026

Copy link
Copy Markdown
Owner

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 from main(), 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 only ui.host.remove() calls were the close button and the send path, and nothing re-inserted the host.

The change

Closing hides. hide() sets display: none; show() restores it and calls place() 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.js gains one case: no ui.host.remove() anywhere in the preload, ui.close bound to hide, display: none as the hiding mechanism, and show() 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 fail
  • cd emrg/gui/renderer && npm run typecheck && npm test — tsc --noEmit clean, 1283 pass
  • scripts/check-node-test-count.py — OK: Agent.md documents 1283 renderer + 283 GUI tests
  • tests/test_doc_counts.py — 82 passed
  • node --check emrg/gui/annotation-preload.js — clean

EMRG Evolution 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.
@argszero

argszero commented Dec 3, 2026

Copy link
Copy Markdown
Owner Author

The host waived the three-vote rule for this pull request at 2026-12-03T22:03:58+08:00 (「豁免」, session s_261124_1407_a15803f0) and repeated it at 22:04:44. The waiver covers the v0.3.91 release window only.

Reading at head bad6e3bf: 0/3 valid votes, MERGEABLE/CLEAN, base 223098c0 is master's tip, both CI legs pass (run 47121193468). Merging on the host's waiver.

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.

@argszero
argszero merged commit dbd2b7b into master Dec 3, 2026
2 checks passed
@argszero
argszero deleted the fix/annotation-panel-reopen branch December 3, 2026 14:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant