fix(tui,coding-agent): handle tmux xterm extended keys and warn on tmux setup fixes #1872
This commit is contained in:
@@ -512,6 +512,13 @@ export class InteractiveMode {
|
||||
}
|
||||
});
|
||||
|
||||
// Check tmux keyboard setup asynchronously
|
||||
this.checkTmuxKeyboardSetup().then((warning) => {
|
||||
if (warning) {
|
||||
this.showWarning(warning);
|
||||
}
|
||||
});
|
||||
|
||||
// Show startup warnings
|
||||
const { migratedProviders, modelFallbackMessage, initialMessage, initialImages, initialMessages } = this.options;
|
||||
|
||||
@@ -586,6 +593,50 @@ export class InteractiveMode {
|
||||
}
|
||||
}
|
||||
|
||||
private async checkTmuxKeyboardSetup(): Promise<string | undefined> {
|
||||
if (!process.env.TMUX) return undefined;
|
||||
|
||||
const runTmuxShow = (option: string): Promise<string | undefined> => {
|
||||
return new Promise((resolve) => {
|
||||
const proc = spawn("tmux", ["show", "-gv", option], {
|
||||
stdio: ["ignore", "pipe", "ignore"],
|
||||
});
|
||||
let stdout = "";
|
||||
const timer = setTimeout(() => {
|
||||
proc.kill();
|
||||
resolve(undefined);
|
||||
}, 2000);
|
||||
|
||||
proc.stdout?.on("data", (data) => {
|
||||
stdout += data.toString();
|
||||
});
|
||||
proc.on("error", () => {
|
||||
clearTimeout(timer);
|
||||
resolve(undefined);
|
||||
});
|
||||
proc.on("close", (code) => {
|
||||
clearTimeout(timer);
|
||||
resolve(code === 0 ? stdout.trim() : undefined);
|
||||
});
|
||||
});
|
||||
};
|
||||
|
||||
const [extendedKeys, extendedKeysFormat] = await Promise.all([
|
||||
runTmuxShow("extended-keys"),
|
||||
runTmuxShow("extended-keys-format"),
|
||||
]);
|
||||
|
||||
if (extendedKeys !== "on" && extendedKeys !== "always") {
|
||||
return "tmux extended-keys is off. Modified Enter keys may not work. Add `set -g extended-keys on` to ~/.tmux.conf and restart tmux.";
|
||||
}
|
||||
|
||||
if (extendedKeysFormat === "xterm") {
|
||||
return "tmux extended-keys-format is xterm. Pi works best with csi-u. Add `set -g extended-keys-format csi-u` to ~/.tmux.conf and restart tmux.";
|
||||
}
|
||||
|
||||
return undefined;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get changelog entries to display on startup.
|
||||
* Only shows new entries since last seen version, skips for resumed sessions.
|
||||
|
||||
Reference in New Issue
Block a user