Skip to content

armgit / kwant

Public Imported from GitHub
0

Your own team of AI bots in one self-hosted binary: spaces, every account you have, handoffs, approvals and routines. Open-source, self-hosted alternative to Grok Bot, Claude Duet and OpenAI dots. Rust + React.

Mac: lay out the install window with a background and drag arrow

Pixel (kwant bot)8177a6aa50fd
diff --git a/.github/workflows/mac.yml b/.github/workflows/mac.yml
index 386e4ebf..310c2256 100644
--- a/.github/workflows/mac.yml
+++ b/.github/workflows/mac.yml
@@ -84,8 +84,17 @@ jobs:
- name: Unit tests (PATH merge, port choice)
working-directory: apps/mac
run: cargo test --locked
+ # one multi-resolution TIFF so Finder draws the background sharp on Retina screens
+ - name: Install-window background
+ working-directory: apps/mac/dmg
+ run: tiffutil -cathidpicheck background.png [email protected] -out background.tiff
- name: Build the universal app and .dmg
working-directory: apps/mac
+ timeout-minutes: 30
+ env:
+ # Tauri skips the Finder AppleScript that lays out the install window (background,
+ # icon positions, hidden files moved out of view) when CI=true; run it anyway
+ TAURI_BUNDLER_DMG_IGNORE_CI: "true"
run: npx --yes @tauri-apps/cli@2 build --ci --target universal-apple-darwin --bundles app,dmg -- --locked
- name: Inspect the bundle
id: bundle
@@ -132,6 +141,68 @@ jobs:
cat "$KWNT_DATA_DIR/mac-app.log" || true
test -n "$ok"
echo "$body" | grep -q '"app":"kwnt"'
+ # Opens the .dmg in Finder the way a person would, with hidden files shown, and screenshots
+ # the window in light and dark mode. The layout check fails the job; the screenshots don't.
+ - name: Install window layout and screenshots
+ env:
+ DMG: ${{ steps.bundle.outputs.dmg }}
+ run: |
+ set -euo pipefail
+ shots="$RUNNER_TEMP/dmg-window"
+ mkdir -p "$shots"
+ python3 -m venv "$RUNNER_TEMP/dsvenv"
+ "$RUNNER_TEMP/dsvenv/bin/pip" install --quiet ds_store mac_alias
+ hdiutil attach -readonly "$DMG" | tee "$shots/attach.txt"
+ vol=$(grep -o '/Volumes/.*' "$shots/attach.txt" | head -1)
+ ls -la "$vol" | tee "$shots/ls.txt"
+ test -f "$vol/.background/background.tiff"
+ "$RUNNER_TEMP/dsvenv/bin/python" - "$vol" <<'PY' | tee "$shots/ds_store.txt"
+ import sys
+ from ds_store import DSStore
+ vol = sys.argv[1]
+ with DSStore.open(vol + "/.DS_Store", "r") as d:
+ entries = {(e.filename, e.code): e.value for e in d}
+ for (name, code), value in sorted(entries.items()):
+ print(name, code, value if code != b"icvp" else {k: v for k, v in value.items() if k != "backgroundImageAlias"})
+ icvp = entries[(".", b"icvp")]
+ assert icvp["iconSize"] == 128, icvp["iconSize"]
+ assert icvp["backgroundType"] == 2 and "backgroundImageAlias" in icvp, "no background picture"
+ bounds = entries[(".", b"bwsp")]["WindowBounds"]
+ print("window", bounds)
+ assert entries[("kwant.app", b"Iloc")] == (180, 170)
+ assert entries[("Applications", b"Iloc")] == (480, 170)
+ for name, code in entries:
+ if code == b"Iloc" and name.startswith("."):
+ x, _ = entries[(name, code)]
+ assert x > 660, f"{name} is inside the window at x={x}"
+ print("layout OK")
+ PY
+ hdiutil detach "$vol" || hdiutil detach -force "$vol"
+ (
+ set +e
+ defaults write com.apple.finder AppleShowAllFiles -bool true
+ killall Finder; sleep 3
+ for mode in light dark; do
+ if [ "$mode" = dark ]; then v=true; else v=false; fi
+ osascript -e "tell application \"System Events\" to tell appearance preferences to set dark mode to $v"
+ hdiutil attach -readonly "$DMG" > /dev/null
+ open "$vol"; sleep 6
+ osascript -e 'tell application "Finder" to get bounds of front window' > "$shots/bounds-$mode.txt"
+ screencapture -x "$shots/screen-$mode.png"
+ osascript -e 'tell application "Finder" to close every window'
+ hdiutil detach "$vol" || hdiutil detach -force "$vol"
+ sleep 2
+ done
+ ls -l "$shots"
+ true
+ )
+ - uses: actions/upload-artifact@v4
+ if: always()
+ with:
+ name: dmg-window
+ path: ${{ runner.temp }}/dmg-window
+ if-no-files-found: ignore
+ retention-days: 14
- uses: actions/upload-artifact@v4
with:
name: ${{ steps.bundle.outputs.name }}
diff --git a/.gitignore b/.gitignore
index f1184311..006a44b2 100644
--- a/.gitignore
+++ b/.gitignore
@@ -6,3 +6,4 @@ dist/
*.db-wal
*.db-shm
.DS_Store
+apps/mac/dmg/background.tiff
diff --git a/apps/mac/README.md b/apps/mac/README.md
index a0ed787e..c59a6162 100644
--- a/apps/mac/README.md
+++ b/apps/mac/README.md
@@ -21,8 +21,17 @@ of the `kwnt` crate.
```sh
(cd ../../frontend && npm ci && npm run build) # kwnt embeds frontend/dist
rustup target add aarch64-apple-darwin x86_64-apple-darwin
+tiffutil -cathidpicheck dmg/background.png dmg/[email protected] -out dmg/background.tiff
npx @tauri-apps/cli@2 build --target universal-apple-darwin --bundles app,dmg
```
The `.dmg` lands in `target/universal-apple-darwin/release/bundle/dmg/`. It is ad-hoc signed, so
the first launch needs right-click → Open. `.github/workflows/mac.yml` builds the same on CI.
+
+The install window's layout (background, 660x400 window, 128px icons, kwant on the left and
+Applications on the right) comes from `bundle.macOS.dmg` in `tauri.conf.json`. Finder writes it
+into the image's `.DS_Store` through AppleScript, which Tauri skips when `CI=true` unless
+`TAURI_BUNDLER_DMG_IGNORE_CI=true` is set, as the workflow does. The same script moves hidden
+files (`.VolumeIcon.icns`, `.background`, …) outside the window, so they stay out of view even
+with hidden files shown. The art is drawn by `dmg/make-background.py`; `background.tiff` is built
+from the two PNGs and not committed.
diff --git a/apps/mac/dmg/background.png b/apps/mac/dmg/background.png
new file mode 100644
index 00000000..67dbc76d
Binary files /dev/null and b/apps/mac/dmg/background.png differ
diff --git a/apps/mac/dmg/[email protected] b/apps/mac/dmg/[email protected]
new file mode 100644
index 00000000..978f307c
Binary files /dev/null and b/apps/mac/dmg/[email protected] differ
diff --git a/apps/mac/dmg/make-background.py b/apps/mac/dmg/make-background.py
new file mode 100644
index 00000000..b88b8802
--- /dev/null
+++ b/apps/mac/dmg/make-background.py
@@ -0,0 +1,69 @@
+"""Draws the kwant DMG window background: background.png (660x400) and [email protected].
+
+Run with: python3 apps/mac/dmg/make-background.py (needs Pillow)
+The window is 660x400 with kwant.app at (180, 170) and Applications at (480, 170),
+matching bundle.macOS.dmg in tauri.conf.json. Plain art only, no text.
+"""
+import math
+import os
+
+from PIL import Image, ImageDraw, ImageFilter
+
+W, H = 660, 400
+APP_X, APPS_X, ICON_Y = 180, 480, 170
+SS = 4 # supersampling for the 2x image
+
+TOP = (24, 22, 34)
+BOTTOM = (14, 15, 21)
+ARROW = (150, 154, 180, 255)
+
+
+def draw(scale):
+ s = scale * SS
+ w, h = W * s, H * s
+ # vertical gradient
+ grad = Image.new("RGB", (1, h))
+ for y in range(h):
+ t = y / (h - 1)
+ grad.putpixel((0, y), tuple(round(a + (b - a) * t) for a, b in zip(TOP, BOTTOM)))
+ img = grad.resize((w, h)).convert("RGBA")
+
+ # soft glow behind each icon slot
+ glow = Image.new("RGBA", (w, h), (0, 0, 0, 0))
+ g = ImageDraw.Draw(glow)
+ r = 92 * s
+ for cx in (APP_X, APPS_X):
+ g.ellipse((cx * s - r, ICON_Y * s - r, cx * s + r, ICON_Y * s + r), fill=(120, 110, 200, 34))
+ glow = glow.filter(ImageFilter.GaussianBlur(40 * s))
+ img = Image.alpha_composite(img, glow)
+
+ # arrow: a shallow arc from the app slot to the Applications slot
+ d = ImageDraw.Draw(img)
+ x0, x1 = (APP_X + 90) * s, (APPS_X - 92) * s
+ y = (ICON_Y - 4) * s
+ sag = 14 * s
+ width = round(4.5 * s)
+ pts = []
+ for i in range(61):
+ t = i / 60
+ pts.append((x0 + (x1 - x0) * t, y - sag * math.sin(math.pi * t)))
+ d.line(pts, fill=ARROW, width=width, joint="curve")
+ for px, py in (pts[0],):
+ d.ellipse((px - width / 2, py - width / 2, px + width / 2, py + width / 2), fill=ARROW)
+ # head, aligned with the arc's end tangent
+ (ax, ay), (bx, by) = pts[-3], pts[-1]
+ ang = math.atan2(by - ay, bx - ax)
+ L, spread = 20 * s, math.radians(34)
+ for side in (-1, 1):
+ hx = bx - L * math.cos(ang + side * spread)
+ hy = by - L * math.sin(ang + side * spread)
+ d.line([(hx, hy), (bx, by)], fill=ARROW, width=width)
+ d.ellipse((hx - width / 2, hy - width / 2, hx + width / 2, hy + width / 2), fill=ARROW)
+ d.ellipse((bx - width / 2, by - width / 2, bx + width / 2, by + width / 2), fill=ARROW)
+
+ return img.resize((W * scale, H * scale), Image.LANCZOS).convert("RGB")
+
+
+here = os.path.dirname(os.path.abspath(__file__))
+draw(1).save(os.path.join(here, "background.png"), dpi=(72, 72), optimize=True)
+draw(2).save(os.path.join(here, "[email protected]"), dpi=(144, 144), optimize=True)
diff --git a/apps/mac/tauri.conf.json b/apps/mac/tauri.conf.json
index bd7a688a..f62adde3 100644
--- a/apps/mac/tauri.conf.json
+++ b/apps/mac/tauri.conf.json
@@ -28,7 +28,13 @@
],
"macOS": {
"minimumSystemVersion": "11.0",
- "signingIdentity": "-"
+ "signingIdentity": "-",
+ "dmg": {
+ "background": "dmg/background.tiff",
+ "windowSize": { "width": 660, "height": 400 },
+ "appPosition": { "x": 180, "y": 170 },
+ "applicationFolderPosition": { "x": 480, "y": 170 }
+ }
}
}
}