Skip to content
Merged
13 changes: 13 additions & 0 deletions .changeset/37480-settings-retired-option.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
---
'@object-ui/console': patch
'@object-ui/i18n': patch
---

fix(console): a stored settings select, radio or multiselect value the setting no longer offers reads as "no longer available" instead of nothing chosen

Clause-②: no
Metadata-protocol: none

When a settings select's stored value is not among the options the setting declares today (an option removed in a later release, such as the knowledge adapter `ragflow`), the Setup select showed an empty box: no label and no placeholder. It now shows the stored code with a mark, for example "ragflow (no longer available)", as one disabled entry in the list. A radio group shows the same text as one checked, disabled item. A multiselect shows each stored member outside the options as a checked checkbox with the same text: ticking a current option keeps the member in the saved list, as before (and the server still refuses a save of that list while it holds one); unticking it removes it, and it cannot be ticked back. The admin can still pick a current option, which saves as before; the retired entry cannot be picked back. Values among the options, and an unset value, render as before.

New locale key: `console.settingsView.selectValueRetired` (`{{value}}` is the stored code), in all eleven Console language packs. No props or exports change.
11 changes: 11 additions & 0 deletions content/docs/protocol/kernel/config-resolution.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -341,6 +341,17 @@ monotonic `version` so `rotateKey()` can re-wrap under a new key; the audit trai
records the rotation. ObjectStack bundles no cloud provider implementation — see
[Outside this contract](#outside-this-contract).

### Retired keys and options

When a release removes a key or a select option from a manifest, rows already
stored for it are kept, unused, and never deleted by the platform; an encrypted
key's `sys_secret` row stays too. A stored value that is no longer an option
shows in Setup as "no longer available" until an admin picks a current one. No
settings door writes a removed key (`400 UNKNOWN_KEY`), so remove its rows by
hand: delete the key's row (namespace and key) from `sys_platform_setting` for a
`global`-scope manifest, or from `sys_setting` otherwise, and for an encrypted
key also the `sys_secret` row whose id that row holds in `value_enc`.

## HTTP Surface

`registerSettingsRoutes()` mounts the resolver under `/api/settings`
Expand Down
67 changes: 66 additions & 1 deletion ui/apps/console/src/pages/settings/SettingsField.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -974,6 +974,14 @@ export function SettingsField(props: SettingsFieldProps) {
/>,
);
}
// A stored value the manifest no longer offers (an option removed in a
// later release) has no item to name it, so the trigger would read
// blank. It gets one disabled item of its own, named with the stored
// code and a "no longer available" mark; picking a current option is
// an ordinary write, and the retired item cannot be picked back.
const stored = value == null ? '' : String(value);
const retired =
stored !== '' && !(spec.options ?? []).some((opt) => String(opt.value) === stored);
return wrapper(
<Select
value={value == null ? undefined : String(value)}
Expand All @@ -987,6 +995,14 @@ export function SettingsField(props: SettingsFieldProps) {
<SelectValue placeholder={t('common.select', { defaultValue: 'Select…' })} />
</SelectTrigger>
<SelectContent>
{retired ? (
<SelectItem value={stored} disabled data-testid="settings-select-retired">
{t('console.settingsView.selectValueRetired', {
value: stored,
defaultValue: '{{value}} (no longer available)',
})}
</SelectItem>
) : null}
{spec.options?.map((opt) => (
<SelectItem key={String(opt.value)} value={String(opt.value)}>
{renderOptionLabel(opt)}
Expand All @@ -996,14 +1012,31 @@ export function SettingsField(props: SettingsFieldProps) {
</Select>,
);
}
case 'radio':
case 'radio': {
// Same named state as the closed select above: a stored value the
// manifest no longer offers gets one disabled, checked item of its own,
// so the group does not read as nothing chosen.
const stored = value == null ? '' : String(value);
const retired =
stored !== '' && !(spec.options ?? []).some((opt) => String(opt.value) === stored);
return wrapper(
<RadioGroup
value={value == null ? undefined : String(value)}
onValueChange={(v) => onChange(v)}
disabled={disabled}
aria-labelledby={labelId}
>
{retired ? (
<div className="flex items-center space-x-2" data-testid="settings-radio-retired">
<RadioGroupItem value={stored} id={`${id}-retired`} disabled />
<Label htmlFor={`${id}-retired`} className="text-sm font-normal text-muted-foreground">
{t('console.settingsView.selectValueRetired', {
value: stored,
defaultValue: '{{value}} (no longer available)',
})}
</Label>
</div>
) : null}
{spec.options?.map((opt) => (
<div key={String(opt.value)} className="flex items-center space-x-2">
<RadioGroupItem value={String(opt.value)} id={`${id}-${opt.value}`} />
Expand All @@ -1015,10 +1048,42 @@ export function SettingsField(props: SettingsFieldProps) {
</RadioGroup>,
undefined,
);
}
case 'multiselect': {
const arr = Array.isArray(value) ? (value as (string | number)[]) : [];
// Stored members the manifest no longer offers are named, checked, in
// the same "no longer available" words as the select and radio arms.
// Ticking a current option keeps them in the array (the next set is
// built from the whole stored array, as before), and the server refuses
// a write of this key while one is in it (`invalid_option`), so each
// stays UNTICKABLE: unticking drops it, and once dropped it is gone
// from the list, so it cannot be ticked back.
const offered = new Set((spec.options ?? []).map((opt) => String(opt.value)));
const retiredMembers = Array.from(new Set(arr.map(String))).filter(
(v) => v !== '' && !offered.has(v),
);
return wrapper(
<div role="group" aria-labelledby={labelId} className="grid grid-cols-2 gap-2">
{retiredMembers.map((v) => (
<label
key={`retired-${v}`}
className="flex items-center gap-2 text-sm text-muted-foreground"
data-testid="settings-multiselect-retired"
>
<Checkbox
checked
disabled={disabled}
onCheckedChange={(c) => {
if (c) return;
onChange(arr.map(String).filter((m) => m !== v));
}}
/>
{t('console.settingsView.selectValueRetired', {
value: v,
defaultValue: '{{value}} (no longer available)',
})}
</label>
))}
{spec.options?.map((opt) => {
const v = String(opt.value);
const checked = arr.map(String).includes(v);
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,171 @@
/**
* ObjectUI
* Copyright (c) 2024-present ObjectStack Inc.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/

/**
* SettingsField — a closed `select` whose stored value is no longer among the
* manifest's `options` names that value as "no longer available"
* (objectstack#37480).
*
* An option removed in a later release (the knowledge adapter `ragflow`) left
* an environment that had saved it with a blank trigger: no label and no
* placeholder, because Radix shows the selected item's text and no item carried
* the stored code. The select now adds one disabled item for that code, so the
* trigger reads the code with the locale's "no longer available" mark, and the
* admin can still pick a current option.
*/

import { describe, it, expect, vi, afterEach } from 'vitest';
import { render, screen, cleanup, fireEvent } from '@testing-library/react';
import { createI18n, I18nProvider } from '@object-ui/i18n';

import { SettingsField } from '../SettingsField';
import type { Specifier } from '../types';

afterEach(cleanup);

/** A closed select: exhaustive `options`, no `valueDomain`. */
const ADAPTER: Specifier = {
type: 'select',
key: 'adapter',
label: 'Adapter',
options: [
{ value: 'builtin', label: 'Built-in' },
{ value: 'dify', label: 'Dify' },
],
};

function renderIn(language: string, value: unknown) {
const instance = createI18n({ defaultLanguage: language, detectBrowserLanguage: false });
render(
<I18nProvider instance={instance} persistLanguage={false}>
<SettingsField spec={ADAPTER} value={value} onChange={vi.fn()} />
</I18nProvider>,
);
return instance;
}

describe('objectstack#37480 — a stored select value outside the current options is named', () => {
it('under en, the trigger reads the stored code marked "no longer available"', () => {
const en = renderIn('en', 'ragflow');
const named = en.t('console.settingsView.selectValueRetired', { value: 'ragflow' });

// The key resolves in the en pack (not the raw key, not the bare code).
expect(named).toBe('ragflow (no longer available)');
expect(screen.getByRole('combobox')).toHaveTextContent(named);
expect(screen.getByRole('combobox')).not.toHaveTextContent(en.t('common.select'));
});

it('under zh-CN, the mark is the zh pack\'s text, not the en words', () => {
const zh = renderIn('zh-CN', 'ragflow');
const zhText = zh.t('console.settingsView.selectValueRetired', { value: 'ragflow' });
const enText = zh.getFixedT('en')('console.settingsView.selectValueRetired', { value: 'ragflow' });

expect(zhText).not.toBe(enText);
expect(zhText).toContain('ragflow');
expect(screen.getByRole('combobox')).toHaveTextContent(zhText);
});

it('CONTROL — a stored value among the options renders its label, with no retired mark', () => {
const en = renderIn('en', 'dify');
const combobox = screen.getByRole('combobox');
expect(combobox).toHaveTextContent('Dify');
expect(combobox).not.toHaveTextContent(
en.t('console.settingsView.selectValueRetired', { value: 'dify' }),
);
expect(screen.queryByTestId('settings-select-retired')).toBeNull();
});

it('CONTROL — no stored value still shows the placeholder, with no retired mark', () => {
const en = renderIn('en', undefined);
expect(screen.getByRole('combobox')).toHaveTextContent(en.t('common.select'));
expect(screen.queryByTestId('settings-select-retired')).toBeNull();
});
});

/** The same options drawn as a radio group. */
const ADAPTER_RADIO: Specifier = { ...ADAPTER, type: 'radio' };

function renderRadioIn(language: string, value: unknown) {
const instance = createI18n({ defaultLanguage: language, detectBrowserLanguage: false });
render(
<I18nProvider instance={instance} persistLanguage={false}>
<SettingsField spec={ADAPTER_RADIO} value={value} onChange={vi.fn()} />
</I18nProvider>,
);
return instance;
}

describe('objectstack#37480 — a stored radio value outside the current options is named', () => {
it('the group shows a checked, disabled item reading the stored code marked "no longer available"', () => {
const en = renderRadioIn('en', 'ragflow');
const named = en.t('console.settingsView.selectValueRetired', { value: 'ragflow' });

const item = screen.getByRole('radio', { name: named });
expect(item).toBeChecked();
expect(item).toBeDisabled();
// The current options stay pickable and unchecked.
expect(screen.getByRole('radio', { name: 'Dify' })).not.toBeChecked();
expect(screen.getByRole('radio', { name: 'Dify' })).toBeEnabled();
});

it('CONTROL — a stored value among the options checks its own item, with no retired item', () => {
renderRadioIn('en', 'dify');
expect(screen.getByRole('radio', { name: 'Dify' })).toBeChecked();
expect(screen.getAllByRole('radio')).toHaveLength(2);
expect(screen.queryByTestId('settings-radio-retired')).toBeNull();
});
});

/** The same options drawn as a multiselect. */
const ADAPTER_MULTI: Specifier = { ...ADAPTER, type: 'multiselect' };

function renderMultiIn(language: string, value: unknown, onChange = vi.fn()) {
const instance = createI18n({ defaultLanguage: language, detectBrowserLanguage: false });
render(
<I18nProvider instance={instance} persistLanguage={false}>
<SettingsField spec={ADAPTER_MULTI} value={value} onChange={onChange} />
</I18nProvider>,
);
return instance;
}

describe('objectstack#37480 — a stored multiselect member outside the current options is named', () => {
it('the member shows as a checked checkbox reading the stored code marked "no longer available"', () => {
const en = renderMultiIn('en', ['ragflow', 'dify']);
const named = en.t('console.settingsView.selectValueRetired', { value: 'ragflow' });

expect(screen.getByRole('checkbox', { name: named })).toBeChecked();
expect(screen.getByRole('checkbox', { name: 'Dify' })).toBeChecked();
expect(screen.getByRole('checkbox', { name: 'Built-in' })).not.toBeChecked();
});

it('ticking a current option keeps the retired member in the array, as before', () => {
const onChange = vi.fn();
renderMultiIn('en', ['ragflow'], onChange);
fireEvent.click(screen.getByRole('checkbox', { name: 'Dify' }));
expect(onChange).toHaveBeenCalledWith(['ragflow', 'dify']);
});

it('unticking the retired member drops it from the array', () => {
const onChange = vi.fn();
const en = renderMultiIn('en', ['ragflow', 'dify'], onChange);
fireEvent.click(
screen.getByRole('checkbox', {
name: en.t('console.settingsView.selectValueRetired', { value: 'ragflow' }),
}),
);
expect(onChange).toHaveBeenCalledWith(['dify']);
});

it('CONTROL — members all among the options draw only the option checkboxes', () => {
renderMultiIn('en', ['dify']);
expect(screen.getAllByRole('checkbox')).toHaveLength(2);
expect(screen.getByRole('checkbox', { name: 'Dify' })).toBeChecked();
expect(screen.queryByTestId('settings-multiselect-retired')).toBeNull();
});
});
1 change: 1 addition & 0 deletions ui/packages/i18n/src/locales/ar.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2875,6 +2875,7 @@ const ar = {
savedCleared: "تم مسح القيمة المحفوظة",
deprecatedBadge: "مهمل",
deprecatedBadgeReplacedBy: "مهمل ← {{replacedBy}}",
selectValueRetired: "{{value}} (لم يعد متاحًا)",
unsupportedSpecifierType: "نوع إعداد غير مدعوم: {{type}}",
mapAddRow: "إضافة صف",
mapRemoveRow: "إزالة {{key}}",
Expand Down
1 change: 1 addition & 0 deletions ui/packages/i18n/src/locales/de.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2587,6 +2587,7 @@ const de = {
savedCleared: "Gespeicherter Wert geleert",
deprecatedBadge: "Veraltet",
deprecatedBadgeReplacedBy: "Veraltet → {{replacedBy}}",
selectValueRetired: "{{value}} (nicht mehr verfügbar)",
unsupportedSpecifierType: "Nicht unterstützter Einstellungstyp: {{type}}",
mapAddRow: "Zeile hinzufügen",
mapRemoveRow: "{{key}} entfernen",
Expand Down
3 changes: 3 additions & 0 deletions ui/packages/i18n/src/locales/en.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2810,6 +2810,9 @@ const en = {
savedCleared: 'Saved value cleared',
deprecatedBadge: 'Deprecated',
deprecatedBadgeReplacedBy: 'Deprecated → {{replacedBy}}',
// `selectValueRetired` names a stored select value the setting no longer offers
// (an option removed in a later release); `{{value}}` is the stored code.
selectValueRetired: '{{value}} (no longer available)',
unsupportedSpecifierType: 'Unsupported specifier type: {{type}}',
// The `map` control (objectstack#31391): keyed rows over the keys the server
// serves. `mapAddRow` is the picker that adds a row by its key, `{{key}}` in
Expand Down
1 change: 1 addition & 0 deletions ui/packages/i18n/src/locales/es.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2661,6 +2661,7 @@ const es = {
savedCleared: "Valor guardado borrado",
deprecatedBadge: "Obsoleto",
deprecatedBadgeReplacedBy: "Obsoleto → {{replacedBy}}",
selectValueRetired: "{{value}} (ya no está disponible)",
unsupportedSpecifierType: "Tipo de ajuste no admitido: {{type}}",
mapAddRow: "Añadir una fila",
mapRemoveRow: "Quitar {{key}}",
Expand Down
1 change: 1 addition & 0 deletions ui/packages/i18n/src/locales/fr.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2657,6 +2657,7 @@ const fr = {
savedCleared: "Valeur enregistrée effacée",
deprecatedBadge: "Obsolète",
deprecatedBadgeReplacedBy: "Obsolète → {{replacedBy}}",
selectValueRetired: "{{value}} (plus disponible)",
unsupportedSpecifierType: "Type de paramètre non pris en charge : {{type}}",
mapAddRow: "Ajouter une ligne",
mapRemoveRow: "Retirer {{key}}",
Expand Down
1 change: 1 addition & 0 deletions ui/packages/i18n/src/locales/ja.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2589,6 +2589,7 @@ const ja = {
savedCleared: "保存された値をクリアしました",
deprecatedBadge: "非推奨",
deprecatedBadgeReplacedBy: "非推奨 → {{replacedBy}}",
selectValueRetired: "{{value}}(現在は利用できません)",
unsupportedSpecifierType: "サポートされていない設定項目の種類: {{type}}",
mapAddRow: "行を追加",
mapRemoveRow: "{{key}} を削除",
Expand Down
1 change: 1 addition & 0 deletions ui/packages/i18n/src/locales/ko.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2587,6 +2587,7 @@ const ko = {
savedCleared: "저장된 값을 지웠습니다",
deprecatedBadge: "지원 중단됨",
deprecatedBadgeReplacedBy: "지원 중단됨 → {{replacedBy}}",
selectValueRetired: "{{value}} (더 이상 사용할 수 없음)",
unsupportedSpecifierType: "지원되지 않는 설정 항목 유형: {{type}}",
mapAddRow: "행 추가",
mapRemoveRow: "{{key}} 삭제",
Expand Down
1 change: 1 addition & 0 deletions ui/packages/i18n/src/locales/pt-BR.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2656,6 +2656,7 @@ const pt = {
savedCleared: "Valor salvo limpo",
deprecatedBadge: "Obsoleto",
deprecatedBadgeReplacedBy: "Obsoleto → {{replacedBy}}",
selectValueRetired: "{{value}} (não está mais disponível)",
unsupportedSpecifierType: "Tipo de configuração não suportado: {{type}}",
mapAddRow: "Adicionar uma linha",
mapRemoveRow: "Remover {{key}}",
Expand Down
1 change: 1 addition & 0 deletions ui/packages/i18n/src/locales/ru.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2737,6 +2737,7 @@ const ru = {
savedCleared: "Сохранённое значение очищено",
deprecatedBadge: "Устарело",
deprecatedBadgeReplacedBy: "Устарело → {{replacedBy}}",
selectValueRetired: "{{value}} (больше недоступно)",
unsupportedSpecifierType: "Неподдерживаемый тип настройки: {{type}}",
mapAddRow: "Добавить строку",
mapRemoveRow: "Удалить {{key}}",
Expand Down
1 change: 1 addition & 0 deletions ui/packages/i18n/src/locales/zh-Hans.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2383,6 +2383,7 @@ const zh = {
savedCleared: '已清除保存的值',
deprecatedBadge: '已弃用',
deprecatedBadgeReplacedBy: '已弃用 → {{replacedBy}}',
selectValueRetired: '{{value}}(已不可用)',
unsupportedSpecifierType: '不支持的设置项类型:{{type}}',
mapAddRow: '添加一行',
mapRemoveRow: '移除 {{key}}',
Expand Down
1 change: 1 addition & 0 deletions ui/packages/i18n/src/locales/zh-Hant.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2383,6 +2383,7 @@ const zhHant = {
savedCleared: '已清除儲存的值',
deprecatedBadge: '已棄用',
deprecatedBadgeReplacedBy: '已棄用 → {{replacedBy}}',
selectValueRetired: '{{value}}(已不可用)',
unsupportedSpecifierType: '不支援的設定項型別:{{type}}',
mapAddRow: '新增一行',
mapRemoveRow: '移除 {{key}}',
Expand Down
Loading