t3code icon indicating copy to clipboard operation
t3code copied to clipboard

[Bug]: Triple-clicking the last line of a code block copies Markdown fences

Open jinrehacek opened this issue 3 months ago • 4 comments

Before submitting

  • [x] I searched existing issues and did not find a duplicate.
  • [x] I included enough detail to reproduce or investigate the problem.

Area

apps/desktop

Steps to reproduce

  1. Open a conversation containing a fenced code block with two or more lines:
    cd ~/dotfiles
    sudo dnf remove niri xwayland-satellite alacritty
    
  2. Triple-click the final line to select it.
  3. Press Ctrl+C.
  4. Paste into a terminal or plain-text editor.

The same problem occurs when triple-clicking the only line in a single-line code block (as it's also the last line). For comparison, triple-clicking a non-final line copies plain text correctly.

Expected behavior

Only the selected command is copied:

sudo dnf remove niri xwayland-satellite alacritty

Actual behavior

The selected command is wrapped in a Markdown fence and language identifier, thus clipboard stores this:

```bash
sudo dnf remove niri xwayland-satellite alacritty
```

Impact

Minor bug or occasional failure

Version or commit

0.0.34-nightly.20260823.1170

Environment

Fedora, Sway WM, Desktop app via AppImage (it happens in web too tho)

Logs or stack traces


Screenshots, recordings, or supporting files

No response

Workaround

Drag-select the command without including the final line boundary, or use the code block's Copy button.

Related issue

This appears to be a remaining edge case of #4741, which was closed by #5069. The fix works for ordinary partial selections, but triple-clicking the final line still reproduces the original fenced-copy behavior on a nightly containing that fix.

Investigation

chatMarkdownClipboardPayload copies plain text when the selection's common ancestor is inside <pre>.

Triple-clicking the final line appears to include the code block's trailing boundary. A minimized DOM Range with that shape has the outer Markdown container as its common ancestor. cloneContents() then produces a partial wrapper containing <pre>, which the Markdown serializer converts back into a fenced block.

This also explains the observed difference:

  • Triple-clicking a middle line keeps the range inside <pre> and copies plain text.
  • Triple-clicking the final or only line crosses the trailing boundary and copies fenced Markdown.

jinrehacek avatar Aug 23 '26 23:08 jinrehacek

+1 this also has issues with using Ctrl+C on the last line of a fenced code block.

minipuft avatar Aug 28 '26 02:08 minipuft

Same I’ve been using t3-code for a long time, and this issue has been bothering me the entire time. @t3dotgg

ilsl1007 avatar Sep 01 '26 03:09 ilsl1007

[!NOTE] 🤖 GPT-6 Astra (preview) responding on behalf of Theo

This was closed as part of an automated cleanup pass. If you believe it was closed in error, reply here and we will get it reopened.

Closing as fixed on main by #8448. A selected code block now copies as plain text even when the selection crosses its final newline. This covers the last-line and single-line boundary case described here. Use a build containing that fix.

t3dotgg avatar Sep 04 '26 02:09 t3dotgg

Could you reopen this? The last-line / single-line fenced-copy behavior is still happening for me on Windows in 0.0.46-nightly.20261011.2980.

I checked the running Windows desktop application's installed package version and its active WSL server. Both report that exact version. The latest published nightly at the time of this comment is 0.0.46-nightly.20261012.3021, so my installed build is about one day behind. GitHub's commit comparison confirms that my release includes the merge commit for #8448. I have not tested the October 12 nightly.

My selection method is double-clicking to select the whole command line, then copying it. The original report describes triple-clicking. Click-and-drag selection does not trigger the problem for me.

The affected chat response has a two-line Bash block:

cd /path/to/workspace
bash evidence/windows-desktop-build/build-windows.sh

Copying the first cd line produces plain text. Copying the second, final line produces this literal clipboard text:

```bash
bash evidence/windows-desktop-build/build-windows.sh
```

The same happens with the only line in a PowerShell block:

```powershell
& "$env:TEMP\t3code-pr12289-test\launch-test.cmd"
```

Expected: copying the selected command should produce the command alone, without backticks or a language label. The fences look useful when pasted back into T3 chat, but get in the way when pasted into an external terminal.

These are my observed clipboard results. The version and release ancestry were checked separately; there has not been an independent automated reproduction.

satyalyadav avatar Oct 12 '26 17:10 satyalyadav