# repl: Show kernel error on notebook cell instead of hanging \(\#59137\) · gitcafe/zed

[View on GitCafe](https://git.cafe/gitcafe/zed/commit/26a355b11d16df84a1fdb57f199daccc13e4bf3f)

Repository: [gitcafe/zed](https://git.cafe/gitcafe/zed)

Visibility: public

Requested revision: 26a355b11d16df84a1fdb57f199daccc13e4bf3f

Requested commit: 26a355b11d16df84a1fdb57f199daccc13e4bf3f

Commit: 26a355b11d16df84a1fdb57f199daccc13e4bf3f

Tree: 35da117250f90644842cca7d238cfa3a854acb1e

Author: MartinYe1234

Committer: GitHub

## Message

```
repl: Show kernel error on notebook cell instead of hanging (#59137)

Closes AI-394

When the kernel isn't running — e.g. Python isn't installed, ipykernel
is missing, or the kernel failed to launch — clicking run on a notebook
cell would unconditionally enter the executing state and silently drop
the execute request. The cell then spun forever with no logs and no way
to cancel (the stop button only works on a running kernel).

This change makes `execute_cell` attempt to send the execute request
first, and only mark the cell as executing when the send succeeds. On
failure it:

- Renders the failure (including the original kernel launch error) as an
error output on the cell, reusing the same `ErrorView` used for Python
tracebacks
- Logs the reason at the moment run is clicked, instead of only once at
notebook open
- No longer swallows `try_send` errors when the kernel process has died

Also adds the first unit test for the notebook editor, which exercises
the production path end to end: a real `.ipynb` parsed via
`NotebookItem::try_open`, a kernelspec pointing at a nonexistent
interpreter selected through `ReplStore::set_active_kernelspec`, a real
failed process spawn, and assertions through the production save path
(`to_nbformat_cell`). Verified red/green: the test fails against the
previous behavior.

Note for future notebook tests: `NotebookEditor` renders a continuously
animating kernel status icon, so rendering it as a root view in a GPUI
test makes `run_until_parked` spin forever. The test creates the editor
inside an empty window instead.

Release Notes:

- N/A
```

## Parents

- [d4cc8d240965e1b3c86b1132df2278e4d01333f6](https://git.cafe/gitcafe/zed/commit/d4cc8d240965e1b3c86b1132df2278e4d01333f6?format=markdown)

[Source at this commit](https://git.cafe/gitcafe/zed/tree/26a355b11d16df84a1fdb57f199daccc13e4bf3f?format=markdown)
