Skip to content

Conversation

@theepicsaxguy
Copy link
Contributor

Very excited about this one! it brings OpenCode-Manager much closer to a real mobile-first IDE experience.

This PR introduces a complete, modern Git source control experience in OpenCode with a new dedicated panel and significantly refactored backend Git handling.

Main Features Added

New Source Control Panel (Frontend)

  • New modal-style Source Control panel (accessible from repo header)
  • Three tabs:
    • Changes — staged/unstaged files with inline stage/unstage actions
    • Commits — recent commit history (last 50)
    • Branches — complete local/remote branch list with ahead/behind indicators
  • diff viewer integrated in the Changes tab
  • Commit message input with ⌘/Ctrl+Enter shortcut
  • Fetch / Pull / Push buttons with loading states
  • Mobile-friendly full-screen experience

Major Backend Git Refactoring

  • Created dedicated modular Git services:

    • GitStatusService
    • GitDiffService
    • GitCommitService
    • GitPushService
    • GitBranchService
    • GitFetchPullService
    • GitLogService
  • Implemented IPC-based git-askpass mechanism (similar to VSCode) for secure credential handling

    • askpass-main.ts + askpass.sh scripts
    • IPCServer + AskpassHandler
    • Credentials stored safely in settings
  • Removed old monolithic git-operations.ts file

UI/UX Improvements

  • New visual style for git status indicators (amber for dirty, green for clean)
  • Better branch switcher with ahead/behind visualization
  • Improved error messages & toast feedback for git operations

Other Changes

  • Updated AGENTS.md guidelines: SOLID + YAGNI + no dead code
  • Updated README with new Source Control Panel description
  • Improved git environment handling & credential injection

Screenshots

  1. Source Control Panel - Changes tab
bild bild bild
  1. Source Control Panel - Branches tab
bild
  1. Source Control Panel - Commits tab
bild
  1. Inline diff viewer
bild
  1. New branch creation flow
bild

Related Issues

Closes #57

Final Notes

This PR ended up significantly larger than planned.
After multiple attempts to split the work into smaller, incremental changes, it became clear that delivering a coherent, pleasant, and reliable Git experience required most of these pieces (UI panel, modular services, secure credential handling, askpass system) to be implemented together.

The result is a solid, well-structured foundation:

  • The new service classes are cleanly separated and easy to extend.
  • The IPC-based askpass system is already protocol-agnostic → SSH support should be relatively straightforward to add later.
  • The branch & checkout infrastructure is now much more robust → worktree support would also be comparatively easy to build on top.

Looking forward to your feedback and any suggestions for further refinement!
Thank you for reviewing.

- Introduced `CommitsTab` for displaying commit history with relative time formatting.
- Added `GitFlatFileItem` and `GitFlatFileList` for managing file statuses in the source control panel.
- Implemented `SourceControlPanel` to encapsulate source control functionalities including changes, commits, and branches.
- Enhanced `useGit` hook to manage git operations such as fetch, pull, push, commit, stage, and unstage files with appropriate error handling and toast notifications.
- Updated `RepoDetail` to integrate the new source control panel and provide a user interface for source control actions.
- Defined `GitCommit` type for better type safety in commit-related operations.
- Remove unused imports and clean up code in repos.ts and git-operations.ts.
- Simplify error handling in repo.ts by enforcing message property in ErrorWithMessage interface.
- Update GitPushService to remove unnecessary database parameter in methods.
- Enhance executeCommand function to better handle command execution results.
- Update tests to use mocked functions for better isolation and clarity.
- Add specific ESLint rules for test files to accommodate common testing patterns.
- Introduce tsconfig.test.json for better TypeScript configuration in tests.
- Update vitest.config.ts to use the new test TypeScript configuration.
- Add GitAuthService to handle Git environment setup with credentials.
- Refactor GitBranchService, GitCommitService, GitFetchPullService, GitPushService, GitStatusService, and GitLogService to utilize the new GitAuthService.
- Remove GitCommandUtils and related error handling for Git operations.
- Delete git-operations.ts and associated tests as functionality is now integrated into other services.
- Update TypeScript configuration to enable composite projects for better build management.
- Add `requires_auth` column to repos table
- Implement auth check in GitAuthService
- Update cloneRepo to detect public/private repos
- Add test coverage for auth-related functionality
- Improve UI styling for auth-related indicators
- Add GitAskpassService to handle credential requests from Git
- Implement askpass script that communicates with backend
- Update GitAuthService to use askpass instead of direct credential
  injection
- Add new endpoint for branch listing and status
- Improve branch name handling in GitBranchService
- Enhance error handling in GitDiffService for untracked files
- Add upstream branch checking and setup in GitFetchPullService
- Update UI components for better visual consistency
- Fix various minor UI styling issues
- Update askpass endpoint to handle hostname parameter and return full
  credential object
- Replace `createNoPromptGitEnv` with `createSilentGitEnv` for better
  VSCode compatibility
- Add compiled Node.js askpass script for broader compatibility
- Enhance GitBranchService to return detailed branch information with
  upstream tracking
- Improve branch listing UI with better sorting and display
- Update GitAuthService to use askpass for all operations with proper
  credential handling
