* fix(cli): one text-source layer for comment, note, and human respond
`bd comment`, `bd note` and `bd comments add` each read their body text a
little differently, and all three applied a SILENT precedence when a caller
gave two sources: positional text plus --stdin or --file resolved to the flag
and dropped the positional half with no message. In every case we could find,
the dropped half was the text the caller meant.
One textSources layer now owns the reading for all of them. Naming two sources
is an ERROR ("cannot combine positional text ... with --stdin") rather than a
precedence question; --file content is passed through verbatim, matching every
other file-input flag (--body-file, --design-file, --reason-file), while stdin
keeps trimming the trailing newline a shell appends; and an explicitly-set-but-
empty text flag counts as a source via cobra's Changed, so `--response ""` gets
"cannot be empty" rather than "no text provided".
`bd human respond` joins them: its response can come from positional args,
--response, --file or --stdin, so --response is no longer a required flag.
`bd human dismiss` takes its reason positionally as well as via --reason, and
both accept trailing free text (`<id> [text...]`) the way `bd comment` does —
a second argument is text, never a second id. The "Response: " prefix and the
shared Dismissed close reason are now formatted ONCE, before the proxied
dispatch, so the two backends cannot shape them differently; the same move
lets the proxied comment entry points take resolved text instead of re-reading
the flags themselves.
`human stats` classifies dismissals by that shared Dismissed prefix instead of
a case-insensitive substring search for "dismiss", so the writer and the
classifier cannot drift. Beads closed earlier with a lowercase or mid-string
"dismiss" move from the Dismissed count to Responded; CHANGELOG carries the
note.
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01UzyFzAJkmN3MGhXSo9AMwQ
* fix(human): bring `human list`/`stats` to bd list parity via IncludeAllTypes
`bd human list` built its own two-field filter: a label match plus whatever
--status the caller typed, unvalidated. So it showed closed beads by default
where `bd list` hides them, answered a typo'd status with a silent empty list
instead of an error, and — because it never went through the shared builder —
could not be told what a default listing is SUPPOSED to hide.
It goes through workapi.BuildListFilter now, which gets it the done/frozen
status exclusions, the pinned default, status validation against built-in and
custom names, comma-separated sets, and "all". `human stats` counts the same
universe (--status=all) through the same path, and the proxied side calls
openAndPrepare rather than hand-building a second filter, so the command
cannot mean one thing in direct mode and another behind the proxy.
What it must NOT inherit is the type suppression: a `human` label is an
explicit request for a person's attention, and this command is the only place
a person sees it, so gates, wisps, infra beads and templates all show. That is
the new issueops.ListRequest.IncludeAllTypes — the union of IncludeTemplates,
IncludeGates, IncludeInfra AND IncludeEphemeral. Both the type exclusions and
the PLANE decision now live in one applyTypeSuppressions that the flag skips
whole, so it decides the ephemeral plane too rather than lifting three type
knobs and leaving `bd human list` blind to human-labeled wisps. A suppression
added there in future is lifted here without touching this command.
Two pinned fixes fall out of parsing the status selector ONCE instead of
comparing the raw string in three places:
* --status=all no longer forces Pinned=false. "all" promises every status;
the string comparison never matched it, so the one selector that hides
nothing kept hiding pinned beads. The golden case status_all_keyword is
re-recorded (Pinned false -> null) and TestPinnedDefaultBySelector owns
the rule now.
* --status=pinned,closed no longer excludes the pinned beads it asks for —
the same comparison missed every multi-status set.
--ready is deliberately unaffected: it forces status open and otherwise
ignores the selector, so an "all" the query never applies must not have a
pinned side effect either.
BEHAVIOR CHANGE, called out in CHANGELOG: scripts using --status=all as a way
to list everything EXCEPT pinned beads will see pinned beads appear. Add
--no-pinned to keep the old result.
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01UzyFzAJkmN3MGhXSo9AMwQ
* fix(human): let proxied respond/dismiss answer wisps, and stop the phantom label warning
Two gaps in the proxied twins of `bd human respond`/`dismiss`, both of which
`bd human list` showing every bead type now makes reachable:
WISPS. The pair resolved through proxiedRequireIssue and then wrote the
comment and the close against the DURABLE tables. A human-labeled wisp is a
bead a person can see in `bd human list` — so it has to be one they can also
answer. Resolution goes through workapi.GetIssueOrWisp and the write side
branches: AddCommentToWisp/CloseWisp for the ephemeral plane, unchanged calls
for the durable one, still inside the single RunTx the proxied write
convention asks for.
THE ADVISORY WARNING FIRED ON A FAILED LOAD. The missing-'human'-label warning
read labels with the error discarded, so a label load that FAILED was
indistinguishable from a bead with no human label, and the user was told the
label was missing when nothing had been checked. The result now carries
labelsKnown, and a failed load simply warns nothing.
NOT salvaged: the post-commit close-hook firing this branch originally carried.
It was written when each proxied call site hand-wired its own hooks; main has
since moved firing onto the unit-of-work plumbing (uow.NewNotifyingProvider,
bd-opisf), which buffers during the transaction and drains after Commit. The
proxied human close already fires its hooks — a hand-wired call here would
fire each one twice. The reason is recorded on closeHumanProxied so the next
reader does not re-add it.
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01UzyFzAJkmN3MGhXSo9AMwQ
---------
Co-authored-by: Claude Opus 5 <noreply@anthropic.com>
145 lines
4.4 KiB
Go
145 lines
4.4 KiB
Go
package main
|
|
|
|
import (
|
|
"fmt"
|
|
|
|
"github.com/spf13/cobra"
|
|
"github.com/steveyegge/beads/internal/metrics"
|
|
"github.com/steveyegge/beads/internal/ui"
|
|
)
|
|
|
|
// validateCommentArgs runs as cobra's Args validation for the singular
|
|
// "comment" shorthand, before RunE's usesProxiedServer() dispatch and (on
|
|
// the local/embedded path) before the id ever reaches ResolvePartialID's
|
|
// fuzzy/substring matching. "comment" has no subcommands of its own — its
|
|
// only job is "add a comment to <id>" — so when the id positional argument
|
|
// is exactly a word that IS a real subcommand on the plural sibling ("list",
|
|
// "add"), the near-certain explanation is that the caller confused the
|
|
// singular and plural forms, not that a bead is genuinely named "list" or
|
|
// "add" (real ids always carry a prefix+hyphen — see looksLikePrefixedID).
|
|
// Left unguarded, that word silently resolves via ResolvePartialID's
|
|
// substring/prefix fallback to whatever existing bead or wisp id happens to
|
|
// contain it, and the comment lands on the WRONG issue with no error.
|
|
func validateCommentArgs(cmd *cobra.Command, args []string) error {
|
|
if err := cobra.MinimumNArgs(1)(cmd, args); err != nil {
|
|
return err
|
|
}
|
|
switch args[0] {
|
|
case "list":
|
|
return HandleErrorRespectJSON(`"bd comment list ..." is not valid — "comment" (singular) takes an issue id first and has no "list" subcommand.
|
|
|
|
To list comments on an issue:
|
|
bd comments <issue-id>
|
|
|
|
To add a comment:
|
|
bd comment <issue-id> "text"
|
|
|
|
See: bd comment --help`)
|
|
case "add":
|
|
return HandleErrorRespectJSON(`"bd comment add ..." is not valid — "comment" (singular) already means "add a comment" and takes an issue id first, not the word "add".
|
|
|
|
To add a comment:
|
|
bd comment <issue-id> "text"
|
|
|
|
("add" is only a subcommand of the plural form: bd comments add <issue-id> "text".)
|
|
|
|
See: bd comment --help`)
|
|
}
|
|
return nil
|
|
}
|
|
|
|
var commentCmd = &cobra.Command{
|
|
Use: "comment <id> [text...]",
|
|
GroupID: "issues",
|
|
Short: "Add a comment to an issue",
|
|
Long: `Add a comment to an issue.
|
|
|
|
Shorthand for 'bd comments add <id> "text"'.
|
|
|
|
Examples:
|
|
bd comment bd-123 "Working on this now"
|
|
bd comment bd-123 Working on this now
|
|
echo "comment from pipe" | bd comment bd-123 --stdin
|
|
bd comment bd-123 --file notes.txt
|
|
|
|
Note: "comment" (singular) only adds a comment — it has no "list" subcommand.
|
|
To list comments on an issue, use the plural form: bd comments <id>`,
|
|
Args: validateCommentArgs,
|
|
SilenceUsage: true,
|
|
SilenceErrors: true,
|
|
RunE: func(cmd *cobra.Command, args []string) error {
|
|
CheckReadonly("comment")
|
|
|
|
evt := metrics.NewCommandEvent("comment")
|
|
defer func() {
|
|
if c := metrics.Global(); c != nil {
|
|
c.CloseEventAndAdd(evt)
|
|
}
|
|
}()
|
|
|
|
id := args[0]
|
|
textArgs := args[1:]
|
|
|
|
commentText, err := requireTextFromSources("comment text", "use positional args, --stdin, or --file",
|
|
cmdTextSources(cmd, textArgs))
|
|
if err != nil {
|
|
return HandleErrorRespectJSON("%v", err)
|
|
}
|
|
|
|
author := getActorWithGit()
|
|
|
|
// Dispatched after the text is resolved so both backends read the
|
|
// same sources and report the same conflicts.
|
|
if usesProxiedServer() {
|
|
return runCommentProxiedServer(rootCtx, id, author, commentText)
|
|
}
|
|
|
|
ctx := rootCtx
|
|
|
|
result, err := resolveAndGetIssueForMutation(ctx, store, id)
|
|
if err != nil {
|
|
if result != nil {
|
|
result.Close()
|
|
}
|
|
return HandleErrorRespectJSON("resolving %s: %v", id, err)
|
|
}
|
|
if result == nil || result.Issue == nil {
|
|
if result != nil {
|
|
result.Close()
|
|
}
|
|
return HandleErrorRespectJSON("issue %s not found", id)
|
|
}
|
|
defer result.Close()
|
|
|
|
issueStore := result.Store
|
|
|
|
if err := validateIssueUpdatable(id, result.Issue); err != nil {
|
|
return HandleErrorRespectJSON("%s", err)
|
|
}
|
|
|
|
comment, err := addCommentDirect(ctx, issueStore, result.ResolvedID, author, commentText)
|
|
if err != nil {
|
|
return HandleErrorRespectJSON("adding comment: %v", err)
|
|
}
|
|
if err := commitPendingIfEmbedded(ctx, issueStore, actor, doltAutoCommitParams{
|
|
Command: "comment",
|
|
IssueIDs: []string{result.ResolvedID},
|
|
}); err != nil {
|
|
return HandleErrorRespectJSON("failed to commit: %v", err)
|
|
}
|
|
|
|
SetLastTouchedID(result.ResolvedID)
|
|
|
|
if jsonOutput {
|
|
return outputJSON(comment)
|
|
}
|
|
fmt.Printf("%s Comment added to %s\n", ui.RenderPass("✓"), formatFeedbackID(result.ResolvedID, result.Issue.Title))
|
|
return nil
|
|
},
|
|
}
|
|
|
|
func init() {
|
|
registerTextSourceFlags(commentCmd, "comment text")
|
|
commentCmd.ValidArgsFunction = issueIDCompletion
|
|
rootCmd.AddCommand(commentCmd)
|
|
}
|