Skip to content

feat: markdown copy buttons next to every table#47

Open
jakduch wants to merge 1 commit into
josepe98:mainfrom
jakduch:feat/markdown-copy-buttons
Open

feat: markdown copy buttons next to every table#47
jakduch wants to merge 1 commit into
josepe98:mainfrom
jakduch:feat/markdown-copy-buttons

Conversation

@jakduch
Copy link
Copy Markdown
Collaborator

@jakduch jakduch commented May 23, 2026

What does this add and why do you believe it belongs in this dashboard?

Adds a small clipboard-icon "MD" button next to every data table (Cost by Model, Recent Sessions, Cost by Project, Cost by Project & Branch). One click copies the table's currently filtered and sorted rows to the clipboard as a GitHub-flavoured markdown table, ready to paste into an issue, PR description, Slack message, or a chat with Claude itself.

This belongs in a personal Claude Code usage dashboard because the most common thing you actually do with these numbers is share them: "hey, look how much I spent on opus this week," filing a bug with a session breakdown, or pasting a project cost table into a standup note. Today that workflow is screenshot-or-retype; CSV export exists but is the wrong format for chat surfaces. A markdown copy button is the missing third option — fast enough to use mid-conversation and faithful to what's currently on screen.

Implementation is self-contained: pure DOM and clipboard JS, pipe-escaped cells, async clipboard with an execCommand fallback, and a small toast for feedback. No new dependencies.

Checklist

Code correctness

  • All calcCost() calls pass 6 arguments: (model, inp, out, cache_read, cache_creation, cache_1h)
  • JavaScript template literals use bare backticks (`), not escaped ones (\`)
  • No JS variables referenced before they are defined
  • No new third-party dependencies introduced

Tests

  • python3 -m unittest discover -s tests -v — all passing
  • python3 -m unittest tests.test_browser -v — all passing
  • New behaviour is covered by at least one test

Scope

  • This is a single concern — one feature or fix per PR
  • Only touches existing files (dashboard.py, scanner.py, cli.py, pricing.py, cowork.py, tests/) — or I've explained below why a new file is needed

@josepe98 josepe98 closed this May 25, 2026
@josepe98 josepe98 reopened this May 25, 2026
@josepe98 josepe98 closed this May 25, 2026
@josepe98 josepe98 reopened this May 25, 2026
@josepe98 josepe98 closed this May 25, 2026
@josepe98 josepe98 reopened this May 25, 2026
@josepe98 josepe98 closed this May 25, 2026
@josepe98 josepe98 reopened this May 25, 2026
@jakduch jakduch force-pushed the feat/markdown-copy-buttons branch 3 times, most recently from 1334e37 to 4c1f2e3 Compare May 26, 2026 20:59
Add a small clipboard 'MD' button to each table section header (Cost
by Model, Recent Sessions, Cost by Project, Cost by Project & Branch).
Clicking it copies the table's current data as a GitHub-flavored
markdown table to the clipboard, ready to paste into Slack, email,
or a PR description.

- Generic JS helper _tableToMarkdown(tableId, headers, rowsData) that
  builds the canonical | col | col |\n|---|---|\n| ... | shape, with
  _mdEscape() to safely handle embedded pipes and newlines.
- Primary copy path uses navigator.clipboard.writeText; falls back to
  a hidden textarea + execCommand('copy') for older browsers.
- Bottom-center toast 'Copied as markdown!' for 2s after click.
- New tests/test_md_copy.py covers the helper shape, per-table
  buttons, fallback path, and toast CSS+behavior (15 tests).

Total 205 tests pass.
@jakduch jakduch force-pushed the feat/markdown-copy-buttons branch from 4c1f2e3 to c8b2120 Compare May 27, 2026 06:48
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.

2 participants