@code-yeongyu/senpi
Version:
Coding agent CLI with read, bash, edit, write tools and session management
58 lines • 2.54 kB
JavaScript
/**
* Builds the startup warning for recommended tmux settings.
*
* All missing settings are collected into a single message so users can fix
* ~/.tmux.conf once, instead of discovering the recommendations one tmux
* restart at a time.
*/
export function buildTmuxSetupWarning(check) {
const recommendations = [];
if (check.extendedKeys !== "on" && check.extendedKeys !== "always") {
recommendations.push({
setting: "set -g extended-keys on",
reason: "modified Enter keys (Shift+Enter, ...)",
});
}
if (check.extendedKeysFormat === "xterm") {
recommendations.push({
setting: "set -g extended-keys-format csi-u",
reason: "Pi works best with csi-u",
});
}
// Only advertise passthrough when it would actually do something: images
// are not already enabled and the outer terminal understands Kitty
// graphics. Users who deliberately chose `allow-passthrough on` already
// have working images and are not nagged to switch to `all`.
if (!check.imagesEnabled && check.outerKittyCapable) {
const versionMatch = check.version?.match(/^(\d+)\.(\d+)/);
const major = Number(versionMatch?.[1] ?? 0);
const minor = Number(versionMatch?.[2] ?? 0);
if (check.version && (major < 3 || (major === 3 && minor < 3))) {
recommendations.push({
setting: `upgrade tmux (current ${check.version})`,
reason: "inline images need tmux >= 3.3",
});
}
else {
if (!["1", "on", "all"].includes(check.allowPassthrough ?? "")) {
recommendations.push({
setting: "set -g allow-passthrough on",
reason: "inline images (Kitty graphics)",
});
}
if (!["1", "on"].includes(check.focusEvents ?? "")) {
recommendations.push({
setting: "set -g focus-events on",
reason: "repaint images after pane activation",
});
}
}
}
if (recommendations.length === 0) {
return undefined;
}
const settingWidth = Math.max(...recommendations.map((entry) => entry.setting.length));
const lines = recommendations.map((entry) => ` ${entry.setting.padEnd(settingWidth)} # ${entry.reason}`);
return `tmux is not fully configured. Add to ~/.tmux.conf and restart tmux:\n\n${lines.join("\n")}`;
}
//# sourceMappingURL=tmux-setup.js.map