Skip to content

Persistent commands: no way to programmatically select/deselect from the backend #2786

@nzjrs

Description

@nzjrs

When a command has persistent: True, its selected/deselected state is managed entirely by aiui frontend Recoil atom (PersistentCommand) with no corresponding backend API. This means the backend can register persistent commands via set_commands, but cannot control whether they appear visually selected.

My use case is to enter a sticky conversation mode text command (e.g. /command argument) rather than exclusively clicking the button. At the moment the button stays visually unselected even though the mode is active. Conversely, if the backend exits the mode programmatically, there is no way to deselect the button in the UI. The symmetric gap exists on the frontend side, when a user deselects a persistent command by clicking the X, Chainlit toggles the Recoil atom locally but sends no socket event to the backend, so the server has no way to know the user exited the mode.

A couple of ideas - a select_command socket event (backend to frontend, accepting a command ID or null to clear) and a command_deselected event (frontend to backend, fired when the user toggles off a persistent command would close both gaps and make persistent commands usable for modal workflows where entry/exit can happen through multiple paths.

Note that I already use window messages to communicate the sticky changes, but have to go via __reactProps$ to get to the onClick

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions