Repository navigation
fix(tui): send pasted image and PDF paths to local servers - #59833
Conversation
There was a problem hiding this comment.
I found nothing that should block this. A path pasted into a TUI using a local server is sent as file://, which core already reads and labels for the model with Attached file: <path>. Remote servers (--server), files deleted before submit, and clipboard bitmaps still send the bytes captured at paste time. Only the pasted-path flow changes; @-mentions and SVG text are untouched.
I ran bun test test/prompt in packages/tui (78 pass) and the two core tests the description cites (both pass). I couldn't check it end to end because our TUI driver can't send a pasted path. bun typecheck won't run in this environment on either branch, but tsc reported no errors in the changed files.
Public API is unchanged. TuiInput.server.local and TuiTerminalEnvironment.localServer are optional fields inside the TUI. Saved prompt history entries gain an optional path, and existing history still loads.
Problem
When I drag an image into the TUI, or paste a path to an image or PDF, the TUI reads the bytes and sends a
data:URI. The path is gone by the time the model sees it, so it can't open the file again or hand it to a tool.Core already does the right thing for
file://attachments: it reads the file, keepssource.uri, and putsAttached file: <path>in front of the image. The TUI just never sent one.Change
The composer still stores the
data:URI, so previews,[Image N]labels, dedup, history and drafts work like before. It now also remembers the local path. On submit, each attachment picks its URI:--standalone. With an explicit--serverI keep sending bytes, since the server could be anywhere. That's the same rule the CLI already uses to decide whether to forward the terminal's environment.data:. SVG paste-as-text and @-mentioned files don't change.packages/cli/src/commands/handlers/default.ts # server.local = no --server packages/tui/src/app.tsx # passes it into the terminal environment packages/tui/src/context/runtime.tsx # localServer flag packages/tui/src/prompt/history.tsx # PromptFile gets an optional path packages/tui/src/component/prompt/ + local-attachment.ts # resolvePastedAttachments returns path, promptFilesForServer picks the URI index.tsx # stores path on paste, maps files on prompt and command submitOut of scope
opencode runmini mode still sends bytes. It has its own prompt types and host wiring.file://URI. That's how @-mentioned images already behave: no thumbnail in the composer, and core reads the file again on resend.Verification
bun test test/promptinpackages/tui: 78 pass. The new test covers PNG, JPEG and PDF with spaces, unicode and quotes, a local vs remote server, a deleted file, and a pathless clipboard image keeping its order.bun run testinpackages/tui: 1550 pass. The one failure,tab-pulse.test.tsx, also fails now and then ondev.bun typecheckinpackages/tuiandpackages/cli: clean.file://URL to a PDF, and a PNG I deleted before submit. The stored message hadsource.urifor the first three andinlinefor the deleted one, with[Image 1] [Image 2] [PDF 1] [Image 3]in order.servethrough--server. The image went inline.session-prompt.test.ts"materializes local image content before admission" andsession-runner-message.test.ts"exposes admitted local image source paths before provider media".Visual
Added by the opencode bot (AI-generated).
Fixes #48190
Fixes #41454
Related: #46664, #57298