Termix icon indicating copy to clipboard operation
Termix copied to clipboard

Toasts that plugins show with `sonner` never appear since 26.11.2 (no Toaster in plugin frames)

Open Li-Lee opened this issue 1 week ago • 2 comments

What happened?

Since 26.11.2, a plugin's frontend runs in sandboxed frames. When a plugin imports toast from sonner and calls it there, nothing appears and nothing is logged. Toasts from the SDK's useToast() still show.

I noticed it with SSH Terminal. After pasting an image, the "Image uploaded: " toast I used to see on 26.11.0 is gone. Its error toasts are gone too, so when something fails it looks like nothing happened. For example, the Paste image button in #1951 "does nothing", but SSH Terminal 1.5.0 does call toast.error("This browser cannot read images from the clipboard") there. The toast just isn't shown.

Steps to reproduce

  1. Open a terminal to any host.
  2. In the bar under the terminal, click Image, then Paste image. A frame has no navigator.clipboard.read, so SSH Terminal shows an error toast right away.
  3. No toast appears.

Or in DevTools, with the console's context set to the SSH Terminal frame:

(await import("sonner")).toast.error("from sonner")  // nothing appears
(await import("@termix-ssh/plugin-sdk/frontend")).useToast().error("from useToast")  // appears

What did you expect?

The toast appears, as it did before 26.11.2 and as useToast() toasts do.

Termix version

First noticed on 26.11.2 (Docker server and macOS desktop app). Reproduced on a build of b4a75bd2 (newer than 26.11.3) with its bundled SSH Terminal 1.5.0. 26.11.3 has the same frame code.

Platform

Web browser

Server install

Docker

Environment

Same in the web UI and in the macOS desktop app. The reproduction below used a web build in headless Chromium.

Logs

Nothing is logged. The toast does reach the frame's copy of sonner. In the SSH Terminal frame, toast.getHistory() returns:
error: This browser cannot read images from the clipboard

Anything else?

Why it happens

sonner is one of the modules the import map shares (SHARED_VENDORS in scripts/lib/plugin-import-map.mjs). In a frame it resolves to the frame runtime's own copy (/plugin-assets/_runtime/<hash>/shared/sonner.js), and nothing in the frame mounts a Toaster for that copy. So a toast is added to that copy's state and never drawn. Core mounts a Toaster in src/main.tsx, on the full-screen app's sign-in screen and in frame-host.tsx (the mobile app's web view), but not in a sandboxed frame. useToast() works because the frame bridge hands it to the shell (call("toast"), shown by frame-connection.ts).

The plugin guide points both ways. It lists sonner under "Shared from Termix and never bundled", and its Frames section says toasts "go through the shell".

Which plugins

15 bundled plugins import toast from sonner and run in frames (none of them has ui:layout, ui:theme or sync:provide): Alerts, Credential Tools, Docker, File Manager, Host Metrics, Import/Export, Remote Desktop, Snippets, SSH Terminal, SSO, Telemetry, TOTP, Tunnels, WebAuthn and Workspaces. Together that's about 500 toast calls. I only tested SSH Terminal, but the others use the same import. #1941 also mentions no progress or error toast for File Manager downloads, and File Manager shows download progress with toast.loading from sonner, so that part may be this too. Layouts, themes and Sync run in the page, so their toasts work.

How I checked

A web build of b4a75bd2 with its bundled plugins, driven by headless Chromium, which counted every [data-sonner-toast] added to the page and to every frame:

Step Toasts shown
Sign in "Login successful"
Image > Paste image in SSH Terminal none. The frame's sonner history has the error, and the frame has no [data-sonner-toaster]
toast.error() from sonner in the same frame none
useToast().error() in the same frame shown, bottom right

Ways to fix it

I can see three, and I'd rather ask which one you want before writing any of them:

  1. Core passes a frame's sonner toasts to the shell. One change fixes every plugin. But the plugins use more than a message. File Manager has loading toasts it updates by id and dismisses, cancel and action buttons, and JSX content. Docker and Snippets use action buttons, and SSH Terminal sets duration and description. Buttons and JSX can't cross the frame as they are, so this needs a rule for what gets through.
  2. Each view frame draws its own toasts. Mount a Toaster in view frames. Every option keeps working, but a toast shows inside the frame's area (fine for a tab, cramped in a small panel or slot), and toasts from the hidden background frame still don't show.
  3. Plugins switch to useToast(). No core change, but 15 plugins to update. ToastApi takes only a message, so loading toasts, buttons, duration and description are lost unless the SDK gets options.

I'm happy to open a PR for whichever you pick.

Before you submit

  • [X] I searched open and closed issues and this is not a duplicate
  • [X] I am on the latest version, or I said which version I am on

Li-Lee avatar Nov 22 '26 21:11 Li-Lee

Auto-triage

Toasts generated by plugins using the shared sonner library do not appear in sandboxed frames because the core does not mount a Toaster component in those frames. This affects multiple bundled plugins including SSH Terminal and File Manager.

Field Value
Type Bug
Difficulty 3/5 (Moderate)
Priority Medium

A maintainer will take a look. If anything above looks wrong, just say so.

termix-triage-bot[bot] avatar Nov 22 '26 21:11 termix-triage-bot[bot]

This was fixed in v26.12.0. Update Termix to the latest version to get it. Thanks for the report!

termix-triage-bot[bot] avatar Dec 02 '26 02:12 termix-triage-bot[bot]