codex icon indicating copy to clipboard operation
codex copied to clipboard

fix: prevent hang when pasting special files (issue #7683)

Open Bronx83 opened this issue 1 week ago • 6 comments

This PR fixes a bug where the application would hang if a user pasted a path to a special file (like /dev/tty0 or a named pipe) into the chat composer.

The issue was caused by image::image_dimensions attempting to read from these special files, which can block indefinitely.

Fixes #7683

Changes

  • Added safe_image_dimensions helper in tui/src/clipboard_paste.rs
    • This function checks std::fs::metadata to ensure the path is a regular file (or symlink to one) before calling image::image_dimensions.
  • Updated ChatComposer (tui/src/bottom_pane/chat_composer.rs) to use safe_image_dimensions in:
    • handle_paste_image_path: When handling pasted text.
    • handle_key_event_with_file_popup: When selecting a file from the search popup.

Verification

  • Reproduction Test: Created a local reproduction test using a named pipe (FIFO).
    • Confirmed that calling image::image_dimensions directly on the FIFO causes a hang (timeout).
    • Confirmed that using the new safe_image_dimensions check returns None immediately, preventing the hang.
  • Manual Testing: Verified that pasting normal image paths still works as expected.

Bronx83 avatar Dec 11 '25 11:12 Bronx83

All contributors have signed the CLA ✍️ ✅
Posted by the CLA Assistant Lite bot.

github-actions[bot] avatar Dec 11 '25 11:12 github-actions[bot]

I have read the CLA Document and I hereby sign the CLA

Bronx83 avatar Dec 11 '25 12:12 Bronx83

recheck

Bronx83 avatar Dec 11 '25 12:12 Bronx83

@codex review

Bronx83 avatar Dec 11 '25 13:12 Bronx83

Codex Review: Didn't find any major issues. Swish!

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

@Bronx83, can you provide more details about how to repro the problem? We'd like to verify both the problem and the fix, but we've been unable to repro.

etraut-openai avatar Dec 15 '25 23:12 etraut-openai