{% extends "layouts/workspace_settings.html" %} {% load static %} {% block title %}Inbox rules · DemandTrail Messaging{% endblock %} {% block content_wrap %}{% endblock %} {% comment %} `editorOpen` hides the header's primary while the editor is on screen: the editor carries its own "Save rule" primary, and two orange buttons on one page is two calls to action. It flips on the htmx swap that fills #inbox-rule-editor, which is the only signal there is — that partial arrives long after Alpine booted. **And it has to flip back, which is the whole reason the second handler exists.** inbox:rule_save answers with toast_response — a 204 — so htmx swaps nothing and the saved form just sits there. A flag set on open and never reset left the header button hidden for the rest of the session, with no way to start a second rule short of reloading. Two guards on that handler, both load-bearing. `bbChanged` rather than `detail.successful`, because a *refused* save is also a 204 and closing the editor on one would throw away the correction the operator is part-way through — only the success path sets inboxRulesChanged. And `$refs.editor.contains(...)`, because this listener sees every htmx request in the page: without it, deleting some other rule from its row menu would wipe the editor somebody is typing in. {% endcomment %} {% block content %}
A rule reads every message that arrives and files, assigns or closes the conversation it belongs to. It runs before any flow replies, and it keeps running even where somebody has paused automation on a thread.