diff --git a/packages/cli/src/utils/settingsUtils.test.ts b/packages/cli/src/utils/settingsUtils.test.ts index a1f662af4d..9274c1b6f8 100644 --- a/packages/cli/src/utils/settingsUtils.test.ts +++ b/packages/cli/src/utils/settingsUtils.test.ts @@ -734,6 +734,55 @@ describe('SettingsUtils', () => { ); expect(result).toBe('false'); }); + + it('should display objects as JSON strings, not "[object Object]"', () => { + vi.mocked(getSettingsSchema).mockReturnValue({ + experimental: { + type: 'object', + label: 'Experimental', + category: 'Experimental', + requiresRestart: true, + default: {}, + description: 'Experimental settings', + showInDialog: false, + properties: { + gemmaModelRouter: { + type: 'object', + label: 'Gemma Model Router', + category: 'Experimental', + requiresRestart: true, + default: {}, + description: 'Gemma model router settings', + showInDialog: true, + }, + }, + }, + } as unknown as SettingsSchemaType); + + // Test with empty object (default) + const emptySettings = makeMockSettings({}); + const emptyResult = getDisplayValue( + 'experimental.gemmaModelRouter', + emptySettings, + emptySettings, + ); + expect(emptyResult).toBe('{}'); + expect(emptyResult).not.toBe('[object Object]'); + + // Test with object containing values + const settings = makeMockSettings({ + experimental: { + gemmaModelRouter: { enabled: true, host: 'localhost' }, + }, + }); + const result = getDisplayValue( + 'experimental.gemmaModelRouter', + settings, + settings, + ); + expect(result).toBe('{"enabled":true,"host":"localhost"}*'); + expect(result).not.toContain('[object Object]'); + }); }); describe('getDisplayValue with units', () => { diff --git a/packages/cli/src/utils/settingsUtils.ts b/packages/cli/src/utils/settingsUtils.ts index 11c3a9a13f..daa599826f 100644 --- a/packages/cli/src/utils/settingsUtils.ts +++ b/packages/cli/src/utils/settingsUtils.ts @@ -284,7 +284,14 @@ export function getDisplayValue( let valueString = String(value); - if (definition?.type === 'enum' && definition.options) { + // Handle object types by stringifying them + if ( + definition?.type === 'object' && + value !== null && + typeof value === 'object' + ) { + valueString = JSON.stringify(value); + } else if (definition?.type === 'enum' && definition.options) { const option = definition.options?.find((option) => option.value === value); valueString = option?.label ?? `${value}`; }