drafted 1.14.21 → 1.14.23

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/install-mcp.sh +19 -13
  2. package/package.json +1 -1
package/install-mcp.sh CHANGED
@@ -161,7 +161,7 @@ install_portable_node() {
161
161
  mkdir -p "$HOME/.drafted"
162
162
  node_dir="$HOME/.drafted/node"
163
163
  tmp="$(mktemp -d)"
164
- filename="$(curl -fsSL https://nodejs.org/dist/latest-v22.x/SHASUMS256.txt | awk "/node-v.*-${platform}-${arch}\\.tar\\.xz/ {print \\$2; exit}")"
164
+ filename="$(curl -fsSL https://nodejs.org/dist/latest-v22.x/SHASUMS256.txt | awk "/node-v.*-${platform}-${arch}\\.tar\\.xz/ {print \$2; exit}")"
165
165
  if [ -z "$filename" ]; then
166
166
  fail "Could not find Node.js 22 download for $platform-$arch"
167
167
  exit 1
@@ -702,14 +702,8 @@ install_desktop_app() {
702
702
  # Clear quarantine so Gatekeeper doesn't block a freshly downloaded bundle.
703
703
  xattr -dr com.apple.quarantine "$app_bundle" >/dev/null 2>&1 || true
704
704
 
705
- # Kill any already-running instance first including a stray one that isn't
706
- # launchd-managed (e.g. left over from a prior run of this same installer,
707
- # before this pkill existed: `open` below used to spawn a second, untracked
708
- # process alongside the launchd-supervised one, and `launchctl bootout` only
709
- # ever stops the launchd-managed process, not that rogue one).
710
- pkill -x "$exe_name" >/dev/null 2>&1 || true
711
-
712
- # Register run-at-login for the new app (mirrors the legacy launch agent).
705
+ # Register run-at-login for the new app (mirrors the legacy launch agent). Write the
706
+ # plist BEFORE touching launchd so the bootstrap below loads the new binary path.
713
707
  uid="$(id -u)"
714
708
  plist="$HOME/Library/LaunchAgents/live.drafted.desktop.plist"
715
709
  mkdir -p "$HOME/Library/LaunchAgents"
@@ -731,11 +725,23 @@ install_desktop_app() {
731
725
  </dict>
732
726
  </plist>
733
727
  PLIST
734
- # launchctl bootstrap + RunAtLoad is the sole launch path — it already starts
735
- # the app, so a trailing `open "$app_bundle"` here would start a second,
736
- # launchd-unaware process every time this function runs (that was the bug).
737
- launchctl bootout "gui/$uid" "$plist" >/dev/null 2>&1 || true
728
+ # Restart under launchd DETERMINISTICALLY. bootout is async: bootstrapping before the old
729
+ # service is fully torn down races, and when it loses the label is left UNLOADED — the app
730
+ # dies with no KeepAlive to save it (that bricked the in-app updater, which is itself a child
731
+ # of the very app being replaced). And a bare pkill while the service is still loaded just
732
+ # trips KeepAlive into respawning the old binary mid-swap. So: bootout, POLL until the label
733
+ # is actually gone, kill any stray non-launchd instance, bootstrap the new plist, and
734
+ # kickstart -k to guarantee it comes up (RunAtLoad alone is not proof it started).
735
+ local svc="gui/$uid/live.drafted.desktop"
736
+ launchctl bootout "$svc" >/dev/null 2>&1 || true
737
+ local waited=0
738
+ while [ "$waited" -lt 40 ] && launchctl print "$svc" >/dev/null 2>&1; do
739
+ sleep 0.25
740
+ waited=$((waited + 1))
741
+ done
742
+ pkill -x "$exe_name" >/dev/null 2>&1 || true
738
743
  launchctl bootstrap "gui/$uid" "$plist" >/dev/null 2>&1 || true
744
+ launchctl kickstart -k "$svc" >/dev/null 2>&1 || true
739
745
  return 0
740
746
  }
741
747
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "drafted",
3
- "version": "1.14.21",
3
+ "version": "1.14.23",
4
4
  "description": "Drafted — visual thinking surface for humans and AI agents. Renders HTML, markdown, images, and code as frames on a zoomable canvas, with MCP tools for AI agents and real-time sync for humans.",
5
5
  "type": "module",
6
6
  "files": [