Skip to content

Commit a48acba

Browse files
committed
fix(macos-app): include stitch binary in app bundle and show startup errors
- Fix workflow YAML syntax that caused stitch binary to be skipped from Stitch.app with a leading space in the path argument - Change make-app.sh to require both stitch and stitch-panel binaries, failing the bundle build if either is missing instead of warning - Add explicit Contents/MacOS file checks in workflow after app assembly - Show native macOS dialog on stitch-desktop startup errors so Finder/Dock launches provide user feedback instead of silently failing - Bump version to 0.1.143
1 parent fd0427e commit a48acba

7 files changed

Lines changed: 65 additions & 17 deletions

File tree

.github/workflows/macos-app.yml

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -117,8 +117,20 @@ jobs:
117117
- name: Assemble Stitch.app
118118
# make-app.sh signs with $STITCH_CODESIGN_ID when set (Developer ID),
119119
# otherwise ad-hoc ("-").
120-
run: packaging/macos/make-app.sh target/universal/stitch-desktop dist \
121-
target/universal/stitch target/universal/stitch-panel
120+
# Use a `|` block — a plain YAML scalar with `\` turns `\ ` into an
121+
# escaped space, so arg3 became " target/universal/stitch" (leading
122+
# space), stitch was omitted from the .app, and macOS launches exited
123+
# immediately with nothing in the Dock / Activity Monitor.
124+
run: |
125+
set -euo pipefail
126+
packaging/macos/make-app.sh \
127+
target/universal/stitch-desktop \
128+
dist \
129+
target/universal/stitch \
130+
target/universal/stitch-panel
131+
test -f dist/Stitch.app/Contents/MacOS/stitch
132+
test -f dist/Stitch.app/Contents/MacOS/stitch-panel
133+
test -f dist/Stitch.app/Contents/MacOS/stitch-desktop
122134
123135
- name: Build Stitch.dmg
124136
# Wrap the (signed) app in a drag-to-Applications image. make-dmg.sh signs

.textile-monorepo-source

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
41ecfdddc55f234c926f892fff7f8c6dc6c1c10f
1+
2020079d7819291ecd5362322493932f130e3e03

.textile-stitch-release-version

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
0.1.142
1+
0.1.143

Cargo.lock

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "stitch-bot"
3-
version = "0.1.142"
3+
version = "0.1.143"
44
edition = "2021"
55
description = "Stitch — Textile filler-network operator bot; market-makes the filler order book with signed UniswapX limit orders."
66
license = "AGPL-3.0-or-later"

packaging/macos/make-app.sh

Lines changed: 14 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -16,18 +16,21 @@ cp "$HERE/Info.plist" "$APP/Contents/Info.plist"
1616
cp "$BIN" "$APP/Contents/MacOS/stitch-desktop"
1717
chmod +x "$APP/Contents/MacOS/stitch-desktop"
1818

19-
copy_helper() {
19+
# Both helpers are required. A missing `stitch` makes stitch-desktop exit
20+
# immediately on launch (Finder shows nothing — no Dock, no dialog).
21+
copy_required() {
2022
local src="$1"
2123
local name="$2"
22-
if [ -f "$src" ]; then
23-
cp "$src" "$APP/Contents/MacOS/$name"
24-
chmod +x "$APP/Contents/MacOS/$name"
25-
else
26-
echo "warning: $name not found at $src; Start Panel will fail until it is present" >&2
24+
if [ ! -f "$src" ]; then
25+
echo "error: required binary '$name' not found at '$src'" >&2
26+
echo "error: Stitch.app cannot launch without stitch + stitch-panel next to stitch-desktop" >&2
27+
exit 1
2728
fi
29+
cp "$src" "$APP/Contents/MacOS/$name"
30+
chmod +x "$APP/Contents/MacOS/$name"
2831
}
29-
copy_helper "$STITCH_BIN" "stitch"
30-
copy_helper "$PANEL_BIN" "stitch-panel"
32+
copy_required "$STITCH_BIN" "stitch"
33+
copy_required "$PANEL_BIN" "stitch-panel"
3134

3235
# App icon (referenced by CFBundleIconFile in Info.plist).
3336
if [ -f "$HERE/Stitch.icns" ]; then
@@ -47,12 +50,13 @@ if [ "$SIGN_ID" != "-" ]; then
4750
fi
4851
if command -v codesign >/dev/null 2>&1; then
4952
# shellcheck disable=SC2086
50-
[ -f "$APP/Contents/MacOS/stitch" ] && codesign --force $RUNTIME_OPT --sign "$SIGN_ID" "$APP/Contents/MacOS/stitch"
53+
codesign --force $RUNTIME_OPT --sign "$SIGN_ID" "$APP/Contents/MacOS/stitch"
5154
# shellcheck disable=SC2086
52-
[ -f "$APP/Contents/MacOS/stitch-panel" ] && codesign --force $RUNTIME_OPT --sign "$SIGN_ID" "$APP/Contents/MacOS/stitch-panel"
55+
codesign --force $RUNTIME_OPT --sign "$SIGN_ID" "$APP/Contents/MacOS/stitch-panel"
5356
# shellcheck disable=SC2086
5457
codesign --force $RUNTIME_OPT --sign "$SIGN_ID" "$APP/Contents/MacOS/stitch-desktop"
5558
# shellcheck disable=SC2086
5659
codesign --force $RUNTIME_OPT --sign "$SIGN_ID" "$APP"
5760
fi
5861
echo "Built $APP"
62+
ls -la "$APP/Contents/MacOS"

src/bin/stitch-desktop/main.rs

Lines changed: 33 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,11 +50,43 @@ const STATUS_POLL_SECS: u64 = 2;
5050

5151
fn main() {
5252
if let Err(e) = run() {
53-
eprintln!("stitch-desktop: {e:#}");
53+
let detail = format!("{e:#}");
54+
eprintln!("stitch-desktop: {detail}");
55+
// Finder launches have no terminal — surface fatal errors in a dialog
56+
// so "double-click → nothing" isn't the only feedback.
57+
show_launch_error(&detail);
5458
std::process::exit(1);
5559
}
5660
}
5761

62+
/// Best-effort native alert when startup fails (macOS Finder / Dock launches).
63+
fn show_launch_error(detail: &str) {
64+
#[cfg(target_os = "macos")]
65+
{
66+
// AppleScript string literals: escape `\`, `"`, and flatten newlines.
67+
let escaped: String = detail
68+
.replace('\\', "\\\\")
69+
.replace('"', "\\\"")
70+
.chars()
71+
.map(|c| match c {
72+
'\n' | '\r' => ' ',
73+
other => other,
74+
})
75+
.collect();
76+
let script = format!(
77+
"display dialog \"Stitch couldn't start.\\n\\n{escaped}\" with title \"Stitch\" buttons {{\"OK\"}} default button \"OK\" with icon stop"
78+
);
79+
let _ = std::process::Command::new("/usr/bin/osascript")
80+
.arg("-e")
81+
.arg(script)
82+
.status();
83+
}
84+
#[cfg(not(target_os = "macos"))]
85+
{
86+
let _ = detail;
87+
}
88+
}
89+
5890
fn launched_via_autostart() -> bool {
5991
std::env::args().any(|a| a == "--autostart")
6092
}

0 commit comments

Comments
 (0)