({
inputValue,
setInputValue,
cursorOffset,
setCursorOffset,
error,
setError,
result,
setResult,
setViewState,
onAddComplete,
cliMode = false
}: Props)
| 27 | cliMode?: boolean; |
| 28 | }; |
| 29 | export function AddMarketplace({ |
| 30 | inputValue, |
| 31 | setInputValue, |
| 32 | cursorOffset, |
| 33 | setCursorOffset, |
| 34 | error, |
| 35 | setError, |
| 36 | result, |
| 37 | setResult, |
| 38 | setViewState, |
| 39 | onAddComplete, |
| 40 | cliMode = false |
| 41 | }: Props): React.ReactNode { |
| 42 | const hasAttemptedAutoAdd = useRef(false); |
| 43 | const [isLoading, setLoading] = useState(false); |
| 44 | const [progressMessage, setProgressMessage] = useState<string>(''); |
| 45 | const handleAdd = async () => { |
| 46 | const input = inputValue.trim(); |
| 47 | if (!input) { |
| 48 | setError('Please enter a marketplace source'); |
| 49 | return; |
| 50 | } |
| 51 | const parsed = await parseMarketplaceInput(input); |
| 52 | if (!parsed) { |
| 53 | setError('Invalid marketplace source format. Try: owner/repo, https://..., or ./path'); |
| 54 | return; |
| 55 | } |
| 56 | |
| 57 | // Check if parseMarketplaceInput returned an error |
| 58 | if ('error' in parsed) { |
| 59 | setError(parsed.error); |
| 60 | return; |
| 61 | } |
| 62 | setError(null); |
| 63 | try { |
| 64 | setLoading(true); |
| 65 | setProgressMessage(''); |
| 66 | const { |
| 67 | name, |
| 68 | resolvedSource |
| 69 | } = await addMarketplaceSource(parsed, message => { |
| 70 | setProgressMessage(message); |
| 71 | }); |
| 72 | saveMarketplaceToSettings(name, { |
| 73 | source: resolvedSource |
| 74 | }); |
| 75 | clearAllCaches(); |
| 76 | let sourceType = parsed.source; |
| 77 | if (parsed.source === 'github') { |
| 78 | sourceType = parsed.repo as AnalyticsMetadata_I_VERIFIED_THIS_IS_NOT_CODE_OR_FILEPATHS; |
| 79 | } |
| 80 | logEvent('tengu_marketplace_added', { |
| 81 | source_type: sourceType as AnalyticsMetadata_I_VERIFIED_THIS_IS_NOT_CODE_OR_FILEPATHS |
| 82 | }); |
| 83 | if (onAddComplete) { |
| 84 | await onAddComplete(); |
| 85 | } |
| 86 | setProgressMessage(''); |
nothing calls this directly
no test coverage detected