@surfishs/dsh-prompt-enhance 0.0.6 → 0.0.7

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/lib/client.js CHANGED
@@ -1106,6 +1106,7 @@ var zh = {
1106
1106
  "settings.saved": "\u5DF2\u4FDD\u5B58",
1107
1107
  "settings.saveFailed": "\u672C\u90E8\u7F72\u6CA1\u6709\u63A5\u53D7\u8FD9\u4E9B\u503C\uFF0C\u5DF2\u4FDD\u7559\u4F9B\u4F60\u4FEE\u6539\u3002",
1108
1108
  "settings.saveFailedShort": "\u4FDD\u5B58\u5931\u8D25",
1109
+ "settings.advanced": "\u9AD8\u7EA7\u8BBE\u7F6E",
1109
1110
  "settings.readOnly": "\u672C\u90E8\u7F72\u7684\u8BBE\u7F6E\u4E3A\u53EA\u8BFB\u3002",
1110
1111
  "settings.unavailable": "\u8BE5\u63D2\u4EF6\u5F53\u524D\u672A\u52A0\u8F7D\uFF0C\u6682\u65F6\u65E0\u6CD5\u914D\u7F6E\u3002",
1111
1112
  "settings.reset": "\u6062\u590D\u9ED8\u8BA4",
@@ -1246,6 +1247,7 @@ var en = {
1246
1247
  "settings.saved": "Saved",
1247
1248
  "settings.saveFailed": "The deployment did not accept these values; they were left for you to correct.",
1248
1249
  "settings.saveFailedShort": "Save failed",
1250
+ "settings.advanced": "Advanced",
1249
1251
  "settings.readOnly": "This deployment stores settings read-only.",
1250
1252
  "settings.unavailable": "This plugin is not loaded, so it cannot be configured right now.",
1251
1253
  "settings.reset": "Reset to default",
@@ -1586,6 +1588,58 @@ var CSS = `
1586
1588
  text-align: center;
1587
1589
  white-space: nowrap;
1588
1590
  }
1591
+ .dsh-pe-advanced {
1592
+ margin-top: 12px;
1593
+ border-top: 1px solid var(--dsw-alias-border-l3, rgba(128, 128, 128, 0.22));
1594
+ }
1595
+ .dsh-pe-advanced > summary {
1596
+ display: flex;
1597
+ align-items: center;
1598
+ gap: 8px;
1599
+ min-height: 40px;
1600
+ padding: 0 4px;
1601
+ list-style: none;
1602
+ font-size: 13px;
1603
+ font-weight: 500;
1604
+ color: var(--dsw-alias-label-secondary, inherit);
1605
+ cursor: pointer;
1606
+ user-select: none;
1607
+ }
1608
+ .dsh-pe-advanced > summary::-webkit-details-marker { display: none; }
1609
+ .dsh-pe-advanced > summary::marker { content: ''; }
1610
+ .dsh-pe-advanced > summary::before {
1611
+ content: '';
1612
+ flex: none;
1613
+ width: 0;
1614
+ height: 0;
1615
+ border-top: 4px solid transparent;
1616
+ border-bottom: 4px solid transparent;
1617
+ border-left: 5px solid currentColor;
1618
+ transition: transform 120ms ease;
1619
+ }
1620
+ .dsh-pe-advanced[open] > summary::before { transform: rotate(90deg); }
1621
+ .dsh-pe-advanced > summary:hover {
1622
+ color: var(--dsw-alias-label-primary, inherit);
1623
+ background: rgba(127, 127, 127, 0.08);
1624
+ border-radius: 6px;
1625
+ }
1626
+ .dsh-pe-advanced > summary:focus-visible {
1627
+ outline: 2px solid var(--dsw-alias-state-business-primary, #4f8cff);
1628
+ outline-offset: -2px;
1629
+ border-radius: 6px;
1630
+ }
1631
+ .dsh-pe-advanced[open] > summary { margin-bottom: 4px; }
1632
+ .dsh-pe-advanced + .dsh-pe-form-footer { margin-top: 0; }
1633
+ .dsh-pe-chip-reset:hover:not(:disabled),
1634
+ .dsh-pe-chip-refresh:hover:not(:disabled) {
1635
+ --pe-chip-bg: var(--dsw-alias-interactive-bg-hover, rgba(127, 127, 127, 0.18));
1636
+ --pe-chip-color: var(--dsw-alias-label-primary, inherit);
1637
+ }
1638
+ .dsh-pe-chip-reset:focus-visible,
1639
+ .dsh-pe-chip-refresh:focus-visible {
1640
+ outline: 2px solid var(--dsw-alias-state-business-primary, #4f8cff);
1641
+ outline-offset: 2px;
1642
+ }
1589
1643
  .dsh-pe-form-footer {
1590
1644
  display: flex;
1591
1645
  justify-content: flex-end;
@@ -2071,25 +2125,28 @@ var STRATEGY_OPTIONS = [
2071
2125
  { value: "replace-default", label: "settings.strategy.replace" },
2072
2126
  { value: "extend-default", label: "settings.strategy.extend" }
2073
2127
  ];
2074
- var ROWS = [
2128
+ var BASIC_ROWS = [
2075
2129
  { key: "enabled", kind: "boolean", label: "settings.row.enabled.label", hint: "settings.row.enabled.hint" },
2076
- { key: "contextAware", kind: "boolean", label: "settings.row.contextAware.label", hint: "settings.row.contextAware.hint" },
2077
- { key: "streaming", kind: "boolean", label: "settings.row.streaming.label", hint: "settings.row.streaming.hint" },
2078
2130
  { key: "provider", kind: "provider", label: "settings.row.provider.label", hint: "settings.row.provider.hint" },
2079
2131
  { key: "model", kind: "model", label: "settings.row.model.label", hint: "settings.row.model.hint" },
2080
2132
  { key: "reasoningEffort", kind: "reasoning", label: "settings.row.reasoningEffort.label", hint: "settings.row.reasoningEffort.hint" },
2081
2133
  { key: "temperature", kind: "number", label: "settings.row.temperature.label", hint: "settings.row.temperature.hint" },
2082
- { key: "maxOutputTokens", kind: "number", label: "settings.row.maxOutputTokens.label", hint: "settings.row.maxOutputTokens.hint" },
2134
+ { key: "contextAware", kind: "boolean", label: "settings.row.contextAware.label", hint: "settings.row.contextAware.hint" },
2135
+ { key: "streaming", kind: "boolean", label: "settings.row.streaming.label", hint: "settings.row.streaming.hint" },
2136
+ { key: "systemPrompt", kind: "text", label: "settings.row.systemPrompt.label", hint: "settings.row.systemPrompt.hint", placeholder: "settings.row.systemPrompt.placeholder" },
2137
+ { key: "shortcut", kind: "text", label: "settings.row.shortcut.label", hint: "settings.row.shortcut.hint", placeholder: "settings.row.shortcut.placeholder" }
2138
+ ];
2139
+ var ADVANCED_ROWS = [
2140
+ { key: "strategyMode", kind: "strategy", label: "settings.row.strategyMode.label", hint: "settings.row.strategyMode.hint" },
2083
2141
  { key: "maxInputChars", kind: "number", label: "settings.row.maxInputChars.label", hint: "settings.row.maxInputChars.hint" },
2142
+ { key: "maxOutputTokens", kind: "number", label: "settings.row.maxOutputTokens.label", hint: "settings.row.maxOutputTokens.hint" },
2084
2143
  { key: "timeoutMs", kind: "number", label: "settings.row.timeoutMs.label", hint: "settings.row.timeoutMs.hint" },
2085
- { key: "strategyMode", kind: "strategy", label: "settings.row.strategyMode.label", hint: "settings.row.strategyMode.hint" },
2086
- { key: "systemPrompt", kind: "text", label: "settings.row.systemPrompt.label", hint: "settings.row.systemPrompt.hint", placeholder: "settings.row.systemPrompt.placeholder" },
2087
2144
  { key: "contextMaxMessages", kind: "number", label: "settings.row.contextMaxMessages.label", hint: "settings.row.contextMaxMessages.hint" },
2088
2145
  { key: "contextMaxChars", kind: "number", label: "settings.row.contextMaxChars.label", hint: "settings.row.contextMaxChars.hint" },
2089
2146
  { key: "maxConcurrent", kind: "number", label: "settings.row.maxConcurrent.label", hint: "settings.row.maxConcurrent.hint" },
2090
- { key: "rateLimitPerMinute", kind: "number", label: "settings.row.rateLimitPerMinute.label", hint: "settings.row.rateLimitPerMinute.hint" },
2091
- { key: "shortcut", kind: "text", label: "settings.row.shortcut.label", hint: "settings.row.shortcut.hint", placeholder: "settings.row.shortcut.placeholder" }
2147
+ { key: "rateLimitPerMinute", kind: "number", label: "settings.row.rateLimitPerMinute.label", hint: "settings.row.rateLimitPerMinute.hint" }
2092
2148
  ];
2149
+ var ROWS = [...BASIC_ROWS, ...ADVANCED_ROWS];
2093
2150
  function descriptorOf(row) {
2094
2151
  switch (row.kind) {
2095
2152
  case "number":
@@ -2129,6 +2186,7 @@ function sectionCopy(t, chinese) {
2129
2186
  save: t("settings.save"),
2130
2187
  saving: t("settings.saving"),
2131
2188
  saved: t("settings.saved"),
2189
+ advanced: t("settings.advanced"),
2132
2190
  reset: t("settings.reset"),
2133
2191
  invalidNumber: t("settings.invalidNumber")
2134
2192
  },
@@ -2149,6 +2207,7 @@ function pageCopy(t) {
2149
2207
  save: t("settings.save"),
2150
2208
  saving: t("settings.saving"),
2151
2209
  saved: t("settings.saved"),
2210
+ advanced: t("settings.advanced"),
2152
2211
  reset: t("settings.reset"),
2153
2212
  invalidNumber: t("settings.invalidNumber")
2154
2213
  },
@@ -2187,12 +2246,12 @@ var CHIP_STYLE = {
2187
2246
  padding: "1px 8px",
2188
2247
  border: "none",
2189
2248
  borderRadius: 999,
2190
- background: "var(--dsw-alias-bg-module-platform, rgba(128, 128, 128, 0.12))",
2249
+ background: "var(--pe-chip-bg, var(--dsw-alias-bg-module-platform, rgba(128, 128, 128, 0.12)))",
2191
2250
  fontFamily: "inherit",
2192
2251
  fontSize: 11,
2193
2252
  fontWeight: 500,
2194
2253
  lineHeight: "17px",
2195
- color: "var(--dsw-alias-label-secondary, inherit)",
2254
+ color: "var(--pe-chip-color, var(--dsw-alias-label-secondary, inherit))",
2196
2255
  textDecoration: "underline",
2197
2256
  textUnderlineOffset: 2,
2198
2257
  cursor: "pointer"
@@ -2237,7 +2296,7 @@ var REPOSITORY_URL = "https://github.com/surfishs/dsh-prompt-enhance";
2237
2296
  var NPM_URL = "https://www.npmjs.com/package/@surfishs/dsh-prompt-enhance";
2238
2297
  var GITHUB_MARK = "M8 0C3.58 0 0 3.58 0 8c0 3.54 2.29 6.53 5.47 7.59.4.07.55-.17.55-.38 0-.19-.01-.82-.01-1.49-2.01.37-2.53-.49-2.69-.94-.09-.23-.48-.94-.82-1.13-.28-.15-.68-.52-.01-.53.63-.01 1.08.58 1.23.82.72 1.21 1.87.87 2.33.66.07-.52.28-.87.51-1.07-1.78-.2-3.64-.89-3.64-3.95 0-.87.31-1.59.82-2.15-.08-.2-.36-1.02.08-2.12 0 0 .67-.21 2.2.82a7.6 7.6 0 0 1 2-.27c.68 0 1.36.09 2 .27 1.53-1.04 2.2-.82 2.2-.82.44 1.1.16 1.92.08 2.12.51.56.82 1.27.82 2.15 0 3.07-1.87 3.75-3.65 3.95.29.25.54.73.54 1.48 0 1.07-.01 1.93-.01 2.2 0 .21.15.46.55.38A8.01 8.01 0 0 0 16 8c0-4.42-3.58-8-8-8z";
2239
2298
  var NPM_MARK = "M1.763 0C.786 0 0 .786 0 1.763v20.474C0 23.214.786 24 1.763 24h20.474c.977 0 1.763-.786 1.763-1.763V1.763C24 .786 23.214 0 22.237 0zM5.13 5.323l13.837.019-.009 13.836h-3.464l.01-10.382h-3.456L12.04 19.17H5.113z";
2240
- var PLUGIN_VERSION = true ? "0.0.6" : "0.0.0";
2299
+ var PLUGIN_VERSION = true ? "0.0.7" : "0.0.0";
2241
2300
  var HEADER_STYLE = { display: "flex", flexDirection: "column", gap: 12, padding: "2px 0" };
2242
2301
  var HEADER_ROW_STYLE = { display: "flex", alignItems: "center", gap: 10, flexWrap: "wrap" };
2243
2302
  var HEADER_TITLE_STYLE = {
@@ -2312,6 +2371,16 @@ function viewOf(snapshot, key) {
2312
2371
  invalid: field.invalid === true
2313
2372
  };
2314
2373
  }
2374
+ function defaultTextOf(key) {
2375
+ const descriptor = FIELD_SPECS.find((item) => item.field === key);
2376
+ const fallback = DEFAULT_VALUES[key];
2377
+ if (descriptor === void 0 || fallback === void 0) return "";
2378
+ try {
2379
+ return descriptor.format(fallback);
2380
+ } catch {
2381
+ return "";
2382
+ }
2383
+ }
2315
2384
  function atDefaultValue(key, text) {
2316
2385
  const fallback = DEFAULT_VALUES[key];
2317
2386
  if (fallback === void 0) return text.trim() === "";
@@ -2327,6 +2396,7 @@ function OverrideActions(props) {
2327
2396
  "button",
2328
2397
  {
2329
2398
  type: "button",
2399
+ className: "dsh-pe-chip-reset",
2330
2400
  style: { ...RESET_STYLE, ...props.disabled ? { opacity: 0.5, cursor: "default" } : {} },
2331
2401
  disabled: props.disabled,
2332
2402
  onClick: props.onReset,
@@ -2461,6 +2531,7 @@ function ReasoningRow(props) {
2461
2531
  "button",
2462
2532
  {
2463
2533
  type: "button",
2534
+ className: "dsh-pe-chip-refresh",
2464
2535
  style: { ...REFRESH_STYLE, opacity: props.disabled || refreshing ? 0.5 : 1 },
2465
2536
  disabled: props.disabled || refreshing,
2466
2537
  onClick: refresh,
@@ -2715,6 +2786,29 @@ function SettingsRows(props) {
2715
2786
  savedTimer.current = void 0;
2716
2787
  }, 2e3);
2717
2788
  };
2789
+ const runReset = async (key, fallback) => {
2790
+ if (props.writeField === void 0) return;
2791
+ const ticket = ++sequence.current;
2792
+ setSaveState("saving");
2793
+ const result = await props.writeField(key, "");
2794
+ if (ticket !== sequence.current) return;
2795
+ if (result === "failed") {
2796
+ setSaveState("failed");
2797
+ return;
2798
+ }
2799
+ if (result === "invalid") {
2800
+ setSaveState("idle");
2801
+ return;
2802
+ }
2803
+ savedValues.current.set(key, fallback);
2804
+ markSaved();
2805
+ };
2806
+ const resetAndSave = (key) => {
2807
+ props.resetField(key);
2808
+ const fallback = defaultTextOf(key);
2809
+ savedValues.current.set(key, fallback);
2810
+ void runReset(key, fallback);
2811
+ };
2718
2812
  const manualSave = async () => {
2719
2813
  if (props.writeField === void 0) {
2720
2814
  props.save?.();
@@ -2775,26 +2869,31 @@ function SettingsRows(props) {
2775
2869
  if (savedTimer.current !== void 0) clearTimeout(savedTimer.current);
2776
2870
  }, []);
2777
2871
  const statusText = props.state.writable === false ? props.copy.labels.readOnly : saveState === "saving" ? props.copy.labels.saving : saveState === "saved" ? props.copy.labels.saved : saveState === "failed" ? props.copy.labels.saveFailedShort : "";
2872
+ const renderRow = (row, index) => {
2873
+ const raw = viewOf(props.state, row.key);
2874
+ const view = raw.overridden && atDefaultValue(row.key, raw.text) ? { ...raw, overridden: false } : raw;
2875
+ return /* @__PURE__ */ (0, import_jsx_runtime7.jsx)("div", { style: index === 0 ? void 0 : SEPARATOR_STYLE, children: /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(
2876
+ SettingsRow,
2877
+ {
2878
+ row,
2879
+ copy: props.copy,
2880
+ view,
2881
+ disabled: !props.state.writable,
2882
+ reasoningPair: { provider, model },
2883
+ routing,
2884
+ providerValue: provider,
2885
+ onEdit: (text) => onEdit(row.key, text),
2886
+ onReset: () => resetAndSave(row.key),
2887
+ onCommit: () => flushField(row.key, viewOf(props.state, row.key).text)
2888
+ }
2889
+ ) }, row.key);
2890
+ };
2778
2891
  return /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)("div", { className: "dsh-pe-form", children: [
2779
- ROWS.map((row, index) => {
2780
- const raw = viewOf(props.state, row.key);
2781
- const view = raw.overridden && atDefaultValue(row.key, raw.text) ? { ...raw, overridden: false } : raw;
2782
- return /* @__PURE__ */ (0, import_jsx_runtime7.jsx)("div", { style: index === 0 ? void 0 : SEPARATOR_STYLE, children: /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(
2783
- SettingsRow,
2784
- {
2785
- row,
2786
- copy: props.copy,
2787
- view,
2788
- disabled: !props.state.writable,
2789
- reasoningPair: { provider, model },
2790
- routing,
2791
- providerValue: provider,
2792
- onEdit: (text) => onEdit(row.key, text),
2793
- onReset: () => props.resetField(row.key),
2794
- onCommit: () => flushField(row.key, viewOf(props.state, row.key).text)
2795
- }
2796
- ) }, row.key);
2797
- }),
2892
+ BASIC_ROWS.map(renderRow),
2893
+ /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)("details", { className: "dsh-pe-advanced", children: [
2894
+ /* @__PURE__ */ (0, import_jsx_runtime7.jsx)("summary", { children: props.copy.labels.advanced }),
2895
+ ADVANCED_ROWS.map(renderRow)
2896
+ ] }),
2798
2897
  /* @__PURE__ */ (0, import_jsx_runtime7.jsx)("div", { className: "dsh-pe-form-footer", children: /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)("div", { className: "dsh-pe-save-group", children: [
2799
2898
  statusText === "" ? null : /* @__PURE__ */ (0, import_jsx_runtime7.jsx)("span", { className: "dsh-pe-save-status", role: "status", "aria-live": "polite", children: statusText }),
2800
2899
  /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@surfishs/dsh-prompt-enhance",
3
3
  "description": "Prompt enhancement for the dsh web GUI: rewrite the composer draft into a well-structured prompt through the harness LLM service, preview the before/after, then fill back, copy, or undo. Original draft is always preserved.",
4
- "version": "0.0.6",
4
+ "version": "0.0.7",
5
5
  "author": "surfishs",
6
6
  "type": "module",
7
7
  "engines": {
@@ -71,6 +71,7 @@ export const zh = {
71
71
  'settings.saved': '已保存',
72
72
  'settings.saveFailed': '本部署没有接受这些值,已保留供你修改。',
73
73
  'settings.saveFailedShort': '保存失败',
74
+ 'settings.advanced': '高级设置',
74
75
  'settings.readOnly': '本部署的设置为只读。',
75
76
  'settings.unavailable': '该插件当前未加载,暂时无法配置。',
76
77
  'settings.reset': '恢复默认',
@@ -216,6 +217,7 @@ export const en: Record<PromptEnhanceKey, string> = {
216
217
  'settings.saved': 'Saved',
217
218
  'settings.saveFailed': 'The deployment did not accept these values; they were left for you to correct.',
218
219
  'settings.saveFailedShort': 'Save failed',
220
+ 'settings.advanced': 'Advanced',
219
221
  'settings.readOnly': 'This deployment stores settings read-only.',
220
222
  'settings.unavailable': 'This plugin is not loaded, so it cannot be configured right now.',
221
223
  'settings.reset': 'Reset to default',
@@ -162,26 +162,33 @@ interface Row {
162
162
  * display/context switches first, then routing and generation, then the
163
163
  * context window, then the host-side resource caps, and the shortcut last.
164
164
  */
165
- const ROWS: readonly Row[] = [
165
+ const BASIC_ROWS: readonly Row[] = [
166
166
  { key: 'enabled', kind: 'boolean', label: 'settings.row.enabled.label', hint: 'settings.row.enabled.hint' },
167
- { key: 'contextAware', kind: 'boolean', label: 'settings.row.contextAware.label', hint: 'settings.row.contextAware.hint' },
168
- { key: 'streaming', kind: 'boolean', label: 'settings.row.streaming.label', hint: 'settings.row.streaming.hint' },
169
167
  { key: 'provider', kind: 'provider', label: 'settings.row.provider.label', hint: 'settings.row.provider.hint' },
170
168
  { key: 'model', kind: 'model', label: 'settings.row.model.label', hint: 'settings.row.model.hint' },
171
169
  { key: 'reasoningEffort', kind: 'reasoning', label: 'settings.row.reasoningEffort.label', hint: 'settings.row.reasoningEffort.hint' },
172
170
  { key: 'temperature', kind: 'number', label: 'settings.row.temperature.label', hint: 'settings.row.temperature.hint' },
173
- { key: 'maxOutputTokens', kind: 'number', label: 'settings.row.maxOutputTokens.label', hint: 'settings.row.maxOutputTokens.hint' },
171
+ { key: 'contextAware', kind: 'boolean', label: 'settings.row.contextAware.label', hint: 'settings.row.contextAware.hint' },
172
+ { key: 'streaming', kind: 'boolean', label: 'settings.row.streaming.label', hint: 'settings.row.streaming.hint' },
173
+ { key: 'systemPrompt', kind: 'text', label: 'settings.row.systemPrompt.label', hint: 'settings.row.systemPrompt.hint', placeholder: 'settings.row.systemPrompt.placeholder' },
174
+ { key: 'shortcut', kind: 'text', label: 'settings.row.shortcut.label', hint: 'settings.row.shortcut.hint', placeholder: 'settings.row.shortcut.placeholder' },
175
+ ]
176
+
177
+ /** Tuning and deployment limits, hidden behind the Advanced disclosure by default. */
178
+ const ADVANCED_ROWS: readonly Row[] = [
179
+ { key: 'strategyMode', kind: 'strategy', label: 'settings.row.strategyMode.label', hint: 'settings.row.strategyMode.hint' },
174
180
  { key: 'maxInputChars', kind: 'number', label: 'settings.row.maxInputChars.label', hint: 'settings.row.maxInputChars.hint' },
181
+ { key: 'maxOutputTokens', kind: 'number', label: 'settings.row.maxOutputTokens.label', hint: 'settings.row.maxOutputTokens.hint' },
175
182
  { key: 'timeoutMs', kind: 'number', label: 'settings.row.timeoutMs.label', hint: 'settings.row.timeoutMs.hint' },
176
- { key: 'strategyMode', kind: 'strategy', label: 'settings.row.strategyMode.label', hint: 'settings.row.strategyMode.hint' },
177
- { key: 'systemPrompt', kind: 'text', label: 'settings.row.systemPrompt.label', hint: 'settings.row.systemPrompt.hint', placeholder: 'settings.row.systemPrompt.placeholder' },
178
183
  { key: 'contextMaxMessages', kind: 'number', label: 'settings.row.contextMaxMessages.label', hint: 'settings.row.contextMaxMessages.hint' },
179
184
  { key: 'contextMaxChars', kind: 'number', label: 'settings.row.contextMaxChars.label', hint: 'settings.row.contextMaxChars.hint' },
180
185
  { key: 'maxConcurrent', kind: 'number', label: 'settings.row.maxConcurrent.label', hint: 'settings.row.maxConcurrent.hint' },
181
186
  { key: 'rateLimitPerMinute', kind: 'number', label: 'settings.row.rateLimitPerMinute.label', hint: 'settings.row.rateLimitPerMinute.hint' },
182
- { key: 'shortcut', kind: 'text', label: 'settings.row.shortcut.label', hint: 'settings.row.shortcut.hint', placeholder: 'settings.row.shortcut.placeholder' },
183
187
  ]
184
188
 
189
+ /** Every row both pages edit; the renderer splits it at the Advanced boundary. */
190
+ const ROWS: readonly Row[] = [...BASIC_ROWS, ...ADVANCED_ROWS]
191
+
185
192
  /**
186
193
  * The staged form's descriptor for one row.
187
194
  * @param row - the row to describe.
@@ -283,6 +290,7 @@ function sectionCopy(t: Translate, chinese: boolean): RowCopy {
283
290
  save: t('settings.save'),
284
291
  saving: t('settings.saving'),
285
292
  saved: t('settings.saved'),
293
+ advanced: t('settings.advanced'),
286
294
  reset: t('settings.reset'),
287
295
  invalidNumber: t('settings.invalidNumber'),
288
296
  },
@@ -310,6 +318,7 @@ function pageCopy(t: Translate): RowCopy {
310
318
  save: t('settings.save'),
311
319
  saving: t('settings.saving'),
312
320
  saved: t('settings.saved'),
321
+ advanced: t('settings.advanced'),
313
322
  reset: t('settings.reset'),
314
323
  invalidNumber: t('settings.invalidNumber'),
315
324
  },
@@ -356,12 +365,12 @@ const CHIP_STYLE: CSSProperties = {
356
365
  padding: '1px 8px',
357
366
  border: 'none',
358
367
  borderRadius: 999,
359
- background: 'var(--dsw-alias-bg-module-platform, rgba(128, 128, 128, 0.12))',
368
+ background: 'var(--pe-chip-bg, var(--dsw-alias-bg-module-platform, rgba(128, 128, 128, 0.12)))',
360
369
  fontFamily: 'inherit',
361
370
  fontSize: 11,
362
371
  fontWeight: 500,
363
372
  lineHeight: '17px',
364
- color: 'var(--dsw-alias-label-secondary, inherit)',
373
+ color: 'var(--pe-chip-color, var(--dsw-alias-label-secondary, inherit))',
365
374
  textDecoration: 'underline',
366
375
  textUnderlineOffset: 2,
367
376
  cursor: 'pointer',
@@ -617,6 +626,18 @@ function viewOf(snapshot: SettingsSnapshot, key: string): FieldView {
617
626
  * @param text - the row's current staged text.
618
627
  * @returns true when editing can no longer change anything from the default.
619
628
  */
629
+ /** The display text a reset row falls back to, from the shared defaults. */
630
+ function defaultTextOf(key: string): string {
631
+ const descriptor = FIELD_SPECS.find((item) => item.field === key)
632
+ const fallback = (DEFAULT_VALUES as Record<string, unknown>)[key]
633
+ if (descriptor === undefined || fallback === undefined) return ''
634
+ try {
635
+ return descriptor.format(fallback)
636
+ } catch {
637
+ return ''
638
+ }
639
+ }
640
+
620
641
  function atDefaultValue(key: string, text: string): boolean {
621
642
  const fallback = (DEFAULT_VALUES as Record<string, unknown>)[key]
622
643
  // provider/model are absent from the defaults on purpose: empty means follow.
@@ -638,6 +659,7 @@ function OverrideActions(props: { copy: RowCopy; disabled: boolean; onReset: ()
638
659
  return (
639
660
  <button
640
661
  type="button"
662
+ className="dsh-pe-chip-reset"
641
663
  style={{ ...RESET_STYLE, ...props.disabled ? { opacity: 0.5, cursor: 'default' } : {} }}
642
664
  disabled={props.disabled}
643
665
  onClick={props.onReset}
@@ -814,6 +836,7 @@ function ReasoningRow(props: RowProps & { provider: string; model: string }): Re
814
836
  ? (
815
837
  <button
816
838
  type="button"
839
+ className="dsh-pe-chip-refresh"
817
840
  style={{ ...REFRESH_STYLE, opacity: props.disabled || refreshing ? 0.5 : 1 }}
818
841
  disabled={props.disabled || refreshing}
819
842
  onClick={refresh}
@@ -1169,6 +1192,31 @@ function SettingsRows(props: {
1169
1192
  }, 2000)
1170
1193
  }
1171
1194
 
1195
+ const runReset = async (key: string, fallback: string): Promise<void> => {
1196
+ if (props.writeField === undefined) return
1197
+ const ticket = ++sequence.current
1198
+ setSaveState('saving')
1199
+ const result = await props.writeField(key, '')
1200
+ if (ticket !== sequence.current) return
1201
+ if (result === 'failed') {
1202
+ setSaveState('failed')
1203
+ return
1204
+ }
1205
+ if (result === 'invalid') {
1206
+ setSaveState('idle')
1207
+ return
1208
+ }
1209
+ savedValues.current.set(key, fallback)
1210
+ markSaved()
1211
+ }
1212
+
1213
+ const resetAndSave = (key: string): void => {
1214
+ props.resetField(key)
1215
+ const fallback = defaultTextOf(key)
1216
+ savedValues.current.set(key, fallback)
1217
+ void runReset(key, fallback)
1218
+ }
1219
+
1172
1220
  const manualSave = async (): Promise<void> => {
1173
1221
  if (props.writeField === undefined) {
1174
1222
  // Hosts without per-field writes keep the original whole-form action.
@@ -1246,30 +1294,36 @@ function SettingsRows(props: {
1246
1294
  ? props.copy.labels.saveFailedShort
1247
1295
  : ''
1248
1296
 
1297
+ const renderRow = (row: Row, index: number): ReactElement => {
1298
+ const raw = viewOf(props.state, row.key)
1299
+ // Hide the override badge once the value is back at its default; the
1300
+ // host's `overridden` flag alone would keep it visible.
1301
+ const view = raw.overridden && atDefaultValue(row.key, raw.text) ? { ...raw, overridden: false } : raw
1302
+ return (
1303
+ <div key={row.key} style={index === 0 ? undefined : SEPARATOR_STYLE}>
1304
+ <SettingsRow
1305
+ row={row}
1306
+ copy={props.copy}
1307
+ view={view}
1308
+ disabled={!props.state.writable}
1309
+ reasoningPair={{ provider, model }}
1310
+ routing={routing}
1311
+ providerValue={provider}
1312
+ onEdit={(text: string) => onEdit(row.key, text)}
1313
+ onReset={() => resetAndSave(row.key)}
1314
+ onCommit={() => flushField(row.key, viewOf(props.state, row.key).text)}
1315
+ />
1316
+ </div>
1317
+ )
1318
+ }
1319
+
1249
1320
  return (
1250
1321
  <div className="dsh-pe-form">
1251
- {ROWS.map((row, index) => {
1252
- const raw = viewOf(props.state, row.key)
1253
- // Hide the override badge once the value is back at its default; the
1254
- // host's `overridden` flag alone would keep it visible.
1255
- const view = raw.overridden && atDefaultValue(row.key, raw.text) ? { ...raw, overridden: false } : raw
1256
- return (
1257
- <div key={row.key} style={index === 0 ? undefined : SEPARATOR_STYLE}>
1258
- <SettingsRow
1259
- row={row}
1260
- copy={props.copy}
1261
- view={view}
1262
- disabled={!props.state.writable}
1263
- reasoningPair={{ provider, model }}
1264
- routing={routing}
1265
- providerValue={provider}
1266
- onEdit={(text: string) => onEdit(row.key, text)}
1267
- onReset={() => props.resetField(row.key)}
1268
- onCommit={() => flushField(row.key, viewOf(props.state, row.key).text)}
1269
- />
1270
- </div>
1271
- )
1272
- })}
1322
+ {BASIC_ROWS.map(renderRow)}
1323
+ <details className="dsh-pe-advanced">
1324
+ <summary>{props.copy.labels.advanced}</summary>
1325
+ {ADVANCED_ROWS.map(renderRow)}
1326
+ </details>
1273
1327
  <div className="dsh-pe-form-footer">
1274
1328
  <div className="dsh-pe-save-group">
1275
1329
  {statusText === ''
@@ -271,6 +271,58 @@ export const CSS = `
271
271
  text-align: center;
272
272
  white-space: nowrap;
273
273
  }
274
+ .dsh-pe-advanced {
275
+ margin-top: 12px;
276
+ border-top: 1px solid var(--dsw-alias-border-l3, rgba(128, 128, 128, 0.22));
277
+ }
278
+ .dsh-pe-advanced > summary {
279
+ display: flex;
280
+ align-items: center;
281
+ gap: 8px;
282
+ min-height: 40px;
283
+ padding: 0 4px;
284
+ list-style: none;
285
+ font-size: 13px;
286
+ font-weight: 500;
287
+ color: var(--dsw-alias-label-secondary, inherit);
288
+ cursor: pointer;
289
+ user-select: none;
290
+ }
291
+ .dsh-pe-advanced > summary::-webkit-details-marker { display: none; }
292
+ .dsh-pe-advanced > summary::marker { content: ''; }
293
+ .dsh-pe-advanced > summary::before {
294
+ content: '';
295
+ flex: none;
296
+ width: 0;
297
+ height: 0;
298
+ border-top: 4px solid transparent;
299
+ border-bottom: 4px solid transparent;
300
+ border-left: 5px solid currentColor;
301
+ transition: transform 120ms ease;
302
+ }
303
+ .dsh-pe-advanced[open] > summary::before { transform: rotate(90deg); }
304
+ .dsh-pe-advanced > summary:hover {
305
+ color: var(--dsw-alias-label-primary, inherit);
306
+ background: rgba(127, 127, 127, 0.08);
307
+ border-radius: 6px;
308
+ }
309
+ .dsh-pe-advanced > summary:focus-visible {
310
+ outline: 2px solid var(--dsw-alias-state-business-primary, #4f8cff);
311
+ outline-offset: -2px;
312
+ border-radius: 6px;
313
+ }
314
+ .dsh-pe-advanced[open] > summary { margin-bottom: 4px; }
315
+ .dsh-pe-advanced + .dsh-pe-form-footer { margin-top: 0; }
316
+ .dsh-pe-chip-reset:hover:not(:disabled),
317
+ .dsh-pe-chip-refresh:hover:not(:disabled) {
318
+ --pe-chip-bg: var(--dsw-alias-interactive-bg-hover, rgba(127, 127, 127, 0.18));
319
+ --pe-chip-color: var(--dsw-alias-label-primary, inherit);
320
+ }
321
+ .dsh-pe-chip-reset:focus-visible,
322
+ .dsh-pe-chip-refresh:focus-visible {
323
+ outline: 2px solid var(--dsw-alias-state-business-primary, #4f8cff);
324
+ outline-offset: 2px;
325
+ }
274
326
  .dsh-pe-form-footer {
275
327
  display: flex;
276
328
  justify-content: flex-end;