minhvo.vercel.app

Tue Mar 03 2026

Git Account Switcher

Git Account Switcher

Native macOS menu bar app for atomic, transactional GitHub account switching — Keychain, git config, and gh CLI in one click.

Overview

A native macOS desktop app to switch between multiple GitHub accounts with a single click. It updates the macOS Keychain credentials, the global git config (user.name / user.email), and the GitHub CLI session — all in a single transaction with rollback on failure.

I shipped this twice: once with Electrobun + Bun + native macOS WebView for the smaller binary, and a parallel native version in Swift + SwiftUI (GitAccountSwitcher) to compare first-paint, memory, and DX.

Features

  • Instant Account Switching with atomic, transactional updates
  • Keychain Integration via git credential-osxkeychain
  • Git Config Management of ~/.gitconfig
  • GitHub CLI Support through gh auth switch
  • System Tray menu for switching without opening the main window
  • Credential Discovery auto-detects existing GitHub credentials from Keychain on first launch
  • Encrypted Storage — account data stored in AES-256-GCM JSON files
  • Rollback on Failure — any failed step rolls back to the previous state
  • Launch at Login via a LaunchAgent plist
  • Glass-effect UI with spring-physics animations

Technical Stack

LayerTechnology
FrameworkElectrobun v1
RuntimeBun
FrontendReact 18 + Tailwind CSS 3 + Vite
AnimationsFramer Motion (spring physics)
LanguageTypeScript
StorageEncrypted JSON (AES-256-GCM)
IPCElectrobun typed RPC

Implementation Highlights

  • Transactional switch: every switch composes Keychain writes + git config writes + gh auth switch into a single unit; any failure unwinds all prior writes
  • Typed RPC between the Bun main process and the WebView, modeled after Electron's IPC but enforced through a shared rpc-types.ts schema
  • Native WebView via Electrobun yielded an installer ~10× smaller than equivalent Electron builds, at the cost of a longer cold-start vs the Swift variant
  • Side-by-side comparison with the SwiftUI build informed the tradeoff write-up: SwiftUI wins on first-paint and idle memory; Electrobun wins on cross-platform reuse

Role & Responsibilities

  • Architected the transactional credential update with rollback semantics
  • Wrote the Bun-side services (Keychain, git config, gh detection, notifications, LaunchAgent)
  • Built the React UI, welcome wizard, and CLI setup wizard
  • Shipped the parallel SwiftUI implementation for benchmarking