Skip to content

armgit / avibe

Public Imported from GitHub
0

Make your computer a home for your AI partner. Avibe is the local-first Agent OS: Vibey, its built-in AI partner, works out of the box, and Claude Code, Codex & OpenCode run unchanged beside it — reach them from your browser, phone, or any chat app.

fix(model-hub): canonicalize OpenCode menu snapshots

cyh012eb32a91d8
diff --git a/ui/src/components/settings/models/menuBaseline.test.ts b/ui/src/components/settings/models/menuBaseline.test.ts
index c94858d27..120b07d5a 100644
--- a/ui/src/components/settings/models/menuBaseline.test.ts
+++ b/ui/src/components/settings/models/menuBaseline.test.ts
@@ -48,6 +48,23 @@ describe('readOpenCodeMenuBaseline', () => {
expect(readValue).toHaveBeenCalledTimes(2);
});
+ it('accepts identical Source and model inventories returned in different orders', async () => {
+ const getAgentSources = vi.fn().mockResolvedValue(agent(['src_a', 'src_b']));
+ const readValue = vi.fn()
+ .mockResolvedValueOnce([
+ source('src_b', ['model-b', 'model-a']),
+ source('src_a', ['model-c']),
+ ])
+ .mockResolvedValueOnce([
+ source('src_a', ['model-c']),
+ source('src_b', ['model-a', 'model-b']),
+ ]);
+
+ const baseline = await readOpenCodeMenuBaseline({ getAgentSources }, { readValue });
+
+ expect(baseline.sources.map(({ id }) => id)).toEqual(['src_a', 'src_b']);
+ });
+
it('rejects Source model content that changes across the Agent read', async () => {
const getAgentSources = vi.fn().mockResolvedValue(agent(['src_a']));
const readValue = vi.fn()
diff --git a/ui/src/components/settings/models/menuBaseline.ts b/ui/src/components/settings/models/menuBaseline.ts
index 891ed00dc..69fedbbcd 100644
--- a/ui/src/components/settings/models/menuBaseline.ts
+++ b/ui/src/components/settings/models/menuBaseline.ts
@@ -13,8 +13,19 @@ export type OpenCodeMenuIntent = {
removed: Set<string>;
};
+const byId = <T extends { id: string }>(left: T, right: T): number =>
+ left.id.localeCompare(right.id);
+
+const canonicalSourceSnapshot = (sources: Source[]): Source[] =>
+ sources
+ .map((source) => ({
+ ...source,
+ models: [...source.models].sort(byId),
+ }))
+ .sort(byId);
+
const sameSourceSnapshot = (left: Source[], right: Source[]): boolean =>
- JSON.stringify(left) === JSON.stringify(right);
+ JSON.stringify(canonicalSourceSnapshot(left)) === JSON.stringify(canonicalSourceSnapshot(right));
/** The Agent read is authoritative only when the complete Source projection is
* unchanged on both sides of it. Source ids alone cannot detect model edits. */