Skip to content

fix: avoid tmux stdin path in paste_text (related to #118)#147

Merged
lsk567 merged 1 commit into
lsk567:mainfrom
zak-510:fix/paste-text-temp-file
Jun 8, 2026
Merged

fix: avoid tmux stdin path in paste_text (related to #118)#147
lsk567 merged 1 commit into
lsk567:mainfrom
zak-510:fix/paste-text-temp-file

Conversation

@zak-510

@zak-510 zak-510 commented Jun 8, 2026

Copy link
Copy Markdown
Contributor

The crash report in #118 shows repeated tmux 3.2a server segfaults while hosting omar. After looking, it showed load-buffer - (reading from piped stdin) in paste_text as a potential candidate trigger. This PR avoids that code path by writing the payload to a temp file and passing the file path to load-buffer instead, aligning paste_text with the existing temp-file approach already used in send_keys_literal for large payloads.

Also addresses the cleanup-on-error gap flagged by Copilot in #144: the temp file is now always deleted even if load-buffer fails.

This is a focused version of #144 with the mpsc::unbounded_channel change dropped per maintainer feedback.

Closes #144. Related to #118.

Copilot AI review requested due to automatic review settings June 8, 2026 01:22

Copilot AI left a comment

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.

Pull request overview

Note

Copilot was unable to run its full agentic suite in this review.

Updates tmux paste buffer loading to use a temporary file rather than piping text via stdin to tmux load-buffer.

Changes:

  • Write paste contents to a temp file and call tmux load-buffer with the file path
  • Add best-effort cleanup of the temp file after running load-buffer
  • Introduce UTF-8 validation for temp file paths before passing them to tmux

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread src/tmux/client.rs
Comment on lines +378 to +380
let tmp_path =
std::env::temp_dir().join(format!("omar-paste-{}.txt", uuid::Uuid::new_v4()));
std::fs::write(&tmp_path, text).context("Failed to write paste text to temp file")?;
Comment thread src/tmux/client.rs
Comment on lines +381 to +384
let path_str = tmp_path
.to_str()
.context("Temp file path is not valid UTF-8")?;
let load_result = self.run(&["load-buffer", "-b", &buffer_name, path_str]);
Comment thread src/tmux/client.rs
Comment on lines +380 to +386
std::fs::write(&tmp_path, text).context("Failed to write paste text to temp file")?;
let path_str = tmp_path
.to_str()
.context("Temp file path is not valid UTF-8")?;
let load_result = self.run(&["load-buffer", "-b", &buffer_name, path_str]);
std::fs::remove_file(&tmp_path).ok(); // best-effort cleanup
load_result?;
@zak-510

zak-510 commented Jun 8, 2026

Copy link
Copy Markdown
Contributor Author

The /tmp permissions and temp-file creation safety concerns raised here are tracked in #146, which proposes a helper for secure temporary file creation across all three call sites.

Cleanup on failure paths is also being considered via a RAII-based approach, but is intentionally out of scope for this PR.

@lsk567

lsk567 commented Jun 8, 2026

Copy link
Copy Markdown
Owner

LGTM. Thanks for working on this!

@lsk567 lsk567 merged commit 3f5671e into lsk567:main Jun 8, 2026
26 of 28 checks passed
@lsk567 lsk567 mentioned this pull request Jun 11, 2026
lsk567 added a commit that referenced this pull request Jun 11, 2026
Bump OMAR version from 0.3.1 to 0.3.2 for release.

Patch release — bug fixes and small enhancements since v0.3.1, no
breaking changes:

- fix: avoid tmux stdin path in paste_text (#147)
- fix(mcp): strip "(deleted)" from server exe path so spawned agents
  get OMAR tools (#139)
- fix: dashboard launch handoff (#137)
- fix: smart event input capture / popup deferral for agent
  suggestions (#143, #133, #138)
- fix(prompts): restore explicit agent cleanup duties lost in MCP
  migration (#132)
- feat: swap gemini backend for agy (#142)
- feat: add Codex reasoning effort to spawn_agent (#131)
- docs/test/CI: CLAUDE.md karpathy template (#145), star-history
  images (#136), opencode session-name test alignment (#134)

Co-authored-by: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
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.

3 participants