feat: toast notification when Runme backend is unavailable#79
feat: toast notification when Runme backend is unavailable#79hamelsmu wants to merge 3 commits intofeature/contents-servicefrom
Conversation
When creating a new notebook or adding a cell to an empty notebook, the default cell type was JavaScript/code. Changed to markdown since most notebooks start with documentation. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com> Signed-off-by: Hamel Husain <hamel.husain@gmail.com>
- Add 5 tests for appendMarkupCell() and addMarkupCellBefore() - Fix comment to accurately describe behavior (applies to both empty and non-empty notebooks) - Add @vitest-environment node directive to fix jsdom ESM bug Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com> Signed-off-by: Hamel Husain <hamel.husain@gmail.com>
When a user clicks Run on a cell and the backend service is not reachable, a toast notification now appears after 5 seconds informing them to start the backend. Uses sonner for lightweight, non-intrusive toasts styled to match the Radix UI design system. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: aff2e2c7fb
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| const runID = cellData.run(); | ||
|
|
||
| if (!runID) { | ||
| toast.error("No runner configured. Check your runner settings in the console.", { |
There was a problem hiding this comment.
Use actual run ID before showing "No runner" toast
cellData.run() is typed to return void (NotebookData/CellData still define run(): void), so runID here is always undefined and if (!runID) always executes. In practice, every Run click will show the "No runner configured" toast and return early from this handler even when a runner is configured and execution was started, which makes the new availability logic incorrect for normal runs.
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
Pull request overview
Adds user-facing feedback when a cell run can’t reach the Runme backend by introducing toast notifications (Sonner) and a 5s “no PID received” timeout. The PR also includes notebook markup-cell insertion changes that appear unrelated to the stated toast-only scope.
Changes:
- Add
sonnerand mount a global<Toaster>with Radix-aligned styling. - Add toast notifications in
Actionsfor (a) no runner configured and (b) backend unreachable after a 5s PID timeout. - Add
NotebookDatamarkup-cell creation APIs + tests, and change the “Add cell” button to insert a markup cell.
Reviewed changes
Copilot reviewed 5 out of 6 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
app/package.json |
Adds sonner dependency. |
pnpm-lock.yaml |
Locks sonner@2.0.7. |
app/src/App.tsx |
Mounts Sonner <Toaster> in the app shell and sets toast styling/position. |
app/src/components/Actions/Actions.tsx |
Adds toast + timeout-based backend unreachability detection; also changes “Add cell” to insert markup cells. |
app/src/lib/notebookData.ts |
Adds addMarkupCellBefore/appendMarkupCell and a markup cell factory. |
app/src/lib/notebookData.test.ts |
Adds unit tests for the new markup-cell APIs (and sets Vitest environment to node). |
Files not reviewed (1)
- pnpm-lock.yaml: Language not supported
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| const runID = cellData.run(); | ||
|
|
||
| if (!runID) { | ||
| toast.error("No runner configured. Check your runner settings in the console.", { | ||
| id: "no-runner", | ||
| duration: 5000, | ||
| }); |
There was a problem hiding this comment.
CellData.run() returns void (see app/src/lib/notebookData.ts), but this code treats it as returning a runID. As written, runID will always be undefined, so the "No runner configured" toast will always show and the backend-timeout toast logic will never run. Update runCode to not rely on a return value from cellData.run() (e.g., change CellData.run() to return the generated runID, or trigger the toast based on an explicit success/failure signal).
| const runID = cellData.run(); | |
| if (!runID) { | |
| toast.error("No runner configured. Check your runner settings in the console.", { | |
| id: "no-runner", | |
| duration: 5000, | |
| }); | |
| try { | |
| cellData.run(); | |
| } catch (error) { | |
| toast.error( | |
| "No runner configured. Check your runner settings in the console.", | |
| { | |
| id: "no-runner", | |
| duration: 5000, | |
| }, | |
| ); |
| // Insert a markup (markdown) cell at the top of the notebook. | ||
| const firstCell = cellDatas[0]?.snapshot; | ||
| if (firstCell) { | ||
| data.addCodeCellBefore(firstCell.refId); | ||
| data.addMarkupCellBefore(firstCell.refId); | ||
| } else { | ||
| const newCell = data.addCodeCellAfter(""); | ||
| if (!newCell) { | ||
| // Fallback: create and persist a new code cell at the end. | ||
| const cell = create(parser_pb.CellSchema, { | ||
| metadata: {}, | ||
| refId: `code_${crypto.randomUUID().replace(/-/g, "")}`, | ||
| languageId: "bash", | ||
| role: parser_pb.CellRole.USER, | ||
| kind: parser_pb.CellKind.CODE, | ||
| value: "", | ||
| }); | ||
| data.updateCell(cell); | ||
| } | ||
| data.appendMarkupCell(); | ||
| } |
There was a problem hiding this comment.
This PR is described as adding a toast when the Runme backend is unavailable, but this hunk changes the global "Add cell" button behavior to insert a markup (markdown) cell (and adds new NotebookData markup cell APIs/tests). If this is intentional, the PR description should be updated; otherwise, consider moving these notebook/markup-cell changes into a separate PR to keep scope aligned and reduce review risk.
Summary
Changes
app/package.jsonsonner^2.0.7 dependencyapp/src/App.tsx<Toaster>component inside<Theme>app/src/components/Actions/Actions.tsxpnpm-lock.yamlHow it works
cellData.run()is called, returning arunIDTest plan
pnpm run build)test-smoke.sh)🤖 Generated with Claude Code