Improve session reconnect behavior

This commit is contained in:
Federico Jaramillo Martinez
2026-05-07 13:00:10 +02:00
parent fd28af3c93
commit ad05497319
10 changed files with 114 additions and 15 deletions
+8 -2
View File
@@ -135,7 +135,7 @@ export class PiSessionService {
this.bindRuntime(active);
runtime.setRebindSession(async () => this.bindRuntime(active));
this.active.set(runtime.session.sessionId, active);
this.events.publish(runtime.session.sessionId, { type: "status.update", status: this.statusFromSession(runtime.session) });
this.publishStatus(runtime.session);
return active;
}
@@ -147,11 +147,17 @@ export class PiSessionService {
const { session } = active.runtime;
active.unsubscribe = session.subscribe((event) => {
this.events.publish(session.sessionId, toClientEvent(event));
this.events.publish(session.sessionId, { type: "status.update", status: this.statusFromSession(session) });
this.publishStatus(session);
});
this.active.set(session.sessionId, active);
}
private publishStatus(session: AgentSession): void {
const status = this.statusFromSession(session);
this.events.publish(session.sessionId, { type: "status.update", status });
this.events.publishGlobal({ type: "status.update", status });
}
private statusFromSession(session: AgentSession): ClientSessionStatus {
const stats = session.getSessionStats();
return {