Skip to Content
sdeck docs

Plugin settings and connections

Settings of the plugin itself, secrets, commands and connections.

settings on the plugin itself (an address, a token) appear in its Settings dialog. A setting.secret is stored outside the config, so sharing a config never shares passwords. Commands (plugin.command) are buttons there: a sign-in, a connection test. A command that returns a URL opens it in the browser. context.status("Connected", "ok") shows a line under the plugin. To act on changed settings, call onSettingsChange(context, () => connection.restart()) in activate; it returns how to stop.

Connections to other programs should use ManagedConnection: it opens only while something needs it, reconnects when it drops, and waits for a fix after a PermanentError (a wrong password):

const connection = new ManagedConnection({
  open: async (lost, signal) => {
    const client = await connect(address, { signal });
    client.on("close", () => lost(new Error("closed")));
    return { value: client, close: () => client.close() };
  },
  onStatus: (state, error) =>
    plugin.context?.status(error?.message ?? state, error ? "error" : "ok"),
});

// In run: await connection.with((client) => client.send("hello"));