Skip to content

Add "Copy as Markdown" button to support ticket message - #462

Merged
simonhamp merged 1 commit into
mainfrom
copy-ticket-as-markdown
Aug 5, 2026
Merged

simonhamp merged 1 commit into
mainfrom
copy-ticket-as-markdown

Conversation

@simonhamp

Copy link
Copy Markdown
Member

What

Adds a Copy as Markdown button beside the Message label on the admin support ticket view (SupportTicketResource → Context section).

Clicking it copies the ticket's initial message to the clipboard as Markdown, converting any ASCII tables it contains into real Markdown tables.

Why

Support tickets submitted for Mobile/Desktop are auto-composed as Markdown, and the Environment: section usually contains an ASCII table pasted from native:doctor:

+--------------------+---------+
| Package Version    | 3.3.3   |
| PHP Version (Host) | 8.4.16  |
+--------------------+---------+

Copying that straight out of the admin panel gives you either rendered HTML or an ASCII blob. This gives one click to get something that renders properly when pasted into a GitHub issue or handed to an LLM.

How

  • New SupportTicketResource::ticketMessageAsMarkdown() does the conversion. The rest of the message passes through untouched, since it's already Markdown.
  • The existing ASCII-table walker was generalised into convertAsciiTables($message, $renderTable), with row parsing extracted to parseAsciiTable(), so the HTML and Markdown renderers share one parser. HTML output is byte-identical — the existing rendering tests pass unchanged.
  • Tables with a +---+ separator after row 1 keep that row as the Markdown header. Key/value tables without one get an empty header row, since Markdown requires a delimiter row to be a table at all. Ragged rows are padded to the widest row.
  • The button is a Filament hintAction using actionJs(), so the copy is entirely client-side — no round-trip. Confirms with a $tooltip('Copied as Markdown'), mirroring Filament's own copy behaviour. Hidden when the message is empty.

Security

The message is embedded in the click handler via Js::from() — the same mechanism Filament's built-in copyable() uses. It hex-escapes quotes, angle brackets and ampersands, so user-submitted content can't break out of the attribute.

Notes

  • Like Filament's built-in copy feature, navigator.clipboard requires a secure context (HTTPS).
  • Scoped to the admin panel only. The customer-facing ticket page also shows the original message for non-mobile/desktop tickets; left alone, as this is aimed at triaging tickets out to an issue tracker.

Tests

7 new tests in tests/Feature/SupportTicketTest.php:

  • conversion: plain Markdown untouched, headerless table, header table, ragged rows, non-table + lines left alone
  • page: button renders with the correct clipboard payload; hidden when there's no message

php artisan test tests/Feature/SupportTicketTest.php → 95 passed (302 assertions). Pint clean.

🤖 Generated with Claude Code

Adds a hint action beside the Message label on the admin ticket view that
copies the initial message to the clipboard as Markdown, converting any
ASCII tables (native:doctor environment dumps) into Markdown tables so
they render when pasted into GitHub issues or an LLM.

The ASCII table walker is generalised so the HTML and Markdown renderers
share one parser; HTML output is unchanged.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
@simonhamp
simonhamp marked this pull request as ready for review August 5, 2026 08:49
@simonhamp
simonhamp merged commit 94c8c98 into main Aug 5, 2026
3 checks passed
@simonhamp
simonhamp deleted the copy-ticket-as-markdown branch August 5, 2026 08:49
SimonTingle pushed a commit to SimonTingle/nativephp.com that referenced this pull request Sep 19, 2026
Adds a hint action beside the Message label on the admin ticket view that
copies the initial message to the clipboard as Markdown, converting any
ASCII tables (native:doctor environment dumps) into Markdown tables so
they render when pasted into GitHub issues or an LLM.

The ASCII table walker is generalised so the HTML and Markdown renderers
share one parser; HTML output is unchanged.

Co-authored-by: Claude Opus 5 (1M context) <noreply@anthropic.com>
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