Compare commits

...

1 Commits

Author SHA1 Message Date
J
3dfcb531cc fix(cli): drop "Showing N comments." stderr preamble on issue comment list
This was the only `list` subcommand that printed a human-readable count
to stderr. Consumers that merge stdout/stderr (agent harnesses, CI
`2>&1`) saw it interleaved with the JSON array on `--output json`, and
in table mode it carried no information the table itself didn't.

The `Next thread cursor` / `Next reply cursor` lines stay — they're
real paging signals the agent runtime reads from stderr.

Closes #3303
MUL-2709

Co-authored-by: multica-agent <github@multica.ai>
2026-05-27 13:06:54 +08:00
2 changed files with 38 additions and 1 deletions

View File

@@ -1002,7 +1002,6 @@ func runIssueCommentList(cmd *cobra.Command, args []string) error {
if err != nil {
return fmt.Errorf("list comments: %w", err)
}
fmt.Fprintf(os.Stderr, "Showing %d comments.\n", len(comments))
// The server emits the next-page cursor in headers when there is likely
// an older page. Surface it on stderr so an operator (and the agent
// prompt update that follows this PR) can scroll deeper without having

View File

@@ -1780,6 +1780,44 @@ func TestRunIssueCommentList_RecentStillLabelsCursorAsThread(t *testing.T) {
}
}
// TestRunIssueCommentList_DoesNotPrintShowingPreamble locks in the removal of
// the "Showing N comments." stderr preamble. The line was the only
// `list --output json` subcommand that emitted a human-readable count, which
// polluted stdout/stderr-merged consumers (agent harnesses, CI `2>&1`).
// Tracks GitHub issue #3303.
func TestRunIssueCommentList_DoesNotPrintShowingPreamble(t *testing.T) {
srv := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
if r.Method == http.MethodGet && strings.HasPrefix(r.URL.Path, "/api/issues/") && !strings.Contains(r.URL.Path, "/comments") {
json.NewEncoder(w).Encode(map[string]any{
"id": "issue-1",
"identifier": "MUL-1",
})
return
}
w.Write([]byte(`[{"id":"c1"},{"id":"c2"}]`))
}))
defer srv.Close()
t.Setenv("MULTICA_SERVER_URL", srv.URL)
t.Setenv("MULTICA_WORKSPACE_ID", "ws-1")
t.Setenv("MULTICA_TOKEN", "test-token")
stderr := captureStderr(t)
defer stderr.restore()
cmd := newIssueCommentListTestCmd()
if err := cmd.Flags().Set("output", "json"); err != nil {
t.Fatalf("set output: %v", err)
}
if err := runIssueCommentList(cmd, []string{"MUL-1"}); err != nil {
t.Fatalf("runIssueCommentList: %v", err)
}
if got := stderr.read(); strings.Contains(got, "Showing") {
t.Errorf("stderr must not contain a 'Showing ...' preamble, got: %q", got)
}
}
func TestValidIssueStatuses(t *testing.T) {
expected := map[string]bool{
"backlog": true,