summaryrefslogtreecommitdiffhomepage
path: root/packages/ui/src
diff options
context:
space:
mode:
authorShoubhit Dash <[email protected]>2026-02-27 03:11:58 +0530
committerGitHub <[email protected]>2026-02-26 15:41:58 -0600
commit270d084cb114cc16ef15cd6f5bbe10bb768d65de (patch)
treeb8e339eef57a43c3c4f20a785c6861874e86fbcf /packages/ui/src
parent9312867565e1de0f51a7ea8d43c5957afa4c90e5 (diff)
downloadopencode-270d084cb114cc16ef15cd6f5bbe10bb768d65de.tar.gz
opencode-270d084cb114cc16ef15cd6f5bbe10bb768d65de.zip
fix(ui): avoid truncating workspace paths in assistant text (#14584)
Diffstat (limited to 'packages/ui/src')
-rw-r--r--packages/ui/src/components/message-part.tsx23
1 files changed, 14 insertions, 9 deletions
diff --git a/packages/ui/src/components/message-part.tsx b/packages/ui/src/components/message-part.tsx
index 8fbad45bd..0f67d683f 100644
--- a/packages/ui/src/components/message-part.tsx
+++ b/packages/ui/src/components/message-part.tsx
@@ -145,17 +145,22 @@ function createThrottledValue(getValue: () => string) {
return value
}
-function relativizeProjectPaths(text: string, directory?: string) {
- if (!text) return ""
- if (!directory) return text
- if (directory === "/") return text
- if (directory === "\\") return text
- return text.split(directory).join("")
+function relativizeProjectPath(path: string, directory?: string) {
+ if (!path) return ""
+ if (!directory) return path
+ if (directory === "/") return path
+ if (directory === "\\") return path
+ if (path === directory) return ""
+
+ const separator = directory.includes("\\") ? "\\" : "/"
+ const prefix = directory.endsWith(separator) ? directory : directory + separator
+ if (!path.startsWith(prefix)) return path
+ return path.slice(directory.length)
}
function getDirectory(path: string | undefined) {
const data = useData()
- return relativizeProjectPaths(_getDirectory(path), data.directory)
+ return relativizeProjectPath(_getDirectory(path), data.directory)
}
import type { IconProps } from "./icon"
@@ -1066,7 +1071,7 @@ PART_MAPPING["text"] = function TextPartDisplay(props) {
return items.filter((x) => !!x).join(" \u00B7 ")
})
- const displayText = () => relativizeProjectPaths((part.text ?? "").trim(), data.directory)
+ const displayText = () => (part.text ?? "").trim()
const throttledText = createThrottledValue(displayText)
const isLastTextPart = createMemo(() => {
const last = (data.store.part?.[props.message.id] ?? [])
@@ -1168,7 +1173,7 @@ ToolRegistry.register({
<div data-component="tool-loaded-file">
<Icon name="enter" size="small" />
<span>
- {i18n.t("ui.tool.loaded")} {relativizeProjectPaths(filepath, data.directory)}
+ {i18n.t("ui.tool.loaded")} {relativizeProjectPath(filepath, data.directory)}
</span>
</div>
)}