Home

DESKTOP_APP_DESIGN

Git Chat Desktop (macOS) — Packaging + Distribution Design Doc

Status: Draft (Milestone/Story reference)

Problem

We want to share Git Chat with friends as a macOS app (e.g., .app/.dmg) that:

Goals

Non-goals (for this milestone)


Current State (As-Is)

Frontend (web-frontend/)

Backend (../web-backend/)


Key Findings / Constraints

1) Security: current backend is not safe to expose

As written, if the backend port is reachable from the network, it can become “remote shell execution”. For a desktop app we should:

2) LocalStorage persistence depends on origin

If the UI is served from http://127.0.0.1:<randomPort>, changing the port changes the origin, which will lose localStorage-based state across launches. Implication: prefer a stable origin (e.g., Electron app:// protocol), or a stable port.

3) Native module packaging

Backend dependency sqlite3 is native. If we package it inside Electron, we must rebuild it for the Electron runtime during builds. End users should not compile anything.

4) GUI launch environment on macOS

When launching from Finder, environment variables (including shell init) can differ from Terminal. Even with zsh -l -c, some users’ toolchains (nvm/asdf/pyenv) may not load if configured only in .zshrc. We should plan for:


Recommendation (Milestone)

Choose Electron first

Electron is the fastest path to a shareable Mac app with an eventual auto-update story.

Tauri remains a good future option if we want smaller bundles later.


Proposed Architecture (To-Be)

Process Model

Alternative (simpler but less robust): backend serves the UI on a fixed port.


Backend Changes Needed

Configurability

Add env/config support (names TBD):

Authentication

Require token for:

Tighten network surface

Path validation hardening

Current startsWith() checks can be fooled by prefix collisions. Use a safer check:

Workspace watching and scanning

Data location

Store SQLite and logs under DATA_DIR (Electron app.getPath('userData')).


Frontend Changes Needed

Runtime API base URL

Add a small helper (example contract):

Auth token plumbing

Keep “web mode” working


Electron App Outline

Main process responsibilities

Backend spawn approach

Spawn Electron’s embedded Node:

Packaging


Distribution + Auto-Update (Later)

Early friend builds

Auto-update target


Milestone Plan (Checklist)

Phase 0 — Baseline (local dev)

Phase 1 — Electron dev shell

Phase 2 — Bundle backend + local-only security

Phase 3 — Package unsigned DMG

Phase 4 — Updates (optional in this milestone)


Open Questions

  1. Should the desktop app support multiple workspace roots or just one active workspace at a time?
  2. Do we want a fixed backend port (simpler) or dynamic port (avoids conflicts) + stable UI origin?
  3. Should command execution be limited to repos under the selected workspace only (recommended), or allow arbitrary paths?
  4. For shell environment: do we need zsh -lic as an option to better load nvm/asdf/pyenv?
  5. Preferred update channel: GitHub Releases, private S3, or something else?
READ i