summaryrefslogtreecommitdiffhomepage
path: root/packages/app/src/components/prompt-input
diff options
context:
space:
mode:
authorAdam <[email protected]>2026-02-10 10:12:17 -0600
committerAdam <[email protected]>2026-02-10 10:15:37 -0600
commit70c794e9139af1c1a2c43979d8f5e499a1587189 (patch)
tree72aedf7a8113d07fe803cf5678d7da683be2dc81 /packages/app/src/components/prompt-input
parent3929f0b5bd5535fc601b8ce9092929af1adb6629 (diff)
downloadopencode-70c794e9139af1c1a2c43979d8f5e499a1587189.tar.gz
opencode-70c794e9139af1c1a2c43979d8f5e499a1587189.zip
fix(app): regressions
Diffstat (limited to 'packages/app/src/components/prompt-input')
-rw-r--r--packages/app/src/components/prompt-input/build-request-parts.test.ts4
-rw-r--r--packages/app/src/components/prompt-input/build-request-parts.ts23
2 files changed, 8 insertions, 19 deletions
diff --git a/packages/app/src/components/prompt-input/build-request-parts.test.ts b/packages/app/src/components/prompt-input/build-request-parts.test.ts
index b0fd3a050..72bdecc01 100644
--- a/packages/app/src/components/prompt-input/build-request-parts.test.ts
+++ b/packages/app/src/components/prompt-input/build-request-parts.test.ts
@@ -112,7 +112,7 @@ describe("buildRequestParts", () => {
// Special chars should be encoded
expect(filePart.url).toContain("file%23name.txt")
// Should have Windows drive letter properly encoded
- expect(filePart.url).toMatch(/file:\/\/\/[A-Z]%3A/)
+ expect(filePart.url).toMatch(/file:\/\/\/[A-Z]:/)
}
})
@@ -210,7 +210,7 @@ describe("buildRequestParts", () => {
if (filePart?.type === "file") {
// Should handle absolute path that differs from sessionDirectory
expect(() => new URL(filePart.url)).not.toThrow()
- expect(filePart.url).toContain("/D%3A/other/project/file.ts")
+ expect(filePart.url).toContain("/D:/other/project/file.ts")
}
})
diff --git a/packages/app/src/components/prompt-input/build-request-parts.ts b/packages/app/src/components/prompt-input/build-request-parts.ts
index 11aec9631..0cc54dc2b 100644
--- a/packages/app/src/components/prompt-input/build-request-parts.ts
+++ b/packages/app/src/components/prompt-input/build-request-parts.ts
@@ -1,6 +1,7 @@
import { getFilename } from "@opencode-ai/util/path"
import { type AgentPartInput, type FilePartInput, type Part, type TextPartInput } from "@opencode-ai/sdk/v2/client"
import type { FileSelection } from "@/context/file"
+import { encodeFilePath } from "@/context/file/path"
import type { AgentPart, FileAttachmentPart, ImageAttachmentPart, Prompt } from "@/context/prompt"
import { Identifier } from "@/utils/id"
@@ -27,23 +28,11 @@ type BuildRequestPartsInput = {
sessionDirectory: string
}
-const absolute = (directory: string, path: string) =>
- path.startsWith("/") ? path : (directory + "/" + path).replace("//", "/")
-
-const encodeFilePath = (filepath: string): string => {
- // Normalize Windows paths: convert backslashes to forward slashes
- let normalized = filepath.replace(/\\/g, "/")
-
- // Handle Windows absolute paths (D:/path -> /D:/path for proper file:// URLs)
- if (/^[A-Za-z]:/.test(normalized)) {
- normalized = "/" + normalized
- }
-
- // Encode each path segment (preserving forward slashes as path separators)
- return normalized
- .split("/")
- .map((segment) => encodeURIComponent(segment))
- .join("/")
+const absolute = (directory: string, path: string) => {
+ if (path.startsWith("/")) return path
+ if (/^[A-Za-z]:[\\/]/.test(path) || /^[A-Za-z]:$/.test(path)) return path
+ if (path.startsWith("\\\\") || path.startsWith("//")) return path
+ return `${directory.replace(/[\\/]+$/, "")}/${path}`
}
const fileQuery = (selection: FileSelection | undefined) =>