feat(git): Add comprehensive worktree management capabilities

This update introduces full support for Git worktrees, allowing users to manage multiple isolated working copies within a single repository. This includes new functionality to list, add, remove, move, lock, and repair worktrees, significantly enhancing the repository's capability to handle parallel development streams.

- Added `GitWorktree` structure definition across API contracts and Rust backend
- Implemented full CRUD operations for worktrees in Tauri commands
- Updated UI components (App.svelte, BranchPanel.svelte) to expose worktree management dialog
This commit is contained in:
Christoph Brandau
2026-07-26 21:47:35 +02:00
parent afa85b97aa
commit 38b7f1a536
9 changed files with 1406 additions and 14 deletions
+251
View File
@@ -3261,6 +3261,19 @@
box-shadow: var(--app-dialog-shadow), 0 0 0 1px rgba(255, 90, 103, 0.04);
overflow: auto;
}
.worktree-dialog {
grid-template-rows: auto auto auto minmax(0, 1fr) auto;
width: min(920px, calc(100vw - 32px));
height: min(820px, calc(100vh - 32px));
border-color: rgba(77, 182, 214, 0.24);
}
.worktree-confirm-dialog {
grid-template-rows: auto auto auto;
width: min(520px, calc(100vw - 32px));
height: auto;
max-height: calc(100vh - 32px);
}
.worktree-nested-backdrop { z-index: 70; }
.ai-settings-dialog {
display: block;
width: min(560px, calc(100vw - 32px));
@@ -3884,6 +3897,244 @@
font-weight: 600;
}
.branch-delete-confirm { min-width: 116px; }
.worktree-dialog-header {
background:
linear-gradient(90deg, rgba(77, 182, 214, 0.09), transparent 40%),
var(--app-dialog-chrome);
}
.worktree-dialog-heading { display: flex; align-items: center; gap: 11px; }
.worktree-dialog-mark {
display: grid;
place-items: center;
width: 34px;
height: 34px;
border: 1px solid rgba(77, 182, 214, 0.3);
border-radius: 9px;
color: #8ed8ee;
background: rgba(77, 182, 214, 0.1);
box-shadow: inset 0 1px 0 rgba(255,255,255,0.05);
}
.worktree-summary {
display: grid;
grid-template-columns: repeat(3, minmax(0, 1fr)) auto;
align-items: stretch;
gap: 1px;
padding: 1px 0;
border-bottom: 1px solid var(--color-border-subtle);
background: var(--color-border-subtle);
}
.worktree-summary > div {
display: flex;
align-items: baseline;
gap: 7px;
min-width: 0;
padding: 11px 14px;
background: var(--app-dialog-bg);
}
.worktree-summary > div strong { color: var(--color-ink); font-family: var(--font-mono); font-size: 14px; }
.worktree-summary > div span { overflow: hidden; color: var(--color-ink-faint); font-size: 10.5px; font-weight: 700; text-overflow: ellipsis; white-space: nowrap; }
.worktree-summary > div.attention strong { color: #ffc07a; }
.worktree-summary > .btn-primary { align-self: center; margin: 0 14px; white-space: nowrap; }
.worktree-error {
display: flex;
align-items: center;
gap: 8px;
padding: 9px 16px;
border-bottom: 1px solid rgba(255, 90, 103, 0.2);
color: #ffb8bf;
background: rgba(255, 90, 103, 0.08);
font-size: 11.5px;
font-weight: 650;
}
.worktree-content {
min-height: 0;
overflow: auto;
padding: 14px;
background:
radial-gradient(circle at 92% 0%, rgba(77, 182, 214, 0.055), transparent 28%),
var(--app-dialog-bg);
}
.worktree-create-card {
display: grid;
gap: 14px;
margin-bottom: 14px;
padding: 14px;
border: 1px solid rgba(77, 182, 214, 0.26);
border-radius: 10px;
background: var(--color-surface-raised);
box-shadow: inset 0 1px 0 rgba(255,255,255,0.035);
}
.worktree-create-card > header { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.worktree-create-card h3 { margin: 3px 0 0; color: var(--color-ink); font-size: 13px; font-weight: 700; }
.worktree-mode-tabs {
display: grid;
grid-template-columns: repeat(3, 1fr);
gap: 3px;
padding: 3px;
border: 1px solid var(--color-border-subtle);
border-radius: 8px;
background: rgba(0, 0, 0, 0.14);
}
.worktree-mode-tabs button {
display: flex;
align-items: center;
justify-content: center;
gap: 6px;
min-height: 32px;
border-color: transparent;
color: var(--color-ink-faint);
background: transparent;
font-size: 10.5px;
font-weight: 750;
}
.worktree-mode-tabs button.active {
border-color: rgba(77, 182, 214, 0.27);
color: #b8e7f6;
background: rgba(77, 182, 214, 0.11);
box-shadow: 0 3px 12px rgba(0,0,0,0.14);
}
.worktree-create-fields { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
.worktree-create-fields label,
.worktree-lock-body label { display: grid; gap: 5px; color: var(--color-ink-dim); font-size: 10.5px; font-weight: 750; }
.worktree-create-fields input,
.worktree-create-fields select,
.worktree-lock-body input { width: 100%; min-width: 0; }
.worktree-create-fields .worktree-path-field { grid-column: 1 / -1; }
.worktree-path-field > div { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 7px; }
.worktree-create-card > footer { display: flex; align-items: center; justify-content: space-between; gap: 14px; }
.worktree-check { display: flex; align-items: flex-start; gap: 8px; color: var(--color-ink-muted); font-size: 11px; cursor: pointer; }
.worktree-check input { width: auto; margin-top: 2px; }
.worktree-check span { display: grid; gap: 1px; }
.worktree-check strong { color: var(--color-ink); font-size: 11px; }
.worktree-check small { color: var(--color-ink-faint); font-size: 10px; font-weight: 500; }
.worktree-check.danger strong,
.worktree-check.danger small { color: #ffb8bf; }
.worktree-list { display: grid; gap: 8px; }
.worktree-card {
position: relative;
display: grid;
grid-template-columns: 28px minmax(0, 1fr);
min-width: 0;
border: 1px solid var(--color-border-subtle);
border-radius: 9px;
background: var(--color-surface-raised);
overflow: hidden;
}
.worktree-card.current { border-color: rgba(77, 182, 214, 0.34); box-shadow: inset 0 0 0 1px rgba(77, 182, 214, 0.06); }
.worktree-card.stale { border-color: rgba(255, 151, 61, 0.28); }
.worktree-rail {
position: relative;
display: grid;
place-items: start center;
padding-top: 18px;
background: rgba(0,0,0,0.1);
}
.worktree-rail::before {
content: "";
position: absolute;
top: 0;
bottom: 0;
left: 50%;
width: 1px;
background: rgba(77, 182, 214, 0.22);
}
.worktree-rail span {
position: relative;
z-index: 1;
width: 9px;
height: 9px;
border: 2px solid #76cde7;
border-radius: 50%;
background: var(--color-surface-solid);
box-shadow: 0 0 0 3px rgba(77, 182, 214, 0.08);
}
.worktree-rail i {
position: absolute;
top: 31px;
left: 50%;
width: 7px;
height: 14px;
border-bottom: 1px solid rgba(77, 182, 214, 0.26);
border-left: 1px solid rgba(77, 182, 214, 0.26);
}
.worktree-card-main { display: grid; gap: 9px; min-width: 0; padding: 12px; }
.worktree-card-main > header { display: flex; align-items: flex-start; justify-content: space-between; gap: 10px; }
.worktree-name { display: flex; align-items: center; gap: 8px; min-width: 0; color: var(--color-accent); }
.worktree-name > div { display: grid; gap: 1px; min-width: 0; }
.worktree-name strong { overflow: hidden; color: var(--color-ink); font-size: 12.5px; text-overflow: ellipsis; white-space: nowrap; }
.worktree-name span { color: var(--color-ink-faint); font-size: 10px; }
.worktree-badges { display: flex; align-items: center; justify-content: flex-end; flex-wrap: wrap; gap: 4px; }
.worktree-badges span {
display: inline-flex;
align-items: center;
gap: 3px;
padding: 2px 6px;
border: 1px solid var(--color-border-subtle);
border-radius: 999px;
color: var(--color-ink-faint);
background: rgba(255,255,255,0.025);
font-size: 8.5px;
font-weight: 800;
letter-spacing: 0.04em;
text-transform: uppercase;
}
.worktree-badges span.active { border-color: rgba(78, 202, 118, 0.25); color: #77d99a; background: rgba(78, 202, 118, 0.08); }
.worktree-badges span.locked { border-color: rgba(111, 140, 255, 0.26); color: #aebcff; background: rgba(111, 140, 255, 0.08); }
.worktree-badges span.danger { border-color: rgba(255, 151, 61, 0.3); color: #ffc07a; background: rgba(255, 151, 61, 0.08); }
.worktree-path { display: flex; align-items: center; gap: 5px; min-width: 0; color: var(--color-ink-faint); }
.worktree-path code { overflow: hidden; font-family: var(--font-mono); font-size: 10.5px; text-overflow: ellipsis; white-space: nowrap; }
.worktree-meta { display: flex; align-items: center; flex-wrap: wrap; gap: 6px 12px; color: var(--color-ink-faint); font-size: 9.5px; }
.worktree-meta span { display: inline-flex; align-items: center; gap: 4px; }
.worktree-meta span.dirty,
.worktree-meta span.danger { color: #ffc07a; }
.worktree-card-main > footer { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding-top: 2px; }
.worktree-card-actions { display: flex; align-items: center; justify-content: flex-end; flex-wrap: wrap; gap: 5px; }
.worktree-card-actions .danger { border-color: rgba(255, 90, 103, 0.2); color: #ff9aa4; background: rgba(255, 90, 103, 0.06); }
.worktree-dialog-footer {
display: flex;
align-items: center;
justify-content: space-between;
gap: 12px;
padding: 10px 14px;
border-top: 1px solid var(--color-border-subtle);
background: var(--app-dialog-chrome);
}
.worktree-dialog-footer > div { display: flex; align-items: center; gap: 6px; color: var(--color-ink-faint); font-size: 10px; }
.worktree-loading,
.worktree-empty {
display: grid;
place-items: center;
align-content: center;
gap: 7px;
min-height: 240px;
color: var(--color-ink-faint);
text-align: center;
font-size: 11px;
}
.worktree-empty strong { color: var(--color-ink); font-size: 13px; }
.worktree-confirm-body {
display: grid;
grid-template-columns: auto minmax(0, 1fr);
gap: 13px;
padding: 17px 16px;
}
.worktree-confirm-body > div { display: grid; gap: 10px; min-width: 0; }
.worktree-confirm-body p { margin: 0; color: var(--color-ink-muted); font-size: 12px; line-height: 1.45; }
.worktree-confirm-body code { overflow: auto; padding: 8px; border: 1px solid var(--color-border-subtle); border-radius: 6px; color: var(--color-ink); background: rgba(0,0,0,0.16); font-size: 10.5px; }
.worktree-lock-body { padding: 18px 16px; }
.worktree-lock-body label > span { display: flex; align-items: baseline; justify-content: space-between; }
.worktree-lock-body small { color: var(--color-ink-faint); font-size: 9.5px; font-weight: 500; }
@media (max-width: 700px) {
.worktree-summary { grid-template-columns: repeat(3, 1fr); }
.worktree-summary > div { display: grid; gap: 2px; }
.worktree-summary > .btn-primary { grid-column: 1 / -1; margin: 9px 14px; }
.worktree-create-fields { grid-template-columns: 1fr; }
.worktree-create-fields .worktree-path-field { grid-column: auto; }
.worktree-create-card > footer,
.worktree-card-main > footer { align-items: stretch; flex-direction: column; }
.worktree-card-actions { justify-content: flex-start; }
.worktree-dialog-footer > div { display: none; }
}
.discard-target-list {
display: grid;
gap: 4px;