mirror of
https://github.com/openclaw/openclaw.git
synced 2026-05-07 09:11:22 +00:00
TUI: coalesce multiline paste submits on macOS terminals
This commit is contained in:
@@ -130,10 +130,32 @@ describe("shouldEnableWindowsGitBashPasteFallback", () => {
|
||||
).toBe(true);
|
||||
});
|
||||
|
||||
it("disables fallback outside Windows", () => {
|
||||
it("enables fallback on macOS iTerm", () => {
|
||||
expect(
|
||||
shouldEnableWindowsGitBashPasteFallback({
|
||||
platform: "darwin",
|
||||
env: {
|
||||
TERM_PROGRAM: "iTerm.app",
|
||||
} as NodeJS.ProcessEnv,
|
||||
}),
|
||||
).toBe(true);
|
||||
});
|
||||
|
||||
it("enables fallback on macOS Terminal.app", () => {
|
||||
expect(
|
||||
shouldEnableWindowsGitBashPasteFallback({
|
||||
platform: "darwin",
|
||||
env: {
|
||||
TERM_PROGRAM: "Apple_Terminal",
|
||||
} as NodeJS.ProcessEnv,
|
||||
}),
|
||||
).toBe(true);
|
||||
});
|
||||
|
||||
it("disables fallback outside Windows", () => {
|
||||
expect(
|
||||
shouldEnableWindowsGitBashPasteFallback({
|
||||
platform: "linux",
|
||||
env: {
|
||||
MSYSTEM: "MINGW64",
|
||||
} as NodeJS.ProcessEnv,
|
||||
|
||||
@@ -84,13 +84,24 @@ export function shouldEnableWindowsGitBashPasteFallback(params?: {
|
||||
env?: NodeJS.ProcessEnv;
|
||||
}): boolean {
|
||||
const platform = params?.platform ?? process.platform;
|
||||
const env = params?.env ?? process.env;
|
||||
const termProgram = (env.TERM_PROGRAM ?? "").toLowerCase();
|
||||
|
||||
// Some macOS terminals emit multiline paste as rapid single-line submits.
|
||||
// Enable burst coalescing so pasted blocks stay as one user message.
|
||||
if (platform === "darwin") {
|
||||
if (termProgram.includes("iterm") || termProgram.includes("apple_terminal")) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
if (platform !== "win32") {
|
||||
return false;
|
||||
}
|
||||
const env = params?.env ?? process.env;
|
||||
|
||||
const msystem = (env.MSYSTEM ?? "").toUpperCase();
|
||||
const shell = env.SHELL ?? "";
|
||||
const termProgram = (env.TERM_PROGRAM ?? "").toLowerCase();
|
||||
if (msystem.startsWith("MINGW") || msystem.startsWith("MSYS")) {
|
||||
return true;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user