Skip to content

feat: toast notification when Runme backend is unavailable#79

Closed
hamelsmu wants to merge 3 commits intofeature/contents-servicefrom
fix/issue-68-runner-unavailable-toast
Closed

feat: toast notification when Runme backend is unavailable#79
hamelsmu wants to merge 3 commits intofeature/contents-servicefrom
fix/issue-68-runner-unavailable-toast

Conversation

@hamelsmu
Copy link
Collaborator

Summary

  • Adds a toast notification (via sonner) when a user clicks Run on a cell but the Runme backend service is not reachable
  • After clicking Run, if no PID arrives within 5 seconds, a non-intrusive error toast appears in the bottom-right corner
  • Toast styling matches the existing Radix UI design system (gray accent, small radius, system font)
  • Two failure modes handled:
    • No runner configured → immediate toast
    • Backend unreachable → 5-second timeout toast with deduplication

Changes

File Change
app/package.json Added sonner ^2.0.7 dependency
app/src/App.tsx Added <Toaster> component inside <Theme>
app/src/components/Actions/Actions.tsx Added timeout-based connection failure detection and toast calls
pnpm-lock.yaml Updated lockfile

How it works

  1. User clicks the Run button on a code cell
  2. cellData.run() is called, returning a runID
  3. A 5-second timeout starts watching for a PID response
  4. If a PID arrives (backend is up), the timeout is cleared — no toast
  5. If no PID arrives within 5 seconds (backend is down), an error toast is shown
  6. Toast uses deduplication IDs to prevent stacking on rapid clicks

Test plan

  • Build succeeds (pnpm run build)
  • Unit tests pass (56 tests)
  • Smoke test passes (test-smoke.sh)
  • Verified toast appears when backend is stopped
  • Verified toast does NOT appear when backend is running and cell executes
  • Verified toast deduplication on rapid clicking

🤖 Generated with Claude Code

hamelsmu and others added 3 commits February 12, 2026 18:50
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>
Copilot AI review requested due to automatic review settings February 13, 2026 03:03
Copy link

@chatgpt-codex-connector chatgpt-codex-connector bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 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".

Comment on lines +395 to +398
const runID = cellData.run();

if (!runID) {
toast.error("No runner configured. Check your runner settings in the console.", {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge 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 👍 / 👎.

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 sonner and mount a global <Toaster> with Radix-aligned styling.
  • Add toast notifications in Actions for (a) no runner configured and (b) backend unreachable after a 5s PID timeout.
  • Add NotebookData markup-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.

Comment on lines +395 to +401
const runID = cellData.run();

if (!runID) {
toast.error("No runner configured. Check your runner settings in the console.", {
id: "no-runner",
duration: 5000,
});
Copy link

Copilot AI Feb 13, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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).

Suggested change
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,
},
);

Copilot uses AI. Check for mistakes.
Comment on lines +866 to 872
// 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();
}
Copy link

Copilot AI Feb 13, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copilot uses AI. Check for mistakes.
@hamelsmu hamelsmu deleted the branch feature/contents-service February 13, 2026 03:28
@hamelsmu hamelsmu closed this Feb 13, 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.

1 participant