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.

fix: add warning when service worker is disabled (#7232)

Myles Scolnick409d2f3ce502
diff --git a/examples/ai/chat/anthropic_example.py b/examples/ai/chat/anthropic_example.py
index d738feb24d..0d6b66da21 100644
--- a/examples/ai/chat/anthropic_example.py
+++ b/examples/ai/chat/anthropic_example.py
@@ -8,7 +8,7 @@
import marimo
-__generated_with = "0.17.4"
+__generated_with = "0.17.8"
app = marimo.App(width="medium")
@@ -18,7 +18,7 @@ def _():
return (mo,)
[email protected](hide_code=True)
def _(mo):
mo.md(r"""
# Using Anthropic
@@ -72,7 +72,7 @@ def _(key, mo):
return (chatbot,)
[email protected](hide_code=True)
def _(mo):
mo.md("""
Access the chatbot's historical messages with [`chatbot.value`](https://docs.marimo.io/api/inputs/chat.html#accessing-chat-history).
diff --git a/examples/ai/chat/streaming_openai.py b/examples/ai/chat/streaming_openai.py
index ea2c202f23..58b600e8a6 100644
--- a/examples/ai/chat/streaming_openai.py
+++ b/examples/ai/chat/streaming_openai.py
@@ -2,7 +2,7 @@
# requires-python = ">=3.11"
# dependencies = [
# "marimo",
-# "openai>=1.55.3",
+# "openai==2.8.1",
# ]
# ///
@@ -26,7 +26,7 @@ def _(mo):
This example shows how to use OpenAI's API with streaming responses.
The built-in `mo.ai.llm.openai()` model automatically streams tokens
as they arrive from the API!
-
+
Enter your API key below to try it out.
""")
return
@@ -70,14 +70,14 @@ def _(chatbot):
return
[email protected](hide_code=True)
def _(mo):
mo.md("""
## How it works
The built-in OpenAI model returns an async generator that yields tokens
as they stream from the API:
-
+
```python
mo.ui.chat(
mo.ai.llm.openai(
@@ -86,7 +86,7 @@ def _(mo):
)
)
```
-
+
Other built-in models (`anthropic`, `google`, `groq`) work the same way.
""")
return
@@ -95,7 +95,7 @@ def _(mo):
@app.cell
def _(chatbot, mo):
# Show chat history
- if hasattr(chatbot, 'value'):
+ if hasattr(chatbot, "value"):
mo.md(f"**Chat history:** {len(chatbot.value)} messages")
return
@@ -103,11 +103,10 @@ def _(chatbot, mo):
@app.cell
def _(chatbot):
# Display full history
- if hasattr(chatbot, 'value'):
+ if hasattr(chatbot, "value"):
chatbot.value
return
if __name__ == "__main__":
app.run()
-
diff --git a/frontend/src/core/cells/__tests__/session.test.ts b/frontend/src/core/cells/__tests__/session.test.ts
index c154ad37f0..dce473bc49 100644
--- a/frontend/src/core/cells/__tests__/session.test.ts
+++ b/frontend/src/core/cells/__tests__/session.test.ts
@@ -446,9 +446,6 @@ describe("notebookStateFromSession", () => {
const session = createSession([]);
const result = notebookStateFromSession(session, null);
- expect(Logger.warn).toHaveBeenCalledWith(
- "Session and notebook must have at least one cell",
- );
expect(result).toBeNull();
});
@@ -456,9 +453,6 @@ describe("notebookStateFromSession", () => {
const notebook = createNotebook([]);
const result = notebookStateFromSession(null, notebook);
- expect(Logger.warn).toHaveBeenCalledWith(
- "Session and notebook must have at least one cell",
- );
expect(result).toBeNull();
});
@@ -467,9 +461,6 @@ describe("notebookStateFromSession", () => {
const notebook = createNotebook([]);
const result = notebookStateFromSession(session, notebook);
- expect(Logger.warn).toHaveBeenCalledWith(
- "Session and notebook must have at least one cell",
- );
expect(result).toBeNull();
});
});
diff --git a/frontend/src/core/cells/session.ts b/frontend/src/core/cells/session.ts
index ae13e02d1d..a32168f6e7 100644
--- a/frontend/src/core/cells/session.ts
+++ b/frontend/src/core/cells/session.ts
@@ -246,7 +246,6 @@ export function notebookStateFromSession(
mergeSessionAndNotebookCells(session, notebook);
if (cellIds.length === 0) {
- Logger.warn("Session and notebook must have at least one cell");
return null;
}
diff --git a/frontend/src/utils/vitals.ts b/frontend/src/utils/vitals.ts
index 0b5eff8877..1321bb7b37 100644
--- a/frontend/src/utils/vitals.ts
+++ b/frontend/src/utils/vitals.ts
@@ -7,7 +7,7 @@ export async function reportVitals() {
}
const { onLCP, onINP, onCLS } = await import("web-vitals");
- Logger.log("Reporting vitals");
+ Logger.debug("Reporting vitals");
const logMetric = (metric: {
name: string;
value: number;
diff --git a/marimo/_server/api/endpoints/assets.py b/marimo/_server/api/endpoints/assets.py
index f78e3c1631..06075972ab 100644
--- a/marimo/_server/api/endpoints/assets.py
+++ b/marimo/_server/api/endpoints/assets.py
@@ -144,6 +144,11 @@ def _inject_service_worker(html: str, file_key: str) -> str:
.catch(error => {{
console.error('Error updating service worker:', error);
}});
+ }} else {{
+ console.warn(
+ '[marimo] Service workers are not supported at this URL. Displaying files from the /public/ directory may be disabled. ' +
+ 'To fix this, enable service workers by using a secure connection (https) or localhost.'
+ );
}}
""",
)