Skip to content

Commit dfc9cef

Browse files
davindicodeclaude
andcommitted
Auto-fix tmux extended-keys compatibility on attach/create
- Automatically set extended-keys off after entering tmux session - Ensures key combos work on all tmux versions 2.0+ (including 3.3/3.4) - Remove version warning banner (no longer needed) Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
1 parent a87bb2b commit dfc9cef

1 file changed

Lines changed: 17 additions & 7 deletions

File tree

app/components/terminal/InputBox.tsx

Lines changed: 17 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -165,7 +165,6 @@ export default function InputBox() {
165165
const [text, setText] = useState("");
166166
const [activeGroup, setActiveGroup] = useState<string | null>(null);
167167
const [tmuxSessions, setTmuxSessions] = useState<TmuxSession[]>([]);
168-
const [tmuxVersion, setTmuxVersion] = useState<string | null>(null);
169168
const [tmuxLoading, setTmuxLoading] = useState(false);
170169
const [tmuxNewName, setTmuxNewName] = useState("");
171170
const [editorFileName, setEditorFileName] = useState("");
@@ -276,16 +275,31 @@ export default function InputBox() {
276275
const res = await fetch("/api/tmux/sessions");
277276
const data = await res.json();
278277
setTmuxSessions(data.sessions || []);
279-
if (data.version) setTmuxVersion(data.version);
280278
} catch { setTmuxSessions([]); }
281279
setTmuxLoading(false);
282280
};
283281

282+
// After entering tmux, disable extended-keys for compatibility with 3.3/3.4
283+
const ensureTmuxCompat = () => {
284+
if (!activeSessionId) return;
285+
setTimeout(() => {
286+
// Send Ctrl+B : to open tmux command prompt, then set extended-keys off
287+
sendInput(activeSessionId, "\x02");
288+
setTimeout(() => {
289+
sendInput(activeSessionId, ":");
290+
setTimeout(() => {
291+
sendInput(activeSessionId, "set -g extended-keys off\n");
292+
}, 50);
293+
}, 50);
294+
}, 300);
295+
};
296+
284297
const handleTmuxAttach = (name: string) => {
285298
if (!activeSessionId) return;
286299
sendInput(activeSessionId, `tmux attach -t ${name}\n`);
287300
setInTmux(activeSessionId, true);
288301
setActiveGroup(null);
302+
ensureTmuxCompat();
289303
};
290304

291305
const handleTmuxNew = () => {
@@ -294,6 +308,7 @@ export default function InputBox() {
294308
setTmuxNewName("");
295309
setInTmux(activeSessionId, true);
296310
setActiveGroup(null);
311+
ensureTmuxCompat();
297312
};
298313

299314
const handleTmuxDetach = () => {
@@ -630,11 +645,6 @@ export default function InputBox() {
630645
)}
631646
{activeGroup === TMUX_TAB && !inTmux && (
632647
<div className="border-b border-gray-700/50 bg-[#12122a] px-3 py-2">
633-
{tmuxVersion && (tmuxVersion.startsWith("3.3") || tmuxVersion.startsWith("3.4")) && (
634-
<div className="text-[10px] text-yellow-400 bg-yellow-900/20 border border-yellow-800/30 rounded px-2 py-1 mb-1.5">
635-
tmux {tmuxVersion} has known key handling issues. Upgrade to 3.5+ or add <code className="text-yellow-300">set -g extended-keys off</code> to ~/.tmux.conf
636-
</div>
637-
)}
638648
{tmuxLoading ? (
639649
<span className="text-[11px] text-gray-500">Loading...</span>
640650
) : tmuxSessions.length === 0 ? (

0 commit comments

Comments
 (0)