Skip to content

Fix PRD generation progress tracking UI - #194

Merged
frankbria merged 3 commits into
mainfrom
claude/fix-prd-progress-tracking-Ca3tB
Jan 6, 2026
Merged

Fix PRD generation progress tracking UI#194
frankbria merged 3 commits into
mainfrom
claude/fix-prd-progress-tracking-Ca3tB

Conversation

@frankbria

@frankbria frankbria commented Jan 6, 2026

Copy link
Copy Markdown
Owner
  • Backend: Add progress_pct: 100 to prd_generation_completed WebSocket message
  • Frontend DiscoveryProgress: Add onViewPRD callback prop for View PRD button
  • Frontend DiscoveryProgress: Add section minimization after PRD completion (3s delay)
  • Frontend DiscoveryProgress: Add "Next: Task Creation" phase indicator
  • Frontend DiscoveryProgress: Add View PRD button in both expanded and minimized states
  • Frontend Dashboard: Update View PRD button state based on PRD availability
  • Frontend Dashboard: Show spinner and "Generating PRD..." during generation
  • Frontend Dashboard: Pass onViewPRD handler to DiscoveryProgress component
  • Tests: Add PRD progress tracking test cases

Summary by CodeRabbit

  • New Features

    • Real-time PRD progress with reliable 100% completion indicator.
    • PRD button disabled when unavailable; shows spinner and "Generating PRD..." while generating.
    • Discovery progress auto-minimizes after PRD completion, with Expand and View PRD actions.
    • View PRD can be opened from the discovery progress area.
  • Tests

    • Expanded test coverage for PRD progress, WebSocket-driven states, retries, and UI interactions.

✏️ Tip: You can customize this high-level summary in your review settings.

- Backend: Add progress_pct: 100 to prd_generation_completed WebSocket message
- Frontend DiscoveryProgress: Add onViewPRD callback prop for View PRD button
- Frontend DiscoveryProgress: Add section minimization after PRD completion (3s delay)
- Frontend DiscoveryProgress: Add "Next: Task Creation" phase indicator
- Frontend DiscoveryProgress: Add View PRD button in both expanded and minimized states
- Frontend Dashboard: Update View PRD button state based on PRD availability
- Frontend Dashboard: Show spinner and "Generating PRD..." during generation
- Frontend Dashboard: Pass onViewPRD handler to DiscoveryProgress component
- Tests: Add PRD progress tracking test cases
@coderabbitai

coderabbitai Bot commented Jan 6, 2026

Copy link
Copy Markdown
Contributor

Walkthrough

Backend adds progress_pct: 100 to the PRD completion broadcast. Frontend: DiscoveryProgress accepts an optional onViewPRD, auto-minimizes 3s after completion, Dashboard updates PRD button visuals/disabled state and forwards onViewPRD, and tests expand WebSocket-driven coverage for PRD flows.

Changes

Cohort / File(s) Summary
Backend PRD Progress Signaling
codeframe/ui/routers/discovery.py
Adds progress_pct: 100 to the prd_generation_completed WebSocket broadcast payload.
Frontend Component Logic
web-ui/src/components/DiscoveryProgress.tsx
Adds optional onViewPRD prop, isSectionMinimized state, automatic minimization after 3s when PRD completes, and conditional minimized/expanded rendering with View PRD and Expand controls.
Frontend Component Integration
web-ui/src/components/Dashboard.tsx
Passes onViewPRD to DiscoveryProgress; makes PRD button disabled unless status is available, adds dynamic styling by prdData?.status, and shows spinner + "Generating PRD..." during generation.
Frontend Test Coverage
web-ui/__tests__/components/DiscoveryProgress.test.tsx
Adds comprehensive WebSocket test scaffolding and scenarios (start, progress, completed with progress_pct, failures, resets), asserts UI states, minimization behavior, retry/restart flows, callbacks, and keyboard interactions.

Sequence Diagram

sequenceDiagram
  autonumber
  actor User
  participant Dashboard
  participant DiscoveryProgress
  participant WebSocket
  participant Backend

  Backend->>WebSocket: emit `prd_generation_completed` (progress_pct: 100)
  WebSocket->>DiscoveryProgress: broadcast `prd_generation_completed`
  DiscoveryProgress->>DiscoveryProgress: set prdCompleted = true
  Note over DiscoveryProgress: schedule auto-minimize after 3s
  DiscoveryProgress->>Dashboard: render minimized PRD section (or expanded if user opens)
  rect rgb(230,245,235)
    Dashboard->>Dashboard: update PRD button state & styling (based on prdData?.status)
  end
  User->>Dashboard: click "View PRD" (if visible)
  Dashboard->>DiscoveryProgress: invoke `onViewPRD` callback
  DiscoveryProgress->>DiscoveryProgress: open PRD modal / expand view
  alt User manually expands
    User->>DiscoveryProgress: click Expand
    DiscoveryProgress->>DiscoveryProgress: isSectionMinimized = false
  end
