Reduce daemon churn from terminals and archived agents

Decouple terminal list snapshots from workspace status invalidation, and filter archived stored agents before projection so seeded homes do less work.
This commit is contained in:
Mohamed Boudra
2026-06-15 20:07:33 +07:00
parent 754f6336c0
commit 1c9e78616f
16 changed files with 837 additions and 105 deletions
@@ -188,14 +188,6 @@ function watchTerminal(session: TerminalSession): void {
]);
}
manager.subscribeTerminalsChanged((event) => {
sendToParent({
type: "terminalsChanged",
cwd: event.cwd,
terminals: event.terminals,
});
});
function enqueueCreateTerminalRequest(message: TerminalCreateRequest): Promise<void> {
const nextRequest = createTerminalQueue.then(() => handleCreateTerminalRequest(message));
createTerminalQueue = nextRequest.catch(() => {});
@@ -265,33 +257,17 @@ async function handleRequest(message: TerminalWorkerRequest): Promise<void> {
}
case "killTerminal": {
const session = manager.getTerminal(message.terminalId);
const cwd = session?.cwd;
manager.killTerminal(message.terminalId);
// Removal is owned by session.onExit -> terminalExit; the parent mirror
// clears contribution and emits terminalsChanged from that single path.
clearTerminalSubscriptions(message.terminalId);
if (cwd) {
sendToParent({
type: "terminalRemoved",
terminalId: message.terminalId,
cwd,
});
}
sendToParent({ type: "response", requestId: message.requestId, ok: true });
return;
}
case "killTerminalAndWait": {
const session = manager.getTerminal(message.terminalId);
const cwd = session?.cwd;
await manager.killTerminalAndWait(message.terminalId, message.options);
clearTerminalSubscriptions(message.terminalId);
if (cwd) {
sendToParent({
type: "terminalRemoved",
terminalId: message.terminalId,
cwd,
});
}
sendToParent({ type: "response", requestId: message.requestId, ok: true });
return;
}