Skip to main content

META_PENDING_OPEN_FILES

Constant META_PENDING_OPEN_FILES 

Source
const META_PENDING_OPEN_FILES: &str = "editor:pending_open_files";
Expand description

Block-meta key carrying an ARRAY of files the reused pane should open — the sole delivery path (see below for why an earlier version’s second, “live MPS event” path was removed). Drained (all entries, in order) reactively by EditorViewModel’s createEffect over its own block meta, then cleared immediately after — covers both “not yet mounted when this was written” and “already mounted, reacts as soon as the write lands” uniformly through the same MuxObj sync path the pane already depends on for everything else.

Array, not a single scalar (codex P1 on PR #2404): if 2+ OpenEditor reuse calls arrive before the target pane ever mounts, a single-value key would have each call overwrite the last, silently losing every request but the final one. Appending to an array and draining all of them at once fixes that.

Sole delivery path — no separate live MPS event (codex P1 on PR #2404, found twice): an earlier version ALSO fired a direct MPS event (persist: 0) alongside this meta write, for immediate delivery when the pane was already mounted. First finding: the frontend’s live handler didn’t clear its own entry from this array, so it could be reprocessed on a later, unrelated remount. Second, deeper finding after fixing that: the MPS event is a direct WS push and arrives essentially synchronously, while THIS meta write only reaches the frontend’s blockAtom after an async MuxObj DB-refetch — so the live handler’s own dequeue attempt could run and read stale data (this exact write not yet reflected) before it landed, no-op, and strand the entry anyway. Removing the separate live path entirely (rather than patching a second-order race in its own race-fix) leaves one delivery mechanism and one reactive consumer — nothing to race. Trades a small amount of latency for the already-mounted case (a real MuxObj round-trip instead of a direct push) for not being racy.

Superseded relying on MPS persist > 0 for durability (codex P1 on PR #2404, earliest finding on this function): a just-created Editor block may not have finished mounting its EditorViewModel by the time a second back-to-back OpenEditor call reuses it. persist: N closes that race but opens a worse one: Broker::unsubscribe_all clears a route’s replay marker on disconnect (crates/srv/src/backend/mps.rs), so any later, unrelated reconnect would replay the entire persisted history again — reopening files the user has since closed. The broker has no ack/consume concept, so nothing marks a persisted event “already delivered.” Block meta does have exactly that shape (write once, drain once, clear after reading) — reusing it avoids inventing new broker machinery.