# Hosts, server and sync

> Run desktop sessions on a zidane-server, lend this computer to a server as a machine, and sync settings to it.

A host runs your sessions. This computer runs them inside the app, or in the [daemon](https://zidane.si/docs/daemon.md) when it is on. With remote hosts on, the app also lists sessions from the [`zidane-server`](https://zidane.si/docs/server.md) instances you save ([what runs where](https://zidane.si/docs/server-clients.md)).

## Remote hosts

Remote hosts are off by default. Settings › Advanced › Experimental › Remote hosts ([details](https://zidane.si/docs/server-clients.md#turn-remote-hosts-on)) adds Hosts under Settings › Accounts. The sidebar groups sessions by host once you save a server.

### Add a server

1. On the server, run `zidane-server token create --name laptop`.
2. In Settings › Accounts › Hosts › Add a server, enter the server's URL (`wss://zidane.example.com`) and paste the token (`zds_…`).
3. Wait while the app tests the connection. If the test passes, the app saves the server.

Scopes and revoking: [tokens](https://zidane.si/docs/server-security.md#tokens). The TUI reads the same saved servers.

Test is a button on the server's card. Rename, Change URL and Remove are in its ⋯ menu. The card says **Chat access** or **Admin access**. With a `chat` token, the parts that need `admin` show greyed out, with an **Admin only** tooltip. **Get admin** shows the server's own command for an admin token (its binary, its user and its data dir). Run it on the server, paste the token it prints, and the app saves it in place of the old one.

| On a saved server | Does |
| - | - |
| Test | Checks the connection and shows the server's name and version |
| Rename | Changes the name shown in the sidebar |
| Change URL | Points the server at a new address (a new port, a new domain). Keeps its token, and saves only once the same server answers there. Its sessions stay with it. |
| Remove | Deletes the saved URL and token from this computer, after a confirmation. Its sessions stay on the server. Its open chats close, and its pending approvals and questions drop. |
| Machines | Lends this computer to the server, or uses the server as a machine |
| Sync | Sends this computer's settings to the server |

![Settings, Hosts tab: This computer, and Add a server.](https://zidane.si/captures/settings-hosts-light.webp)

### Sessions on a server

A new chat picks its host in the composer's Runs on menu (This computer by default), then a server folder among its workspace roots and an environment the server offers ([start a new chat](https://zidane.si/docs/desktop-composer.md#start-a-new-chat)).

A server session uses the server's folders and provider keys ([what runs where](https://zidane.si/docs/server-clients.md#desktop-app)) and keeps running after you close the window. Files, Diffs and the terminal show the server's side. New terminal on this Mac opens a local terminal. To edit the server's settings, pick it in the host menu at the top right of Settings ([switch hosts](https://zidane.si/docs/desktop-settings.md#switch-hosts)). Rows synced from this computer carry a marker.

A session can run on this computer, in a worktree or on a machine, another computer that runs its commands. To move it, open the session's menu in the sidebar or the session header. Then choose Move to… ([move a session](https://zidane.si/docs/servers-and-machines.md#move-a-session)). A session in a worktree can also remove that worktree when it leaves. To do that, tick Remove the old worktree if it has no uncommitted changes.

## Banners

These replace the composer while they apply:

| Banner | When | What you can do |
| - | - | - |
| *Server* is offline | The session's server cannot be reached. The last known transcript stays readable. | Retry reconnects now instead of at the next attempt. |
| *Server* refused this computer's token | The token was revoked or changed | Update the token in Settings › Accounts › Hosts |
| A different server answers | The server was reinstalled at the same address | Remove it and add it again |
| *Server* was removed | You removed the server while the session was open | Nothing. The session is gone from this computer. |
| Waiting for *machine* | The run waits for a machine that is offline | Nothing. The run continues when the machine reconnects. |

## Machines

A [machine](https://zidane.si/docs/server-clients.md#machines) runs commands and edits files for a server without seeing its sessions, settings or keys. From a server's Machines in Settings › Accounts › Hosts:

| Action | Does |
| - | - |
| Share this computer | Names this computer, picks the folders that the server can use, and creates the machine token on the server |
| Use *server* as a machine | Shown when the server offers itself. It appears as `local@<server>`. |
| Add a machine | Asks for an optional name for the machine. If you leave it empty, the machine gives its own name. Then it shows a join command, `zidane machine setup --join <server url>#<code>`, with a copy button. Run the command on the new computer. The code in it (the join code) works once, until the time shown. Needs an admin token on the server: with a `chat` token it shows greyed out, **Admin only**. |
| The machine list | Each machine with "online" or "offline since 14:32", its version, its GPUs, its folders and last contact. A version that differs from the main server's shows a warning. Forget removes one, after a confirmation. |

## Settings sync

Sends this computer's settings to one server, one way.

1. In Settings › Accounts › Hosts, open the server's Sync.
2. Pick a mode: Off (the default), Import once, or Keep in sync.
3. Pick the categories to send. Provider API keys ask for a confirmation, one key at a time.

What each mode and category sends: [settings sync](https://zidane.si/docs/server-clients.md#settings-sync).

## Reference

- [Server](https://zidane.si/docs/server.md): what `zidane-server` is, then [installing](https://zidane.si/docs/server-install.md), [deploying](https://zidane.si/docs/server-deploy.md) and [securing](https://zidane.si/docs/server-security.md) it.
- [Server clients](https://zidane.si/docs/server-clients.md): what the desktop app keeps local and what runs on the server.
- [`zidane/ipc/remote`](https://zidane.si/docs/reference/ipc-remote.md): the client a window uses to reach a server.