Loading

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~45 minutes

Poem

🐰 A hundred lights, a final ping so bright,
I tuck the section in after three small ticks.
A button waits, a hop to bring it sight—
Click, expand, and out the PRD flicks.
Tiny paws, big features, soft delights.

Pre-merge checks and finishing touches

✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly summarizes the main change: improving PRD generation progress tracking in the UI across both backend and frontend components.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.
✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch claude/fix-prd-progress-tracking-Ca3tB

📜 Recent review details

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between bbdcb7b and d56dc3f.

📒 Files selected for processing (1)
  • web-ui/__tests__/components/DiscoveryProgress.test.tsx
🧰 Additional context used
🧠 Learnings (5)
📓 Common learnings
Learnt from: CR
Repo: frankbria/codeframe PR: 0
File: CLAUDE.md:0-0
Timestamp: 2026-01-04T06:26:12.870Z
Learning: Applies to web-ui/src/app/page.tsx : Implement automatic project discovery start after project creation with loading state transitions and 'Start Discovery' button for idle projects
📚 Learning: 2026-01-04T06:26:12.870Z
Learnt from: CR
Repo: frankbria/codeframe PR: 0
File: CLAUDE.md:0-0
Timestamp: 2026-01-04T06:26:12.870Z
Learning: Applies to web-ui/src/app/page.tsx : Implement automatic project discovery start after project creation with loading state transitions and 'Start Discovery' button for idle projects

Applied to files:

  • web-ui/__tests__/components/DiscoveryProgress.test.tsx
📚 Learning: 2026-01-04T06:26:12.870Z
Learnt from: CR
Repo: frankbria/codeframe PR: 0
File: CLAUDE.md:0-0
Timestamp: 2026-01-04T06:26:12.870Z
Learning: Applies to web-ui/src/lib/websocketMessageMapper.ts : Implement WebSocket event mapping with 9 event types (agent_created, task_assigned, etc.) with automatic reconnection using exponential backoff (1s → 30s)

Applied to files:

  • web-ui/__tests__/components/DiscoveryProgress.test.tsx
📚 Learning: 2025-11-25T19:08:37.203Z
Learnt from: CR
Repo: frankbria/codeframe PR: 0
File: docs/CLAUDE.md:0-0
Timestamp: 2025-11-25T19:08:37.203Z
Learning: Applies to docs/web-ui/**/__tests__/**/*.test.{ts,tsx} : Create JavaScript test files colocated or in __tests__/ as *.test.ts

Applied to files:

  • web-ui/__tests__/components/DiscoveryProgress.test.tsx
📚 Learning: 2026-01-04T06:26:12.870Z
Learnt from: CR
Repo: frankbria/codeframe PR: 0
File: CLAUDE.md:0-0
Timestamp: 2026-01-04T06:26:12.870Z
Learning: Applies to tests/e2e/**/*.ts : Implement E2E tests using Playwright + TestSprite with loginUser() helper from tests/e2e/test-utils.ts for authentication

Applied to files:

  • web-ui/__tests__/components/DiscoveryProgress.test.tsx
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (4)
  • GitHub Check: Frontend Unit Tests
  • GitHub Check: Backend Unit Tests
  • GitHub Check: E2E Smoke Tests (Chromium)
  • GitHub Check: claude-review
🔇 Additional comments (8)
web-ui/__tests__/components/DiscoveryProgress.test.tsx (8)

31-54: WebSocket mock infrastructure is well-implemented.

The mock client correctly simulates the real WebSocket behavior with proper handler registration, cleanup, and message broadcasting. The cleanup in beforeEach (line 91) ensures test isolation.


1930-2144: Excellent improvements to PRD progress tracking tests.

These tests now properly address the previous review comments by:

  • Simulating WebSocket messages (prd_generation_completed, prd_generation_progress) to trigger component state changes
  • Asserting on actual progress percentages (10%, 30%, 80%, 100%) during PRD generation
  • Verifying the View PRD button appears and invokes the callback

The tests now comprehensively validate the WebSocket-driven PRD flow.


2151-2454: Comprehensive WebSocket message handler coverage.

These tests thoroughly validate all WebSocket event types and their effects on component state. The project_id filtering test (lines 2424-2453) is particularly valuable for ensuring the component doesn't respond to events from other projects.


2460-2630: Stuck state detection tests are well-designed.

These tests properly validate the 30-second timeout mechanism and restart functionality, including error handling. The use of manually-resolved promises (lines 2596-2628) to test loading states is a good pattern.


2719-2777: Retry loading state test correctly reflects actual behavior.

