Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions Casks/orca.rb
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,13 @@

app "Orca.app"

# Why: expose the bundled `orca` CLI on PATH at install time (Homebrew symlinks
# this into its already-on-PATH bin dir). Without it, the CLI is only registered
# by the in-app "Install CLI" action, which a headless host can never trigger —
# so `orca serve` on a server would be unreachable from the shell. The shim
# resolves the real app by walking symlinks, so the Homebrew symlink works.
binary "#{appdir}/Orca.app/Contents/Resources/bin/orca"

# Why: Orca writes user data under ~/.orca (worktrees, agent state) and
# Electron's standard userData directories. Zap removes everything the app
# creates during normal use so `brew uninstall --zap` is a clean slate.
Expand Down
7 changes: 7 additions & 0 deletions Casks/orca@rc.rb
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,13 @@

app "Orca.app"

# Why: expose the bundled `orca` CLI on PATH at install time (Homebrew symlinks
# this into its already-on-PATH bin dir). Without it, the CLI is only registered
# by the in-app "Install CLI" action, which a headless host can never trigger —
# so `orca serve` on a server would be unreachable from the shell. The shim
# resolves the real app by walking symlinks, so the Homebrew symlink works.
binary "#{appdir}/Orca.app/Contents/Resources/bin/orca"

# Why: Orca writes user data under ~/.orca (worktrees, agent state) and
# Electron's standard userData directories. Zap removes everything the app
# creates during normal use so `brew uninstall --zap` is a clean slate.
Expand Down
13 changes: 11 additions & 2 deletions config/electron-builder.config.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -281,7 +281,13 @@ module.exports = {
// Why: xvfb lets the bundled `orca serve` CLI run browser panes on a headless
// Linux host — Chromium needs a display server even for offscreen rendering,
// and serve starts Xvfb itself when present (see ensure-virtual-display.ts).
depends: ['python3', 'python3-gi', 'gir1.2-atspi-2.0', 'at-spi2-core', 'xdotool', 'xclip', 'xvfb']
depends: ['python3', 'python3-gi', 'gir1.2-atspi-2.0', 'at-spi2-core', 'xdotool', 'xclip', 'xvfb'],
// Why: symlink the bundled CLI onto PATH at install time so `orca-ide serve`
// works on a headless host. The in-app CLI registration (CliInstaller) is
// GUI-triggered and can never run on a server, so without this the CLI is
// unreachable from the shell on exactly the hosts that need it.
afterInstall: 'resources/linux/packaging/after-install.sh',
afterRemove: 'resources/linux/packaging/after-remove.sh'
},
rpm: {
packageName: 'orca-ide',
Expand All @@ -295,7 +301,10 @@ module.exports = {
'xdotool',
'xclip',
'xorg-x11-server-Xvfb'
]
],
// Why: same headless CLI-on-PATH registration as deb; rpm runs these via fpm.
afterInstall: 'resources/linux/packaging/after-install.sh',
afterRemove: 'resources/linux/packaging/after-remove.sh'
},
beforeBuild: electronBuilderNativeRebuild,
// Why: must be true so that electron-builder rebuilds native modules
Expand Down
25 changes: 25 additions & 0 deletions resources/linux/packaging/after-install.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
#!/bin/bash
# Why: register the bundled `orca-ide` CLI on PATH at package-install time.
# The in-app "Install CLI" action (CliInstaller) can never run on a headless
# server, so without this symlink `orca serve` is unreachable from the shell on
# the exact hosts that need it most. deb/rpm both run this after unpacking.
#
# The shim resolves the real app by walking up from its own location, so a
# symlink works. We discover the install dir instead of hardcoding /opt/Orca
# because electron-builder's directory name can vary by productName sanitization.
set -e

link="/usr/bin/orca-ide"

for dir in /opt/Orca /opt/orca-ide /opt/orca; do
shim="$dir/resources/bin/orca-ide"
if [ -x "$shim" ]; then
# Only manage our own symlink; never clobber an unrelated /usr/bin/orca-ide.
if [ ! -e "$link" ] || [ -L "$link" ]; then
ln -sf "$shim" "$link"
Comment on lines +18 to +19

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟠 Major | ⚡ Quick win

Avoid overwriting unrelated existing symlinks at /usr/bin/orca-ide.

Current logic force-replaces any symlink target, so an unrelated symlink at the same path gets clobbered. That contradicts the script’s own safety contract.

Suggested fix
-    if [ ! -e "$link" ] || [ -L "$link" ]; then
-      ln -sf "$shim" "$link"
-    fi
+    if [ ! -e "$link" ]; then
+      ln -s "$shim" "$link"
+    elif [ -L "$link" ]; then
+      current_target="$(readlink "$link" || true)"
+      case "$current_target" in
+        /opt/Orca/*|/opt/orca-ide/*|/opt/orca/*)
+          ln -sf "$shim" "$link"
+          ;;
+      esac
+    fi
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
if [ ! -e "$link" ] || [ -L "$link" ]; then
ln -sf "$shim" "$link"
if [ ! -e "$link" ]; then
ln -s "$shim" "$link"
elif [ -L "$link" ]; then
current_target="$(readlink "$link" || true)"
case "$current_target" in
/opt/Orca/*|/opt/orca-ide/*|/opt/orca/*)
ln -sf "$shim" "$link"
;;
esac
fi

fi
break
fi
done

exit 0
18 changes: 18 additions & 0 deletions resources/linux/packaging/after-remove.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
#!/bin/bash
# Why: remove the PATH symlink that after-install.sh created, but only if it
# still points into an Orca install dir — never delete an unrelated
# /usr/bin/orca-ide a user or other package may own.
set -e

link="/usr/bin/orca-ide"

if [ -L "$link" ]; then
target="$(readlink "$link" || true)"
case "$target" in
/opt/Orca/*|/opt/orca-ide/*|/opt/orca/*)
rm -f "$link"
;;
esac
fi

exit 0
Loading