From 8bd37bcdbff84db5c656fa376ddce445539c980b Mon Sep 17 00:00:00 2001 From: Jean-Baptiste Date: Sun, 23 Aug 2026 22:29:43 +0200 Subject: [PATCH] fix(grid): rename pruneStaleSubagents so sidebar.js stops shadowing it Renderer files load as plain non-module scripts sharing one global scope, and index.html loads sidebar.js (:136) after grid-view.js (:132). Both declared a top-level pruneStaleSubagents(), so the later declaration won: wrapInGridCard() was calling sidebar.js's prune against activeSubagentsByParent instead of the grid's own activeSubagents map. Two consequences: a grid subagent pill whose parent PTY died before the subagent-completed event stayed "running" forever, and every grid card re-wrap triggered a spurious prune of the sidebar's map. Rename the grid-side function; sidebar.js is untouched. The new test pins both the absence of colliding top-level names between the two files and the end-to-end TTL prune through the real wrapInGridCard() call site. --- .ai/contexts/subagent-observability.md | 8 + public/grid-view.js | 6 +- test/dom-grid-sidebar-prune-collision.test.js | 147 ++++++++++++++++++ 3 files changed, 158 insertions(+), 3 deletions(-) create mode 100644 test/dom-grid-sidebar-prune-collision.test.js diff --git a/.ai/contexts/subagent-observability.md b/.ai/contexts/subagent-observability.md index 653e3e43..b3a5a3e6 100644 --- a/.ai/contexts/subagent-observability.md +++ b/.ai/contexts/subagent-observability.md @@ -83,6 +83,14 @@ This is the **#1 fork-specific feature** (upstream PR #47 still pending). It per - **`subagentDomId()`** mirrors `subagentSessionId()` in `read-session-file.js` — that file is main-process and not `require()`-able from the renderer (sidebar.js loads as a plain script), hence the local copy. +- **Grid view keeps its own parallel tracking** (`activeSubagents` + + `pruneStaleGridSubagents()` in `grid-view.js`, pruned from `wrapInGridCard()` + rather than on a timer). Renderer files are plain non-module `