Skip to content

docs: fix misplaced copy buttons by dropping terminal frames - #4090

Merged
max-sixty merged 3 commits into
mainfrom
copy
Sep 13, 2026
Merged

max-sixty merged 3 commits into
mainfrom
copy

Conversation

@max-sixty

@max-sixty max-sixty commented Sep 13, 2026 •

Copy link
Copy Markdown
Owner

On every shell code block the copy button sat 40px below the top of the code: on the second line of multi-line blocks, and hanging below one-line blocks such as wt merge --no-ff on /merge/. Shell blocks were Expressive Code terminal frames, and the terminal plugin deleted their title bar, but Expressive Code still offsets the copy button by that bar's height.

Changes

  • docs/astro.config.mjs sets defaultProps: { frame: 'code' }, so no block is a terminal frame and there is no title bar to remove. The plugin's header-removal hook and its props.frame = 'terminal' go, and so does the wt-commands-only class: mobile wrapping in custom.css now keys on whether a block contains captured output (:has(.wt-output)).
  • Blocks with several commands had a whole-block copy button and per-line buttons in the same corner, handed over on hover by opacity. A hidden button still takes clicks, so clicking a line's button could copy the whole block, and on touch screens one button covered another. Most of these blocks are lists of alternatives, so they now get only per-line buttons, and the hover rule is deleted.
  • Those blocks wrap (Expressive Code's wrap prop) unless they carry captured output, since a per-line button sits at the end of its line and scrolled out of view on the long jq examples on /list/. A per-line button is no taller than its line, so buttons on adjacent lines no longer overlap.
  • The two multi-command blocks that only work run in order, the FAQ's stash recipe and the Equivalent to: block under wt step diff's How it works (in src/cli/step.rs), are now bash fences, the form docs/CLAUDE.md prescribes for a copyable recipe, so they keep one copy button for the whole recipe. Terminal --help renders console and bash fences alike (it strips $ ), and the help snapshots are unchanged.

Side effect

Expressive Code strips comment lines only from what terminal frames copy. The eight bash and powershell blocks with comments on /shell-integration/ now copy them, as console blocks already did. Pasted into zsh without interactivecomments, each comment line prints command not found: #; the commands still run.

Tests

A browser test checks every copy button on every page, at 393px with touch and at 1376px, for three things: it sits on the line it copies, it is inside the visible code, and it doesn't overlap another button. These checks fail against worktrunk.dev and against a build without the wrap and the height cap. The built-site and plugin tests now expect per-line payloads and no block payload on multi-command blocks, and a plugin test pins that blocks carrying output never wrap.

This was written by Claude Code on behalf of max-sixty

🤖 Generated with Claude Code

https://claude.ai/code/session_013U96NY8qKtZhavBSwnfCYq

max-sixty and others added 2 commits September 12, 2026 21:53
Shell blocks were Expressive Code terminal frames whose title bar the
terminal plugin then deleted. Expressive Code still offsets the copy button
by that title bar's height, so on every shell block the button sat 40px
below the top of the code: on the second line of multi-line blocks, and
hanging below one-line blocks such as `wt merge --no-ff` on /merge/.

`defaultProps: { frame: 'code' }` stops requesting terminal frames, so
there is no title bar to remove and the button sits on the first line. The
header-removal hook goes, and so does the `wt-commands-only` class: mobile
wrapping now keys on whether a block contains captured output. Expressive
Code strips comment lines from what terminal frames copy, so the eight
`bash` and `powershell` blocks with comments on /shell-integration/ now copy
them, as console blocks already did.

Blocks with several commands had a whole-block copy button and per-line
buttons in the same corner, handed over on hover by opacity. A hidden
button still takes clicks, so clicking one line's button copied the whole
block, and on touch screens one button covered another. Most of those
blocks are lists of alternatives, so they now get only the per-line
buttons, and the hover hand-off rule is deleted. Those blocks wrap, since a
per-line button sits at the end of its line and scrolled out of view on the
/list/ jq examples. A per-line button is no taller than its line, so
buttons on adjacent lines no longer overlap.

A browser test checks, on every page at 393px with touch and at 1376px,
that each copy button sits on the line it copies, inside the visible code,
without overlapping another. Against worktrunk.dev, and against a build
without the wrap and the height cap, it fails.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_013U96NY8qKtZhavBSwnfCYq

@worktrunk-bot worktrunk-bot left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Two console blocks aren't menus of alternatives, and they lose a copy that was runnable as-is: the Equivalent to: recipe under How it works in wt step diff ($ cp "$(git rev-parse --git-dir)/index" /tmp/idx and the two GIT_INDEX_FILE=/tmp/idx lines that follow), and the stash recipe in the FAQ ($ git stash push -u / $ wt switch --create feature / $ git stash pop). Both only do anything run in order, so a reader now has to copy each line on its own. They're the only two of the site's 25 multi-command console blocks in that shape — the FAQ's plain-git comparison carries a # ...work, commit, push... placeholder mid-block, so its block copy was never runnable either — so the trade is right everywhere else and the open decision is just these two. docs/CLAUDE.md already names the form that would keep a block button for them: "Use bash for commands a reader can copy as a complete recipe." The FAQ one is a docs-only edit, but the step recipe lives in after_long_help in src/cli/step.rs, so dropping its $ prefixes also changes what wt step diff --help prints — worth deciding rather than assuming. I can push that commit if you want it.

Smaller, and latent rather than broken today: codeBlock.props.wrap = true keys on the command count alone, so a console block with several commands and captured output would get its output reflowed — the one thing custom.css deliberately protects, since :not(:has(.wt-output)) leaves output blocks scrolling instead of wrapping. No block on the site is that shape, so nothing renders wrong today; it's a constraint on future blocks that nothing currently records.

The FAQ's stash recipe and the `Equivalent to:` block under `wt step diff`
only work run in order, so they are `bash` fences, the form docs/CLAUDE.md
prescribes for a copyable recipe, and keep one copy button. Terminal help
renders both fence kinds alike, so `wt step diff --help` is unchanged.

A console block with several commands wraps only when it carries no
captured output, so output keeps its columns.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_013U96NY8qKtZhavBSwnfCYq
@max-sixty
max-sixty merged commit cff085e into main Sep 13, 2026
40 checks passed
@max-sixty
max-sixty deleted the copy branch September 13, 2026 17:00
@max-sixty max-sixty mentioned this pull request Sep 16, 2026
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