Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
42 changes: 42 additions & 0 deletions src/sync/config.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,48 @@ describe('stripOverrides', () => {

expect(stripped).toEqual({ theme: 'opencode', other: true });
});

it('strips override object keys missing from local config even when present in base', () => {
const base = {
mcp: { context7: { url: 'https://example.com' } },
server: { port: 8080, hostname: '0.0.0.0' },
};
const overrides = {
mcp: { context7: { headers: { apiKey: 'local-key' } } },
server: { port: 8080, hostname: '0.0.0.0' },
};
const local = {
mcp: { context7: { url: 'https://example.com', headers: { apiKey: 'local-key' } } },
};

const stripped = stripOverrides(local, overrides, base);

expect(stripped).not.toHaveProperty('server');
expect(stripped).toEqual({
mcp: { context7: { url: 'https://example.com' } },
});
});

it('strips override scalar keys missing from local config even when present in base', () => {
const base = { theme: 'dark', port: 3000 };
const overrides = { theme: 'light', port: 8080 };
const local = { theme: 'light' };

const stripped = stripOverrides(local, overrides, base);

expect(stripped).not.toHaveProperty('port');
expect(stripped).toEqual({ theme: 'dark' });
});

it('strips override keys from local when present in local and base', () => {
const base = { theme: 'dark', editor: 'vim' };
const overrides = { theme: 'light', editor: 'code' };
const local = { theme: 'light', editor: 'code', extra: true };

const stripped = stripOverrides(local, overrides, base);

expect(stripped).toEqual({ theme: 'dark', editor: 'vim', extra: true });
});
});

describe('normalizeSyncConfig', () => {
Expand Down
2 changes: 1 addition & 1 deletion src/sync/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -236,7 +236,7 @@ export function stripOverrides(
continue;
}

if (baseValue === undefined) {
if (currentValue === undefined || baseValue === undefined) {
delete result[key];
} else {
result[key] = baseValue;
Expand Down