Skip to content

Conversation

@marius-kilocode
Copy link
Collaborator

@marius-kilocode marius-kilocode commented Jan 9, 2026

Summary

  • Abbreviate large pasted text (10+ lines) as [Pasted text #N +X lines] to prevent input field overflow when pasting logs or large code blocks
  • Fix paste performance by skipping unnecessary clipboard image checks for bracketed pastes

Changes

  • Add processPastedText.ts utilities for handling pasted text references (extract, remove, expand)
  • Add pasted text reference atoms in keyboard.ts with handlePaste function
  • Expand references to full content in useMessageHandler.ts before sending messages
  • Optimize KeyboardProvider.tsx to skip osascript clipboard check for bracketed pastes
  • Permance is optimized, just takes a few ms for a very large text

How it works

  • Pastes with 10+ lines are stored and displayed as [Pasted text #1 +X lines]
  • References are expanded to full content when the message is submitted
  • Image pasting via Cmd+V still works (clipboard check only runs for explicit Cmd+V)
  • Regular terminal paste (bracketed paste mode) is now instant
image

@changeset-bot
Copy link

changeset-bot bot commented Jan 9, 2026

🦋 Changeset detected

Latest commit: 2a56107

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
@kilocode/cli Minor

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@marius-kilocode marius-kilocode requested a review from a team January 9, 2026 22:36
@kiloconnect
Copy link
Contributor

kiloconnect bot commented Jan 9, 2026

Code Review Summary

Status: No Issues Found | Recommendation: Merge

Overview

This PR implements a clean solution for abbreviating large pasted text in the CLI input. When users paste text with 10+ lines, it displays a compact reference like [Pasted text #1 +25 lines] instead of the full content, preventing input field overflow. The full text is stored and expanded when the message is sent.

Key Implementation Details:

  • New processPastedText.ts module with regex-based reference parsing
  • Jotai atoms for managing pasted text references (pastedTextReferencesAtom, pastedTextReferenceCounterAtom)
  • handlePaste function with efficient early-exit line counting
  • Integration with useMessageHandler to expand references before sending
  • Simplified KeyboardProvider by removing unused paste buffer atoms

Code Quality:

  • ✅ Comprehensive test coverage for all new functionality
  • ✅ Proper TypeScript types throughout
  • ✅ Clear separation of concerns
  • ✅ Good documentation comments
  • ✅ Follows existing codebase patterns
Files Reviewed (7 files)
  • .changeset/abbreviate-large-pasted-text.md - Changeset
  • cli/src/media/processPastedText.ts - New helper functions
  • cli/src/media/__tests__/processPastedText.test.ts - Tests for helpers
  • cli/src/state/atoms/keyboard.ts - Pasted text atoms and handlePaste
  • cli/src/state/atoms/__tests__/keyboard.test.ts - Paste abbreviation tests
  • cli/src/state/hooks/useMessageHandler.ts - Reference expansion
  • cli/src/ui/providers/KeyboardProvider.tsx - Simplified paste handling

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.

2 participants