fix(desktop): SSH launcher waits for desktop updates before starting a server #23005
github-actions[bot](GitHub profile, opens in a new tab) added labelsvouch:trusted
github-actions[bot](GitHub profile, opens in a new tab) added labelssize:L
juliusmarminge added labelsvia-triage
- @@ -125,3 +130,8 @@125130 ),126131 );127132133+const UpdateMarker = Schema.fromJsonString(134+ Schema.Struct({ startedAt: Schema.optional(Schema.Unknown), expiresAt: Schema.Number }),135+);136+137+export const updateRemaining = Effect.fn("sshHelper.updateRemaining")(function* (
juliusmarminge added labelsvia-triage:needs-julius
juliusmarminge removed labelsvia-triage
juliusmarminge removed labelsvia-triage:needs-julius
juliusmarminge added labelsbugfix
juliusmarminge added labelspr:needs-julius
juliusmarminge removed labelspr:needs-julius
juliusmarminge added labelspr:gate-failed
juliusmarminge added labelspr:in-progress
juliusmarminge removed labelspr:gate-failed
github-actions[bot](GitHub profile, opens in a new tab) removed labelssize:L
github-actions[bot](GitHub profile, opens in a new tab) added labelssize:XL
- scripts/evidence/pr-23005-ssh-update-race.sh line 166OutdatedResolvedby macroscopeapp[bot](GitHub profile, opens in a new tab)@@ -0,0 +146,21 @@146+ if [ "$rc" -ne 0 ]; then say "launcher stderr: $(grep -v '[▀█▄]' "$FAKE/launch.err" | tail -n3 | tr '\n' ' ')"; fi147+ report_servers148+}149+launch_fg() { launch_bg "${1:-node}"; launch_wait; }150+151+report_servers() {152+ local f="$FAKE/.t3/ssh-launch/k1"153+ say "state: managed=$(cat "$f/managed" 2>/dev/null || echo -) pid=$(cat "$f/pid" 2>/dev/null || echo -) port=$(cat "$f/port" 2>/dev/null || echo -)"154+ say "server processes on this HOME ($(ps -eo pid=,args= | grep -F -- "--base-dir $FAKE/.t3" | grep -v grep | wc -l)):"155+ ps -eo pid=,args= | grep -F -- "--base-dir $FAKE/.t3" | grep -v grep | sed "s|^| |" || true156+ show_marker157+}158+159+# Starts the dev desktop with its data dir at $FAKE/.t3, in its own session160+# so it stops by the process group captured here.161+DESKTOP_PGID=""162+start_desktop() {163+ local cfg="$WORK/xdg-config"164+ mkdir -p "$cfg" "$WORK/shots"165+ rm -f "$WORK/display"166+ ( cd "$CO" && XDG_CONFIG_HOME="$cfg" exec setsid headless-desktop bash -c \scripts/evidence/pr-23005-ssh-update-race.sh line 63OutdatedResolvedby macroscopeapp[bot](GitHub profile, opens in a new tab)@@ -0,0 +43,21 @@43+ node "$helper" "$WORK/launch-archive.sh" archive "$ARCHIVE_VERSION" >/dev/null 2>&144+ rm -f "$helper"45+}46+47+STARTED_PIDS=()48+FAKE=""49+cleanup() {50+ local pid51+ if [ -n "$FAKE" ] && [ -f "$FAKE/.t3/ssh-launch/k1/pid" ]; then52+ STARTED_PIDS+=("$(cat "$FAKE/.t3/ssh-launch/k1/pid")")53+ fi54+ if [ -n "${DESKTOP_PGID:-}" ]; then55+ kill -TERM -- "-$DESKTOP_PGID" 2>/dev/null || true56+ while kill -0 -- "-$DESKTOP_PGID" 2>/dev/null; do sleep 0.2; done57+ DESKTOP_PGID=""58+ fi59+ for pid in "${STARTED_PIDS[@]}"; do60+ kill "$pid" 2>/dev/null || true61+ done62+ for pid in "${STARTED_PIDS[@]}"; do63+ while kill -0 "$pid" 2>/dev/null; do sleep 0.1; donescripts/evidence/pr-23005-ssh-update-race.sh line 123OutdatedResolvedby macroscopeapp[bot](GitHub profile, opens in a new tab)@@ -0,0 +103,21 @@103+}104+runtime_json() { tr -d '\n' <"$FAKE/.t3/userdata/server-runtime.json" 2>/dev/null | cut -c1-120; }105+# The launcher's own server shares this base dir, so wait for the file to name106+# the replacement's PID, not just to exist.107+wait_runtime_file() {108+ local i=0109+ while ! grep -q "\"pid\":$REPLACEMENT_PID," "$FAKE/.t3/userdata/server-runtime.json" 2>/dev/null; do110+ i=$((i + 1))111+ if [ "$i" -ge 300 ]; then112+ say "replacement did not publish server-runtime.json within 30 s; file now: $(runtime_json)"113+ return 0114+ fi115+ sleep 0.1116+ done117+ say "replacement (pid $REPLACEMENT_PID) wrote server-runtime.json: $(runtime_json)"118+}119+120+seed_archive() {121+ local bin="$1" dir="$FAKE/.t3/runtime/versions/$ARCHIVE_VERSION"122+ mkdir -p "$dir"123+ printf '#!/bin/sh\nexec node %s "$@"\n' "$bin" >"$dir/t3"
- scripts/evidence/pr-23005-capture-launcher.ts line 14OutdatedResolvedby coderabbitai[bot](GitHub profile, opens in a new tab)@@ -0,0 +1,14 @@1+// @effect-diagnostics nodeBuiltinImport:off - Evidence helper; copied next to tunnel.ts in the checkout under test.2+// Prints the exact launch script launchOrReuseRemoteServer sends over SSH.3+// Uses only the public launchOrReuseRemoteServer so it runs unchanged on4+// checkouts that predate launcherTestHarness.ts.5+// Usage: node <checkout>/packages/ssh/src/<this file> <out.sh> node <bin.ts> | archive <version>6+// Writes to a file because the Effect logger prints to stdout.7+import * as NodeServices from "@effect/platform-node/NodeServices";8+import * as NodeFS from "node:fs";9+import * as Effect from "effect/Effect";10+import * as Layer from "effect/Layer";11+import * as Sink from "effect/Sink";12+import * as Stream from "effect/Stream";13+import { ChildProcessSpawner } from "effect/process";14+import { launchOrReuseRemoteServer } from "./tunnel.ts";@@ -0,0 +24,21 @@24+CO="$(cd "${1:?checkout}" && pwd)"25+ROW="${2:?row}"26+WORK="${3:-/tmp/ev-23005/driver}"27+HERE="$(cd "$(dirname "$0")" && pwd)"28+ARCHIVE_VERSION="9.9.9"29+MARKER_REL=".t3/runtime/desktop-update-in-progress"30+mkdir -p "$WORK"31+# Version-manager shims resolve node under $HOME; pin the real binary so the32+# throwaway HOMEs do not each install a runtime.33+PATH="$(dirname "$(node -p process.execPath)"):$PATH"34+export PATH35+36+ts() { date +%T.%3N; }37+say() { printf '[%s] %s\n' "$(ts)" "$*"; }38+39+capture_scripts() {40+ local helper="$CO/packages/ssh/src/.ev-capture-launcher.ts"41+ cp "$HERE/pr-23005-capture-launcher.ts" "$helper"42+ node "$helper" "$WORK/launch-node.sh" node "$CO/apps/server/src/bin.ts" >/dev/null 2>&143+ node "$helper" "$WORK/launch-archive.sh" archive "$ARCHIVE_VERSION" >/dev/null 2>&144+ rm -f "$helper"
juliusmarminge added labelspr:gate-failed
juliusmarminge removed labelspr:in-progress
juliusmarminge added labelspr:in-progress
juliusmarminge removed labelspr:gate-failed
github-actions[bot](GitHub profile, opens in a new tab) removed labelssize:XL
github-actions[bot](GitHub profile, opens in a new tab) added labelssize:L
juliusmarminge added labelspr:gate-failed
juliusmarminge removed labelspr:in-progress
t3dotgg(GitHub profile, opens in a new tab) closed this
juliusmarminge removed labelspr:gate-failed
Sign in to join this conversation.




Thread transfer impact#
✅ Thread transfer remains within every enforced ceiling.
Baseline:
8d3b061· PR result:87ac5b3· Source CI: successScenario and decoded snapshot size
10 historical turns, 5 command tools per turn, 878.9 KiB retained MCP result per historical turn, and a 1.05 MiB retained result in the measured turn.
Updated in place by a trusted workflow. PR artifacts are strictly validated and never executed.