Skip to content

fix variants for toast#9230

Merged
Light2Dark merged 1 commit intomainfrom
sham/toast-fix
Apr 16, 2026
Merged

fix variants for toast#9230
Light2Dark merged 1 commit intomainfrom
sham/toast-fix

Conversation

@Light2Dark
Copy link
Copy Markdown
Collaborator

@Light2Dark Light2Dark commented Apr 16, 2026

📝 Summary

Code_mode would call toast with success kind, which is not supported at the moment. So, it would choose the wrong styles.

mo.status.toast(
    title="Claude reporting for duty! 🧑‍🍳",
    description="Ready to pair on the kitchen sink ✨ — what shall we cook up?",
    kind="success",  # <---- Not supported
)

This resolves to choose the default style and adds some better typing.

📋 Pre-Review Checklist

  • For large changes, or changes that affect the public API: this change was discussed or approved through an issue, on Discord, or the community discussions (Please provide a link if applicable).
  • Any AI generated code has been reviewed line-by-line by the human PR author, who stands by it.
  • Video or media evidence is provided for any visual changes (optional).

✅ Merge Checklist

  • I have read the contributor guidelines.
  • Documentation has been updated where applicable, including docstrings for API changes.
  • Tests have been added for the changes made.

Copilot AI review requested due to automatic review settings April 16, 2026 18:03
@vercel
Copy link
Copy Markdown

vercel Bot commented Apr 16, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
marimo-docs Ready Ready Preview, Comment Apr 16, 2026 6:03pm

Request Review

@Light2Dark Light2Dark added the bug Something isn't working label Apr 16, 2026
@Light2Dark Light2Dark requested a review from kirangadhave April 16, 2026 18:05
@Light2Dark Light2Dark enabled auto-merge (squash) April 16, 2026 18:05
Copy link
Copy Markdown
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

Fixes toast styling selection by ensuring unsupported toast variant values (e.g. "success") fall back to the default toast styles instead of producing an unstyled/incorrect toast.

Changes:

  • Extracted toast variant class definitions into a shared VARIANT_CLASSES constant and derived ToastVariant from it.
  • Added a runtime isToastVariant guard and used it to resolve invalid variant values to "default" before passing into cva.

);

function isToastVariant(value: unknown): value is ToastVariant {
return typeof value === "string" && value in VARIANT_CLASSES;
Copy link

Copilot AI Apr 16, 2026

Choose a reason for hiding this comment

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

isToastVariant uses value in VARIANT_CLASSES, which is true for inherited Object prototype keys (e.g. "toString"). That makes the type guard unsound and can result in non-string classNames being passed into cva (e.g. Object.prototype.toString), producing broken class output. Use an own-property check instead (e.g. Object.prototype.hasOwnProperty.call(VARIANT_CLASSES, value) or an equivalent safe helper).

Suggested change
return typeof value === "string" && value in VARIANT_CLASSES;
return (
typeof value === "string" &&
Object.prototype.hasOwnProperty.call(VARIANT_CLASSES, value)
);

Copilot uses AI. Check for mistakes.
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

We should do something like !!VARIANT_CLASSES[value]

Copy link
Copy Markdown
Member

@kirangadhave kirangadhave left a comment

Choose a reason for hiding this comment

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

🚀 approving, but we should address the copilot suggestion

);

function isToastVariant(value: unknown): value is ToastVariant {
return typeof value === "string" && value in VARIANT_CLASSES;
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

We should do something like !!VARIANT_CLASSES[value]

@Light2Dark Light2Dark merged commit dbd8158 into main Apr 16, 2026
37 of 39 checks passed
@Light2Dark Light2Dark deleted the sham/toast-fix branch April 16, 2026 18:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants