Skip to content

Shared task board where people and AI coding agents work as teammates. Source-available, self-hostable.

Go

fix(hub): init subagent registry on startup and cleanup on shutdown

yushen6bd068a97f73
diff --git a/src/hub/hub.ts b/src/hub/hub.ts
index bc86bfdb2d..3181895079 100644
--- a/src/hub/hub.ts
+++ b/src/hub/hub.ts
@@ -12,6 +12,7 @@ import { AsyncAgent } from "../agent/async-agent.js";
import type { AgentOptions } from "../agent/types.js";
import { getHubId } from "./hub-identity.js";
import { setHub } from "./hub-singleton.js";
+import { initSubagentRegistry, shutdownSubagentRegistry } from "../agent/subagent/index.js";
import { loadAgentRecords, addAgentRecord, removeAgentRecord } from "./agent-store.js";
import { RpcDispatcher, RpcError } from "./rpc/dispatcher.js";
import { createGetAgentMessagesHandler } from "./rpc/handlers/get-agent-messages.js";
@@ -53,6 +54,9 @@ export class Hub {
// Register as global singleton for cross-module access (subagent tools, announce flow)
setHub(this);
+ // Restore subagent registry from persistent state
+ initSubagentRegistry();
+
this.client = this.createClient(this.url);
this.client.connect();
this.restoreAgents();
@@ -292,6 +296,9 @@ export class Hub {
}
shutdown(): void {
+ // Finalize subagent registry before closing agents
+ shutdownSubagentRegistry();
+
for (const [id, agent] of this.agents) {
agent.close();
this.agents.delete(id);