Skip to content

Show file size for campfire upload lines#322

Merged
jeremy merged 4 commits intomainfrom
bc-9666170667
Mar 16, 2026
Merged

Show file size for campfire upload lines#322
jeremy merged 4 commits intomainfrom
bc-9666170667

Conversation

@jeremy
Copy link
Copy Markdown
Member

@jeremy jeremy commented Mar 16, 2026

Summary

  • Add display helpers that inject attachment file sizes (from CampfireLineAttachment.ByteSize) into campfire line output for styled/markdown rendering
  • Wire up WithDisplayData at three call sites: chat messages, chat line, and chat upload — JSON output stays untouched
  • Upload summary now prefers the API-returned filename and includes file size

Details

Attachment marker lines (📎 filename) produced by richtext.HTMLToMarkdown are matched line-by-line and annotated with (size). Plain text and empty content paths synthesize attachment info directly. ByteSize == 0 is treated as "API omitted the field" (no size parenthetical).

Test plan

  • Helper unit tests: HTML+attachments, plain text+attachments, empty content, title fallback, mid-line non-rewrite, zero byte size, duplicate filenames
  • Command-level tests: upload summary and styled output include 📎 filename (size)
  • Output-level tests: styled/markdown render display data correctly, JSON preserves original content
  • bin/ci passes (lint, vet, unit tests, e2e, surface snapshot, skill drift)

jeremy added 2 commits March 15, 2026 18:59
Add display helpers that inject attachment file sizes into campfire
line output. HTML content goes through HTMLToMarkdown then gets size
annotations on deterministic 📎 marker lines. Plain text and empty
content paths synthesize attachment info directly. ByteSize == 0 is
treated as omitted (no size parenthetical).

Wire up WithDisplayData at three call sites (messages, line show,
upload) so styled/markdown output shows sizes while JSON stays
untouched. Upload summary now prefers the API-returned filename
and includes file size.
Helper unit tests: HTML+attachments, plain text+attachments, empty
content+attachments, title fallback, plain-text-only, mid-line
non-rewrite, zero byte size, title fallback, duplicate filenames.

Command-level tests: upload summary includes file size, styled
output renders 📎 filename (size).

Output-level tests: styled and markdown rendering with display data,
JSON preserves original content.
@jeremy jeremy requested a review from a team as a code owner March 16, 2026 02:13
Copilot AI review requested due to automatic review settings March 16, 2026 02:13
@github-actions github-actions bot added commands CLI command implementations tests Tests (unit and e2e) output Output formatting and presentation enhancement New feature or request labels Mar 16, 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.

1 issue found across 3 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="internal/commands/chat_test.go">

<violation number="1" location="internal/commands/chat_test.go:989">
P2: Unchecked error from `os.WriteFile`. If the write fails, the test will produce a confusing failure downstream. Use `require.NoError` to surface the real cause.</violation>
</file>

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

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 enhances human-readable chat output by surfacing Campfire attachment file sizes (from CampfireLineAttachment.ByteSize) in styled/markdown output while keeping raw JSON output unchanged.

Changes:

  • Wire WithDisplayData(...) through chat messages, chat line, and chat upload so styled/markdown rendering can show attachment sizes without altering JSON data.
  • Add chat-line display helpers to render attachment-only lines more informatively and to inject sizes into rich-text→markdown attachment markers.
  • Add output/command tests covering the new display behavior and upload summaries.

Reviewed changes

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

File Description
internal/commands/chat.go Adds display-data plumbing + helpers to format chat line content with attachment sizes and to update upload summaries.
internal/commands/chat_test.go Adds unit tests for display-content helpers and command-level tests validating upload summary/styled output include sizes.
internal/output/output_test.go Adds rendering coverage confirming WithDisplayData affects styled/markdown but not JSON for chat_line.

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

jeremy added 2 commits March 15, 2026 19:30
NormalizeData returns []map[string]any (not []any) when all elements
are objects, so chatLinesDisplayData was silently skipping content
replacement. Assert the correct type.

Also wrap os.WriteFile in require.NoError in test helpers.
Use min(len(items), len(lines)) bounded loop instead of range+break
so gosec can verify the index is in bounds.
Copilot AI review requested due to automatic review settings March 16, 2026 04:07
@jeremy jeremy enabled auto-merge (squash) March 16, 2026 04:08
@jeremy jeremy merged commit 699bcf8 into main Mar 16, 2026
29 checks passed
@jeremy jeremy deleted the bc-9666170667 branch March 16, 2026 04:09
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

Adds “display data” helpers so chat line attachment markers can show file sizes in human-oriented outputs (styled/markdown) while keeping JSON output unchanged.

Changes:

  • Introduces chat-line display helpers that inject attachment sizes into rendered content.
  • Wires WithDisplayData into chat messages, chat line, and chat upload responses.
  • Enhances upload summary to prefer API-returned filename and include file size when available.

Reviewed changes

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

File Description
internal/output/output_test.go Adds output-level tests verifying DisplayData is used for styled/markdown and ignored for JSON.
internal/commands/chat_test.go Adds unit tests for display helper behavior and command-level upload output/summary assertions.
internal/commands/chat.go Implements display-content helpers, injects DisplayData into chat commands, and updates upload summary formatting.

💡 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: c6b8bc8d87

ℹ️ 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".

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 tests Tests (unit and e2e)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants