11import { ArrowPathIcon , PlayIcon } from "@heroicons/react/24/outline" ;
22import { useContext , useEffect , useState } from "react" ;
3+ import { normalizeRepoUrl } from "core/util/repoUrl" ;
34import { useAuth } from "../../context/Auth" ;
45import { IdeMessengerContext } from "../../context/IdeMessenger" ;
56import { useAppSelector } from "../../redux/hooks" ;
@@ -21,48 +22,6 @@ interface AgentsListProps {
2122 isCreatingAgent ?: boolean ;
2223}
2324
24- // Robust URL normalization function
25- const normalizeRepoUrl = ( url : string | undefined | null ) : string => {
26- if ( ! url ) return "" ;
27-
28- let normalized = url . trim ( ) ;
29-
30- // Convert SSH to HTTPS: git@github .com:owner/repo.git -> https://github.com/owner/repo
31- if ( normalized . startsWith ( "git@github.com:" ) ) {
32- normalized = normalized . replace ( "git@github.com:" , "https://github.com/" ) ;
33- }
34-
35- // Convert SSH protocol to HTTPS: ssh://git@github .com/owner/repo.git -> https://github.com/owner/repo
36- // Also handles: ssh://git@github .com:owner/repo.git (less common)
37- if ( normalized . startsWith ( "ssh://git@github.com" ) ) {
38- normalized = normalized
39- . replace ( "ssh://git@github.com/" , "https://github.com/" )
40- . replace ( "ssh://git@github.com:" , "https://github.com/" ) ;
41- }
42-
43- // Convert shorthand owner/repo to full URL
44- if (
45- normalized . includes ( "/" ) &&
46- ! normalized . startsWith ( "http" ) &&
47- ! normalized . startsWith ( "git@" )
48- ) {
49- normalized = `https://github.com/${ normalized } ` ;
50- }
51-
52- // Remove .git suffix
53- if ( normalized . endsWith ( ".git" ) ) {
54- normalized = normalized . slice ( 0 , - 4 ) ;
55- }
56-
57- // Remove trailing slash
58- if ( normalized . endsWith ( "/" ) ) {
59- normalized = normalized . slice ( 0 , - 1 ) ;
60- }
61-
62- // Normalize to lowercase
63- return normalized . toLowerCase ( ) ;
64- } ;
65-
6625export function AgentsList ( { isCreatingAgent = false } : AgentsListProps ) {
6726 const { session } = useAuth ( ) ;
6827 const ideMessenger = useContext ( IdeMessengerContext ) ;
@@ -156,7 +115,7 @@ export function AgentsList({ isCreatingAgent = false }: AgentsListProps) {
156115 const isAgentInCurrentWorkspace = ( agent : Agent ) : boolean => {
157116 // Get all possible agent repo URLs (both repoUrl and metadata.github_repo)
158117 const agentUrls = [ agent . repoUrl , agent . metadata ?. github_repo ]
159- . filter ( Boolean )
118+ . filter ( ( url ) : url is string => Boolean ( url ) )
160119 . map ( normalizeRepoUrl )
161120 . filter ( ( url ) => url !== "" ) ;
162121
0 commit comments