Skip to content

fix(tui): relax paste summary thresholds for short pastes#4

Merged
CreatorGhost merged 2 commits into
devfrom
paste-summary-thresholds
Jul 11, 2026
Merged

fix(tui): relax paste summary thresholds for short pastes#4
CreatorGhost merged 2 commits into
devfrom
paste-summary-thresholds

Conversation

@CreatorGhost

@CreatorGhost CreatorGhost commented Jul 11, 2026

Copy link
Copy Markdown
Owner

Problem

The TUI collapsed any paste with >=3 lines OR >150 characters into a [Pasted ~N lines] placeholder. Dictated speech-to-text input (a sentence or two, often 150+ chars) was compacted immediately, making it impossible to review or edit the transcription inline.

Fix

  • New shouldSummarizePaste() in packages/tui/src/prompt/part.ts with dictation-friendly limits: summarize only when >10 lines or >1000 characters (~150-180 words).
  • OR logic retained so single-line huge blobs (minified JSON, long log lines) still collapse.
  • app.toggle.paste_summary command and experimental.disable_paste_summary config are unchanged.

Tests

  • New unit tests covering short pastes, dictation-sized paragraphs, exact boundary values, and large dumps.
  • bun test test/prompt/part.test.ts: 5 pass. bun typecheck: clean (both from packages/tui).

Summary by CodeRabbit

  • New Features
    • Improved pasted-text handling by automatically summarizing content that exceeds defined size or line limits.
    • Keeps shorter pastes inline for easier editing and review.
  • Bug Fixes
    • Improved consistency in deciding when pasted content should be replaced with a compact summary placeholder.
  • Tests
    • Added coverage for short, boundary-sized, long single-line, multiline, and large repeated-text pastes.

@coderabbitai

coderabbitai Bot commented Jul 11, 2026

Copy link
Copy Markdown

Review Change Stack

Warning

Review limit reached

@CreatorGhost, you've reached your PR review limit, so we couldn't start this review.

Next review available in: 49 minutes

Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available.
You're only billed for reviews past your plan's rate limits ($0.25/file).

How can I continue?

After more reviews become available, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews.

How do review limits work?

CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability.

For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window.

Please refer docs for additional details.

Review details
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 3cb7b76b-9d44-4246-8564-1df814dd5e37

📥 Commits

Reviewing files that changed from the base of the PR and between 2083003 and be2bf8e.

📒 Files selected for processing (2)
  • packages/tui/src/component/prompt/index.tsx
  • packages/tui/src/prompt/part.ts
📝 Walkthrough

Walkthrough

Paste summarization now uses a shared line- and character-based heuristic. The paste handler delegates eligibility checks to this helper, and unit tests cover threshold boundaries and larger inputs.

Changes

Paste summarization

Layer / File(s) Summary
Paste sizing heuristic and coverage
packages/tui/src/prompt/part.ts, packages/tui/test/prompt/part.test.ts
Adds configurable line and character thresholds with tests for inline-sized and large pasted content.
Paste handler integration
packages/tui/src/component/prompt/index.tsx
Uses shouldSummarizePaste while preserving feature-flag gating and summary placeholder line counts.

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

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Description check ⚠️ Warning The description covers the problem, fix, and tests, but it omits required template sections like issue link, change type, screenshots, and checklist. Add the missing template sections: issue reference, type of change, screenshots/recordings if applicable, and the checklist items.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly summarizes the main change: relaxing paste summarization thresholds for short pastes.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch paste-summary-thresholds

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

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

@CreatorGhost

Copy link
Copy Markdown
Owner Author

@coderabbitai review

@coderabbitai

coderabbitai Bot commented Jul 11, 2026

Copy link
Copy Markdown
✅ Action performed

Review finished.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

@CreatorGhost

Copy link
Copy Markdown
Owner Author

@coderabbitai full review

@coderabbitai

coderabbitai Bot commented Jul 11, 2026

Copy link
Copy Markdown
✅ Action performed

Full review finished.

@coderabbitai coderabbitai 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.

🧹 Nitpick comments (1)
packages/tui/src/prompt/part.ts (1)

9-12: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

Extract a line-counting helper to avoid duplication.

The expression (text.match(/\n/g)?.length ?? 0) + 1 is duplicated in pasteInputText (index.tsx line 1205) to build the [Pasted ~N lines] placeholder. If the counting logic changes, the placeholder could display a different count than what was used for the summarization decision — undercutting the PR's goal of centralizing paste heuristics.

♻️ Proposed refactor

In part.ts:

+export function countPasteLines(text: string): number {
+  return (text.match(/\n/g)?.length ?? 0) + 1
+}
+
 export function shouldSummarizePaste(text: string) {
-  const lines = (text.match(/\n/g)?.length ?? 0) + 1
+  const lines = countPasteLines(text)
   return lines > PASTE_SUMMARY_LINE_LIMIT || text.length > PASTE_SUMMARY_CHAR_LIMIT
 }

In index.tsx:

-import { expandPastedTextPlaceholders, expandTrackedPastedText, shouldSummarizePaste } from "../../prompt/part"
+import { countPasteLines, expandPastedTextPlaceholders, expandTrackedPastedText, shouldSummarizePaste } from "../../prompt/part"
-      const lineCount = (pastedContent.match(/\n/g)?.length ?? 0) + 1
+      const lineCount = countPasteLines(pastedContent)
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@packages/tui/src/prompt/part.ts` around lines 9 - 12, Extract the
newline-based line-count calculation from shouldSummarizePaste into a reusable
helper in part.ts, then update both shouldSummarizePaste and pasteInputText to
call that helper when deciding summarization and constructing the “[Pasted ~N
lines]” placeholder. Remove the duplicated inline expression while preserving
the existing count behavior.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Nitpick comments:
In `@packages/tui/src/prompt/part.ts`:
- Around line 9-12: Extract the newline-based line-count calculation from
shouldSummarizePaste into a reusable helper in part.ts, then update both
shouldSummarizePaste and pasteInputText to call that helper when deciding
summarization and constructing the “[Pasted ~N lines]” placeholder. Remove the
duplicated inline expression while preserving the existing count behavior.

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 9cfcb9b3-0372-4508-94ed-6b5995012ead

📥 Commits

Reviewing files that changed from the base of the PR and between 4edde72 and 2083003.

📒 Files selected for processing (3)
  • packages/tui/src/component/prompt/index.tsx
  • packages/tui/src/prompt/part.ts
  • packages/tui/test/prompt/part.test.ts

@CreatorGhost

Copy link
Copy Markdown
Owner Author

@coderabbitai review

@coderabbitai

coderabbitai Bot commented Jul 11, 2026

Copy link
Copy Markdown
✅ Action performed

Review finished.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

@CreatorGhost
CreatorGhost merged commit 0086db6 into dev Jul 11, 2026
5 of 7 checks passed
@CreatorGhost
CreatorGhost deleted the paste-summary-thresholds branch July 11, 2026 19:07
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