on master help sign in
Installer: never leave a missing or empty host manifest; brew hint
ebd0bc6Claude
scripts/install-manifest.sh+16−1
@@ -7,6 +7,7 @@
7# host manifest with that absolute path and the pinned extension ID, then installs the fm schemas
7# host manifest with that absolute path and the pinned extension ID, then installs the fm schemas
8# and runs the self-test. Safe to re-run.
8# and runs the self-test. Safe to re-run.
9set -euo pipefail
9set -euo pipefail
10+trap 'echo "Diagonal host install failed at line $LINENO: $BASH_COMMAND" >&2' ERR
10HERE="$(cd "$(dirname "$0")" && pwd)"
11HERE="$(cd "$(dirname "$0")" && pwd)"
11if [[ -d "$HERE/host" ]]; then cd "$HERE"; else cd "$HERE/.."; fi
12if [[ -d "$HERE/host" ]]; then cd "$HERE"; else cd "$HERE/.."; fi
12
13
@@ -45,10 +46,24 @@ xattr -dr com.apple.quarantine "$SHARE" 2>/dev/null || true
45ln -sf "$SHARE/diagonal-host.py" "$BIN"
46ln -sf "$SHARE/diagonal-host.py" "$BIN"
46echo "host: $BIN -> $SHARE/diagonal-host.py"
47echo "host: $BIN -> $SHARE/diagonal-host.py"
47
48
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
48for ch in "${CHANNELS[@]}"; do
62for ch in "${CHANNELS[@]}"; do
49 DIR="$HOME/Library/Application Support/BraveSoftware/$ch/NativeMessagingHosts"
63 DIR="$HOME/Library/Application Support/BraveSoftware/$ch/NativeMessagingHosts"
50 mkdir -p "$DIR"
64 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"
52 echo "manifest: $DIR/io.diagonal.host.json"
67 echo "manifest: $DIR/io.diagonal.host.json"
53done
68done
54
69
src/background/host.ts+1−1
@@ -111,7 +111,7 @@ export function explain(error: HostError | undefined, extensionId = ""): string
111 if (!error) return "";
111 if (!error) return "";
112 switch (error.code) {
112 switch (error.code) {
113 case "HOST_NOT_FOUND":
113 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`;
115 case "HOST_FORBIDDEN":
115 case "HOST_FORBIDDEN":
116 case "FORBIDDEN_ORIGIN":
116 case "FORBIDDEN_ORIGIN":
117 return `The host does not allow this extension. Its manifest needs "allowed_origins": ["chrome-extension://${extensionId}/"]`;
117 return `The host does not allow this extension. Its manifest needs "allowed_origins": ["chrome-extension://${extensionId}/"]`;