Skip to content

Conversation

@davidagold
Copy link
Owner

@davidagold davidagold commented May 20, 2024

What

This branch contains a sketch of Jupyter notebook support for Zed. Given that there are already efforts underway to develop such functionality, I would be content for the upshot of the present implementation to be my familiarizing myself with the codebase and having some fun. However, if there is desire to incorporate any part of this work, please let me know! I would be happy to continue developing it.

(As an aside, the top-line LOC changed figures are somewhat misleading, as ~2K lines are attributable to lock files.)

The code is organized as follows:

  • crates/notebook/src
    • actions.rs -- Notebook actions
    • cell.rs -- Encapsulation of notebook cell functionality, primarily in the Cell and Cells structs. The former represents an individual cell; the latter represents an ordered collection of cells and contains functionality for managing the cells' relations to the MultiBuffer through which the cell contents are exposed via an Editor.
    • chat.rs -- Chat functionality that can be accessed from within the notebook.
    • common.rs -- Common utilities
    • editor.rs -- Provides NotebookEditor, a wrapper around a View<Editor> through which a user can interact with the notebook (e.g. by inserting new cells or running the presently focused cell/selection).
    • jupyter/ -- While still aspirational, my intention is for this directory to contain Jupyter-specific functionality and to make the core Notebook, Cells, NotebookEditor constructs sufficiently generic so as to support other kinds of interactive development. The present implementation uses pyo3 to integrate a Python-based kernel connection construct that uses the jupyter_client Python package directly into Zed, and the jupyter/ directory contains the relevant code.
      • jupyter/connection.py -- Provides the KernelConnection Python construct, which exposes jupyter_client functionality for use in the JupyterKernelClient Rust struct.
      • jupyter/message.py -- Provides Pydantic models for Jupyter messages.
      • jupyter/message.rs -- Provides Rust models for Jupyter messages.
      • jupyter/python.rs -- Provides utilities for integrating asynchronous Python applications in Zed.
    • kernel.rs -- Provides the JupyterKernelClient through which the NotebookEditor interacts with the kernel. Upon initialization, the JupyterKernelClient launches a background task that listens for commands from the client and messages from the kernel via the KernelConnection. When the kernel publishes a message, a Python forwarder sends the message to the background task via a channel, and the task in turn emits an event containing the message. The NotebookEditor in turn subscribes to the client and updates the notebook accordingly. (Arguably this should be in jupyter/.)
    • notebook.rs -- Provides the Notebook container for Cells, the handle for the client, and methods for deserialization of .ipynb files.

The notebook view itself just uses the present Editor over a MultiBuffer, where each cell is represented as excerpts spanning its respective source and output Buffers. I'm sure it would be preferable to tailor this view, but it served rather well for a prototype. I would be curious to see whether a new EditorMode variant, e.g. EditorMode::Notebook would be a good means of including such customizations.

The present implementation only supports plaintext output.

notebook.mov

osiewicz and others added 28 commits July 11, 2024 14:56
TODO:
- [ ] File a PR with Yarn to add Zed to the list of supported IDEs.

Fixes: zed-industries#10107
Fixes: zed-industries#13706
Release Notes:

- Improved experience in projects using Yarn. Run `yarn dlx
@yarnpkg/sdks base` in the root of your project in order to elevate your
experience.

---------

Co-authored-by: Saurabh <79586784+m4saurabh@users.noreply.github.com>
…ndustries#14207)

This PR updates the `/docs` slash command to show a message to more
clearly indicate when there are no available docs providers.

<img width="379" alt="Screenshot 2024-07-11 at 10 31 53 AM"
src="https://github.com/zed-industries/zed/assets/1486634/d079f87c-4933-4da9-ad82-34dbfe6a284c">

Release Notes:

- N/A
It seems `hold: false` causes alacritty to close the channel earlier,
without waiting for the output from the child command to go to Zed.

