Skip to content

Comment flags on all show commands + bug fixes#394

Merged
jeremy merged 13 commits intomainfrom
show-include-comments
Mar 30, 2026
Merged

Comment flags on all show commands + bug fixes#394
jeremy merged 13 commits intomainfrom
show-include-comments

Conversation

@jeremy
Copy link
Copy Markdown
Member

@jeremy jeremy commented Mar 28, 2026

Summary

Follow-up to #389 (merged). Fixes two bugs found in review, makes basecamp show always fetch comments (dropping the comments_count gate), and adds --comments / --no-comments / --all-comments to all commentable typed show commands.

  • Renderer fix: renderObject unconditionally skipped the comments key, causing data loss when comments was a non-array shape (string, int) via basecamp api get. Now only skips when topLevelComments returns non-nil.
  • Test fix: False-positive _attachments regression test asserted a key that was never filtered. Replaced with previewable_attachments which actually exercises the filter.
  • Three-flag model: --comments / --no-comments / --all-comments (mutually exclusive). defaultOn=true for show, false for typed commands (opt-in).
  • Always fetch: basecamp show no longer requires comments_count in the response. Non-commentable types (people, boosts) are gated.
  • Typed commands wired: todos, messages, cards, files, todolists, schedule, checkins (question + answer), forwards, chat line. Comments on comments excluded (flat model).

Test plan

  • bin/ci passes clean
  • basecamp show <any-commentable-id> fetches comments by default — 2 requests, comments key present, summary includes count
  • basecamp show <person-id> does NOT attempt comment fetch — 1 request, no comments key
  • basecamp todos show <id> --comments fetches comments — 2 requests, comments present
  • basecamp cards show <id> --all-comments fetches all comments — 2 requests
  • basecamp messages show <id> --no-comments suppresses comments — 1 request, no comments key
  • basecamp comments show <id> has no comment flags (flat model) — help shows no --comments/--no-comments/--all-comments

jeremy added 6 commits March 27, 2026 21:59
renderObject unconditionally skipped the "comments" key, then
topLevelComments tried to reconstruct it as []map[string]any.
When comments was a different shape (string, int, []string) —
as happens with `basecamp api get` — reconstruction returned nil
and data was silently dropped.

Only skip "comments" in the field loop when topLevelComments
returns non-nil. Both styled and markdown renderers.
TestStyledRenderObjectPreservesUnknownAttachmentFields asserted
custom_attachments_report survived — but that key doesn't end
with _attachments, so it passed under the old code too.
previewable_attachments was in the test data but never asserted.

Assert previewable_attachments values appear in output (both
styled and markdown). Remove the misleading assertion.
Three mutually exclusive flags: --comments / --no-comments /
--all-comments. addCommentFlags(cmd, defaultOn) controls whether
comments are fetched by default (show) or require opt-in (typed
show commands).

New fetchCommentsForRecording derives count from API response
metadata, not the parent's comments_count. fetchRecordingComments
becomes a thin wrapper that falls back to the parent's count when
Meta.TotalCount is unavailable.
Drop the comments_count gate — basecamp show now always attempts
comment fetching for commentable types. Skip the fetch for people
and boosts which don't support comments.

Update tests: expect the extra comments request, add
X-Total-Count header support to mock transport, rename
TestShowCommentsMissingField to TestShowSkipsCommentsForNonCommentableTypes.
Wire fetchCommentsForRecording into all commentable show commands:
todos, messages, cards, files, todolists, schedule (both paths),
checkins (question + answer), forwards, chat line.

defaultOn=false means typed commands require --comments or
--all-comments to opt in. Attachment notices are merged via
applyNotices. Comments on comments are excluded (flat model).
Regenerate CLI surface snapshot with new --comments,
--no-comments, --all-comments flags on typed show commands.
Acknowledge comments show flag removal in .surface-breaking.
Update skill with typed show command examples.
Copilot AI review requested due to automatic review settings March 28, 2026 05:02
@github-actions github-actions bot added commands CLI command implementations tests Tests (unit and e2e) skills Agent skills output Output formatting and presentation labels Mar 28, 2026
Copy link
Copy Markdown
Contributor

@cubic-dev-ai cubic-dev-ai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

2 issues found across 18 files

Prompt for AI agents (unresolved issues)

Check if these issues are valid — if so, understand the root cause of each and fix them. If appropriate, use sub-agents to investigate and fix each issue separately.


<file name=".surface">

<violation number="1" location=".surface:4062">
P2: `basecamp comments show` should not expose comment-fetch flags; comments-on-comments are excluded in the flat model.</violation>
</file>

<file name="internal/output/render.go">

<violation number="1" location="internal/output/render.go:777">
P2: Using `len(comments) > 0` to decide whether to hide the `comments` field fails for empty comment arrays, so `comments` leaks into detail output as a regular field.</violation>
</file>

Reply with feedback, questions, or to request a fix. Tag @cubic-dev-ai to re-run a review.

Copy link
Copy Markdown

@chatgpt-codex-connector chatgpt-codex-connector bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: dda6ad1b9b

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR extends the CLI’s “show” experience by standardizing comment-fetching behavior: basecamp show now fetches comments by default for commentable types, and typed … show commands gain a consistent --comments / --no-comments / --all-comments flag model. It also includes a renderer bug fix around top-level comments filtering and updates tests/docs/surface snapshots accordingly.

