zed/crates/terminal_view
Max Brunsfeld 4ea8b8292c
Introduce channels and move collab popover contents to a collaboration panel (#2828)
### Summary

This PR introduces channels: a new way of starting collaboration
sessions. You can create channels and invite others to join them. You
can then hold a call in a channel, where any member of the channel is
free to join the call without needing to be invited.

Channels are displayed in a new panel called the collaboration panel,
which now also contains the contacts list, and the current call. The
collaboration popover has been removed from the titlebar.

![Screen Shot 2023-08-15 at 9 25 37
AM](https://github.com/zed-industries/zed/assets/326587/0f989dea-7fb7-4d50-9acd-25c8f1c30cd1)


For now, the channels functionality will only be revealed to staff, so
the public-facing change is just the move from the popover to the panel.

### To-do

* User-facing UI
  * [x] signed-out state for collab panel
  * [x] new icon for collab panel
  * [x] for now, channels section only appears for zed staff
* [x] current call section styling
(https://zed-industries.slack.com/archives/C05CJUNF2BU/p1691189389988239?thread_ts=1691189120.403009&cid=C05CJUNF2BU)
* [x] Channel members
* Channels
  * [x] style channel name editor
* [x] decide on a special "empty state" for the panel, when user has no
contacts
* [x] ensure channels are sorted in a consistent way (expose channel id
paths to client)
  * [x] Figure out layered panels UX
  * [x] Change add contacts to be the same kind of tabbed modal
* [x] race condition between channel updates and user fetches
(`ChannelStore::handle_update_contacts`)
* [x] race condition between joining channels and channel update
messages `collab::rpc::channel_updated`)
* [x] don't display mic as muted when microphone share is pending upon
first joining call

Release Notes:

- Moved the collaboration dropdown into its own panel.
- Added settings for disabling the AI assistant panel button.
- Switch to lazily initializing audio output sources
(https://github.com/zed-industries/community/issues/1840,
https://github.com/zed-industries/community/issues/1919)
2023-08-16 11:03:53 -07:00
..
scripts Fix typos 2023-06-02 22:02:19 -04:00
src Introduce channels and move collab popover contents to a collaboration panel (#2828) 2023-08-16 11:03:53 -07:00
Cargo.toml Allow moving the assistant panel to other docks 2023-06-02 10:55:19 +02:00
README.md Fix typos 2023-06-02 22:02:19 -04:00

Design notes:

This crate is split into two conceptual halves:

  • The terminal.rs file and the src/mappings/ folder, these contain the code for interacting with Alacritty and maintaining the pty event loop. Some behavior in this file is constrained by terminal protocols and standards. The Zed init function is also placed here.
  • Everything else. These other files integrate the Terminal struct created in terminal.rs into the rest of GPUI. The main entry point for GPUI is the terminal_view.rs file and the modal.rs file.

ttys are created externally, and so can fail in unexpected ways. However, GPUI currently does not have an API for models than can fail to instantiate. TerminalBuilder solves this by using Rust's type system to split tty instantiation into a 2 step process: first attempt to create the file handles with TerminalBuilder::new(), check the result, then call TerminalBuilder::subscribe(cx) from within a model context.

The TerminalView struct abstracts over failed and successful terminals, passing focus through to the associated view and allowing clients to build a terminal without worrying about errors.

#Input

There are currently many distinct paths for getting keystrokes to the terminal:

  1. Terminal specific characters and bindings. Things like ctrl-a mapping to ASCII control character 1, ANSI escape codes associated with the function keys, etc. These are caught with a raw key-down handler in the element and are processed immediately. This is done with the try_keystroke() method on Terminal

  2. GPU Action handlers. GPUI clobbers a few vital keys by adding bindings to them in the global context. These keys are synthesized and then dispatched through the same try_keystroke() API as the above mappings

  3. IME text. When the special character mappings fail, we pass the keystroke back to GPUI to hand it to the IME system. This comes back to us in the View::replace_text_in_range() method, and we then send that to the terminal directly, bypassing try_keystroke().

  4. Pasted text has a separate pathway.

Generally, there's a distinction between 'keystrokes that need to be mapped' and 'strings which need to be written'. I've attempted to unify these under the '.try_keystroke()' API and the .input() API (which try_keystroke uses) so we have consistent input handling across the terminal