1
1
mirror of https://github.com/wez/wezterm.git synced 2024-11-22 04:56:12 +03:00
Commit Graph

87 Commits

Author SHA1 Message Date
Sean Estabrooks
100b85dec9 Remove mux-server race condition.
New changes were being lost, and not sent to the
client, if they occurred during the time previous
updates were being processed.
2024-09-14 10:52:50 -07:00
Wez Furlong
c9116830c2
mux: augment PKI SAN list with getaddrinfo AI_CANONNAME
This should hopefully make things a bit easier to consume
for remote clients.

refs: https://github.com/wez/wezterm/issues/5543
2024-07-15 08:09:45 -07:00
Wez Furlong
0fcd4a847c
move uds stuff into new wezterm-uds crate
This centralizes the conditional imports and makes a home
for the IoSafe trait annotation for smol/async-io compat.
2024-05-13 17:56:57 -07:00
Wez Furlong
6b493ecd18
windows: another run at fixing up the build 2024-05-13 15:09:48 -07:00
Wez Furlong
ccc32faaba
speculative windows build fix 2024-05-13 13:58:26 -07:00
Wez Furlong
1ca5e6cc90
deps: upgrade smol to 2.0 2024-05-13 10:26:29 -07:00
Wez Furlong
14d426fea8
add cargo deny config, update lru 2024-05-13 08:29:36 -07:00
Wez Furlong
4af418fddd
mux: enable ssh agent forwarding
This is done with a wezterm twist: not only is the auth sock forwarded,
but the mux on the remote end will automatically maintain a symlink to
point to the auth sock of the most recently active mux client, and set
SSH_AUTH_SOCK to that symlink so that your remote panes should always be
referencing something sane.

refs: https://github.com/wez/wezterm/issues/1647
refs: https://github.com/wez/wezterm/discussions/988
2024-05-09 12:52:29 -07:00
Wez Furlong
6b93ee19e7
mux: record client ssh_auth_sock information
This commit expands the set of data that we track for each client to
include the SSH_AUTH_SOCK. This defaults to the value of that env var on
the machine where the ClientId is constructed, which may be remote from
the mux server.

For the proxy scenario, a remote SSH_AUTH_SOCK path is not addressable,
and what we really want is the local SSH_AUTH_SOCK path from that SSH
session, so we introduce awareness of whether the current session is a
proxy session. Proxy sessions register the mux-local-proxy-id during the
setup of the proxy, but we don't apply the identity to the mux. Instead,
we wait for the remote client to send their identity and that is
annotate to show that it has been routed via a proxy and, crucially, has
the SSH_AUTH_SOCK replaced with the mux-local-proxy-id SSH_AUTH_SOCK.

```
; wezterm cli list-clients
USER HOST                          PID CONNECTED     IDLE         WORKSPACE FOCUS SSH_AUTH_SOCK
wez  foo                        336500 86.944834352s 944.834352ms default       3 /home/wez/.1password/agent.sock
wez  foo (via proxy pid 337457) 337314 1.944834352s  944.834352ms               4 /tmp/ssh-XXXXTfGSp7/agent.337456
```

For the SSH_AUTH_SOCK to be populated, ssh agent forwarding also needs
to be enabled for SSH exec() calls; previously it was enabled only for
pty channels.

Since this commit changes the ABI of the mux protocol, the codec
version has been bumped.
2024-05-09 07:45:19 -07:00
Wez Furlong
d22e97dcef
deps: update hostname to 0.4 2024-05-04 17:11:47 -07:00
Wez Furlong
aa81a46d58
mux: allow specifying cache policy for process information
This allows individual call sites to be able to force an immediate
resolution of the process information.

This should help to address https://github.com/wez/wezterm/issues/4811
wherein the problem seems to be that the cwd used for a new spawn
is taken from a stale read.
2024-02-02 18:02:18 -07:00
Eric Long
a51c6a2638 Upgrade rcgen to 0.12
This brings ring version from 0.16 to 0.17, which enables build on platforms like RISC-V and LoongArch.
2024-01-29 19:54:13 -07:00
Quan Tong
f4db68637d check the zoom state before unzooming 2023-08-28 21:58:22 -07:00
Quan Tong
cb2178e7d7 add zoom-pane subcommand 2023-08-28 21:58:22 -07:00
Wez Furlong
c7ff432581
mux server: register additional domains
Relocate the helper function to mux-server-impl and have both the GUI
and the mux server call it at the appropriate times.

