Skip to content
Open
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 7 additions & 2 deletions apps/frontend/src/main/task-state-manager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -362,7 +362,12 @@ export class TaskStateManager {

const phase = XSTATE_TO_PHASE[xstateState] || 'idle';

// Emit execution progress with the phase derived from XState
// Emit execution progress with the phase derived from XState.
// IMPORTANT: Do NOT use Date.now() as sequenceNumber here — doing so would
// permanently block all subsequent agent execution-progress events, because
// the agent uses small sequential integers (1, 2, 3…) that are always less
// than a timestamp. Instead emit with sequenceNumber=0 so the agent's own
// events can continue updating phaseProgress once the phase is established.
safeSendToRenderer(
this.getMainWindow,
IPC_CHANNELS.TASK_EXECUTION_PROGRESS,
Expand All @@ -372,7 +377,7 @@ export class TaskStateManager {
phaseProgress: phase === 'complete' ? 100 : 50,
overallProgress: phase === 'complete' ? 100 : 50,
message: `State: ${xstateState}`,
sequenceNumber: Date.now() // Use timestamp as sequence to ensure it's newer
sequenceNumber: 0
},
Comment on lines +365 to 381
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🔴 Critical

🧩 Analysis chain

🏁 Script executed:

rg -n "updateExecutionProgress|incomingSeq|currentSeq|sequenceNumber" --type ts --type tsx -C 3 apps/frontend/src/renderer/

Repository: AndyMik90/Auto-Claude

Length of output: 92


🏁 Script executed:

rg -n "updateExecutionProgress|incomingSeq|currentSeq" apps/frontend/src/renderer/ -C 3

Repository: AndyMik90/Auto-Claude

Length of output: 8389


🏁 Script executed:

sed -n '416,460p' apps/frontend/src/renderer/stores/task-store.ts

Repository: AndyMik90/Auto-Claude

Length of output: 1875


Sequence guard doesn't filter sequenceNumber: 0 mid-task—progress bar will reset.

The renderer's sequence guard at line 435 of apps/frontend/src/renderer/stores/task-store.ts only drops updates when incomingSeq > 0 && currentSeq > 0 && incomingSeq < currentSeq. When the main process sends sequenceNumber: 0 (as this fix does), the condition incomingSeq > 0 is false, so the guard is bypassed entirely. The update proceeds to merge at line 451-454, applying phaseProgress: 0 to the task state.

This means every XState mid-task transition (e.g., planning → coding while the agent is running) will reset the progress bar to 0%, which is the exact regression the PR commit message claims to avoid. The sequence guard has no logic to treat sequenceNumber: 0 as a special sentinel that should be dropped when currentSeq > 0.

Either update the renderer's guard to explicitly drop sequenceNumber: 0 when currentSeq > 0:

if ((incomingSeq === 0 && currentSeq > 0) || (incomingSeq > 0 && currentSeq > 0 && incomingSeq < currentSeq)) {
  return t; // Skip update
}

Or use a distinct sentinel value (e.g., sequenceNumber: -1) with explicit renderer handling.

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@apps/frontend/src/main/task-state-manager.ts` around lines 365 - 381, The
renderer's sequence guard (the check using incomingSeq and currentSeq in the
task-store update path that merges IPC_CHANNELS.TASK_EXECUTION_PROGRESS
payloads) must treat sequenceNumber=0 as a special sentinel so mid-task updates
don't reset progress; update that guard (the condition that currently reads
incomingSeq > 0 && currentSeq > 0 && incomingSeq < currentSeq) to also skip when
incomingSeq === 0 && currentSeq > 0 (or alternatively change the main-process
sender safeSendToRenderer for IPC_CHANNELS.TASK_EXECUTION_PROGRESS to use a
distinct sentinel like -1 and update the renderer's guard to handle that
sentinel), ensuring variables referenced (incomingSeq/currentSeq and the
TASK_EXECUTION_PROGRESS handler that merges phaseProgress/overallProgress) are
adjusted accordingly.

projectId
);
Expand Down
Loading