Skip to content

feat(md-copy): per-message + whole-conversation markdown copy/export#6

Merged
phase3dev merged 15 commits into
mainfrom
md-copy-export
Jun 10, 2026
Merged

feat(md-copy): per-message + whole-conversation markdown copy/export#6
phase3dev merged 15 commits into
mainfrom
md-copy-export

Conversation

@phase3dev

Copy link
Copy Markdown
Owner

Summary

Adds a markdown copy/export feature as three deliverables in fixes/markdown-copy-export/:

  • cc-export.py - standalone CLI: reads a session .jsonl and renders Markdown (--format, --include-thinking / --include-tools, --open, -o).
  • webview-inject.{js,css} - per-message and whole-conversation "Copy" controls (Markdown / plain text) in the VS Code chat, with an embedded DOM->Markdown converter; keyed on [data-testid="assistant-message"] and a sanitizer that strips the rating widget + tool/thinking blocks; fails safe (controls simply do not appear if the markup moves).
  • add-md-copy.py - standalone patcher (sentinel-block append, marker-scoped --revert, composes with context-icon).

Plus tools/gen-embeds (single-source payload -> bash heredoc / node JSON / python base64 embeds, with a --check / --strict drift gate) and launcher integration: CC_PATCH_MD_COPY (default on) reconciles both index.js and index.css.

The copy UI ships on by default (CC_PATCH_MD_COPY=0 to opt out). Stacked on launcher-refactor (PR 1); the base retargets to main once PR 1 merges. Incorporates two rounds of Codex audit (6 pre-implementation findings + 2 post-implementation: delimiter-safe code fences, launcher header comments).

Test plan

  • python3 -m unittest discover -s tests (85 cases)
  • python3 tools/gen-embeds --check --strict (all three consumers in sync)
  • bash -n / ShellCheck / node --check / py_compile
  • Live sandbox: patch/revert byte-exact on the installed 2.1.170 bundle + selector guard
  • CI green on this PR

🤖 Generated with Claude Code

phase3dev and others added 15 commits June 10, 2026 01:55
…t/open)

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
block() dispatches on each child's tag, so passing a bare <pre>/<ul>/<table>
as root flattened it (its own tag never handled). Wrap root in a one-off
container so its own tag is dispatched too; behavior is unchanged when root is
the bubble container (the production path). Found while reaching GREEN on the
converter tests, which pass single block elements as root.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Inline code used single backticks and fenced blocks always used three, so
copied/exported content that itself contained a backtick run closed the fence
early and produced structurally-broken Markdown. Both the webview converter
(htmlToMarkdown) and the CLI exporter (_fence) now choose a delimiter one longer
than the longest backtick run in the content (>=3 for fences), and inline code
gets CommonMark space-padding when an edge is a backtick. Regenerated the three
embeds from the updated source. Adds converter + exporter tests for backtick
content (Codex audit, Medium).

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Both launchers still said they combine "TWO" fixes and the toggle guidance
omitted CC_PATCH_MD_COPY, so "thinking only" guidance would still leave the
md-copy webview patch enabled. Document the third fix and CC_PATCH_MD_COPY in the
headers and toggle lists. Comments only; the embed region is untouched (Codex
audit, Low).

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@phase3dev phase3dev changed the base branch from launcher-refactor to main June 10, 2026 11:59
@phase3dev phase3dev merged commit 6e076f3 into main Jun 10, 2026
1 check passed
@phase3dev phase3dev deleted the md-copy-export branch June 10, 2026 12:00

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

Copy link
Copy Markdown

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: e71e702c03

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

* Additive and read-only w.r.t. app state; keyed on stable CSS-module class
* prefixes, so it fails safe (controls simply do not appear) if a prefix moves.
* Exposes its pure functions for node unit tests; boot()s only in a real webview. */
(function () {

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Prefix the appended IIFE with a semicolon

When this payload is appended to webview/index.js, it starts with an IIFE token ( after only comments/newlines. If the upstream bundle happens to end with an expression statement without a trailing semicolon (for example console.log(1) or a minified call expression), JavaScript parses the appended IIFE as a continuation call like previousExpression(function(){...})(), which can throw before the webview app initializes. Add a leading semicolon to the injected payload (or append one before the sentinel) so the patch is safe regardless of the bundle's final token.

Useful? React with 👍 / 👎.

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