theepicsaxguyandChris Scott da283a82cf Feature/enhanced source control (#138)
* feat: enhance source control with discard and commit detail views

- Add discard changes functionality with confirmation dialog
- Implement commit detail view with file list and diffs
- Update commit badges: blue for unpushed (local), purple for pushed (remote)
- Display current branch in commits header
- Reuse existing components (DeleteDialog, FileDiffView, GitFlatFileList)
- Add proper error handling and toast notifications
- Extend backend API with /discard and /commit/:hash endpoints
- Update types to include CommitDetails and CommitFile interfaces

Backend:
- Add discardChanges() method to GitService
- Add getCommitDetails() and getCommitDiff() methods
- Add POST /:id/git/discard endpoint
- Add GET /:id/git/commit/:hash and /:id/git/commit/:hash/diff endpoints

Frontend:
- Add discard button (rotate-left icon) to file items
- Add gitDiscardFiles API function and useGit mutation
- Create CommitDetailView component
- Update CommitsTab with color coding and branch display
- Extend SourceControlPanel for commit detail navigation
- Add confirmation dialog using DeleteDialog pattern

Tests:
- Backend tests passing with 77% line coverage
- Linting passes for all modified files
- Type safety maintained throughout

BREAKING CHANGES: None

* Fix critical bugs from code review

- Fix syntax error in GitService.ts (missing closing brace for getCommitDiff)
- Make AUTH_SECRET mandatory in crypto.ts to prevent weak encryption fallback
- Fix race condition in PassphraseHandler by using unique request IDs
- Add error logging to ssh-key-manager catch blocks
- Add type guards (isGitCredential, filterGitCredentials) to replace unsafe assertions
- Fix TypeScript errors and variable shadowing in GitService and settings
- Remove unused variable in sshHostKeyHandler
- Update GitService tests with proper mock data structure

All changes verified: lint passes, typecheck passes, 102/103 tests pass

* Fix critical bugs from code review

- Fix git restore command syntax (--source=HEAD → --source HEAD)
- Use crypto.randomBytes for secure requestId generation
- Add requestId to SSH host key broadcast for frontend compatibility
- Add missing onDiscard prop to GitFlatFileList
- Remove dead code (187 unreachable lines) in ChangesTab
- Fix regex alternation bug in commit stat parsing
- Optimize getCommitDetails with --numstat (N+1 → 1 git call)
- Optimize unpushed commit check to use merge-base instead of full list
- Remove useless conditional in handleDiscard
- Fix type contract violation in CommitDetailView onSelect

* fix: resolve code review issues

- Add missing handleDiscard function in ChangesTab.tsx
- Fix duplicate requestId property in sshHostKeyHandler.ts
- Remove unnecessary type assertion in settings.ts

* feat: enhance source control with commit view improvements and diff fixes

- Add readOnly mode to GitFlatFileList to hide stage/unstage buttons in commit view
- Fix commit file diff display by using correct git show command syntax
- Add line stats display (+additions/-deletions) for each file in commit view
- Show total commit stats in header (Changed Files N +X -Y)
- Fix commit file list parsing to use --name-status and --numstat
- Add 500KB diff size limit with truncation warning
- Fix discard changes for untracked files by deleting them directly
- Update Dockerfile to copy backend/node_modules correctly
- Fix TypeScript error in CommitDetailView onFileSelect call

* Refactor API error handling and enhance source control functionality

* Fix code review issues: OAuth error handling, unpushed detection, comments, and duplicates

- Remove shared handleApiError import from OAuth and restore local pattern

- Fix isCommitUnpushed to use getUnpushedCommitHashes for correct upstream detection

- Remove inline comments from ssh-key-manager.ts (style violation)

- Remove duplicate fetchCommitDiff function

- Add missing getErrorMessage import to repo-git.ts

* Refactor imports and type assertions in GitService, SSH tests, and handleApiError

* Refactor GitService methods for improved error handling and code clarity; add discardChanges functionality and enhance commit details retrieval

* Refactor Git and SSH services: streamline imports, enhance error handling, and remove unused code

* Refactor source control components: remove unused useGitAction hook and enhance error handling in handleGitAction

* Enhance error handling in Git routes and improve UI components for better user experience

* Remove unnecessary blank line in GitService class

* Fix commit log parsing and rename detection in GitService

* Refactor source control UI for full-screen diffs, improve mobile view, and add discard confirmation dialog

* Fix lint warnings and ignore test files in GitGuardian scan

---------

Co-authored-by: Chris Scott <99081550+chriswritescode-dev@users.noreply.github.com>
2026-02-21 21:57:05 -05:00
2026-02-15 19:48:03 -05:00
2025-11-23 23:25:27 -05:00
2026-01-17 14:15:59 -05:00
2025-11-23 22:17:21 -05:00
2026-02-16 21:16:54 -05:00

OpenCode Manager

OpenCode Manager

Mobile-first web interface for OpenCode AI agents. Manage, control, and code from any device - your phone, tablet, or desktop.

OpenCode Manager Demo

Quick Start

git clone https://github.com/chriswritescode-dev/opencode-manager.git
cd opencode-manager
docker-compose up -d
# Open http://localhost:5003

On first launch, you'll be prompted to create an admin account. That's it!

Screenshots

Chat (Mobile)
chat-mobile
File Browser (Mobile)
files-mobile
Inline Diff View
inline-diff-view

Features

Repository & Git

  • Multi-Repository Support - Clone and manage multiple git repos with private repo support via GitHub PAT
  • SSH Authentication - SSH key authentication for git repositories
  • Git Worktrees - Work on multiple branches simultaneously
  • Source Control Panel - View changes, commits, and branches in a unified interface
  • Diff Viewer - Unified diffs with line numbers and change counts
  • Push PRs - Create and push pull requests directly from the UI

File Management

  • Directory Browser - Navigate files with tree view and search
  • Syntax Highlighting - Code preview with highlighting for all major languages
  • File Operations - Create, rename, delete, and drag-and-drop upload
  • ZIP Download - Download repos as ZIP (respects .gitignore)

Chat & Sessions

  • Real-time Streaming - Live message streaming with SSE
  • Slash Commands - Built-in (/help, /new, /compact) and custom commands
  • File Mentions - Reference files with @filename autocomplete
  • Plan/Build Modes - Toggle between read-only and file-change modes
  • Mermaid Diagrams - Visual diagram rendering in chat
  • Text-to-Speech - Listen to AI responses with browser or OpenAI-compatible TTS
  • Speech-to-Text - Dictate messages using browser speech recognition or OpenAI-compatible STT

AI Configuration

  • Model Selection - Browse and filter available AI models
  • Provider Management - Configure API keys or OAuth for providers
  • OAuth Support - Secure OAuth login for Anthropic and GitHub Copilot
  • Custom Agents - Create agents with custom system prompts and tool permissions
  • MCP Servers - Add local or remote MCP servers with pre-built templates

Mobile & PWA

  • Mobile-First Design - Responsive UI optimized for mobile
  • PWA Installable - Add to home screen on any device
  • iOS Optimized - Proper keyboard handling and swipe navigation
  • Push Notifications - Background alerts for agent events when app is closed

Installation

git clone https://github.com/chriswritescode-dev/opencode-manager.git
cd opencode-manager
docker-compose up -d

The container automatically installs OpenCode, builds the frontend, and sets up persistent volumes.

Common commands:

docker-compose up -d      # Start
docker-compose down       # Stop
docker-compose logs -f    # View logs
docker-compose restart    # Restart

Local Development

For contributors who want to develop locally:

# Prerequisites: pnpm, Bun, OpenCode TUI (npm i -g @opencode/tui)

git clone https://github.com/chriswritescode-dev/opencode-manager.git
cd opencode-manager
pnpm install
cp .env.example .env
pnpm dev

Configuration

Authentication

OpenCode Manager uses single-user authentication. Create your admin account on first launch, or pre-configure via environment variables:

# Pre-configured admin (optional)
ADMIN_EMAIL=admin@example.com
ADMIN_PASSWORD=your-secure-password

# Required for production
AUTH_SECRET=your-secure-random-secret  # Generate with: openssl rand -base64 32

Remote/LAN Access

For HTTP access on local networks:

AUTH_TRUSTED_ORIGINS=http://localhost:5003
AUTH_SECURE_COOKIES=false  # Required when not using HTTPS (cookies won't work over plain HTTP otherwise)

OAuth Providers (Optional)

Enable social login by configuring OAuth credentials:

# GitHub
GITHUB_CLIENT_ID=...
GITHUB_CLIENT_SECRET=...

# Google
GOOGLE_CLIENT_ID=...
GOOGLE_CLIENT_SECRET=...

# Discord
DISCORD_CLIENT_ID=...
DISCORD_CLIENT_SECRET=...

Passkeys

For WebAuthn/passkey support:

PASSKEY_RP_ID=yourdomain.com
PASSKEY_RP_NAME=OpenCode Manager
PASSKEY_ORIGIN=https://yourdomain.com

Push Notifications (VAPID)

Enable push notifications for the PWA (background alerts for agent questions, permission requests, errors, and session completions):

# Generate keys: npx web-push generate-vapid-keys
VAPID_PUBLIC_KEY=your-public-key
VAPID_PRIVATE_KEY=your-private-key
VAPID_SUBJECT=mailto:you@yourdomain.com

Important: VAPID_SUBJECT MUST use mailto: format for iOS/Safari push notifications to work. Apple's push service rejects https:// subjects.

Dev Server Ports

The Docker container exposes ports 5100-5103 for running dev servers inside repositories:

# Example: Vite
server: { port: 5100, host: '0.0.0.0' }

# Access at http://localhost:5100

Documentation

For detailed guides and configuration reference, see the Documentation Site.

License

MIT

Languages
TypeScript 99.5%
Shell 0.3%
CSS 0.1%