Create independent sessions and open SSH sessions in adjacent tabs
Start new windows with a fresh shell and add explicit session selection through --attach. Route in-pane SSH launches back to the originating session, preserving remote shells and tab order across local detach and reattach.
This commit is contained in:
@@ -15,6 +15,8 @@ import subprocess
|
||||
import tempfile
|
||||
import time
|
||||
|
||||
PROTOCOL_VERSION = 6
|
||||
|
||||
parser = argparse.ArgumentParser(description=__doc__)
|
||||
parser.add_argument("--binary", type=Path, default=Path("target/debug/psyterm"))
|
||||
args = parser.parse_args()
|
||||
@@ -70,13 +72,16 @@ def write_frame(stream, payload):
|
||||
stream.sendall(struct.pack("<I", len(payload)) + payload)
|
||||
|
||||
|
||||
def send_input(version, pane, text):
|
||||
def send_input(session_id, pane, text):
|
||||
# These prefix commands have stable, regression-tested bincode wire tags.
|
||||
with socket.socket(socket.AF_UNIX) as stream:
|
||||
stream.settimeout(5)
|
||||
stream.connect(str(server_socket))
|
||||
write_frame(stream, struct.pack("<II", 0, version)) # Hello
|
||||
assert struct.unpack_from("<II", read_frame(stream)) == (0, version)
|
||||
write_frame(stream, struct.pack("<II", 0, PROTOCOL_VERSION)) # Hello
|
||||
assert struct.unpack_from("<II", read_frame(stream)) == (0, PROTOCOL_VERSION)
|
||||
# Join the GUI's session before sending pane commands.
|
||||
write_frame(stream, struct.pack("<IIBQ", 1, 1, 1, session_id)) # Connect(Attach(Some(id)))
|
||||
assert struct.unpack("<IQ", read_frame(stream)) == (6, session_id) # Connected
|
||||
data = text.encode()
|
||||
write_frame(stream, struct.pack("<IQQ", 2, pane, len(data)) + data)
|
||||
write_frame(stream, struct.pack("<I", 15)) # Ping, after Input
|
||||
@@ -110,11 +115,11 @@ try:
|
||||
)
|
||||
wait_for(prepared_frames, "first terminal frame")
|
||||
listing = control("--list")
|
||||
version = int(re.search(r"version: (\d+)", listing).group(1))
|
||||
session_id = int(re.search(r"session (\d+)", listing).group(1))
|
||||
pane = int(re.search(r"panes \[(\d+)", listing).group(1))
|
||||
# No cursor animation, input event, resize, or screenshot may keep drawing
|
||||
# alive or accidentally wake the output during the check.
|
||||
send_input(version, pane, "printf '\\033[?25l'\n")
|
||||
send_input(session_id, pane, "printf '\\033[?25l'\n")
|
||||
time.sleep(2)
|
||||
idle_paints = gui_log.read_text().count("paint_us=")
|
||||
time.sleep(1.25)
|
||||
@@ -122,7 +127,7 @@ try:
|
||||
f"Hidden cursor keeps repainting an idle window; logs: {runtime}"
|
||||
)
|
||||
before = prepared_frames()
|
||||
send_input(version, pane, "printf '\\033]2;IDLE-DRAW-CHECK\\007Fresh output after idle\\n'\n")
|
||||
send_input(session_id, pane, "printf '\\033]2;IDLE-DRAW-CHECK\\007Fresh output after idle\\n'\n")
|
||||
wait_for(lambda: "IDLE-DRAW-CHECK" in control("--list"), "updated server title")
|
||||
wait_for(lambda: prepared_frames() > before, "updated terminal paint without compositor input", timeout=2)
|
||||
assert gui.poll() is None, "GUI exited during redraw"
|
||||
|
||||
Reference in New Issue
Block a user