refactor: remove OMO common config two-layer merge system

Each OMO provider now stores its complete configuration directly in
settings_config.otherFields instead of relying on a shared OmoGlobalConfig
merged at write time. This simplifies the data flow from a 4-tuple
(agents, categories, otherFields, useCommonConfig) to a 3-tuple and
eliminates an entire DB table, two Tauri commands, and ~1700 lines of
merge/sync code across frontend and backend.

Backend:
- Delete database/dao/omo.rs (OmoGlobalConfig struct + get/save methods)
- Remove get/set_config_snippet from settings DAO
- Remove get/set_common_config_snippet Tauri commands
- Replace merge_config() with build_config() in services/omo.rs
- Simplify OmoVariant (remove config_key, known_keys)
- Simplify import_from_local and build_local_file_data
- Rewrite all OMO service tests

Frontend:
- Delete OmoCommonConfigEditor.tsx and OmoGlobalConfigFields.tsx
- Delete src/lib/api/config.ts
- Remove OmoGlobalConfig type and merge preview functions
- Remove useGlobalConfig/useSaveGlobalConfig query hooks
- Simplify useOmoDraftState (remove all common config state)
- Replace OmoCommonConfigEditor with read-only JsonEditor preview
- Clean i18n keys (zh/en/ja)
This commit is contained in:
Jason
2026-02-26 19:31:43 +08:00
parent 3e9815f5d2
commit e7766d4d22
21 changed files with 74 additions and 1733 deletions

View File

@@ -1,19 +1,9 @@
import { describe, expect, it } from "vitest";
import {
mergeOmoConfigPreview,
buildOmoProfilePreview,
parseOmoOtherFieldsObject,
type OmoGlobalConfig,
} from "@/types/omo";
const EMPTY_GLOBAL: OmoGlobalConfig = {
id: "global",
disabledAgents: [],
disabledMcps: [],
disabledHooks: [],
disabledSkills: [],
updatedAt: "2026-01-01T00:00:00.000Z",
};
describe("parseOmoOtherFieldsObject", () => {
it("解析对象 JSON", () => {
expect(parseOmoOtherFieldsObject('{ "foo": 1 }')).toEqual({ foo: 1 });
@@ -29,22 +19,12 @@ describe("parseOmoOtherFieldsObject", () => {
});
});
describe("mergeOmoConfigPreview", () => {
describe("buildOmoProfilePreview", () => {
it("只合并 otherFields 的对象值,忽略数组", () => {
const mergedFromArray = mergeOmoConfigPreview(
EMPTY_GLOBAL,
{},
{},
'["a", "b"]',
);
expect(mergedFromArray).toEqual({});
const fromArray = buildOmoProfilePreview({}, {}, '["a", "b"]');
expect(fromArray).toEqual({});
const mergedFromObject = mergeOmoConfigPreview(
EMPTY_GLOBAL,
{},
{},
'{ "foo": "bar" }',
);
expect(mergedFromObject).toEqual({ foo: "bar" });
const fromObject = buildOmoProfilePreview({}, {}, '{ "foo": "bar" }');
expect(fromObject).toEqual({ foo: "bar" });
});
});