fix(marketplace): correct mode slug handling and update en marketplace i18n

Refs #8181
This commit is contained in:
matt-rudolph 2025-09-23 16:10:22 -06:00
parent d3a24a3c6a
commit 4e480496ac
3 changed files with 19 additions and 17 deletions

View file

@ -64,6 +64,7 @@
"installError": "Failed to install \"{{itemName}}\": {{errorMessage}}",
"removing": "Removing item: \"{{itemName}}\"",
"removeSuccess": "\"{{itemName}}\" removed successfully",
"removeError": "Failed to remove \"{{itemName}}\": {{errorMessage}}"
"removeError": "Failed to remove \"{{itemName}}\": {{errorMessage}}",
"notInstalledForTarget": "Mode not found"
}
}

View file

@ -4,7 +4,13 @@ import * as path from "path"
import * as vscode from "vscode"
import * as yaml from "yaml"
import type { OrganizationSettings, MarketplaceItem, MarketplaceItemType, McpMarketplaceItem, ModeConfig } from "@roo-code/types"
import type {
OrganizationSettings,
MarketplaceItem,
MarketplaceItemType,
McpMarketplaceItem,
ModeConfig,
} from "@roo-code/types"
import { customModesSettingsSchema } from "@roo-code/types"
import { TelemetryService } from "@roo-code/telemetry"
import { CloudService } from "@roo-code/cloud"
@ -254,10 +260,7 @@ export class MarketplaceManager {
}
// Helper: parse YAML and collect installed mode metadata with proper typing
private collectInstalledModesFromYaml(
content: string,
out: Record<string, { type: string }>,
): void {
private collectInstalledModesFromYaml(content: string, out: Record<string, { type: string }>): void {
try {
const parsed = yaml.parse(content)
const result = customModesSettingsSchema.safeParse(parsed)
@ -266,7 +269,7 @@ export class MarketplaceManager {
}
for (const mode of result.data.customModes) {
if (this.isMarketplaceInstalledMode(mode)) {
out[mode.marketplaceItemId!] = { type: "mode" }
out[mode.marketplaceItemId] = { type: "mode" }
}
}
} catch {

View file

@ -2,7 +2,7 @@ import * as vscode from "vscode"
import * as path from "path"
import * as fs from "fs/promises"
import * as yaml from "yaml"
import type { MarketplaceItem, MarketplaceItemType, InstallMarketplaceItemOptions, McpParameter, ModeConfig } from "@roo-code/types"
import type { MarketplaceItem, McpParameter, ModeConfig } from "@roo-code/types"
import { GlobalFileNames } from "../../shared/globalFileNames"
import { ensureSettingsDirectoryExists } from "../../utils/globalContext"
import type { CustomModesManager } from "../../core/config/CustomModesManager"
@ -22,6 +22,7 @@ export class SimpleInstaller {
async installItem(item: MarketplaceItem, options: InstallOptions): Promise<{ filePath: string; line?: number }> {
const { target } = options
const itemType = item.type
switch (item.type) {
case "mode":
@ -29,7 +30,7 @@ export class SimpleInstaller {
case "mcp":
return await this.installMcp(item, target, options)
default:
throw new Error("Unsupported item type")
throw new Error(`Unsupported item type: ${itemType}`)
}
}
@ -293,6 +294,7 @@ export class SimpleInstaller {
async removeItem(item: MarketplaceItem, options: InstallOptions): Promise<void> {
const { target } = options
const itemType = item.type
switch (item.type) {
case "mode":
@ -302,7 +304,7 @@ export class SimpleInstaller {
await this.removeMcp(item, target)
break
default:
throw new Error("Unsupported item type")
throw new Error(`Unsupported item type: ${itemType}`)
}
}
@ -343,16 +345,12 @@ export class SimpleInstaller {
)
if (!candidate) {
throw new Error(t("common:customModes.errors.modeNotFound"))
const msg = t("marketplace:installation.notInstalledForTarget")
throw new Error(msg === "installation.notInstalledForTarget" ? "Mode not found" : msg)
}
// Delete only from the selected source to avoid unintended removals
if (typeof (this.customModesManager as any).deleteCustomModeForSource === "function") {
await (this.customModesManager as any).deleteCustomModeForSource(modeSlug, target, true)
} else {
// Scoped deletion not supported in this version
throw new Error("Scoped deletion is not supported in this version")
}
await this.customModesManager.deleteCustomModeForSource(modeSlug, target, true)
}
private async removeMcp(item: MarketplaceItem, target: "project" | "global"): Promise<void> {