Compare commits
No commits in common. "5915014c2e56787a196e97cc637a00f7713e2fb7" and "2ebbadbeffc4b86cdc3068d7f7228591818a9ca3" have entirely different histories.
5915014c2e
...
2ebbadbeff
@ -119,28 +119,13 @@ class TaskEventBus {
|
|||||||
timestamp: Date.now()
|
timestamp: Date.now()
|
||||||
};
|
};
|
||||||
|
|
||||||
const isTerminal = task.status === 'completed' || task.status === 'failed' || task.status === 'cancelled';
|
|
||||||
const wasTerminal = prevStatus === 'completed' || prevStatus === 'failed' || prevStatus === 'cancelled';
|
|
||||||
|
|
||||||
// Bootstrap silently. When this is the first time we've ever seen a task
|
|
||||||
// AND it's already in a terminal state, we have NO evidence it
|
|
||||||
// transitioned just now — it might have completed seconds or hours ago.
|
|
||||||
// The backend re-broadcasts the file's contents on any inode change (e.g.
|
|
||||||
// the periodic ownership/permission sweep stats every task file), so
|
|
||||||
// firing taskCompleted here would surface a "ghost" completion
|
|
||||||
// notification for a task the user already saw finish 28 minutes ago.
|
|
||||||
// Just record it in our map and move on.
|
|
||||||
if (isNew && isTerminal) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (isNew) {
|
if (isNew) {
|
||||||
window.dispatchEvent(new CustomEvent('taskCreated', { detail }));
|
window.dispatchEvent(new CustomEvent('taskCreated', { detail }));
|
||||||
}
|
}
|
||||||
|
|
||||||
// Genuine transition to terminal: we had a prior non-terminal record and
|
const isTerminal = task.status === 'completed' || task.status === 'failed' || task.status === 'cancelled';
|
||||||
// the current upsert flips that to terminal. This is what users expect
|
const wasTerminal = prevStatus === 'completed' || prevStatus === 'failed' || prevStatus === 'cancelled';
|
||||||
// to be notified about.
|
|
||||||
if (isTerminal && !wasTerminal) {
|
if (isTerminal && !wasTerminal) {
|
||||||
window.dispatchEvent(new CustomEvent('taskCompleted', { detail }));
|
window.dispatchEvent(new CustomEvent('taskCompleted', { detail }));
|
||||||
} else if (!isNew) {
|
} else if (!isNew) {
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user