diff options
| author | Aiden Cline <[email protected]> | 2026-01-13 13:33:58 -0600 |
|---|---|---|
| committer | Frank <[email protected]> | 2026-01-13 19:51:01 -0500 |
| commit | 7599396162e8196535f1eb56f7fd9014c70538f0 (patch) | |
| tree | f14dd60e17cf0b96545f8d2968d88e5387fd31e6 | |
| parent | d99d1315ee8e49e83d87d6b0006fd4a015540b99 (diff) | |
| download | opencode-7599396162e8196535f1eb56f7fd9014c70538f0.tar.gz opencode-7599396162e8196535f1eb56f7fd9014c70538f0.zip | |
tweak: ensure external dir and bash tool invocations render workdir details
| -rw-r--r-- | packages/opencode/src/cli/cmd/tui/routes/session/index.tsx | 29 | ||||
| -rw-r--r-- | packages/opencode/src/cli/cmd/tui/routes/session/permission.tsx | 18 |
2 files changed, 45 insertions, 2 deletions
diff --git a/packages/opencode/src/cli/cmd/tui/routes/session/index.tsx b/packages/opencode/src/cli/cmd/tui/routes/session/index.tsx index 10e340d7f..f87b811ae 100644 --- a/packages/opencode/src/cli/cmd/tui/routes/session/index.tsx +++ b/packages/opencode/src/cli/cmd/tui/routes/session/index.tsx @@ -69,6 +69,7 @@ import { Footer } from "./footer.tsx" import { usePromptRef } from "../../context/prompt" import { useExit } from "../../context/exit" import { Filesystem } from "@/util/filesystem" +import { Global } from "@/global" import { PermissionPrompt } from "./permission" import { QuestionPrompt } from "./question" import { DialogExportOptions } from "../../ui/dialog-export-options" @@ -1525,6 +1526,7 @@ function BlockTool(props: { title: string; children: JSX.Element; onClick?: () = function Bash(props: ToolProps<typeof BashTool>) { const { theme } = useTheme() + const sync = useSync() const output = createMemo(() => stripAnsi(props.metadata.output?.trim() ?? "")) const [expanded, setExpanded] = createSignal(false) const lines = createMemo(() => output().split("\n")) @@ -1534,11 +1536,36 @@ function Bash(props: ToolProps<typeof BashTool>) { return [...lines().slice(0, 10), "…"].join("\n") }) + const workdirDisplay = createMemo(() => { + const workdir = props.input.workdir + if (!workdir || workdir === ".") return undefined + + const base = sync.data.path.directory + if (!base) return undefined + + const absolute = path.resolve(base, workdir) + if (absolute === base) return undefined + + const home = Global.Path.home + if (!home) return absolute + + const match = absolute === home || absolute.startsWith(home + path.sep) + return match ? absolute.replace(home, "~") : absolute + }) + + const title = createMemo(() => { + const desc = props.input.description ?? "Shell" + const wd = workdirDisplay() + if (!wd) return `# ${desc}` + if (desc.includes(wd)) return `# ${desc}` + return `# ${desc} in ${wd}` + }) + return ( <Switch> <Match when={props.metadata.output !== undefined}> <BlockTool - title={"# " + (props.input.description ?? "Shell")} + title={title()} part={props.part} onClick={overflow() ? () => setExpanded((prev) => !prev) : undefined} > 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 c95b42260..9cde65d2e 100644 --- a/packages/opencode/src/cli/cmd/tui/routes/session/permission.tsx +++ b/packages/opencode/src/cli/cmd/tui/routes/session/permission.tsx @@ -226,7 +226,23 @@ export function PermissionPrompt(props: { request: PermissionRequest }) { <TextBody icon="◇" title={`Exa Code Search "` + (input().query ?? "") + `"`} /> </Match> <Match when={props.request.permission === "external_directory"}> - <TextBody icon="←" title={`Access external directory ` + normalizePath(input().path as string)} /> + {(() => { + const meta = props.request.metadata ?? {} + const parent = typeof meta["parentDir"] === "string" ? meta["parentDir"] : undefined + const filepath = typeof meta["filepath"] === "string" ? meta["filepath"] : undefined + const pattern = props.request.patterns?.[0] + const derived = + typeof pattern === "string" + ? pattern.includes("*") + ? path.dirname(pattern) + : pattern + : undefined + + const raw = parent ?? filepath ?? derived + const dir = normalizePath(raw) + + return <TextBody icon="←" title={`Access external directory ` + dir} /> + })()} </Match> <Match when={props.request.permission === "doom_loop"}> <TextBody icon="⟳" title="Continue after repeated failures" /> |
