feat: add remote management functionality

- Introduced a new route for adding remotes to git worktrees.
- Enhanced the PushToRemoteDialog component to support adding new remotes, including form handling and error management.
- Updated the API client to include an endpoint for adding remotes.
- Modified the worktree state management to track the presence of remotes.
- Improved the list branches handler to check for configured remotes.

This update allows users to easily add remotes through the UI, enhancing the overall git workflow experience.
This commit is contained in:
Shirone
2026-01-21 22:11:16 +01:00
parent c3cecc18f2
commit a9616ff309
12 changed files with 1142 additions and 95 deletions

View File

@@ -330,7 +330,14 @@ export type {
export { EVENT_HISTORY_VERSION, DEFAULT_EVENT_HISTORY_INDEX } from './event-history.js';
// Worktree and PR types
export type { PRState, WorktreePRInfo } from './worktree.js';
export type {
PRState,
WorktreePRInfo,
AddRemoteRequest,
AddRemoteResult,
AddRemoteResponse,
AddRemoteErrorResponse,
} from './worktree.js';
export { PR_STATES, validatePRState } from './worktree.js';
// Terminal types

View File

@@ -30,3 +30,47 @@ export interface WorktreePRInfo {
state: PRState;
createdAt: string;
}
/**
* Request payload for adding a git remote
*/
export interface AddRemoteRequest {
/** Path to the git worktree/repository */
worktreePath: string;
/** Name for the remote (e.g., 'origin', 'upstream') */
remoteName: string;
/** URL of the remote repository (HTTPS, SSH, or git:// protocol) */
remoteUrl: string;
}
/**
* Result data from a successful add-remote operation
*/
export interface AddRemoteResult {
/** Name of the added remote */
remoteName: string;
/** URL of the added remote */
remoteUrl: string;
/** Whether the initial fetch was successful */
fetched: boolean;
/** Human-readable status message */
message: string;
}
/**
* Successful response from add-remote endpoint
*/
export interface AddRemoteResponse {
success: true;
result: AddRemoteResult;
}
/**
* Error response from add-remote endpoint
*/
export interface AddRemoteErrorResponse {
success: false;
error: string;
/** Optional error code for specific error types (e.g., 'REMOTE_EXISTS') */
code?: string;
}