This test has been properly updated to assert the actual component behavior: when retry is clicked, the error state clears and a loading spinner with "Starting PRD Generation..." appears. This aligns with the commit message stating the test should verify "clicking retry clears error state and shows a loading spinner."


2784-2953: Auto-minimize and view toggle tests are thorough.

These tests properly validate the 3-second auto-minimize feature and the expand/minimize button interactions. The use of act wrappers with timer advances (lines 2814, 2852, 2895) correctly handles React state updates.


2959-2988: Next phase indicator test is clear and focused.

This test properly validates that the "Next: Task Creation" indicator appears when PRD generation completes in the planning phase, matching the PR objectives.


2994-3038: Duplicate submission prevention test is valuable.

This test validates that rapid clicking on the submit button doesn't trigger multiple API calls, which is important for data integrity and user experience. The approach of using a never-resolving promise to keep the submit in-flight is effective.


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

@claude

claude Bot commented Jan 6, 2026

Copy link
Copy Markdown

Code Review: PRD Generation Progress Tracking UI

I've reviewed the changes in this PR. Overall, this is a solid UX improvement with good implementation quality. Here are my findings:


Strengths

1. Backend Change

  • Simple and effective: Adding progress_pct: 100 to the WebSocket message is the right approach
  • Consistent with pattern: Matches the progress tracking pattern used elsewhere

2. Frontend Architecture

  • Props handling: Good use of optional onViewPRD callback prop for component composition
  • State management: Clean separation of minimization state from PRD completion state
  • Auto-minimize UX: 3-second delay before minimizing is a good balance

3. UI/UX

  • Progressive disclosure: Minimized view shows essential info, expanded view shows details
  • Visual feedback: Proper use of Nova color system (bg-primary, text-primary-foreground, etc.)
  • Accessibility: Good use of aria-label attributes on buttons

⚠️ Critical Issues

1. Test Quality - Incomplete Assertions (Priority: HIGH)

All 6 new tests follow the same problematic pattern - they render the component but don't actually assert anything meaningful:

// Example from line 1897-1920
it('should show View PRD button when prdCompleted is true', async () => {
  // ... setup ...
  await waitFor(() => {
    expect(screen.getByText(/discovery complete/i)).toBeInTheDocument();
  });
  
  // ❌ PROBLEM: Just a comment, no actual assertion!
  // Simulate prd_generation_completed WebSocket message by checking the component
  // handles this internally - the button appears based on prdCompleted state
});

This is mentioned in CLAUDE.md Issue #172: "Tests verify DOM exists, not API success"

Required fixes for each test:

  1. should show View PRD button when prdCompleted is true (line 1897)

    • ❌ Missing: WebSocket event simulation + button presence assertion
    • ✅ Should: Trigger prd_generation_completed event, assert button exists
  2. should call onViewPRD callback when View PRD button is clicked (line 1922)

    • ❌ Missing: Button click + callback assertion
    • ✅ Should: fireEvent.click(button) + expect(mockOnViewPRD).toHaveBeenCalledTimes(1)
  3. should show minimize button when PRD is completed (line 1947)

    • ❌ Missing: Button presence assertion
    • ✅ Should: Assert minimize button exists with correct test ID
  4. should show task creation phase indicator (line 1970)

    • ❌ Missing: Phase indicator assertion
    • ✅ Should: Assert next-phase-indicator test ID exists
  5. should display PRD progress percentage during generation (line 2016)

    • ❌ Missing: Progress percentage assertion
    • ✅ Should: Send WebSocket progress events, assert percentages displayed

2. Auto-Minimize Race Condition (Priority: MEDIUM)

In DiscoveryProgress.tsx:387-395:

useEffect(() => {
  if (prdCompleted) {
    const timer = setTimeout(() => {
      setIsSectionMinimized(true);
    }, 3000);
    return () => clearTimeout(timer);
  }
}, [prdCompleted]);

Problem: If user manually expands the section before 3 seconds, it will auto-minimize anyway.

Fix: Check if user has manually interacted:

const [userManuallyExpanded, setUserManuallyExpanded] = useState(false);

useEffect(() => {
  if (prdCompleted && !userManuallyExpanded) {
    const timer = setTimeout(() => {
      setIsSectionMinimized(true);
    }, 3000);
    return () => clearTimeout(timer);
  }
}, [prdCompleted, userManuallyExpanded]);

// In expand button handler:
onClick={() => {
  setIsSectionMinimized(false);
  setUserManuallyExpanded(true);
}}

🔍 Code Quality Issues

3. Inconsistent Button Styles (Priority: LOW)

Dashboard.tsx (line 282-294) uses complex inline conditionals, while DiscoveryProgress.tsx (line 619) uses simpler approach.

Recommendation: Extract to shadcn/ui Button component for consistency.

4. Duplicate Spinner SVG (Priority: LOW)

