@@ -258,12 +258,17 @@ export default function MarketplacePage() {
258258 agentName : string ,
259259 activeScope : ScopeValue ,
260260 ) => {
261- const key = `${ item . id } :${ agentName } ` ;
262- if ( installed . has ( key ) ) return true ;
263-
264261 const targetKey =
265262 activeScope . type === "all" ? null : scopeKey ( activeScope as ConfigScope ) ;
266263
264+ if ( targetKey !== null ) {
265+ if ( installed . has ( `${ item . id } :${ agentName } :${ targetKey } ` ) ) return true ;
266+ } else {
267+ for ( const k of installed ) {
268+ if ( k . startsWith ( `${ item . id } :${ agentName } :` ) ) return true ;
269+ }
270+ }
271+
267272 return extensions . some ( ( ext ) => {
268273 if ( ! ext . agents . includes ( agentName ) ) return false ;
269274
@@ -279,15 +284,17 @@ export default function MarketplacePage() {
279284 ext . source . url ;
280285 let extSource = "" ;
281286 if ( extUrl ) {
282- const match = extUrl . match ( / g i t h u b \. c o m \/ ( [ ^ / ] + \/ [ ^ / ] + ) / ) ;
283- extSource = match ? match [ 1 ] . replace ( / \. g i t $ / , "" ) : extUrl ;
287+ const cleanUrl = extUrl . split ( / [ ? # ] / ) [ 0 ] ;
288+ const match = cleanUrl . match ( / g i t h u b \. c o m [: / ] ( [ ^ / ] + \/ [ ^ / ] + ) / ) ;
289+ extSource = match ? match [ 1 ] . replace ( / \. g i t $ / , "" ) : cleanUrl ;
284290 }
285291 if ( ! extSource && ext . pack ) extSource = ext . pack ;
286292
287293 // GitHub repo slugs are case-insensitive; marketplace normalizes to
288294 // lowercase while scanner preserves original casing. Compare lowered
289295 // on both sides to avoid false negatives.
290296 const itemSourceLower = item . source . toLowerCase ( ) ;
297+ if ( ! itemSourceLower ) return false ;
291298 const matchSource =
292299 extSource . toLowerCase ( ) === itemSourceLower ||
293300 ( ext . pack ?? "" ) . toLowerCase ( ) === itemSourceLower ;
@@ -347,7 +354,8 @@ export default function MarketplacePage() {
347354 // Refresh extension store so audit page can resolve names immediately
348355 useExtensionStore . getState ( ) . fetch ( ) ;
349356 const key = `${ item . id } :${ targetAgent ?? "" } ` ;
350- setInstalled ( ( prev ) => new Set ( prev ) . add ( key ) ) ;
357+ const installedKey = `${ key } :${ scopeKey ( targetScope ) } ` ;
358+ setInstalled ( ( prev ) => new Set ( prev ) . add ( installedKey ) ) ;
351359 toast . success (
352360 result . was_update
353361 ? t ( "toast.updated" , { name : item . name } )
0 commit comments