fix(tui): relax paste summary thresholds for short pastes#4
Conversation
|
Warning Review limit reached
Next review available in: 49 minutes Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available. How can I continue?After more reviews become available, a review can be triggered using the 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 configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (2)
📝 WalkthroughWalkthroughPaste 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. ChangesPaste summarization
Estimated code review effort: 2 (Simple) | ~10 minutes 🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✨ Finishing Touches🧪 Generate unit tests (beta)
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. Comment |
|
@coderabbitai review |
✅ Action performedReview finished.
|
|
@coderabbitai full review |
✅ Action performedFull review finished. |
There was a problem hiding this comment.
🧹 Nitpick comments (1)
packages/tui/src/prompt/part.ts (1)
9-12: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick winExtract a line-counting helper to avoid duplication.
The expression
(text.match(/\n/g)?.length ?? 0) + 1is duplicated inpasteInputText(index.tsxline 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
📒 Files selected for processing (3)
packages/tui/src/component/prompt/index.tsxpackages/tui/src/prompt/part.tspackages/tui/test/prompt/part.test.ts
|
@coderabbitai review |
✅ Action performedReview finished.
|
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
shouldSummarizePaste()inpackages/tui/src/prompt/part.tswith dictation-friendly limits: summarize only when >10 lines or >1000 characters (~150-180 words).app.toggle.paste_summarycommand andexperimental.disable_paste_summaryconfig are unchanged.Tests
bun test test/prompt/part.test.ts: 5 pass.bun typecheck: clean (both frompackages/tui).Summary by CodeRabbit