@agent-relay/dashboard 2.0.80 → 2.0.82
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/out/404.html +1 -1
- package/out/_next/static/chunks/{118-4c8241b0218335de.js → 118-ae2b650136a5a5fc.js} +1 -1
- package/out/_next/static/chunks/407-0c82986cf79c8ecb.js +1 -0
- package/out/_next/static/chunks/app/app/[[...slug]]/{page-1e81c047cff17212.js → page-f7eca1b66fb4249b.js} +1 -1
- package/out/_next/static/chunks/app/{page-6892fe2dd07fb48b.js → page-0ee604f7070d14c0.js} +1 -1
- package/out/_next/static/css/8968d98ed4c4d33f.css +1 -0
- package/out/about.html +2 -2
- package/out/about.txt +1 -1
- package/out/app/onboarding.html +1 -1
- package/out/app/onboarding.txt +1 -1
- package/out/app.html +1 -1
- package/out/app.txt +2 -2
- package/out/blog/go-to-bed-wake-up-to-a-finished-product.html +2 -2
- package/out/blog/go-to-bed-wake-up-to-a-finished-product.txt +1 -1
- package/out/blog/let-them-cook-multi-agent-orchestration.html +2 -2
- package/out/blog/let-them-cook-multi-agent-orchestration.txt +2 -2
- package/out/blog.html +2 -2
- package/out/blog.txt +1 -1
- package/out/careers.html +2 -2
- package/out/careers.txt +1 -1
- package/out/changelog.html +2 -2
- package/out/changelog.txt +1 -1
- package/out/cloud/link.html +1 -1
- package/out/cloud/link.txt +2 -2
- package/out/complete-profile.html +2 -2
- package/out/complete-profile.txt +1 -1
- package/out/connect-repos.html +1 -1
- package/out/connect-repos.txt +1 -1
- package/out/contact.html +2 -2
- package/out/contact.txt +1 -1
- package/out/docs.html +2 -2
- package/out/docs.txt +1 -1
- package/out/history.html +1 -1
- package/out/history.txt +2 -2
- package/out/index.html +1 -1
- package/out/index.txt +2 -2
- package/out/login.html +2 -2
- package/out/login.txt +1 -1
- package/out/metrics.html +1 -1
- package/out/metrics.txt +2 -2
- package/out/pricing.html +2 -2
- package/out/pricing.txt +1 -1
- package/out/privacy.html +2 -2
- package/out/privacy.txt +1 -1
- package/out/providers/setup/claude.html +1 -1
- package/out/providers/setup/claude.txt +1 -1
- package/out/providers/setup/codex.html +1 -1
- package/out/providers/setup/codex.txt +1 -1
- package/out/providers/setup/cursor.html +1 -1
- package/out/providers/setup/cursor.txt +1 -1
- package/out/providers.html +1 -1
- package/out/providers.txt +1 -1
- package/out/security.html +2 -2
- package/out/security.txt +1 -1
- package/out/signup.html +2 -2
- package/out/signup.txt +1 -1
- package/out/terms.html +2 -2
- package/out/terms.txt +1 -1
- package/package.json +7 -1
- package/src/app/about/page.tsx +7 -0
- package/src/app/app/[[...slug]]/DashboardPageClient.tsx +853 -0
- package/src/app/app/[[...slug]]/page.tsx +23 -0
- package/src/app/app/onboarding/page.tsx +394 -0
- package/src/app/apple-icon.png +0 -0
- package/src/app/blog/go-to-bed-wake-up-to-a-finished-product/page.tsx +88 -0
- package/src/app/blog/let-them-cook-multi-agent-orchestration/page.tsx +93 -0
- package/src/app/blog/page.tsx +15 -0
- package/src/app/careers/page.tsx +7 -0
- package/src/app/changelog/page.tsx +7 -0
- package/src/app/cloud/link/page.tsx +464 -0
- package/src/app/complete-profile/page.tsx +204 -0
- package/src/app/connect-repos/page.tsx +410 -0
- package/src/app/contact/page.tsx +7 -0
- package/src/app/docs/page.tsx +7 -0
- package/src/app/favicon.png +0 -0
- package/src/app/globals.css +200 -0
- package/src/app/history/page.tsx +658 -0
- package/src/app/layout.tsx +25 -0
- package/src/app/login/page.tsx +424 -0
- package/src/app/metrics/page.tsx +781 -0
- package/src/app/page.tsx +59 -0
- package/src/app/pricing/page.tsx +7 -0
- package/src/app/privacy/page.tsx +7 -0
- package/src/app/providers/page.tsx +193 -0
- package/src/app/providers/setup/[provider]/ProviderSetupClient.tsx +197 -0
- package/src/app/providers/setup/[provider]/constants.ts +35 -0
- package/src/app/providers/setup/[provider]/page.tsx +42 -0
- package/src/app/security/page.tsx +7 -0
- package/src/app/signup/page.tsx +533 -0
- package/src/app/terms/page.tsx +7 -0
- package/src/components/ActivityFeed.tsx +216 -0
- package/src/components/AddWorkspaceModal.tsx +170 -0
- package/src/components/AgentCard.test.tsx +134 -0
- package/src/components/AgentCard.tsx +585 -0
- package/src/components/AgentList.test.tsx +147 -0
- package/src/components/AgentList.tsx +419 -0
- package/src/components/AgentLogPreview.tsx +173 -0
- package/src/components/AgentProfilePanel.tsx +569 -0
- package/src/components/App.tsx +3424 -0
- package/src/components/BillingPanel.tsx +922 -0
- package/src/components/BillingResult.tsx +447 -0
- package/src/components/BroadcastComposer.tsx +690 -0
- package/src/components/ChannelAdminPanel.tsx +773 -0
- package/src/components/ChannelBrowser.tsx +385 -0
- package/src/components/ChannelChat.tsx +261 -0
- package/src/components/ChannelSidebar.tsx +399 -0
- package/src/components/CloudSessionProvider.tsx +130 -0
- package/src/components/CommandPalette.tsx +815 -0
- package/src/components/ConfirmationDialog.tsx +133 -0
- package/src/components/ConversationHistory.tsx +518 -0
- package/src/components/CoordinatorPanel.tsx +956 -0
- package/src/components/DecisionQueue.tsx +717 -0
- package/src/components/DirectMessageView.tsx +164 -0
- package/src/components/FileAutocomplete.tsx +368 -0
- package/src/components/FleetOverview.tsx +278 -0
- package/src/components/LogViewer.tsx +310 -0
- package/src/components/LogViewerPanel.tsx +482 -0
- package/src/components/Logo.tsx +284 -0
- package/src/components/MentionAutocomplete.tsx +384 -0
- package/src/components/MessageComposer.tsx +473 -0
- package/src/components/MessageList.tsx +725 -0
- package/src/components/MessageSenderName.tsx +91 -0
- package/src/components/MessageStatusIndicator.tsx +142 -0
- package/src/components/NewConversationModal.tsx +400 -0
- package/src/components/NotificationToast.tsx +488 -0
- package/src/components/OnlineUsersIndicator.tsx +164 -0
- package/src/components/Pagination.tsx +124 -0
- package/src/components/PricingPlans.tsx +386 -0
- package/src/components/ProjectList.tsx +711 -0
- package/src/components/ProviderAuthFlow.tsx +343 -0
- package/src/components/ProviderConnectionList.tsx +375 -0
- package/src/components/ProvisioningProgress.tsx +730 -0
- package/src/components/ReactionChips.tsx +70 -0
- package/src/components/ReactionPicker.tsx +121 -0
- package/src/components/RepoAccessPanel.tsx +787 -0
- package/src/components/RepositoriesPanel.tsx +901 -0
- package/src/components/ServerCard.tsx +202 -0
- package/src/components/SessionExpiredModal.tsx +128 -0
- package/src/components/SpawnModal.test.tsx +190 -0
- package/src/components/SpawnModal.tsx +1001 -0
- package/src/components/TaskAssignmentUI.tsx +375 -0
- package/src/components/TerminalProviderSetup.tsx +517 -0
- package/src/components/ThemeProvider.tsx +159 -0
- package/src/components/ThinkingIndicator.tsx +231 -0
- package/src/components/ThreadList.tsx +198 -0
- package/src/components/ThreadPanel.tsx +405 -0
- package/src/components/TrajectoryViewer.tsx +698 -0
- package/src/components/TypingIndicator.tsx +69 -0
- package/src/components/UsageBanner.tsx +231 -0
- package/src/components/UserProfilePanel.tsx +233 -0
- package/src/components/WorkspaceContext.tsx +95 -0
- package/src/components/WorkspaceSelector.tsx +234 -0
- package/src/components/WorkspaceStatusIndicator.tsx +396 -0
- package/src/components/XTermInteractive.tsx +516 -0
- package/src/components/XTermLogViewer.tsx +719 -0
- package/src/components/channels/ChannelDialogs.tsx +1411 -0
- package/src/components/channels/ChannelHeader.tsx +317 -0
- package/src/components/channels/ChannelMessageList.tsx +463 -0
- package/src/components/channels/ChannelViewV1.tsx +146 -0
- package/src/components/channels/MessageInput.tsx +302 -0
- package/src/components/channels/SearchInput.tsx +172 -0
- package/src/components/channels/SearchResults.tsx +336 -0
- package/src/components/channels/api.test.ts +1527 -0
- package/src/components/channels/api.ts +703 -0
- package/src/components/channels/index.ts +76 -0
- package/src/components/channels/mockApi.ts +344 -0
- package/src/components/channels/types.ts +566 -0
- package/src/components/hooks/index.ts +58 -0
- package/src/components/hooks/useAgentLogs.ts +504 -0
- package/src/components/hooks/useAgents.ts +127 -0
- package/src/components/hooks/useBroadcastDedup.test.ts +371 -0
- package/src/components/hooks/useBroadcastDedup.ts +86 -0
- package/src/components/hooks/useChannelAdmin.ts +329 -0
- package/src/components/hooks/useChannelBrowser.ts +239 -0
- package/src/components/hooks/useChannelCommands.ts +138 -0
- package/src/components/hooks/useChannels.ts +367 -0
- package/src/components/hooks/useDebounce.ts +29 -0
- package/src/components/hooks/useDirectMessage.test.ts +952 -0
- package/src/components/hooks/useDirectMessage.ts +141 -0
- package/src/components/hooks/useMessages.ts +310 -0
- package/src/components/hooks/useOrchestrator.test.ts +165 -0
- package/src/components/hooks/useOrchestrator.ts +424 -0
- package/src/components/hooks/usePinnedAgents.test.ts +356 -0
- package/src/components/hooks/usePinnedAgents.ts +140 -0
- package/src/components/hooks/usePresence.test.ts +245 -0
- package/src/components/hooks/usePresence.ts +377 -0
- package/src/components/hooks/useRecentRepos.ts +130 -0
- package/src/components/hooks/useSession.ts +209 -0
- package/src/components/hooks/useThread.ts +138 -0
- package/src/components/hooks/useTrajectory.ts +265 -0
- package/src/components/hooks/useWebSocket.ts +290 -0
- package/src/components/hooks/useWorkspaceMembers.ts +132 -0
- package/src/components/hooks/useWorkspaceRepos.ts +73 -0
- package/src/components/hooks/useWorkspaceStatus.ts +237 -0
- package/src/components/index.ts +81 -0
- package/src/components/layout/Header.tsx +311 -0
- package/src/components/layout/RepoContextHeader.tsx +361 -0
- package/src/components/layout/Sidebar.archive.test.tsx +126 -0
- package/src/components/layout/Sidebar.test.tsx +691 -0
- package/src/components/layout/Sidebar.tsx +900 -0
- package/src/components/layout/index.ts +7 -0
- package/src/components/settings/BillingSettingsPanel.tsx +564 -0
- package/src/components/settings/SettingsPage.tsx +683 -0
- package/src/components/settings/TeamSettingsPanel.tsx +560 -0
- package/src/components/settings/WorkspaceSettingsPanel.tsx +1368 -0
- package/src/components/settings/index.ts +11 -0
- package/src/components/settings/types.ts +79 -0
- package/src/components/utils/messageFormatting.test.tsx +331 -0
- package/src/components/utils/messageFormatting.tsx +597 -0
- package/src/index.ts +63 -0
- package/src/landing/AboutPage.tsx +77 -0
- package/src/landing/BlogContent.tsx +187 -0
- package/src/landing/BlogPage.tsx +47 -0
- package/src/landing/CareersPage.tsx +53 -0
- package/src/landing/ChangelogPage.tsx +33 -0
- package/src/landing/ContactPage.tsx +41 -0
- package/src/landing/DocsPage.tsx +43 -0
- package/src/landing/LandingPage.tsx +702 -0
- package/src/landing/PricingPage.tsx +549 -0
- package/src/landing/PrivacyPage.tsx +117 -0
- package/src/landing/SecurityPage.tsx +42 -0
- package/src/landing/StaticPage.tsx +165 -0
- package/src/landing/TermsPage.tsx +125 -0
- package/src/landing/blogData.ts +312 -0
- package/src/landing/index.ts +18 -0
- package/src/landing/styles.css +3673 -0
- package/src/lib/agent-merge.test.ts +43 -0
- package/src/lib/agent-merge.ts +35 -0
- package/src/lib/api.ts +1294 -0
- package/src/lib/cloudApi.ts +893 -0
- package/src/lib/colors.test.ts +175 -0
- package/src/lib/colors.ts +218 -0
- package/src/lib/config.ts +109 -0
- package/src/lib/hierarchy.ts +242 -0
- package/src/lib/stuckDetection.ts +142 -0
- package/src/lib/useUrlRouting.ts +190 -0
- package/src/types/index.ts +317 -0
- package/src/types/threading.ts +7 -0
- package/out/_next/static/chunks/285-dc644487a8d6500d.js +0 -1
- package/out/_next/static/css/4c58d9cf493aa626.css +0 -1
- /package/out/_next/static/{AqelRhy1vr2nBUcU0Iqcp → IxfA6RZu4trcsEMYlkQra}/_buildManifest.js +0 -0
- /package/out/_next/static/{AqelRhy1vr2nBUcU0Iqcp → IxfA6RZu4trcsEMYlkQra}/_ssgManifest.js +0 -0
- /package/out/_next/static/chunks/{528-d375bc8b46912d2c.js → 528-f5f676996d613c25.js} +0 -0
- /package/out/_next/static/chunks/app/blog/let-them-cook-multi-agent-orchestration/{page-a58308f43557b908.js → page-b194f207fbd91862.js} +0 -0
|
@@ -0,0 +1,787 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* RepoAccessPanel - GitHub Repository Access Management
|
|
3
|
+
*
|
|
4
|
+
* Shows repositories the user has GitHub access to with permission levels.
|
|
5
|
+
* Allows creating workspaces to enable dashboard/chat access per repo.
|
|
6
|
+
*
|
|
7
|
+
* Uses:
|
|
8
|
+
* - GET /api/repos/accessible - List repos user can access via GitHub OAuth
|
|
9
|
+
* - POST /api/workspaces/quick - Create workspace for a repo
|
|
10
|
+
*/
|
|
11
|
+
|
|
12
|
+
import React, { useState, useEffect, useCallback, useRef } from 'react';
|
|
13
|
+
import Nango from '@nangohq/frontend';
|
|
14
|
+
|
|
15
|
+
interface GitHubAppAccessResult {
|
|
16
|
+
hasAccess: boolean;
|
|
17
|
+
needsReconnect: boolean;
|
|
18
|
+
reason?: string;
|
|
19
|
+
message?: string;
|
|
20
|
+
connectionId?: string;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
interface AccessibleRepo {
|
|
24
|
+
id: number;
|
|
25
|
+
fullName: string;
|
|
26
|
+
isPrivate: boolean;
|
|
27
|
+
defaultBranch: string;
|
|
28
|
+
permissions: {
|
|
29
|
+
admin: boolean;
|
|
30
|
+
push: boolean;
|
|
31
|
+
pull: boolean;
|
|
32
|
+
};
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
interface Workspace {
|
|
36
|
+
id: string;
|
|
37
|
+
name: string;
|
|
38
|
+
repositoryFullName?: string;
|
|
39
|
+
status: 'provisioning' | 'running' | 'stopped' | 'error';
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
export interface RepoAccessPanelProps {
|
|
43
|
+
/** Existing workspaces to show which repos have dashboard access */
|
|
44
|
+
workspaces?: Workspace[];
|
|
45
|
+
/** Callback when a workspace is created */
|
|
46
|
+
onWorkspaceCreated?: (workspaceId: string, repoFullName: string) => void;
|
|
47
|
+
/** Callback when user wants to open a workspace */
|
|
48
|
+
onOpenWorkspace?: (workspaceId: string) => void;
|
|
49
|
+
/** CSRF token for mutations */
|
|
50
|
+
csrfToken?: string;
|
|
51
|
+
/** Custom class name */
|
|
52
|
+
className?: string;
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
type LoadingState = 'idle' | 'loading' | 'loaded' | 'error';
|
|
56
|
+
|
|
57
|
+
function getPermissionLevel(permissions: { admin: boolean; push: boolean; pull: boolean }): {
|
|
58
|
+
level: 'admin' | 'write' | 'read';
|
|
59
|
+
label: string;
|
|
60
|
+
color: string;
|
|
61
|
+
} {
|
|
62
|
+
if (permissions.admin) {
|
|
63
|
+
return { level: 'admin', label: 'Admin', color: 'text-accent-purple bg-accent-purple/10 border-accent-purple/30' };
|
|
64
|
+
}
|
|
65
|
+
if (permissions.push) {
|
|
66
|
+
return { level: 'write', label: 'Write', color: 'text-accent-cyan bg-accent-cyan/10 border-accent-cyan/30' };
|
|
67
|
+
}
|
|
68
|
+
return { level: 'read', label: 'Read', color: 'text-text-muted bg-bg-tertiary border-border-subtle' };
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
export function RepoAccessPanel({
|
|
72
|
+
workspaces = [],
|
|
73
|
+
onWorkspaceCreated,
|
|
74
|
+
onOpenWorkspace,
|
|
75
|
+
csrfToken,
|
|
76
|
+
className = '',
|
|
77
|
+
}: RepoAccessPanelProps) {
|
|
78
|
+
const [repos, setRepos] = useState<AccessibleRepo[]>([]);
|
|
79
|
+
const [loadingState, setLoadingState] = useState<LoadingState>('idle');
|
|
80
|
+
const [error, setError] = useState<string | null>(null);
|
|
81
|
+
const [isGitHubNotConnected, setIsGitHubNotConnected] = useState(false);
|
|
82
|
+
const [creatingWorkspace, setCreatingWorkspace] = useState<string | null>(null);
|
|
83
|
+
const [searchQuery, setSearchQuery] = useState('');
|
|
84
|
+
const [filterType, setFilterType] = useState<'all' | 'with-workspace' | 'without-workspace'>('all');
|
|
85
|
+
|
|
86
|
+
// GitHub OAuth state (for initial connection when not connected)
|
|
87
|
+
const nangoRef = useRef<InstanceType<typeof Nango> | null>(null);
|
|
88
|
+
const [isNangoReady, setIsNangoReady] = useState(false);
|
|
89
|
+
const [isConnecting, setIsConnecting] = useState(false);
|
|
90
|
+
const [connectError, setConnectError] = useState<string | null>(null);
|
|
91
|
+
|
|
92
|
+
// GitHub App reconnect state (for adding repos to existing installation)
|
|
93
|
+
const nangoAppRef = useRef<InstanceType<typeof Nango> | null>(null);
|
|
94
|
+
const [isNangoAppReady, setIsNangoAppReady] = useState(false);
|
|
95
|
+
const [isReconnecting, setIsReconnecting] = useState(false);
|
|
96
|
+
const [checkingAppAccess, setCheckingAppAccess] = useState<string | null>(null);
|
|
97
|
+
const [pendingRepoForWorkspace, setPendingRepoForWorkspace] = useState<string | null>(null);
|
|
98
|
+
const [reconnectSuccessful, setReconnectSuccessful] = useState(false);
|
|
99
|
+
|
|
100
|
+
// Create a map of repo full names to workspace IDs for quick lookup
|
|
101
|
+
const repoToWorkspace = new Map<string, Workspace>();
|
|
102
|
+
workspaces.forEach(ws => {
|
|
103
|
+
if (ws.repositoryFullName) {
|
|
104
|
+
repoToWorkspace.set(ws.repositoryFullName, ws);
|
|
105
|
+
}
|
|
106
|
+
});
|
|
107
|
+
|
|
108
|
+
// Fetch accessible repos
|
|
109
|
+
const fetchRepos = useCallback(async () => {
|
|
110
|
+
setLoadingState('loading');
|
|
111
|
+
setError(null);
|
|
112
|
+
setIsGitHubNotConnected(false);
|
|
113
|
+
|
|
114
|
+
try {
|
|
115
|
+
const response = await fetch('/api/repos/accessible?perPage=100', {
|
|
116
|
+
credentials: 'include',
|
|
117
|
+
});
|
|
118
|
+
|
|
119
|
+
if (!response.ok) {
|
|
120
|
+
const data = await response.json();
|
|
121
|
+
if (data.code === 'NANGO_NOT_CONNECTED') {
|
|
122
|
+
setIsGitHubNotConnected(true);
|
|
123
|
+
throw new Error('GitHub not connected. Connect your GitHub account to see your repositories.');
|
|
124
|
+
}
|
|
125
|
+
throw new Error(data.error || 'Failed to fetch repositories');
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
const data = await response.json();
|
|
129
|
+
setRepos(data.repositories || []);
|
|
130
|
+
setLoadingState('loaded');
|
|
131
|
+
} catch (err) {
|
|
132
|
+
console.error('Error fetching accessible repos:', err);
|
|
133
|
+
setError(err instanceof Error ? err.message : 'Failed to load repositories');
|
|
134
|
+
setLoadingState('error');
|
|
135
|
+
}
|
|
136
|
+
}, []);
|
|
137
|
+
|
|
138
|
+
useEffect(() => {
|
|
139
|
+
fetchRepos();
|
|
140
|
+
}, [fetchRepos]);
|
|
141
|
+
|
|
142
|
+
// Initialize Nango when GitHub is not connected
|
|
143
|
+
useEffect(() => {
|
|
144
|
+
if (!isGitHubNotConnected) return;
|
|
145
|
+
|
|
146
|
+
let mounted = true;
|
|
147
|
+
|
|
148
|
+
const initNango = async () => {
|
|
149
|
+
try {
|
|
150
|
+
// Get Nango session token for GitHub login
|
|
151
|
+
const response = await fetch('/api/auth/nango/login-session', {
|
|
152
|
+
credentials: 'include',
|
|
153
|
+
});
|
|
154
|
+
const data = await response.json();
|
|
155
|
+
|
|
156
|
+
if (!mounted) return;
|
|
157
|
+
|
|
158
|
+
if (response.ok && data.sessionToken) {
|
|
159
|
+
nangoRef.current = new Nango({ connectSessionToken: data.sessionToken });
|
|
160
|
+
setIsNangoReady(true);
|
|
161
|
+
}
|
|
162
|
+
} catch (err) {
|
|
163
|
+
console.error('Failed to initialize Nango:', err);
|
|
164
|
+
}
|
|
165
|
+
};
|
|
166
|
+
|
|
167
|
+
initNango();
|
|
168
|
+
return () => { mounted = false; };
|
|
169
|
+
}, [isGitHubNotConnected]);
|
|
170
|
+
|
|
171
|
+
// Initialize Nango for GitHub App reconnect (proactively, when repos are loaded)
|
|
172
|
+
useEffect(() => {
|
|
173
|
+
if (loadingState !== 'loaded' || repos.length === 0) return;
|
|
174
|
+
|
|
175
|
+
let mounted = true;
|
|
176
|
+
|
|
177
|
+
const initNangoApp = async () => {
|
|
178
|
+
try {
|
|
179
|
+
// Get Nango session token for GitHub App repo connection
|
|
180
|
+
const response = await fetch('/api/auth/nango/repo-session', {
|
|
181
|
+
credentials: 'include',
|
|
182
|
+
});
|
|
183
|
+
const data = await response.json();
|
|
184
|
+
|
|
185
|
+
if (!mounted) return;
|
|
186
|
+
|
|
187
|
+
if (response.ok && data.sessionToken) {
|
|
188
|
+
nangoAppRef.current = new Nango({ connectSessionToken: data.sessionToken });
|
|
189
|
+
setIsNangoAppReady(true);
|
|
190
|
+
}
|
|
191
|
+
} catch (err) {
|
|
192
|
+
console.error('Failed to initialize Nango for GitHub App:', err);
|
|
193
|
+
}
|
|
194
|
+
};
|
|
195
|
+
|
|
196
|
+
initNangoApp();
|
|
197
|
+
return () => { mounted = false; };
|
|
198
|
+
}, [loadingState, repos.length]);
|
|
199
|
+
|
|
200
|
+
// Check if GitHub App has access to a specific repo
|
|
201
|
+
const checkGitHubAppAccess = useCallback(async (repoFullName: string): Promise<GitHubAppAccessResult> => {
|
|
202
|
+
console.log('[RepoAccessPanel] checkGitHubAppAccess called for:', repoFullName);
|
|
203
|
+
const [owner, repo] = repoFullName.split('/');
|
|
204
|
+
if (!owner || !repo) {
|
|
205
|
+
return { hasAccess: false, needsReconnect: false, message: 'Invalid repository name' };
|
|
206
|
+
}
|
|
207
|
+
|
|
208
|
+
try {
|
|
209
|
+
console.log('[RepoAccessPanel] Fetching /api/repos/check-github-app-access/' + owner + '/' + repo);
|
|
210
|
+
const response = await fetch(`/api/repos/check-github-app-access/${owner}/${repo}`, {
|
|
211
|
+
credentials: 'include',
|
|
212
|
+
});
|
|
213
|
+
const data = await response.json();
|
|
214
|
+
console.log('[RepoAccessPanel] Response:', data);
|
|
215
|
+
|
|
216
|
+
if (!response.ok) {
|
|
217
|
+
return { hasAccess: false, needsReconnect: true, message: data.error || 'Failed to check access' };
|
|
218
|
+
}
|
|
219
|
+
|
|
220
|
+
return data as GitHubAppAccessResult;
|
|
221
|
+
} catch (err) {
|
|
222
|
+
console.error('Error checking GitHub App access:', err);
|
|
223
|
+
return { hasAccess: false, needsReconnect: true, message: 'Failed to check access' };
|
|
224
|
+
}
|
|
225
|
+
}, []);
|
|
226
|
+
|
|
227
|
+
// Handle GitHub App reconnect to add a repo
|
|
228
|
+
const handleReconnectGitHubApp = useCallback(async (repoFullName: string) => {
|
|
229
|
+
setIsReconnecting(true);
|
|
230
|
+
setPendingRepoForWorkspace(repoFullName);
|
|
231
|
+
setReconnectSuccessful(false);
|
|
232
|
+
setError(null);
|
|
233
|
+
|
|
234
|
+
try {
|
|
235
|
+
// First, try to get a reconnect session (for existing connections)
|
|
236
|
+
// This uses the Nango reconnect flow to update the existing GitHub App installation
|
|
237
|
+
let sessionResponse = await fetch('/api/auth/nango/repo-reconnect-session', {
|
|
238
|
+
credentials: 'include',
|
|
239
|
+
});
|
|
240
|
+
let sessionData = await sessionResponse.json();
|
|
241
|
+
|
|
242
|
+
// If no existing connection, fall back to regular connect flow
|
|
243
|
+
if (!sessionResponse.ok || sessionData.code === 'NO_EXISTING_CONNECTION') {
|
|
244
|
+
sessionResponse = await fetch('/api/auth/nango/repo-session', {
|
|
245
|
+
credentials: 'include',
|
|
246
|
+
});
|
|
247
|
+
sessionData = await sessionResponse.json();
|
|
248
|
+
}
|
|
249
|
+
|
|
250
|
+
if (!sessionResponse.ok || !sessionData.sessionToken) {
|
|
251
|
+
setError('Failed to initialize GitHub connection. Please refresh the page.');
|
|
252
|
+
setIsReconnecting(false);
|
|
253
|
+
setPendingRepoForWorkspace(null);
|
|
254
|
+
return;
|
|
255
|
+
}
|
|
256
|
+
|
|
257
|
+
// Create Nango instance with the session token
|
|
258
|
+
const nangoInstance = new Nango({ connectSessionToken: sessionData.sessionToken });
|
|
259
|
+
nangoAppRef.current = nangoInstance;
|
|
260
|
+
setIsNangoAppReady(true);
|
|
261
|
+
|
|
262
|
+
// Use github-app-oauth for GitHub App installation
|
|
263
|
+
const result = await nangoInstance.auth('github-app-oauth');
|
|
264
|
+
if (result && 'connectionId' in result) {
|
|
265
|
+
// Poll for completion
|
|
266
|
+
const pollForRepos = async (attempts = 0): Promise<boolean> => {
|
|
267
|
+
console.log(`[RepoAccessPanel] Polling for repos, attempt ${attempts}, connectionId=${result.connectionId}`);
|
|
268
|
+
if (attempts > 30) {
|
|
269
|
+
throw new Error('Connection timed out. Please try again.');
|
|
270
|
+
}
|
|
271
|
+
|
|
272
|
+
try {
|
|
273
|
+
const statusRes = await fetch(`/api/auth/nango/repo-status/${result.connectionId}`, {
|
|
274
|
+
credentials: 'include',
|
|
275
|
+
});
|
|
276
|
+
const statusData = await statusRes.json();
|
|
277
|
+
console.log(`[RepoAccessPanel] Poll response:`, statusData);
|
|
278
|
+
|
|
279
|
+
if (statusData.pendingApproval) {
|
|
280
|
+
setError('Waiting for organization admin approval. Please try again later.');
|
|
281
|
+
return false;
|
|
282
|
+
} else if (statusData.ready) {
|
|
283
|
+
console.log('[RepoAccessPanel] Repos ready!');
|
|
284
|
+
return true;
|
|
285
|
+
}
|
|
286
|
+
|
|
287
|
+
await new Promise(resolve => setTimeout(resolve, 2000));
|
|
288
|
+
return pollForRepos(attempts + 1);
|
|
289
|
+
} catch (err) {
|
|
290
|
+
console.error('[RepoAccessPanel] Poll error:', err);
|
|
291
|
+
await new Promise(resolve => setTimeout(resolve, 2000));
|
|
292
|
+
return pollForRepos(attempts + 1);
|
|
293
|
+
}
|
|
294
|
+
};
|
|
295
|
+
|
|
296
|
+
const success = await pollForRepos();
|
|
297
|
+
if (success) {
|
|
298
|
+
// Refresh the repos list
|
|
299
|
+
await fetchRepos();
|
|
300
|
+
// Signal that reconnect was successful - effect will handle workspace creation
|
|
301
|
+
setReconnectSuccessful(true);
|
|
302
|
+
setIsReconnecting(false);
|
|
303
|
+
}
|
|
304
|
+
} else {
|
|
305
|
+
throw new Error('No connection ID returned');
|
|
306
|
+
}
|
|
307
|
+
} catch (err: unknown) {
|
|
308
|
+
const error = err as Error & { type?: string };
|
|
309
|
+
console.error('GitHub App reconnect error:', error);
|
|
310
|
+
|
|
311
|
+
// Don't show error for user-cancelled auth
|
|
312
|
+
if (error.type === 'user_cancelled' || error.message?.includes('closed')) {
|
|
313
|
+
setPendingRepoForWorkspace(null);
|
|
314
|
+
} else {
|
|
315
|
+
setError(error.message || 'Failed to reconnect GitHub');
|
|
316
|
+
setPendingRepoForWorkspace(null);
|
|
317
|
+
}
|
|
318
|
+
setIsReconnecting(false);
|
|
319
|
+
}
|
|
320
|
+
}, [fetchRepos]);
|
|
321
|
+
|
|
322
|
+
// Effect to create workspace after successful reconnect
|
|
323
|
+
useEffect(() => {
|
|
324
|
+
if (reconnectSuccessful && pendingRepoForWorkspace && !isReconnecting) {
|
|
325
|
+
const repoName = pendingRepoForWorkspace;
|
|
326
|
+
// Clear the flags
|
|
327
|
+
setReconnectSuccessful(false);
|
|
328
|
+
setPendingRepoForWorkspace(null);
|
|
329
|
+
// Create the workspace (skip access check since we just reconnected)
|
|
330
|
+
(async () => {
|
|
331
|
+
setCreatingWorkspace(repoName);
|
|
332
|
+
setError(null);
|
|
333
|
+
try {
|
|
334
|
+
const headers: Record<string, string> = { 'Content-Type': 'application/json' };
|
|
335
|
+
if (csrfToken) {
|
|
336
|
+
headers['X-CSRF-Token'] = csrfToken;
|
|
337
|
+
}
|
|
338
|
+
const response = await fetch('/api/workspaces/quick', {
|
|
339
|
+
method: 'POST',
|
|
340
|
+
credentials: 'include',
|
|
341
|
+
headers,
|
|
342
|
+
body: JSON.stringify({ repositoryFullName: repoName }),
|
|
343
|
+
});
|
|
344
|
+
const data = await response.json();
|
|
345
|
+
if (!response.ok) {
|
|
346
|
+
throw new Error(data.error || 'Failed to create workspace');
|
|
347
|
+
}
|
|
348
|
+
onWorkspaceCreated?.(data.workspaceId, repoName);
|
|
349
|
+
} catch (err) {
|
|
350
|
+
console.error('Error creating workspace after reconnect:', err);
|
|
351
|
+
setError(err instanceof Error ? err.message : 'Failed to create workspace');
|
|
352
|
+
} finally {
|
|
353
|
+
setCreatingWorkspace(null);
|
|
354
|
+
}
|
|
355
|
+
})();
|
|
356
|
+
}
|
|
357
|
+
}, [reconnectSuccessful, pendingRepoForWorkspace, isReconnecting, csrfToken, onWorkspaceCreated]);
|
|
358
|
+
|
|
359
|
+
// Handle GitHub OAuth connection
|
|
360
|
+
const handleConnectGitHub = async () => {
|
|
361
|
+
if (!nangoRef.current) {
|
|
362
|
+
setConnectError('GitHub connection not available. Please refresh the page.');
|
|
363
|
+
return;
|
|
364
|
+
}
|
|
365
|
+
|
|
366
|
+
setIsConnecting(true);
|
|
367
|
+
setConnectError(null);
|
|
368
|
+
|
|
369
|
+
try {
|
|
370
|
+
const result = await nangoRef.current.auth('github');
|
|
371
|
+
if (result && 'connectionId' in result) {
|
|
372
|
+
// Poll for auth completion
|
|
373
|
+
const pollForAuth = async (attempts = 0): Promise<void> => {
|
|
374
|
+
if (attempts > 30) {
|
|
375
|
+
throw new Error('Authentication timed out. Please try again.');
|
|
376
|
+
}
|
|
377
|
+
|
|
378
|
+
const statusRes = await fetch(`/api/auth/nango/login-status/${result.connectionId}`, {
|
|
379
|
+
credentials: 'include',
|
|
380
|
+
});
|
|
381
|
+
const statusData = await statusRes.json();
|
|
382
|
+
|
|
383
|
+
if (statusData.ready) {
|
|
384
|
+
// Auth complete, refresh repos
|
|
385
|
+
setIsConnecting(false);
|
|
386
|
+
setIsGitHubNotConnected(false);
|
|
387
|
+
fetchRepos();
|
|
388
|
+
return;
|
|
389
|
+
}
|
|
390
|
+
|
|
391
|
+
await new Promise(resolve => setTimeout(resolve, 1000));
|
|
392
|
+
return pollForAuth(attempts + 1);
|
|
393
|
+
};
|
|
394
|
+
|
|
395
|
+
await pollForAuth();
|
|
396
|
+
} else {
|
|
397
|
+
throw new Error('No connection ID returned');
|
|
398
|
+
}
|
|
399
|
+
} catch (err: unknown) {
|
|
400
|
+
const error = err as Error & { type?: string };
|
|
401
|
+
console.error('GitHub auth error:', error);
|
|
402
|
+
|
|
403
|
+
// Don't show error for user-cancelled auth
|
|
404
|
+
if (error.type === 'user_cancelled' || error.message?.includes('closed')) {
|
|
405
|
+
setIsConnecting(false);
|
|
406
|
+
// Re-initialize Nango for next attempt
|
|
407
|
+
fetch('/api/auth/nango/login-session', { credentials: 'include' })
|
|
408
|
+
.then(res => res.json())
|
|
409
|
+
.then(data => {
|
|
410
|
+
if (data.sessionToken) {
|
|
411
|
+
nangoRef.current = new Nango({ connectSessionToken: data.sessionToken });
|
|
412
|
+
}
|
|
413
|
+
});
|
|
414
|
+
return;
|
|
415
|
+
}
|
|
416
|
+
|
|
417
|
+
setConnectError(error.message || 'Failed to connect GitHub');
|
|
418
|
+
setIsConnecting(false);
|
|
419
|
+
}
|
|
420
|
+
};
|
|
421
|
+
|
|
422
|
+
// Create workspace for a repo - checks GitHub App access first
|
|
423
|
+
const handleCreateWorkspace = useCallback(async (repoFullName: string) => {
|
|
424
|
+
console.log('[RepoAccessPanel] handleCreateWorkspace called for:', repoFullName);
|
|
425
|
+
setCreatingWorkspace(repoFullName);
|
|
426
|
+
setError(null);
|
|
427
|
+
|
|
428
|
+
try {
|
|
429
|
+
// First, check if GitHub App has access to this repo
|
|
430
|
+
setCheckingAppAccess(repoFullName);
|
|
431
|
+
const accessResult = await checkGitHubAppAccess(repoFullName);
|
|
432
|
+
console.log('[RepoAccessPanel] Access result:', accessResult);
|
|
433
|
+
setCheckingAppAccess(null);
|
|
434
|
+
|
|
435
|
+
if (!accessResult.hasAccess && accessResult.needsReconnect) {
|
|
436
|
+
console.log('[RepoAccessPanel] Needs reconnect, triggering handleReconnectGitHubApp');
|
|
437
|
+
// Need to reconnect GitHub App to add this repo
|
|
438
|
+
// The reconnect handler will trigger workspace creation via effect
|
|
439
|
+
setCreatingWorkspace(null);
|
|
440
|
+
handleReconnectGitHubApp(repoFullName);
|
|
441
|
+
return;
|
|
442
|
+
}
|
|
443
|
+
|
|
444
|
+
// Proceed with workspace creation
|
|
445
|
+
const headers: Record<string, string> = { 'Content-Type': 'application/json' };
|
|
446
|
+
if (csrfToken) {
|
|
447
|
+
headers['X-CSRF-Token'] = csrfToken;
|
|
448
|
+
}
|
|
449
|
+
|
|
450
|
+
const response = await fetch('/api/workspaces/quick', {
|
|
451
|
+
method: 'POST',
|
|
452
|
+
credentials: 'include',
|
|
453
|
+
headers,
|
|
454
|
+
body: JSON.stringify({ repositoryFullName: repoFullName }),
|
|
455
|
+
});
|
|
456
|
+
|
|
457
|
+
const data = await response.json();
|
|
458
|
+
|
|
459
|
+
if (!response.ok) {
|
|
460
|
+
throw new Error(data.error || 'Failed to create workspace');
|
|
461
|
+
}
|
|
462
|
+
|
|
463
|
+
onWorkspaceCreated?.(data.workspaceId, repoFullName);
|
|
464
|
+
} catch (err) {
|
|
465
|
+
console.error('Error creating workspace:', err);
|
|
466
|
+
setError(err instanceof Error ? err.message : 'Failed to create workspace');
|
|
467
|
+
} finally {
|
|
468
|
+
setCreatingWorkspace(null);
|
|
469
|
+
setCheckingAppAccess(null);
|
|
470
|
+
}
|
|
471
|
+
}, [csrfToken, onWorkspaceCreated, checkGitHubAppAccess, handleReconnectGitHubApp]);
|
|
472
|
+
|
|
473
|
+
// Filter repos based on search and filter type
|
|
474
|
+
const filteredRepos = repos.filter(repo => {
|
|
475
|
+
// Search filter
|
|
476
|
+
if (searchQuery && !repo.fullName.toLowerCase().includes(searchQuery.toLowerCase())) {
|
|
477
|
+
return false;
|
|
478
|
+
}
|
|
479
|
+
|
|
480
|
+
// Workspace filter
|
|
481
|
+
const hasWorkspace = repoToWorkspace.has(repo.fullName);
|
|
482
|
+
if (filterType === 'with-workspace' && !hasWorkspace) return false;
|
|
483
|
+
if (filterType === 'without-workspace' && hasWorkspace) return false;
|
|
484
|
+
|
|
485
|
+
return true;
|
|
486
|
+
});
|
|
487
|
+
|
|
488
|
+
// Loading state
|
|
489
|
+
if (loadingState === 'loading') {
|
|
490
|
+
return (
|
|
491
|
+
<div className={`flex items-center justify-center py-12 ${className}`}>
|
|
492
|
+
<div className="text-center">
|
|
493
|
+
<svg className="w-8 h-8 text-accent-cyan animate-spin mx-auto" fill="none" viewBox="0 0 24 24">
|
|
494
|
+
<circle className="opacity-25" cx="12" cy="12" r="10" stroke="currentColor" strokeWidth="4" />
|
|
495
|
+
<path className="opacity-75" fill="currentColor" d="M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4z" />
|
|
496
|
+
</svg>
|
|
497
|
+
<p className="mt-4 text-text-muted">Loading repositories...</p>
|
|
498
|
+
</div>
|
|
499
|
+
</div>
|
|
500
|
+
);
|
|
501
|
+
}
|
|
502
|
+
|
|
503
|
+
// Error state - special handling for GitHub not connected
|
|
504
|
+
if (loadingState === 'error') {
|
|
505
|
+
if (isGitHubNotConnected) {
|
|
506
|
+
return (
|
|
507
|
+
<div className={`p-6 ${className}`}>
|
|
508
|
+
<div className="bg-bg-tertiary border border-border-subtle rounded-xl p-8 text-center">
|
|
509
|
+
<div className="w-16 h-16 mx-auto mb-4 bg-bg-hover rounded-full flex items-center justify-center">
|
|
510
|
+
<GitHubIcon className="w-8 h-8 text-text-muted" />
|
|
511
|
+
</div>
|
|
512
|
+
<h3 className="text-lg font-semibold text-text-primary mb-2">Connect GitHub</h3>
|
|
513
|
+
<p className="text-text-muted mb-6 max-w-md mx-auto">
|
|
514
|
+
Connect your GitHub account to see your repositories and enable agent access to your code.
|
|
515
|
+
</p>
|
|
516
|
+
{connectError && (
|
|
517
|
+
<p className="text-error text-sm mb-4">{connectError}</p>
|
|
518
|
+
)}
|
|
519
|
+
<button
|
|
520
|
+
onClick={handleConnectGitHub}
|
|
521
|
+
disabled={!isNangoReady || isConnecting}
|
|
522
|
+
className="px-6 py-3 bg-gradient-to-r from-accent-cyan to-[#00b8d9] text-bg-deep font-medium rounded-lg hover:shadow-glow-cyan transition-all disabled:opacity-50 disabled:cursor-not-allowed"
|
|
523
|
+
>
|
|
524
|
+
{isConnecting ? (
|
|
525
|
+
<span className="flex items-center gap-2">
|
|
526
|
+
<svg className="w-5 h-5 animate-spin" fill="none" viewBox="0 0 24 24">
|
|
527
|
+
<circle className="opacity-25" cx="12" cy="12" r="10" stroke="currentColor" strokeWidth="4" />
|
|
528
|
+
<path className="opacity-75" fill="currentColor" d="M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4z" />
|
|
529
|
+
</svg>
|
|
530
|
+
Connecting...
|
|
531
|
+
</span>
|
|
532
|
+
) : !isNangoReady ? (
|
|
533
|
+
<span className="flex items-center gap-2">
|
|
534
|
+
<svg className="w-5 h-5 animate-spin" fill="none" viewBox="0 0 24 24">
|
|
535
|
+
<circle className="opacity-25" cx="12" cy="12" r="10" stroke="currentColor" strokeWidth="4" />
|
|
536
|
+
<path className="opacity-75" fill="currentColor" d="M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4z" />
|
|
537
|
+
</svg>
|
|
538
|
+
Loading...
|
|
539
|
+
</span>
|
|
540
|
+
) : (
|
|
541
|
+
<span className="flex items-center gap-2">
|
|
542
|
+
<GitHubIcon className="w-5 h-5" />
|
|
543
|
+
Connect GitHub Account
|
|
544
|
+
</span>
|
|
545
|
+
)}
|
|
546
|
+
</button>
|
|
547
|
+
</div>
|
|
548
|
+
</div>
|
|
549
|
+
);
|
|
550
|
+
}
|
|
551
|
+
|
|
552
|
+
return (
|
|
553
|
+
<div className={`p-6 ${className}`}>
|
|
554
|
+
<div className="bg-error/10 border border-error/20 rounded-xl p-4 text-center">
|
|
555
|
+
<div className="w-12 h-12 mx-auto mb-3 bg-error/20 rounded-full flex items-center justify-center">
|
|
556
|
+
<svg className="w-6 h-6 text-error" fill="none" viewBox="0 0 24 24" stroke="currentColor">
|
|
557
|
+
<path strokeLinecap="round" strokeLinejoin="round" strokeWidth={2} d="M12 9v2m0 4h.01m-6.938 4h13.856c1.54 0 2.502-1.667 1.732-3L13.732 4c-.77-1.333-2.694-1.333-3.464 0L3.34 16c-.77 1.333.192 3 1.732 3z" />
|
|
558
|
+
</svg>
|
|
559
|
+
</div>
|
|
560
|
+
<p className="text-error mb-4">{error}</p>
|
|
561
|
+
<button
|
|
562
|
+
onClick={fetchRepos}
|
|
563
|
+
className="px-4 py-2 bg-bg-tertiary border border-border-subtle rounded-lg text-text-primary hover:bg-bg-hover transition-colors"
|
|
564
|
+
>
|
|
565
|
+
Try Again
|
|
566
|
+
</button>
|
|
567
|
+
</div>
|
|
568
|
+
</div>
|
|
569
|
+
);
|
|
570
|
+
}
|
|
571
|
+
|
|
572
|
+
return (
|
|
573
|
+
<div className={className}>
|
|
574
|
+
{/* Header */}
|
|
575
|
+
<div className="p-4 border-b border-border-subtle">
|
|
576
|
+
<h2 className="text-lg font-semibold text-text-primary mb-1">Repository Access</h2>
|
|
577
|
+
<p className="text-sm text-text-muted">
|
|
578
|
+
Repositories you have access to on GitHub. Create workspaces to enable dashboard and chat access.
|
|
579
|
+
</p>
|
|
580
|
+
</div>
|
|
581
|
+
|
|
582
|
+
{/* Error banner */}
|
|
583
|
+
{error && (
|
|
584
|
+
<div className="mx-4 mt-4 p-3 bg-error/10 border border-error/20 rounded-lg">
|
|
585
|
+
<p className="text-error text-sm">{error}</p>
|
|
586
|
+
</div>
|
|
587
|
+
)}
|
|
588
|
+
|
|
589
|
+
{/* Search and filters */}
|
|
590
|
+
<div className="p-4 border-b border-border-subtle">
|
|
591
|
+
<div className="flex flex-col sm:flex-row gap-3">
|
|
592
|
+
{/* Search */}
|
|
593
|
+
<div className="flex-1 relative">
|
|
594
|
+
<SearchIcon className="absolute left-3 top-1/2 -translate-y-1/2 text-text-muted" />
|
|
595
|
+
<input
|
|
596
|
+
type="text"
|
|
597
|
+
placeholder="Search repositories..."
|
|
598
|
+
value={searchQuery}
|
|
599
|
+
onChange={(e) => setSearchQuery(e.target.value)}
|
|
600
|
+
className="w-full pl-10 pr-4 py-2 bg-bg-tertiary border border-border-subtle rounded-lg text-text-primary placeholder:text-text-muted focus:outline-none focus:border-accent-cyan/50 transition-colors"
|
|
601
|
+
/>
|
|
602
|
+
</div>
|
|
603
|
+
|
|
604
|
+
{/* Filter */}
|
|
605
|
+
<div className="flex gap-2">
|
|
606
|
+
<button
|
|
607
|
+
onClick={() => setFilterType('all')}
|
|
608
|
+
className={`px-3 py-2 text-sm rounded-lg border transition-colors ${
|
|
609
|
+
filterType === 'all'
|
|
610
|
+
? 'bg-accent-cyan/10 border-accent-cyan/30 text-accent-cyan'
|
|
611
|
+
: 'bg-bg-tertiary border-border-subtle text-text-muted hover:text-text-primary'
|
|
612
|
+
}`}
|
|
613
|
+
>
|
|
614
|
+
All ({repos.length})
|
|
615
|
+
</button>
|
|
616
|
+
<button
|
|
617
|
+
onClick={() => setFilterType('with-workspace')}
|
|
618
|
+
className={`px-3 py-2 text-sm rounded-lg border transition-colors ${
|
|
619
|
+
filterType === 'with-workspace'
|
|
620
|
+
? 'bg-success/10 border-success/30 text-success'
|
|
621
|
+
: 'bg-bg-tertiary border-border-subtle text-text-muted hover:text-text-primary'
|
|
622
|
+
}`}
|
|
623
|
+
>
|
|
624
|
+
With Access
|
|
625
|
+
</button>
|
|
626
|
+
<button
|
|
627
|
+
onClick={() => setFilterType('without-workspace')}
|
|
628
|
+
className={`px-3 py-2 text-sm rounded-lg border transition-colors ${
|
|
629
|
+
filterType === 'without-workspace'
|
|
630
|
+
? 'bg-warning/10 border-warning/30 text-warning'
|
|
631
|
+
: 'bg-bg-tertiary border-border-subtle text-text-muted hover:text-text-primary'
|
|
632
|
+
}`}
|
|
633
|
+
>
|
|
634
|
+
No Access
|
|
635
|
+
</button>
|
|
636
|
+
</div>
|
|
637
|
+
</div>
|
|
638
|
+
</div>
|
|
639
|
+
|
|
640
|
+
{/* Repo list */}
|
|
641
|
+
<div className="max-h-[500px] overflow-y-auto">
|
|
642
|
+
{filteredRepos.length === 0 ? (
|
|
643
|
+
<div className="py-12 text-center text-text-muted">
|
|
644
|
+
{searchQuery ? (
|
|
645
|
+
<p>No repositories match "{searchQuery}"</p>
|
|
646
|
+
) : filterType !== 'all' ? (
|
|
647
|
+
<p>No repositories in this category</p>
|
|
648
|
+
) : (
|
|
649
|
+
<p>No repositories found. Connect your GitHub account to see your repos.</p>
|
|
650
|
+
)}
|
|
651
|
+
</div>
|
|
652
|
+
) : (
|
|
653
|
+
<div className="divide-y divide-border-subtle">
|
|
654
|
+
{filteredRepos.map((repo) => {
|
|
655
|
+
const permission = getPermissionLevel(repo.permissions);
|
|
656
|
+
const workspace = repoToWorkspace.get(repo.fullName);
|
|
657
|
+
const isCreating = creatingWorkspace === repo.fullName;
|
|
658
|
+
|
|
659
|
+
return (
|
|
660
|
+
<div
|
|
661
|
+
key={repo.id}
|
|
662
|
+
className="flex items-center gap-4 p-4 hover:bg-bg-hover/50 transition-colors"
|
|
663
|
+
>
|
|
664
|
+
{/* Repo icon */}
|
|
665
|
+
<div className="w-10 h-10 rounded-lg bg-bg-tertiary border border-border-subtle flex items-center justify-center flex-shrink-0">
|
|
666
|
+
<RepoIcon className="text-text-muted" />
|
|
667
|
+
</div>
|
|
668
|
+
|
|
669
|
+
{/* Repo info */}
|
|
670
|
+
<div className="flex-1 min-w-0">
|
|
671
|
+
<div className="flex items-center gap-2 mb-0.5">
|
|
672
|
+
<p className="font-medium text-text-primary truncate">{repo.fullName}</p>
|
|
673
|
+
{repo.isPrivate && (
|
|
674
|
+
<span className="px-1.5 py-0.5 text-xs bg-bg-tertiary border border-border-subtle rounded text-text-muted">
|
|
675
|
+
Private
|
|
676
|
+
</span>
|
|
677
|
+
)}
|
|
678
|
+
</div>
|
|
679
|
+
<div className="flex items-center gap-2">
|
|
680
|
+
<span className={`px-2 py-0.5 text-xs rounded-full border ${permission.color}`}>
|
|
681
|
+
{permission.label}
|
|
682
|
+
</span>
|
|
683
|
+
<span className="text-xs text-text-muted">{repo.defaultBranch}</span>
|
|
684
|
+
</div>
|
|
685
|
+
</div>
|
|
686
|
+
|
|
687
|
+
{/* Action button */}
|
|
688
|
+
<div className="flex-shrink-0">
|
|
689
|
+
{workspace ? (
|
|
690
|
+
<button
|
|
691
|
+
onClick={() => onOpenWorkspace?.(workspace.id)}
|
|
692
|
+
className={`px-4 py-2 text-sm rounded-lg border transition-colors ${
|
|
693
|
+
workspace.status === 'running'
|
|
694
|
+
? 'bg-success/10 border-success/30 text-success hover:bg-success/20'
|
|
695
|
+
: workspace.status === 'provisioning'
|
|
696
|
+
? 'bg-accent-cyan/10 border-accent-cyan/30 text-accent-cyan'
|
|
697
|
+
: 'bg-bg-tertiary border-border-subtle text-text-muted hover:bg-bg-hover'
|
|
698
|
+
}`}
|
|
699
|
+
>
|
|
700
|
+
{workspace.status === 'running' ? 'Open Dashboard' :
|
|
701
|
+
workspace.status === 'provisioning' ? 'Starting...' :
|
|
702
|
+
workspace.status === 'stopped' ? 'Start' : 'View'}
|
|
703
|
+
</button>
|
|
704
|
+
) : (
|
|
705
|
+
<button
|
|
706
|
+
onClick={() => handleCreateWorkspace(repo.fullName)}
|
|
707
|
+
disabled={isCreating || checkingAppAccess === repo.fullName || isReconnecting}
|
|
708
|
+
className="px-4 py-2 text-sm bg-gradient-to-r from-accent-cyan to-[#00b8d9] text-bg-deep font-medium rounded-lg hover:shadow-glow-cyan transition-all disabled:opacity-50 disabled:cursor-not-allowed"
|
|
709
|
+
>
|
|
710
|
+
{checkingAppAccess === repo.fullName ? (
|
|
711
|
+
<span className="flex items-center gap-2">
|
|
712
|
+
<svg className="w-4 h-4 animate-spin" fill="none" viewBox="0 0 24 24">
|
|
713
|
+
<circle className="opacity-25" cx="12" cy="12" r="10" stroke="currentColor" strokeWidth="4" />
|
|
714
|
+
<path className="opacity-75" fill="currentColor" d="M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4z" />
|
|
715
|
+
</svg>
|
|
716
|
+
Checking...
|
|
717
|
+
</span>
|
|
718
|
+
) : isReconnecting && pendingRepoForWorkspace === repo.fullName ? (
|
|
719
|
+
<span className="flex items-center gap-2">
|
|
720
|
+
<svg className="w-4 h-4 animate-spin" fill="none" viewBox="0 0 24 24">
|
|
721
|
+
<circle className="opacity-25" cx="12" cy="12" r="10" stroke="currentColor" strokeWidth="4" />
|
|
722
|
+
<path className="opacity-75" fill="currentColor" d="M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4z" />
|
|
723
|
+
</svg>
|
|
724
|
+
Connecting...
|
|
725
|
+
</span>
|
|
726
|
+
) : isCreating ? (
|
|
727
|
+
<span className="flex items-center gap-2">
|
|
728
|
+
<svg className="w-4 h-4 animate-spin" fill="none" viewBox="0 0 24 24">
|
|
729
|
+
<circle className="opacity-25" cx="12" cy="12" r="10" stroke="currentColor" strokeWidth="4" />
|
|
730
|
+
<path className="opacity-75" fill="currentColor" d="M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4z" />
|
|
731
|
+
</svg>
|
|
732
|
+
Creating...
|
|
733
|
+
</span>
|
|
734
|
+
) : (
|
|
735
|
+
'Enable Access'
|
|
736
|
+
)}
|
|
737
|
+
</button>
|
|
738
|
+
)}
|
|
739
|
+
</div>
|
|
740
|
+
</div>
|
|
741
|
+
);
|
|
742
|
+
})}
|
|
743
|
+
</div>
|
|
744
|
+
)}
|
|
745
|
+
</div>
|
|
746
|
+
|
|
747
|
+
{/* Footer */}
|
|
748
|
+
<div className="p-4 border-t border-border-subtle bg-bg-tertiary/50">
|
|
749
|
+
<p className="text-xs text-text-muted text-center">
|
|
750
|
+
Showing {filteredRepos.length} of {repos.length} repositories you have GitHub access to.
|
|
751
|
+
<button
|
|
752
|
+
onClick={fetchRepos}
|
|
753
|
+
className="ml-2 text-accent-cyan hover:underline"
|
|
754
|
+
>
|
|
755
|
+
Refresh
|
|
756
|
+
</button>
|
|
757
|
+
</p>
|
|
758
|
+
</div>
|
|
759
|
+
</div>
|
|
760
|
+
);
|
|
761
|
+
}
|
|
762
|
+
|
|
763
|
+
// Icons
|
|
764
|
+
function SearchIcon({ className = '' }: { className?: string }) {
|
|
765
|
+
return (
|
|
766
|
+
<svg className={className} width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="2">
|
|
767
|
+
<circle cx="11" cy="11" r="8" />
|
|
768
|
+
<line x1="21" y1="21" x2="16.65" y2="16.65" />
|
|
769
|
+
</svg>
|
|
770
|
+
);
|
|
771
|
+
}
|
|
772
|
+
|
|
773
|
+
function RepoIcon({ className = '' }: { className?: string }) {
|
|
774
|
+
return (
|
|
775
|
+
<svg className={className} width="18" height="18" viewBox="0 0 16 16" fill="currentColor">
|
|
776
|
+
<path d="M2 2.5A2.5 2.5 0 014.5 0h8.75a.75.75 0 01.75.75v12.5a.75.75 0 01-.75.75h-2.5a.75.75 0 110-1.5h1.75v-2h-8a1 1 0 00-.714 1.7.75.75 0 01-1.072 1.05A2.495 2.495 0 012 11.5v-9zm10.5-1V9h-8c-.356 0-.694.074-1 .208V2.5a1 1 0 011-1h8z" />
|
|
777
|
+
</svg>
|
|
778
|
+
);
|
|
779
|
+
}
|
|
780
|
+
|
|
781
|
+
function GitHubIcon({ className = '' }: { className?: string }) {
|
|
782
|
+
return (
|
|
783
|
+
<svg className={className} viewBox="0 0 24 24" fill="currentColor">
|
|
784
|
+
<path d="M12 0c-6.626 0-12 5.373-12 12 0 5.302 3.438 9.8 8.207 11.387.599.111.793-.261.793-.577v-2.234c-3.338.726-4.033-1.416-4.033-1.416-.546-1.387-1.333-1.756-1.333-1.756-1.089-.745.083-.729.083-.729 1.205.084 1.839 1.237 1.839 1.237 1.07 1.834 2.807 1.304 3.492.997.107-.775.418-1.305.762-1.604-2.665-.305-5.467-1.334-5.467-5.931 0-1.311.469-2.381 1.236-3.221-.124-.303-.535-1.524.117-3.176 0 0 1.008-.322 3.301 1.23.957-.266 1.983-.399 3.003-.404 1.02.005 2.047.138 3.006.404 2.291-1.552 3.297-1.23 3.297-1.23.653 1.653.242 2.874.118 3.176.77.84 1.235 1.911 1.235 3.221 0 4.609-2.807 5.624-5.479 5.921.43.372.823 1.102.823 2.222v3.293c0 .319.192.694.801.576 4.765-1.589 8.199-6.086 8.199-11.386 0-6.627-5.373-12-12-12z"/>
|
|
785
|
+
</svg>
|
|
786
|
+
);
|
|
787
|
+
}
|