The open source coding agent.
TypeScript
fix: windows fallback for "less" cmd in `session list` (#6515)
Mani Sundararajan154c52c4d94f
diff --git a/packages/opencode/src/cli/cmd/session.ts b/packages/opencode/src/cli/cmd/session.tsindex c8b5b033660..c6a1fd4138f 100644--- a/packages/opencode/src/cli/cmd/session.ts+++ b/packages/opencode/src/cli/cmd/session.ts@@ -4,7 +4,36 @@ import { Session } from "../../session"import { bootstrap } from "../bootstrap"import { UI } from "../ui"import { Locale } from "../../util/locale"+import { Flag } from "../../flag/flag"import { EOL } from "os"+import path from "path"++function pagerCmd(): string[] {+ const lessOptions = ["-R", "-S"]+ if (process.platform !== "win32") {+ return ["less", ...lessOptions]+ }++ // user could have less installed via other options+ const lessOnPath = Bun.which("less")+ if (lessOnPath) {+ if (Bun.file(lessOnPath).size) return [lessOnPath, ...lessOptions]+ }++ if (Flag.OPENCODE_GIT_BASH_PATH) {+ const less = path.join(Flag.OPENCODE_GIT_BASH_PATH, "..", "..", "usr", "bin", "less.exe")+ if (Bun.file(less).size) return [less, ...lessOptions]+ }++ const git = Bun.which("git")+ if (git) {+ const less = path.join(git, "..", "..", "usr", "bin", "less.exe")+ if (Bun.file(less).size) return [less, ...lessOptions]+ }++ // Fall back to Windows built-in more (via cmd.exe)+ return ["cmd", "/c", "more"]+}export const SessionCommand = cmd({command: "session",@@ -58,7 +87,7 @@ export const SessionListCommand = cmd({if (shouldPaginate) {const proc = Bun.spawn({- cmd: ["less", "-R", "-S"],+ cmd: pagerCmd(),stdin: "pipe",stdout: "inherit",stderr: "inherit",