Skip to content

A reactive notebook for Python — run reproducible experiments, query with SQL, execute as a script, deploy as an app, and version with git. Stored as pure Python. All in a modern, AI-native editor.

feat: news and notices (#6635)

Dylan Madisetti49bc22dfd8b6
diff --git a/marimo/_cli/upgrade.py b/marimo/_cli/upgrade.py
index a4a90cb264..0ee8ad34f4 100644
--- a/marimo/_cli/upgrade.py
+++ b/marimo/_cli/upgrade.py
@@ -24,15 +24,24 @@ FETCH_TIMEOUT = 3
LOGGER = _loggers.marimo_logger()
-def print_latest_version(current_version: str, latest_version: str) -> None:
- message = f"Update available {current_version} → {latest_version}"
+def print_latest_version(current_version: str, state: MarimoCLIState) -> None:
+ message = f"Update available {current_version} → {state.latest_version}"
echo(orange(message))
echo(f"Run {green('pip install --upgrade marimo')} to upgrade.")
+
+ if state.notices:
+ echo()
+ echo("Recent updates:")
+ for notice in state.notices:
+ echo(f"• {notice}")
+
echo()
@server_tracer.start_as_current_span("check_for_updates")
-def check_for_updates(on_update: Callable[[str, str], None]) -> None:
+def check_for_updates(
+ on_update: Callable[[str, MarimoCLIState], None],
+) -> None:
try:
_check_for_updates_internal(on_update)
except Exception as e:
@@ -41,7 +50,9 @@ def check_for_updates(on_update: Callable[[str, str], None]) -> None:
pass
-def _check_for_updates_internal(on_update: Callable[[str, str], None]) -> None:
+def _check_for_updates_internal(
+ on_update: Callable[[str, MarimoCLIState], None],
+) -> None:
from packaging import version
state = get_cli_state()
@@ -59,7 +70,7 @@ def _check_for_updates_internal(on_update: Callable[[str, str], None]) -> None:
if current_version and version.parse(state.latest_version) > version.parse(
current_version
):
- on_update(current_version, state.latest_version)
+ on_update(current_version, state)
# Save the state, create directories if necessary
write_cli_state(state)
@@ -96,6 +107,7 @@ def _update_with_latest_version(state: MarimoCLIState) -> MarimoCLIState:
# Fetch the latest version from PyPI
response = _fetch_data_from_url(api_url)
version = response["info"]["version"]
+ state.notices = update_notices(response)
state.latest_version = version
state.last_checked_at = now.strftime(DATE_FORMAT)
return state
@@ -128,3 +140,40 @@ def _fetch_data_from_url(url: str) -> dict[str, Any]:
def _is_same_day(date1: datetime, date2: datetime) -> bool:
return date1.date() == date2.date()
+
+
+def update_notices(response: dict[str, Any]) -> list[str]:
+ """
+ Extract notices from the version endpoint response.
+ Work down through versions and collect notices for versions
+ greater than current but less than or equal to latest.
+ Add them to the list in reverse order and break early.
+ """
+ from packaging import version
+
+ LOGGER.debug(f"Updating notices from version response, {response}")
+ notices = response.get("info", {}).get("notices", {})
+ if not notices:
+ return []
+
+ current_ver = version.parse(current_version)
+ latest_ver = version.parse(response["info"]["version"])
+
+ collected_notices: list[str] = []
+
+ # Work down through the notices dict
+ for version_str, notice_text in notices.items():
+ notice_version = version.parse(version_str)
+
+ # If we've gone below the current version, we can break
+ if notice_version <= current_ver:
+ break
+
+ # Add notice if version is greater than current but <= latest
+ if current_ver < notice_version <= latest_ver:
+ if notice_text:
+ collected_notices.insert(
+ 0, notice_text
+ ) # Add to front (reverse order)
+
+ return collected_notices
diff --git a/marimo/_config/cli_state.py b/marimo/_config/cli_state.py
index 2626b1b15e..c99f6beb86 100644
--- a/marimo/_config/cli_state.py
+++ b/marimo/_config/cli_state.py
@@ -12,6 +12,7 @@ class MarimoCLIState:
latest_version: Optional[str] = None
last_checked_at: Optional[str] = None
accepted_text_to_notebook_terms_at: Optional[str] = None
+ notices: Optional[list[str]] = None
FILE_NAME = "state.toml"
diff --git a/marimo/_server/api/endpoints/ws.py b/marimo/_server/api/endpoints/ws.py
index b5dc7ad61e..7bdcdd3604 100644
--- a/marimo/_server/api/endpoints/ws.py
+++ b/marimo/_server/api/endpoints/ws.py
@@ -10,6 +10,7 @@ from starlette.websockets import WebSocket, WebSocketDisconnect, WebSocketState
from marimo import _loggers
from marimo._ast.cell import CellConfig
from marimo._cli.upgrade import check_for_updates
+from marimo._config.cli_state import MarimoCLIState
from marimo._config.settings import GLOBAL_SETTINGS
from marimo._dependencies.dependencies import DependencyManager
from marimo._messaging.ops import (
@@ -730,7 +731,7 @@ class WebsocketHandler(SessionConsumer):
):
return
- def on_update(current_version: str, latest_version: str) -> None:
+ def on_update(current_version: str, state: MarimoCLIState) -> None:
# Let's only toast once per marimo server
# so we can just store this in memory.
# We still want to check for updates (which are debounced 24 hours)
@@ -741,9 +742,21 @@ class WebsocketHandler(SessionConsumer):
has_toasted = True
- title = f"Update available {current_version} → {latest_version}"
+ title = (
+ f"Update available {current_version} → {state.latest_version}"
+ )
release_url = "https://github.com/marimo-team/marimo/releases"
+
+ # Build description with notices if present
description = f"Check out the <a class='underline' target='_blank' href='{release_url}'>latest release on GitHub.</a>" # noqa: E501
+
+ if state.notices:
+ notices_text = (
+ "<br><br><strong>Recent updates:</strong><br>"
+ + "<br>".join(f"• {notice}" for notice in state.notices)
+ )
+ description += notices_text
+
self.write_operation(Alert(title=title, description=description))
check_for_updates(on_update)