fix(opencode): add missing omo-slim category checks across add/form/mutation paths

Several code paths only checked for "omo" category but missed "omo-slim",
causing OMO Slim providers to be treated as regular OpenCode providers
(triggering invalid write_live_snapshot, requiring manual provider key,
and showing wrong form fields).
This commit is contained in:
Jason
2026-02-24 15:31:02 +08:00
parent 8ea9638b9d
commit bb3130cbe0
3 changed files with 21 additions and 15 deletions

View File

@@ -133,10 +133,11 @@ impl ProviderService {
// Additive mode apps (OpenCode, OpenClaw) - always write to live config
if app_type.is_additive_mode() {
// OMO providers use exclusive mode and write to dedicated config file.
if matches!(app_type, AppType::OpenCode) && provider.category.as_deref() == Some("omo")
// OMO / OMO Slim providers use exclusive mode and write to dedicated config file.
if matches!(app_type, AppType::OpenCode)
&& matches!(provider.category.as_deref(), Some("omo") | Some("omo-slim"))
{
// Do not auto-enable newly added OMO providers.
// Do not auto-enable newly added OMO / OMO Slim providers.
// Users must explicitly switch/apply an OMO provider to activate it.
return Ok(true);
}

View File

@@ -551,7 +551,7 @@ export function ProviderForm({
return;
}
if (appId === "opencode" && category !== "omo") {
if (appId === "opencode" && !isAnyOmoCategory) {
const keyPattern = /^[a-z0-9]+(-[a-z0-9]+)*$/;
if (!opencodeForm.opencodeProviderKey.trim()) {
toast.error(t("opencode.providerKeyRequired"));
@@ -732,9 +732,10 @@ export function ProviderForm({
};
if (appId === "opencode") {
if (category === "omo") {
if (isAnyOmoCategory) {
if (!isEditMode) {
payload.providerKey = `omo-${crypto.randomUUID().slice(0, 8)}`;
const prefix = category === "omo" ? "omo" : "omo-slim";
payload.providerKey = `${prefix}-${crypto.randomUUID().slice(0, 8)}`;
}
} else {
payload.providerKey = opencodeForm.opencodeProviderKey;
@@ -743,8 +744,8 @@ export function ProviderForm({
payload.providerKey = openclawForm.openclawProviderKey;
}
if (category === "omo" && !payload.presetCategory) {
payload.presetCategory = "omo";
if (isAnyOmoCategory && !payload.presetCategory) {
payload.presetCategory = category;
}
if (activePreset) {
@@ -1000,10 +1001,10 @@ export function ProviderForm({
const preset = entry.preset as OpenCodeProviderPreset;
const config = preset.settingsConfig;
if (preset.category === "omo") {
if (preset.category === "omo" || preset.category === "omo-slim") {
omoDraft.resetOmoDraftState();
form.reset({
name: "OMO",
name: preset.category === "omo" ? "OMO" : "OMO Slim",
websiteUrl: preset.websiteUrl ?? "",
settingsConfig: JSON.stringify({}, null, 2),
icon: preset.icon ?? "",
@@ -1113,7 +1114,7 @@ export function ProviderForm({
<BasicFormFields
form={form}
beforeNameSlot={
appId === "opencode" && category !== "omo" ? (
appId === "opencode" && !isAnyOmoCategory ? (
<div className="space-y-2">
<Label htmlFor="opencode-key">
{t("opencode.providerKey")}
@@ -1337,7 +1338,7 @@ export function ProviderForm({
/>
)}
{appId === "opencode" && category !== "omo" && (
{appId === "opencode" && !isAnyOmoCategory && (
<OpenCodeFormFields
npm={opencodeForm.opencodeNpm}
onNpmChange={opencodeForm.handleOpencodeNpmChange}
@@ -1531,7 +1532,7 @@ export function ProviderForm({
</>
)}
{category !== "omo" && appId !== "opencode" && appId !== "openclaw" && (
{!isAnyOmoCategory && appId !== "opencode" && appId !== "openclaw" && (
<ProviderAdvancedConfig
testConfig={testConfig}
proxyConfig={proxyConfig}

View File

@@ -19,8 +19,12 @@ export const useAddProviderMutation = (appId: AppId) => {
let id: string;
if (appId === "opencode" || appId === "openclaw") {
if (providerInput.category === "omo") {
id = `omo-${generateUUID()}`;
if (
providerInput.category === "omo" ||
providerInput.category === "omo-slim"
) {
const prefix = providerInput.category === "omo" ? "omo" : "omo-slim";
id = `${prefix}-${generateUUID()}`;
} else {
if (!providerInput.providerKey) {
throw new Error(`Provider key is required for ${appId}`);