feat(omo): unify common config enabled via provider meta for OpenCode

This commit is contained in:
YoVinchen
2026-02-12 12:01:50 +08:00
parent b9afcbf2b0
commit 0c6d429fdb
8 changed files with 65 additions and 22 deletions
+5 -1
View File
@@ -141,7 +141,11 @@ function App() {
// Fallback from sessions view when switching to an app without session support
useEffect(() => {
if (currentView === "sessions" && activeApp !== "claude" && activeApp !== "codex") {
if (
currentView === "sessions" &&
activeApp !== "claude" &&
activeApp !== "codex"
) {
setCurrentView("providers");
}
}, [activeApp, currentView]);
@@ -91,7 +91,7 @@ export function EditProviderDialog({
// 检查是否启用了通用配置
const metaByApp = provider.meta?.commonConfigEnabledByApp;
const commonConfigEnabled =
metaByApp?.[appId as "claude" | "codex" | "gemini"] ??
metaByApp?.[appId] ??
provider.meta?.commonConfigEnabled ??
false;
+22 -11
View File
@@ -651,16 +651,6 @@ export function ProviderForm({
markCommonConfigSaved: markGeminiCommonConfigSaved,
} = geminiCommonConfig;
const supportsCommonConfig =
appId === "claude" || appId === "codex" || appId === "gemini";
const commonConfigEnabled = supportsCommonConfig
? appId === "claude"
? useCommonConfig
: appId === "codex"
? useCodexCommonConfigFlag
: useGeminiCommonConfigFlag
: undefined;
const { data: opencodeProvidersData } = useProvidersQuery("opencode");
const existingOpencodeKeys = useMemo(() => {
if (!opencodeProvidersData?.providers) return [];
@@ -866,6 +856,13 @@ export function ProviderForm({
const [isOmoConfigModalOpen, setIsOmoConfigModalOpen] = useState(false);
const [useOmoCommonConfig, setUseOmoCommonConfig] = useState(() => {
const metaByApp = initialData?.meta?.commonConfigEnabledByApp;
const fromMeta =
metaByApp?.opencode ?? initialData?.meta?.commonConfigEnabled;
if (typeof fromMeta === "boolean") {
return fromMeta;
}
// Backward compatibility for old OMO data.
const raw = initialOmoSettings?.useCommonConfig;
return typeof raw === "boolean" ? raw : true;
});
@@ -949,6 +946,21 @@ export function ProviderForm({
setUseOmoCommonConfig(useCommonConfig);
}, []);
const supportsCommonConfig =
appId === "claude" ||
appId === "codex" ||
appId === "gemini" ||
isOmoCategory;
const commonConfigEnabled = supportsCommonConfig
? appId === "claude"
? useCommonConfig
: appId === "codex"
? useCodexCommonConfigFlag
: appId === "gemini"
? useGeminiCommonConfigFlag
: useOmoCommonConfig
: undefined;
const updateOpencodeSettings = useCallback(
(updater: (config: Record<string, any>) => void) => {
try {
@@ -1277,7 +1289,6 @@ export function ProviderForm({
}
} else if (appId === "opencode" && category === "omo") {
const omoConfig: Record<string, unknown> = {};
omoConfig.useCommonConfig = useOmoCommonConfig;
if (Object.keys(omoAgents).length > 0) {
omoConfig.agents = omoAgents;
}
+1
View File
@@ -124,6 +124,7 @@ export type CommonConfigEnabledByApp = Partial<{
claude: boolean;
codex: boolean;
gemini: boolean;
opencode: boolean;
}>;
// 供应商元数据(字段名与后端一致,保持 snake_case