Merge remote-tracking branch 'origin/polecat/rockryder-mk0frt3g'
This commit is contained in:
@@ -368,6 +368,7 @@ func runMoleculeStatus(cmd *cobra.Command, args []string) error {
|
||||
}
|
||||
} else {
|
||||
// FALLBACK: Query for hooked beads (work on agent's hook)
|
||||
// First try status=hooked (work that's been slung but not yet claimed)
|
||||
hookedBeads, err := b.List(beads.ListOptions{
|
||||
Status: beads.StatusHooked,
|
||||
Assignee: target,
|
||||
@@ -377,6 +378,21 @@ func runMoleculeStatus(cmd *cobra.Command, args []string) error {
|
||||
return fmt.Errorf("listing hooked beads: %w", err)
|
||||
}
|
||||
|
||||
// If no hooked beads found, also check in_progress beads assigned to this agent.
|
||||
// This handles the case where work was claimed (status changed to in_progress)
|
||||
// but the session was interrupted before completion. The hook should persist.
|
||||
if len(hookedBeads) == 0 {
|
||||
inProgressBeads, err := b.List(beads.ListOptions{
|
||||
Status: "in_progress",
|
||||
Assignee: target,
|
||||
Priority: -1,
|
||||
})
|
||||
if err == nil && len(inProgressBeads) > 0 {
|
||||
// Use the first in_progress bead (should typically be only one)
|
||||
hookedBeads = inProgressBeads
|
||||
}
|
||||
}
|
||||
|
||||
// For town-level roles (mayor, deacon), scan all rigs if nothing found locally
|
||||
if len(hookedBeads) == 0 && isTownLevelRole(target) {
|
||||
hookedBeads = scanAllRigsForHookedBeads(townRoot, target)
|
||||
@@ -887,6 +903,8 @@ func scanAllRigsForHookedBeads(townRoot, target string) []*beads.Issue {
|
||||
}
|
||||
|
||||
b := beads.New(rigBeadsDir)
|
||||
|
||||
// First check for hooked beads
|
||||
hookedBeads, err := b.List(beads.ListOptions{
|
||||
Status: beads.StatusHooked,
|
||||
Assignee: target,
|
||||
@@ -899,6 +917,20 @@ func scanAllRigsForHookedBeads(townRoot, target string) []*beads.Issue {
|
||||
if len(hookedBeads) > 0 {
|
||||
return hookedBeads
|
||||
}
|
||||
|
||||
// Also check for in_progress beads (work that was claimed but session interrupted)
|
||||
inProgressBeads, err := b.List(beads.ListOptions{
|
||||
Status: "in_progress",
|
||||
Assignee: target,
|
||||
Priority: -1,
|
||||
})
|
||||
if err != nil {
|
||||
continue
|
||||
}
|
||||
|
||||
if len(inProgressBeads) > 0 {
|
||||
return inProgressBeads
|
||||
}
|
||||
}
|
||||
|
||||
return nil
|
||||
|
||||
@@ -977,11 +977,25 @@ func checkSlungWork(ctx RoleContext) bool {
|
||||
Assignee: agentID,
|
||||
Priority: -1,
|
||||
})
|
||||
if err != nil || len(hookedBeads) == 0 {
|
||||
// No hooked beads - no slung work
|
||||
if err != nil {
|
||||
return false
|
||||
}
|
||||
|
||||
// If no hooked beads found, also check in_progress beads assigned to this agent.
|
||||
// This handles the case where work was claimed (status changed to in_progress)
|
||||
// but the session was interrupted before completion. The hook should persist.
|
||||
if len(hookedBeads) == 0 {
|
||||
inProgressBeads, err := b.List(beads.ListOptions{
|
||||
Status: "in_progress",
|
||||
Assignee: agentID,
|
||||
Priority: -1,
|
||||
})
|
||||
if err != nil || len(inProgressBeads) == 0 {
|
||||
return false
|
||||
}
|
||||
hookedBeads = inProgressBeads
|
||||
}
|
||||
|
||||
// Use the first hooked bead (agents typically have one)
|
||||
hookedBead := hookedBeads[0]
|
||||
|
||||
|
||||
Reference in New Issue
Block a user