feat: expose worktree path and branch in task API and UI
- Add WorktreePath and WorktreeBranch fields to TaskDTO - Add WorktreeLookup interface to TaskController for enriching task responses - Add GetWorktreeInfo method to worktree.Manager implementing WorktreeLookup - Wire worktree manager to task controller in main.go - Add worktree_path and worktree_branch to frontend Task type - Display worktree path with copy button in TaskTopBar when worktree exists - Show worktree branch in tooltip for easy reference
This commit is contained in:
@@ -7,14 +7,36 @@ import (
|
||||
"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
|
||||
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 {
|
||||
@@ -25,7 +47,9 @@ func (c *TaskController) ListTasks(ctx context.Context, req dto.ListTasksRequest
|
||||
Total: len(tasks),
|
||||
}
|
||||
for _, task := range tasks {
|
||||
resp.Tasks = append(resp.Tasks, dto.FromTask(task))
|
||||
taskDTO := dto.FromTask(task)
|
||||
c.enrichWithWorktree(ctx, &taskDTO)
|
||||
resp.Tasks = append(resp.Tasks, taskDTO)
|
||||
}
|
||||
return resp, nil
|
||||
}
|
||||
@@ -35,7 +59,9 @@ func (c *TaskController) GetTask(ctx context.Context, req dto.GetTaskRequest) (d
|
||||
if err != nil {
|
||||
return dto.TaskDTO{}, err
|
||||
}
|
||||
return dto.FromTask(task), nil
|
||||
taskDTO := dto.FromTask(task)
|
||||
c.enrichWithWorktree(ctx, &taskDTO)
|
||||
return taskDTO, nil
|
||||
}
|
||||
|
||||
func (c *TaskController) CreateTask(ctx context.Context, req dto.CreateTaskRequest) (dto.TaskDTO, error) {
|
||||
|
||||
Reference in New Issue
Block a user