Skip to content

AI-native design editor. Open-source Figma alternative.

feat(settings): one Reset to default for every setting with a default (#1695)

Danila Poyarkov6af643979323
diff --git a/changes/1695/changed.md b/changes/1695/changed.md
new file mode 100644
index 000000000..4fcb935df
--- /dev/null
+++ b/changes/1695/changed.md
@@ -0,0 +1 @@
+- Every setting with a default offers the same Reset to default, shown only while it differs, including the toolbar layout, tool access, chat, notifications, and online fonts.
diff --git a/packages/vue/src/i18n/locales/de/automation.json b/packages/vue/src/i18n/locales/de/automation.json
index af74b6dfc..d65629acc 100644
--- a/packages/vue/src/i18n/locales/de/automation.json
+++ b/packages/vue/src/i18n/locales/de/automation.json
@@ -1,5 +1,4 @@
{
- "restoreToolDefaults": "Standard wiederherstellen",
"aiToolAccessDescription": "Werkzeuge für direkte KI-Modellverbindungen auswählen. ACP- und Pi-Agenten verwenden stattdessen den MCP-Zugriff.",
"mcpToolAccessDescription": "Werkzeuge auswählen, die der lokale Server verbundenen Agenten und Clients anbietet.",
"aiToolsNotice": "Änderungen gelten ab der nächsten Nachricht. Werkzeugschalter sind keine Sandbox: Aktivierte Skriptwerkzeuge können weiterhin andere Designoperationen ausführen.",
diff --git a/packages/vue/src/i18n/locales/de/settings.json b/packages/vue/src/i18n/locales/de/settings.json
index 40c9b0a5d..9e430afdb 100644
--- a/packages/vue/src/i18n/locales/de/settings.json
+++ b/packages/vue/src/i18n/locales/de/settings.json
@@ -1,7 +1,6 @@
{
"interfaceScale": "Oberflächengröße",
"interfaceScaleDescription": "Skaliert Bedienfelder, Text und Steuerelemente, ohne den Canvas-Zoom zu ändern.",
- "interfaceScaleDefault": "{scale} (Standard)",
"recentFiles": "Zuletzt verwendete Dateien",
"recentFilesDescription": "Wähle, wie viele Dateien in der Liste und im Menü „Zuletzt verwendet“ gespeichert werden.",
"recentFilesLimit": "Anzahl zuletzt verwendeter Dateien",
@@ -67,7 +66,6 @@
"toolbarMoveDown": "Nach unten",
"toolbarGroupWith": "Mit {tool} gruppieren",
"toolbarUngroup": "Gruppierung aufheben",
- "toolbarReset": "Auf Standard zurücksetzen",
"resetToDefault": "Auf Standard zurücksetzen",
"customizeToolbar": "Werkzeugleiste anpassen…",
"discardChanges": "Änderungen verwerfen?",
diff --git a/packages/vue/src/i18n/locales/es/automation.json b/packages/vue/src/i18n/locales/es/automation.json
index 3986cc064..b2405d917 100644
--- a/packages/vue/src/i18n/locales/es/automation.json
+++ b/packages/vue/src/i18n/locales/es/automation.json
@@ -1,5 +1,4 @@
{
- "restoreToolDefaults": "Restaurar valores predeterminados",
"aiToolAccessDescription": "Elige herramientas para conexiones directas a modelos de IA. Los agentes ACP y Pi utilizan el acceso MCP.",
"mcpToolAccessDescription": "Elige las herramientas que el servidor local ofrece a los agentes y clientes conectados.",
"aiToolsNotice": "Los cambios se aplican al siguiente mensaje. Los interruptores no aíslan la ejecución: las herramientas de scripts habilitadas pueden realizar otras operaciones de diseño.",
diff --git a/packages/vue/src/i18n/locales/es/settings.json b/packages/vue/src/i18n/locales/es/settings.json
index 36a29c668..589692ae0 100644
--- a/packages/vue/src/i18n/locales/es/settings.json
+++ b/packages/vue/src/i18n/locales/es/settings.json
@@ -1,7 +1,6 @@
{
"interfaceScale": "Tamaño de la interfaz",
"interfaceScaleDescription": "Ajusta el tamaño de los paneles, el texto y los controles sin cambiar el zoom del lienzo.",
- "interfaceScaleDefault": "{scale} (predeterminado)",
"recentFiles": "Archivos recientes",
"recentFilesDescription": "Elige cuántos archivos conservar en la lista de recientes y en el menú Abrir recientes.",
"recentFilesLimit": "Número de archivos recientes",
@@ -67,7 +66,6 @@
"toolbarMoveDown": "Bajar",
"toolbarGroupWith": "Agrupar con {tool}",
"toolbarUngroup": "Desagrupar",
- "toolbarReset": "Restablecer valores predeterminados",
"resetToDefault": "Restablecer valores predeterminados",
"customizeToolbar": "Personalizar barra de herramientas…",
"discardChanges": "¿Descartar los cambios?",
diff --git a/packages/vue/src/i18n/locales/fr/automation.json b/packages/vue/src/i18n/locales/fr/automation.json
index bf0f6186c..9a2df9f7a 100644
--- a/packages/vue/src/i18n/locales/fr/automation.json
+++ b/packages/vue/src/i18n/locales/fr/automation.json
@@ -1,5 +1,4 @@
{
- "restoreToolDefaults": "Rétablir les valeurs par défaut",
"aiToolAccessDescription": "Choisissez les outils pour les connexions directes aux modèles d’IA. Les agents ACP et Pi utilisent l’accès MCP.",
"mcpToolAccessDescription": "Choisissez les outils que le serveur local propose aux agents et clients connectés.",
"aiToolsNotice": "Les modifications s’appliquent au prochain message. Les interrupteurs ne constituent pas un bac à sable : les outils de script activés peuvent effectuer d’autres opérations de conception.",
diff --git a/packages/vue/src/i18n/locales/fr/settings.json b/packages/vue/src/i18n/locales/fr/settings.json
index 1909d2de0..f7c43abcd 100644
--- a/packages/vue/src/i18n/locales/fr/settings.json
+++ b/packages/vue/src/i18n/locales/fr/settings.json
@@ -1,7 +1,6 @@
{
"interfaceScale": "Taille de l’interface",
"interfaceScaleDescription": "Redimensionne les panneaux, le texte et les commandes sans modifier le zoom du canevas.",
- "interfaceScaleDefault": "{scale} (par défaut)",
"recentFiles": "Fichiers récents",
"recentFilesDescription": "Choisissez combien de fichiers conserver dans la liste et le menu des fichiers récents.",
"recentFilesLimit": "Nombre de fichiers récents",
@@ -67,7 +66,6 @@
"toolbarMoveDown": "Descendre",
"toolbarGroupWith": "Grouper avec {tool}",
"toolbarUngroup": "Dégrouper",
- "toolbarReset": "Rétablir les valeurs par défaut",
"resetToDefault": "Rétablir les valeurs par défaut",
"customizeToolbar": "Personnaliser la barre d’outils…",
"discardChanges": "Abandonner les modifications ?",
diff --git a/packages/vue/src/i18n/locales/it/automation.json b/packages/vue/src/i18n/locales/it/automation.json
index 2e2873bf3..1e495c268 100644
--- a/packages/vue/src/i18n/locales/it/automation.json
+++ b/packages/vue/src/i18n/locales/it/automation.json
@@ -1,5 +1,4 @@
{
- "restoreToolDefaults": "Ripristina valori predefiniti",
"aiToolAccessDescription": "Scegli gli strumenti per le connessioni dirette ai modelli IA. Gli agenti ACP e Pi utilizzano invece l’accesso MCP.",
"mcpToolAccessDescription": "Scegli gli strumenti che il server locale offre agli agenti e ai client connessi.",
"aiToolsNotice": "Le modifiche si applicano dal prossimo messaggio. Gli interruttori non isolano l’esecuzione: gli strumenti di script abilitati possono eseguire altre operazioni di progettazione.",
diff --git a/packages/vue/src/i18n/locales/it/settings.json b/packages/vue/src/i18n/locales/it/settings.json
index 6f49ccbc7..e08077276 100644
--- a/packages/vue/src/i18n/locales/it/settings.json
+++ b/packages/vue/src/i18n/locales/it/settings.json
@@ -1,7 +1,6 @@
{
"interfaceScale": "Dimensione dell’interfaccia",
"interfaceScaleDescription": "Ridimensiona pannelli, testo e controlli senza modificare lo zoom della tela.",
- "interfaceScaleDefault": "{scale} (predefinito)",
"recentFiles": "File recenti",
"recentFilesDescription": "Scegli quanti file conservare nell’elenco e nel menu dei file recenti.",
"recentFilesLimit": "Numero di file recenti",
@@ -67,7 +66,6 @@
"toolbarMoveDown": "Sposta giù",
"toolbarGroupWith": "Raggruppa con {tool}",
"toolbarUngroup": "Separa",
- "toolbarReset": "Ripristina predefiniti",
"resetToDefault": "Ripristina predefiniti",
"customizeToolbar": "Personalizza barra degli strumenti…",
"discardChanges": "Scartare le modifiche?",
diff --git a/packages/vue/src/i18n/locales/ja/automation.json b/packages/vue/src/i18n/locales/ja/automation.json
index 8f7d922f3..d0df0ee44 100644
--- a/packages/vue/src/i18n/locales/ja/automation.json
+++ b/packages/vue/src/i18n/locales/ja/automation.json
@@ -1,5 +1,4 @@
{
- "restoreToolDefaults": "既定値に戻す",
"aiToolAccessDescription": "AI モデルへの直接接続で使うツールを選択します。ACP と Pi エージェントは MCP アクセスを使用します。",
"mcpToolAccessDescription": "ローカルサーバーが接続中のエージェントやクライアントに公開するツールを選択します。",
"aiToolsNotice": "変更は次のメッセージから適用されます。ツールの切り替えはサンドボックスではありません。有効なスクリプトツールは他のデザイン操作も実行できます。",
diff --git a/packages/vue/src/i18n/locales/ja/settings.json b/packages/vue/src/i18n/locales/ja/settings.json
index 67beae421..e8b1c3560 100644
--- a/packages/vue/src/i18n/locales/ja/settings.json
+++ b/packages/vue/src/i18n/locales/ja/settings.json
@@ -1,7 +1,6 @@
{
"interfaceScale": "インターフェースのサイズ",
"interfaceScaleDescription": "キャンバスのズームを変更せずに、パネル、テキスト、コントロールのサイズを調整します。",
- "interfaceScaleDefault": "{scale}(デフォルト)",
"recentFiles": "最近使ったファイル",
"recentFilesDescription": "最近使ったファイルの一覧とメニューに保持するファイル数を選択します。",
"recentFilesLimit": "最近使ったファイルの数",
@@ -67,7 +66,6 @@
"toolbarMoveDown": "下へ移動",
"toolbarGroupWith": "{tool}とまとめる",
"toolbarUngroup": "グループ解除",
- "toolbarReset": "デフォルトに戻す",
"resetToDefault": "デフォルトに戻す",
"customizeToolbar": "ツールバーをカスタマイズ…",
"discardChanges": "変更を破棄しますか?",
diff --git a/packages/vue/src/i18n/locales/pl/automation.json b/packages/vue/src/i18n/locales/pl/automation.json
index 59319943f..37e751402 100644
--- a/packages/vue/src/i18n/locales/pl/automation.json
+++ b/packages/vue/src/i18n/locales/pl/automation.json
@@ -1,5 +1,4 @@
{
- "restoreToolDefaults": "Przywróć domyślne",
"aiToolAccessDescription": "Wybierz narzędzia dla bezpośrednich połączeń z modelami AI. Agenci ACP i Pi korzystają z dostępu MCP.",
"mcpToolAccessDescription": "Wybierz narzędzia udostępniane przez lokalny serwer połączonym agentom i klientom.",
"aiToolsNotice": "Zmiany obowiązują od następnej wiadomości. Przełączniki nie izolują wykonania: włączone narzędzia skryptowe mogą wykonywać inne operacje projektowe.",
diff --git a/packages/vue/src/i18n/locales/pl/settings.json b/packages/vue/src/i18n/locales/pl/settings.json
index f4f810c84..477068287 100644
--- a/packages/vue/src/i18n/locales/pl/settings.json
+++ b/packages/vue/src/i18n/locales/pl/settings.json
@@ -1,7 +1,6 @@
{
"interfaceScale": "Rozmiar interfejsu",
"interfaceScaleDescription": "Skaluj panele, tekst i elementy sterujące bez zmiany powiększenia płótna.",
- "interfaceScaleDefault": "{scale} (domyślnie)",
"recentFiles": "Ostatnie pliki",
"recentFilesDescription": "Wybierz, ile plików zachować na liście ostatnich plików i w menu ich otwierania.",
"recentFilesLimit": "Liczba ostatnich plików",
@@ -67,7 +66,6 @@
"toolbarMoveDown": "Przesuń w dół",
"toolbarGroupWith": "Grupuj z: {tool}",
"toolbarUngroup": "Rozgrupuj",
- "toolbarReset": "Przywróć domyślne",
"resetToDefault": "Przywróć domyślne",
"customizeToolbar": "Dostosuj pasek narzędzi…",
"discardChanges": "Odrzucić zmiany?",
diff --git a/packages/vue/src/i18n/locales/ru/automation.json b/packages/vue/src/i18n/locales/ru/automation.json
index cadfcf021..8281c0a0f 100644
--- a/packages/vue/src/i18n/locales/ru/automation.json
+++ b/packages/vue/src/i18n/locales/ru/automation.json
@@ -1,5 +1,4 @@
{
- "restoreToolDefaults": "Восстановить настройки",
"aiToolAccessDescription": "Выберите инструменты для прямых подключений к моделям ИИ. Агенты ACP и Pi используют доступ через MCP.",
"mcpToolAccessDescription": "Выберите инструменты, которые локальный сервер предоставляет подключённым агентам и клиентам.",
"aiToolsNotice": "Изменения применяются со следующего сообщения. Переключатели не изолируют выполнение: включённые инструменты скриптов могут выполнять и другие операции с дизайном.",
diff --git a/packages/vue/src/i18n/locales/ru/settings.json b/packages/vue/src/i18n/locales/ru/settings.json
index d5842885b..e07e5afc0 100644
--- a/packages/vue/src/i18n/locales/ru/settings.json
+++ b/packages/vue/src/i18n/locales/ru/settings.json
@@ -1,7 +1,6 @@
{
"interfaceScale": "Размер интерфейса",
"interfaceScaleDescription": "Изменяет размер панелей, текста и элементов управления, не меняя масштаб холста.",
- "interfaceScaleDefault": "{scale} (по умолчанию)",
"recentFiles": "Недавние файлы",
"recentFilesDescription": "Выберите, сколько файлов хранить в списке недавних файлов и меню их открытия.",
"recentFilesLimit": "Количество недавних файлов",
@@ -67,7 +66,6 @@
"toolbarMoveDown": "Переместить вниз",
"toolbarGroupWith": "Объединить с: {tool}",
"toolbarUngroup": "Разгруппировать",
- "toolbarReset": "Сбросить по умолчанию",
"resetToDefault": "Сбросить по умолчанию",
"customizeToolbar": "Настроить панель инструментов…",
"discardChanges": "Отменить изменения?",
diff --git a/packages/vue/src/i18n/locales/zh-cn/automation.json b/packages/vue/src/i18n/locales/zh-cn/automation.json
index 6ada22945..4f8d6902b 100644
--- a/packages/vue/src/i18n/locales/zh-cn/automation.json
+++ b/packages/vue/src/i18n/locales/zh-cn/automation.json
@@ -1,5 +1,4 @@
{
- "restoreToolDefaults": "恢复默认设置",
"aiToolAccessDescription": "选择直接连接 AI 模型时可用的工具。ACP 和 Pi 智能体使用 MCP 访问权限。",
"mcpToolAccessDescription": "选择本地服务器向已连接的智能体和客户端提供的工具。",
"aiToolsNotice": "更改从下一条消息开始生效。工具开关不是沙箱:已启用的脚本工具仍可执行其他设计操作。",
diff --git a/packages/vue/src/i18n/locales/zh-cn/settings.json b/packages/vue/src/i18n/locales/zh-cn/settings.json
index 9567b8d50..7d7b8425d 100644
--- a/packages/vue/src/i18n/locales/zh-cn/settings.json
+++ b/packages/vue/src/i18n/locales/zh-cn/settings.json
@@ -1,7 +1,6 @@
{
"interfaceScale": "界面大小",
"interfaceScaleDescription": "调整面板、文本和控件的大小,不改变画布缩放。",
- "interfaceScaleDefault": "{scale}(默认)",
"recentFiles": "最近的文件",
"recentFilesDescription": "选择在最近文件列表和“打开最近的文件”菜单中保留的文件数量。",
"recentFilesLimit": "最近文件数量",
@@ -67,7 +66,6 @@
"toolbarMoveDown": "下移",
"toolbarGroupWith": "与{tool}组合",
"toolbarUngroup": "取消组合",
- "toolbarReset": "恢复默认",
"resetToDefault": "恢复默认",
"customizeToolbar": "自定义工具栏…",
"discardChanges": "放弃更改?",
diff --git a/packages/vue/src/i18n/messages/automation.ts b/packages/vue/src/i18n/messages/automation.ts
index 9a0bea8e0..c1d12c2ea 100644
--- a/packages/vue/src/i18n/messages/automation.ts
+++ b/packages/vue/src/i18n/messages/automation.ts
@@ -3,7 +3,6 @@ import { params } from '@nanostores/i18n'
import { i18n } from '#vue/i18n/create'
export const automationMessageDefaults = {
- restoreToolDefaults: 'Restore defaults',
aiToolAccessDescription:
'Choose tools for direct AI model connections. ACP and Pi agents use MCP access instead.',
mcpToolAccessDescription:
diff --git a/packages/vue/src/i18n/messages/settings.ts b/packages/vue/src/i18n/messages/settings.ts
index 9cc05858b..0c84750e5 100644
--- a/packages/vue/src/i18n/messages/settings.ts
+++ b/packages/vue/src/i18n/messages/settings.ts
@@ -6,7 +6,6 @@ export const settingsMessageDefaults = {
appearance: 'Appearance',
interfaceScale: 'Interface size',
interfaceScaleDescription: 'Scale panels, text, and controls without changing canvas zoom.',
- interfaceScaleDefault: params('{scale} (default)'),
animations: 'Animations',
animationsSystem: 'Follow system',
animationsOff: 'Off',
@@ -30,7 +29,6 @@ export const settingsMessageDefaults = {
toolbarMoveDown: 'Move down',
toolbarGroupWith: params('Group with {tool}'),
toolbarUngroup: 'Ungroup',
- toolbarReset: 'Reset to default',
resetToDefault: 'Reset to default',
customizeToolbar: 'Customize toolbar…',
title: 'Settings',
diff --git a/src/AGENTS.md b/src/AGENTS.md
index 5a0c70545..5dc49673d 100644
--- a/src/AGENTS.md
+++ b/src/AGENTS.md
@@ -94,7 +94,8 @@ The supported browser baseline lives in `src/app/shell/support/baseline.ts` and
- Compose Settings sections with `SettingsSection` and its `title`, `description`, `actions`, and default content slots. It owns heading association and internal spacing; `SettingsGroup` owns bordered row grouping. Do not repeat section, header, or spacing markup per feature.
- Settings components own layout, translated copy, confirmation visibility, and emits; small presentation-only computed bindings may stay in components. Workflows, persistence, and credentials: `src/AGENTS.md`.
- `SettingsSaveFeedback` maps domain outcomes (`saved`, `failed`, `partial`) to `AppAlert`. `SettingsLink` owns external-link styling, the icon, and native opening for provider key pages and setup guides; keep arrow glyphs out of translated labels.
-- A section's header-level action (Add, Reset, Restart) goes in its `actions` slot; a link to another settings tab is a `SettingsRow` with an outline `xs` button; status, warning, and error `AppAlert`s come last inside the section they describe, offering only the fix (`src/components/settings/mcp/MCPSettingsPanel.vue`).
+- A setting with a default offers one Reset to default, the `SettingsResetButton` shown only while it differs: `modified` and `reset` on its `SettingsRow`, or on its `SettingsSection` when the section edits one value as a whole (`src/components/settings/toolbar/ToolbarSettingsPanel.vue`, `tests/e2e/settings/reset.spec.ts`). Consent and credential choices have no reset, since resetting would grant on the person's behalf.
+- A section's header-level action (Add, Restart) goes in its `actions` slot; a link to another settings tab is a `SettingsRow` with an outline `xs` button; status, warning, and error `AppAlert`s come last inside the section they describe, offering only the fix (`src/components/settings/mcp/MCPSettingsPanel.vue`).
- An integration section links its guide once, as `common.learnMore` at the end of its description; alerts link only to the fix (Node.js, the desktop app), never to docs. Guide URLs live in `src/constants.ts`, except the unsupported-browser guidance, which stays self-contained (`src/app/shell/support/guidance.ts`).
- Empty lists use `AppPlaceholder`: `size="compact" :fill="false"` for no results or nothing added yet, an icon, description, and action for a feature that still needs setting up (`src/components/assets-panel/AssetsPanel.vue`, `src/components/chat/ChatProviderSetup.vue`).
diff --git a/src/app/ai/tools/preferences.ts b/src/app/ai/tools/preferences.ts
index cb242431c..536ab981d 100644
--- a/src/app/ai/tools/preferences.ts
+++ b/src/app/ai/tools/preferences.ts
@@ -20,11 +20,19 @@ export const aiToolOverrides = useLocalStorage<Record<string, boolean>>(
}
)
+function disabledWith(overrides: Readonly<Record<string, boolean>>): string[] {
+ return configurableAITools
+ .filter((tool) => !isAIToolEnabled(tool.name, overrides))
+ .map((tool) => tool.name)
+}
+
+/** The AI tools that are off when nothing has been changed. */
+export function defaultDisabledAITools(): string[] {
+ return disabledWith({})
+}
+
export const disabledAITools = computed({
- get: () =>
- configurableAITools
- .filter((tool) => !isAIToolEnabled(tool.name, aiToolOverrides.value))
- .map((tool) => tool.name),
+ get: () => disabledWith(aiToolOverrides.value),
set: (names: string[]) => {
const disabled = new Set(names)
aiToolOverrides.value = Object.fromEntries(
diff --git a/src/app/automation/tool-access/settings/use.ts b/src/app/automation/tool-access/settings/use.ts
index 5f6ca222a..850ea7aa5 100644
--- a/src/app/automation/tool-access/settings/use.ts
+++ b/src/app/automation/tool-access/settings/use.ts
@@ -1,7 +1,12 @@
+import { isEqual } from 'es-toolkit'
import { computed, ref } from 'vue'
import { configurableAITools } from '@/app/ai/tools/catalog'
-import { aiToolOverrides, disabledAITools } from '@/app/ai/tools/preferences'
+import {
+ aiToolOverrides,
+ defaultDisabledAITools,
+ disabledAITools
+} from '@/app/ai/tools/preferences'
import { configurableMCPTools, disabledMCPTools } from '@/app/automation/mcp/preferences'
import { openSettingsDialog } from '@/app/settings/dialog'
@@ -43,10 +48,17 @@ export function useToolAccessSettings(target: ToolAccessTarget) {
}
})
+ /** Whether the enabled tools differ from the defaults, which Reset to default puts back. */
+ const modified = computed(() =>
+ target === 'ai'
+ ? !isEqual(disabled.value, defaultDisabledAITools())
+ : disabledMCPTools.value.length > 0
+ )
+
function reset() {
if (target === 'ai') aiToolOverrides.value = {}
else disabledMCPTools.value = []
}
- return { tools, disabled, reset }
+ return { tools, disabled, modified, reset }
}
diff --git a/src/app/editor/fonts/index.ts b/src/app/editor/fonts/index.ts
index 231f6c8c8..e7538c22e 100644
--- a/src/app/editor/fonts/index.ts
+++ b/src/app/editor/fonts/index.ts
@@ -31,7 +31,9 @@ if (typeof navigator !== 'undefined') {
export type FontProviderSettings = Record<WebFontProviderId, boolean>
-export const onlineFontsEnabled = useLocalStorage('op-online-fonts-enabled', true)
+/** Online fonts are on until turned off in Settings. */
+export const DEFAULT_ONLINE_FONTS = true
+export const onlineFontsEnabled = useLocalStorage('op-online-fonts-enabled', DEFAULT_ONLINE_FONTS)
export const fontProviderSettings = useLocalStorage<FontProviderSettings>(
'op-font-providers',
DEFAULT_WEB_FONT_PROVIDER_SETTINGS
diff --git a/src/components/settings/chat/ChatSettingsSection.vue b/src/components/settings/chat/ChatSettingsSection.vue
index c53486577..9b738d6e8 100644
--- a/src/components/settings/chat/ChatSettingsSection.vue
+++ b/src/components/settings/chat/ChatSettingsSection.vue
@@ -5,7 +5,9 @@ import { useI18n } from '@open-pencil/vue/i18n'
import { changePreviewSize, maxAgentSteps, reasoningDisplay } from '@/app/ai/chat/preferences'
import { AGENT_STEP_LIMIT_MIN, AGENT_STEP_LIMIT_MAX } from '@/app/ai/reply/schema'
+import { resolveAgentStepLimit } from '@/app/ai/reply/step-limit'
import { openToolAccessSettings } from '@/app/automation/tool-access/settings/use'
+import { DEFAULT_APP_PREFERENCES } from '@/app/settings/preferences/store'
import SettingsGroup from '@/components/settings/layout/SettingsGroup.vue'
import SettingsRow from '@/components/settings/layout/SettingsRow.vue'
import SettingsSection from '@/components/settings/layout/SettingsSection.vue'
@@ -15,6 +17,8 @@ import AppSelect from '@/components/ui/select/AppSelect.vue'
const { ai, automation, settings } = useI18n()
const stepPresets = [25, 50, 100, 200]
+const defaults = DEFAULT_APP_PREFERENCES.chat
+const defaultSteps = resolveAgentStepLimit(defaults.maxAgentSteps)
const limitMessage = computed(() =>
ai.value.maxAgentStepsRange({ min: AGENT_STEP_LIMIT_MIN, max: AGENT_STEP_LIMIT_MAX })
)
@@ -35,7 +39,12 @@ const previewOptions = computed(() => [
<SettingsSection>
<template #title>{{ ai.chatSettings }}</template>
<SettingsGroup>
- <SettingsRow :label="ai.reasoningDisplay" class="max-sm:flex-col max-sm:items-stretch">
+ <SettingsRow
+ :label="ai.reasoningDisplay"
+ :modified="reasoningDisplay !== defaults.reasoningDisplay"
+ class="max-sm:flex-col max-sm:items-stretch"
+ @reset="reasoningDisplay = defaults.reasoningDisplay"
+ >
<AppSelect
v-model="reasoningDisplay"
:label="ai.reasoningDisplay"
@@ -46,7 +55,9 @@ const previewOptions = computed(() => [
<SettingsRow
:label="ai.changePreview"
:description="ai.changePreviewHint"
+ :modified="changePreviewSize !== defaults.changePreviewSize"
class="max-sm:flex-col max-sm:items-stretch"
+ @reset="changePreviewSize = defaults.changePreviewSize"
>
<AppSelect
v-model="changePreviewSize"
@@ -58,7 +69,9 @@ const previewOptions = computed(() => [
<SettingsRow
:label="ai.maxAgentSteps"
:description="ai.maxAgentStepsHint"
+ :modified="maxAgentSteps !== defaultSteps"
class="max-sm:flex-col max-sm:items-stretch"
+ @reset="maxAgentSteps = defaultSteps"
>
<PresetNumberField
v-model:number="maxAgentSteps"
diff --git a/src/components/settings/fonts/FontSettingsPanel.vue b/src/components/settings/fonts/FontSettingsPanel.vue
index 13c438824..57fa821e0 100644
--- a/src/components/settings/fonts/FontSettingsPanel.vue
+++ b/src/components/settings/fonts/FontSettingsPanel.vue
@@ -1,10 +1,15 @@
<script setup lang="ts">
import { computed, onMounted } from 'vue'
-import { WEB_FONT_PROVIDER_IDS, WEB_FONT_PROVIDER_LABELS } from '@open-pencil/core/text'
+import {
+ DEFAULT_WEB_FONT_PROVIDER_SETTINGS,
+ WEB_FONT_PROVIDER_IDS,
+ WEB_FONT_PROVIDER_LABELS
+} from '@open-pencil/core/text'
import type { WebFontProviderId } from '@open-pencil/core/text'
import { useI18n } from '@open-pencil/vue/i18n'
+import { DEFAULT_ONLINE_FONTS } from '@/app/editor/fonts'
import { useFontSettings } from '@/app/settings/fonts/use'
import { isTauri } from '@/app/tauri/env'
import SettingsGroup from '@/components/settings/layout/SettingsGroup.vue'
@@ -82,7 +87,13 @@ onMounted(() => {
<template #title>{{ fonts.onlineFontProviders }}</template>
<template #description>{{ fonts.downloadMissingWebFonts }}</template>
<SettingsGroup>
- <SettingsRow as="label" :label="fonts.onlineFonts">
+ <SettingsRow
+ as="label"
+ :label="fonts.onlineFonts"
+ :modified="online !== DEFAULT_ONLINE_FONTS"
+ :reset-disabled="busyAction !== null"
+ @reset="setOnlineFontsEnabled(DEFAULT_ONLINE_FONTS)"
+ >
<AppSwitch
:model-value="online"
:label="fonts.onlineFonts"
@@ -95,6 +106,9 @@ onMounted(() => {
:key="provider"
as="label"
:label="WEB_FONT_PROVIDER_LABELS[provider]"
+ :modified="providerEnabled(provider) !== DEFAULT_WEB_FONT_PROVIDER_SETTINGS[provider]"
+ :reset-disabled="busyAction !== null || !online"
+ @reset="setFontProviderEnabled(provider, DEFAULT_WEB_FONT_PROVIDER_SETTINGS[provider])"
>
<AppSwitch
:model-value="providerEnabled(provider)"
diff --git a/src/components/settings/general/GeneralSettingsPanel.vue b/src/components/settings/general/GeneralSettingsPanel.vue
index 72c460638..b6fd7d09e 100644
--- a/src/components/settings/general/GeneralSettingsPanel.vue
+++ b/src/components/settings/general/GeneralSettingsPanel.vue
@@ -23,7 +23,6 @@ import CredentialSettingsSection from '@/components/settings/credentials/Credent
import AccentColorPicker from '@/components/settings/general/AccentColorPicker.vue'
import CollaborationNameSection from '@/components/settings/general/CollaborationNameSection.vue'
import SettingsGroup from '@/components/settings/layout/SettingsGroup.vue'
-import SettingsResetButton from '@/components/settings/layout/SettingsResetButton.vue'
import SettingsRow from '@/components/settings/layout/SettingsRow.vue'
import SettingsSection from '@/components/settings/layout/SettingsSection.vue'
import PresetNumberField from '@/components/ui/input/PresetNumberField.vue'
@@ -64,13 +63,7 @@ const preserveUnsavedWork = computed({
const defaultInterfaceScale = DEFAULT_APP_PREFERENCES.appearance.interfaceScale
const interfaceScaleOptions = computed(() => {
const format = new Intl.NumberFormat(locale.value, { style: 'percent' })
- return INTERFACE_SCALES.map((value) => ({
- value,
- label:
- value === defaultInterfaceScale
- ? settings.value.interfaceScaleDefault({ scale: format.format(value / 100) })
- : format.format(value / 100)
- }))
+ return INTERFACE_SCALES.map((value) => ({ value, label: format.format(value / 100) }))
})
</script>
@@ -127,16 +120,14 @@ const interfaceScaleOptions = computed(() => {
:ui="selectUI"
/>
</SettingsRow>
- <div class="flex flex-wrap items-center justify-between gap-x-4 gap-y-2 px-3 py-2.5">
- <span class="text-xs font-medium text-surface">{{ settings.accentColor }}</span>
- <span class="flex items-center gap-1">
- <SettingsResetButton
- v-if="accentModified"
- @reset="updateAccentPreference({ ...DEFAULT_ACCENT })"
- />
- <AccentColorPicker />
- </span>
- </div>
+ <SettingsRow
+ :label="settings.accentColor"
+ :modified="accentModified"
+ class="flex-wrap gap-y-2"
+ @reset="updateAccentPreference({ ...DEFAULT_ACCENT })"
+ >
+ <AccentColorPicker />
+ </SettingsRow>
<SettingsRow
as="label"
:label="settings.animations"
diff --git a/src/components/settings/layout/SettingsResetButton.vue b/src/components/settings/layout/SettingsResetButton.vue
index 4792f05f2..23c7de892 100644
--- a/src/components/settings/layout/SettingsResetButton.vue
+++ b/src/components/settings/layout/SettingsResetButton.vue
@@ -7,6 +7,10 @@ import IconButton from '@/components/ui/button/IconButton.vue'
* Puts one setting back to its default. A row shows it only while its value differs from the
* default, as VS Code's settings do, so an unchanged page shows none.
*/
+const { disabled = false } = defineProps<{
+ /** The setting can't change right now, as when its control is disabled. */
+ disabled?: boolean
+}>()
const emit = defineEmits<{ reset: [] }>()
const settings = useSettingsMessages()
</script>
@@ -15,6 +19,7 @@ const settings = useSettingsMessages()
<IconButton
:label="settings.resetToDefault"
size="sm"
+ :disabled="disabled"
data-settings-reset
@click.prevent="emit('reset')"
>
diff --git a/src/components/settings/layout/SettingsRow.vue b/src/components/settings/layout/SettingsRow.vue
index 8b62c012b..21cdd2081 100644
--- a/src/components/settings/layout/SettingsRow.vue
+++ b/src/components/settings/layout/SettingsRow.vue
@@ -12,13 +12,16 @@ const {
label,
description,
as = 'div',
- modified = false
+ modified = false,
+ resetDisabled = false
} = defineProps<{
label?: string
description?: string
as?: 'div' | 'label'
/** The setting differs from its default. */
modified?: boolean
+ /** The setting can't change right now; pass what disables its control. */
+ resetDisabled?: boolean
}>()
const emit = defineEmits<{ reset: [] }>()
</script>
@@ -39,7 +42,7 @@ const emit = defineEmits<{ reset: [] }>()
<slot name="description" />
</span>
<span class="flex shrink-0 items-center gap-1">
- <SettingsResetButton v-if="modified" @reset="emit('reset')" />
+ <SettingsResetButton v-if="modified" :disabled="resetDisabled" @reset="emit('reset')" />
<slot />
</span>
</Primitive>
diff --git a/src/components/settings/layout/SettingsSection.vue b/src/components/settings/layout/SettingsSection.vue
index 9a348a02c..346b36084 100644
--- a/src/components/settings/layout/SettingsSection.vue
+++ b/src/components/settings/layout/SettingsSection.vue
@@ -1,6 +1,17 @@
<script setup lang="ts">
import { useId } from 'vue'
+import SettingsResetButton from './SettingsResetButton.vue'
+
+/**
+ * A titled block of settings. A setting edited as a whole, such as the toolbar's layout, is
+ * `modified` on its section, which then offers the same Reset to default as a changed row does.
+ */
+const { modified = false } = defineProps<{
+ /** The section's setting differs from its default. */
+ modified?: boolean
+}>()
+const emit = defineEmits<{ reset: [] }>()
const headingId = useId()
</script>
@@ -13,7 +24,10 @@ const headingId = useId()
<slot name="description" />
</p>
</div>
- <div v-if="$slots.actions" class="shrink-0"><slot name="actions" /></div>
+ <div v-if="modified || $slots.actions" class="flex shrink-0 items-center gap-1">
+ <SettingsResetButton v-if="modified" @reset="emit('reset')" />
+ <slot name="actions" />
+ </div>
</div>
<slot />
</section>
diff --git a/src/components/settings/notifications/NotificationSettingsSection.vue b/src/components/settings/notifications/NotificationSettingsSection.vue
index a7d97fc1f..69f4b4d32 100644
--- a/src/components/settings/notifications/NotificationSettingsSection.vue
+++ b/src/components/settings/notifications/NotificationSettingsSection.vue
@@ -2,6 +2,7 @@
import { IS_TAURI } from '@open-pencil/core/constants'
import { useI18n } from '@open-pencil/vue/i18n'
+import { DEFAULT_APP_PREFERENCES } from '@/app/settings/preferences/store'
import {
browserNotificationPermission,
requestBrowserNotificationPermission
@@ -18,6 +19,7 @@ const { ai, settings } = useI18n()
const needsInput = notificationPreference('agentNeedsInput')
const finished = notificationPreference('agentFinished')
const failed = notificationPreference('agentFailed')
+const defaults = DEFAULT_APP_PREFERENCES.notifications
</script>
<template>
@@ -40,13 +42,26 @@ const failed = notificationPreference('agentFailed')
>{{ ai.notificationsAllow }}</AppButton
>
</SettingsRow>
- <SettingsRow :label="ai.notifyNeedsInput" :description="ai.notifyNeedsInputHint">
+ <SettingsRow
+ :label="ai.notifyNeedsInput"
+ :description="ai.notifyNeedsInputHint"
+ :modified="needsInput !== defaults.agentNeedsInput"
+ @reset="needsInput = defaults.agentNeedsInput"
+ >
<AppSwitch v-model="needsInput" :label="ai.notifyNeedsInput" />
</SettingsRow>
- <SettingsRow :label="ai.notifyFinished">
+ <SettingsRow
+ :label="ai.notifyFinished"
+ :modified="finished !== defaults.agentFinished"
+ @reset="finished = defaults.agentFinished"
+ >
<AppSwitch v-model="finished" :label="ai.notifyFinished" />
</SettingsRow>
- <SettingsRow :label="ai.notifyFailed">
+ <SettingsRow
+ :label="ai.notifyFailed"
+ :modified="failed !== defaults.agentFailed"
+ @reset="failed = defaults.agentFailed"
+ >
<AppSwitch v-model="failed" :label="ai.notifyFailed" />
</SettingsRow>
</SettingsGroup>
diff --git a/src/components/settings/tool-access/ToolAccessSettingsPanel.vue b/src/components/settings/tool-access/ToolAccessSettingsPanel.vue
index 55517ccd6..99203489a 100644
--- a/src/components/settings/tool-access/ToolAccessSettingsPanel.vue
+++ b/src/components/settings/tool-access/ToolAccessSettingsPanel.vue
@@ -12,6 +12,7 @@ import CapabilityList from '@/components/settings/capability/CapabilityList.vue'
import CapabilityPage from '@/components/settings/capability/CapabilityPage.vue'
import { filterCapabilities } from '@/components/settings/capability/filter'
import type { CapabilityFilter, CapabilityGroup } from '@/components/settings/capability/types'
+import SettingsResetButton from '@/components/settings/layout/SettingsResetButton.vue'
import AppButton from '@/components/ui/button/AppButton.vue'
import AppPlaceholder from '@/components/ui/feedback/AppPlaceholder.vue'
@@ -22,7 +23,7 @@ import AppPlaceholder from '@/components/ui/feedback/AppPlaceholder.vue'
const { target } = defineProps<{ target: ToolAccessTarget }>()
const automation = useAutomationMessages()
-const { tools, disabled, reset } = useToolAccessSettings(target)
+const { tools, disabled, modified, reset } = useToolAccessSettings(target)
const { search, groups, expanded, setGroupEnabled, isEnabled, setToolEnabled } = useToolAccess(
tools,
disabled
@@ -69,10 +70,8 @@ function setExpanded(key: string, open: boolean) {
<template #description>{{
target === 'ai' ? automation.aiToolAccessDescription : automation.mcpToolAccessDescription
}}</template>
- <template #tools>
- <AppButton size="sm" variant="outline" @click="reset">{{
- automation.restoreToolDefaults
- }}</AppButton>
+ <template v-if="modified" #tools>
+ <SettingsResetButton @reset="reset" />
</template>
<AppPlaceholder
v-if="!hasMatches"
diff --git a/src/components/settings/toolbar/ToolbarSettingsPanel.vue b/src/components/settings/toolbar/ToolbarSettingsPanel.vue
index 9806af996..364cc5979 100644
--- a/src/components/settings/toolbar/ToolbarSettingsPanel.vue
+++ b/src/components/settings/toolbar/ToolbarSettingsPanel.vue
@@ -1,4 +1,5 @@
<script setup lang="ts">
+import { isEqual } from 'es-toolkit'
import { computed } from 'vue'
import { useI18n } from '@open-pencil/vue/i18n'
@@ -7,7 +8,6 @@ import { DEFAULT_TOOLBAR_LAYOUT } from '@/app/editor/toolbar/layout'
import { appPreferences, updateToolbarLayout } from '@/app/settings/preferences/store'
import SettingsSection from '@/components/settings/layout/SettingsSection.vue'
import ToolbarLayoutEditor from '@/components/settings/toolbar/ToolbarLayoutEditor.vue'
-import AppButton from '@/components/ui/button/AppButton.vue'
const { settings } = useI18n()
@@ -16,6 +16,8 @@ const layout = computed({
set: updateToolbarLayout
})
+const modified = computed(() => !isEqual(layout.value, DEFAULT_TOOLBAR_LAYOUT))
+
function reset() {
updateToolbarLayout(structuredClone(DEFAULT_TOOLBAR_LAYOUT))
}
@@ -23,14 +25,9 @@ function reset() {
<template>
<section class="flex flex-col gap-6" data-test-id="settings-toolbar-panel">
- <SettingsSection>
+ <SettingsSection :modified="modified" @reset="reset">
<template #title>{{ settings.toolbar }}</template>
<template #description>{{ settings.toolbarDescription }}</template>
- <template #actions>
- <AppButton @click="reset">
- {{ settings.toolbarReset }}
- </AppButton>
- </template>
<ToolbarLayoutEditor v-model="layout" />
</SettingsSection>
</section>
diff --git a/tests/e2e/settings/credentials.spec.ts b/tests/e2e/settings/credentials.spec.ts
index 1b73b4980..3c1489dbe 100644
--- a/tests/e2e/settings/credentials.spec.ts
+++ b/tests/e2e/settings/credentials.spec.ts
@@ -149,7 +149,7 @@ test('MCP automation settings filter and persist tool availability', async ({ pa
await page.getByTestId('settings-mcp-tool-access').click()
await expect(createShape).toHaveAttribute('data-state', 'unchecked')
- await page.getByRole('button', { name: 'Restore defaults' }).click()
+ await page.getByRole('button', { name: 'Reset to default' }).click()
await expect(createShape).toHaveAttribute('data-state', 'checked')
})
diff --git a/tests/e2e/settings/interface-scale.webkit.spec.ts b/tests/e2e/settings/interface-scale.webkit.spec.ts
index af8d2f92b..65dfe3c89 100644
--- a/tests/e2e/settings/interface-scale.webkit.spec.ts
+++ b/tests/e2e/settings/interface-scale.webkit.spec.ts
@@ -48,7 +48,7 @@ for (const scale of ['110%', '150%']) {
await page.setViewportSize({ width: 1280, height: 800 })
await page.reload()
await canvas.waitForInit()
- await chooseScale(page, '100% (default)')
+ await chooseScale(page, '100%')
await expect.poll(() => sidebarWidth(page, 'left')).toBeCloseTo(left, 0)
await expect.poll(() => sidebarWidth(page, 'right')).toBeCloseTo(right, 0)
expect(await savedLayout(page)).toBeUndefined()
@@ -94,7 +94,7 @@ for (const side of ['left', 'right'] as const) {
await canvas.waitForInit()
await chooseScale(page, '125%')
await expect.poll(() => sidebarWidth(page, side)).toBeCloseTo(resized, 0)
- await chooseScale(page, '100% (default)')
+ await chooseScale(page, '100%')
await expect.poll(() => sidebarWidth(page, opposite)).toBeCloseTo(originalOpposite, 0)
expect(await savedLayout(page)).toBe(saved)
})
@@ -129,7 +129,7 @@ test('interface size can return to the default', async ({ page }) => {
const canvas = new CanvasHelper(page)
await canvas.waitForInit()
await chooseScale(page, '125%')
- await chooseScale(page, '100% (default)')
+ await chooseScale(page, '100%')
await page.reload()
await canvas.waitForInit()
await expect(page.locator('html')).toHaveAttribute('data-interface-scale', '100')
@@ -187,7 +187,7 @@ test('interface scaling preserves the scrolled layer and partial row offset', as
})
await expect.poll(async () => (await anchor()).id).not.toBeNull()
const before = await anchor()
- for (const scale of ['150%', '125%', '100% (default)']) {
+ for (const scale of ['150%', '125%', '100%']) {
await chooseScale(page, scale)
await expect.poll(async () => (await anchor()).id).toBe(before.id)
await expect.poll(async () => (await anchor()).fraction).toBeCloseTo(before.fraction, 1)
@@ -210,7 +210,7 @@ test('scaling down clamps the layer scroll position at the end of the list', asy
el.scrollTop = el.scrollHeight
})
await expect.poll(() => scroller.evaluate((el) => el.scrollTop)).toBeGreaterThan(1000)
- await chooseScale(page, '100% (default)')
+ await chooseScale(page, '100%')
await expect
.poll(() => scroller.evaluate((el) => el.scrollHeight - el.clientHeight - el.scrollTop))
.toBeLessThan(1)
diff --git a/tests/e2e/settings/tool-access.spec.ts b/tests/e2e/settings/tool-access.spec.ts
index 04ddb5486..d1d0f8550 100644
--- a/tests/e2e/settings/tool-access.spec.ts
+++ b/tests/e2e/settings/tool-access.spec.ts
@@ -41,15 +41,18 @@ for (const width of [1280, 390]) {
await openSection(page, 'Tool access', phone)
await search.fill('create_component')
await expect(create).toHaveAttribute('data-state', 'checked')
- await page.getByRole('button', { name: 'Restore defaults' }).click()
+ await page.getByRole('button', { name: 'Reset to default' }).click()
await expect(create).toHaveAttribute('data-state', 'unchecked')
+ // Back at the defaults, there is nothing left to reset.
+ await expect(page.getByRole('button', { name: 'Reset to default' })).toHaveCount(0)
await page.keyboard.press('Escape')
await openSection(page, 'MCP', phone)
await page.getByTestId('settings-mcp-tool-access').click()
await search.fill('create_component')
await expect(create).toHaveAttribute('data-state', 'unchecked')
- await page.getByRole('button', { name: 'Restore defaults' }).click()
+ await page.getByRole('button', { name: 'Reset to default' }).click()
await expect(create).toHaveAttribute('data-state', 'checked')
+ await expect(page.getByRole('button', { name: 'Reset to default' })).toHaveCount(0)
})
}
diff --git a/tests/e2e/toolbar/customize.spec.ts b/tests/e2e/toolbar/customize.spec.ts
index f1e0f744f..1f1431a33 100644
--- a/tests/e2e/toolbar/customize.spec.ts
+++ b/tests/e2e/toolbar/customize.spec.ts
@@ -66,6 +66,8 @@ test('the toolbar hides, reorders and regroups tools from Settings and keeps the
await page.getByTestId('toolbar').click({ button: 'right' })
await page.getByRole('menuitem', { name: 'Customize toolbar…' }).click()
await page.getByRole('button', { name: 'Reset to default' }).click()
+ // Back at the default layout, the section has nothing left to reset.
+ await expect(page.getByRole('button', { name: 'Reset to default' })).toHaveCount(0)
await page.getByTestId('app-settings-done').click()
await expect(page.getByTestId(toolbarToolTestId('PEN'))).toBeVisible()
canvas.assertNoErrors()