Skip to content

Commit 0ee2ad7

Browse files
authored
Fix rounded macOS icon on older Macs (#8018)
Older macOS versions display Buzz’s opaque icon as an oversized square. Bake rounded corners and transparent padding into the macOS `.icns`, preserving the original bee artwork and leaving other platforms unchanged. Generation uses Hermit-pinned uv, Python 3.14.3, and Pillow 12.2.0. `scripts/macos-icon.sh --check` regenerates temporarily and compares all decoded representations; macOS CI runs it before packaging. Pixel reproducibility is verified independently of Apple’s ICNS container encoding. Validated native AppKit preview, all 10 representations, fresh-cache generation, one-pixel/missing-representation drift rejection, workflow lint, and pre-push checks. Full local `just ci` is running. Packaged Dock checks on older/current macOS remain outstanding. --------- Signed-off-by: kenny lopez <[email protected]>
1 parent 514a9a8 commit 0ee2ad7

9 files changed

Lines changed: 121 additions & 2 deletions

File tree

‎.github/workflows/_ci-desktop-macos.yml‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,8 @@ jobs:
3131
steps:
3232
- uses: actions/checkout@df4cb1c069e1874edd31b4311f1884172cec0e10 # v6.0.3
3333
- uses: cashapp/activate-hermit@cea9af7913204a965fd488637a8d1811bba2e616 # v1
34+
- name: Verify macOS icon representations
35+
run: scripts/macos-icon.sh --check
3436
- uses: Swatinem/rust-cache@e18b497796c12c097a38f9edb9d0641fb99eee32
3537
with:
3638
workspaces: desktop/src-tauri

‎.github/workflows/ci.yml‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,10 @@ jobs:
6666
- 'scripts/normative-corpus.json'
6767
- 'justfile'
6868
desktop:
69+
- 'scripts/generate-macos-icon.py'
70+
- 'scripts/macos-icon.sh'
71+
- 'bin/uv'
72+
- 'bin/.uv-*.pkg'
6973
- 'scripts/model-capabilities.json'
7074
- 'scripts/normative-corpus.json'
7175
- 'desktop/**'

‎bin/.uv-0.12.21.pkg‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
hermit

‎bin/uv‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
.uv-0.12.21.pkg

‎bin/uvx‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
.uv-0.12.21.pkg

‎desktop/src-tauri/icons/icon.icns‎

60.8 KB
Binary file not shown.

‎desktop/tests/e2e/image-attachment-gallery.spec.ts‎

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -710,7 +710,10 @@ test("hidden spoiler images are excluded from gallery navigation until revealed"
710710
.last();
711711
await expect(row).toBeVisible();
712712

713-
await row.locator(`img[src*="${SPOILER_VISIBLE_SHA}"]`).click();
713+
const visibleImage = row.locator(`img[src*="${SPOILER_VISIBLE_SHA}"]`);
714+
await visibleImage.scrollIntoViewIfNeeded();
715+
await waitForAnimations(page);
716+
await visibleImage.click();
714717
const dialog = page.getByRole("dialog");
715718
await expect(dialog).toBeVisible();
716719
await expect(page.getByRole("button", { name: "Next image" })).toHaveCount(0);
@@ -723,7 +726,13 @@ test("hidden spoiler images are excluded from gallery navigation until revealed"
723726
await spoiler.click();
724727
await expect(spoiler).toHaveAttribute("data-revealed", "true");
725728

726-
await row.locator(`img[src*="${SPOILER_VISIBLE_SHA}"]`).click();
729+
// The gallery snapshots visible images when opened; the state attribute
730+
// changes before the spoiler image finishes its opacity transition.
731+
await expect(spoiler.locator(`img[src*="${SPOILER_HIDDEN_SHA}"]`)).toHaveCSS(
732+
"opacity",
733+
"1",
734+
);
735+
await visibleImage.click();
727736
await expect(dialog).toBeVisible();
728737
await expect(page.getByRole("button", { name: "Next image" })).toBeVisible();
729738
});

‎scripts/generate-macos-icon.py‎

Lines changed: 94 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,94 @@
1+
#!/usr/bin/env python3
2+
"""Build the legacy macOS icon without relying on system corner masking.
3+
4+
Run: scripts/macos-icon.sh [--check]
5+
6+
The wrapper pins uv, Python and Pillow. Verification compares the complete set
7+
of decoded RGBA representations, not PNG encoding or ICNS container bytes:
8+
Apple's system iconutil may encode the same pixels differently across macOS.
9+
The shared artwork and other platforms' icons are intentionally untouched.
10+
"""
11+
12+
# /// script
13+
# requires-python = "==3.14.3"
14+
# dependencies = ["Pillow==12.2.0"]
15+
# ///
16+
17+
import argparse
18+
from pathlib import Path
19+
import subprocess
20+
import tempfile
21+
22+
from PIL import Image, ImageDraw
23+
24+
25+
ROOT = Path(__file__).resolve().parent.parent
26+
ICONS = ROOT / "desktop/src-tauri/icons"
27+
28+
29+
def generate(output):
30+
# An 824px tile on a 1024px canvas leaves the macOS optical inset.
31+
# Work at 4x resolution to antialias the rounded edge at every icon size.
32+
scale = 4
33+
canvas = Image.new("RGBA", (1024 * scale, 1024 * scale))
34+
with Image.open(ICONS / "buzz-source.png") as source:
35+
tile = source.convert("RGBA").resize(
36+
(824 * scale, 824 * scale), Image.Resampling.LANCZOS
37+
)
38+
mask = Image.new("L", tile.size)
39+
ImageDraw.Draw(mask).rounded_rectangle(
40+
(0, 0, tile.width - 1, tile.height - 1), radius=185 * scale, fill=255
41+
)
42+
canvas.paste(tile, (100 * scale, 100 * scale), mask)
43+
44+
with tempfile.TemporaryDirectory(prefix="buzz-macos-icon-") as temporary:
45+
iconset = Path(temporary) / "Buzz.iconset"
46+
iconset.mkdir()
47+
for size in (16, 32, 128, 256, 512):
48+
for density in (1, 2):
49+
suffix = "@2x" if density == 2 else ""
50+
canvas.resize(
51+
(size * density, size * density), Image.Resampling.LANCZOS
52+
).save(iconset / f"icon_{size}x{size}{suffix}.png")
53+
subprocess.run(
54+
["/usr/bin/iconutil", "-c", "icns", str(iconset), "-o", str(output)],
55+
check=True,
56+
)
57+
58+
59+
def verify(candidate, reference):
60+
"""Reject missing/extra representations and any decoded pixel drift."""
61+
with tempfile.TemporaryDirectory(prefix="buzz-icon-check-") as temporary:
62+
sets = []
63+
for name, icon in (("candidate", candidate), ("reference", reference)):
64+
iconset = Path(temporary) / f"{name}.iconset"
65+
subprocess.run(
66+
["/usr/bin/iconutil", "-c", "iconset", str(icon), "-o", str(iconset)],
67+
check=True,
68+
)
69+
sets.append({p.name: p for p in iconset.glob("*.png")})
70+
if sets[0].keys() != sets[1].keys():
71+
raise ValueError("macOS icon representation set drifted")
72+
for name in sorted(sets[0]):
73+
with Image.open(sets[0][name]) as a, Image.open(sets[1][name]) as b:
74+
if a.size != b.size or a.convert("RGBA").tobytes() != b.convert("RGBA").tobytes():
75+
raise ValueError(f"macOS icon pixel drift: {name}")
76+
77+
78+
def main():
79+
parser = argparse.ArgumentParser(description=__doc__)
80+
parser.add_argument("--check", action="store_true", help="verify without modifying the icon")
81+
parser.add_argument("--output", type=Path, default=ICONS / "icon.icns")
82+
args = parser.parse_args()
83+
if args.check:
84+
with tempfile.TemporaryDirectory(prefix="buzz-icon-regenerate-") as temporary:
85+
generated = Path(temporary) / "icon.icns"
86+
generate(generated)
87+
verify(args.output, generated)
88+
print("macOS icon: all decoded representations match")
89+
else:
90+
generate(args.output)
91+
92+
93+
if __name__ == "__main__":
94+
main()

‎scripts/macos-icon.sh‎

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
#!/usr/bin/env bash
2+
set -euo pipefail
3+
ROOT="$(cd "$(dirname "$0")/.." && pwd)"
4+
# Hermit pins uv; inline script metadata pins Python and Pillow exactly.
5+
# uv script environments are isolated from the caller's Python packages.
6+
exec "$ROOT/bin/uv" run --managed-python --python 3.14.3 \
7+
--script "$ROOT/scripts/generate-macos-icon.py" "$@"

0 commit comments

Comments
 (0)