diff options
| author | Aiden Cline <[email protected]> | 2026-01-13 13:52:09 -0600 |
|---|---|---|
| committer | Aiden Cline <[email protected]> | 2026-01-13 13:52:16 -0600 |
| commit | 33ba064c40925670b4b4a1286e2afd5ef26df862 (patch) | |
| tree | 5b3e5d31c202a46f5872270ca6704511de8dfaa9 | |
| parent | 96ae5925c324767662ee2a76a1ec866ba9bf3bc0 (diff) | |
| download | opencode-33ba064c40925670b4b4a1286e2afd5ef26df862.tar.gz opencode-33ba064c40925670b4b4a1286e2afd5ef26df862.zip | |
tweak: external dir permission rendering in tui
| -rw-r--r-- | packages/opencode/src/cli/cmd/tui/routes/session/permission.tsx | 17 |
1 files changed, 14 insertions, 3 deletions
diff --git a/packages/opencode/src/cli/cmd/tui/routes/session/permission.tsx b/packages/opencode/src/cli/cmd/tui/routes/session/permission.tsx index 9cde65d2e..eab2adb10 100644 --- a/packages/opencode/src/cli/cmd/tui/routes/session/permission.tsx +++ b/packages/opencode/src/cli/cmd/tui/routes/session/permission.tsx @@ -13,15 +13,26 @@ import path from "path" import { LANGUAGE_EXTENSIONS } from "@/lsp/language" import { Keybind } from "@/util/keybind" import { Locale } from "@/util/locale" +import { Global } from "@/global" type PermissionStage = "permission" | "always" | "reject" function normalizePath(input?: string) { if (!input) return "" - if (path.isAbsolute(input)) { - return path.relative(process.cwd(), input) || "." + + const cwd = process.cwd() + const home = Global.Path.home + const absolute = path.isAbsolute(input) ? input : path.resolve(cwd, input) + const relative = path.relative(cwd, absolute) + + if (!relative) return "." + if (!relative.startsWith("..")) return relative + + // outside cwd - use ~ or absolute + if (home && (absolute === home || absolute.startsWith(home + path.sep))) { + return absolute.replace(home, "~") } - return input + return absolute } function filetype(input?: string) { |
