Skip to content
Written for developers. Just using FluxPlugs? Go to the user guide.

Native dialogs and actions

Use the ui capability to add host-rendered dialogs, text panels, notifications, overlays, and composer attachment-menu actions. Core owns labels, focus management, scrolling, cancellation, and theme styling. A dialog’s header shows your title and, under it, the plugin’s name from the manifest, so the user always knows which plugin is asking.

The following snippet registers an action and stores its disposer in the lifecycle cleanup array:

cleanup.push(
await api.ui.registerAttachmentAction(
{ id: "greeting", label: "Show greeting" },
async () => {
const values = await api.ui.openDialog(
{
title: "Greeting",
description: "Choose the text to display.",
submitLabel: "Show",
sections: [
{
title: "Message",
controls: [
{
key: "message",
label: "Message",
kind: "text",
maxLength: 100,
},
],
},
],
},
(values) =>
typeof values.message === "string" && values.message.trim()
? undefined
: "Enter a message",
);
if (values && typeof values.message === "string") {
await api.ui.notify(values.message);
}
},
),
);

The validator returns an error string to keep the dialog open, or undefined to accept. The dialog promise resolves to values or undefined on dismissal. Act after successful completion; do not send messages or save data in the validator.

Control kinds are text, url, number, textarea, checkbox, and password. A control’s optional value fills it in: text or a number, or true to check a checkbox. Keys must be unique.

A password control masks what the user types, for an API key or token. It is never filled in, so a password control with a value is refused, and the browser doesn’t suggest, correct or remember its text. Save what the user enters with storage secrets. Sections can use repeatKey and maxRows for up to 25 repeated rows.

Use registerPanel for plain text, notify for a concise notice, and setOverlay for bounded geometry with optional action text. setOverlay(null) removes an overlay.

An attachment action can specify submenu: { id, label }. Groups are plugin-scoped and disappear when their last action is removed. Composer actions differ from posted-file actions.

ui.pickEmoji() opens Fluxer’s own emoji picker, from the message box’s Emojis button, and resolves with what the user picks: the character for a unicode emoji, in the skin tone they chose, or name:id for a custom community emoji. Both are ready for messages.react. It resolves to undefined when the user closes the picker. Fluxer does nothing with the pick itself: no reaction is added and nothing is typed.

const emoji = await api.ui.pickEmoji();
if (emoji) await api.ui.notify(`You picked ${emoji}`);

A channel must be open in Fluxer, even behind its settings, and only one picker can be open at a time; otherwise the call fails with emoji_picker_unavailable or emoji_picker_busy. The picker offers the custom emoji Fluxer allows in the open channel. Unicode emoji are looked up by name in the emoji list inside Fluxer’s own app code; if FluxPlugs can’t read that list, or can’t tell which emoji was clicked, the call fails with emoji_data_unavailable or emoji_unreadable. Offer a typed fallback for those cases.

Catch operation failures in your callback and use a short user-facing error. Dispose registrations in stop; do not retain callbacks from an old instance.

FluxPlugs is an independent project, not affiliated with or endorsed by Fluxer.