{"record":{"id":"e7cf80c47c61b80b","repo":"Hmbown/CodeWhale","slug":"clipboard-unavailable-err","errorCode":null,"errorMessage":"Clipboard unavailable: {err}","messagePattern":"Clipboard unavailable: (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"warning","filePath":"crates/tui/src/tui/clipboard.rs","lineNumber":590,"sourceCode":"    pub fn write_text(&mut self, text: &str) -> Result<()> {\n        #[cfg(test)]\n        {\n            if let Some(writer) = self.terminal_writer.as_ref() {\n                return writer.enqueue(text, self.terminal_context.in_tmux);\n            }\n            if self.fail_text_writes {\n                bail!(\"test clipboard unavailable\");\n            }\n            self.written_text.push(text.to_string());\n            Ok(())\n        }\n\n        #[cfg(not(test))]\n        {\n            if self.terminal_context.write_order() == ClipboardWriteOrder::TerminalClientOnly {\n                return self\n                    .enqueue_terminal_write(text)\n                    .map_err(|err| anyhow::anyhow!(\"Clipboard unavailable: {err}\"));\n            }\n\n            #[cfg(all(target_os = \"linux\", not(target_env = \"ohos\")))]\n            if write_text_with_wlcopy(text).is_ok() {\n                return Ok(());\n            }\n\n            #[cfg(any(\n                target_os = \"macos\",\n                target_os = \"windows\",\n                all(target_os = \"linux\", not(target_env = \"ohos\"))\n            ))]\n            {\n                self.ensure_clipboard();\n                if let Some(clipboard) = self.clipboard.as_mut()\n                    && clipboard.set_text(text.to_string()).is_ok()\n                {\n                    return Ok(());","sourceCodeStart":572,"sourceCodeEnd":608,"githubUrl":"https://github.com/Hmbown/CodeWhale/blob/73e0f67d83c59909b571efdfc88c4bc28c309cb1/crates/tui/src/tui/clipboard.rs#L572-L608","documentation":"write_text wraps any failure of the terminal-client-only clipboard path (enqueue_terminal_write) into a generic 'Clipboard unavailable' error. It means the terminal multiplexer/client clipboard transport could not accept the write — either the bounded queue was full or the writer was disconnected.","triggerScenarios":"Calling write_text while ClipboardWriteOrder::TerminalClientOnly is configured and enqueue_terminal_write fails: another write is still queued (bounded channel full) or the writer thread has stopped (disconnected).","commonSituations":"Spamming copy operations faster than the slow terminal transport drains them; running inside tmux/screen where client-only clipboard is required but the writer died; copy during shutdown.","solutions":["Retry the copy after a short delay so the queued write can drain","Check the wrapped source error to distinguish 'still queued' (retry) from 'writer stopped' (reinit)","Switch the clipboard write order so a fallback transport (OSC52/wlcopy) is tried when the terminal-client path fails"],"exampleFix":"// before\nclipboard.write_text(text).map_err(|e| anyhow!(\"Clipboard unavailable: {e}\"))\n// after\nmatch clipboard.write_text(text) {\n    Ok(()) => {},\n    Err(e) if e.to_string().contains(\"still queued\") => {\n        std::thread::sleep(Duration::from_millis(50));\n        clipboard.write_text(text)?;\n    }\n    Err(e) => return Err(e),\n}","handlingStrategy":"fallback","validationCode":"if clipboard.write_order() == ClipboardWriteOrder::TerminalClientOnly\n    && clipboard.queue_is_saturated() {\n    // defer the copy instead of calling write_text now\n}","typeGuard":null,"tryCatchPattern":"match clipboard.write_text(text) {\n    Ok(()) => {},\n    Err(e) if e.to_string().contains(\"still queued\") => schedule_retry(text),\n    Err(e) => try_osc52_fallback(text).unwrap_or_else(|e| log::warn!(\"{e}\")),\n}","preventionTips":["Throttle copy bursts so the bounded terminal write queue never fills","Prefer write orders that include a non-terminal fallback transport","Check tmux/screen clipboard passthrough support before relying on client-only mode"],"tags":["clipboard","terminal","queue-full"],"backgroundTag":"clipboard-unavailable","analyzedSha":"73e0f67d83c59909b571efdfc88c4bc28c309cb1","analyzedAt":"2026-09-22T01:30:00.501Z","contentChangedAt":"2026-09-22T01:30:00.501Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}