Skip to content

feat: add disabled parameter to mo.ui.chat#8214

Merged
mscolnick merged 1 commit intomarimo-team:mainfrom
AhmadYasser1:feat/chat-disabled-prop
Feb 9, 2026
Merged

feat: add disabled parameter to mo.ui.chat#8214
mscolnick merged 1 commit intomarimo-team:mainfrom
AhmadYasser1:feat/chat-disabled-prop

Conversation

@AhmadYasser1
Copy link
Contributor

Summary

Adds a disabled parameter to mo.ui.chat that prevents user interaction when set to True. Uses the HTML inert attribute on the form container so all child inputs, buttons, and links are automatically non-interactive.

Closes #3823

Test Plan

  • Added Python test for disabled parameter serialization
  • Visual: opacity-50 cursor-not-allowed styling when disabled

Add a `disabled` parameter that prevents user interaction with the chat
input. When `disabled=True`, the form area uses the HTML `inert`
attribute to block all input, with reduced opacity to visually indicate
the disabled state.

This enables patterns like conditionally disabling the chatbot until
an API key is provided via another input element.

Fixes marimo-team#3823
@mscolnick
Copy link
Contributor

This looks good, here is a screenshot
image

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Adds a disabled parameter to mo.ui.chat so the chat input area can be made non-interactive (intended for gating interaction until prerequisites like API keys are provided), propagating the flag through Python serialization into the frontend chat plugin.

Changes:

  • Add disabled: bool = False to the Python ui.chat API and serialize it into component args.
  • Extend the chat plugin schema/props to accept disabled on the frontend.
  • Disable chat form interaction in the UI (via inert) and add a Python test for the new arg.

Reviewed changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated 2 comments.

File Description
tests/_plugins/ui/_impl/chat/test_chat.py Adds coverage for disabled arg serialization into _component_args.
marimo/_plugins/ui/_impl/chat/chat.py Introduces disabled parameter in the ui.chat constructor and passes it to frontend args.
frontend/src/plugins/impl/chat/ChatPlugin.tsx Adds disabled to plugin data schema and forwards it to the Chatbot component.
frontend/src/plugins/impl/chat/chat-ui.tsx Uses disabled to short-circuit submit and applies inert + disabled styling on the form.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines 451 to +474
@@ -462,7 +466,12 @@ export const Chatbot: React.FC<Props> = (props) => {
resetInput();
}}
ref={formRef}
className="flex w-full border-t border-(--slate-6) px-2 py-1 items-center"
// biome-ignore lint/a11y/useSemanticElements: inert is used to disable the entire form
inert={props.disabled || undefined}
className={cn(
"flex w-full border-t border-(--slate-6) px-2 py-1 items-center",
props.disabled && "opacity-50 cursor-not-allowed",
)}
Copy link

Copilot AI Feb 9, 2026

Choose a reason for hiding this comment

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

Relying on the HTML inert attribute alone means the “disabled” behavior may be incomplete in environments where inert isn’t supported, and it also removes the form controls from the accessibility tree (screen readers won’t discover a disabled input). Consider also wiring props.disabled into the actual control disabling (e.g., disabled/isDisabled props on the send button, attachment button, PromptInput/editor) and/or using a <fieldset disabled> approach with appropriate aria-disabled so the UI remains discoverable but non-interactive.

Copilot uses AI. Check for mistakes.
}}
ref={formRef}
className="flex w-full border-t border-(--slate-6) px-2 py-1 items-center"
// biome-ignore lint/a11y/useSemanticElements: inert is used to disable the entire form
Copy link

Copilot AI Feb 9, 2026

Choose a reason for hiding this comment

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

The biome-ignore lint/a11y/useSemanticElements suppression doesn’t appear to match what’s happening here (a <form> is already a semantic element, and inert isn’t related to that rule). Please remove the suppression or replace it with the specific rule that actually triggers, so real a11y issues aren’t accidentally masked.

Suggested change
// biome-ignore lint/a11y/useSemanticElements: inert is used to disable the entire form

Copilot uses AI. Check for mistakes.
@mscolnick mscolnick added the enhancement New feature or request label Feb 9, 2026
@mscolnick mscolnick merged commit a80b785 into marimo-team:main Feb 9, 2026
34 of 49 checks passed
@AhmadYasser1 AhmadYasser1 deleted the feat/chat-disabled-prop branch February 9, 2026 21:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Support disabling mo.ui.chat input

3 participants