Termix icon indicating copy to clipboard operation
Termix copied to clipboard

Linked desktop app overwrites hosts' own plugin settings on the server when a plugin starts on it

Open Li-Lee opened this issue 2 weeks ago • 5 comments

What happened?

When a plugin with host settings starts on a desktop app linked to a server, the app sends every host back to the server with that plugin's built-in defaults in place of the values the host sets itself, and the server saves them. Nobody changed anything.

I hit this with Tmux Monitor when a desktop app linked to my server ran the full build for the first time, so Tmux Monitor started on it. Within seconds every host on the server had Tmux Monitor off and mouse on as its own values (defaultOverrides["tmux-monitor"] = ["enableTmuxMonitor", "mouseEnabled"]). Before that, Tmux Monitor was on for every host and the Macs had mouse off. Auto tmux and Tmux Monitor stopped working on every host, for every client (web, mobile, other desktops), with no warning, and I had to put each host back by hand.

Steps to reproduce

  1. On the server, with Sync and Tmux Monitor running, give host A its own "Tmux Monitor enabled = on", and give host B its own "Tmux Monitor enabled = on" and "mouse = off".
  2. Link a desktop app that doesn't have Tmux Monitor (for example a build other than the full one) to that account and let it sync. Nothing changes on the server.
  3. Start the app with Tmux Monitor (for example the full build) and let it sync.
  4. On the server, host A has Tmux Monitor off, and host B has Tmux Monitor off and mouse on, still as their own values.

What did you expect?

The server keeps the hosts' settings, and the app shows the server's values for the plugin that just started.

Termix version

Desktop app 26.11.2 linked to a 26.11.0 server. Also reproduced on dev-26.11.3 (3d398695).

Platform

Desktop app (macOS)

Server install

Docker

Environment

Desktop app linked to the server with the Sync plugin. Plugin versions in my reproduction: Sync 1.3.0, Tmux Monitor 1.3.0. SQLite on both sides.

Logs

[WARN] [🔄] A pushed sync change was not fully applied [op:sync_push,user:…]
[WARN] [🔄] A pushed sync change was not fully applied [op:sync_push,user:…]

Anything else?

This is in Termix's own sync code (src/backend/sync/), not in the Sync or Tmux Monitor plugin.

Why it happens

  1. While a plugin isn't running on the desktop, the desktop drops that plugin's values from every host it pulls: importHostPluginSettings (src/backend/sync/host-plugin-settings.ts) only writes plugins from hostSettingsPlugins(), which lists running plugins only.
  2. When the plugin starts, the desktop has nothing stored for it, so for the keys a host sets itself, exportHostPluginSettings sends the plugin's built-in defaults.
  3. The export covers running plugins only, so the plugin starting changes every host's exported row. The Sync engine compares its hash with the last synced one, treats the difference as a local edit, and pushes every host. The server's copy hasn't changed, so the push is accepted.
  4. On the server, afterWrite of the hosts entity (src/backend/sync/entities.ts) writes the pushed values for the keys the pushed host lists as its own in defaultOverrides, so the built-in defaults replace them. Keys a host takes from "My defaults" aren't listed there, so they stay as they were.

How I reproduced it

On one Mac, a server and a desktop app backend (ELECTRON_EMBEDDED=true) built from dev-26.11.3 at 3d398695, each with its own data folder, port and bundled-plugins folder, with the plugin versions docker/bundled-plugins.json pins (Sync 1.3.0, Tmux Monitor 1.3.0, SSH Terminal 1.4.1). The server has Tmux Monitor, "My defaults" with Tmux Monitor on, and two hosts. The desktop links (merge) without Tmux Monitor, then restarts with it.

Setup Hosts' own values on the server before On the server after the desktop started Tmux Monitor
1 (the steps above) A: Tmux Monitor on. B: Tmux Monitor on, mouse off A: Tmux Monitor off. B: Tmux Monitor off, mouse on
2 A: none. B: mouse off. Both take Tmux Monitor on from "My defaults" A: unchanged. B: mouse on, Tmux Monitor still on from "My defaults"

In both setups, linking changed nothing on the server, and afterwards the desktop showed the same values as the server. Nothing was logged in setup 1. In setup 2 the server logged the warning in Logs once per host, and the desktop listed both hosts under Sync conflicts, although host B's mouse had already been overwritten on the server.

Proposed fix

I've tested the following fix and I'm happy to open a PR against dev-26.11.3 if you'd like it, or to change the approach first. On a linked desktop:

  • The values the server sends for a plugin that isn't running on the desktop are kept as they came (in a new desktop-only table), sent back unchanged with the host, and written to the plugin when it starts.
  • For a running plugin, a key the desktop holds nothing for is left out of the host instead of sent as the plugin's default. This also covers desktops that already lost the values.

A host's row then doesn't depend on which plugins run on the desktop, so a plugin starting is no longer an edit. The server side is unchanged. With the fix, in both setups the server's hosts stay as they were and aren't written to, and no warnings or conflicts come up when the plugin starts. The same holds when the desktop was linked without the fix and then updated (checked with setup 1).

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 20 '26 03:11 Li-Lee

Auto-triage

Linking a desktop app with a newly enabled plugin overwrites existing host-specific plugin settings on the server with the plugin's built-in defaults.

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

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

termix-triage-bot[bot] avatar Nov 20 '26 03:11 termix-triage-bot[bot]

Thanks for the very clear write up and repro. Your fix sounds right to me: keeping the server's values for plugins that aren't running on the desktop, and leaving out keys the desktop holds nothing for, so a plugin starting is never an edit. Please open the PR against dev-26.11.3 with a test for both setups and I'll review it.

LukeGus avatar Nov 20 '26 03:11 LukeGus

Closing this since there was no reply to the question above. Reply any time and the issue will be reopened.

termix-triage-bot[bot] avatar Nov 28 '26 02:11 termix-triage-bot[bot]

The fix is in #1960, which is approved and waiting to be merged.

Li-Lee avatar Nov 29 '26 00:11 Li-Lee

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]