on master help sign in
Installer: never leave a missing or empty host manifest; brew hint

The manifest is now written by the installer itself and moved into place, instead of being printed by the host into a redirect that could leave an empty file if python3 failed. The host is checked to start first, and any failing step prints the line that failed. The popup's "not installed" message now suggests `brew reinstall diagonal`. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01LdKDAYoqmGehyHsV42LhJW

commitebd0bc65ff6736d3d290daa10a7597cdb8e9b71e authorClaude <noreply@anthropic.com> dateWed 23 Sep 2026, 20:09 (2 weeks ago) parent4e43454
2 files changed+17−2
scripts/install-manifest.sh+16−1 src/background/host.ts+1−1
scripts/install-manifest.sh+16−1
@@ -7,6 +7,7 @@
77# host manifest with that absolute path and the pinned extension ID, then installs the fm schemas
88# and runs the self-test. Safe to re-run.
99set -euo pipefail
10+trap 'echo "Diagonal host install failed at line $LINENO: $BASH_COMMAND" >&2' ERR
1011HERE="$(cd "$(dirname "$0")" && pwd)"
1112if [[ -d "$HERE/host" ]]; then cd "$HERE"; else cd "$HERE/.."; fi
1213
@@ -45,10 +46,24 @@ xattr -dr com.apple.quarantine "$SHARE" 2>/dev/null || true
4546ln -sf "$SHARE/diagonal-host.py" "$BIN"
4647echo "host: $BIN -> $SHARE/diagonal-host.py"
4748
49+# Written here rather than by the host, so a python3 problem cannot leave an empty manifest behind,
50+# and moved into place so Brave never reads a half-written one.
51+MANIFEST=$(cat <<JSON
52+{
53+ "name": "io.diagonal.host",
54+ "description": "Diagonal: names tab groups with Apple's on-device model",
55+ "path": "$BIN",
56+ "type": "stdio",
57+ "allowed_origins": ["chrome-extension://$ID/"]
58+}
59+JSON
60+)
61+"$BIN" --version >/dev/null # the host must start with the python3 it was pinned to
4862for ch in "${CHANNELS[@]}"; do
4963 DIR="$HOME/Library/Application Support/BraveSoftware/$ch/NativeMessagingHosts"
5064 mkdir -p "$DIR"
51− "$BIN" --print-manifest "$BIN" > "$DIR/io.diagonal.host.json"
65+ printf '%s\n' "$MANIFEST" > "$DIR/io.diagonal.host.json.tmp"
66+ mv -f "$DIR/io.diagonal.host.json.tmp" "$DIR/io.diagonal.host.json"
5267 echo "manifest: $DIR/io.diagonal.host.json"
5368done
5469
src/background/host.ts+1−1
@@ -111,7 +111,7 @@ export function explain(error: HostError | undefined, extensionId = ""): string
111111 if (!error) return "";
112112 switch (error.code) {
113113 case "HOST_NOT_FOUND":
114− return `Native host not installed. In Terminal, run: bash <the Diagonal folder>/install-host.command (expected manifest at ${HOST_MANIFEST_PATH})`;
114+ return `Native host not installed (no manifest at ${HOST_MANIFEST_PATH}). Installed with Homebrew? Run: brew reinstall diagonal. Otherwise run: bash <the Diagonal folder>/install-host.command`;
115115 case "HOST_FORBIDDEN":
116116 case "FORBIDDEN_ORIGIN":
117117 return `The host does not allow this extension. Its manifest needs "allowed_origins": ["chrome-extension://${extensionId}/"]`;