82e8c8905b
* feat: replace agent_type with agent_profile_id - Replace agent_type field with agent_profile_id across backend and frontend - Add ProfileResolver interface and StoreProfileResolver implementation - Update task creation/update to use agent_profile_id - Change default agent runtime from docker to standalone - Fix workspace state types to include all required fields - Fix websocket handlers type mismatches for environments, executors, workspaces - Update integration tests to use agent_profile_id * feat: pass model as CLI argument to agents - Add ModelFlag field to AgentTypeConfig for specifying the CLI flag - Set ModelFlag to '--model' for all agents (auggie, claude, codex, gemini, opencode, copilot) - Update launchStandalone to append model flag to agent command - Update launchDocker/buildContainerConfig to append model flag to container command - Model is passed when both agent supports ModelFlag and profile has Model configured * fix: make WebSocket message handling async to prevent blocking When a long-running handler like orchestrator.prompt was executing, it blocked the ReadPump loop, preventing other requests (like workspace.tree.get) from being processed until the handler completed. Now each message is handled in its own goroutine, allowing concurrent message handling so file tree requests work while the agent is working. * feat: show task description as first message in chat - Add 'Task' label with distinct styling (lighter background, border) - Pass taskDescription from page to TaskChatPanel component - Differentiate from regular user messages visually
128 lines
3.8 KiB
Go
128 lines
3.8 KiB
Go
package controller
|
|
|
|
import (
|
|
"context"
|
|
|
|
"github.com/kandev/kandev/internal/task/dto"
|
|
"github.com/kandev/kandev/internal/task/service"
|
|
)
|
|
|
|
// WorktreeLookup provides worktree information for tasks.
|
|
type WorktreeLookup interface {
|
|
// GetWorktreeInfo returns worktree path and branch for a task, or nil if no worktree exists.
|
|
GetWorktreeInfo(ctx context.Context, taskID string) (path, branch *string)
|
|
}
|
|
|
|
type TaskController struct {
|
|
service *service.Service
|
|
worktreeLookup WorktreeLookup
|
|
}
|
|
|
|
func NewTaskController(svc *service.Service) *TaskController {
|
|
return &TaskController{service: svc}
|
|
}
|
|
|
|
// SetWorktreeLookup sets the worktree lookup for enriching task responses.
|
|
func (c *TaskController) SetWorktreeLookup(lookup WorktreeLookup) {
|
|
c.worktreeLookup = lookup
|
|
}
|
|
|
|
// enrichWithWorktree adds worktree info to a TaskDTO if available.
|
|
func (c *TaskController) enrichWithWorktree(ctx context.Context, task *dto.TaskDTO) {
|
|
if c.worktreeLookup == nil {
|
|
return
|
|
}
|
|
path, branch := c.worktreeLookup.GetWorktreeInfo(ctx, task.ID)
|
|
task.WorktreePath = path
|
|
task.WorktreeBranch = branch
|
|
}
|
|
|
|
func (c *TaskController) ListTasks(ctx context.Context, req dto.ListTasksRequest) (dto.ListTasksResponse, error) {
|
|
tasks, err := c.service.ListTasks(ctx, req.BoardID)
|
|
if err != nil {
|
|
return dto.ListTasksResponse{}, err
|
|
}
|
|
resp := dto.ListTasksResponse{
|
|
Tasks: make([]dto.TaskDTO, 0, len(tasks)),
|
|
Total: len(tasks),
|
|
}
|
|
for _, task := range tasks {
|
|
taskDTO := dto.FromTask(task)
|
|
c.enrichWithWorktree(ctx, &taskDTO)
|
|
resp.Tasks = append(resp.Tasks, taskDTO)
|
|
}
|
|
return resp, nil
|
|
}
|
|
|
|
func (c *TaskController) GetTask(ctx context.Context, req dto.GetTaskRequest) (dto.TaskDTO, error) {
|
|
task, err := c.service.GetTask(ctx, req.ID)
|
|
if err != nil {
|
|
return dto.TaskDTO{}, err
|
|
}
|
|
taskDTO := dto.FromTask(task)
|
|
c.enrichWithWorktree(ctx, &taskDTO)
|
|
return taskDTO, nil
|
|
}
|
|
|
|
func (c *TaskController) CreateTask(ctx context.Context, req dto.CreateTaskRequest) (dto.TaskDTO, error) {
|
|
task, err := c.service.CreateTask(ctx, &service.CreateTaskRequest{
|
|
WorkspaceID: req.WorkspaceID,
|
|
BoardID: req.BoardID,
|
|
ColumnID: req.ColumnID,
|
|
Title: req.Title,
|
|
Description: req.Description,
|
|
Priority: req.Priority,
|
|
State: req.State,
|
|
AgentProfileID: req.AgentProfileID,
|
|
RepositoryURL: req.RepositoryURL,
|
|
Branch: req.Branch,
|
|
AssignedTo: req.AssignedTo,
|
|
Position: req.Position,
|
|
Metadata: req.Metadata,
|
|
})
|
|
if err != nil {
|
|
return dto.TaskDTO{}, err
|
|
}
|
|
return dto.FromTask(task), nil
|
|
}
|
|
|
|
func (c *TaskController) UpdateTask(ctx context.Context, req dto.UpdateTaskRequest) (dto.TaskDTO, error) {
|
|
task, err := c.service.UpdateTask(ctx, req.ID, &service.UpdateTaskRequest{
|
|
Title: req.Title,
|
|
Description: req.Description,
|
|
Priority: req.Priority,
|
|
State: req.State,
|
|
AgentProfileID: req.AgentProfileID,
|
|
AssignedTo: req.AssignedTo,
|
|
Position: req.Position,
|
|
Metadata: req.Metadata,
|
|
})
|
|
if err != nil {
|
|
return dto.TaskDTO{}, err
|
|
}
|
|
return dto.FromTask(task), nil
|
|
}
|
|
|
|
func (c *TaskController) DeleteTask(ctx context.Context, req dto.DeleteTaskRequest) (dto.SuccessResponse, error) {
|
|
if err := c.service.DeleteTask(ctx, req.ID); err != nil {
|
|
return dto.SuccessResponse{}, err
|
|
}
|
|
return dto.SuccessResponse{Success: true}, nil
|
|
}
|
|
|
|
func (c *TaskController) MoveTask(ctx context.Context, req dto.MoveTaskRequest) (dto.TaskDTO, error) {
|
|
task, err := c.service.MoveTask(ctx, req.ID, req.BoardID, req.ColumnID, req.Position)
|
|
if err != nil {
|
|
return dto.TaskDTO{}, err
|
|
}
|
|
return dto.FromTask(task), nil
|
|
}
|
|
|
|
func (c *TaskController) UpdateTaskState(ctx context.Context, req dto.UpdateTaskStateRequest) (dto.TaskDTO, error) {
|
|
task, err := c.service.UpdateTaskState(ctx, req.ID, req.State)
|
|
if err != nil {
|
|
return dto.TaskDTO{}, err
|
|
}
|
|
return dto.FromTask(task), nil
|
|
}
|