-
Notifications
You must be signed in to change notification settings - Fork 27
Git Source Control Integration #74
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Git Source Control Integration #74
Conversation
- 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.
…te into RepoDetail and SessionDetail pages
- 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.
…redential handling
…r handling in repo commands
…ironment variable handling
- 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
There was a problem hiding this 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
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)
Major Backend Git Refactoring
Created dedicated modular Git services:
GitStatusServiceGitDiffServiceGitCommitServiceGitPushServiceGitBranchServiceGitFetchPullServiceGitLogServiceImplemented IPC-based git-askpass mechanism (similar to VSCode) for secure credential handling
askpass-main.ts+askpass.shscriptsIPCServer+AskpassHandlerRemoved old monolithic
git-operations.tsfileUI/UX Improvements
Other Changes
Screenshots
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:
Looking forward to your feedback and any suggestions for further refinement!
Thank you for reviewing.