Skip to content

Commit 6c45890

Browse files
committed
Merge branch 'shuvcode-dev' into integration
fix(tui): restore Linux paste support lost in upstream merge - Re-add parseUriList import for file:// URI handling - Restore Linux drag-and-drop and clipboard paste support - Document in fork-features.json to prevent future regression Closes anomalyco#257
2 parents 384567d + 1041e82 commit 6c45890

2 files changed

Lines changed: 63 additions & 0 deletions

File tree

‎packages/opencode/src/cli/cmd/tui/component/prompt/index.tsx‎

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ import { useRenderer } from "@opentui/solid"
2020
import { Editor } from "@tui/util/editor"
2121
import { useExit } from "../../context/exit"
2222
import { Clipboard } from "../../util/clipboard"
23+
import { parseUriList } from "../../util/uri"
2324
import type { FilePart } from "@opencode-ai/sdk/v2"
2425
import { TuiEvent } from "../../event"
2526
import { iife } from "@/util/iife"
@@ -942,6 +943,39 @@ export function Prompt(props: PromptProps) {
942943
return
943944
}
944945

946+
// Handle file:// URIs or text/uri-list (common for drag-and-drop on Linux)
947+
if (pastedContent.includes("file://")) {
948+
const paths = parseUriList(pastedContent)
949+
if (paths.length > 0) {
950+
let handled = false
951+
for (const path of paths) {
952+
try {
953+
const file = Bun.file(path)
954+
if (file.type.startsWith("image/")) {
955+
const content = await file
956+
.arrayBuffer()
957+
.then((buffer) => Buffer.from(buffer).toString("base64"))
958+
.catch(() => {})
959+
if (content) {
960+
await pasteImage({
961+
filename: file.name,
962+
mime: file.type,
963+
content,
964+
})
965+
handled = true
966+
continue
967+
}
968+
}
969+
} catch {}
970+
}
971+
972+
if (handled) {
973+
event.preventDefault()
974+
return
975+
}
976+
}
977+
}
978+
945979
// trim ' from the beginning and end of the pasted content. just
946980
// ' and nothing else
947981
const filepath = pastedContent.replace(/^'+|'+$/g, "").replace(/\\ /g, " ")

‎script/sync/fork-features.json‎

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1600,6 +1600,35 @@
16001600
"markers": ["absorbLineRange", "lineRangeRegex", "updateFileUrl"]
16011601
}
16021602
]
1603+
},
1604+
{
1605+
"pr": 230,
1606+
"title": "Linux/Ghostty drag-and-drop and clipboard image paste support",
1607+
"author": "fork",
1608+
"status": "fork-only",
1609+
"description": "Handle file:// URIs and text/uri-list format for Linux drag-and-drop. Added ctrl+shift+v keybind for Linux paste. Supports both Wayland and X11 display servers. Fixes image paste in terminal emulators like Ghostty.",
1610+
"files": [
1611+
"packages/opencode/src/cli/cmd/tui/util/uri.ts",
1612+
"packages/opencode/src/cli/cmd/tui/component/prompt/index.tsx",
1613+
"packages/opencode/src/config/config.ts"
1614+
],
1615+
"criticalCode": [
1616+
{
1617+
"file": "packages/opencode/src/cli/cmd/tui/util/uri.ts",
1618+
"description": "parseUriList() helper to parse file:// URIs and text/uri-list format",
1619+
"markers": ["export function parseUriList", "file://", "decodeURIComponent"]
1620+
},
1621+
{
1622+
"file": "packages/opencode/src/cli/cmd/tui/component/prompt/index.tsx",
1623+
"description": "Import parseUriList and handle file:// URIs in onPaste handler",
1624+
"markers": ["import { parseUriList }", "pastedContent.includes(\"file://\")", "parseUriList(pastedContent)"]
1625+
},
1626+
{
1627+
"file": "packages/opencode/src/config/config.ts",
1628+
"description": "input_paste keybind includes ctrl+shift+v for Linux",
1629+
"markers": ["input_paste:", "ctrl+v,ctrl+shift+v"]
1630+
}
1631+
]
16031632
}
16041633
]
16051634
}

0 commit comments

Comments
 (0)