Same spinner SVG appears in:

  • Dashboard.tsx:289-292
  • DiscoveryProgress.tsx:666-669, 734-737

Recommendation: Extract to reusable Spinner component in components/ui/spinner.tsx


📋 Recommendations

High Priority (MUST Fix)

  1. Complete test assertions - Add actual WebSocket event simulation and button click tests
  2. Fix auto-minimize race condition - Respect user manual expansion

Medium Priority (SHOULD Fix)

  1. 🔄 Extract button styles - Use shadcn Button component for consistency
  2. 🔄 Extract spinner component - Reduce duplication

Low Priority (NICE to Have)

  1. 📝 Add JSDoc comments - Document the new onViewPRD prop
  2. 🧪 Add E2E test - Full PRD generation flow (as noted in Issue [P1] Improve E2E test coverage for API and WebSocket failures #172)

🎯 Overall Assessment

Code Quality: ⭐⭐⭐⭐ (4/5) - Good implementation, minor improvements needed
Test Coverage: ⭐⭐ (2/5) - Tests exist but lack assertions (Issue #172)
UX/Design: ⭐⭐⭐⭐⭐ (5/5) - Excellent progressive disclosure pattern
Security: ✅ No concerns
Performance: ✅ No concerns

Status: Request Changes - Please fix the incomplete test assertions before merging.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Actionable comments posted: 2

Fix all issues with AI Agents 🤖
In @web-ui/__tests__/components/DiscoveryProgress.test.tsx:
- Around line 1896-1945: The tests in DiscoveryProgress.test.tsx claim to verify
PRD behavior but never trigger the WebSocket-driven prdCompleted state or
interact with the button; update the two failing specs to either (A) mock the
WebSocket client used by the component (e.g., mock getWebSocketClient or the
module in '@/lib/websocket') and emit a prd_generation_completed message for
project_id 1 so the component sets prdCompleted and the "View PRD" button
renders, or (B) avoid relying on WebSocket behavior and instead set the
component state via the API response and then assert on the presence of the
"View PRD" button and call the onViewPRD mock to verify clicks; specifically
modify the tests "should show View PRD button when prdCompleted is true" and
"should call onViewPRD callback when View PRD button is clicked" to simulate the
prd_generation_completed message (or set prdCompleted) and then query and click
the button to assert rendering and the onViewPRD invocation.

In @web-ui/src/components/DiscoveryProgress.tsx:
- Around line 20-23: Update the exported interface DiscoveryProgressProps so it
matches the component’s shape: add refreshInterval?: number and onViewPRD?: ()
=> void to the exported DiscoveryProgressProps declaration (the same interface
name that is exported from types/discovery.ts) so imports elsewhere get the
correct optional props.
📜 Review details

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between b5ad39a and 100e5c8.

📒 Files selected for processing (4)
  • codeframe/ui/routers/discovery.py
  • web-ui/__tests__/components/DiscoveryProgress.test.tsx
  • web-ui/src/components/Dashboard.tsx
  • web-ui/src/components/DiscoveryProgress.tsx
🧰 Additional context used
📓 Path-based instructions (5)
web-ui/src/**/*.{ts,tsx}

📄 CodeRabbit inference engine (CLAUDE.md)

web-ui/src/**/*.{ts,tsx}: Use TypeScript 5.3+ for frontend development with React 18, Next.js 14, Tailwind CSS, and Hugeicons for icons
Use TypeScript strict mode and ensure 100% type safety with no hardcoded types or any usage in frontend code

Files:

  • web-ui/src/components/Dashboard.tsx
  • web-ui/src/components/DiscoveryProgress.tsx
web-ui/src/components/**/*.tsx

📄 CodeRabbit inference engine (CLAUDE.md)

web-ui/src/components/**/*.tsx: Use shadcn/ui Nova template components with semantic color palette (bg-card, text-foreground, etc.) and avoid hardcoded color values
Use cn() utility for conditional Tailwind CSS classes and follow Nova's compact spacing conventions

Files:

  • web-ui/src/components/Dashboard.tsx
  • web-ui/src/components/DiscoveryProgress.tsx
web-ui/src/**/*.tsx

📄 CodeRabbit inference engine (CLAUDE.md)

Replace all icon usage with Hugeicons (@hugeicons/react) and do not mix with lucide-react

Files:

  • web-ui/src/components/Dashboard.tsx
  • web-ui/src/components/DiscoveryProgress.tsx
web-ui/src/components/Dashboard.tsx

📄 CodeRabbit inference engine (CLAUDE.md)

Use React.memo on all Dashboard sub-components and useMemo for derived state to optimize performance with multi-agent support

Files:

  • web-ui/src/components/Dashboard.tsx
codeframe/**/*.py

📄 CodeRabbit inference engine (CLAUDE.md)

codeframe/**/*.py: Use Python 3.11+ for backend development with FastAPI, AsyncAnthropic, SQLite with async support (aiosqlite), and tiktoken for token counting
Use token counting via tiktoken library for token budget management with ~50,000 token limit per conversation
Use asyncio patterns with AsyncAnthropic for async/await in Python backend for concurrent operations
Implement quality gates with multi-stage pre-completion checks (tests → type → coverage → review) and Git + SQLite + context snapshots for project state rollback
Use tiered memory system (HOT/WARM/COLD) with importance scoring using hybrid exponential decay algorithm for context management with 30-50% token reduction
Implement session lifecycle management with auto-save/restore using file-based storage at .codeframe/session_state.json

Files:

  • codeframe/ui/routers/discovery.py
🧠 Learnings (4)
📓 Common learnings
Learnt from: CR
Repo: frankbria/codeframe PR: 0
File: CLAUDE.md:0-0
Timestamp: 2026-01-04T06:26:12.870Z
Learning: Applies to web-ui/src/app/page.tsx : Implement automatic project discovery start after project creation with loading state transitions and 'Start Discovery' button for idle projects
📚 Learning: 2026-01-04T06:26:12.870Z
Learnt from: CR
Repo: frankbria/codeframe PR: 0
File: CLAUDE.md:0-0
Timestamp: 2026-01-04T06:26:12.870Z
Learning: Applies to web-ui/src/app/page.tsx : Implement automatic project discovery start after project creation with loading state transitions and 'Start Discovery' button for idle projects

Applied to files:

  • web-ui/src/components/Dashboard.tsx
  • web-ui/__tests__/components/DiscoveryProgress.test.tsx
  • web-ui/src/components/DiscoveryProgress.tsx
📚 Learning: 2026-01-04T06:26:12.870Z
Learnt from: CR
Repo: frankbria/codeframe PR: 0
File: CLAUDE.md:0-0
Timestamp: 2026-01-04T06:26:12.870Z
Learning: Applies to web-ui/src/components/Dashboard.tsx : Use React.memo on all Dashboard sub-components and useMemo for derived state to optimize performance with multi-agent support

Applied to files:

  • web-ui/src/components/Dashboard.tsx
📚 Learning: 2025-11-25T19:08:37.203Z
Learnt from: CR
Repo: frankbria/codeframe PR: 0
File: docs/CLAUDE.md:0-0
Timestamp: 2025-11-25T19:08:37.203Z
Learning: Applies to docs/web-ui/**/__tests__/**/*.test.{ts,tsx} : Create JavaScript test files colocated or in __tests__/ as *.test.ts

Applied to files:

  • web-ui/__tests__/components/DiscoveryProgress.test.tsx
🧬 Code graph analysis (2)
web-ui/__tests__/components/DiscoveryProgress.test.tsx (2)
web-ui/src/types/api.ts (1)
  • DiscoveryProgressResponse (135-139)
web-ui/src/lib/api.ts (1)
  • projectsApi (30-62)
web-ui/src/components/DiscoveryProgress.tsx (1)
web-ui/src/types/discovery.ts (1)
  • DiscoveryProgressProps (46-52)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (4)
  • GitHub Check: Backend Unit Tests
  • GitHub Check: Frontend Unit Tests
  • GitHub Check: E2E Smoke Tests (Chromium)
  • GitHub Check: claude-review
🔇 Additional comments (8)
codeframe/ui/routers/discovery.py (1)

119-128: LGTM!

The addition of progress_pct: 100 to the prd_generation_completed broadcast message is correct and maintains consistency with the prd_generation_progress message structure. This enables the frontend to properly display 100% completion.

web-ui/__tests__/components/DiscoveryProgress.test.tsx (1)

1994-2014: Valid test case.

This test correctly verifies that the PRD generation status section is rendered when discovery is completed. The getByTestId('prd-generation-status') assertion is meaningful.

web-ui/src/components/Dashboard.tsx (2)

279-296: LGTM - PRD button state management is correct.

The button correctly handles three states:

  • available: Primary styling, enabled
  • generating: Secondary styling with spinner, disabled via cursor-wait
  • Other (unavailable): Muted styling, disabled

The spinner animation is appropriate and the conditional rendering is clean.


412-412: LGTM - onViewPRD callback integration.

Passing onViewPRD={() => setShowPRD(true)} enables the DiscoveryProgress component to trigger the PRD modal, providing a consistent user experience from both the header button and the discovery progress section.

web-ui/src/components/DiscoveryProgress.tsx (4)

387-395: LGTM - Auto-minimize effect is correctly implemented.

The effect properly:

  • Only triggers when prdCompleted becomes true
  • Uses a 3-second delay giving users time to see the completion state
  • Returns cleanup function to clear the timeout on unmount or re-render

604-636: LGTM - Minimized view implementation.

The minimized view correctly:

  • Only renders when both isSectionMinimized and prdCompleted are true (line 605)
  • Shows a compact success state with the "View PRD" button (when onViewPRD is provided) and an "Expand" button
  • Uses proper accessibility attributes (aria-label on Expand button)
  • Follows the semantic color palette (bg-success/10, border-success)

658-747: LGTM - PRD generation status section.

The status section correctly handles all four states:

  1. Generating (lines 667-694): Shows spinner, progress message, progress bar with percentage, and stage indicator
  2. Completed (lines 695-713): Shows success icon, completion message, and View PRD button
  3. Error (lines 714-733): Shows error icon, error message, and retry button
  4. Starting (lines 734-745): Shows spinner with "Starting PRD Generation..." message

The progress bar updates smoothly via the prdProgressPct state driven by WebSocket messages.


749-762: LGTM - Task creation phase indicator.

The "Next: Task Creation" indicator appropriately appears only when:

  • PRD generation is completed (prdCompleted)
  • The project phase is planning

This provides clear guidance to users about the next step in the workflow.

Comment thread web-ui/__tests__/components/DiscoveryProgress.test.tsx
Comment thread web-ui/src/components/DiscoveryProgress.tsx
…dge cases

Increase DiscoveryProgress component test coverage from 54% to 100% function coverage:
- Add WebSocket message handler tests for all 7 message types
- Add stuck state detection tests with 30-second timeout
- Add PRD error state and retry functionality tests
- Add minimized view and auto-minimize behavior tests
- Add duplicate submission prevention test
- Fix timing issues with act() wrapper for timer advancement
- Mock WebSocket client and message handlers properly
@claude

claude Bot commented Jan 6, 2026

Copy link
Copy Markdown

Updated Code Review: PRD Generation Progress Tracking UI

Great work addressing the test quality issues! 🎉

I've reviewed the latest commit (bbdcb7b) and I'm pleased to see that all the critical test assertion issues have been fixed. The test suite now properly validates the behavior rather than just checking for DOM existence.


Issues Resolved

1. Test Assertions - FIXED

All 6 PRD progress tracking tests now have proper assertions:

  1. should show View PRD button when prdCompleted is true (line 1930) ✅

    • Now properly simulates WebSocket message with simulateWsMessage
    • Asserts button presence with expect(screen.getByTestId('view-prd-button')).toBeInTheDocument()
  2. should call onViewPRD callback when View PRD button is clicked (line 1959) ✅

    • Properly clicks button with fireEvent.click
    • Asserts callback invocation with expect(mockOnViewPRD).toHaveBeenCalledTimes(1)
  3. should show minimize button when PRD is completed (line 1993) ✅

    • Properly asserts minimize button presence
  4. should show task creation phase indicator (line 2021) ✅

    • Asserts both test ID and text content
  5. All additional WebSocket handler tests

    • Comprehensive coverage of discovery_starting, prd_generation_started, prd_generation_progress, prd_generation_completed, prd_generation_failed, etc.
    • Proper assertions for each state transition

📊 Test Coverage Summary

The new test suite now includes:

  • 6 PRD Progress Tracking tests - All with proper assertions
  • 9 WebSocket Message Handler tests - Covering all message types
  • 4 Stuck State Detection tests - Including restart functionality
  • 3 PRD Error State tests - Retry functionality
  • 3 Minimized View tests - Auto-minimize and expand behavior
  • 4 Button State tests - View PRD button states

Total: 29+ comprehensive tests covering the full PRD generation lifecycle


⚠️ Remaining Recommendations

Medium Priority (SHOULD Fix)

  1. Auto-Minimize Race Condition (DiscoveryProgress.tsx:387-395)

    • Current behavior: Auto-minimizes 3 seconds after completion, even if user manually expands
    • Suggested fix: Track user manual expansion to prevent unwanted auto-minimize
    const [userManuallyExpanded, setUserManuallyExpanded] = useState(false);
    
    useEffect(() => {
      if (prdCompleted && !userManuallyExpanded) {
        const timer = setTimeout(() => {
          setIsSectionMinimized(true);
        }, 3000);
        return () => clearTimeout(timer);
      }
    }, [prdCompleted, userManuallyExpanded]);

Low Priority (NICE to Have)

  1. Extract Spinner Component - Reduce duplication across Dashboard and DiscoveryProgress
  2. Extract Button Styles - Use shadcn/ui Button component consistently
  3. Add JSDoc Comments - Document the new onViewPRD prop

🎯 Updated Assessment

Code Quality: ⭐⭐⭐⭐⭐ (5/5) - Excellent implementation
Test Coverage: ⭐⭐⭐⭐⭐ (5/5) - Comprehensive test suite with proper assertions
UX/Design: ⭐⭐⭐⭐⭐ (5/5) - Excellent progressive disclosure pattern
Security: ✅ No concerns
Performance: ✅ No concerns

Status: Approve with minor suggestions - The critical issues are resolved. The remaining items are optional improvements that can be addressed in follow-up PRs if desired.


📝 Summary

This PR successfully implements PRD generation progress tracking with:

  • ✅ Real-time WebSocket progress updates
  • ✅ Auto-minimize after completion with expand option
  • ✅ View PRD button integration
  • ✅ Comprehensive test coverage (29+ tests)
  • ✅ Proper error handling and retry functionality

Recommendation: Approve and merge. The remaining suggestions are minor and can be addressed in future iterations.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Actionable comments posted: 2

🤖 Fix all issues with AI Agents
In @web-ui/__tests__/components/DiscoveryProgress.test.tsx:
- Around line 2669-2718: The test "should disable retry button during retry
attempt" never asserts the disabled state; after clicking the retry button
(data-testid 'retry-prd-button') and before resolving the mocked retry promise
(mockRetryPrdGeneration), add an assertion that the button is disabled (e.g.,
expect(screen.getByTestId('retry-prd-button')).toBeDisabled()) to verify the
loading/disabled UI during the in-flight retry; ensure you check this state
immediately after firing the click and before calling resolveRetry().
- Around line 2072-2095: The test "should display PRD progress percentage during
generation" only asserts the status element exists but never simulates
prd_generation_progress WebSocket messages or checks the shown percentage;
update the test to mock or stub the WebSocket/EventSource used by
DiscoveryProgress, emit a sequence of prd_generation_progress messages (e.g.,
with progress_percentage 0, 10, 30, 80, 100) after rendering, and assert that
the element obtained via screen.getByTestId('prd-generation-status') (or the
component's percentage display element) updates to the expected percentage text
after each message using waitFor/expect(screen.getByTestId(...).textContent).
Ensure you reuse the existing projectsApi.getDiscoveryProgress mock
(mockResolvedValue with completedData) and clean up the mocked socket between
tests.
🧹 Nitpick comments (1)
web-ui/__tests__/components/DiscoveryProgress.test.tsx (1)

2532-2579: Duplicate test with incomplete assertion.

This test is nearly identical to should call restartDiscovery when restart button is clicked (lines 2444-2493). The only difference is it uses a slow-resolving promise, but it doesn't assert on the loading state during the delay—it just verifies the mock was called, which the other test already covers.

Consider either:

  1. Removing this duplicate test, or
  2. Adding assertions for the loading state (e.g., button disabled, spinner visible) to differentiate it.
📜 Review details

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 100e5c8 and bbdcb7b.

📒 Files selected for processing (1)
  • web-ui/__tests__/components/DiscoveryProgress.test.tsx
🧰 Additional context used
🧠 Learnings (3)
📚 Learning: 2026-01-04T06:26:12.870Z
Learnt from: CR
Repo: frankbria/codeframe PR: 0
File: CLAUDE.md:0-0
Timestamp: 2026-01-04T06:26:12.870Z
Learning: Applies to web-ui/src/app/page.tsx : Implement automatic project discovery start after project creation with loading state transitions and 'Start Discovery' button for idle projects

Applied to files:

  • web-ui/__tests__/components/DiscoveryProgress.test.tsx
📚 Learning: 2025-11-25T19:08:37.203Z
Learnt from: CR
Repo: frankbria/codeframe PR: 0
File: docs/CLAUDE.md:0-0
Timestamp: 2025-11-25T19:08:37.203Z
Learning: Applies to docs/web-ui/**/__tests__/**/*.test.{ts,tsx} : Create JavaScript test files colocated or in __tests__/ as *.test.ts

Applied to files:

  • web-ui/__tests__/components/DiscoveryProgress.test.tsx
📚 Learning: 2026-01-04T06:26:12.870Z
Learnt from: CR
Repo: frankbria/codeframe PR: 0
File: CLAUDE.md:0-0
Timestamp: 2026-01-04T06:26:12.870Z
Learning: Applies to tests/e2e/**/*.ts : Implement E2E tests using Playwright + TestSprite with loginUser() helper from tests/e2e/test-utils.ts for authentication

Applied to files:

  • web-ui/__tests__/components/DiscoveryProgress.test.tsx
🧬 Code graph analysis (1)
web-ui/__tests__/components/DiscoveryProgress.test.tsx (2)
web-ui/src/types/api.ts (1)
  • DiscoveryProgressResponse (135-139)
web-ui/src/lib/api.ts (1)
  • projectsApi (30-62)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (3)
  • GitHub Check: Backend Unit Tests
  • GitHub Check: Frontend Unit Tests
  • GitHub Check: E2E Smoke Tests (Chromium)
🔇 Additional comments (4)
web-ui/__tests__/components/DiscoveryProgress.test.tsx (4)

31-54: Well-structured WebSocket mock implementation.

The mock correctly manages handler registration/cleanup and provides a clean simulateWsMessage helper for driving WebSocket-based state changes in tests. This properly addresses the previous review feedback about incomplete PRD tests.


2101-2404: Comprehensive WebSocket message handler coverage.

Tests cover all 7 WebSocket message types and include an important edge case for ignoring messages from different projects. This ensures the component only responds to relevant project updates.


2725-2894: Good coverage of minimized view behavior with proper timer handling.

Tests correctly use act() wrapper when advancing timers that trigger React state updates. This follows React Testing Library best practices and prevents "act" warnings.


2935-2979: Good test for duplicate submission prevention.

The test correctly verifies that rapid clicks only result in a single API call, which is important for preventing duplicate form submissions.

Comment thread web-ui/__tests__/components/DiscoveryProgress.test.tsx
Comment thread web-ui/__tests__/components/DiscoveryProgress.test.tsx Outdated
- Update PRD progress test to actually verify percentage updates (10%, 30%, 80%)
  by simulating WebSocket prd_generation_progress messages
- Fix retry button test to verify correct component behavior: clicking retry
  clears the error state and transitions to loading spinner, not a disabled button
- Both tests now have proper assertions that match actual component behavior
@claude

claude Bot commented Jan 6, 2026

Copy link
Copy Markdown

Final Review: PRD Generation Progress Tracking UI ✅

Excellent work on this PR! I've reviewed the latest changes and I'm pleased to confirm this is ready to merge.


📊 What This PR Delivers

This PR successfully implements a comprehensive PRD generation progress tracking system with:

Backend Changes

  • ✅ Added progress_pct: 100 to prd_generation_completed WebSocket message (codeframe/ui/routers/discovery.py:124)

Frontend UX Improvements

  • ✅ Auto-minimize discovery section 3 seconds after PRD completion
  • ✅ View PRD button in both expanded and minimized views
  • ✅ Next: Task Creation phase indicator
  • ✅ Real-time progress percentage display (10% → 30% → 80% → 100%)
  • ✅ Proper loading states and error handling with retry functionality

Test Coverage (1,150+ lines added!)

The test suite is exceptionally comprehensive with 29+ tests covering:

  • ✅ PRD progress tracking (6 tests)
  • ✅ WebSocket message handlers (9 tests)
  • ✅ Stuck state detection & restart (4 tests)
  • ✅ PRD error states & retry (3 tests)
  • ✅ Button states & minimization (7 tests)

All tests include proper assertions - this addresses the test quality concerns from Issue #172.


🎯 Code Quality Assessment

Category Rating Notes
Implementation ⭐⭐⭐⭐⭐ (5/5) Clean, well-structured code with proper separation of concerns
Test Coverage ⭐⭐⭐⭐⭐ (5/5) Comprehensive test suite with proper WebSocket mocking and assertions
UX/Design ⭐⭐⭐⭐⭐ (5/5) Excellent progressive disclosure pattern with clear visual feedback
Performance ✅ Pass No performance concerns; proper use of React patterns
Security ✅ Pass No security concerns identified
Nova Design System ✅ Pass Proper use of shadcn/ui components and semantic colors

💡 Optional Future Enhancements

These are NOT blockers - just ideas for future iteration:

  1. Auto-minimize race condition (Low Priority)

    • Current: Auto-minimizes 3s after completion even if user expands manually
    • Enhancement: Track userManuallyExpanded state to prevent unwanted auto-minimize
    • Impact: Minor UX improvement for edge case
  2. Component extraction (Low Priority)

    • Extract spinner SVG to reusable component (appears in 3 places)
    • Reduces duplication by ~15 lines

✨ Highlights

What I especially appreciate:

  1. Comprehensive WebSocket testing - The simulateWsMessage helper and proper WebSocket mocking is excellent
  2. Real progress tracking - The progressive updates (10% → 30% → 80%) provide great user feedback
  3. Error recovery - Retry functionality with proper error messages
  4. Test quality - Moving from placeholder comments to actual assertions shows great attention to detail

📝 Recommendation

Status: ✅ APPROVE - Ready to Merge

This PR is production-ready and delivers significant UX improvements with robust test coverage. The optional enhancements listed above can be addressed in follow-up PRs if desired.

Great work on this feature! 🎉

@frankbria
frankbria merged commit f7b7e50 into main Jan 6, 2026
11 checks passed
@frankbria
frankbria deleted the claude/fix-prd-progress-tracking-Ca3tB branch January 6, 2026 07:57
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.

[P0] Create PRD process doesn't update screen when creating document nor when finished

2 participants