Hmbown/CodeWhale · warning
another terminal clipboard write is still queued
Error message
another terminal clipboard write is still queued
What it means
Terminal clipboard writes are serialized through a channel to a dedicated writer thread that owns the terminal. `enqueue` uses `try_send` (non-blocking); when the single-slot queue is already full — a previous write has not been drained yet — the new request is refused with this error rather than blocking the caller.
Solutions
- Retry the enqueue after a short delay (rate-limit clipboard writes)
- Wait for or track completion of the previous clipboard write before enqueueing
- Coalesce/dedupe clipboard writes so only the latest text is sent
Example fix
// before
clipboard.enqueue(text1);
clipboard.enqueue(text2); // may fail: queue full
// after
if clipboard.enqueue(text2).is_err() {
// drop or retry later; only the latest text matters
std::thread::sleep(std::time::Duration::from_millis(50));
let _ = clipboard.enqueue(text2);
} Defensive patterns
Strategy: retry
Try / catch
match clipboard.enqueue(text) {
Ok(()) => {}
Err(e) if e.to_string().contains("still queued") => {
// drop or retry after a short delay; the queued write still lands
}
Err(e) => return Err(e),
} Prevention
- Throttle clipboard writes; coalesce rapid copies to the latest text
- Check channel capacity before high-frequency enqueue loops
- Handle queue-full as an expected, non-fatal condition
When it happens
Trigger: Calling `enqueue` twice in quick succession before the writer thread consumed the first `TerminalClipboardWriteRequest`, so `try_send` returns `TrySendError::Full`.
Common situations: Copying multiple selections rapidly in the TUI; a slow or paused terminal (tmux, flow control) delays the writer; bulk copy operations issuing many clipboard writes back-to-back.
Related errors
- Clipboard unavailable
- OSC 52 clipboard fallback requires a terminal
- selection is too large for OSC 52 clipboard fallback
- terminal clipboard writer stopped
- accepted_requests must equal requests_attempted; sender…
AI-assisted analysis of Hmbown/CodeWhale@73e0f67d83 (2026-09-22).
Data as JSON: /api/errors/22f65da55f6aac11.
Report an issue: GitHub.
Appendix: source
Thrown at crates/tui/src/tui/clipboard.rs:288
break;
}
}
})
.context("spawn terminal clipboard writer")?;
Ok(Self {
request_tx,
completion_rx,
})
}
fn enqueue(&self, text: &str, in_tmux: bool) -> Result<()> {
let request = TerminalClipboardWriteRequest {
text: text.to_string(),
in_tmux,
};
self.request_tx.try_send(request).map_err(|err| match err {
std::sync::mpsc::TrySendError::Full(_) => {
anyhow::anyhow!("another terminal clipboard write is still queued")
}
std::sync::mpsc::TrySendError::Disconnected(_) => {
anyhow::anyhow!("terminal clipboard writer stopped")
}
})
}
fn poll_completion(&self) -> Option<TerminalClipboardWriteCompletion> {
self.completion_rx.try_recv().ok()
}
}
/// Clipboard reader/writer helper.
pub struct ClipboardHandler {
terminal_context: TerminalClipboardContext,
terminal_writer: Option<TerminalClipboardWriter>,
#[cfg(all(target_os = "linux", not(target_env = "ohos"), not(test)))]
primary: Option<primary::PrimarySelection>,View on GitHub (pinned to 73e0f67d83)