Repository navigation
emrg: annotate local pages in the editor's browser mode - #3308
Merged
Merged
Conversation
The annotation panel shipped in v0.3.88/0.3.89 was mounted in a second WebContentsView that nothing could open: no button, menu or shortcut called `emrg:previewHtml`, and `grep -rn previewHtml emrg/gui/renderer` answered 0. The host was asking for browser mode — the globe toggle in the file editor — the whole time. So that view is deleted, with its four IPC channels, its bounds sync and its renderer-side preload exposure. What it carried moves to where it belongs: the browser view loads `annotation-preload.js` (the same panel, renamed), and the preload asks the address before it builds anything, so a document that is not a local `file:` page gets no panel and no listener. The gate on what leaves is in the main process, unchanged in shape: the sender must be that view's own webContents, the address it recorded must be a local file, and the file is computed from that address with `fileURLToPath` — a path a page reports is never used. The channel is `emrg:pageAnnotate` up and `emrg:pageAnnotation` down; the renderer binds `onPageAnnotation` and hands the batch to the composer. Measured on this tree: `cd emrg/gui && npm test` 283 pass / 8 skipped, `renderer` 1283 pass with `tsc --noEmit` clean, `pytest tests/` all pass, `check-node-test-count.py` and `tests/test_doc_counts.py` agree (Agent.md 1283 + 282 labels).
Owner
Author
|
The host waived the three-vote gate for this version (2026-12-03T21:10, in session Gates measured on head
|
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
v0.3.88 and v0.3.89 shipped an annotation panel into a view that has no way to be opened. The panel lived in a second
WebContentsViewcreated byensurePreviewView()and reached throughemrg:previewHtml/emrg:closePreview/emrg:getPreviewState/emrg:panelResized— and no renderer file called any of them (grep -rn previewHtml emrg/gui/renderer= 0 hits). There was no button, no menu item and no shortcut, so the feature could not be exercised at all.What was being asked for is the editor's browser mode — the globe toggle in
EditorPanel.tsx(editor-toggle-browser), backed byensureBrowserView(). That is the surface the host uses, and it had no annotation.The change
The unopenable view is gone.
ensurePreviewView,showPreview,previewRect,updatePreviewBounds, the four IPC channels, the window-resize bounds sync and the renderer's exposure ofpreviewHtml/closePreview/panelResized/getPreviewStateare deleted. No channel is left behind without a handler, and no handler without a channel.The panel moves to the page it belongs to.
preview-preload.jsbecomesannotation-preload.jsand is mounted on the browser view. Both areWebContentsViews composited above the app's window, which is why the panel cannot be a DOM layer in the renderer and has to be drawn inside the document — that reason is unchanged, its host is not.A network page carries nothing. Electron cannot swap a preload on navigation, so the same preload is mounted for every address this view loads, and it asks the address before it builds anything:
location.protocol !== "file:"returns before a panel or a listener exists.browser-policy.jsgainsannotationAllowed(url)for the same question on the main-process side.These two checks are not two carriers of one rule, and the PR does not treat them as such: the preload's answer decides only whether to draw, while what may leave is decided in one place —
ipcMain.on("emrg:pageAnnotate")accepts a batch only from that view's ownwebContents, only while the address main itself recorded passesannotationAllowed, and it computes the file withfileURLToPathfrom that address. A file name or an address reported by the page is never used.The batch reaches the composer unchanged. Up
emrg:pageAnnotate, downemrg:pageAnnotation,onPageAnnotationinpreload.js, andShell.tsxstill hands the composed message to the composer — queueing, the user record and the session all live on that one path.Guards
test/annotation-wiring.test.js(rewritten frompreview-annotation-wiring.test.js) pins six things:annotation-preload.jsandbuild.filesnames it — a preload is not arequire, so no other scan would put it inapp.asar(v0.3.88's own defect);main()runs, at the onlymain();call site, so a network page builds no panel and installs no listener;annotationAllowedgate andfileURLToPathare all present, andpayload.file/payload.pathare absent — the page's own claim is not read;contextBridge, noexposeInMainWorld, nowindow.emrg(comment-stripped before asserting);composeMessage+setComposerSend;ensurePreviewViewandshowPrevieware absent frommain.js, the five names absent frompreload.js, andpreview-preload.jsdoes not exist.browser-policy.test.jsgains a case forannotationAllowed(file:in,http/https/about:and "no address at all" out).Measured
cd emrg/gui && npm test— 283 pass, 8 skipped, 0 failcd emrg/gui/renderer && npm run typecheck && npm test—tsc --noEmitclean, 1283 passuv run --no-sync python -m pytest tests/ -q— 7000 passed, 36 skippedscripts/check-node-test-count.py—OK: Agent.md documents 1283 renderer + 282 GUI tests, andtests/test_doc_counts.pypassesnode --check main.js preload.js annotation-preload.js browser-policy.js— clean