Skip to content

feat: add Spinner.done() for checkmark transition#9946

Closed
allin2 wants to merge 3 commits into
marimo-team:mainfrom
allin2:feat/spinner-done-method
Closed

feat: add Spinner.done() for checkmark transition#9946
allin2 wants to merge 3 commits into
marimo-team:mainfrom
allin2:feat/spinner-done-method

Conversation

@allin2

@allin2 allin2 commented Jun 21, 2026

Copy link
Copy Markdown

This pull request was authored by a coding agent.

Description

Adds Spinner.done(), which transitions a spinner from its loading animation to a checkmark. This resolves two TODOs by @akshayka:

  1. Add a done() method that turns the spinner into a checkmark.
  2. Transition a retained spinner to a completed state when its context exits successfully.

Changes

Python (marimo/_plugins/stateless/status/_progress.py)

  • Add an _is_done flag to the _Progress base class.
  • Add a thread-safe mark_done() method.
  • Add Spinner.done() as the public convenience method.
  • Serialize the optional done state for the frontend.
  • Automatically mark retained spinners as done after successful context-manager exit.
  • Clear retained spinners when the context exits with an exception, avoiding a false success state or an indefinitely loading spinner.

TypeScript (frontend/src/plugins/layout/ProgressPlugin.tsx)

  • Add optional done state to the data interface and Zod validator.
  • Render a green CheckCircle2Icon instead of the loading indicator when done=true.

Tests (tests/_plugins/stateless/status/test_progress.py)

  • Verify done() updates completion state, title, and subtitle.
  • Verify done() without arguments preserves the existing title and subtitle.
  • Verify calling done() after close raises RuntimeError.
  • Verify remove_on_exit=True clears the spinner.
  • Verify successful exit with remove_on_exit=False transitions to done.
  • Verify exceptional exit with remove_on_exit=False clears the spinner without marking it done.

Usage

# Manual completion
with mo.status.spinner("Loading ...") as spinner:
    data = expensive_function()
    spinner.done(title="Done!")

# Automatic completion after successful exit
with mo.status.spinner("Loading ...", remove_on_exit=False):
    data = expensive_function()

Validation

  • tests/_plugins/stateless/status/test_progress.py: 21 passed.
  • no-double-backticks-in-docstrings: passed.
  • CLA Assistant: passed.
  • pre-commit.ci: passed.

I have read the CLA Document and I hereby sign the CLA.

Implements the TODO(akshayka) for adding a done() method that turns
the spinner into a checkmark when completed.

Changes:
- Add mark_done() to _Progress base class (thread-safe)
- Add done() convenience method to Spinner class
- Pass done state to frontend via _get_text()
- Frontend: show CheckCircle2Icon when done=true
- Context manager: auto-transition to done when remove_on_exit=False
- Tests: 5 new test cases covering all scenarios

Usage:
    with mo.status.spinner('Loading ...') as s:
        data = load_data()
        s.done(title='Done!')

Closes: #<issue>
@vercel

vercel Bot commented Jun 21, 2026

Copy link
Copy Markdown

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

Project Deployment Actions Updated (UTC)
marimo-docs Ready Ready Preview, Comment Jun 22, 2026 9:04am

Request Review

@github-actions

github-actions Bot commented Jun 21, 2026

Copy link
Copy Markdown

All contributors have signed the CLA ✍️ ✅
Posted by the CLA Assistant Lite bot.

@allin2

allin2 commented Jun 21, 2026

Copy link
Copy Markdown
Author

I have read the CLA Document and I hereby sign the CLA

@matthieugraziani

Copy link
Copy Markdown

Thanks for the contribution! This is a clean and user-friendly enhancement that addresses both TODOs left in the codebase.

I particularly like:

The thread-safe implementation via mark_done()
The automatic transition when remove_on_exit=False
The frontend/backend consistency for the new done state
The comprehensive test coverage, including context manager behavior and error handling

A few points worth double-checking during review:

Ensure the serialized payload remains backward compatible for clients that may not yet recognize the done field.
Verify that repeated calls to done() are intentionally idempotent (or documented otherwise).
Consider whether future status states (success, warning, error) might benefit from a more generic state enum instead of a boolean flag.

Overall, the feature is well-scoped, resolves the referenced TODOs, and includes appropriate test coverage. Nice work!

@allin2

allin2 commented Jun 22, 2026

Copy link
Copy Markdown
Author

@akshayka, could you please review this PR when you have a chance? It implements the two Spinner completion TODOs and handles exceptional context exits without showing a success state. Thank you.

@akshayka

Copy link
Copy Markdown
Contributor

@allin2 do you have a use case for this? Feature requests need to be discussed with the team via a GitHub issue before submitting a PR for review

@Yasin197

Copy link
Copy Markdown

@allin2 - do you think if we had like 4 items in a workflow where each item ended in a check mark, we could see all 4 check marks in the UI?

@akshayka

Copy link
Copy Markdown
Contributor

Closing due to lack of response

@akshayka akshayka closed this Jun 25, 2026
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.

4 participants