Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Agent.md
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ What EMRG does today — capabilities, not a changelog.
Foreground daemon: `python -m emrg`.

- Python: `uv run pytest tests/ -v` — re-count with `uv run --no-sync python3 scripts/check-doc-count.py --measure`. Import check: `uv run python -c "from emrg.client.app import run_client"`
GUI: `cd emrg/gui && npm test` (280: 107 daemon_client + 22 conn-manager + 7 integration + 7 nav-policy + 11 gui-state + 10 build-config + 10 config_fields + 16 boot-contract + 3 preload-api + 2 theme-guard + 2 image-hash + 8 switch-session + 19 atp_login + 4 gui-op-log + 9 theme-setting + 5 window-title + 4 frame-route + 11 browser-policy + 5 browser-wiring + 13 settings_store + 5 preview-annotation-wiring) — syntax: `node --check main.js preload.js daemon_client.js`
GUI: `cd emrg/gui && npm test` (282: 107 daemon_client + 22 conn-manager + 7 integration + 7 nav-policy + 11 gui-state + 10 build-config + 10 config_fields + 16 boot-contract + 3 preload-api + 2 theme-guard + 2 image-hash + 8 switch-session + 19 atp_login + 4 gui-op-log + 9 theme-setting + 5 window-title + 4 frame-route + 12 browser-policy + 5 browser-wiring + 13 settings_store + 6 annotation-wiring) — syntax: `node --check main.js preload.js daemon_client.js`
Renderer: `cd emrg/gui/renderer && npm run typecheck && npm test` (1283: 5 snapshot-store + 13 utils + 3 ErrorBoundary + 2 App + 12 commands + 4 copywriting + 14 i18n + 33 markdown + 22 selection + 41 transcript + 11 conversationType + 4 MarkdownText + 65 TranscriptView + 22 history + 30 historyReplay + 8 userImages + 43 composer + 97 Composer + 14 sidebar + 32 workspaceView + 18 WorkspaceView + 10 dialog + 6 Dialog + 9 ConfirmDialog + 9 RenameDialog + 13 dialogLists + 3 HelpDialog + 9 MemoryDialog + 8 SkillsDialog + 8 openSession + 6 WelcomeDialog + 20 OpenSessionDialog + 14 NewSessionDialog + 7 rewind + 8 RewindDialog + 7 GithubDeviceDialog + 82 daemonBridge + 13 DaemonBridgeProvider + 69 Shell + 19 page + 51 EditorPanel + 25 DialogHost + 48 SettingsPanel + 18 TaskFormDialog + 5 RantDialog + 8 vendorMarkdown + 10 highlightTheme + 8 ApprovalDialog + 20 SandboxRootsDialog + 42 cockpit + 4 editorSelectionCascade + 9 fileTree + 24 FileTree + 5 contextMenu + 1 residue + 24 StatusBand + 24 UsageRanking + 9 usageRanking + 6 SearchOverlay + 5 ResizeHandle + 8 IconRail + 6 SessionColumn + 5 EmrgMark + 38 editorDoc + 27 CodeEditor + 26 annotation + 14 AnnotationMode)
- CI: pytest on ubuntu **and windows-2025**, the GUI suites, and an actionlint gate over `.github/workflows/`; re-trigger a dropped push with `scripts/re-trigger-ci.sh <branch>`, never an empty commit
- Merge gates, run before merging — `uv run --no-sync python3 scripts/check-vote-count.py` · `scripts/check-pr-base.py` · `scripts/check-merge-freshness.py` · `scripts/check-merge-order.py` · `scripts/check-merge-landing-diff.py` · `scripts/check-merge-pairs.py` / `scripts/check-merge-sequence.py` · `scripts/check-merge-tree-health.py` (the merged tree passes one guard) · `scripts/check-merge-plan-suite.py` — all under `uv run --no-sync python3`
Expand Down
30 changes: 23 additions & 7 deletions emrg/gui/preview-preload.js → emrg/gui/annotation-preload.js
Original file line number Diff line number Diff line change
@@ -1,13 +1,23 @@
"use strict";
/**
* preview-preload.js — annotate the HTML preview (host 2026-12-03T18:38:18).
* annotation-preload.js — annotate a local page in the editor's browser mode (host 2026-12-03T20:55).
*
* The preview is its own WebContentsView, composited by the main process *above* the app's own
* Browser mode is a `WebContentsView`, composited by the main process *above* the app's own
* window. That is why the app's floating panel cannot hang over it: a DOM layer in the renderer
* sits under whatever the main process adds with `addChildView`. So the panel for a previewed page
* has to be drawn inside the page, and this file is where that happens.
* sits under whatever the main process adds with `addChildView`. So the panel for a page has to
* be drawn inside the page, and this file is where that happens.
*
* Two properties make that safe, and both are why nothing else lives here.
* A network page gets none of it. Electron cannot swap a preload on navigation, so this one is
* mounted for every address the view loads and asks the address first: unless the document is a
* local `file:` page it returns before building a panel or installing a listener. What a remote
* page therefore never has is an annotation interface. What it cannot have at all is a way to
* make an annotation travel — that gate is in the **main process**, which takes a batch only
* from this view's own webContents, only while the address it recorded is a `file:` one, and
* which computes the file from that address instead of believing one a page reports. The two
* scheme tests are therefore not two carriers of one rule: this one decides whether to draw,
* the main process decides what leaves.
*
* Two properties make drawing safe, and both are why nothing else lives here.
*
* **No `contextBridge`.** The page gets no function, no object, no `window.emrg`. This file runs in
* a preload's own world with DOM access, draws its interface behind a closed shadow root, and is
Expand Down Expand Up @@ -252,7 +262,7 @@ function main() {
.filter((i) => i.body.trim().length > 0)
.map((i) => ({ paragraph: i.paragraph, body: i.body.trim(), selector: i.selector }));
if (payload.length === 0) return;
ipcRenderer.send("emrg:previewAnnotate", { items: payload });
ipcRenderer.send("emrg:pageAnnotate", { items: payload });
items.length = 0;
render();
ui.host.remove();
Expand Down Expand Up @@ -340,7 +350,13 @@ function main() {
});
}

if (document.readyState === "loading") {
// The address is asked before anything is built, and a page that is not a local file gets
// nothing: no panel, no listener, no message. `location.protocol` is read here rather than a
// helper being required because a sandboxed preload has no `require` for local files — which is
// also why this check decides only whether to *draw*, and the main process decides what leaves.
if (location.protocol !== "file:") {
// A network page. Draw nothing.
} else if (document.readyState === "loading") {
document.addEventListener("DOMContentLoaded", main, { once: true });
} else {
main();
Expand Down
21 changes: 19 additions & 2 deletions emrg/gui/browser-policy.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,9 @@
* `window.emrg` bridge — and this browser, which exists to do the opposite: draw a remote
* page inside the app. Two things keep the second from being a hole in the first:
*
* - it is a **different** `WebContentsView`, built with `sandbox: true`,
* `contextIsolation: true` and no preload, so nothing it loads can reach the bridge;
* - it is a **different** `WebContentsView`, built with `sandbox: true` and
* `contextIsolation: true`, and the one preload it carries mounts nothing in a network page
* (`annotationAllowed`), so nothing it loads can reach the bridge;
* - every policy below is installed on the browser's **own partition**, never on the
* default session. `setPermissionRequestHandler`, `will-download`,
* `setCertificateVerifyProc` and `clearStorageData` hang off a `Session`, so a handler
Expand Down Expand Up @@ -52,6 +53,21 @@ function schemeOf(url) {
}
}

/**
* Whether the annotation layer belongs in the page at this address: only a local `file:` page.
*
* The layer draws a floating panel inside the page — the app's own window is composited *under*
* a `WebContentsView`, so inside the document is the only place a panel can hang over a page.
* That is a favour to the host reading a page they are editing, and it stops at `file:`. A
* network page is somebody else's code: no interface of ours is drawn into it, and — because
* `annotation-preload.js` asks this first and returns before installing anything — no listener
* is left in it either. Electron cannot swap a preload on navigation, so this predicate, asked
* in the document, is the boundary rather than a property of the view.
*/
function annotationAllowed(url) {
return typeof url === "string" && /^file:/i.test(url);
}

/** Whether a page may go to this URL at all. */
function navAllowed(url) {
if (typeof url !== "string" || url.length === 0) return false;
Expand Down Expand Up @@ -302,6 +318,7 @@ module.exports = {
BROWSER_PARTITION,
NAV_SCHEMES,
addressTarget,
annotationAllowed,
blocksMainFrameNavigation,
browserNavPolicy,
browserRect,
Expand Down
Loading
Loading