* wy-j2upyy: render the derived GATED decoration on bd show and bd list
A bead an open gate blocks is excluded from `bd ready` but rendered
`[P2 · OPEN]` by `bd show` and with a plain ○ by `bd list`, so the human
surfaces disagreed with the readiness query.
The decoration is DERIVED, never stored: no status write, no --status
filter change, no existing JSON field reshaped.
- internal/types/gated.go: IsActiveGate, the ONE predicate — a gate-typed
dependency reached over a blocking edge (blocks / conditional-blocks /
waits-for) whose status is neither closed nor pinned. That is the
is_blocked recompute's blocking leg restricted to gates, so a rendered
GATED and a `bd ready` exclusion cannot disagree. GateDescription /
GateReason own the reason's round trip with `bd gate create`.
- bd show: `[P2 · OPEN · GATED]` plus one `Gated by: <id> (<type>[:
<reason>][, awaiting <await-id>])` line per gate, beside Deferred:. The
dependency read the DEPENDS ON section already made is hoisted, so the
decoration costs no extra query.
- bd list: ⊘ in the glyph column (circle family, distinct from ○ and ❄),
and a legend entry when the page carries one. Batched by id set —
at most two extra queries per listing, one in the tree view where the
edge map is already loaded.
- --json: additive `gated_by: [{id,type,reason}]` on the detail view,
omitted when empty; documented in the OpenAPI IssueDetails schema.
Tests (red first): cmd/bd/gated_render_embedded_test.go drives real
bd show/list/--json over an embedded rig — gated, resolved, deferred+gated,
JSON additivity — plus pure unit tests for the predicate and formatters.
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
* wy-j2upyy: document the additive gated_by field in the JSON schema reference
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
* wy-j2upyy: cover the flat list route's own batched gate read
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
* wy-j2upyy: make GATED the readiness rule's gate clause, both halves
The adversarial review found the "one predicate shared with bd ready" claim
false on two axes, and both were reproducible by hand:
BLOCKER 1 — waits-for is not the status rule. The is_blocked recompute applies
"target not closed and not pinned" only to its blocks / conditional-blocks
legs; the waits-for leg goes through waitsForGateBlockedSQL, a fanout over the
target's open parent-child children (or an also_blocks spawner). A plain
`bd dep add X G -t waits-for` onto an open childless gate therefore leaves X
in `bd ready` while every new surface called it GATED. Mirroring that leg in
Go would be a second implementation of a rule the database owns, so the edge
clause now names the two legs it really mirrors (types.IsGateEdge) and the
test that pinned the wrong direction is flipped.
BLOCKER 2 — the subject half was missing and spelled three different ways.
unmarkAllBlockedSQL forces is_blocked=0 for a closed or pinned subject
whatever its edges say, so `bd ready` never withholds one on a gate's account;
show and workapi filtered nothing, cmd/bd/gated.go filtered closed only, and
list_format.go filtered closed at two more sites. A force-closed bead rendered
[CLOSED · GATED] with gated_by on show while list showed a plain row — show
and list disagreeing about one bead, which is the drift this was meant to
prevent. The clause is now types.SubjectCanBeGated, asked once in
types.GatesHolding (which replaces ActiveGates and takes the subject) and once
in the listing helper that has no hydrated deps; the formatters re-ask the SAME
exported predicate rather than inventing a fourth spelling.
SHOULD 3 — agent mode computed the gate reads and threw them away, in every
CLAUDE_CODE seat, i.e. the population that filed the bug. Decorating it is the
real fix, so gatesByIssueID now returns the gate IDS and formatAgentIssue
carries "gated by: <id>" in the parenthetical it already prints. A gate is
also a blocker, so its id appears under both "blocked by" and "gated by": the
first says what to wait on, the second says which of those nobody can clear by
doing more work. --long and --format render no gate and no longer pay for the
reads.
NOTE 5 — a pinned+gated row kept ⊘ instead of 📌; with the subject clause a
pinned bead is not gated at all, so the pin survives by construction.
NOTE 6 — the cost comments claimed "two queries" / "exactly ONE"; the id-set
readers are a few round trips each. The bound that is real (per page, never
per row) is what the comments now say.
Tests, red-first: the flipped waits-for case; TestGatesHoldingSubjectStatus and
TestSubjectCanBeGated (open/in_progress/deferred yes, closed/pinned/nil no);
TestFormatIssueCompactGated and TestFormatAgentIssueGated; and four embedded
arms — a waits-for edge that bd ready lists and no surface decorates, a
force-closed subject and a pinned subject that render nothing and publish no
gated_by, and the agent line naming its gate. Each was watched to fail against
the pre-fix predicate before it passed.
Ran: go test ./internal/types/ -run 'TestGateIsHolding|TestGatesHolding|
TestSubjectCanBeGated|TestGateDescriptionRoundTrip|TestGateRefsProjection';
go test ./cmd/bd/ -run 'TestFormat*Gated|TestFormatIssueCompact*|
TestFormatDependencyInfoWithParent|TestListRoles*|TestDisplayPrettyList*';
BEADS_TEST_EMBEDDED_DOLT=1 go test ./cmd/bd/ -run TestEmbeddedGatedRendering
(11/11 subtests); gofmt -l (empty), go vet and golangci-lint on cmd/bd,
internal/types, internal/ui, internal/workapi; scripts/ci/pr-policy.sh.
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
* wy-j2upyy: render GATED on the proxied `bd show` text route
SHOULD 4 of the review, and required for this rig: the constellation runs
proxied-server, where `bd show --json` already carried gated_by (uow
issue_reader -> workapi.BuildIssueDetails) while the TEXT renderer called the
plain formatters. The same bead read two ways from the same server disagreed.
proxiedRenderIssue now hoists the outgoing-edge read it already did for the
DEPENDS ON section above the header — the gates are the gate-typed subset of
that very set, so the decoration costs no extra query — and passes them to
formatIssueHeaderWithGates / formatIssueMetadataWithGates. The proxied LIST
routes were wired in the previous commit.
TestProxiedServerGatedRendering covers all five text surfaces plus the JSON
one beside them (header + Gated by line, pretty glyph, compact glyph + "gated
by", agent line, and a closed subject that renders nothing). Watched red first
with the proxied decoration stubbed out: four of six subtests failed, and the
--json arm passed, which is exactly the asymmetry the review reported.
Ran: BEADS_TEST_PROXIED_SERVER=1 go test ./cmd/bd/
-run TestProxiedServerGatedRendering -count=1 (6/6, 37.8s).
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
* wy-j2upyy: put cmd/bd/state.go on the shared "Reason:" marker
NOTE 7 of the review: types' gateReasonMarker was not gate-private —
cmd/bd/state.go wrote the same "\n\nReason: " into state-change EVENT
descriptions from its own literal. No live collision (events are not
gate-typed), but the constant's doc claimed GateReason returns "" for every
gate not made by `bd gate create`, and that is false for any description
carrying the marker.
The previous commit exported the constant as types.ReasonMarker, reworded
GateReason to say what the pair really guarantees (a round trip, not a
provenance check) and pinned the honest behavior in
TestGateDescriptionRoundTrip. This commit is the second writer: state.go now
builds its event description from the same constant, so the two cannot drift
apart by accident.
Ran: go build ./...; go test ./internal/types/ -run TestGateDescriptionRoundTrip
-count=1; gofmt -l cmd/bd/state.go (empty); go vet ./cmd/bd/.
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
* wy-j2upyy: alias types.GateRef in package backend
gated_by on IssueDetails makes GateRef reachable from the public backend
contract; TestPublicSurfaceComplete requires every such type to carry an
alias here.
Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
* wy-j2upyy: build(bazel): register gated.go and its tests in cmd/bd and internal/types
The rebase onto e766da5ed carried the new source files but not their
BUILD.bazel entries, so every Bazel lane failed to compile internal/types
(undefined: GateRef). This is CI's own bazel-sync patch for 9ad7eb96c3,
applied unchanged.
Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
* wy-j2upyy: compute gated_by AFTER the dependencies read in BuildIssueDetails
The be-lpi merge (#6352) moved src.Dependencies() below the cardinality
counts so the unresolvable-edge delta reads count-first. That hunk merged
cleanly, which left details.GatedBy computed on the still-nil slice, and
both CI shards' show_json…carries_gated_by subtests went red (PR Risk
Embedded Dolt Cmd 20/20, Proxied Dolt Cmd 4/15 at d21237f3dc).
Move the GatedBy line to directly after details.Dependencies = deps, still
before the BriefDeps trim that rewrites the slice, and pin the ordering with
a workapi unit test over both DetailSource seams and BriefDeps on/off (red
on the pre-fix code, green after).
Ran: go test ./internal/workapi; go vet ./internal/workapi;
BEADS_TEST_EMBEDDED_DOLT=1 go test ./cmd/bd -run TestEmbeddedGatedRendering;
BEADS_TEST_PROXIED_SERVER=1 go test ./cmd/bd -run TestProxiedServerGatedRendering.
Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
* ci: register #6606's gated-rendering tests and gated_by wire shape with main's generated gates
Maintainer fixup for adopt-pr #6606. The adopted head merges the PR head
(c43eb567d2) into main (800d43eb8d). The PR's merge-base (02f05340f6)
predates three generated artifacts on main that every PR adding a cmd/bd
tier test or a wire member has to keep current, so the merged tree is red
on them even though the PR's own CI cannot see them:
- .github/scripts/embedded-cmd-test-shards.txt: the Bazel-only 50-shard
block must name every TestEmbedded* test exactly once, or
TestCmdEmbeddedShardManifestGeneratorNotStale fails `go test ./scripts/`.
`gen_embedded_cmd_shard_manifest.py 50 --weights=duration --write`
(incremental) placed TestEmbeddedGatedRendering on shard 16 and moved
no existing assignment; the frozen 20-shard block is untouched.
- .github/scripts/proxied-cmd-test-shards.txt: likewise for the 30-shard
block and TestProxiedServerGatedRendering (shard 2), via
`gen_proxied_shard_manifest.py 30 --weights=duration --write`, so
TestProxiedShardManifestGeneratorNotStale passes.
- internal/httpapi/wireshape/testdata/golden.json: TestWireShapeDigest
(#7182) pins every response member. `go run
./internal/httpapi/wireshape/cmd/gendigest` recorded the PR's new
IssueDetails.gated_by array and its id/type/reason members as four pure
additions (+25/-0), so no wire_revision bump is owed.
The PR's own files are unchanged.
Agent-Signature: claude-code-claude-opus-5-5-max on behalf of Gas City Adopt-PR
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* docs(gated): state gated_by one way, mark --watch as undecorated, fix stale refs
Review follow-ups for #6606. Comment and doc text only; no behavior change.
- gated_by is now documented in one direction. internal/types/types.go,
internal/types/gated.go and docs/reference/json-schema.md said the list
is nonempty EXACTLY when `bd ready` withholds the issue on a gate's
account. Only one direction holds: the is_blocked recompute also blocks
a child whose parent is blocked (its parent-child legs), so a child of a
gated parent leaves `bd ready` with an empty gated_by. All three now say
"nonempty means withheld", as the OpenAPI text already did, and name the
parent-child case.
- bd list --watch passes a nil gated map on both routes
(runListProxiedWatch, displayWatchedIssueList), so a bead the one-shot
listing marks with the gated glyph keeps its plain status glyph while
watched. Watch is out of this PR's scope; the three call sites now say
so instead of reading as a forgotten argument.
- show_format.go named types.ActiveGates, which does not exist; the
predicate is types.GatesHolding.
- gated.go's best-effort note compared the gate read with `bd list`'s
blocking annotation, which only the direct route swallows. It now scopes
that comparison to the direct route and names the proxied route's
failing read (A-blk-1).
- proxiedGatedIssueIDsOwnUOW now notes that its unit of work is a second
snapshot, so one render can name a just-resolved gate under "blocked by:"
but not "gated by:".
Agent-Signature: claude-code-claude-opus-5-5-max on behalf of Gas City Adopt-PR
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* fix(list): hydrate proxied gate candidates from both planes (bd-p8k7dm)
The proxied list resolved gate candidates through the use case's
GetIssuesByIDs, which reads the issues table only, while the edges it
resolved came from GetForIssueIDs, which reads both dependency tables.
A wisp gate (`bd mol wisp` clones a formula's gates as wisps, held to a
wisp step by a blocks edge) therefore hydrated to nothing. Its step
listed undecorated in pretty, --flat and agent output while `bd show`,
`--json` and `bd ready` called it gated.
Read the wisps beside the issues, the two-plane idiom
ready_proxied_server.go and uowMolReader already use. A failed wisps
read keeps the durable candidates. Correct the cost-bound comment that
claimed the id-set readers partition the planes on both routes.
Tests: a wisp-step + wisp-gate case in TestProxiedServerGatedRendering
and TestEmbeddedGatedRendering asserts the pretty, --flat and
CLAUDE_CODE=1 rows of `bd list --include-ephemeral`, and
TestProxiedGatedIssueIDsHydratesBothPlanes pins both planes plus the
failed-wisps-read fallback.
Agent-Signature: claude-code-claude-opus-5-5-max on behalf of Gas City Adopt-PR
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
---------
Co-authored-by: Claude Opus 5 (1M context) <noreply@anthropic.com>
Co-authored-by: Eddie the Engineer <adopt-pr@gascity.com>
351 lines
16 KiB
Go
351 lines
16 KiB
Go
package main
|
||
|
||
import (
|
||
"cmp"
|
||
"fmt"
|
||
"slices"
|
||
"strings"
|
||
"time"
|
||
|
||
"github.com/steveyegge/beads/internal/types"
|
||
"github.com/steveyegge/beads/internal/ui"
|
||
"github.com/steveyegge/beads/internal/utils"
|
||
"github.com/steveyegge/beads/internal/workapi"
|
||
)
|
||
|
||
// buildIssueTree builds parent-child tree structure from issues
|
||
// Uses actual parent-child dependencies from the database when store is provided
|
||
func buildIssueTree(issues []*types.Issue) (roots []*types.Issue, childrenMap map[string][]*types.Issue) {
|
||
return buildIssueTreeWithDeps(issues, nil)
|
||
}
|
||
|
||
// buildIssueTreeWithDeps builds parent-child tree using dependency records
|
||
// If allDeps is nil, falls back to dotted ID hierarchy (e.g., "parent.1")
|
||
// Only parent-child dependency edges establish nesting; other edge types
|
||
// (blocks, waits-for, discovered-from, relates-to, ...) are workflow/graph
|
||
// links and are not rendered as hierarchy.
|
||
func buildIssueTreeWithDeps(issues []*types.Issue, allDeps map[string][]*types.Dependency) (roots []*types.Issue, childrenMap map[string][]*types.Issue) {
|
||
return buildIssueTreeWithDepsOrdered(issues, allDeps, compareIssuesByPriority)
|
||
}
|
||
|
||
// buildIssueTreeWithDepsOrdered builds the same hierarchy while preserving the
|
||
// caller's requested order within each root and sibling group.
|
||
func buildIssueTreeWithDepsOrdered(issues []*types.Issue, allDeps map[string][]*types.Dependency, compare func(a, b *types.Issue) int) (roots []*types.Issue, childrenMap map[string][]*types.Issue) {
|
||
issueMap := make(map[string]*types.Issue)
|
||
childrenMap = make(map[string][]*types.Issue)
|
||
isChild := make(map[string]bool)
|
||
|
||
for _, issue := range issues {
|
||
issueMap[issue.ID] = issue
|
||
}
|
||
|
||
// If we have dependency records, use them to find parent-child relationships.
|
||
// Nesting is driven strictly by the parent-child edge type. Earlier versions
|
||
// also nested any dependency whose target was an epic, but that conflated
|
||
// workflow edges (a task that merely blocks an epic) with membership, so a
|
||
// genuinely 2-layer parent tree could render as a 6+ level tangle and trigger
|
||
// false "the hierarchy is broken" conclusions. This now matches the storage
|
||
// layer, which scopes an epic's children to parent-child edges only
|
||
// (see epic_closure.go); non-hierarchical edges stay off the tree.
|
||
if allDeps != nil {
|
||
addedChild := make(map[string]bool) // tracks "parentID:childID" to prevent duplicates
|
||
for issueID, deps := range allDeps {
|
||
for _, dep := range deps {
|
||
if dep.Type != types.DepParentChild {
|
||
continue
|
||
}
|
||
parentID := dep.DependsOnID
|
||
// Only include if both parent and child are in the issue set
|
||
child, childOk := issueMap[issueID]
|
||
_, parentOk := issueMap[parentID]
|
||
if !childOk || !parentOk {
|
||
continue
|
||
}
|
||
|
||
key := parentID + ":" + issueID
|
||
if !addedChild[key] {
|
||
childrenMap[parentID] = append(childrenMap[parentID], child)
|
||
addedChild[key] = true
|
||
}
|
||
isChild[issueID] = true
|
||
}
|
||
}
|
||
}
|
||
|
||
// Fallback: check for hierarchical subtask IDs (e.g., "parent.1")
|
||
for _, issue := range issues {
|
||
if isChild[issue.ID] {
|
||
continue // Already a child via dependency
|
||
}
|
||
if strings.Contains(issue.ID, ".") {
|
||
parts := strings.Split(issue.ID, ".")
|
||
parentID := strings.Join(parts[:len(parts)-1], ".")
|
||
if _, exists := issueMap[parentID]; exists {
|
||
childrenMap[parentID] = append(childrenMap[parentID], issue)
|
||
isChild[issue.ID] = true
|
||
continue
|
||
}
|
||
}
|
||
}
|
||
|
||
// Roots are issues that aren't children of any other issue
|
||
for _, issue := range issues {
|
||
if !isChild[issue.ID] {
|
||
roots = append(roots, issue)
|
||
}
|
||
}
|
||
|
||
// Sort roots for stable tree ordering (fixes unstable --tree output)
|
||
// Use same sorting logic as children for consistency
|
||
slices.SortFunc(roots, compare)
|
||
|
||
// Sort children within each parent for stable ordering in data structure
|
||
for parentID := range childrenMap {
|
||
slices.SortFunc(childrenMap[parentID], compare)
|
||
}
|
||
|
||
return roots, childrenMap
|
||
}
|
||
|
||
func compareIssuesForTree(sortBy string, reverse bool) func(a, b *types.Issue) int {
|
||
if sortBy == "" {
|
||
if reverse {
|
||
return func(a, b *types.Issue) int {
|
||
if result := cmp.Compare(a.Priority, b.Priority); result != 0 {
|
||
return -result
|
||
}
|
||
return utils.NaturalCompareIDs(a.ID, b.ID)
|
||
}
|
||
}
|
||
return compareIssuesByPriority
|
||
}
|
||
return func(a, b *types.Issue) int {
|
||
result := workapi.CompareIssuesBy(a, b, sortBy)
|
||
if reverse {
|
||
result = -result
|
||
}
|
||
if result != 0 {
|
||
return result
|
||
}
|
||
return utils.NaturalCompareIDs(a.ID, b.ID)
|
||
}
|
||
}
|
||
|
||
// compareIssuesByPriority provides stable sorting for tree display
|
||
// Primary sort: priority (P0 before P1 before P2...)
|
||
// Secondary sort: ID for deterministic ordering when priorities match
|
||
func compareIssuesByPriority(a, b *types.Issue) int {
|
||
// Primary: priority (ascending: P0 before P1 before P2...)
|
||
if result := cmp.Compare(a.Priority, b.Priority); result != 0 {
|
||
return result
|
||
}
|
||
// Secondary: ID for deterministic order when priorities match
|
||
return utils.NaturalCompareIDs(a.ID, b.ID)
|
||
}
|
||
|
||
// treeCycleMarker is appended to a tree line whose issue is already an
|
||
// ancestor on the current path. It mirrors the "(shown above)" arm of
|
||
// bd dep tree but means something narrower: an ancestor of this very line,
|
||
// not any node the walk happened to print earlier.
|
||
//
|
||
// It names the edge class rather than a command to run. childrenMap is built
|
||
// from parent-child edges alone, so every cycle this marker can fire on is a
|
||
// parent-child cycle — and no command reports that class today: bd dep cycles
|
||
// and bd doctor both walk the blocking graph (DetectCycles uses
|
||
// AppendBlockingGraphInTx deliberately; see issueops/cycles.go), which admits
|
||
// blocks and conditional-blocks only. Sent there, the reader gets an
|
||
// affirmative "No dependency cycles detected" for the very store that just
|
||
// produced this line. Cite a command here only once one can see these edges.
|
||
const treeCycleMarker = "(cycle: shown above; parent-child cycle in stored edges)"
|
||
|
||
// printPrettyTree recursively prints the issue tree.
|
||
// Children use the requested list order. With --deps, dependency order takes
|
||
// precedence and the requested order breaks ties. When dr is set, each node's
|
||
// dependency edges are annotated just beneath it.
|
||
func printPrettyTree(childrenMap map[string][]*types.Issue, parentID string, prefix string, dr *depRender, compare func(a, b *types.Issue) int, gated map[string][]string) {
|
||
printPrettyTreePath(childrenMap, parentID, prefix, dr, compare, gated, map[string]bool{parentID: true})
|
||
}
|
||
|
||
// printPrettyTreePath is printPrettyTree carrying the set of ancestors on the
|
||
// current root-to-node path. childrenMap comes from stored edges, and a cycle
|
||
// in it (parent-child rows imported without validation, or a build that nested
|
||
// every dependency on an epic, as v1.2.2 did) must not recurse forever: the
|
||
// walk allocates until the host swaps (GH#5887). A child already on the path
|
||
// is printed once with a marker and not descended. The set is scoped to the
|
||
// path, not the whole walk, so a node reachable through two parents still
|
||
// renders under both; only a true ancestor counts as a cycle. Like the
|
||
// "(shown above)" arm of bd dep tree, the marked line carries no --deps
|
||
// annotations: they were printed with the node's first appearance.
|
||
func printPrettyTreePath(childrenMap map[string][]*types.Issue, parentID string, prefix string, dr *depRender, compare func(a, b *types.Issue) int, gated map[string][]string, onPath map[string]bool) {
|
||
children := childrenMap[parentID]
|
||
|
||
if dr != nil {
|
||
children = orderSiblingsByDeps(children, dr.allDeps, compare)
|
||
} else {
|
||
slices.SortFunc(children, compare)
|
||
}
|
||
|
||
for i, child := range children {
|
||
isLast := i == len(children)-1
|
||
connector := "├── "
|
||
if isLast {
|
||
connector = "└── "
|
||
}
|
||
if onPath[child.ID] {
|
||
fmt.Printf("%s%s%s %s\n", prefix, connector, formatPrettyIssueGated(child, gated[child.ID]), ui.RenderMuted(treeCycleMarker)) //nolint:forbidigo // Pretty-tree output is outside the --format contract.
|
||
continue
|
||
}
|
||
fmt.Printf("%s%s%s\n", prefix, connector, formatPrettyIssueGated(child, gated[child.ID])) //nolint:forbidigo // Pretty-tree output is outside the --format contract.
|
||
|
||
extension := "│ "
|
||
if isLast {
|
||
extension = " "
|
||
}
|
||
dr.annotationsFor(child.ID, prefix+extension)
|
||
onPath[child.ID] = true
|
||
printPrettyTreePath(childrenMap, child.ID, prefix+extension, dr, compare, gated, onPath)
|
||
delete(onPath, child.ID)
|
||
}
|
||
}
|
||
|
||
// displayPrettyList displays issues in pretty tree format (GH#654)
|
||
// Uses buildIssueTree which only supports dotted ID hierarchy
|
||
// There is no --ready arm behind this one: it is the plain tree, so the
|
||
// summary keeps its status breakdown.
|
||
func displayPrettyList(issues []*types.Issue, showHeader bool) {
|
||
displayPrettyListWithDeps(issues, showHeader, nil, false, false, "")
|
||
}
|
||
|
||
// displayPrettyListWithDeps displays issues in tree format using dependency data.
|
||
// readyFiltered and statusSelector must be threaded from the caller's --ready
|
||
// / --status state rather than defaulted here: the watch paths reach the
|
||
// summary through this wrapper, and a hardcoded false silently restores the
|
||
// vacuous "(N open, 0 in progress)" that listFooterLine exists to suppress.
|
||
func displayPrettyListWithDeps(issues []*types.Issue, showHeader bool, allDeps map[string][]*types.Dependency, truncated, readyFiltered bool, statusSelector string) {
|
||
displayPrettyListWithDepsMode(issues, showHeader, allDeps, "", truncated, readyFiltered, statusSelector, "", false, nil)
|
||
}
|
||
|
||
// listFooterLine renders the one-line summary under a text listing.
|
||
//
|
||
// The status breakdown is only meaningful when the query could have returned
|
||
// more than one status. Under --ready the query is status-pinned: the default
|
||
// (no --status, or --status all) is still open, so "(N open, 0 in progress)"
|
||
// is a tautology for ANY database, including one with a thousand in-progress
|
||
// issues matching the same label. An explicit --status is the intersection
|
||
// (GH#5832), and the same tautology applies to whatever selector was asked
|
||
// for — the footer must name that selector rather than reuse the default-open
|
||
// sentence.
|
||
//
|
||
// Printed next to a real count that number reads as a finding rather than an
|
||
// artifact of the flag: "0 in progress" answers the question "is anything in
|
||
// progress here?" with a confident no, while the rows that would have said
|
||
// otherwise were removed before counting. So when a status filter is in force by
|
||
// construction, say what was excluded instead of asserting a count for it. This
|
||
// is the same principle as the truncation arm below, which refuses to label a
|
||
// cut-off page "Total" (GH#5362): a count is only honest alongside its scope.
|
||
func listFooterLine(total, open, inProgress int, truncated, readyFiltered bool, statusSelector string) string {
|
||
if readyFiltered {
|
||
// No status breakdown: --ready makes it vacuous. Name the scope instead.
|
||
scope := readyFooterScope(statusSelector)
|
||
if truncated {
|
||
return fmt.Sprintf("Showing %d ready issues (%s); more match (truncated by --limit). Use --limit 0 for all.", total, scope)
|
||
}
|
||
return fmt.Sprintf("Ready: %d issues with no active blockers (%s)", total, scope)
|
||
}
|
||
if truncated {
|
||
return fmt.Sprintf("Showing %d issues (%d open, %d in progress); more match (truncated by --limit). Use --limit 0 for all.",
|
||
total, open, inProgress)
|
||
}
|
||
return fmt.Sprintf("Total: %d issues (%d open, %d in progress)", total, open, inProgress)
|
||
}
|
||
|
||
// readyFooterScope names the status pin a --ready listing actually used.
|
||
// Empty / "all" still take the open default; an explicit selector is the
|
||
// intersection and must not reuse "excludes in_progress" (GH#5832).
|
||
func readyFooterScope(statusSelector string) string {
|
||
var parts []string
|
||
for _, part := range strings.Split(statusSelector, ",") {
|
||
part = strings.TrimSpace(part)
|
||
if part != "" {
|
||
parts = append(parts, part)
|
||
}
|
||
}
|
||
if len(parts) == 0 || (len(parts) == 1 && parts[0] == "all") {
|
||
return "open only — --ready excludes in_progress"
|
||
}
|
||
return strings.Join(parts, ",") + " only"
|
||
}
|
||
|
||
// displayPrettyListWithDepsMode displays issues in tree format. When depsMode is
|
||
// "scheduling" or "all", the tree also annotates each node's dependency edges and
|
||
// orders siblings by their scheduling dependencies (see orderSiblingsByDeps). An
|
||
// empty depsMode is the plain parent-child tree. truncated means the page was cut
|
||
// by --limit; the summary then says "Showing N" instead of "Total: N" (GH#5362).
|
||
// readyFiltered means --ready was in force; statusSelector is the --status value
|
||
// so the summary names the pin that actually applied — see listFooterLine.
|
||
// sortBy and reverse preserve the requested list order within the hierarchy.
|
||
// gated maps each listed id to the OPEN gates holding it (gatesByIssueID);
|
||
// nil means the caller computed no gate decoration, and every row renders as
|
||
// it always did.
|
||
func displayPrettyListWithDepsMode(issues []*types.Issue, showHeader bool, allDeps map[string][]*types.Dependency, depsMode string, truncated, readyFiltered bool, statusSelector, sortBy string, reverse bool, gated map[string][]string) {
|
||
if showHeader {
|
||
// Clear screen and show header
|
||
fmt.Print("\033[2J\033[H") //nolint:forbidigo // Pretty-tree output is outside the --format contract.
|
||
fmt.Println(strings.Repeat("=", 80)) //nolint:forbidigo // Pretty-tree output is outside the --format contract.
|
||
fmt.Printf("Beads - Open & In Progress (%s)\n", time.Now().Format("15:04:05")) //nolint:forbidigo // Pretty-tree output is outside the --format contract.
|
||
fmt.Println(strings.Repeat("=", 80)) //nolint:forbidigo // Pretty-tree output is outside the --format contract.
|
||
fmt.Println() //nolint:forbidigo // Pretty-tree output is outside the --format contract.
|
||
}
|
||
|
||
if len(issues) == 0 {
|
||
fmt.Println("No issues found.") //nolint:forbidigo // Pretty-tree output is outside the --format contract.
|
||
return
|
||
}
|
||
|
||
compare := compareIssuesForTree(sortBy, reverse)
|
||
roots, childrenMap := buildIssueTreeWithDepsOrdered(issues, allDeps, compare)
|
||
|
||
var dr *depRender
|
||
if depsMode != "" {
|
||
inView := make(map[string]*types.Issue, len(issues))
|
||
for _, issue := range issues {
|
||
inView[issue.ID] = issue
|
||
}
|
||
dr = &depRender{mode: depsMode, allDeps: allDeps, inView: inView}
|
||
roots = orderSiblingsByDeps(roots, allDeps, compare)
|
||
}
|
||
|
||
for _, issue := range roots {
|
||
fmt.Println(formatPrettyIssueGated(issue, gated[issue.ID])) //nolint:forbidigo // Pretty-tree output is outside the --format contract.
|
||
dr.annotationsFor(issue.ID, "")
|
||
printPrettyTree(childrenMap, issue.ID, "", dr, compare, gated)
|
||
}
|
||
|
||
// Summary — counts describe the shown page; never label a truncated page "Total".
|
||
fmt.Println() //nolint:forbidigo // Pretty-tree output is outside the --format contract.
|
||
fmt.Println(strings.Repeat("-", 80)) //nolint:forbidigo // Pretty-tree output is outside the --format contract.
|
||
openCount := 0
|
||
inProgressCount := 0
|
||
for _, issue := range issues {
|
||
switch issue.Status {
|
||
case "open":
|
||
openCount++
|
||
case "in_progress":
|
||
inProgressCount++
|
||
}
|
||
}
|
||
fmt.Println(listFooterLine(len(issues), openCount, inProgressCount, truncated, readyFiltered, statusSelector)) //nolint:forbidigo // Pretty-tree output is outside the --format contract.
|
||
fmt.Println() //nolint:forbidigo // Pretty-tree output is outside the --format contract.
|
||
// The gated glyph joins the legend only when the page actually carries one:
|
||
// it is a derived decoration, not a status, and a permanent entry would
|
||
// promise a row shape most listings never show.
|
||
statusLegend := "Status: ○ open ◐ in_progress ● blocked ✓ closed ❄ deferred"
|
||
if len(gated) > 0 {
|
||
statusLegend += " " + ui.StatusIconGated + " gated (open gate; not in bd ready)"
|
||
}
|
||
fmt.Println(statusLegend) //nolint:forbidigo // Pretty-tree output is outside the --format contract.
|
||
fmt.Println("Priority: P0–P4 (label only; not a status icon)") //nolint:forbidigo // Pretty-tree output is outside the --format contract.
|
||
if dr != nil {
|
||
fmt.Printf("Deps: %s = depends-on / relationship (points to target); siblings ordered so dependencies come first; ↗ = target outside current view\n", depGlyph) //nolint:forbidigo // Pretty-tree output is outside the --format contract.
|
||
}
|
||
}
|