{"record":{"id":"a938c142a7cafee6","repo":"Hmbown/CodeWhale","slug":"selection-is-too-large-for-osc-52-clipboard-fallba","errorCode":null,"errorMessage":"selection is too large for OSC 52 clipboard fallback","messagePattern":"selection is too large for OSC 52 clipboard fallback","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"warning","filePath":"crates/tui/src/tui/clipboard.rs","lineNumber":476,"sourceCode":"            if write_text_with_pbcopy(text).is_ok() {\n                return Ok(());\n            }\n\n            #[cfg(target_os = \"windows\")]\n            if write_text_with_set_clipboard(text).is_ok() {\n                return Ok(());\n            }\n\n            self.enqueue_terminal_write(text)\n                .map_err(|err| anyhow::anyhow!(\"Clipboard unavailable: {err}\"))\n        }\n    }\n\n    #[cfg(not(test))]\n    fn enqueue_terminal_write(&mut self, text: &str) -> Result<()> {\n        if !self.terminal_context.in_tmux {\n            if text.len() > OSC52_MAX_BYTES {\n                bail!(\"selection is too large for OSC 52 clipboard fallback\");\n            }\n            if !io::stdout().is_terminal() {\n                bail!(\"OSC 52 clipboard fallback requires a terminal\");\n            }\n        }\n\n        if self.terminal_writer.is_none() {\n            self.terminal_writer = Some(TerminalClipboardWriter::spawn()?);\n        }\n        self.terminal_writer\n            .as_ref()\n            .expect(\"terminal clipboard writer initialized\")\n            .enqueue(text, self.terminal_context.in_tmux)\n    }\n\n    /// Return one completed background terminal clipboard write, if available.\n    ///\n    /// Successes are intentionally quiet because callers already show their","sourceCodeStart":458,"sourceCodeEnd":494,"githubUrl":"https://github.com/Hmbown/CodeWhale/blob/0c42157ee52f9d55af2b506d71b46249910f77d3/crates/tui/src/tui/clipboard.rs#L458-L494","documentation":"The OSC 52 clipboard fallback refuses to emit sequences larger than OSC52_MAX_BYTES (100 KiB) when not running under tmux. OSC 52 encodes the selection as base64 inside a terminal escape sequence, and many terminals truncate or drop oversized sequences, so the copy would silently fail. Under tmux the check is skipped because the write goes through tmux load-buffer instead.","triggerScenarios":"Copying a selection larger than 100 KiB (about 25 KiB of text after base64 inflation, i.e. large multi-thousand-line selections) when no system clipboard utility (pbcopy/wl-copy/xclip) is available and the session is not inside tmux.","commonSituations":"Headless-ish setups with no clipboard helper installed; selecting whole files or huge command output in the TUI; minimal Linux containers or SSH sessions without X11/Wayland.","solutions":["Install a native clipboard utility (wl-clipboard on Wayland, xclip/xsel on X11, pbcopy on macOS) so OSC 52 is not the fallback.","Copy a smaller selection; narrow the region to what you actually need (<100 KiB, roughly a few thousand lines).","Run the TUI inside tmux so the copy routes through tmux load-buffer, which is not subject to this cap."],"exampleFix":null,"handlingStrategy":"validation","validationCode":"const OSC52_MAX_BYTES: usize = 100 * 1024;\n\nfn selection_copyable_via_osc52(text: &str, in_tmux: bool) -> bool {\n    in_tmux || text.len() <= OSC52_MAX_BYTES\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Install a native clipboard utility (pbcopy, wl-copy, xclip) so OSC 52 stays a last resort.","Cap copy-to-clipboard selections in your UI and warn above ~100 KiB outside tmux.","Run inside tmux when you routinely copy very large regions; load-buffer has no such cap."],"tags":["clipboard","osc52","terminal","size-limit","rust"],"backgroundTag":"payload-too-large","analyzedSha":"0c42157ee52f9d55af2b506d71b46249910f77d3","analyzedAt":"2026-08-20T21:50:45.477Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}