- st_demo: persist failure in call history, clear active_handle, and disable Run while call active to avoid overwriting handle - JupyterApp.shutdown: gather all shutdowns with return_exceptions=True and re-raise as BaseExceptionGroup so one failure doesn't leak kernels - messages: fallback known-but-malformed messages to UnknownJupyterMessage via ValidationError, make Unknown channel permissive (str) for nuance - transport: record reader failures as terminal state (_reader_failure) and fail fast from execute/messages_for instead of hanging - shell: don't reset execution_count to 0 when IPython returns None - README: use ipython_shell imports Skipped non-urgent/deferred items: line(), get_shell_2, test renames, import laziness, call-ID bounding, settle window config (worth doing later).
32 lines
903 B
Markdown
32 lines
903 B
Markdown
# IPython demo
|
|
|
|
The application-facing API is:
|
|
|
|
```python
|
|
from ipython_shell import App, CallOptions
|
|
|
|
app = App()
|
|
call = app.run_code(
|
|
"print('hello'); 2 + 2",
|
|
shell_name="new",
|
|
options=CallOptions(collapsed=False),
|
|
)
|
|
```
|
|
|
|
`call` contains the submitted `code`, `call_id`, `shell_name`, typed `options`,
|
|
a typed `result`, and ordered typed `events`. Event sequences are
|
|
stable within a call, so a frontend can use `(call_id, sequence)` as its
|
|
idempotency and React key pair.
|
|
|
|
For MIME output, retain the complete bundle and choose a renderer in the UI.
|
|
The initial preference is `text/html`, JavaScript, `text/latex`, then
|
|
`text/plain`, with image MIME types handled by their image renderers. HTML
|
|
must be sanitized, and JavaScript should be treated as untrusted unless the
|
|
host explicitly opts into a sandboxed execution policy.
|
|
|
|
Run the JSON showcase with:
|
|
|
|
```text
|
|
uv run ipython-demo
|
|
```
|