Merge branch 'steveyegge:main' into main
This commit is contained in:
@@ -333,6 +333,11 @@ func (c *Client) Ready(args *ReadyArgs) (*Response, error) {
|
||||
return c.Execute(OpReady, args)
|
||||
}
|
||||
|
||||
// Blocked gets blocked issues via the daemon
|
||||
func (c *Client) Blocked(args *BlockedArgs) (*Response, error) {
|
||||
return c.Execute(OpBlocked, args)
|
||||
}
|
||||
|
||||
// Stale gets stale issues via the daemon
|
||||
func (c *Client) Stale(args *StaleArgs) (*Response, error) {
|
||||
return c.Execute(OpStale, args)
|
||||
|
||||
@@ -3,6 +3,8 @@ package rpc
|
||||
import (
|
||||
"encoding/json"
|
||||
"time"
|
||||
|
||||
"github.com/steveyegge/beads/internal/types"
|
||||
)
|
||||
|
||||
// Operation constants for all bd commands
|
||||
@@ -18,6 +20,7 @@ const (
|
||||
OpCount = "count"
|
||||
OpShow = "show"
|
||||
OpReady = "ready"
|
||||
OpBlocked = "blocked"
|
||||
OpStale = "stale"
|
||||
OpStats = "stats"
|
||||
OpDepAdd = "dep_add"
|
||||
@@ -124,8 +127,16 @@ type UpdateArgs struct {
|
||||
|
||||
// CloseArgs represents arguments for the close operation
|
||||
type CloseArgs struct {
|
||||
ID string `json:"id"`
|
||||
Reason string `json:"reason,omitempty"`
|
||||
ID string `json:"id"`
|
||||
Reason string `json:"reason,omitempty"`
|
||||
SuggestNext bool `json:"suggest_next,omitempty"` // Return newly unblocked issues (GH#679)
|
||||
}
|
||||
|
||||
// CloseResult is returned when SuggestNext is true (GH#679)
|
||||
// When SuggestNext is false, just the closed issue is returned for backward compatibility
|
||||
type CloseResult struct {
|
||||
Closed *types.Issue `json:"closed"` // The issue that was closed
|
||||
Unblocked []*types.Issue `json:"unblocked,omitempty"` // Issues newly unblocked by closing
|
||||
}
|
||||
|
||||
// DeleteArgs represents arguments for the delete operation
|
||||
@@ -243,6 +254,12 @@ type ReadyArgs struct {
|
||||
SortPolicy string `json:"sort_policy,omitempty"`
|
||||
Labels []string `json:"labels,omitempty"`
|
||||
LabelsAny []string `json:"labels_any,omitempty"`
|
||||
ParentID string `json:"parent_id,omitempty"` // Filter to descendants of this bead/epic
|
||||
}
|
||||
|
||||
// BlockedArgs represents arguments for the blocked operation
|
||||
type BlockedArgs struct {
|
||||
ParentID string `json:"parent_id,omitempty"` // Filter to descendants of this bead/epic
|
||||
}
|
||||
|
||||
// StaleArgs represents arguments for the stale command
|
||||
|
||||
@@ -555,6 +555,26 @@ func (s *Server) handleClose(req *Request) Response {
|
||||
})
|
||||
|
||||
closedIssue, _ := store.GetIssue(ctx, closeArgs.ID)
|
||||
|
||||
// If SuggestNext is requested, find newly unblocked issues (GH#679)
|
||||
if closeArgs.SuggestNext {
|
||||
unblocked, err := store.GetNewlyUnblockedByClose(ctx, closeArgs.ID)
|
||||
if err != nil {
|
||||
// Non-fatal: still return the closed issue
|
||||
unblocked = nil
|
||||
}
|
||||
result := CloseResult{
|
||||
Closed: closedIssue,
|
||||
Unblocked: unblocked,
|
||||
}
|
||||
data, _ := json.Marshal(result)
|
||||
return Response{
|
||||
Success: true,
|
||||
Data: data,
|
||||
}
|
||||
}
|
||||
|
||||
// Backward compatible: just return the closed issue
|
||||
data, _ := json.Marshal(closedIssue)
|
||||
return Response{
|
||||
Success: true,
|
||||
@@ -1242,6 +1262,7 @@ func (s *Server) handleReady(req *Request) Response {
|
||||
|
||||
wf := types.WorkFilter{
|
||||
Status: types.StatusOpen,
|
||||
Type: readyArgs.Type,
|
||||
Priority: readyArgs.Priority,
|
||||
Unassigned: readyArgs.Unassigned,
|
||||
Limit: readyArgs.Limit,
|
||||
@@ -1252,6 +1273,9 @@ func (s *Server) handleReady(req *Request) Response {
|
||||
if readyArgs.Assignee != "" && !readyArgs.Unassigned {
|
||||
wf.Assignee = &readyArgs.Assignee
|
||||
}
|
||||
if readyArgs.ParentID != "" {
|
||||
wf.ParentID = &readyArgs.ParentID
|
||||
}
|
||||
|
||||
ctx := s.reqCtx(req)
|
||||
issues, err := store.GetReadyWork(ctx, wf)
|
||||
@@ -1269,6 +1293,44 @@ func (s *Server) handleReady(req *Request) Response {
|
||||
}
|
||||
}
|
||||
|
||||
func (s *Server) handleBlocked(req *Request) Response {
|
||||
var blockedArgs BlockedArgs
|
||||
if err := json.Unmarshal(req.Args, &blockedArgs); err != nil {
|
||||
return Response{
|
||||
Success: false,
|
||||
Error: fmt.Sprintf("invalid blocked args: %v", err),
|
||||
}
|
||||
}
|
||||
|
||||
store := s.storage
|
||||
if store == nil {
|
||||
return Response{
|
||||
Success: false,
|
||||
Error: "storage not available (global daemon deprecated - use local daemon instead with 'bd daemon' in your project)",
|
||||
}
|
||||
}
|
||||
|
||||
var wf types.WorkFilter
|
||||
if blockedArgs.ParentID != "" {
|
||||
wf.ParentID = &blockedArgs.ParentID
|
||||
}
|
||||
|
||||
ctx := s.reqCtx(req)
|
||||
blocked, err := store.GetBlockedIssues(ctx, wf)
|
||||
if err != nil {
|
||||
return Response{
|
||||
Success: false,
|
||||
Error: fmt.Sprintf("failed to get blocked issues: %v", err),
|
||||
}
|
||||
}
|
||||
|
||||
data, _ := json.Marshal(blocked)
|
||||
return Response{
|
||||
Success: true,
|
||||
Data: data,
|
||||
}
|
||||
}
|
||||
|
||||
func (s *Server) handleStale(req *Request) Response {
|
||||
var staleArgs StaleArgs
|
||||
if err := json.Unmarshal(req.Args, &staleArgs); err != nil {
|
||||
|
||||
@@ -188,6 +188,8 @@ func (s *Server) handleRequest(req *Request) Response {
|
||||
resp = s.handleResolveID(req)
|
||||
case OpReady:
|
||||
resp = s.handleReady(req)
|
||||
case OpBlocked:
|
||||
resp = s.handleBlocked(req)
|
||||
case OpStale:
|
||||
resp = s.handleStale(req)
|
||||
case OpStats:
|
||||
|
||||
Reference in New Issue
Block a user