- Fix various UI styling issues in diff view and source control panel
- Update test mocks to use new silent environment function
- Add proper error handling and credential caching in GitAskpassService
- Add new IPC server infrastructure for handling Git credential requests
- Implement AskpassHandler to manage Git authentication through IPC
- Replace previous HTTP-based askpass system with local IPC
  communication
- Remove deprecated GitAskpassService and related HTTP endpoints
- Update GitAuthService to use IPC-based authentication flow
- Add new shell scripts for Git askpass integration (askpass.sh,
  askpass-main.js)
- Remove database column 'requires_auth' as it's no longer needed
- Update all Git service classes to use new authentication approach
- Improve error handling and credential caching
- Add proper cleanup for IPC server on shutdown
- Handle empty response bodies in askpass-main.ts to prevent JSON parse errors
- Add logging to IPC server for debugging request/response issues
- Add logging to AskpassHandler for credential lookup visibility
Silent fetch operations (used when fetching commit history on repo open)
should return empty credentials gracefully rather than failing, allowing
git to proceed without credentials for public repos or cached credentials.
- Log handler registration and lookup paths
- Log incoming request details
- Log handler response results
- Add detailed stderr logging to askpass-main.ts for all steps
- Log environment variables and paths at initialization
- Log IPC connection attempts and responses
- Log JSON parsing results

This will help trace where the IPC communication fails.
…IPC requests

- Log GIT_ASKPASS, VSCODE_GIT_IPC_HANDLE, GIT_TERMINAL_PROMPT env vars when executing git
- Log all incoming IPC requests with URL and body
- Log handler registration status
- Add GitAuthService parameter to all repo service functions
- Replace direct git env creation with GitAuthService.getGitEnvironment()
- Update route handlers to pass GitAuthService to service calls
- Remove createSilentGitEnv utility in favor of centralized auth
- Ensure consistent git authentication across all operations
- Remove GitFetchService and consolidate into GitFetchPullService
- Clean up duplicate git authentication logic across services
- Simplify repo service by removing redundant environment handling
- Update tests to reflect consolidated service structure
- Remove unused imports and streamline API endpoints
- Reduce codebase complexity by eliminating service duplication
- Fix unstaged file diff showing all changes instead of working directory only
- Remove auto-refresh (10s) to reduce git command spam
- Add reset/revert mutation for unpushed local commits
- Fix branch creation/switching to update database
- Add unpushed commit detection and visual indicator in commits tab
- Handle no-upstream branch status gracefully
- Fix branch name parsing to use full name instead of regex capturing only first word
- Add refresh button for branches
- Show remote branches with Globe icon and make them non-clickable
- Add 'local' label for branches without upstream tracking
- Handle remotes/ prefix properly in branch detection
- Extract branch name before whitespace/bracket in git branch -vv -a output
- When clicking remote branch, checkout local tracking branch instead of remote reference
- Set full height on mobile for better screen utilization
- Add larger centered close button on mobile
- Hide default close button when custom one is shown on mobile
The test credential button in settings was broken because it tried to test
authentication against just the host URL (e.g., https://github.com/) instead
of a repository path. Since git credentials are already handled correctly
through the askpass mechanism when cloning repositories, the test button
was redundant and has been removed.

Changes:
- Remove /test-credential endpoint from settings routes
- Remove testGitCredential API from frontend
- Remove TestCredentialRequest/Response types
- Remove test button and related state from GitSettings component
Copilot AI review requested due to automatic review settings January 19, 2026 00:16
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR introduces a comprehensive Git source control integration for OpenCode-Manager, adding a new Source Control panel with advanced Git operations, modular backend services, and secure credential handling via an IPC-based askpass mechanism.

Changes:

  • New Source Control Panel UI with Changes, Commits, and Branches tabs
  • Modular Git services (Status, Diff, Commit, Push, Fetch/Pull, Log, Branch)
  • IPC-based git-askpass system for secure credential handling
  • Improved Git credential management UI with test functionality
  • Removed monolithic git-operations.ts in favor of service-based architecture

Reviewed changes

Copilot reviewed 68 out of 68 changed files in this pull request and generated 8 comments.

Show a summary per file
File Description
frontend/src/types/git.ts Defines Git types including duplicate GitCommit interface
frontend/src/pages/SessionDetail.tsx Integrates Source Control button and panel
frontend/src/pages/RepoDetail.tsx Adds Source Control integration with CSS typo
frontend/src/components/source-control/* New Source Control panel components
frontend/src/components/settings/GitSettings.tsx Refactored credential management UI
frontend/src/hooks/useGit.ts Custom hook for Git operations with mutations
frontend/src/api/git.ts Expanded Git API with error handling
backend/src/services/git/* New modular Git service classes
backend/src/services/git-auth.ts New GitAuthService for credential handling
backend/test/services/git/* Comprehensive tests for Git services

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

- Remove duplicate GitCommit interface definition
- Fix CSS typos: bg-linear-to-br -> bg-gradient-to-br
- Fix typo: /sessflex-shrink-0 -> flex-shrink-0
- Add *.test.js to .gitignore and remove compiled test files
- Fix missing closing brace in useGit.test.tsx
- Remove unused maskToken function
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Allow git actions

1 participant