Skip to content

Commit 2746323

Browse files
sallyomclaude
andcommitted
feat: Improve git repository context UX (Issue #376)
Enhances the user experience for adding git repositories as context. Frontend UX Improvements: 1. Enhanced Add Context Modal - Repository options with base/feature branch configuration, protected branch detection, sync configuration 2. Improved Repository Dialog - Branch configuration with branch fetching, protected branch warnings, sync support 3. Enhanced Repository Display - Visual badges, color-coded branch pills, improved layout Co-Authored-By: Claude Sonnet 4.5 <[email protected]> Signed-off-by: sallyom <[email protected]>
1 parent fc75f47 commit 2746323

File tree

11 files changed

+925
-110
lines changed

11 files changed

+925
-110
lines changed

components/frontend/package-lock.json

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

components/frontend/package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
"@radix-ui/react-accordion": "^1.2.12",
1414
"@radix-ui/react-avatar": "^1.1.10",
1515
"@radix-ui/react-checkbox": "^1.3.3",
16+
"@radix-ui/react-collapsible": "^1.1.12",
1617
"@radix-ui/react-dropdown-menu": "^2.1.16",
1718
"@radix-ui/react-label": "^2.1.7",
1819
"@radix-ui/react-progress": "^1.1.7",

components/frontend/src/app/projects/[name]/sessions/[sessionName]/components/accordions/repositories-accordion.tsx

Lines changed: 71 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,21 @@
11
"use client";
22

33
import { useState } from "react";
4-
import { GitBranch, X, Link, Loader2, CloudUpload } from "lucide-react";
4+
import { GitBranch, X, Link, Loader2, CloudUpload, GitMerge, Shield } from "lucide-react";
55
import { AccordionItem, AccordionTrigger, AccordionContent } from "@/components/ui/accordion";
66
import { Badge } from "@/components/ui/badge";
77
import { Button } from "@/components/ui/button";
88

99
type Repository = {
1010
url: string;
1111
branch?: string;
12+
baseBranch?: string;
13+
featureBranch?: string;
14+
allowProtectedWork?: boolean;
15+
sync?: {
16+
url: string;
17+
branch?: string;
18+
};
1219
};
1320

1421
type UploadedFile = {
@@ -78,7 +85,7 @@ export function RepositoriesAccordion({
7885
<p className="text-sm text-muted-foreground">
7986
Add additional context to improve AI responses.
8087
</p>
81-
88+
8289
{/* Context Items List (Repos + Uploaded Files) */}
8390
{totalContextItems === 0 ? (
8491
<div className="text-center py-6">
@@ -98,26 +105,70 @@ export function RepositoriesAccordion({
98105
const repoName = repo.url.split('/').pop()?.replace('.git', '') || `repo-${idx}`;
99106
const isRemoving = removingRepo === repoName;
100107

108+
// Determine which branch info to show
109+
const baseBranch = repo.baseBranch || repo.branch || 'main';
110+
const featureBranch = repo.featureBranch;
111+
const hasSync = !!repo.sync?.url;
112+
const allowProtected = repo.allowProtectedWork;
113+
101114
return (
102-
<div key={`repo-${idx}`} className="flex items-center gap-2 p-2 border rounded bg-muted/30 hover:bg-muted/50 transition-colors">
103-
<GitBranch className="h-4 w-4 text-muted-foreground flex-shrink-0" />
104-
<div className="flex-1 min-w-0">
105-
<div className="text-sm font-medium truncate">{repoName}</div>
106-
<div className="text-xs text-muted-foreground truncate">{repo.url}</div>
115+
<div key={`repo-${idx}`} className="border rounded-lg bg-muted/30 hover:bg-muted/50 transition-colors">
116+
<div className="flex items-start gap-2 p-3">
117+
<GitBranch className="h-4 w-4 text-muted-foreground flex-shrink-0 mt-0.5" />
118+
<div className="flex-1 min-w-0">
119+
<div className="flex items-center gap-2 mb-1">
120+
<div className="text-sm font-medium truncate">{repoName}</div>
121+
{hasSync && (
122+
<Badge variant="outline" className="text-xs">
123+
<GitMerge className="h-3 w-3 mr-1" />
124+
Synced
125+
</Badge>
126+
)}
127+
{allowProtected && (
128+
<Badge variant="outline" className="text-xs text-orange-600 border-orange-300">
129+
<Shield className="h-3 w-3 mr-1" />
130+
Protected
131+
</Badge>
132+
)}
133+
</div>
134+
<div className="text-xs text-muted-foreground truncate mb-2">{repo.url}</div>
135+
136+
{/* Branch information */}
137+
<div className="flex flex-wrap gap-1 text-xs">
138+
<div className="inline-flex items-center gap-1 bg-background px-2 py-0.5 rounded border">
139+
<span className="text-muted-foreground">Base:</span>
140+
<span className="font-mono">{baseBranch}</span>
141+
</div>
142+
{featureBranch && (
143+
<div className="inline-flex items-center gap-1 bg-blue-50 dark:bg-blue-950 px-2 py-0.5 rounded border border-blue-200 dark:border-blue-800">
144+
<span className="text-blue-700 dark:text-blue-300">Feature:</span>
145+
<span className="font-mono text-blue-900 dark:text-blue-100">{featureBranch}</span>
146+
</div>
147+
)}
148+
{hasSync && (
149+
<div className="inline-flex items-center gap-1 bg-green-50 dark:bg-green-950 px-2 py-0.5 rounded border border-green-200 dark:border-green-800">
150+
<GitMerge className="h-3 w-3 text-green-600 dark:text-green-400" />
151+
<span className="text-green-700 dark:text-green-300">
152+
{repo.sync?.url.split('/').pop()?.replace('.git', '')}
153+
</span>
154+
</div>
155+
)}
156+
</div>
157+
</div>
158+
<Button
159+
variant="ghost"
160+
size="sm"
161+
className="h-7 w-7 p-0 flex-shrink-0"
162+
onClick={() => handleRemoveRepo(repoName)}
163+
disabled={isRemoving}
164+
>
165+
{isRemoving ? (
166+
<Loader2 className="h-3 w-3 animate-spin" />
167+
) : (
168+
<X className="h-3 w-3" />
169+
)}
170+
</Button>
107171
</div>
108-
<Button
109-
variant="ghost"
110-
size="sm"
111-
className="h-7 w-7 p-0 flex-shrink-0"
112-
onClick={() => handleRemoveRepo(repoName)}
113-
disabled={isRemoving}
114-
>
115-
{isRemoving ? (
116-
<Loader2 className="h-3 w-3 animate-spin" />
117-
) : (
118-
<X className="h-3 w-3" />
119-
)}
120-
</Button>
121172
</div>
122173
);
123174
})}
@@ -166,4 +217,3 @@ export function RepositoriesAccordion({
166217
</AccordionItem>
167218
);
168219
}
169-

0 commit comments

Comments
 (0)