Skip to content

Commit acb02b5

Browse files
committed
Fix uninstall visual state not working in versioned bundles
1 parent 0a38393 commit acb02b5

File tree

1 file changed

+135
-4
lines changed

1 file changed

+135
-4
lines changed

src/ui/MarketplaceViewProvider.ts

Lines changed: 135 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -356,7 +356,29 @@ export class MarketplaceViewProvider implements vscode.WebviewViewProvider {
356356
try {
357357
this.logger.info(`Uninstalling bundle from marketplace: ${bundleId}`);
358358

359-
await this.registryManager.uninstallBundle(bundleId, 'user');
359+
// Find the actual installed bundle using identity matching
360+
const installedBundles = await this.registryManager.listInstalledBundles();
361+
const sources = await this.registryManager.listSources();
362+
363+
// Get the bundle to determine its source type
364+
const bundles = await this.registryManager.searchBundles({});
365+
const bundle = bundles.find(b => b.id === bundleId);
366+
367+
if (!bundle) {
368+
throw new Error('Bundle not found');
369+
}
370+
371+
const source = sources.find(s => s.id === bundle.sourceId);
372+
const installed = installedBundles.find(ib =>
373+
this.matchesBundleIdentity(ib.bundleId, bundle.id, source?.type || 'local')
374+
);
375+
376+
if (!installed) {
377+
throw new Error(`Bundle '${bundleId}' is not installed`);
378+
}
379+
380+
// Use the stored bundle ID from the installation record
381+
await this.registryManager.uninstallBundle(installed.bundleId, installed.scope || 'user');
360382

361383
vscode.window.showInformationMessage(`✅ Bundle uninstalled successfully!`);
362384

@@ -470,9 +492,13 @@ export class MarketplaceViewProvider implements vscode.WebviewViewProvider {
470492
return;
471493
}
472494

473-
// Check if installed to get manifest
495+
// Check if installed to get manifest - use identity matching for GitHub bundles
474496
const installedBundles = await this.registryManager.listInstalledBundles();
475-
const installed = installedBundles.find(ib => ib.bundleId === bundleId);
497+
const sources = await this.registryManager.listSources();
498+
const source = sources.find(s => s.id === bundle.sourceId);
499+
const installed = installedBundles.find(ib =>
500+
this.matchesBundleIdentity(ib.bundleId, bundle.id, source?.type || 'local')
501+
);
476502
const breakdown = this.getContentBreakdown(bundle, installed?.manifest);
477503

478504
// Create webview panel
@@ -1370,6 +1396,105 @@ export class MarketplaceViewProvider implements vscode.WebviewViewProvider {
13701396
opacity: 0.9;
13711397
}
13721398
1399+
/* Version selector styles */
1400+
.version-selector {
1401+
position: relative;
1402+
display: inline-block;
1403+
}
1404+
1405+
.version-selector-btn {
1406+
padding: 8px 12px;
1407+
background: var(--vscode-button-background);
1408+
color: var(--vscode-button-foreground);
1409+
border: none;
1410+
border-radius: 4px;
1411+
cursor: pointer;
1412+
font-size: 13px;
1413+
font-weight: 500;
1414+
display: flex;
1415+
align-items: center;
1416+
gap: 6px;
1417+
transition: background 0.2s;
1418+
}
1419+
1420+
.version-selector-btn:hover {
1421+
background: var(--vscode-button-hoverBackground);
1422+
}
1423+
1424+
.version-selector-icon {
1425+
font-size: 11px;
1426+
}
1427+
1428+
.version-dropdown {
1429+
position: absolute;
1430+
bottom: 100%;
1431+
left: 0;
1432+
margin-bottom: 4px;
1433+
background: var(--vscode-dropdown-background);
1434+
border: 1px solid var(--vscode-dropdown-border);
1435+
border-radius: 4px;
1436+
box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
1437+
z-index: 1000;
1438+
min-width: 200px;
1439+
max-height: 300px;
1440+
overflow-y: auto;
1441+
display: none;
1442+
}
1443+
1444+
.version-dropdown.show {
1445+
display: block;
1446+
}
1447+
1448+
.version-dropdown-header {
1449+
padding: 8px 12px;
1450+
border-bottom: 1px solid var(--vscode-dropdown-border);
1451+
font-size: 12px;
1452+
font-weight: 600;
1453+
color: var(--vscode-descriptionForeground);
1454+
}
1455+
1456+
.version-item {
1457+
padding: 8px 12px;
1458+
cursor: pointer;
1459+
font-size: 13px;
1460+
display: flex;
1461+
align-items: center;
1462+
justify-content: space-between;
1463+
transition: background 0.15s;
1464+
}
1465+
1466+
.version-item:hover {
1467+
background: var(--vscode-list-hoverBackground);
1468+
}
1469+
1470+
.version-item.current {
1471+
background: var(--vscode-list-activeSelectionBackground);
1472+
color: var(--vscode-list-activeSelectionForeground);
1473+
}
1474+
1475+
.version-item.uninstall {
1476+
color: var(--vscode-errorForeground);
1477+
font-weight: 600;
1478+
border-bottom: 1px solid var(--vscode-dropdown-border);
1479+
}
1480+
1481+
.version-item.uninstall:hover {
1482+
background: var(--vscode-inputValidation-errorBackground);
1483+
}
1484+
1485+
.version-badge {
1486+
font-size: 10px;
1487+
padding: 2px 6px;
1488+
border-radius: 8px;
1489+
background: var(--vscode-badge-background);
1490+
color: var(--vscode-badge-foreground);
1491+
}
1492+
1493+
.version-badge.latest {
1494+
background: var(--vscode-gitDecoration-addedResourceForeground);
1495+
color: white;
1496+
}
1497+
13731498
.empty-state {
13741499
text-align: center;
13751500
padding: 60px 20px;
@@ -1830,7 +1955,9 @@ export class MarketplaceViewProvider implements vscode.WebviewViewProvider {
18301955
</div>
18311956
18321957
<div class="bundle-actions" onclick="event.stopPropagation()">
1833-
\${bundle.installed
1958+
\${bundle.buttonState === 'update'
1959+
? \`<button class="btn btn-primary" onclick="updateBundle('\${bundle.id}')">Update\${bundle.installedVersion ? ' (v' + bundle.installedVersion + ' → v' + bundle.version + ')' : ''}</button>\`
1960+
: bundle.buttonState === 'uninstall'
18341961
? \`<button class="btn btn-danger" onclick="uninstallBundle('\${bundle.id}')">Uninstall</button>\`
18351962
: \`<button class="btn btn-primary" onclick="installBundle('\${bundle.id}')">Install</button>\`
18361963
}
@@ -1855,6 +1982,10 @@ export class MarketplaceViewProvider implements vscode.WebviewViewProvider {
18551982
vscode.postMessage({ type: 'install', bundleId });
18561983
}
18571984
1985+
function updateBundle(bundleId) {
1986+
vscode.postMessage({ type: 'update', bundleId });
1987+
}
1988+
18581989
function uninstallBundle(bundleId) {
18591990
vscode.postMessage({ type: 'uninstall', bundleId });
18601991
}

0 commit comments

Comments
 (0)