Skip to content

fix: copy the whole code block from a folded commit preview - #1237

Merged
nunomaduro merged 1 commit into
productionfrom
fix/copy-full-code-in-folded-preview
Oct 27, 2026
Merged

nunomaduro merged 1 commit into
productionfrom
fix/copy-full-code-in-folded-preview

Conversation

@nunomaduro

@nunomaduro nunomaduro commented Oct 27, 2026 •

Copy link
Copy Markdown
Member

Closes #1161.

A long commit in a list shows a server-made excerpt with a "Show more" button. When the body starts with a code block, the excerpt keeps only that block's first lines, and the copy button copied what was rendered, so it copied only part of the code.

FoldedCommitBody now pairs each code block in the preview with the matching block in the full body (the preview is the start of the body, so they line up in order). CodeBlock copies that full block's text when it has one. What the preview shows doesn't change.

Verification: a scratch render test showed that a folded preview block now gets the full block's HTML and an unfolded body doesn't. tsc shows no errors in the changed files. Lint and format checks pass. I didn't click through it in a browser because the orb has no PHP or Postgres to run the app.

Summary by CodeRabbit

  • Bug Fixes
    • Copying code from a folded commit preview now captures the complete code block, rather than only the portion currently shown. Copy behavior for fully expanded code blocks remains unchanged.

@coderabbitai

coderabbitai Bot commented Oct 27, 2026 •

Copy link
Copy Markdown

Review in Change Stack →

Caution

Review failed

The pull request is closed.

Walkthrough

When a commit body is folded, preview code blocks now retain the corresponding full block HTML. CodeBlock uses that HTML as the copy source when provided, while preserving the existing rendered-content fallback.

Changes: Folded code copy

Layer / File(s) Summary
Full-block data and copy flow
resources/js/types/commit.ts, resources/js/components/commit-body.tsx, resources/js/components/code-block.tsx
Block segments add optional fullHtml. Folded previews assign each preview block the corresponding full-body block HTML, and CodeBlock uses it to extract copied text when present.

Priority: Not assessed

Estimated code review effort: 2 (Simple) | ~10 minutes

Change: Bug fix · Severity of issue fixed: Low

Possibly related PRs

Suggested reviewers: xheaven, mnapoli

Merge Risk: Minimal · up to 83faa

No actionable issue remains before merge; complete the normal checks.

Security architecture risk: Low · up to 83faa

The change affects copying from folded previews, not permissions or data access. Copying remains a user-triggered plain-text operation. No new security failure was established, although the complete conversion behavior was not verified in a running browser.

Retained concerns
No architecture-level concerns identified.

Security review details

Security Blast Radius

  • observed — The added copy source is the full block already supplied to the same folded-body component. Its text, including lines hidden by folding, reaches the viewer's clipboard only through the Copy button; this path does not execute the copied code.

Trust Boundaries and Controls

  • inferred — The new parsing step does not establish an executable-DOM attack path: fullHtml enters a detached template, whose inert contents are reduced to textContent before writeText. The live HTML-rendering path and its server-escaping dependency already existed, so they are not introduced concerns in this PR.

Resilience and Maintainability Implications

  • observed — Clipboard success, unsupported access, and rejected writes retain existing terminal handling: success sets copied feedback, failure clears it and shows an error, and the feedback timeout is cleared during effect cleanup. The change adds no retry, reservation, or persistent state transition.
Finishing Touches
📝 Generate docstrings
  • Commit to this branch
  • Create a new PR
🧪 Generate unit tests (beta)
  • Commit to this branch
  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Comment @coderabbitai help to get the list of available commands.

@nunomaduro
nunomaduro merged commit 3096b3c into production Oct 27, 2026
8 of 9 checks passed
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.

Copy Button Does Not Copy the Entire Code When a Post Is Collapsed

2 participants