refactor sse

This commit is contained in:
d-kimsuon
2025-09-21 07:50:50 +09:00
parent f299e8f8bb
commit 7211ddeb5a
7 changed files with 20 additions and 9 deletions

View File

@@ -444,6 +444,7 @@ export const routes = (app: HonoAppType) => {
) => {
stream.writeSSE("taskChanged", {
aliveTasks: event.aliveTasks,
changed: event.changed,
});
};
@@ -451,6 +452,7 @@ export const routes = (app: HonoAppType) => {
eventBus.on("sessionChanged", onSessionChanged);
eventBus.on("taskChanged", onTaskChanged);
const { connectionPromise } = adaptInternalEventToSSE(rawStream, {
timeout: 5 /* min */ * 60 /* sec */ * 1000,
cleanUp: () => {
eventBus.off("sessionListChanged", onSessionListChanged);
eventBus.off("sessionChanged", onSessionChanged);

View File

@@ -368,8 +368,11 @@ export class ClaudeCodeTaskController {
Object.assign(target, task);
this.eventBus.emit("taskChanged", {
aliveTasks: this.aliveTasks,
});
if (task.status === "paused" || task.status === "running") {
this.eventBus.emit("taskChanged", {
aliveTasks: this.aliveTasks,
changed: task,
});
}
}
}

View File

@@ -18,6 +18,7 @@ export type InternalEventDeclaration = {
taskChanged: {
aliveTasks: AliveClaudeCodeTask[];
changed: AliveClaudeCodeTask;
};
permissionRequested: {