style(smolmachines): address PR #83 review comments
test / unit (push) Successful in 27s
test / integration (push) Successful in 42s

- bottle.py:_PTY_RESIZE_SCRIPT docstring: strip the speculative
  cwd-dependence explanation. The real reason to use absolute
  path is just that the wrapper is self-contained; the original
  rationale (tmux pane cwd) was a hypothesis we never confirmed
  and wasn't load-bearing once we found the libkrun race.

- pty_resize.py:main: drop the long comment duplicating
  `_STARTUP_SYNC_DELAY_SEC`'s docstring. Keep a one-liner
  pointing at the constant + the operational note about
  daemon=True.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
This commit is contained in:
2026-05-27 21:05:33 -04:00
parent aa5aa1f031
commit b3c6d66850
2 changed files with 7 additions and 25 deletions
+4 -8
View File
@@ -26,14 +26,10 @@ from . import pty_resize as _pty_resize
from . import smolvm as _smolvm
# Absolute path to the pty_resize wrapper. The dashboard's tmux
# pane (split-window / respawn-pane) opens the new pane in its
# OWN cwd, not the cwd of the process running split-window — so
# invoking the wrapper as `python -m <dotted-path>` would fail
# with ModuleNotFoundError whenever the operator's tmux pane was
# started from anywhere outside the claude-bottle repo. Absolute
# path sidesteps the cwd dependence (the wrapper has no
# claude_bottle.* imports, so it runs as a standalone script).
# Absolute path to the pty_resize wrapper. Invoke as
# `python <path>` rather than `python -m <dotted-path>` so the
# wrapper runs regardless of cwd / sys.path — it has no
# claude_bottle.* imports, so it's self-contained.
_PTY_RESIZE_SCRIPT = _pty_resize.__file__
@@ -132,23 +132,9 @@ def main(argv: list[str]) -> int:
signal.signal(signal.SIGWINCH, sync)
proc = subprocess.Popen(inner)
# Defer the initial sync. Firing it immediately races
# libkrun's per-exec OCI config write: both `smolvm machine
# exec` invocations stash a config.json in the same smolvm
# state dir during their bringup window, libkrun loads one
# mid-write, and the main exec dies with SIGKILL (rc=137)
# or libkrun's "parse error: trailing garbage" depending on
# scheduling. Trivial inner commands finish before the
# overlap matters; claude's slower startup hits the race
# every time, only inside tmux (the outside-tmux foreground
# handoff path takes a different bringup sequence that
# happens to dodge the window).
#
# A 2s timer is past the bringup window on a warm VM, so
# the side-channel writes a fresh config.json without
# collision, and the in-VM PTY is sized before claude has
# finished rendering its first frame. daemon=True so the
# timer doesn't block exit when the child finishes quickly.
# Initial sync is deferred — see _STARTUP_SYNC_DELAY_SEC.
# daemon=True so the timer doesn't block exit when the child
# finishes before the delay elapses.
timer = threading.Timer(_STARTUP_SYNC_DELAY_SEC, sync)
timer.daemon = True
timer.start()