Skip to content

[Bug] Agent does not auto-start after spec creation from empty Kanban #144

@nogataka

Description

@nogataka

Summary

When creating a spec from an empty Kanban board (via "Create Spec" button), the agent does not automatically start after clicking "Continue to Project". The user must manually click the Play button to start the agent.

Steps to Reproduce

  1. Create a new project with manual spec method (or have an existing project without a spec)
  2. Open the project in Kanban view
  3. Click "Create Spec" button (shown when has_spec: false)
  4. Complete the spec creation chat with Claude
  5. Click "Continue to Project" button
  6. Bug: Agent does not start automatically
  7. User must click Play button to start the agent

Expected Behavior

After clicking "Continue to Project", the agent should automatically start (same behavior as creating a new project via NewProjectModal).

Actual Behavior

  • The spec chat closes and navigates to Kanban
  • No /api/projects/{project}/agent/start POST request is made
  • Agent status remains "stopped"
  • User must manually click Play to start the agent

Root Cause

SpecCreationChat component is used in two places with different onComplete handlers:

1. NewProjectModal.tsx (works correctly)

// ui/src/components/NewProjectModal.tsx:218
<SpecCreationChat
  projectName={projectName.trim()}
  onComplete={handleSpecComplete}  // ✅ Calls startAgent()
  ...
/>

2. App.tsx (missing agent start)

// ui/src/App.tsx:496-507
<SpecCreationChat
  projectName={selectedProject}
  onComplete={() => {
    setShowSpecChat(false)
    queryClient.invalidateQueries({ queryKey: ['projects'] })
    queryClient.invalidateQueries({ queryKey: ['features', selectedProject] })
  }}  // ❌ Does NOT call startAgent()
  onCancel={() => setShowSpecChat(false)}
  onExitToProject={() => setShowSpecChat(false)}
/>

The App.tsx version only closes the chat and refreshes queries but does not start the agent.

Proposed Fix

Update App.tsx to start the agent in the onComplete handler:

// ui/src/App.tsx
import { startAgent } from './lib/api'

// ...

<SpecCreationChat
  projectName={selectedProject}
  onComplete={async (_specPath, yoloMode) => {
    try {
      await startAgent(selectedProject, {
        yoloMode: yoloMode ?? false,
        maxConcurrency: 3,
      })
    } catch (err) {
      console.error('Failed to start agent:', err)
    }
    setShowSpecChat(false)
    queryClient.invalidateQueries({ queryKey: ['projects'] })
    queryClient.invalidateQueries({ queryKey: ['features', selectedProject] })
  }}
  onCancel={() => setShowSpecChat(false)}
  onExitToProject={() => setShowSpecChat(false)}
/>

Affected Files

  • ui/src/App.tsx (lines 496-507)

Environment

  • OS: macOS / Windows / Linux
  • Browser: All browsers

Additional Context

This issue was discovered through debugging with console.log statements. The onComplete function passed to SpecCreationChat was found to be the inline function from App.tsx (which returns undefined) rather than handleSpecComplete from NewProjectModal.tsx (which returns a Promise).

Labels

bug, ui, agent

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions