Skip to content

fix: upload terminal images to the backend that holds the session - #69

Merged
LukeGus merged 4 commits into
Termix-SSH:dev-1.4.1from
Li-Lee:fix/image-upload-session-origin
Nov 16, 2026
Merged

LukeGus merged 4 commits into
Termix-SSH:dev-1.4.1from
Li-Lee:fix/image-upload-session-origin

Conversation

@Li-Lee

@Li-Lee Li-Lee commented Nov 10, 2026

Copy link
Copy Markdown

Problem

In the desktop app, pasting or uploading an image into a terminal fails when the session was started on the linked server ("Where connections start" = server, or a host with connectionOrigin: remote):

Request failed with status code 503 (IMAGE_STORAGE_UNAVAILABLE)

handleImageUpload posts /image-upload with usePluginApi(), which in the desktop app is always the app's local backend. The terminal WebSocket, however, was opened against the server (pluginWsUrl(..., { origin })), so the SSH session lives there. The local backend finds no session for the instanceId, has no SFTP connection to store the image through, and selectImageStorageMode returns unavailable.

The app's log shows Terminal image upload received for every attempt; the server's log shows none.

Fix

Send the upload to the backend that holds the session: usePluginApiFor("remote") when sessionOriginRef.current is "remote", the local client otherwise. The choice is a small pure helper, selectImageUploadApi, next to buildImageUploadFormData.

Why this doesn't change other cases

  • Web and mobile: the origin is always "local" outside Electron, and usePluginApiFor returns the normal client there anyway.
  • Desktop, session started on this computer: the origin is "local", so the upload goes where it went before.
  • Desktop, session started on the server: this is the only case that changes, and it could not work before.
  • sessionOriginRef is set on every connect, before the WebSocket opens, so a reconnect keeps it in step with the session.
  • The image storage settings are now read by the server that does the storing, which is the one whose SFTP session and local mapping apply.

Testing

  • npm run typecheck, npm run format:check on the changed files, npm run validate, npm run build: pass
  • npm test: 678 passed (676 before, plus 2 new for selectImageUploadApi)
  • By hand: desktop app 26.11.0 (macOS, full build) linked to a 26.11.0 server, connections started on the server. Before: the 503 above on every paste. With the same change applied to the app's bundled frontend.js: the image is stored on the host and its path is typed at the prompt.

I left CHANGELOG.md alone because main has no section for the next version yet. Suggested entry under Fixed: "Pasting an image in the desktop app works when the session was started on the linked server".

🤖 Generated with Claude Code

LukeGus and others added 3 commits November 10, 2026 15:07
In the desktop app, a terminal whose session was started on the linked
server still posted /image-upload to the app's local backend. That backend
has no such session, so it had no SFTP connection to store the image
through and answered 503 IMAGE_STORAGE_UNAVAILABLE.

Send the upload through usePluginApiFor("remote") when the session's
origin is remote, and through the local client otherwise.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
@termix-triage-bot

termix-triage-bot Bot commented Nov 10, 2026 •

Copy link
Copy Markdown

AI review | Looks safe to merge

The PR fixes a desktop app bug by routing terminal image uploads to the backend that holds the SSH session instead of always using the local backend. The change is minimal, well-tested, and introduces no security risks or rule violations.

Reviewed 981163e. AI can be wrong, a maintainer still decides. Comment /termix review to run it again.

@LukeGus
LukeGus changed the base branch from main to dev-1.4.1 November 16, 2026 23:18

@LukeGus LukeGus left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks!

@LukeGus
LukeGus merged commit 7d461e9 into Termix-SSH:dev-1.4.1 Nov 16, 2026
4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants