experiments in a post-browser web
10
fork

Configure Feed

Select the types of activity you want to include in your feed.

chore: audit createExtensionWindow callers (Phase 2.5 #3)

+76 -4
+76 -4
AGENT_REPORT.md
··· 1 1 # Phase 2.5 #3 Agent Report — createExtensionWindow migration audit 2 2 3 - ## Triage stub (in progress) 3 + ## Audit (Phase A) 4 4 5 - Target: migrate `createExtensionWindow()` in `backend/electron/main.ts` from 6 - v1 `preload.js` to v2 tile-preload, OR document why it stays. 5 + Target: `createExtensionWindow()` in `backend/electron/main.ts` (line 1106). 6 + Still uses v1 `preload.js` (`config.preloadPath`). Function creates a 7 + BrowserWindow per extension and loads `peek://ext/{id}/background.html`. 7 8 8 - Initial scan complete. Full audit next — see later sections. 9 + ### Call sites (6 inside main.ts, 2 inside ipc.ts) 10 + 11 + | Site | Caller | Runtime reachability | Bucket | 12 + |------|--------|----------------------|--------| 13 + | main.ts:1213 | `loadEnabledExtensions()` | **DEAD** — exported but never invoked. Replaced by `loadExtensions()` (entry.ts:741). | dead code | 14 + | main.ts:1458 | `loadExtensions()` — `externalBuiltinIds` loop | **EMPTY in practice.** Filter = `registered ∩ !CONSOLIDATED_EXTENSION_IDS ∩ enabled ∩ !v2FeatureIds`. All 35 features in `features/` are v2 (`manifestVersion: 2`) and get loaded by `loadV2Feature()` into `v2FeatureIds`, so this set is empty. | dead in practice | 15 + | main.ts:1467 | `loadExtensions()` — `enabledExternalExts` from `extensions` DB table | Empty under normal test / dev. The `extensions` table is populated by the legacy settings UI `api.extensions.add()` — superseded by features-manager (which installs into the v2 feature registry, not this table). | dead in practice | 16 + | main.ts:1672 | `loadDevExtension()` | Live when user passes `--load-extension` CLI flag. Dev-only. | v1 path, dev-only | 17 + | main.ts:1747 | `reloadExtension()` | **LIVE.** Called by `ipcMain.handle('extension-reload')` (ipc.ts:1374), which is invoked by `api.extensions.reload(id)` on trustedBuiltin tiles (features-manager, test fixtures). | v1 path, live | 18 + | ipc.ts:1287 | `ipcMain.handle('extension-window-load')` | **DEAD** — no renderer invokes this channel (grep). | dead code | 19 + | ipc.ts:1315 | `ipcMain.handle('extension-window-reload')` | **DEAD** — no renderer invokes this channel (grep). | dead code | 20 + 21 + ### Bucket summary 22 + 23 + - **v2-migratable builtin externals:** 0. All features are already loaded through 24 + `loadV2Tile()` / `launchTile()` today — `createExtensionWindow` is never 25 + invoked for them at runtime. 26 + - **Chrome extensions:** 0 — Chrome extensions use a separate path 27 + (`backend/electron/chrome-extensions.ts` + `session.loadExtension()`), not 28 + `createExtensionWindow`. Out of scope as planned. 29 + - **v1-only live callers:** 2 — `reloadExtension` (features-manager) and 30 + `loadDevExtension` (CLI). Both need a v2 "launch/relaunch a tile by id" 31 + helper that doesn't exist yet (tile-launcher has `launchTile(opts)` but no 32 + "find the manifest, revoke the old token, close the old window, relaunch" 33 + convenience). 34 + - **Dead code:** 4 call sites (`loadEnabledExtensions`, two IPC handlers, 35 + + the two startup branches that are empty in practice). Safe to drop. 36 + 37 + ### Implementation choice 38 + 39 + **Exit at audit boundary.** Migrating `reloadExtension` and `loadDevExtension` 40 + requires: 41 + 42 + 1. A `relaunchTile(tileId)` helper in `tile-launcher.ts` that re-reads the 43 + manifest from disk, revokes the old token, closes the old window, and 44 + calls `launchTile` again. 45 + 2. A "find the tile's resident/launch entry from manifest" utility (currently 46 + only `loadV2Tile` does this, and it's tangled with eager/lazy branching). 47 + 3. Handling the dev-extension case where the path is registered 48 + transiently via `registerDevExtension` and not in the feature registry. 49 + 50 + That's 1–2 commits of new infrastructure, not a "remove v1 call site" swap. 51 + Given the 60-minute budget and the audit finding that `createExtensionWindow` 52 + is effectively already replaced for the common path (startup loading), the 53 + correct move is to (a) remove the dead-code call sites cleanly in a follow-up 54 + and (b) defer the remaining two live v1 call sites to a dedicated Phase 2.5 #3b. 55 + 56 + ### Open items for Phase 3 / follow-up 57 + 58 + - **Phase 2.5 #3b** — implement `relaunchTile(tileId)` in tile-launcher.ts; 59 + rewrite `reloadExtension()` and `loadDevExtension()` to use it; delete 60 + `createExtensionWindow`, `loadEnabledExtensions`, the dead IPC handlers, 61 + and the dead `externalBuiltinIds` / `enabledExternalExts` branches. 62 + - Phase 3 can proceed for everything not behind `createExtensionWindow` — 63 + features-manager reload and CLI dev extensions are the only surfaces 64 + that still need v1 `preload.js`. 65 + 66 + ### Files read during audit 67 + 68 + - `backend/electron/main.ts` — createExtensionWindow, loadExtensions, loadEnabledExtensions, reloadExtension, loadDevExtension, discoverBuiltinExtensions 69 + - `backend/electron/ipc.ts` — extension-window-* handlers, extension-reload 70 + - `backend/electron/tile-compat.ts` — loadV2Tile, ensureTileIpcHandlers 71 + - `backend/electron/tile-loader.ts` — loadV2Feature, loadFeaturesFromRegistry 72 + - `backend/electron/feature-startup.ts` — initializeFeatures 73 + - `backend/electron/feature-installer.ts` — syncBuiltinFeatures 74 + - `backend/electron/tile-launcher.ts` — launchTile 75 + - `backend/electron/extensions.ts` — getExternalExtensions (reads `extensions` DB table) 76 + - All `features/*/manifest.json` — confirmed 31 of 31 are `manifestVersion: 2` 77 + 78 + ## Validation 79 + 80 + N/A at audit-commit. No code changes landed.