From 736ce6304f23573b31f0cbc8cbde651cb2e48233 Mon Sep 17 00:00:00 2001 From: Claude Date: Fri, 20 Nov 2026 10:00:52 +0000 Subject: [PATCH] docs(data-apps): connect pages to their own notebook without its ID Pages now call `Deepnote.connect().notebook()` without an ID, so a copy of the project keeps working. The local preview passes the notebook ID that `create_data_app_token` returns, the way Deepnote's handshake does. Co-Authored-By: Claude Opus 5.5 Claude-Session: https://claude.ai/code/session_01SQznHZ7hEr7Na8M51aTzb7 --- .../deepnote/skills/deepnote-data-apps/SKILL.md | 6 +++--- .../skills/deepnote-data-apps/scripts/app-dev.mjs | 14 ++++++++------ plugins/deepnote/skills/deepnote-mcp/SKILL.md | 2 +- 3 files changed, 12 insertions(+), 10 deletions(-) diff --git a/plugins/deepnote/skills/deepnote-data-apps/SKILL.md b/plugins/deepnote/skills/deepnote-data-apps/SKILL.md index b8bd5dc..46a9eec 100644 --- a/plugins/deepnote/skills/deepnote-data-apps/SKILL.md +++ b/plugins/deepnote/skills/deepnote-data-apps/SKILL.md @@ -65,13 +65,13 @@ A data app project has two parts: the page, a responsive HTML page in `_deepnote ``` - By default, make it calm and compact like Deepnote without copying Deepnote's UI: neutral surfaces with one blue accent, 1px borders, `rounded-lg` controls and `rounded-xl` cards, sentence case, solid backgrounds without gradients, no emoji or decorative icons, shadows only on floating elements, and at most one primary button per view. When the user asks for another look or their brand, change the theme and classes freely. -- Connect with `const notebook = Deepnote.connect().notebook('')`, using the notebook ID from `get_project`. +- Connect with `const notebook = Deepnote.connect().notebook()`. Without an ID, it connects to the project's own notebook, so a copy of the project keeps working; never write that notebook's ID into the page or its files. - On load, render `const {appData, agentBlockSummary, runCreatedAt} = await notebook.appData()` and show `runCreatedAt` as the time of the last update. When the app lets everyone with access see results without running it, a viewer with no run of their own gets the latest results of the app's editors. It throws when the viewer has no run yet, their results expired, or the run has no JSON output: show the message in an empty state with a button that runs the notebook with `{}`. - `const {run} = await notebook.run(values, {onProgress})` runs the whole notebook for this viewer. When `run.status === 'success'`, render `await notebook.appData()` again. Run it on submission, or with `{}` from a refresh button when the app has no inputs. Public visitors with **View** access can't run the app, so the call rejects: show its message. - Build the form from `await notebook.inputs()`, which returns each input's label, value, min, max, step, and options, so input changes in the notebook reach the app. Never overwrite input variables with hardcoded values. Values are keyed by input name and are strings (sliders too), booleans, or string arrays. - Show loading, empty, and error states, prevent duplicate submissions, and handle rejected calls, missing results, and `run.error`. When a failed run has no error text, show its status and point to run history. - Lay out dashboards as a title with one line of context, filters, a row of key numbers, one to three main charts, then a detail table. Format numbers and dates for reading, and label units. -- To show another app's data, connect to that app's notebook instead of copying its queries. Find its ID with `search`, check its JSON output with a read-only run, and do not change that notebook. Its keys can change, so show an error state when they are missing. +- To show another app's data, connect to that app's notebook with `Deepnote.connect().notebook('')` instead of copying its queries. Find the ID with `search`, check its JSON output with a read-only run, and do not change that notebook. Its keys can change, so show an error state when they are missing. - Never put API keys, tokens, `.env` contents, or other secrets in the page or its files. ## Testing @@ -81,7 +81,7 @@ Test a changed-input submission with `create_run`, its `inputs`, and `detachedRu Preview the page locally before pushing it, against the same API and data it gets in Deepnote: 1. Mint a viewer token with `create_data_app_token` for the project. Pass it only on the command line; never write it into files or answers. -2. Run `node scripts/app-dev.mjs --token --api-origin ` in the background, with the script from this skill's directory. Have the same background command kill it after 15 minutes, for example after `sleep 900`, so previews do not pile up; the token expires then anyway. It needs Node 18 or later. It serves the page embedded the way Deepnote does, prints the preview URL, and logs files the page asks for that do not exist. +2. Run `node scripts/app-dev.mjs --token --api-origin --notebook-id ` in the background, with the script from this skill's directory. Have the same background command kill it after 15 minutes, for example after `sleep 900`, so previews do not pile up; the token expires then anyway. It needs Node 18 or later. It serves the page embedded the way Deepnote does, prints the preview URL, and logs files the page asks for that do not exist. 3. With a browser tool, open the preview URL. The bar above the page says whether the app connected to Deepnote and lists its errors. Look at the page and try the inputs; runs started there are real runs. Fix the files and reload until the bar shows no errors. When it stops, mint a new token and start it again. 4. Without a browser tool, give the user the preview URL, ask them to open it, and say that you did not check the page yourself. 5. Push the new and changed files, after asking the user first when the app existed before this conversation, and leave the preview running so the user can open it until it is killed after 15 minutes. Stop it sooner when the user asks, or before starting another preview on the same port. When the user still wants it after it stops, mint a new token and start it again. diff --git a/plugins/deepnote/skills/deepnote-data-apps/scripts/app-dev.mjs b/plugins/deepnote/skills/deepnote-data-apps/scripts/app-dev.mjs index 8320a58..961e21d 100755 --- a/plugins/deepnote/skills/deepnote-data-apps/scripts/app-dev.mjs +++ b/plugins/deepnote/skills/deepnote-data-apps/scripts/app-dev.mjs @@ -10,10 +10,11 @@ import http from 'node:http' import path from 'node:path' import { parseArgs } from 'node:util' -const USAGE = `Usage: node app-dev.mjs --token --api-origin [--port ] +const USAGE = `Usage: node app-dev.mjs --token --api-origin --notebook-id [--port ] --token Viewer token from the create_data_app_token MCP tool. It is never printed. --api-origin apiOrigin from the same create_data_app_token result. + --notebook-id notebookId from the same result, which Deepnote.connect().notebook() connects to when the page names none. --port Port of the preview page; the app is served on the next one. Default 4747.` // The common web types from the table Deepnote's server looks content types up in. @@ -91,7 +92,7 @@ function createAppServer(root, origins, apiOrigin) { }) } -function renderDeepnotePage({ appOrigin, apiOrigin, token }) { +function renderDeepnotePage({ appOrigin, apiOrigin, token, notebookId }) { return ` @@ -111,7 +112,7 @@ iframe { flex: 1; width: 100%; border: 0; color-scheme: light dark; }
Waiting for the app to connect to Deepnote.