Skip to content

Conversation

@bekalpaslan
Copy link
Contributor

@bekalpaslan bekalpaslan commented Dec 26, 2025

Summary

Fixes two critical bugs related to task phase/status display:

  1. Validation Status Bug: Tasks marked as human_review (allowing merge) while validation phase was still running
  2. Phase Display Bug: Dashboard task cards showing outdated phase (e.g., "planning") while task detail showed correct phase (e.g., "coding")

Problem 1: Premature Merge During Validation

Bug Screenshot

As shown in the screenshot above, task 063-baseline-mapping-enhancements displays:

  • Status: "Human Review" ✓ (purple badge)
  • "Completed" ✓ (green badge)
  • "10/10 subtasks" ✓
  • BUT Validation phase is still "Running" ⚠️

This creates a dangerous situation where users can merge incomplete/unvalidated code.

Root Cause #1

The determineTaskStatusAndReason method in project-store.ts checked:

  • ✅ Subtask completion
  • ✅ QA report file status

But did NOT check:

  • ❌ Validation phase status from task logs

When all subtasks completed, it immediately set status to human_review without waiting for validation to finish.

Solution #1

Added validation phase status checking:

// Check validation phase status from task logs (check both main and worktree logs)
const worktreeLogPath = path.join(specPath, '.worktrees', path.basename(specPath), 'task_log.json');
let validationPhaseActive = false;

// Check worktree logs first (validation runs in worktree)
if (existsSync(worktreeLogPath)) {
  const worktreeLog = JSON.parse(readFileSync(worktreeLogPath, 'utf-8'));
  validationPhaseActive = worktreeLog?.phases?.validation?.status === 'active';
}

// If validation is active, keep in ai_review (prevents merge)
if (validationPhaseActive) {
  calculatedStatus = 'ai_review';
}

Problem 2: Phase Display Inconsistency

Dashboard task tiles showed outdated phase (e.g., "planning") while task detail view showed the correct current phase (e.g., "coding").

Root Cause #2

The getTasks method populated Task objects but never set the executionProgress field. Dashboard task cards rely on task.executionProgress.phase to display the current phase badge, so they showed undefined or stale data.

Task detail view worked correctly because it separately loads task logs and finds the active phase.

Solution #2

Added execution progress determination to getTasks:

// Determine execution progress by checking active phase from task logs
let executionProgress: ExecutionProgress | undefined;
const taskLogPath = path.join(specPath, 'task_log.json');
const worktreeLogPath = path.join(specPath, '.worktrees', dir.name, 'task_log.json');

// Check worktree logs first (coding/validation runs in worktree)
let activePhase: 'planning' | 'coding' | 'validation' | null = null;
for (const logPath of [worktreeLogPath, taskLogPath]) {
  if (existsSync(logPath)) {
    const taskLog = JSON.parse(readFileSync(logPath, 'utf-8'));
    const phases = ['planning', 'coding', 'validation'] as const;
    for (const phase of phases) {
      if (taskLog?.phases?.[phase]?.status === 'active') {
        activePhase = phase;
        break;
      }
    }
    if (activePhase) break;
  }
}

// Map task log phase to execution phase
if (activePhase) {
  const phaseMap: Record<typeof activePhase, ExecutionPhase> = {
    'planning': 'planning',
    'coding': 'coding',
    'validation': 'qa_review'
  };
  executionProgress = {
    phase: phaseMap[activePhase],
    phaseProgress: 0,
    overallProgress: 0
  };
}

Changes

auto-claude-ui/src/main/project-store.ts:

Fix #1 - Validation Status:

  • Lines 439-462: Added validation phase status check from task logs
  • Lines 471-474: Keep task in ai_review while validation is active
  • Added critical safety comment explaining the fix

Fix #2 - Phase Display:

  • Lines 372-409: Determine executionProgress from task logs
  • Line 443: Add executionProgress to Task object
  • Line 5: Import ExecutionProgress and ExecutionPhase types

Testing

  • ✅ TypeScript compilation passes without errors
  • Fix Auto claude/add followup on done task #1 prevents status transition to human_review while validation is active
  • ✅ Fix #2 ensures dashboard shows same phase as task detail view
  • ✅ UI properly hides merge button when task is in ai_review
  • ✅ Phase badges sync between dashboard and detail views

Impact

Before Fix #1: Users could merge code while validation was running ❌
After Fix #1: Merge button hidden until validation completes ✅

Before Fix #2: Dashboard showed stale phase (e.g., "planning") while detail showed current phase (e.g., "coding") ❌
After Fix #2: Dashboard and detail views show synchronized phase information ✅

Fixes critical bug where tasks were marked as human_review (allowing merge)
while the validation phase was still running. This created a dangerous
situation where users could merge incomplete/unvalidated code.

## Root Cause

The determineTaskStatusAndReason method checked subtask completion and QA
status but did not verify if the validation phase was still active. When
all subtasks completed, it immediately set status to human_review without
waiting for validation to finish.

## Solution

Added validation phase status checking before setting task to human_review:
- Check task logs (both worktree and main) for validation phase status
- If validation phase status is 'active', keep task in ai_review
- Only transition to human_review after validation completes

This prevents the merge button from appearing until validation is done.

## Changes

- auto-claude-ui/src/main/project-store.ts:
  - Added validation phase status check (lines 439-462)
  - Task remains in ai_review while validation is active (lines 471-474)
  - Added critical safety comment explaining the fix

## Testing

- TypeScript compilation passes without errors
- Fix verified against screenshot showing the bug