Tip

If you aren't ready for review, convert to a draft PR.
Click "Convert to draft" or run gh pr ready --undo.
Click "Ready for review" or run gh pr ready to reengage.

Changes:

  • Add a three-flag comment model (--comments / --no-comments / --all-comments) and wire it into multiple typed show commands.
  • Make basecamp show fetch comments by default (with type gating for non-commentable recordings).
  • Adjust object rendering/tests/docs and update .surface snapshots to reflect the new CLI surface.

Reviewed changes

Copilot reviewed 18 out of 18 changed files in this pull request and generated 8 comments.

Show a summary per file
File Description
skills/basecamp/SKILL.md Documents updated show/comment-flag behavior.
internal/output/render.go Adjusts when the raw comments field is skipped vs rendered.
internal/output/output_test.go Updates renderer regression coverage around attachment fields.
internal/commands/todos.go Wires comment enrichment + notice merging into todos show.
internal/commands/todolists.go Wires comment enrichment into todolists show.
internal/commands/show_test.go Updates show tests for “always fetch comments” and new count/headers behavior.
internal/commands/show.go Adds type gating for comment fetch and updates comment flag defaults for basecamp show.
internal/commands/schedule.go Wires comment enrichment into schedule show.
internal/commands/messages.go Wires comment enrichment + notice merging into messages show.
internal/commands/forwards.go Wires comment enrichment into forwards show.
internal/commands/files.go Wires comment enrichment + notice merging into files show.
internal/commands/comments_embed_test.go Updates tests for default-on vs opt-in comment flag behavior.
internal/commands/comments_embed.go Implements the three-flag model and splits typed-vs-map comment fetching helpers.
internal/commands/checkins.go Wires comment enrichment into checkins … show (question/answer).
internal/commands/chat.go Wires comment enrichment into chat line (and alias show).
internal/commands/cards.go Wires comment enrichment + notice merging into cards show.
.surface-breaking Records CLI-surface breaking changes related to newly added flags.
.surface Updates the CLI surface snapshot to include the new comment flags across commands.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

jeremy added 4 commits March 27, 2026 22:24
Use isCommentsArray to decide whether to suppress the raw
comments field, not len(comments) > 0. topLevelComments returns
nil for empty arrays (toMapSlice on []any{}), so empty comments
arrays were rendered as regular fields instead of being suppressed.

Rename attachment tests to reflect updated fixture focus.
Add comment/comments CLI aliases and Comment API type to
isCommentableShowType's non-commentable list. Comments are flat —
attempting to fetch comments-on-comments wastes a request and can
produce misleading diagnostics.
Register --comments/--no-comments/--all-comments on the parent
question and answer commands so both entry points (shortcut and
explicit show) accept the same flags.
Fresh surface snapshot reflects comment type exclusion and
checkins parent flag wiring. Remove the comments show flag
removal entries from .surface-breaking — the flags were never
in the regenerated baseline.
@github-actions github-actions bot added the bug Something isn't working label Mar 28, 2026
Copy link
Copy Markdown

@chatgpt-codex-connector chatgpt-codex-connector bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 3f6f5d1fca

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Copilot AI review requested due to automatic review settings March 30, 2026 17:51
@github-actions github-actions bot added enhancement New feature or request and removed bug Something isn't working labels Mar 30, 2026
jeremy added 2 commits March 30, 2026 10:56
Every typed show command repeated the same withComments / applyNotices /
breadcrumbs sequence. The new apply() method on commentEnrichment returns
enriched data and composed opts in one call. All 11 call sites now use it.

Includes tests for apply() (nil, populated, breadcrumb composition) and
isCommentableShowType (CLI aliases, generic lookups, API types).
The schema-driven presenter only renders fields declared in YAML schemas,
so comments injected via withComments were silently dropped in styled and
markdown output. Extract comments from NormalizeData(resp.Data) — never
from DisplayData — and append a comments section after the presenter body.

Includes tests for entity+comments rendering (plain entity and DisplayData
split path, both formats) and isCommentsArray coverage.
@jeremy jeremy force-pushed the show-include-comments branch from a221311 to 0e658c5 Compare March 30, 2026 17:56
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 19 out of 19 changed files in this pull request and generated 1 comment.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Copy link
Copy Markdown

@chatgpt-codex-connector chatgpt-codex-connector bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 0e658c58e3

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Rename TestShowNoCommentsWhenCountZero to TestShowFetchesCommentsEvenWhenCountZero
to match the actual assertion (comments ARE fetched even with count 0).

When Meta.TotalCount is missing from the API response but the parent's
comments_count indicates truncation occurred, recompute the truncation
notice so the user sees a warning and the --all-comments breadcrumb.
@jeremy jeremy merged commit f8def41 into main Mar 30, 2026
26 checks passed
@jeremy jeremy deleted the show-include-comments branch March 30, 2026 19:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

commands CLI command implementations enhancement New feature or request output Output formatting and presentation skills Agent skills tests Tests (unit and e2e)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants