summaryrefslogtreecommitdiffhomepage
path: root/packaging/electron
diff options
context:
space:
mode:
authorAdam Malczewski <[email protected]>2026-05-27 23:17:18 +0900
committerAdam Malczewski <[email protected]>2026-05-27 23:17:18 +0900
commit60f56367dfc1e3c5095d034bed4fb4f572e32b55 (patch)
treeaa4bc7be095e7030ce0b1a67e33b1abe4cc8c36a /packaging/electron
parent4f0ed4ed9456e30344228f0106f6bb104417da3d (diff)
downloaddispatch-60f56367dfc1e3c5095d034bed4fb4f572e32b55.tar.gz
dispatch-60f56367dfc1e3c5095d034bed4fb4f572e32b55.zip
refactor(packaging): split into dispatch/dispatch-systemd/dispatch-s6, separate dispatch-electron, add bun-based frontend serve
PKGBUILD is now a split package producing three .pkg.tar.zst files in one makepkg run: - dispatch base application files (/opt/dispatch), CLI wrappers (dispatch-api, dispatch-frontend), env configs (/etc/dispatch/dispatch-api.conf, /etc/dispatch/dispatch-frontend.conf) - dispatch-systemd systemd user units for dispatch-api + dispatch-frontend (conflicts with dispatch-s6) - dispatch-s6 s6-rc service pipelines (-srv + -log) for both services (conflicts with dispatch-systemd) The Electron desktop wrapper moved to its own self-contained PKGBUILD at packaging/electron/, producing dispatch-electron. It bundles its own copy of the frontend dist + electron entry points under /opt/dispatch-electron and does not depend on the base dispatch package, so users can install it standalone and point VITE_API_URL at any backend at build time. Files under packaging/ are now read directly from ${_projectdir}/packaging/ rather than via source=(); the two s6 service dirs share basenames (run, type) which would collide inside ${srcdir}. New frontend static server: packages/frontend/serve.ts uses Bun's built-in HTTP server (no extra runtime deps) with SPA fallback to index.html and path-traversal protection. PORT/HOST/DIST_DIR overridable via env. Exposed as 'bun run --cwd packages/frontend serve' and via /usr/bin/dispatch-frontend. Build scripts: - bin/build-pkg now prints the freshest built packages - bin/install-pkg installs dispatch + dispatch-systemd by default; accepts package names or --all; searches both packaging/ and packaging/electron/ - bin/build-pkg-electron new, builds the electron split - bin/build-pkg-windows replaces bin/windows-pkg; drops the hard-coded WSL copy step, just prints the win-unpacked path .gitignore extended to cover packaging/*.tar.zst and packaging/electron/{src,pkg,*.pkg.tar.zst,*.tar.zst}.
Diffstat (limited to 'packaging/electron')
-rw-r--r--packaging/electron/PKGBUILD100
-rwxr-xr-xpackaging/electron/dispatch-electron-wrapper.sh2
-rw-r--r--packaging/electron/dispatch-electron.install32
-rw-r--r--packaging/electron/dispatch.desktop9
-rw-r--r--packaging/electron/dispatch.pngbin0 -> 10192 bytes
-rw-r--r--packaging/electron/dispatch.svg24
6 files changed, 167 insertions, 0 deletions
diff --git a/packaging/electron/PKGBUILD b/packaging/electron/PKGBUILD
new file mode 100644
index 0000000..a259418
--- /dev/null
+++ b/packaging/electron/PKGBUILD
@@ -0,0 +1,100 @@
+# Maintainer: dispatch
+#
+# Electron desktop wrapper for Dispatch on Linux.
+#
+# Self-contained: bundles its own copy of the built frontend dist + electron
+# entry points under /opt/dispatch-electron/. Does NOT depend on the `dispatch`
+# package — install that separately (with dispatch-systemd or dispatch-s6) if
+# you want to run the backend locally, or point VITE_API_URL at a remote
+# instance at build time.
+#
+# Build with:
+# bin/build-pkg-electron # makepkg -fd in packaging/electron/
+#
+# Override the backend URL the bundled frontend talks to:
+# VITE_API_URL="http://your-host:18390" bin/build-pkg-electron
+
+pkgname=dispatch-electron
+pkgver=0.0.1
+pkgrel=1
+pkgdesc='Electron desktop wrapper for Dispatch (self-contained)'
+arch=('x86_64')
+url='https://github.com/anomalyco/dispatch'
+license=('MIT')
+depends=('electron')
+makedepends=('bun')
+install=dispatch-electron.install
+source=()
+sha256sums=()
+
+_projectdir="${startdir}/../.."
+_packagingdir="${_projectdir}/packaging"
+_electrondir="${_packagingdir}/electron"
+
+prepare() {
+ mkdir -p "${srcdir}/dispatch-electron-${pkgver}"
+
+ # Copy project files into the src build directory (preserve symlinks)
+ cp -a \
+ "${_projectdir}/packages" \
+ "${_projectdir}/package.json" \
+ "${_projectdir}/bun.lock" \
+ "${_projectdir}/tsconfig.base.json" \
+ "${srcdir}/dispatch-electron-${pkgver}/"
+}
+
+build() {
+ cd "${srcdir}/dispatch-electron-${pkgver}"
+
+ # Install all deps (including devDependencies for vite build)
+ bun install --frozen-lockfile
+
+ # Build the SPA. VITE_API_URL is baked in at build time.
+ VITE_API_URL="${VITE_API_URL:-http://localhost:18390}" \
+ bun run --cwd packages/frontend build
+}
+
+package() {
+ cd "${srcdir}/dispatch-electron-${pkgver}"
+
+ local optdir="${pkgdir}/opt/dispatch-electron"
+
+ # --- Bundled SPA dist ---
+ install -dm755 "${optdir}/dist"
+ cp -a packages/frontend/dist/. "${optdir}/dist/"
+
+ # --- Electron entry points ---
+ # main.cjs loads ../dist/index.html — so the dist must sit alongside electron/.
+ install -Dm644 \
+ packages/frontend/electron/main.cjs \
+ "${optdir}/electron/main.cjs"
+ install -Dm644 \
+ packages/frontend/electron/preload.cjs \
+ "${optdir}/electron/preload.cjs"
+
+ # --- /usr/bin/dispatch (electron wrapper) ---
+ install -Dm755 \
+ "${_electrondir}/dispatch-electron-wrapper.sh" \
+ "${pkgdir}/usr/bin/dispatch"
+
+ # --- Desktop integration ---
+ install -Dm644 \
+ "${_electrondir}/dispatch.desktop" \
+ "${pkgdir}/usr/share/applications/dispatch.desktop"
+
+ install -Dm644 \
+ "${_electrondir}/dispatch.svg" \
+ "${pkgdir}/usr/share/icons/hicolor/scalable/apps/dispatch.svg"
+
+ if [ -f "${_electrondir}/dispatch.png" ]; then
+ install -Dm644 \
+ "${_electrondir}/dispatch.png" \
+ "${pkgdir}/usr/share/icons/hicolor/512x512/apps/dispatch.png"
+ fi
+
+ # --- License ---
+ if [ -f "${_projectdir}/LICENSE" ]; then
+ install -Dm644 "${_projectdir}/LICENSE" \
+ "${pkgdir}/usr/share/licenses/${pkgname}/LICENSE"
+ fi
+}
diff --git a/packaging/electron/dispatch-electron-wrapper.sh b/packaging/electron/dispatch-electron-wrapper.sh
new file mode 100755
index 0000000..948db3b
--- /dev/null
+++ b/packaging/electron/dispatch-electron-wrapper.sh
@@ -0,0 +1,2 @@
+#!/bin/bash
+exec /usr/bin/electron --name="Dispatch" /opt/dispatch-electron/electron/main.cjs "$@"
diff --git a/packaging/electron/dispatch-electron.install b/packaging/electron/dispatch-electron.install
new file mode 100644
index 0000000..9eea6b1
--- /dev/null
+++ b/packaging/electron/dispatch-electron.install
@@ -0,0 +1,32 @@
+post_install() {
+ echo ""
+ echo "==> Dispatch Electron desktop wrapper installed (self-contained)."
+ echo " Launch from your menu (Dispatch) or run:"
+ echo " dispatch"
+ echo ""
+ echo " The bundled frontend talks to the API URL baked in at build"
+ echo " time (default: http://localhost:18390). To run a local backend:"
+ echo " pacman -S dispatch dispatch-systemd # systemd"
+ echo " pacman -S dispatch dispatch-s6 # s6 / Artix"
+ echo ""
+ echo " To point the wrapper at a different backend, rebuild with:"
+ echo " VITE_API_URL=\"http://your-host:18390\" bin/build-pkg-electron"
+ echo ""
+
+ if command -v update-desktop-database >/dev/null 2>&1; then
+ update-desktop-database -q /usr/share/applications 2>/dev/null || true
+ fi
+ if command -v gtk-update-icon-cache >/dev/null 2>&1; then
+ gtk-update-icon-cache -q /usr/share/icons/hicolor 2>/dev/null || true
+ fi
+}
+
+post_upgrade() {
+ post_install
+}
+
+post_remove() {
+ if command -v update-desktop-database >/dev/null 2>&1; then
+ update-desktop-database -q /usr/share/applications 2>/dev/null || true
+ fi
+}
diff --git a/packaging/electron/dispatch.desktop b/packaging/electron/dispatch.desktop
new file mode 100644
index 0000000..0ed44af
--- /dev/null
+++ b/packaging/electron/dispatch.desktop
@@ -0,0 +1,9 @@
+[Desktop Entry]
+Name=Dispatch
+Comment=AI Agent Dispatch Interface
+Exec=/usr/bin/dispatch %U
+Icon=dispatch
+Terminal=false
+Type=Application
+Categories=Development;Utility;
+StartupWMClass=Dispatch
diff --git a/packaging/electron/dispatch.png b/packaging/electron/dispatch.png
new file mode 100644
index 0000000..84d743a
--- /dev/null
+++ b/packaging/electron/dispatch.png
Binary files differ
diff --git a/packaging/electron/dispatch.svg b/packaging/electron/dispatch.svg
new file mode 100644
index 0000000..2aae97f
--- /dev/null
+++ b/packaging/electron/dispatch.svg
@@ -0,0 +1,24 @@
+<?xml version="1.0" encoding="UTF-8" standalone="no"?>
+<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 64 64" width="64" height="64">
+ <defs>
+ <linearGradient id="bg" x1="0%" y1="0%" x2="100%" y2="100%">
+ <stop offset="0%" style="stop-color:#5b6af0"/>
+ <stop offset="100%" style="stop-color:#9b59f7"/>
+ </linearGradient>
+ <linearGradient id="arrow" x1="0%" y1="0%" x2="100%" y2="100%">
+ <stop offset="0%" style="stop-color:#ffffff;stop-opacity:1"/>
+ <stop offset="100%" style="stop-color:#e0d8ff;stop-opacity:1"/>
+ </linearGradient>
+ </defs>
+
+ <!-- Rounded square background -->
+ <rect x="2" y="2" width="60" height="60" rx="14" ry="14" fill="url(#bg)"/>
+
+ <!-- Send/dispatch arrow icon: a paper-plane style arrow pointing upper-right -->
+ <!-- Main arrow body -->
+ <polygon points="10,50 54,10 38,32" fill="url(#arrow)" opacity="0.95"/>
+ <!-- Arrow tail fill -->
+ <polygon points="10,50 28,36 22,54" fill="url(#arrow)" opacity="0.75"/>
+ <!-- Subtle highlight line -->
+ <line x1="54" y1="10" x2="28" y2="36" stroke="white" stroke-width="1.5" stroke-linecap="round" opacity="0.5"/>
+</svg>