fix(backend): track Pi turn lifecycle

This commit is contained in:
User
2026-07-14 20:39:45 +02:00
parent 37cc42bebf
commit aba8666f16
4 changed files with 143 additions and 4 deletions
+2
View File
@@ -94,6 +94,7 @@ export class PiProcessManager {
const rpc = new RpcClient(child);
const bridge = new SessionBridge(rpc);
const rt: SessionRuntime = { rpc, bridge, child };
bridge.beginTurn();
this.runtimes.set(sessionId, rt);
// Identity-checked: a stale child's exit must not evict a newer runtime.
// Expected teardowns (teardown()/respawn) delete the runtime from the map BEFORE the
@@ -136,6 +137,7 @@ export class PiProcessManager {
const message = o.mode === "resume"
? `/riprendi-sessione ${sessionId}`
: `/nuova-domanda ${JSON.stringify(o.question ?? "")}`;
rt.bridge.beginTurn();
rt.rpc.send({ type: "prompt", message });
}