MLFlexer / resurrect.wezterm

A plugin to restore windows, tabs and panes for Wezterm inspired by tmux-resurrect
MIT License
30 stars 1 forks source link

Restore lines for non-local domains #41

Open MLFlexer opened 1 month ago

MLFlexer commented 1 month ago

See discussion from this comment. Currently there is no way to restore the lines for WSL and SSH domains, but it seems like there might be a way to do so as per the discussion in #39.

MLFlexer commented 1 month ago

Continuing discussion from #39 here @joncrangle:

I agree. This is promising but is a separate feature and could use more testing. I think the solution will involve some variation of the following Wezterm lua functions to get the pane_id and return the scrollback text from it:

root.pane:pane_id() -- 23 was the pane_id for my SSH domain session
wezterm.mux.get_pane(23):get_lines_as_escapes(1000))

It might also make sense to abstract the get_lines_as_escapes into its own local function.

That should be the same behaviour as just root.pane:get_lines_as_escapes(1000) when saving the pane

MLFlexer commented 4 weeks ago

I found I was unable to inject output in panes within domains, and found this in the docs:

"Not all panes support this method; at the time of writing, this works for local panes but not for multiplexer panes."

MLFlexer commented 4 weeks ago

For now I see several directions this could be taken.

  1. Do not save the text for non-local domains
  2. use get_lines_as_text to store the text only and then send it to the pane with send_text forcing either the user to ctrl-c or we insert a ctrl-c control sequence at the end.
  3. Spawn the pane with a command like printf <text> ; sh

One of these are great tho :neutral_face:

joncrangle commented 4 weeks ago

For now I see several directions this could be taken.

  1. Do not save the text for non-local domains
  2. use get_lines_as_text to store the text only and then send it to the pane with send_text forcing either the user to ctrl-c or we insert a ctrl-c control sequence at the end.
  3. Spawn the pane with a command like printf <text> ; sh

One of these are great tho :neutral_face:

I'd be interested in whether others have feedback, because this is not a feature I'm overly concerned about for my personal workflow.

This plugin currently satisfies the pain point I was having by reattaching to SSH and SSHMUX sessions. SSHMUX sessions are already very similar to tmux in that running processes are continued as long as the Wezterm daemon on the server side is still running. I am personally less concerned about the scrollback, but can completely understand if someone else would find it useful.

MLFlexer commented 4 weeks ago

For now I think not saving lines for non-local panes is the best option, but if someone is reading this and has input on this, please feel free to provide ideas or feedback 😄