fix(sidebar): exclude watch_folders heartbeat from active task count
The watcher worker reports its periodic watch_folders task as perpetually active, which kept the sidebar background-activity spinner running even when no real work was in flight. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -20,11 +20,21 @@ function pendingTasks(ws: WorkerStatus | undefined): number {
|
|||||||
|
|
||||||
/** Tasks actively being executed by workers right now. Distinct from
|
/** Tasks actively being executed by workers right now. Distinct from
|
||||||
* pendingTasks so we can drop the spinner the moment no real work is
|
* pendingTasks so we can drop the spinner the moment no real work is
|
||||||
* in flight, even if reserved tasks linger. */
|
* in flight, even if reserved tasks linger.
|
||||||
|
*
|
||||||
|
* Excludes the periodic `watch_folders` heartbeat — the watcher
|
||||||
|
* worker reports it as a perpetually-active task, which would pin
|
||||||
|
* the spinner on indefinitely with no real work in flight. */
|
||||||
|
const IDLE_TASK_NAMES = new Set(['watch_folders'])
|
||||||
function activeTasks(ws: WorkerStatus | undefined): number {
|
function activeTasks(ws: WorkerStatus | undefined): number {
|
||||||
if (!ws) return 0
|
if (!ws) return 0
|
||||||
return (
|
return (
|
||||||
ws.workers?.reduce((sum, w) => sum + (w.active ?? 0), 0) ?? 0
|
ws.workers?.reduce((sum, w) => {
|
||||||
|
const real = (w.active_tasks ?? []).filter(
|
||||||
|
(t) => !IDLE_TASK_NAMES.has(t.name),
|
||||||
|
).length
|
||||||
|
return sum + real
|
||||||
|
}, 0) ?? 0
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user