Bug Description
When pasting multi-line text (50+ lines) into an active AI session (Claude Code or GitHub Copilot), only the last few lines are pasted. The first lines are silently dropped. Pasting the same content into a new terminal (inside or outside tmax) works fine.
Steps to Reproduce
- Open tmax on Windows
- Start a Claude Code or GitHub Copilot session
- Copy 50 lines of text to the clipboard
- Paste into the AI session (Ctrl+V or right-click)
- Observe that only the last few lines appear
Expected Behavior
All copied lines should be pasted into the session.
Actual Behavior
The beginning of the pasted text is silently truncated. Only the tail end appears.
What Works
- Pasting the same content into a new tmax terminal — ✅ works
- Pasting the same content into a terminal outside tmax — ✅ works
- Only fails in active AI sessions (Claude Code, Copilot)
Root Cause Analysis
AI sessions (Claude Code, Copilot) enable bracketed paste mode (\x1b[?2004h). When tmax detects this, it wraps the entire pasted text in bracketed paste escape sequences and sends it as a single write:
src/renderer/components/TerminalPanel.tsx (lines 549–559):
if (cursorHideSignalsRef.current.bracketedPaste) {
text = `\x1b[200~${text}\x1b[201~`;
}
window.terminalAPI.writePty(terminalId, text);
src/main/pty-manager.ts (line ~200):
pty.write(data); // entire bracketed paste in one shot
The entire payload — escape sequences + 50 lines of text — is sent as a single pty.write() call. Windows ConPTY or the receiving application's input processing truncates the beginning when the payload is too large, keeping only the tail.
New terminals work because they don't have bracketed paste mode enabled, so the shell's default input handling (which is more tolerant of large input) processes the paste.
Suggested Fix
Chunk large writes in PtyManager.write() when the payload exceeds a threshold:
- Split writes larger than ~4KB into sequential chunks
- Add a small delay between chunks to allow ConPTY / the receiving application to process each one
- Keep the bracketed paste wrapper on the first and last chunks respectively (
\x1b[200~ on first, \x1b[201~ on last)
- Keep single-keystroke writes unchanged for responsiveness
Environment
- OS: Windows 11
- tmax version: latest
Bug Description
When pasting multi-line text (50+ lines) into an active AI session (Claude Code or GitHub Copilot), only the last few lines are pasted. The first lines are silently dropped. Pasting the same content into a new terminal (inside or outside tmax) works fine.
Steps to Reproduce
Expected Behavior
All copied lines should be pasted into the session.
Actual Behavior
The beginning of the pasted text is silently truncated. Only the tail end appears.
What Works
Root Cause Analysis
AI sessions (Claude Code, Copilot) enable bracketed paste mode (
\x1b[?2004h). When tmax detects this, it wraps the entire pasted text in bracketed paste escape sequences and sends it as a single write:src/renderer/components/TerminalPanel.tsx(lines 549–559):src/main/pty-manager.ts(line ~200):The entire payload — escape sequences + 50 lines of text — is sent as a single
pty.write()call. Windows ConPTY or the receiving application's input processing truncates the beginning when the payload is too large, keeping only the tail.New terminals work because they don't have bracketed paste mode enabled, so the shell's default input handling (which is more tolerant of large input) processes the paste.
Suggested Fix
Chunk large writes in
PtyManager.write()when the payload exceeds a threshold:\x1b[200~on first,\x1b[201~on last)Environment