From efb025a8a7fbce5ca532a5b7b2a3498606344499 Mon Sep 17 00:00:00 2001 From: Dylan Trotter Date: Mon, 26 Oct 2026 13:09:08 +0000 Subject: [PATCH 1/2] stewards: show a hidden steward when a worker of its binding starts (BB-64) --- plugins/stewards/DESIGN.md | 5 +++- plugins/stewards/server.test.ts | 52 +++++++++++++++++++++++++++++++++ plugins/stewards/server.ts | 12 +++++++- 3 files changed, 67 insertions(+), 2 deletions(-) diff --git a/plugins/stewards/DESIGN.md b/plugins/stewards/DESIGN.md index a6343ca5..dd30a4ff 100644 --- a/plugins/stewards/DESIGN.md +++ b/plugins/stewards/DESIGN.md @@ -271,7 +271,10 @@ plugins. stays addressable, and the next wake reaches it. It is made visible again when it needs the user — the report puts the user next, an escalation is open, a question is unanswered, or a needs item is on the Stewards page — - and stays hidden across "nothing changed" wakes. Hiding cascades to the + and stays hidden across "nothing changed" wakes. A steward is shown again + when a worker of its binding starts or runs, so the sidebar's effort stays + rooted at it instead of dropping the worker to a bare row under Threads. + Hiding cascades to the steward's finished workers and their reviewers, so a row is not left behind without its steward; a running worker is unaffected, and showing the steward again shows them. The open-escalation rule stays. A report that diff --git a/plugins/stewards/server.test.ts b/plugins/stewards/server.test.ts index 26b6d1b8..aabee7f7 100644 --- a/plugins/stewards/server.test.ts +++ b/plugins/stewards/server.test.ts @@ -2244,6 +2244,58 @@ describe("stewards waiting on others", () => { expect(t.threads.get(steward)!.visibility).toBe("hidden"); }); + it("shows a hidden steward when a worker of its binding starts (BB-64)", async () => { + const t = await setup(); + t.entities.set("uuid-12", issue({ state: "In Progress", stateType: "started" })); + await t.ring("linear", "uuid-12"); + const steward = t.spawns[1]!.id; + // The steward waits on someone else and its turn ends: hidden. + await t.tool("steward_report", { ...waiting, phase: "In Progress" }, steward); + await t.idle(steward); + expect(t.threads.get(steward)!.visibility).toBe("hidden"); + + // Its hold lifts and it starts a worker: the steward comes back so the + // effort roots at it, not a bare worker row under Threads. + await t.created("thr_w1", steward); + expect(t.threads.get(steward)!.visibility).toBe("visible"); + expect(t.threads.get("thr_w1")!.visibility).toBe("visible"); + }); + + it("shows a hidden steward when its finished worker runs again (BB-64)", async () => { + const t = await setup(); + t.entities.set("uuid-12", issue({ state: "In Progress", stateType: "started" })); + await t.ring("linear", "uuid-12"); + const steward = t.spawns[1]!.id; + await t.created("thr_w1", steward); + await t.idle("thr_w1", "Should I keep the reviewer open?"); + expect(t.hooks.store.worker("thr_w1")!.status).toBe("finished"); + + // The steward is hidden (a hold lift with the worker parked), and its + // worker is woken again: the steward comes back with it. + t.threads.get(steward)!.visibility = "hidden"; + await t.harness.behavior.emitThreadEvent("thread.active", { thread: makeThreadResponse({ id: "thr_w1" }) }); + await t.flush(); + expect(t.hooks.store.worker("thr_w1")!.status).toBe("running"); + expect(t.threads.get(steward)!.visibility).toBe("visible"); + }); + + it("leaves a hidden steward with no worker hidden on a wake that needs nobody (BB-64)", async () => { + const t = await setup(); + t.entities.set("uuid-12", issue({ state: "In Progress", stateType: "started" })); + await t.ring("linear", "uuid-12"); + const steward = t.spawns[1]!.id; + await t.tool("steward_report", { ...waiting, phase: "In Progress" }, steward); + await t.idle(steward); + expect(t.threads.get(steward)!.visibility).toBe("hidden"); + + // A hold-lift wake reaches the steward, but it needs no user and has no + // worker in flight, so it stays hidden until it starts one. + t.entities.set("uuid-12", issue({ state: "In Progress", stateType: "started", comments: [comment({ createdAt: "2026-10-14T16:00:00Z" })] })); + await t.ring("linear", "uuid-12"); + expect(t.sends.at(-1)!.threadId).toBe(steward); + expect(t.threads.get(steward)!.visibility).toBe("hidden"); + }); + it("keeps a steward with an open escalation visible", async () => { const t = await setup(); t.entities.set("uuid-12", issue()); diff --git a/plugins/stewards/server.ts b/plugins/stewards/server.ts index 8932f14e..3f57da67 100644 --- a/plugins/stewards/server.ts +++ b/plugins/stewards/server.ts @@ -1630,6 +1630,9 @@ export function createStewardsPlugin(deps: StewardsDeps): (bb: BbPluginApi) => P }); store.setSecretRequester(thread.id, need.id); store.addWorker(thread.id, b.id, title); + // A requester is a worker of the binding: a steward hidden by hideWaiting + // comes back so the effort roots at it (BB-64). + await showSteward(b); bb.log.info(`stewards: started a requester thread for ${b.entityKey}'s ${variable} (${thread.id})`); return thread.id; } @@ -3617,6 +3620,10 @@ export function createStewardsPlugin(deps: StewardsDeps): (bb: BbPluginApi) => P const runaway = store.spawnsSince(owner.id, now() - 3_600_000) >= limit; store.addWorker(thread.id, owner.id, thread.title ?? thread.titleFallback ?? thread.id); if (!runaway) { + // A hidden steward (hideWaiting, "waits on others") comes back when a + // worker of its binding starts, so the sidebar roots the effort at it + // and the worker is not a bare row under Threads (BB-64). + await showSteward(owner); await validateWorkerSpawn(thread, owner); return; } @@ -3826,10 +3833,13 @@ export function createStewardsPlugin(deps: StewardsDeps): (bb: BbPluginApi) => P // A worker the waiting cascade hid is shown again once it runs (BB-47). if (thread.visibility === "hidden") await quietly(`show running worker ${thread.id}`, () => bb.sdk.threads.update({ threadId: thread.id, visibility: "visible" })); if (worker.status === "finished") store.setWorker(thread.id, "running", worker.result); + const owner = store.binding(worker.bindingId); + // A hidden steward comes back when a worker of its binding runs again, + // so the effort stays rooted at it (BB-64). + if (owner !== null && owner.endedAt === null) await showSteward(owner); // The first turn is dispatched now, so the spawn's model can be read. if (worker.modelCheckPending && worker.status !== "stopped") { store.setWorkerModelCheckPending(thread.id, false); - const owner = store.binding(worker.bindingId); if (owner !== null && owner.endedAt === null) await validateWorkerSpawn(thread, owner); } }); From e211519a93662f31afc314beff81b83d4dd3c1ca Mon Sep 17 00:00:00 2001 From: Dylan Trotter Date: Mon, 26 Oct 2026 13:17:08 +0000 Subject: [PATCH 2/2] stewards: skip the show write when the steward is already visible (BB-64 review) --- plugins/stewards/server.ts | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/plugins/stewards/server.ts b/plugins/stewards/server.ts index 3f57da67..9ba50d26 100644 --- a/plugins/stewards/server.ts +++ b/plugins/stewards/server.ts @@ -1465,6 +1465,10 @@ export function createStewardsPlugin(deps: StewardsDeps): (bb: BbPluginApi) => P async function showSteward(b: Binding): Promise { if (b.threadId === null) return; const info = await threadInfo(b.threadId).catch(() => null); + // Already visible: nothing to show and no write to spend. This runs on + // every worker registration and turn, so the common case is a no-op. A + // lookup that failed is unknown, so the write is still attempted. + if (info !== null && info.visibility === "visible") return; const wasHidden = info !== null && info.visibility === "hidden"; await quietly(`show ${b.entityKey}'s steward`, () => bb.sdk.threads.update({ threadId: b.threadId!, visibility: "visible" })); if (wasHidden) await cascadeVisibility(b, "visible");