Add daemon support for label commands and populate labels in issue queries

- Updated label CLI commands to support both daemon and direct modes
- Added label fetching to GetIssue() and scanIssues() methods
- All label operations (add, remove, list, list-all) work with daemon
- Closed bd-162 (label CLI commands), bd-166 (duplicate), bd-141 (daemon support)

Amp-Thread-ID: https://ampcode.com/threads/T-4858f62e-ad06-4cc7-ad05-17ee76861f86
Co-authored-by: Amp <amp@ampcode.com>
This commit is contained in:
Steve Yegge
2025-10-19 21:14:23 -07:00
parent 8a48b599ae
commit c3023cd5f7
6 changed files with 284 additions and 190 deletions

View File

@@ -363,7 +363,7 @@ func (s *SQLiteStorage) GetDependencies(ctx context.Context, issueID string) ([]
}
defer rows.Close()
return scanIssues(rows)
return s.scanIssues(ctx, rows)
}
// GetDependents returns issues that depend on this issue
@@ -382,7 +382,7 @@ func (s *SQLiteStorage) GetDependents(ctx context.Context, issueID string) ([]*t
}
defer rows.Close()
return scanIssues(rows)
return s.scanIssues(ctx, rows)
}
// GetDependencyRecords returns raw dependency records for an issue
@@ -644,7 +644,7 @@ func (s *SQLiteStorage) DetectCycles(ctx context.Context) ([][]*types.Issue, err
}
// Helper function to scan issues from rows
func scanIssues(rows *sql.Rows) ([]*types.Issue, error) {
func (s *SQLiteStorage) scanIssues(ctx context.Context, rows *sql.Rows) ([]*types.Issue, error) {
var issues []*types.Issue
for rows.Next() {
var issue types.Issue
@@ -677,6 +677,13 @@ func scanIssues(rows *sql.Rows) ([]*types.Issue, error) {
issue.ExternalRef = &externalRef.String
}
// Fetch labels for this issue
labels, err := s.GetLabels(ctx, issue.ID)
if err != nil {
return nil, fmt.Errorf("failed to get labels for issue %s: %w", issue.ID, err)
}
issue.Labels = labels
issues = append(issues, &issue)
}

View File

@@ -112,5 +112,5 @@ func (s *SQLiteStorage) GetIssuesByLabel(ctx context.Context, label string) ([]*
}
defer rows.Close()
return scanIssues(rows)
return s.scanIssues(ctx, rows)
}

View File

@@ -109,7 +109,7 @@ func (s *SQLiteStorage) GetReadyWork(ctx context.Context, filter types.WorkFilte
}
defer rows.Close()
return scanIssues(rows)
return s.scanIssues(ctx, rows)
}
// GetBlockedIssues returns issues that are blocked by dependencies

View File

@@ -925,6 +925,13 @@ func (s *SQLiteStorage) GetIssue(ctx context.Context, id string) (*types.Issue,
issue.OriginalSize = int(originalSize.Int64)
}
// Fetch labels for this issue
labels, err := s.GetLabels(ctx, issue.ID)
if err != nil {
return nil, fmt.Errorf("failed to get labels: %w", err)
}
issue.Labels = labels
return &issue, nil
}
@@ -1693,7 +1700,7 @@ func (s *SQLiteStorage) SearchIssues(ctx context.Context, query string, filter t
}
defer rows.Close()
return scanIssues(rows)
return s.scanIssues(ctx, rows)
}
// SetConfig sets a configuration value