Skip to content

refactor(ui): unify clipboard line clipping - #860

Merged
benvinegar merged 1 commit into
mainfrom
refactor/simplify-copy-rendering
Aug 26, 2026
Merged

benvinegar merged 1 commit into
mainfrom
refactor/simplify-copy-rendering

Conversation

@benvinegar

Copy link
Copy Markdown
Member

Problem

renderCopySelectionText duplicated visual-row clipping, terminal-cell slicing, and first/last-column handling across decorated and code-only clipboard output. The paths differed in subtle but intentional ways, making future changes error-prone.

Approach

  • represent rendered clipboard rows as one CopyVisualLine shape with visual row, global origin, text, and empty-line policy;
  • route headers, decorated rows, and code-only rows through one inclusive terminal-cell clipper;
  • preserve split-pane origins, decorated blank lines, code-only blank omission, CJK/zero-width slicing, and terminal-control sanitization;
  • add wrapped partial-line, blank-line, split-right-origin, and multi-file header coverage.

This is a behavior-preserving maintenance refactor. renderCopySelectionText complexity drops from 56 to 29.

Validation

Tested on Linux:

  • bun test src/ui/components/panes/copySelection.test.ts — 51 passed;
  • full test suite passed both shards before rebasing onto current main;
  • bun run typecheck;
  • bun run lint;
  • bunx oxfmt --check src/ui/components/panes/copySelection.ts src/ui/components/panes/copySelection.test.ts;
  • git diff --check main...HEAD.

No visual evidence is included because clipboard text is covered directly and interaction/rendering behavior is unchanged.

This PR description was generated by Pi using OpenAI GPT-5.6 Sol

@vercel

vercel Bot commented Aug 26, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

1 Skipped Deployment
Project Deployment Actions Updated (UTC)
hunk-web Ignored Ignored Aug 26, 2026 1:25pm

Request Review

@greptile-apps

greptile-apps Bot commented Aug 26, 2026

Copy link
Copy Markdown
Contributor

Greptile Summary

This refactor represents clipboard output as uniformly clipped visual lines while preserving distinct empty-line policies for decorated and code-only output.

  • Adds shared terminal-cell clipping and global-origin resolution for headers and planned diff rows.
  • Expands tests for wrapped selections, blank lines, split-pane origins, and multi-file headers.
  • Adds an empty changeset entry for the maintenance-only change.

Confidence Score: 5/5

The PR appears safe to merge with no actionable correctness, security, or maintainability issues identified.

The unified clipper preserves normalized selection boundaries, terminal-cell slicing, pane-relative origins, header inclusion, and the intentional difference between decorated and code-only blank lines.

Important Files Changed

Filename Overview
src/ui/components/panes/copySelection.ts Consolidates header, decorated-row, and code-only clipping through a shared visual-line representation without an identified behavioral regression.
src/ui/components/panes/copySelection.test.ts Adds focused regression coverage for wrapped clipping, empty-line policy, split-right origins, and multi-file header boundaries.

Reviews (1): Last reviewed commit: "refactor(ui): simplify clipboard visual-..." | Re-trigger Greptile

@benvinegar
benvinegar merged commit 9fe390a into main Aug 26, 2026
13 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.

1 participant