Skip to content

feat(sessions): add shareable spend card (agentdiff --card) - #66

Closed
lostmartian wants to merge 2 commits into
mainfrom
feat/share-card
Closed

lostmartian wants to merge 2 commits into
mainfrom
feat/share-card

Conversation

@lostmartian

Copy link
Copy Markdown
Collaborator

What

agentdiff --card creates an image of your spend that you can post:

  • Output: writes agentdiff-card.html (change with --card-out) and opens it in the browser (--no-open to skip).
  • Sizes: landscape 1200×675 for X and LinkedIn, or portrait 1080×1350 for the LinkedIn feed, both exported at 2x.
  • Options: dark or light theme, and Hide $ to show percentages only.
  • Export: Download PNG and Copy image buttons.
  • Report footer: the terminal report now ends with Share it: agentdiff --card ….

Why

This is roadmap P1.3, built-in reach. The launch depends on people posting their own numbers, and an image is what gets shared on LinkedIn and X.

How

  • sessions/card.py:
    • card_data() builds aggregate-only data: total, avoidable, a four-way breakdown, the top three leak categories, session and project counts, and the period;
    • build_card_html() embeds that data as JSON, escaping </ so it can't close the script tag. A test covers this.
  • The page draws the card on a <canvas>, using Manrope and JetBrains Mono from Google Fonts with system-font fallbacks. It redraws once the fonts load and exports with canvas.toBlob.
  • No new Python dependencies: no Pillow and no bundled fonts. Brand assets for launch posts stay in the separate marketing repo.
  • Privacy: the card never includes session titles, project names, file paths or commands. A test plants identifiable strings in a session and asserts none of them reach the HTML.

Testing

make lint                  -> All checks passed
uv run python -m pytest    -> 466 passed (5 new in tests/test_card.py)

Rendered from my real logs in a browser:

  • landscape, portrait, Hide $ and light theme all render without overlaps;
  • the landscape export is a 2400×1350 PNG of about 240 KB;
  • the brand fonts load;
  • no console errors;
  • the generated HTML contains none of my session or project names.

Checklist

  • Exactly one logical change in this PR
  • make lint passes
  • uv run python -m pytest is green
  • Docs updated if user-facing
  • CHANGELOG.md entry added under [Unreleased] (if feat/fix)
  • Conventional title: type(scope): summary

Write a self-contained HTML page that draws the user's spend on a canvas
in the brand fonts and exports a PNG sized for X and LinkedIn (landscape
or portrait, light/dark, optional hidden dollar amounts). The card holds
only aggregate numbers and finding categories. No new dependencies.
@lostmartian

Copy link
Copy Markdown
Collaborator Author

Closing: the shareable card isn't going into the product. Marketing assets live outside this repo.

@lostmartian
lostmartian deleted the feat/share-card branch October 19, 2026 02:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant