@@ -11,78 +11,115 @@ struct MCPRegistryURLInputField: View {
1111 let defaultMCPRegistryURL = " https://api.mcp.github.com/2025-09-15/v0/servers "
1212 let maxURLLength : Int
1313 let isSheet : Bool
14+ let mcpRegistryEntry : MCPRegistryEntry ?
1415 let onValidationChange : ( ( Bool ) -> Void ) ?
1516
17+ private var isRegistryOnly : Bool {
18+ mcpRegistryEntry? . registryAccess == . registryOnly
19+ }
20+
1621 init (
1722 urlText: Binding < String > ,
1823 maxURLLength: Int = 2048 ,
1924 isSheet: Bool = false ,
25+ mcpRegistryEntry: MCPRegistryEntry ? = nil ,
2026 onValidationChange: ( ( Bool ) -> Void ) ? = nil
2127 ) {
2228 self . _urlText = urlText
2329 self . maxURLLength = maxURLLength
2430 self . isSheet = isSheet
31+ self . mcpRegistryEntry = mcpRegistryEntry
2532 self . onValidationChange = onValidationChange
2633 }
2734
2835 var body : some View {
29- HStack ( spacing: 8 ) {
30- if isSheet {
31- TextFieldsContainer {
32- TextField ( " MCP Registry URL " , text: $urlText)
36+ VStack ( alignment: . leading, spacing: 8 ) {
37+ HStack ( spacing: 8 ) {
38+ if isSheet {
39+ TextFieldsContainer {
40+ TextField ( " MCP Registry URL " , text: $urlText)
41+ . focused ( $isFocused)
42+ . disabled ( isRegistryOnly)
43+ . onChange ( of: urlText) { newValue in
44+ handleURLChange ( newValue)
45+ }
46+ }
47+ } else {
48+ TextField ( " MCP Registry URL: " , text: $urlText)
49+ . textFieldStyle ( . roundedBorder)
3350 . focused ( $isFocused)
51+ . disabled ( isRegistryOnly)
3452 . onChange ( of: urlText) { newValue in
3553 handleURLChange ( newValue)
3654 }
3755 }
38- } else {
39- TextField ( " MCP Registry URL: " , text: $urlText)
40- . textFieldStyle ( . roundedBorder)
41- . focused ( $isFocused)
42- . onChange ( of: urlText) { newValue in
43- handleURLChange ( newValue)
56+
57+ Menu {
58+ ForEach ( urlHistory, id: \. self) { url in
59+ Button ( url) {
60+ urlText = url
61+ isFocused = false
62+ }
4463 }
45- }
46-
47- Menu {
48- ForEach ( urlHistory, id: \. self) { url in
49- Button ( url) {
50- urlText = url
51- isFocused = false
64+
65+ Divider ( )
66+
67+ Button ( " Reset to Default " ) {
68+ urlText = defaultMCPRegistryURL
5269 }
53- }
54-
55- Divider ( )
56-
57- Button ( " Reset to Default " ) {
58- urlText = defaultMCPRegistryURL
59- }
60-
61- if !urlHistory. isEmpty {
62- Button ( " Clear History " ) {
63- urlHistory = [ ]
70+
71+ if !urlHistory. isEmpty {
72+ Button ( " Clear History " ) {
73+ urlHistory = [ ]
74+ }
6475 }
65- }
66- } label: {
67- Image ( systemName: " chevron.down " )
76+ } label: {
77+ Image ( systemName: " chevron.down " )
6878 . resizable ( )
6979 . scaledToFit ( )
7080 . frame ( width: 11 , height: 11 )
7181 . padding ( isSheet ? 9 : 3 )
82+ }
83+ . labelStyle ( . iconOnly)
84+ . menuIndicator ( . hidden)
85+ . buttonStyle (
86+ HoverButtonStyle (
87+ hoverColor: SecondarySystemFillColor,
88+ backgroundColor: SecondarySystemFillColor,
89+ cornerRadius: isSheet ? 12 : 6
90+ )
91+ )
92+ . opacity ( isRegistryOnly ? 0.5 : 1 )
93+ . disabled ( isRegistryOnly)
7294 }
73- . labelStyle ( . iconOnly)
74- . menuIndicator ( . hidden)
75- . buttonStyle (
76- HoverButtonStyle (
77- hoverColor: SecondarySystemFillColor,
78- backgroundColor: SecondarySystemFillColor,
79- cornerRadius: isSheet ? 12 : 6
95+
96+ if isRegistryOnly {
97+ Badge (
98+ text: " This URL is managed by \( mcpRegistryEntry!. owner. login) and cannot be modified " ,
99+ level: . info,
100+ icon: " info.circle.fill "
80101 )
81- )
102+ }
103+ }
104+ . onAppear {
105+ if isRegistryOnly, let entryURL = mcpRegistryEntry? . url {
106+ urlText = entryURL
107+ }
108+ }
109+ . onChange ( of: mcpRegistryEntry) { newEntry in
110+ if newEntry? . registryAccess == . registryOnly, let entryURL = newEntry? . url {
111+ urlText = entryURL
112+ }
82113 }
83114 }
84115
85116 private func handleURLChange( _ newValue: String ) {
117+ // If registryOnly, force the URL back to the registry entry URL
118+ if isRegistryOnly, let entryURL = mcpRegistryEntry? . url {
119+ urlText = entryURL
120+ return
121+ }
122+
86123 let limitedText = String ( newValue. prefix ( maxURLLength) )
87124 if limitedText != newValue {
88125 urlText = limitedText
0 commit comments