Introduce default_mux_server_domain which is used instead of
default_domain in the mux server.  This is to avoid recursive
cycles when starting up the mux; we don't want the default
domain to be a unix client that connects to our selves because
we'll try to connect to ourselves, then in act of handling that
spawn in the default domain and try to connect to ourselves and
repeat.

refs: https://github.com/wez/wezterm/issues/3907
2023-07-11 09:34:34 -07:00
Mat Jones
2f4266cb6a
feat: resize pane from CLI (#3491)
* WIP resize pane from CLI

* fix response types

* fix: remove unneeded `import std::usize;`

Co-authored-by: Wez Furlong <wez@wezfurlong.org>

* fix: update derived files

* fix: update codec version

* chore: update changelog.md

* fix: remove unneeded `import std::usize;`

Co-authored-by: Wez Furlong <wez@wezfurlong.org>

* chore: update changelog.md

* remove erroneous changelog.md change

* remove erroneous changelog.md change

* remove whitespace changes

---------

Co-authored-by: Wez Furlong <wez@wezfurlong.org>
2023-04-18 08:34:39 -07:00
Wez Furlong
947d242fda
mux: improve error messaging
https://github.com/wez/wezterm/discussions/3480#discussioncomment-5567569
mentioned that running `wezterm cli spawn --domain-name SSH:foo`,
closing that tab and running `wezterm cli spawn --domain-name SSH:foo`
again failed.

The error message had no useful context.

This commit adds more context.
2023-04-10 20:14:58 -07:00
Wez Furlong
9b67a71485
add wezterm cli get-pane-direction
refs: https://github.com/mrjones2014/smart-splits.nvim/issues/53
2023-04-05 07:00:49 -07:00
Wez Furlong
b2b5c64aff
remove stray debug 2023-04-04 17:43:10 -07:00
Wez Furlong
11dc59b613
mux: explicitly update tab/pane active status on focus change
Previously, we'd record the focused pane only in the per-client
view.

That status didn't propagate through the model fully, leading to
inconsistencies when using activate-pane-direction.

This commit does the full model update to force that through.
I may regret this later: the focus state was intended to be
a per-client attribute and this effectively prevents that
from ever being useful.

Maybe the per-client state should just be removed?
Will ponder that later.

refs: https://github.com/wez/wezterm/issues/3448
refs: https://github.com/wez/wezterm/issues/3387

Also sneaking in here is not updating the last input time
for a client unless the input was taken by a user.
2023-04-04 17:31:35 -07:00
Wez Furlong
d36ad7ca7f
mux: reduce volume of bonus lines sent by server
At 80x24 (< 2k cells), sending all 24 lines of the viewport as an
optimistic prefetch is "OK", but for full screen 4k (80*250 = 20k cells)
the volume is oversized and pushes latency up.

This commit dials that back down to the minimal useful data; the
cursor row + any changed rows in the viewport.  When navigating
in vim that reduces things down to 2 rows of prefetch per movement,
assuming that the status line is being updated to show the cursor
position.

This feels a little more snappy for me.

refs: https://github.com/wez/wezterm/issues/2503
refs: https://github.com/wez/wezterm/issues/1872
2023-04-02 16:26:11 -07:00
Wez Furlong
49296500da
mux: forward ClearScrollback requests to remote server
refs: #2624
2023-04-02 14:17:05 -07:00
Wez Furlong
741570563d
add wezterm cli rename-workspace
refs: #2787
2023-04-02 07:37:45 -07:00
Wez Furlong
dd7d22ed6b
mux: propagate tab and window title when it changes
refs: #1598
2023-04-01 21:31:37 -07:00
Wez Furlong
74da631430
mux: allow client to provide palette to mux server
The server-side ownership of the palette is a stumbling block for
many users, so let's fix it.

This commit allows the client to pass its configured palette to
the server when it connects, and when the config is changed.

That palette takes precedence over the palette from the server config.

However, if the remote application uses any escape sequences that
redefine the color palette, the color palette that was active at
that point in time is forked and use as the basis, and will remain
the active palette until the palette is reset via escape sequences.

refs: https://github.com/wez/wezterm/issues/2686
refs: https://github.com/wez/wezterm/issues/3397
2023-03-31 08:02:32 -07:00
Wez Furlong
98e137942a
mux: move-pane-to-new-tab didn't resync structure
Resolution is to propagate the MuxNotification to the clients
and have them resync.

refs: https://github.com/wez/wezterm/issues/3219
2023-03-25 20:50:03 -07:00
Wez Furlong
622ea1add8
mux: notify clients when the size/structure of a tab changes
This helps to notify when eg: splits are changed, or the tab
is resized by another client.

refs: https://github.com/wez/wezterm/issues/2133
refs: https://github.com/wez/wezterm/issues/2351
refs: https://github.com/wez/wezterm/issues/783
2023-03-24 17:28:34 -07:00
Wez Furlong
f71bce1727
mux: propagate pane focus change events to clients
This commit causes the mux to generate a PaneFocused notification
when the active pane is changed.

The mux server will forward that as a unilateral PDU to connected
clients.

The clientpane implementation will handle that by applying the
same state to the local mux.

refs: #2863
2023-03-24 13:13:31 -07:00
Wez Furlong
2b298f5f96
mux: pass gui window position through from new mux window
Threads through a GuiPosition from mux window creation to allow it to be
used when the corresponding gui window is created.

SpawnCommand now has an optional position field to use for that purpose.

```lua
wezterm.mux.spawn_window {
  position = {
    x = 10,
    y = 300,
    -- Optional origin to use for x and y.
    -- Possible values:
    -- * "ScreenCoordinateSystem" (this is the default)
    -- * "MainScreen" (the primary or main screen)
    -- * "ActiveScreen" (whichever screen hosts the active/focused window)
    -- * {Named="HDMI-1"} - uses a screen by name. See wezterm.gui.screens()
    -- origin = "ScreenCoordinateSystem"
  },
}
```

refs: https://github.com/wez/wezterm/issues/2976
2023-02-05 21:43:37 -07:00
Wez Furlong
1609fd386b
add wezterm cli get-text command
closes: https://github.com/wez/wezterm/pull/2729
2023-02-05 09:05:48 -07:00
Wez Furlong
02eb0b4294
mux: rename Mux::get() -> try_get(), add "infallible" Mux::get()
This allows removing a bunch of unwrap/expect calls.

However, my primary motive was to replace the cases where we used
Mux::get() == None to indicate that we were not on the main thread.

A separate API has been added to test for that explicitly rather than
implicitly.
2022-12-19 11:55:35 -07:00
Wez Furlong
6e06b9af02
mux: Pane is now required to be Send+Sync. Use Arc<dyn Pane> 2022-12-19 11:52:33 -07:00
Antoine Büsch
36f47ec3f6
Expose activate-pane-direction cli command (#2526)
* Expose `activate-pane-direction` cli command

Add a new subcommand for `wezterm cli` called `activate-pane-direction`.
It allows switching the active pane in the current tab in the given
direction.

* Bump codec version

* Replace boolean flags with a single direction arg

* Run cargo fmt
2022-09-20 08:37:05 -07:00
Wez Furlong
ef532fc7e5 mux: adjust window size after attach
Since the initial attach is async, we'd create the window at the
default/initial size and then never reconcile the size of the remote
tabs once they'd attached.

This commit introduces an event that allows the gui window to do that.

The action that it takes is to take the max width and height between
its current size and the size of a newly added tab and resizes to
that new size, if it changed.

refs: https://github.com/wez/wezterm/issues/2133
refs: https://github.com/wez/wezterm/issues/2351
2022-08-05 07:53:44 -07:00
Wez Furlong
39adbb984d Pane::search: expose range, limit. Limit quickselect by default
The recent work on the scrollback made it easier to constrain the
search region, so expose those parameters to the Pane::search
interface and to the mux protocol.

Use those new parameters to constrain quickselect search to
1000 rows above and below the current viewport by default, and
add a new parameter to QuickSelectArgs that allows overriding that
range.

A follow-up commit could make the search/copy overlay issue a series
of searches in chunks so that it avoids blocking the UI when
searching very large scrollback.

refs: https://github.com/wez/wezterm/pull/1317
2022-07-25 18:31:27 -07:00
Wez Furlong
ec46aba089 mux: prefer compressed Lines when syncing 2022-07-24 16:15:47 -07:00
Wez Furlong
614900f85c line: introduce possibility of alternate cell backing
Uses an enum as a way to use an alternative to Vec<Cell>, but
doesn't provide that alternative in this commit.
2022-07-23 08:18:34 -07:00
Wez Furlong
75420c1b8f cli: add move-pane-to-new-tab command
This allows moving a pane to a new tab, which can in turn be
created in a new window.

refs: https://github.com/wez/wezterm/issues/1253
2022-05-28 06:43:22 -07:00
Wez Furlong
c4a248f1a3 mux: split-pane can optionally move an existing pane into the split
This commit allows for the SplitPane internal action to use the
pane id of an existing pane as the source of the pane to be added
in the new split target, rather than spawning a new command.

This can be used to move a pane from one tab to another, and is
analagous to tmux's `join-pane` command.

refs: https://github.com/wez/wezterm/discussions/2043
refs: https://github.com/wez/wezterm/issues/1253
2022-05-27 19:47:12 -07:00
Wez Furlong
ecd05547d5 Add SplitPane assignment
This, along with the plumbing included here, allows specifying
the destination of the split (now you can specify top/left, whereas
previously it was limited to right/bottom), as well as the size
of the split, and also whether the split targets the node at the
top level of the tab rather than the active pane--that is referred
to as full-width in tmux terminology.

https://github.com/wez/wezterm/issues/578
2022-05-21 21:09:11 -07:00
Wez Furlong
69f1f1e7d5 deps: update to rcgen 0.9 2022-05-04 20:16:41 -07:00
Wez Furlong
6b67ae842c mux: try to detect invalid data on stdout during connection
Use some heuristics to verify the data that is about to be parsed;
this can help to detect eg: data being output to stdout prior
to us sending any encoded data to the remote mux.

In addition, add a timeout to help avoid waiting forever in
the case that we didn't detect a problem.

refs: https://github.com/wez/wezterm/issues/1860
2022-04-11 21:08:57 -07:00
Wez Furlong
b162f6f1e2 reduce log level of some diagnostics printed on startup 2022-04-09 22:19:22 -07:00
Wez Furlong
b70ca55bdb mux: suppress error messages when client disconnects 2022-04-06 22:23:42 -07:00
Wez Furlong
27d7666a8d downloader: restructure how we propagate to the gui
same deal as 210999b915 but for the
download handler.

The download handler doesn't work across the multiplexer today.
2022-03-31 20:06:43 -07:00
Wez Furlong
210999b915 clipboard: restructure how we capture OSC 52
Previously, we'd create a clipboard handler associated with a GUI window
and take care to pass that down to the underlying Pane whenever we
spawned a new pane.

For the mux server, instead of being associated with a GUI window, the
clipboard was a special RemoteClipboard that would send a PDU through
to the client that spawned the window.

The bug here was that when that client went away, the clipboard for
that window was broken.

If the mux server was the built-in mux in a gui process this could
leave a tab without working OSC 52 clipboard support.

This commit restructures things so that the Mux is responsible for
assigning a clipboard handler that rephrases the clipboard event
as a MuxNotification.

Both the GUI frontend and the mux server dispatcher already listen
for mux notifications and translate those events into appropriate
operations on the system clipboard or Pdus to send to the client(s).

refs: #1790
2022-03-31 09:55:51 -07:00
Wez Furlong
1a71a0b216 improve error logging for OSC 52 in mux
refs: #1790
2022-03-29 08:09:52 -07:00
Wez Furlong
1c9bd347c2 multiplexer: improve handling of image attachments
There were a a couple of issues:

* `ImageData::hash` would re-hash the image on every call, and this was
  called for every cell that comprised an image on the mux server side
* `SerializedLine` needed to understand how to remove the `Arc<ImageData>`
  image attachments so that we didn't serialize a complete copy of the
  image per cell that comprised the image.

A new RPC was introduced to attempt to fetch `ImageData` given its
content hash and pane, row and cell index as a hint to locate it.

A client side LRU of content hash to `ImageData` is used to avoid
issuing repeat calls to that new RPC.

refs: #1237
2022-03-28 20:28:05 -07:00
Wez Furlong
4007ccbcd2 track focused pane in the client info
wezterm cli spawn, and wezterm cli split-pane can use this information
to pick a default for the pane id when invoked from outside of wezterm.

refs: https://github.com/wez/wezterm/issues/1531
2022-03-18 19:24:54 -07:00
Wez Furlong
cf518c9186 fun with sticky bits and RUNTIME_DIR
This commit does two related things, from opposite ends of the spectrum:

* Sets the sticky bit on pid files and unix sockets to avoid tmpwatch
  deleting them in cleanup scenarios
* Falls back to looking at the changed time if the filesystem doesn't
  support reporting creation time when wezterm does its own liveness
  and cleanup checks for unix domain sockets in the runtime dir
* Allow any wezterm instance to perform that cleanup

refs: #1601
2022-01-31 07:29:15 -07:00