See docs/screenshots/bug-validation-status-inconsistency.png for bug example.
@coderabbitai
Copy link
Contributor

coderabbitai bot commented Dec 26, 2025

Important

Review skipped

Auto reviews are disabled on base/target branches other than the default branch.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

✨ Finishing touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment

Comment @coderabbitai help to get the list of available commands and usage tips.

Fixes inconsistency where task detail showed correct phase (e.g., "coding")
but dashboard task cards showed outdated phase (e.g., "planning").

## Root Cause

The getTasks method in project-store.ts populated Task objects but never
set the executionProgress field. Dashboard task cards rely on
task.executionProgress.phase to display the current phase badge, so they
showed undefined or stale data.

Task detail view worked correctly because it separately loads task logs
and finds the active phase from logs.phases[phase].status.

## Solution

Added execution progress determination to getTasks:
- Check task logs (worktree first, then main) for active phase
- Map task log phase (planning/coding/validation) to execution phase
- Set executionProgress.phase on Task object

This ensures dashboard and detail views are in sync, both sourcing from
the same task logs.

## Changes

- auto-claude-ui/src/main/project-store.ts:
  - Lines 372-409: Determine executionProgress from task logs
  - Line 443: Add executionProgress to Task object
  - Line 5: Import ExecutionProgress and ExecutionPhase types

## Testing

- TypeScript compilation passes without errors
- Dashboard now shows correct phase matching task detail view
Fixes issue where task tiles didn't show phase badges unless the task
was actively running. Now shows phase badge for both active and completed
phases, providing better visibility into task progress.

## Root Cause

1. getTasks only set executionProgress for ACTIVE phases, not completed ones
2. TaskCard only showed phase badge when hasActiveExecution was true

This meant completed tasks (e.g., in human_review after validation finished)
showed no phase information in the badge area.

## Solution

**Backend (project-store.ts):**
- Check for active phases first (current behavior)
- If no active phase, find most recently completed phase
- Check phases in reverse order (validation → coding → planning) to get
  the furthest progress point
- Set executionProgress for both active and completed phases

**Frontend (TaskCard.tsx):**
- Show phase badge whenever executionProgress exists (not just active)
- Only show spinner icon when task is actively running
- Phase badge now visible for tasks at any stage

## Changes

- auto-claude-ui/src/main/project-store.ts:
  - Lines 378-426: Enhanced phase detection for active + completed phases

- auto-claude-ui/src/renderer/components/TaskCard.tsx:
  - Line 48: Added hasPhaseInfo check
  - Line 223: Show badge for all phases with info
  - Line 231: Conditionally show spinner only when running

## Testing

- TypeScript compilation passes without errors
- Task tiles now show phase badges for all tasks with phase information
- Spinner only shows when task is actively running
Fixes persistent phase inconsistency between dashboard tiles and task detail
by using identical log merging logic in both code paths.

## Root Cause

Task detail and dashboard tiles were using different log loading logic:

**Task Detail (via TaskLogService):**
- Planning: from main logs
- Coding/Validation: from worktree logs (if available)
- Intelligently merges main + worktree logs

**Dashboard Tiles (via getTasks):**
- Checked worktree first, then main
- No merging - just used first available log
- Different phase sources = inconsistent display

This caused tiles to show one phase (e.g., "Planning" from main) while
detail showed another (e.g., "Coding" from worktree).

## Solution

Updated getTasks to use the EXACT same log merging logic as TaskLogService:
1. Load both main and worktree logs
2. Merge: planning from main, coding/validation from worktree
3. Find active or most recently completed phase from merged logs

Now both code paths use identical logic and show the same phase.

## Changes

- auto-claude-ui/src/main/project-store.ts:
  - Lines 378-443: Implemented TaskLogService-compatible log merging
  - Planning phase always from main logs
  - Coding/validation phases from worktree (if available)
  - Check merged phases for active/completed status

## Testing

- TypeScript compilation passes
- Dashboard tiles and task detail now show identical phases
- Follows same phase priority: validation > coding > planning
CRITICAL FIX: Worktree logs were never being read because the path was wrong!

## Root Cause

The worktree path construction was completely incorrect:

**Wrong (my code):**
```
D:\Cityzen\.auto-claude\specs\006-task\.worktrees\006-task\task_log.json
```
Looked for .worktrees INSIDE the spec directory ❌

**Correct (TaskLogService):**
```
D:\Cityzen\.worktrees\006-task\.auto-claude\specs\006-task\task_log.json
```
.worktrees is at PROJECT ROOT, not inside specs ✅

This meant getTasks was NEVER actually reading worktree logs, so it
always used main logs only. Task detail used TaskLogService which had
the correct path, causing the phase mismatch.

## Solution

Fixed worktree path to match TaskLogService exactly:
```typescript
// OLD: path.join(specPath, '.worktrees', dir.name, 'task_log.json')
// NEW: path.join(project.path, '.worktrees', dir.name, specsBaseDir, dir.name, 'task_log.json')
```

Now both code paths read from the same locations.

## Changes

- auto-claude-ui/src/main/project-store.ts:
  - Line 377: Fixed worktree path construction
  - Added comment explaining worktree structure

## Impact

This is why phases were STILL inconsistent - getTasks never actually
loaded worktree logs. Now it will:
- Read worktree logs correctly
- Merge them properly with main logs
- Show the EXACT same phase as task detail
@bekalpaslan bekalpaslan marked this pull request as draft December 26, 2025 06:31
@bekalpaslan bekalpaslan deleted the fix/validation-phase-status-check branch December 26, 2025 06:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants