Skip to content

Fix/Paste large text silently converted to @file#2172

Closed
idling11 wants to merge 2 commits into
Hmbown:mainfrom
idling11:fix/paste-large-text-hang
Closed

Fix/Paste large text silently converted to @file#2172
idling11 wants to merge 2 commits into
Hmbown:mainfrom
idling11:fix/paste-large-text-hang

Conversation

@idling11
Copy link
Copy Markdown
Contributor

@idling11 idling11 commented May 26, 2026

Summary

Defer paste consolidation to submit time so pasted text remains
visible and editable in the composer.

Closes: #2159

Problem

insert_paste_text called consolidate_large_input_if_oversized
immediately after paste, silently replacing the composer content
with an @.deepseek/pastes/... file reference. Users pasting
large text saw their content disappear with no chance to preview
or edit it.

Fix

Remove the paste-time consolidation call. The submit path (Enter)
still enforces the same safety cap, so oversized input is still
protected — but now the user sees their full text until they
choose to submit.

Also keep the "Consolidating large paste to file…" status message
in consolidate_large_input so the submit-time consolidation is
visible.

Files Changed

File Change
crates/tui/src/tui/app.rs Remove paste-time consolidate + update test

Test

Updated paste_consolidates_oversized_text_into_paste_file_visibly
paste_oversized_text_is_preserved_in_composer_not_consolidated.
All 27 paste-related tests pass.

Greptile Summary

This PR defers large-paste consolidation from paste time to submit time, so pasted text stays visible and editable in the composer rather than being silently replaced with an @file mention. A status message is now emitted inside consolidate_large_input to make the submit-time swap visible to users.

  • insert_paste_text no longer calls consolidate_large_input_if_oversized; the submit path in submit_input retains the safety-net call, so oversized input is still capped before being sent.
  • The test paste_consolidates_oversized_text_into_paste_file_visibly is replaced by paste_oversized_text_is_preserved_in_composer_not_consolidated, correctly asserting the new behaviour; two inline comments that described the old dual-path flow were not updated and now describe behaviour that no longer exists.

Confidence Score: 4/5

Safe to merge — the submit-time safety net remains intact and the test suite was updated to match the new paste behaviour.

The logic change is straightforward and well-tested. Two inline comments that described the old dual-path consolidation flow were not updated, leaving inaccurate descriptions of how insert_paste_text and consolidate_large_input_if_oversized interact — worth fixing before this becomes a maintenance trap, but not a correctness issue.

The stale comments in submit_input (around the consolidate_large_input_if_oversized call) and the doc comment on consolidate_large_input_if_oversized itself both describe the removed paste-time path and should be updated.

Important Files Changed

Filename Overview
crates/tui/src/tui/app.rs Removes paste-time consolidation from insert_paste_text and adds a status message to consolidate_large_input; two inline comments that described the old dual-path behaviour were not updated and now mislead readers.

Sequence Diagram

sequenceDiagram
    participant User
    participant insert_paste_text
    participant submit_input
    participant consolidate_large_input

    Note over User,consolidate_large_input: Before this PR (old behaviour)
    User->>insert_paste_text: paste large text
    insert_paste_text->>consolidate_large_input: consolidate_large_input_if_oversized()
    consolidate_large_input-->>insert_paste_text: "composer replaced with @mention"
    insert_paste_text-->>User: "sees @mention (content gone)"

    Note over User,consolidate_large_input: After this PR (new behaviour)
    User->>insert_paste_text: paste large text
    insert_paste_text-->>User: full text visible in composer (no consolidation)
    User->>submit_input: press Enter
    submit_input->>consolidate_large_input: consolidate_large_input_if_oversized()
    consolidate_large_input-->>submit_input: "status_message set, input replaced with @mention"
    submit_input-->>User: "@mention submitted, composer cleared"
Loading

Comments Outside Diff (2)

  1. crates/tui/src/tui/app.rs, line 4093-4098 (link)

    P2 The comment on lines 4095-4097 still describes the old behaviour — bracketed pastes no longer pre-consolidate in insert_paste_text, so "Bracketed pastes hit the consolidation in insert_paste_text first" is now factually wrong and will mislead future readers.

    Fix in Codex Fix in Claude Code Fix in Cursor

  2. crates/tui/src/tui/app.rs, line 4200-4205 (link)

    P2 The doc comment on consolidate_large_input_if_oversized still refers to "the paste-insert path (visible-before-submit)" routing through it. That path was removed by this PR, so the "enforced exactly once even when both paths fire" rationale no longer applies and will confuse future readers.

    Fix in Codex Fix in Claude Code Fix in Cursor

Fix All in Codex Fix All in Claude Code Fix All in Cursor

Reviews (1): Last reviewed commit: "fix: defer paste consolidation to submit..." | Re-trigger Greptile

Copy link
Copy Markdown
Contributor

@gemini-code-assist gemini-code-assist Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request defers the consolidation of large pasted text to submit time instead of doing it immediately upon pasting, allowing users to view and edit the pasted content in the composer. A review comment points out that setting a status message synchronously during consolidation is redundant and blocks the UI thread, potentially causing duplicate toast notifications.

Comment thread crates/tui/src/tui/app.rs
Comment on lines +4217 to +4219
self.status_message = Some("Consolidating large paste to file…".to_string());
self.needs_redraw = true;

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

Issue: Redundant Status Message & Synchronous UI Blocking

  1. UI Thread Blocking: consolidate_large_input runs synchronously on the main UI thread. Because the event loop is blocked during the execution of this function (specifically during the synchronous std::fs::write call), the TUI cannot perform a redraw to display the "Consolidating large paste to file…" status message while the consolidation is actually in progress.
  2. Duplicate/Redundant Toasts: Once the function finishes and the event handler returns, the UI finally redraws. At this point, both the "Consolidating..." status message (which gets synced to toasts via sync_status_message_to_toasts) and the "Large paste consolidated — sent as @mention" toast (pushed at the end of the function) will be displayed simultaneously. This results in redundant and confusing toast notifications for the user.

Recommendation

Remove the redundant self.status_message assignment. The final toast "Large paste consolidated — sent as @mention" is sufficient to inform the user of the completed action.

@Hmbown
Copy link
Copy Markdown
Owner

Hmbown commented May 26, 2026

Merged manually — paste consolidation deferral landed on main. Thanks @idling11!

@Hmbown Hmbown closed this May 26, 2026
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.

BUG: Paste teks besar dikonversi otomatis ke @file syntax lalu hang

2 participants