feat(show): --comments-tail N renders only the last N comments in text mode (#6618)

* feat(show): --comments-tail N renders only the last N comments in text mode

Real-world beads accumulate 600+ comments and bd show renders ~800 KB of
text for them. --comments-tail N caps the text-mode COMMENTS section to
the last N comments, preceded by one elision line naming how many older
ones were hidden (singular/plural handled). This is render-only: no data
is fetched differently, and the comment count in any header still
reflects the total.

The flag absent or set to 0 is byte-identical to today's output (pinned
by a test comparing against an independent reproduction of the pre-flag
render). A negative value is a usage error, matching how --max-rows
already rejects negative values. --json is untouched; --include-comments
still streams every comment there, documented in the flag's help text.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>

* fix(show): --comments-tail reaches --watch; drop two vacuous tests

Plumb --comments-tail through watchIssue / displayShowIssue /
displayShowIssueReturn to a new renderWatchComments (its own function so
tests can exercise the exact call without a real database), replacing the
third inline COMMENTS copy that ignored the flag. watchCommentFormatTime
preserves the hardcoded UTC formatting byte for byte; --local-time still
isn't threaded to --watch, unchanged by this commit.

Also drop TestPrintComments_AbsentMatchesZero and
TestPrintComments_CommentCountHeaderUnaffected (vacuous — the first called
printComments(x, 0) against itself, the second asserted len() on a
by-value slice and bd show text mode prints no comment count); folded the
absent-flag case into the legacy-comparison test instead.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>

* ci: list show_comments_tail_test.go in cmd/bd BUILD.bazel

Bazel equivalence requires every test file in the go_test srcs; this is the
line CI's bazel-sync patch printed.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>

* ci: rerun after #7338 re-pinned the RBE worker-env (no code change)

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>

---------

Co-authored-by: Claude Fable 5.1 <noreply@anthropic.com>
Co-authored-by: Eddie the Engineer <adopt-pr@gascity.com>
This commit is contained in:
Bee 2026-10-08 09:00:31 +00:00 • committed by GitHub
commit 5d2c01bd9a
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
7 changed files with 424 additions and 37 deletions

View file

