experiments in a post-browser web
10
fork

Configure Feed

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

feat(pubsub): Phase 5 — delete cmd:request-registers replay machinery

+49 -44
-9
app/cmd/background.js
··· 361 361 api.pubsub.publish('cmd:query-commands-response', { commands }, api.scopes.GLOBAL); 362 362 }, api.scopes.GLOBAL); 363 363 364 - // Request every booted tile re-emit its cmd:register events. Tiles that 365 - // registered their commands during their own init may have done so before 366 - // this extension's `cmd:register` subscriber was live on main-side — the 367 - // broadcaster iterates tileWindows at publish time, so any tile registered 368 - // in tileWindows after the publish never saw those events. Each tile- 369 - // preload caches its `cmd:register` payloads and replays them in response 370 - // to this request. See smoke.spec.ts:1502 flake analysis. 371 - api.pubsub.publish('cmd:request-registers', {}, api.scopes.GLOBAL); 372 - 373 364 log('ext:cmd', 'Command registry initialized'); 374 365 }; 375 366
+48
backend/electron/tile-preload-no-request-registers.test.ts
··· 1 + /** 2 + * Phase 5: replay machinery removal. 3 + * 4 + * Asserts the compiled tile-preload.cjs carries no reference to the 5 + * deleted `cmd:request-registers` replay topic, the `registeredPayloads` 6 + * cache, or the `ensureCmdRequestRegistersListener` installer. Phase 4 7 + * made the subscribe-before-publish invariant load-bearing (Core's 8 + * subscribers are live before any tile reaches `ready`), so the replay 9 + * topic has no job and must not linger as dead code. 10 + * 11 + * Mirrors the "tile-ipc.js does not register a tile:command:result 12 + * handler" style assertion from tile-ipc.test.ts (Phase 3). 13 + */ 14 + 15 + import { describe, it } from 'node:test'; 16 + import * as assert from 'node:assert'; 17 + import { readFileSync } from 'node:fs'; 18 + import { fileURLToPath } from 'node:url'; 19 + import { dirname, join } from 'node:path'; 20 + 21 + // At runtime under ELECTRON_RUN_AS_NODE=1 this test file lives at 22 + // dist/backend/electron/tile-preload-no-request-registers.test.js and the 23 + // compiled preload module is its sibling tile-preload.cjs (emitted from 24 + // tile-preload.cts). 25 + const hereDir = dirname(fileURLToPath(import.meta.url)); 26 + const compiledPreload = join(hereDir, 'tile-preload.cjs'); 27 + 28 + describe('Phase 5: cmd:request-registers replay machinery is gone', () => { 29 + it('compiled tile-preload.cjs contains no reference to cmd:request-registers', () => { 30 + const src = readFileSync(compiledPreload, 'utf8'); 31 + assert.ok( 32 + !src.includes('cmd:request-registers'), 33 + 'tile-preload.cjs still references cmd:request-registers — Phase 5 deleted that replay topic' 34 + ); 35 + }); 36 + 37 + it('compiled tile-preload.cjs does not install the replay listener or cache', () => { 38 + const src = readFileSync(compiledPreload, 'utf8'); 39 + assert.ok( 40 + !src.includes('ensureCmdRequestRegistersListener'), 41 + 'tile-preload.cjs still installs ensureCmdRequestRegistersListener — Phase 5 deleted it' 42 + ); 43 + assert.ok( 44 + !src.includes('registeredPayloads'), 45 + 'tile-preload.cjs still maintains the registeredPayloads cache — Phase 5 deleted it' 46 + ); 47 + }); 48 + });
-34
backend/electron/tile-preload.cts
··· 247 247 // re-registers the same command (swap handler in-place instead of adding a 248 248 // second `pubsub:cmd:execute:{name}` listener). 249 249 const registeredCommands = new Map<string, (params: unknown) => unknown>(); 250 - // Cache of cmd:register publish payloads so we can re-emit them if a later- 251 - // booting cmd extension asks via `cmd:request-registers`. Without this, a 252 - // tile that registers its commands during module init can have its events 253 - // dropped if the cmd extension's subscriber wasn't yet live on main-side — 254 - // the broadcaster iterates `tileWindows` unconditionally but only at the 255 - // moment of publish. See smoke.spec.ts:1502 flake analysis. 256 - const registeredPayloads = new Map<string, Record<string, unknown>>(); 257 - let cmdRequestRegistersListenerInstalled = false; 258 - 259 - function ensureCmdRequestRegistersListener(): void { 260 - if (cmdRequestRegistersListenerInstalled) return; 261 - cmdRequestRegistersListenerInstalled = true; 262 - // Synchronous upstream subscribe (same pattern as subscribeImpl post-fix). 263 - // On request, re-emit every cached cmd:register payload so a freshly- 264 - // booted cmd extension gets this tile's registry. 265 - ipcRenderer.send('tile:pubsub:subscribe', { 266 - token: tileToken, 267 - source: sourceAddress, 268 - topic: 'cmd:request-registers', 269 - }); 270 - ipcRenderer.on('pubsub:cmd:request-registers', () => { 271 - for (const payload of registeredPayloads.values()) { 272 - ipcRenderer.send('tile:pubsub:publish', { 273 - token: tileToken, 274 - source: sourceAddress, 275 - scope: 3, // GLOBAL 276 - topic: 'cmd:register', 277 - data: payload, 278 - }); 279 - } 280 - }); 281 - } 282 250 283 251 function hasCommandsCapability(): boolean { 284 252 const cc = grantedCapabilities?.commands; ··· 368 336 produces: produces || [], 369 337 params: params || [], 370 338 }; 371 - registeredPayloads.set(name, registerPayload); 372 - ensureCmdRequestRegistersListener(); 373 339 ipcRenderer.send('tile:pubsub:publish', { 374 340 token: tileToken, 375 341 source: sourceAddress,
+1 -1
docs/tasks.md
··· 16 16 17 17 - [x] **Consolidate command-result paths into one.** DONE 2026-04-23 as Phase 3 of pubsub-state-machine.md. The `tile:command:result` side-channel (preload send site + main-process unrestricted `publish()` handler) is gone; all command results now flow through the capability-gated `tile:pubsub:publish` of `cmd:execute:{name}:result:{uuid}` via the infra carve-out (commit `f32063db`). 18 18 19 - - [ ] **UI-level tests for cmd-panel repeat invocation.** The 2026-04-23 repro (`tests/desktop/cmd-execute-twice.spec.ts`) fires on the pubsub bus directly and passes 3/3. Manual testing caught a 3rd-invocation stall that the bus test misses — the difference must be panel UI state (`state.executionTimeout`, `urlSearchTimer`, subscription lifetime in `ensureCmdRequestRegistersListener`) leaking across repeats. Add Playwright tests that drive Cmd+K → type → Enter 3-5x in a row and assert panel closes + no spinner. 19 + - [ ] **UI-level tests for cmd-panel repeat invocation.** The 2026-04-23 repro (`tests/desktop/cmd-execute-twice.spec.ts`) fires on the pubsub bus directly and passes 3/3. Manual testing caught a 3rd-invocation stall that the bus test misses — the difference must be panel UI state (`state.executionTimeout`, `urlSearchTimer`, command subscription lifetime) leaking across repeats. Add Playwright tests that drive Cmd+K → type → Enter 3-5x in a row and assert panel closes + no spinner. 20 20 21 21 --- 22 22