Skip to content

fix(plugins): tell the user when a plugin is quarantined - #396

Merged
fcoury merged 2 commits into
mainfrom
fix/plugin-quarantine-visibility
Oct 15, 2026
Merged

fcoury merged 2 commits into
mainfrom
fix/plugin-quarantine-visibility

Conversation

@fcoury

@fcoury fcoury commented Oct 15, 2026 •

Copy link
Copy Markdown
Contributor

When Red quarantined a plugin, the only record was an INFO line in red.log. A picker the plugin had open stayed on screen with no working handlers. The plugin's commands answered unknown command. A stopped plugin looked like a crash or a missing command, which is how #388 was reported.

Fixes #392.

What changes

  • Every quarantine publishes an error notice attributed to the plugin, for example lsp_symbols: stopped for this session: error[HUSK-R0001]: Husk heap byte limit exceeded …. It needs attention until acknowledged and is recorded in :messages. The details include the stage, the plugin's source path, the full diagnostic, and how to recover: restart Red, or save a fix if you're developing the plugin.
  • Pickers and composers the plugin owned are closed. Red already did this for JSON-RPC pickers, but Husk callback dialogs stayed open after their handlers were dropped. The registry now collects the plugin's open dialogs before unloading it and passes them with the new PluginRequest::PluginQuarantined.
  • Commands explain why they're unavailable. Before unloading a plugin, the registry records its registered Husk commands, its JSON-RPC commands, and its onCommand: activation commands, each with its scope. Invoking one, from a key binding or typed as :Command, shows `LspWorkspaceSymbols` is unavailable because plugin `lsp_symbols` was stopped: …. The message leads the bottom line without adding to the messages that need attention. A global command's key binding still reaches it while a panel has focus.
  • Metadata failures found when plugins are registered happen before a runtime exists. They're now reported the first time the registry initializes.
  • No repeated notices for one cause. A dependency cascade and the dependent's own revalidation can quarantine the same plugin twice in one reload. A repeat with the same stage and diagnostic doesn't produce a second notice. Repeated notices for one plugin also share a notification key, so they're grouped into one entry.
  • The log line is now WARN, through a new log_warn! macro. The logger already supported levels, but log! always wrote INFO.

Not in this PR

  • Quarantine state in red plugin list. That command runs in its own process and can't see the editor session's state. It needs a separate design, such as an in-editor plugin view.
  • The JSON-RPC activation timeout from the Plugin quarantine is silent: the first command does nothing, later ones say "unknown command" #392 repro wasn't tested end to end. It goes through the same quarantine path, so the notice and the command explanation should apply. But I haven't checked how the first :Silent behaves while activation is still waiting for its 5-second timeout.

How to Test

  1. Save this plugin as crashy.hk. Typing in its picker divides by zero:

    pub fn activate() {
        red::add_command("CrashDemo", open);
    }
    
    fn open() {
        red::execute("OpenPicker", "Crash demo", [], PickerOptions {}, PickerHandlers {
            query: crash,
        });
    }
    
    fn crash(query: String) {
        red::execute("Print", 1 / 0);
    }
  2. Add it to the [plugins] table of your config.toml, as crashy = "/absolute/path/to/crashy.hk", and start Red.

  3. Run :CrashDemo, then type any character in the empty picker. The picker closes, and the bottom line shows × crashy: stopped for this session: error[HUSK-R0001]: integer division by zero with 1 needs attention.

  4. Open :messages and select the notice. Its details show Stage: runtime, the plugin's source path, the diagnostic pointing at line 12 of crashy.hk, and the recovery text. red.log in the config directory has a [WARN] Plugin crashy quarantined during runtime line.

  5. Run :CrashDemo again. The bottom line shows `CrashDemo` is unavailable because plugin `crashy` was stopped: …, and the badge still reads 1 needs attention.

  6. Run :BufferPicker. Other plugins are unaffected, so the buffer picker opens normally.

These automated tests cover the same cases: quarantine_notice_names_the_dialogs_its_plugin_left_open, lazy_command_keeps_explaining_its_failed_activation, quarantined_commands_keep_their_registered_scope, metadata_quarantine_from_registration_is_reported_once_at_startup, plugin_quarantine_closes_only_its_dialog_and_reports_the_plugin, and routine_foreground_warning_leads_without_needing_attention.

Quarantining a plugin only wrote an INFO line to red.log. Its open
pickers stayed on screen without working handlers, and its commands
answered "unknown command", so a stopped plugin looked like a crash
or a missing command.

Every quarantine now publishes an error notice from the plugin, with
the stage, source and full diagnostic in its details, and closes the
pickers and composers the plugin owned. Commands of a quarantined
plugin, including lazily declared ones, explain that it was stopped
and why. Metadata failures found while registering plugins are
reported at startup, a repeated quarantine with the same cause is not
announced twice, and the log line is now a WARN.

Fixes #392
@fcoury-oai

Copy link
Copy Markdown
Collaborator

@codex review

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 15, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-10-15T16:23:33.488142Z 0991362 Manual request
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 099136257f

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread src/plugin/registry.rs Resolved
Running a command of a quarantined plugin printed its explanation as a
routine warning, which the plugin's retained error outranked on the
bottom line, so the explanation only appeared in :messages. It now leads
the bottom line as quiet foreground feedback, without adding another
message that needs attention, and names the command without its
arguments.

Quarantine also dropped each command's scope, so a global command's key
binding was rejected while a panel had focus and never reached the
explanation. The registry now keeps the registered scope of quarantined
commands, and declared activation commands keep the panel reach they had
while pending.
@fcoury
fcoury merged commit 15d26c1 into main Oct 15, 2026
19 checks passed
@fcoury
fcoury deleted the fix/plugin-quarantine-visibility branch October 15, 2026 16:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Plugin quarantine is silent: the first command does nothing, later ones say "unknown command"

2 participants