Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion plugins/stewards/DESIGN.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
52 changes: 52 additions & 0 deletions plugins/stewards/server.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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());
Expand Down
16 changes: 15 additions & 1 deletion plugins/stewards/server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1465,6 +1465,10 @@ export function createStewardsPlugin(deps: StewardsDeps): (bb: BbPluginApi) => P
async function showSteward(b: Binding): Promise<void> {
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");
Expand Down Expand Up @@ -1630,6 +1634,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;
}
Expand Down Expand Up @@ -3617,6 +3624,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;
}
Expand Down Expand Up @@ -3826,10 +3837,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);
}
});
Expand Down
Loading