pub(super) async fn maybe_reuse_editor_pane(
state: &AppState,
caller_block_id: &str,
file: &str,
connection: &str,
) -> Result<Option<PaneOpenResult>, String>Expand description
If the calling agent (identified by its own block id, caller_block_id)
already has an Editor pane open in its own tab, push file into that
pane as a new tab instead of creating another Editor pane. Returns
Ok(None) when there’s no existing Editor pane to reuse (or the caller’s
tab can’t be resolved) — the normal create-new-block path handles that
case unchanged.
Known, accepted limitation: does not apply layout focus. An earlier
version of this function resolved the reused block’s layout leaf id and
dispatched Command::SetFocusedNode — reagent (PR #2404) confirmed the
leaf-id resolution itself was correct, then found a deeper problem:
the frontend’s onBackendUpdate (frontend/layout/lib/layoutPersistence.ts)
only re-derives focusedNodeId at initial model construction or via a
pendingBackendActions-driven tree action — a bare focusednodeid
MuxObj push to an ALREADY-MOUNTED LayoutModel (confirmed by reading
the function directly: no branch reads muxObj.focusednodeid outside
those two triggers) is silently never applied to the live treeState.
Making that work would mean changing onBackendUpdate’s reactivity —
shared code this file’s own comments show has deliberately been kept
narrow/non-reactive before (see the dangling-leaf-prune history right
above it) — a real, separate piece of work, not a one-line fix. Shipping
a backend dispatch that compiles and passes a reducer-internal test but
has no visible frontend effect would be worse than not attempting it: it
would look done without being done. The reused pane’s new tab still
becomes its own active tab via openFile(); only the cross-pane
layout-focus indicator is unaffected, same as before this feature
existed.