Cancel from the board; office creates the session and builds the panes; handover rewritten

This commit is contained in:
Sam
2026-11-11 19:00:05 +11:00
parent 7a2d4358d3
commit 404fcc221d
12 changed files with 694 additions and 77 deletions

Binary file not shown.

View File

@@ -14,7 +14,9 @@ on a machine that is not the recorded one is refused rather than silently
producing a second copy of the same project.
"""
import json
import os
import subprocess
import sys
HERE = os.path.dirname(os.path.abspath(__file__))
@@ -25,7 +27,8 @@ import tuios # noqa: E402
def parse(argv):
opts = {"folder": ".", "project": "", "session": "", "dry": "--dry" in argv, "host": ""}
opts = {"folder": ".", "project": "", "session": "", "dry": "--dry" in argv,
"host": "", "no_switch": "--no-switch" in argv}
args = [a for a in argv if not a.startswith("--")]
if args:
opts["folder"] = args[0]
@@ -39,6 +42,25 @@ def parse(argv):
return opts
def ensure_session(session, folder):
"""Make the session exist. It cannot be shown from here, and that is fine.
Moving a person's TUIOS client to another session is refused when the call
comes from a pane — the daemon will not let a program change what the person
is looking at. Creating the session and building its panes works, so the
only step left for the person is switching to it, which TUIOS has a key for.
"""
if session in tuios.sessions():
h.say("session: %s (already there)" % session)
return
params = {"name": session, "cwd": folder, "window": False}
out = subprocess.run(["tuios", "call", "new-session", json.dumps(params)],
capture_output=True, text=True, timeout=60)
if out.returncode != 0 and "session_exists" not in (out.stderr or out.stdout):
raise h.Refused(3, "could not create session %r: %s" % (session, (out.stderr or out.stdout).strip()[:300]))
h.say("session: %s (created; switch to it with TUIOS's session switcher)" % session)
def scaffold(folder, name):
"""Write the files this project keeps, and only the ones that are missing.
@@ -100,7 +122,12 @@ def main():
or existing.get("session")
or os.path.basename(folder)
)
tuios.require_session(session)
# The session is created if it does not exist and the client is moved to it,
# so one command takes a person from a folder to a working layout. TUIOS has
# the verb for exactly this; asking the person to run `tuios new` first was
# the step everyone forgot.
if not opts["no_switch"]:
ensure_session(session, folder)
if opts["host"] and opts["host"] not in (pj.this_machine(), pj.this_machine().split(".")[0]):
# Only a note, because the panes are built by the machine that owns them.