Fixes [zed-industries#13683](zed-industries#13683)

Release Notes:

- Fixed loosing output of a spawned task
([zed-industries#13683](zed-industries#13683)).

[Screencast from 2024-07-06
18-28-56.webm](https://github.com/zed-industries/zed/assets/39293/4ebef8b5-7c0d-46be-9341-4ac0d809458d)
…ies#14209)

This PR updates the Wasm API compatibility check to allow Nightly to
load extensions using v0.0.7 of the Zed extension API.

Release Notes:

- N/A
- Mostly just tweaking some design (colors & spacing) stuff
- Some small accessibility things—e.g., underline decoration for links
and one h1 only per page
- Most of the other captured changes are really just Prettier indenting
stuff

Release Notes:

- N/A
- Linux (default) add ctrl-shift-j
- Linux (default) remove ctrl-j
  - Conflicted with: `"ctrl-j": "workspace::ToggleBottomDock",`
- MacOS (sublime) add cmd-shift-j
This PR bumps the Svelte extension to v0.0.2.

Changes:

- zed-industries#12788

Release Notes:

- N/A
When I implemented zed-industries#13701, I kinda messed up with the reversed
selections, thinking that their anchors are flipped, so I flipped them
again. This caused the reverse selections to always be cleared

Release Notes:

- Fix reverse selections always being cleared, even if the right click
was performed inside
`buffer_line_height` has been requested in zed-industries#5590 and implemented in
zed-industries#2718, however the documentation was still lacking.

Release Notes:

- N/A
…ariables in integrated terminal (zed-industries#14213)

![image](https://github.com/zed-industries/zed/assets/31354274/9d1c5410-897b-40a1-8256-2d7e207f69ff)

These two environment variables are essential when people need to detect
terminal type and do something. Many popular terminals set them.

fixes zed-industries#4571

Release Notes:

- Set `TERM_PROGRAM` and `TERM_PROGRAM_VERSION` environment variables in
the integrated terminal
([zed-industries#4571](zed-industries#4571)).
…#14139)

Release Notes:

- vim: Fixed `c <motion>` omitting trailing multibyte characters
([zed-industries#13909](zed-industries#13909)).
Allows deleting the outputs directly within the editor. This also fixes
the overlap logic to make sure that the ends and the starts are
compared.


https://github.com/zed-industries/zed/assets/836375/84f5f582-95f3-4c6a-a3c9-54da6009e34d

Release Notes:

- N/A

---------

Co-authored-by: Antonio <antonio@zed.dev>
…ustries#14177)

# Issue

When a user does something that changes the cursor shape, such as when
switching between vim modes, there may be an up to 500ms (cursor blink
interval) delay until the user receives feedback for their action. This
happens when the shape change happens during the invisible phase of a
blink - the user will not see the cursor shape change until the next
phase, which could be 500ms away.

# Solution

Cursor shape changes should disrupt blinking by forcing the cursor to be
shown, this results in immediate feedback for shape changes. This is in
line with the behavior of other editors I've tried.

Release Notes:

- Improved visual feedback when changing cursor shape
Release Notes:

- vim: (BREAKING) Improved vim keymap contexts.

Previously `vim_mode == normal` was true even when operators were
pending, which led to bugs like zed-industries#13789 and a requirement for custom
keymaps to exclude various conditions like (`!VimObject` and
`!VimWaiting`) to avoid bugs.

Now `vim_mode` will be set to `operator` or `waiting` in these cases as
described in [the docs](https://zed.dev/docs/vim#keybindings). For most
custom keymaps this change will be a no-op or an improvement, but if you
were deliberately relying on the old behaviour (if you were relying on
`VimObject` or `VimWaiting` becoming true) you will need to update your
keymap.

---------

Co-authored-by: Thorsten <thorsten@zed.dev>
Previously http://google.com would get modified to
https://http://google.com which doesn't work. I assume http links should
be supported.

Release Notes:

- N/A
Fixed tarball documentation links for linux aarch64 (they were pointing
at x86_64 tarballs)

Release Notes:

- N/A
…tries#14247)

This PR updates the `/docs` slash command to use a more generic icon to
convey docs.

It was still using the Rust icon, a relic of when it was still
`/rustdoc`.

Release Notes:

- N/A
Add support for aligning items to the baseline.

Release Notes:

- N/A

---------

Co-authored-by: Danilo Leal <67129314+danilo-leal@users.noreply.github.com>
… doc` (zed-industries#14262)

This PR updates the `/docs` slash command to show a warning to the user
if a crate's docs cannot be indexed due to the target directory not
containing docs:

<img width="782" alt="Screenshot 2024-07-11 at 5 11 46 PM"
src="https://github.com/user-attachments/assets/2f54f7a1-97f4-4d2d-b51f-57ba31e50a2f">

Release Notes:

- N/A
…ters (zed-industries#14269)

Also, don't retrieve code snippets when rendering the repl quick action
button

Release Notes:

- N/A

---------

Co-authored-by: Kyle Kelley <kylek@zed.dev>
Co-authored-by: Kyle Kelley <rgbkrk@gmail.com>
This change pulls in kvark/blade#135 and updates
the simplelog dependency for compatibility with that.


Release Notes:

- linux: Show link to troubleshooting docs when we can't open a window
Release Notes:

- linux: Fixed a panic if we request a cursor style your system doesn't
support
* Work on outputs

* Work

* Produce cell output buffers

* Bugfix, but we're still seeing no outputs

* Better way to do syntax highlighting

* Didn't mean to comment that

* Clean up a bit

* (Some) Output cells print

* Remove commented code

* Aesthetics

* Error forwarding utility and cleanup

* Simple  outputs display
* Remove duplicate Cargo deps entry and sort

* Moving along

* Progress (exclamation point)

* More progress

* I don't think things will work this way.

* Horrendous state but some progress I think

* I think this will do

* A little cleanup

* Work testing code execution

* Work testing code execution

* Work testing code execution

* Now we're talking (exclamation point)

* Kernel connection

* Reorganize a little bit

* test_server.py -> src/jupyter/connection.py
* Superfluous change that was nonetheless bugging me

* Fill out, consolidate Cells initialization and SumTree dimensions

* Commit work while I try to undo accidental find+replace-all

* Work on updating outputs

* Include Python modules

* Small post-rebase fixes

* Progress on adding new cell

* Checkpoint

* We can insert cells

* We can insert cells

* Wow that took much longer than expected

* Get current cell ID from buffer

* Include cell ID in KernelMessage event

* Remove stale output of current cell when run

* IT WORKS

* Clean up a little bit
Mark output when execution successful
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.