@ -1205,6 +1205,15 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
open, including the library API, `bd doctor --fix` and `bd bootstrap`, keeps
the existing message.
- **`bd show --comments-tail N`** renders only the last N comments in text
output (including under `--watch`)
([#6618](https://github.com/gastownhall/beads/pull/6618)), preceded by one
elision line naming how many older ones were hidden. A render-only cap for
fat, append-only beads whose full comment history is hundreds of KB —
description and metadata are unchanged, and omitting the flag (or passing
`0`) is byte-identical to today's output. JSON output is untouched;
`--include-comments` still streams every comment there.
### Changed
- **The managed shared Dolt server now opens its configured remotesapi

View file

@ -1118,6 +1118,7 @@ go_test(
"shared_store_migrate_gate_test.go",
"ship_embedded_test.go",
"show_brief_deps_test.go",
"show_comments_tail_test.go",
"show_current_test.go",
"show_details_json_test.go",
"show_embedded_test.go",

View file

@ -59,6 +59,10 @@ var showCmd = &cobra.Command{
includeDepends, _ := cmd.Flags().GetBool("include-dependents")
includeComments, _ := cmd.Flags().GetBool("include-comments")
briefDeps, _ := cmd.Flags().GetBool("brief-deps")
commentsTail, _ := cmd.Flags().GetInt("comments-tail")
if err := validateCommentsTail(commentsTail); err != nil {
return err
}
ctx := rootCtx
// Helper to format timestamp based on --local-time flag
@ -99,7 +103,7 @@ var showCmd = &cobra.Command{
if len(args) != 1 {
return HandleErrorRespectJSON("watch mode requires exactly one issue ID")
}
return watchIssue(ctx, args[0])
return watchIssue(ctx, args[0], commentsTail)
}
if showThread {
@ -263,17 +267,7 @@ var showCmd = &cobra.Command{
// Show comments
comments, _ := issueStore.GetIssueComments(ctx, issue.ID) // Best effort: show issue even if comments unavailable
if len(comments) > 0 {
fmt.Printf("\n%s\n", ui.RenderBold("COMMENTS"))
for _, comment := range comments {
fmt.Printf(" %s %s\n", ui.RenderMuted(formatTime(comment.CreatedAt)), comment.Author)
rendered := uimd.RenderMarkdown(comment.Text)
// TrimRight removes trailing newlines that Glamour adds, preventing extra blank lines
for _, line := range strings.Split(strings.TrimRight(rendered, "\n"), "\n") {
fmt.Printf(" %s\n", line)
}
}
}
printComments(comments, commentsTail, formatTime, issue.ID)
// Long mode: show all extended fields
if longMode {
@ -325,6 +319,7 @@ func init() {
"Without it the comments field is absent entirely, not truncated: an issue with comments carries "+
"comment_count and comments_omitted=true, so check those before reading an absent comments field as none.")
showCmd.Flags().Bool("brief-deps", false, "Reduce each dependency to its identity fields in JSON output (--json only; drops description, design, notes and acceptance criteria)")
showCmd.Flags().Int("comments-tail", 0, "Render only the last N comments in text output, preceded by one elision line naming how many older ones were hidden (text output only; 0, the default, renders every comment unchanged; N must be >= 0)")
showCmd.ValidArgsFunction = issueIDCompletion
rootCmd.AddCommand(showCmd)
}

View file

@ -0,0 +1,316 @@
package main
import (
"fmt"
"strings"
"testing"
"time"
"github.com/steveyegge/beads/internal/types"
"github.com/steveyegge/beads/internal/ui"
"github.com/steveyegge/beads/internal/uimd"
)
// testCommentsTailFormatTime is a fixed, deterministic formatTime for these
// tests — the real callers build one closed over --local-time, but the
// render function under test doesn't care which one it gets.
func testCommentsTailFormatTime(t time.Time) string {
return t.UTC().Format("2006-01-02 15:04")
}
// makeTailTestComments builds n comments with distinguishable Author/Text
// bodies ("author-0"/"body-0" .. "author-(n-1)"/"body-(n-1)") in ascending
// CreatedAt order, matching GetIssueComments' oldest-first contract — the
// same order both show routes hand to printComments today.
func makeTailTestComments(n int) []*types.Comment {
base := time.Date(2026, 1, 1, 0, 0, 0, 0, time.UTC)
comments := make([]*types.Comment, n)
for i := 0; i < n; i++ {
comments[i] = &types.Comment{
ID: fmt.Sprintf("c-%d", i),
Author: fmt.Sprintf("author-%d", i),
Text: fmt.Sprintf("body-%d", i),
CreatedAt: base.Add(time.Duration(i) * time.Minute),
}
}
return comments
}
// legacyRenderComments reproduces, verbatim, the COMMENTS block that lived
// inline in show.go / show_proxied_server.go before --comments-tail
// existed. It gives the "byte-identical to today's output" invariant an
// independent baseline to compare against, rather than comparing
// printComments against itself (which could hide a shared bug in both the
// capped and uncapped branches).
func legacyRenderComments(comments []*types.Comment, formatTime func(time.Time) string) {
if len(comments) > 0 {
fmt.Printf("\n%s\n", ui.RenderBold("COMMENTS"))
for _, comment := range comments {
fmt.Printf(" %s %s\n", ui.RenderMuted(formatTime(comment.CreatedAt)), comment.Author)
rendered := uimd.RenderMarkdown(comment.Text)
for _, line := range strings.Split(strings.TrimRight(rendered, "\n"), "\n") {
fmt.Printf(" %s\n", line)
}
}
}
}
// TestShowCommentsTailFlagRegistration guards the wiring for --comments-tail:
// the flag must exist, default to 0 so a caller that never passes it gets
// today's uncapped output, and be read by the proxied route too — the direct
// and proxied routes gather flags separately (see TestShowBriefDepsFlag),
// so a flag added to one does not reach the other by implication.
func TestShowCommentsTailFlagRegistration(t *testing.T) {
flag := showCmd.Flags().Lookup("comments-tail")
if flag == nil {
t.Fatal("comments-tail flag is not registered on showCmd")
}
if flag.DefValue != "0" {
t.Errorf("comments-tail default = %q, want \"0\": the default output must not change", flag.DefValue)
}
t.Run("proxied route defaults to 0", func(t *testing.T) {
if in := gatherShowProxiedInput(showCmd, []string{"be-abc"}); in.commentsTail != 0 {
t.Errorf("commentsTail defaulted to %d, want 0", in.commentsTail)
}
})
t.Run("proxied route reads it", func(t *testing.T) {
if err := showCmd.Flags().Set("comments-tail", "3"); err != nil {
t.Fatalf("set comments-tail=3: %v", err)
}
t.Cleanup(func() {
_ = showCmd.Flags().Set("comments-tail", "0")
showCmd.Flags().Lookup("comments-tail").Changed = false
})
if in := gatherShowProxiedInput(showCmd, []string{"be-abc"}); in.commentsTail != 3 {
t.Errorf("gatherShowProxiedInput did not carry comments-tail to the proxied request, got %d", in.commentsTail)
}
})
}
// TestValidateCommentsTail pins the negative-value usage error both show
// routes share, following how --max-rows already rejects a negative value
// (resolveMaxRows in max_rows.go).
func TestValidateCommentsTail(t *testing.T) {
if err := validateCommentsTail(0); err != nil {
t.Errorf("0 should be valid, got %v", err)
}
if err := validateCommentsTail(5); err != nil {
t.Errorf("a positive value should be valid, got %v", err)
}
var gotErr error
stderr := captureStderr(t, func() {
gotErr = validateCommentsTail(-1)
})
if gotErr == nil {
t.Fatal("expected an error for a negative --comments-tail")
}
if !strings.Contains(stderr, "--comments-tail") || !strings.Contains(stderr, "non-negative") {
t.Errorf("expected stderr to explain the flag constraint, got: %s", stderr)
}
}
// TestPrintComments_TailSmallerThanCount is scenario 1: a real cap hides the
// older comments behind exactly one elision line naming how many, and
// renders only the newest N bodies, in their existing order and format.
func TestPrintComments_TailSmallerThanCount(t *testing.T) {
comments := makeTailTestComments(5)
out := captureStdout(t, func() error {
printComments(comments, 2, testCommentsTailFormatTime, "ts-1")
return nil
})
for i := 0; i < 3; i++ {
if strings.Contains(out, fmt.Sprintf("body-%d", i)) {
t.Errorf("expected body-%d to be hidden by the cap, found it in:\n%s", i, out)
}
}
for i := 3; i < 5; i++ {
if !strings.Contains(out, fmt.Sprintf("body-%d", i)) {
t.Errorf("expected body-%d (one of the last 2) to render, missing from:\n%s", i, out)
}
}
if n := strings.Count(out, "older comment"); n != 1 {
t.Errorf("expected exactly one elision line, found %d in:\n%s", n, out)
}
wantLine := "… 3 older comments hidden — bd show ts-1 for the full record"
if !strings.Contains(out, wantLine) {
t.Errorf("expected elision line %q, got:\n%s", wantLine, out)
}
}
// TestPrintComments_TailAtOrAboveCount is scenario 2: a cap that does not
// need to hide anything (tailN >= len(comments)) must render byte-identical
// output to the uncapped (tailN == 0) path — no elision line, every comment
// present.
func TestPrintComments_TailAtOrAboveCount(t *testing.T) {
comments := makeTailTestComments(5)
uncapped := captureStdout(t, func() error {
printComments(comments, 0, testCommentsTailFormatTime, "ts-1")
return nil
})
atCount := captureStdout(t, func() error {
printComments(comments, 5, testCommentsTailFormatTime, "ts-1")
return nil
})
aboveCount := captureStdout(t, func() error {
printComments(comments, 100, testCommentsTailFormatTime, "ts-1")
return nil
})
if uncapped != atCount {
t.Errorf("tailN == len(comments) diverged from tailN == 0:\nuncapped:\n%s\natCount:\n%s", uncapped, atCount)
}
if uncapped != aboveCount {
t.Errorf("tailN > len(comments) diverged from tailN == 0:\nuncapped:\n%s\naboveCount:\n%s", uncapped, aboveCount)
}
if strings.Contains(uncapped, "older comment") {
t.Errorf("expected no elision line when nothing is hidden, got:\n%s", uncapped)
}
}
// TestPrintComments_ByteIdenticalToLegacyRender is the strongest form of "the
// flag absent or 0 must not change output": it compares printComments'
// uncapped path against an independent reproduction of the exact code that
// rendered the COMMENTS section before --comments-tail existed, so the two
// can't share a bug that a self-comparison (capped vs. uncapped both going
// through printComments) would hide. Calling printComments(x, 0) and
// comparing it to another printComments(x, 0) call would be vacuous — it
// can't fail — so every subtest here compares against legacyRenderComments
// instead.
func TestPrintComments_ByteIdenticalToLegacyRender(t *testing.T) {
comments := makeTailTestComments(7)
legacy := captureStdout(t, func() error {
legacyRenderComments(comments, testCommentsTailFormatTime)
return nil
})
current := captureStdout(t, func() error {
printComments(comments, 0, testCommentsTailFormatTime, "ts-1")
return nil
})
if legacy != current {
t.Errorf("printComments(tailN=0) diverged from the pre-flag render:\nlegacy:\n%s\ncurrent:\n%s", legacy, current)
}
// scenario 3: the flag absent — which resolves to Go's zero value for an
// unset int flag — must render identically to the pre-flag block, not
// merely to another explicit-0 call.
t.Run("flag absent (zero value)", func(t *testing.T) {
var absentTailN int // an unset --comments-tail flag GetInt()s to this
absent := captureStdout(t, func() error {
printComments(comments, absentTailN, testCommentsTailFormatTime, "ts-1")
return nil
})
if absent != legacy {
t.Errorf("flag-absent output diverged from the pre-flag render:\nabsent:\n%s\nlegacy:\n%s", absent, legacy)
}
})
t.Run("empty comments", func(t *testing.T) {
legacyEmpty := captureStdout(t, func() error {
legacyRenderComments(nil, testCommentsTailFormatTime)
return nil
})
currentEmpty := captureStdout(t, func() error {
printComments(nil, 0, testCommentsTailFormatTime, "ts-1")
return nil
})
if legacyEmpty != currentEmpty || legacyEmpty != "" {
t.Errorf("expected empty output for no comments, got legacy=%q current=%q", legacyEmpty, currentEmpty)
}
})
}
// TestPrintComments_SingularWording is scenario 5: exactly one older comment
// hidden gets "comment", not "comments".
func TestPrintComments_SingularWording(t *testing.T) {
comments := makeTailTestComments(3)
out := captureStdout(t, func() error {
printComments(comments, 2, testCommentsTailFormatTime, "ts-1")
return nil
})
wantLine := "… 1 older comment hidden — bd show ts-1 for the full record"
if !strings.Contains(out, wantLine) {
t.Errorf("expected singular elision line %q, got:\n%s", wantLine, out)
}
if strings.Contains(out, "1 older comments") {
t.Errorf("expected singular \"comment\", found plural in:\n%s", out)
}
}
// legacyWatchRenderComments reproduces, verbatim, the COMMENTS block that
// lived inline in show_display.go's displayShowIssueReturn before
// --comments-tail existed. Unlike legacyRenderComments above (which the
// direct and --proxied-server routes shared), the watch path hardcoded UTC
// unconditionally rather than taking a formatTime parameter — it never
// threaded --local-time — so this is its own, separate baseline.
func legacyWatchRenderComments(comments []*types.Comment) {
if len(comments) > 0 {
fmt.Printf("\n%s\n", ui.RenderBold("COMMENTS"))
for _, comment := range comments {
fmt.Printf(" %s %s\n", ui.RenderMuted(comment.CreatedAt.UTC().Format("2006-01-02 15:04")), comment.Author)
rendered := uimd.RenderMarkdown(comment.Text)
for _, line := range strings.Split(strings.TrimRight(rendered, "\n"), "\n") {
fmt.Printf(" %s\n", line)
}
}
}
}
// TestRenderWatchComments_TailAbsentMatchesLegacy pins that the watch path's
// own render call (renderWatchComments, the exact function
// displayShowIssueReturn calls — see show_display.go) reproduces the old
// watch block byte for byte when --comments-tail is absent (tailN == 0),
// including its hardcoded UTC formatting. This is the "watch mode ignores
// the flag" regression guard: it exercises the real wiring, not a
// hand-picked formatTime, so a future edit that stops threading
// --comments-tail to the watch render — or that starts threading
// --local-time in a way that changes the UTC formatting — would surface
// here.
func TestRenderWatchComments_TailAbsentMatchesLegacy(t *testing.T) {
comments := makeTailTestComments(4)
legacy := captureStdout(t, func() error {
legacyWatchRenderComments(comments)
return nil
})
current := captureStdout(t, func() error {
renderWatchComments(comments, 0, "ts-1")
return nil
})
if legacy != current {
t.Errorf("renderWatchComments(tailN=0) diverged from the pre-flag watch block:\nlegacy:\n%s\ncurrent:\n%s", legacy, current)
}
}
// TestRenderWatchComments_HonoursTail is the watch-path form of scenario 1:
// --comments-tail must cap the watch render the same way it caps the other
// two show routes, through the actual renderWatchComments call
// displayShowIssueReturn makes.
func TestRenderWatchComments_HonoursTail(t *testing.T) {
comments := makeTailTestComments(5)
out := captureStdout(t, func() error {
renderWatchComments(comments, 2, "ts-1")
return nil
})
for i := 0; i < 3; i++ {
if strings.Contains(out, fmt.Sprintf("body-%d", i)) {
t.Errorf("expected body-%d to be hidden by the cap in watch output, found it in:\n%s", i, out)
}
}
for i := 3; i < 5; i++ {
if !strings.Contains(out, fmt.Sprintf("body-%d", i)) {
t.Errorf("expected body-%d to render in watch output, missing from:\n%s", i, out)
}
}
wantLine := "… 3 older comments hidden — bd show ts-1 for the full record"
if !strings.Contains(out, wantLine) {
t.Errorf("expected elision line %q in watch output, got:\n%s", wantLine, out)
}
}

View file

@ -15,6 +15,26 @@ import (
"github.com/steveyegge/beads/internal/uimd"
)
// watchCommentFormatTime is the watch path's comment timestamp formatter.
// It reproduces, byte for byte, what the inline COMMENTS block here always
// did before printComments existed: UTC, unconditionally — this path does
// not read --local-time today (a pre-existing gap from the non-watch
// render), and this change does not alter that.
func watchCommentFormatTime(t time.Time) string {
return t.UTC().Format("2006-01-02 15:04")
}
// renderWatchComments prints the watch path's COMMENTS section, applying the
// same --comments-tail cap as the other two show routes, always through
// watchCommentFormatTime. Split out from displayShowIssueReturn as its own
// function so tests can exercise the watch path's exact render call —
// commentsTail plumbed all the way to printComments — without going through
// displayShowIssueReturn itself, which resolves the issue via a live store
// and so needs a real database.
func renderWatchComments(comments []*types.Comment, commentsTail int, issueID string) {
printComments(comments, commentsTail, watchCommentFormatTime, issueID)
}
// singleIssueSnapshot builds a comparable string from a single issue's state
// so we can detect when the issue has changed between poll cycles.
func singleIssueSnapshot(issue *types.Issue) string {
@ -38,10 +58,12 @@ const showWatchPollInterval = 2 * time.Second
// watchIssue polls for changes to an issue and auto-refreshes the display (GH#654).
// Uses polling instead of fsnotify because Dolt stores data in a server-side
// database, not files — file watchers never fire.
func watchIssue(ctx context.Context, issueID string) error {
// database, not files — file watchers never fire. commentsTail is the
// --comments-tail render cap, threaded through to every render this loop
// does (initial and on each refresh); see printComments.
func watchIssue(ctx context.Context, issueID string, commentsTail int) error {
return runIssueWatch(ctx, issueWatchSource{
render: func(ctx context.Context) *types.Issue { return displayShowIssueReturn(ctx, issueID) },
render: func(ctx context.Context) *types.Issue { return displayShowIssueReturn(ctx, issueID, commentsTail) },
fetch: func(ctx context.Context) (*types.Issue, error) { return fetchIssue(ctx, issueID) },
})
}
@ -118,7 +140,8 @@ func fetchIssue(ctx context.Context, issueID string) (*types.Issue, error) {
// displayShowIssueReturn displays a single issue and returns it for snapshot use.
// Matches the full bd show output: header, metadata, content, labels, deps, comments.
func displayShowIssueReturn(ctx context.Context, issueID string) *types.Issue {
// commentsTail is the --comments-tail render cap; see printComments.
func displayShowIssueReturn(ctx context.Context, issueID string, commentsTail int) *types.Issue {
result, err := resolveAndGetIssueWithRouting(ctx, store, issueID)
if result != nil {
defer result.Close()
@ -185,18 +208,12 @@ func displayShowIssueReturn(ctx context.Context, issueID string) *types.Issue {
// Related (bidirectional, deduplicated)
printRelatedSection(relatedSeen)
// Comments
// Comments. watchCommentFormatTime hardcodes UTC — this path does not
// thread --local-time today (a pre-existing discrepancy from the
// non-watch render, left alone here; only the --comments-tail cap is
// wired through).
comments, _ := issueStore.GetIssueComments(ctx, issue.ID)
if len(comments) > 0 {
fmt.Printf("\n%s\n", ui.RenderBold("COMMENTS"))
for _, comment := range comments {
fmt.Printf(" %s %s\n", ui.RenderMuted(comment.CreatedAt.UTC().Format("2006-01-02 15:04")), comment.Author)
rendered := uimd.RenderMarkdown(comment.Text)
for _, line := range strings.Split(strings.TrimRight(rendered, "\n"), "\n") {
fmt.Printf(" %s\n", line)
}
}
}
renderWatchComments(comments, commentsTail, issue.ID)
fmt.Println()
return issue

View file

@ -314,6 +314,58 @@ func printEpicChildProgress(children []*types.IssueWithDependencyMetadata) {
fmt.Printf(" %s %d/%d complete (%d%%)%s\n", icon, closed, len(children), pct, eligible)
}
// validateCommentsTail rejects a negative --comments-tail value the same way
// on both show routes (direct and --proxied-server): a negative render cap
// has no meaning, so it is a usage error rather than a silently-clamped
// default, matching how resolveMaxRows (max_rows.go) rejects a negative
// --max-rows.
func validateCommentsTail(n int) error {
if n < 0 {
return HandleErrorRespectJSON("--comments-tail must be non-negative; got %d", n)
}
return nil
}
// printComments prints the COMMENTS section of bd show's text-mode output:
// the bold heading, then one block per comment (muted timestamp + author,
// rendered markdown body). Both show routes (direct and --proxied-server)
// call this so the render stays identical between them.
//
// tailN is the --comments-tail cap: <= 0 or >= len(comments) renders every
// comment with no elision line, byte-identical to the output before the flag
// existed (the flag's off state MUST be indistinguishable from its absence).
// A real cap — 0 < tailN < len(comments) — hides the older comments behind
// exactly one muted elision line naming how many were hidden (singular for
// one), then renders only the last tailN in their existing order and format.
// issueID feeds the elision line's "bd show <id>" pointer at the full
// record.
func printComments(comments []*types.Comment, tailN int, formatTime func(time.Time) string, issueID string) {
if len(comments) == 0 {
return
}
fmt.Printf("\n%s\n", ui.RenderBold("COMMENTS"))
start := 0
if tailN > 0 && tailN < len(comments) {
hidden := len(comments) - tailN
start = hidden
noun := "comments"
if hidden == 1 {
noun = "comment"
}
fmt.Printf(" %s\n", ui.RenderMuted(fmt.Sprintf("… %d older %s hidden — bd show %s for the full record", hidden, noun, issueID)))
}
for _, comment := range comments[start:] {
fmt.Printf(" %s %s\n", ui.RenderMuted(formatTime(comment.CreatedAt)), comment.Author)
rendered := uimd.RenderMarkdown(comment.Text)
// TrimRight removes trailing newlines that Glamour adds, preventing extra blank lines
for _, line := range strings.Split(strings.TrimRight(rendered, "\n"), "\n") {
fmt.Printf(" %s\n", line)
}
}
}
// formatSimpleDependencyLine formats a dependency without metadata (fallback)
// Closed items get entire row muted - the work is done, no need for attention
func formatSimpleDependencyLine(prefix string, dep *types.Issue) string {

View file

@ -36,6 +36,7 @@ type showProxiedInput struct {
includeDepends bool
briefDeps bool
includeComments bool
commentsTail int
}
func gatherShowProxiedInput(cmd *cobra.Command, args []string) *showProxiedInput {
@ -52,6 +53,7 @@ func gatherShowProxiedInput(cmd *cobra.Command, args []string) *showProxiedInput
in.includeDepends, _ = cmd.Flags().GetBool("include-dependents")
in.briefDeps, _ = cmd.Flags().GetBool("brief-deps")
in.includeComments, _ = cmd.Flags().GetBool("include-comments")
in.commentsTail, _ = cmd.Flags().GetInt("comments-tail")
idFlags, _ := cmd.Flags().GetStringArray("id")
in.ids = append(in.ids, args...)
@ -94,6 +96,10 @@ func proxiedIssueReader() (issueops.Reader, error) {
func runShowProxiedServer(cmd *cobra.Command, ctx context.Context, args []string) error {
in := gatherShowProxiedInput(cmd, args)
if err := validateCommentsTail(in.commentsTail); err != nil {
return err
}
uw, err := proxiedOpenReadUOW(ctx)
if err != nil {
return err
@ -607,16 +613,7 @@ func proxiedRenderIssue(ctx context.Context, uw uow.UnitOfWork, issue *types.Iss
printRelatedSection(relatedSeen)
comments, _ := proxiedGetComments(ctx, uw, issue.ID, isWisp)
if len(comments) > 0 {
fmt.Printf("\n%s\n", ui.RenderBold("COMMENTS"))
for _, c := range comments {
fmt.Printf(" %s %s\n", ui.RenderMuted(formatTime(c.CreatedAt)), c.Author)
rendered := uimd.RenderMarkdown(c.Text)
for _, line := range strings.Split(strings.TrimRight(rendered, "\n"), "\n") {
fmt.Printf(" %s\n", line)
}
}
}
printComments(comments, in.commentsTail, formatTime, issue.ID)
if in.longMode {
fmt.Print(formatIssueLongExtras(issue, formatTime))