dsh-thinking-levels 1.0.0-beta.2 → 1.0.1

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
@@ -76,6 +76,14 @@ window.__ModuleLoader__.load({
76
76
  "input.context.clear": "清除",
77
77
  "input.context.integer": "上下文长度必须是整数(2000-1000000)",
78
78
  "input.context.range": "上下文长度必须在 2000 到 1000000 之间",
79
+ "model.panel.choose": "选择模型",
80
+ "model.panel.loading": "模型目录加载中…",
81
+ "model.panel.empty": "没有可用模型",
82
+ "model.panel.window": "窗口",
83
+ "model.panel.noTarget": "该模型没有可写的配置项",
84
+ "model.panel.unavailable": "当前会话的模型目录不可用",
85
+ "input.effort.title": "思考强度",
86
+ "input.effort.default": "提供方默认",
79
87
  "card.capabilities.failed": "保存失败:配置被拒绝或冲突,请检查值。"
80
88
  };
81
89
  /** English dictionary (keys mirror zh). */
@@ -144,6 +152,14 @@ window.__ModuleLoader__.load({
144
152
  "input.context.clear": "Clear",
145
153
  "input.context.integer": "Context length must be an integer (2000-1000000)",
146
154
  "input.context.range": "Context length must be between 2000 and 1000000",
155
+ "model.panel.choose": "Choose model",
156
+ "model.panel.loading": "Loading the model directory…",
157
+ "model.panel.empty": "No models available",
158
+ "model.panel.window": "Window",
159
+ "model.panel.noTarget": "No writable config entry for this model",
160
+ "model.panel.unavailable": "The model directory is unavailable for this session",
161
+ "input.effort.title": "Reasoning effort",
162
+ "input.effort.default": "Provider default",
147
163
  "card.capabilities.failed": "Save failed: the value was rejected or conflicted. Check it."
148
164
  };
149
165
  /** Japanese dictionary (keys mirror zh). */
@@ -212,6 +228,14 @@ window.__ModuleLoader__.load({
212
228
  "input.context.clear": "クリア",
213
229
  "input.context.integer": "コンテキスト長は整数で入力してください(2000-1000000)",
214
230
  "input.context.range": "コンテキスト長は 2000 から 1000000 の範囲で指定してください",
231
+ "model.panel.choose": "モデルを選択",
232
+ "model.panel.loading": "モデルディレクトリを読み込み中…",
233
+ "model.panel.empty": "利用可能なモデルがありません",
234
+ "model.panel.window": "ウィンドウ",
235
+ "model.panel.noTarget": "このモデルには書き込み可能な設定項目がありません",
236
+ "model.panel.unavailable": "このセッションのモデルディレクトリは利用できません",
237
+ "input.effort.title": "思考レベル",
238
+ "input.effort.default": "プロバイダーの既定",
215
239
  "card.capabilities.failed": "保存に失敗しました:値が拒否されたか競合しています。確認してください。"
216
240
  };
217
241
  /** Korean dictionary (keys mirror zh). */
@@ -280,6 +304,14 @@ window.__ModuleLoader__.load({
280
304
  "input.context.clear": "지우기",
281
305
  "input.context.integer": "컨텍스트 길이는 정수여야 합니다 (2000-1000000)",
282
306
  "input.context.range": "컨텍스트 길이는 2000에서 1000000 사이여야 합니다",
307
+ "model.panel.choose": "모델 선택",
308
+ "model.panel.loading": "모델 디렉터리를 불러오는 중…",
309
+ "model.panel.empty": "사용 가능한 모델이 없습니다",
310
+ "model.panel.window": "창",
311
+ "model.panel.noTarget": "이 모델에는 쓰기 가능한 설정 항목이 없습니다",
312
+ "model.panel.unavailable": "이 세션의 모델 디렉터리를 사용할 수 없습니다",
313
+ "input.effort.title": "추론 강도",
314
+ "input.effort.default": "공급자 기본값",
283
315
  "card.capabilities.failed": "저장 실패: 값이 거부되었거나 충돌합니다. 확인하세요."
284
316
  };
285
317
  /** The multi-level context-window presets, in ascending order. */
@@ -426,7 +458,7 @@ window.__ModuleLoader__.load({
426
458
  "string-thinking",
427
459
  "ant-ling"
428
460
  ];
429
- const rowStyle$1 = {
461
+ const rowStyle = {
430
462
  display: "flex",
431
463
  alignItems: "center",
432
464
  justifyContent: "space-between",
@@ -483,7 +515,7 @@ window.__ModuleLoader__.load({
483
515
  padding: "7px 10px",
484
516
  background: "var(--dsw-alias-bg-layer-2, rgba(127,127,127,0.06))"
485
517
  };
486
- const providerNameStyle = {
518
+ const providerNameStyle$1 = {
487
519
  margin: 0,
488
520
  flex: "1 1 auto",
489
521
  minWidth: 0,
@@ -514,7 +546,7 @@ window.__ModuleLoader__.load({
514
546
  alignItems: "center"
515
547
  };
516
548
  /** One model row inside a provider group. */
517
- const modelRowStyle = {
549
+ const modelRowStyle$1 = {
518
550
  display: "flex",
519
551
  alignItems: "center",
520
552
  gap: "8px",
@@ -971,7 +1003,7 @@ window.__ModuleLoader__.load({
971
1003
  children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(ChevronIcon, { open: providerOpen })
972
1004
  }),
973
1005
  /* @__PURE__ */ (0, react_jsx_runtime.jsx)("p", {
974
- style: providerNameStyle,
1006
+ style: providerNameStyle$1,
975
1007
  children: providerId
976
1008
  }),
977
1009
  /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("label", {
@@ -1005,7 +1037,7 @@ window.__ModuleLoader__.load({
1005
1037
  const meta = summaryOf(entry);
1006
1038
  const format = typeof compat["thinkingFormat"] === "string" ? compat["thinkingFormat"] : void 0;
1007
1039
  return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", { children: [/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
1008
- style: modelRowStyle,
1040
+ style: modelRowStyle$1,
1009
1041
  children: [
1010
1042
  /* @__PURE__ */ (0, react_jsx_runtime.jsx)("button", {
1011
1043
  type: "button",
@@ -1421,7 +1453,7 @@ window.__ModuleLoader__.load({
1421
1453
  children: t("card.unavailable")
1422
1454
  }) : /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(react_jsx_runtime.Fragment, { children: [
1423
1455
  /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
1424
- style: rowStyle$1,
1456
+ style: rowStyle,
1425
1457
  children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("label", {
1426
1458
  htmlFor: "plugin-config-thinking-levels-level",
1427
1459
  style: labelStyle$1,
@@ -1441,7 +1473,7 @@ window.__ModuleLoader__.load({
1441
1473
  })]
1442
1474
  }),
1443
1475
  /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
1444
- style: rowStyle$1,
1476
+ style: rowStyle,
1445
1477
  children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("label", {
1446
1478
  htmlFor: "plugin-config-thinking-levels-enabled",
1447
1479
  style: labelStyle$1,
@@ -1457,7 +1489,7 @@ window.__ModuleLoader__.load({
1457
1489
  })]
1458
1490
  }),
1459
1491
  /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
1460
- style: rowStyle$1,
1492
+ style: rowStyle,
1461
1493
  children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("label", {
1462
1494
  htmlFor: "plugin-config-thinking-levels-downgrade",
1463
1495
  style: labelStyle$1,
@@ -1473,7 +1505,7 @@ window.__ModuleLoader__.load({
1473
1505
  })]
1474
1506
  }),
1475
1507
  /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
1476
- style: rowStyle$1,
1508
+ style: rowStyle,
1477
1509
  children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("label", {
1478
1510
  htmlFor: "plugin-config-thinking-levels-upgrade",
1479
1511
  style: labelStyle$1,
@@ -1506,41 +1538,36 @@ window.__ModuleLoader__.load({
1506
1538
  });
1507
1539
  }
1508
1540
  //#endregion
1509
- //#region src/client/context-quick.tsx
1541
+ //#region src/client/model-panel.tsx
1510
1542
  /**
1511
- * Context-window quick control for the composer tool row
1512
- * (`conversation.input.right`, the seat just left of the model/effort select).
1513
- *
1514
- * This is the compat (DSH < 0.1.2-alpha.1) implementation: it targets the
1515
- * CURRENT session's active model and lets the user cap that model's context
1516
- * window on the fly. The trigger is a compact pill showing the committed value
1517
- * only; the popover holds one slider row over the shared presets, a collapsed
1518
- * custom-integer editor and Clear — no preset button grid.
1543
+ * Model-seat panel for the composer (`conversation.input.model`).
1519
1544
  *
1520
- * Model source: the session `useConversation` seat (selector hook over
1521
- * `ConversationSnapshot`), whose `views.get('trajectory')` carries the request
1522
- * ledger. Every renderer standard seat is a `useSyncExternalStoreWithSelector`
1523
- * selector hook, never a bare getter — calling one without a selector throws
1524
- * `TypeError: <minified> is not a function` inside the binding shim. A harness
1525
- * line that does not provide the seat renders nothing at all here instead of a
1526
- * dead control.
1545
+ * Why this seat: the shipped `ModelSelect` renders no slots inside its popup,
1546
+ * so a plugin can never contribute *into* that panel — the working pattern
1547
+ * (proven by dsh-reasoning-effort) is to occupy the model seat itself: one
1548
+ * registered entry named after the seat with `priority: -1` replaces the
1549
+ * shipped trigger and popup outright. This component then renders its own
1550
+ * picker over the harness's shared model directory (`modelDirectories`
1551
+ * service), so model switching keeps working, and adds what the official
1552
+ * popup cannot offer: a context-window editor on every model line.
1527
1553
  *
1528
- * Two model families are served, each with its own writable settings
1529
- * namespace (both consumed live by `resolveModelInfo(...).context.contextWindow`,
1530
- * so a write takes effect on the next request without a restart):
1554
+ * Per-line context window (the "max context window" moved into each line):
1555
+ * each model row carries a compact chip showing the model's effective
1556
+ * `contextWindow`; clicking it opens an inline editor row (preset slider,
1557
+ * custom-integer input, Clear). Writes follow the same two-family discipline
1558
+ * the retired composer pill used (both consumed live by
1559
+ * `resolveModelInfo(...).context.contextWindow`, effective on the next
1560
+ * request without a restart):
1531
1561
  * - Custom gateways (`llm-pi-ai` providers): writes the model entry's
1532
- * `contextWindow` under `providers[provider].models[i]`.
1533
- * - Official DeepSeek models (`deepseek-official`, the `llm-deepseek`
1534
- * namespace): writes the catalog model's `contextWindow` when the model is
1535
- * listed, otherwise caps via `defaultContextWindow`.
1562
+ * `contextWindow` under `providers[provider].models[i]`; a gateway model
1563
+ * missing from the config has no write target and renders the chip disabled.
1564
+ * - Official DeepSeek (`deepseek-official`, the `llm-deepseek` entry): writes
1565
+ * the catalog model's `contextWindow` when listed, otherwise caps via
1566
+ * `defaultContextWindow`.
1536
1567
  *
1537
- * Write discipline: dragging the slider only moves a local draft; the settings
1538
- * write happens once per gesture (pointer release, key release, blur), so a
1539
- * drag never floods the host with intermediate values.
1540
- *
1541
- * Kept dependency-free beyond react + the injected scopes: plain HTML controls
1542
- * with token-based inline styling, and validation reuses the shared
1543
- * `validateContextWindow`.
1568
+ * Graceful degradation: when the harness provides no `modelDirectories`
1569
+ * service (older lines) the registration is skipped entirely and the shipped
1570
+ * model selector stays untouched.
1544
1571
  */
1545
1572
  /** The official DeepSeek provider route owned by the llm-deepseek adapter. */
1546
1573
  const DEEPSEEK_PROVIDER = "deepseek-official";
@@ -1548,62 +1575,204 @@ window.__ModuleLoader__.load({
1548
1575
  const DEEPSEEK_DEFAULT_WINDOW = 1e6;
1549
1576
  /** Slider stop an unset window parks on: the thumb needs a position, the readout stays "unset". */
1550
1577
  const UNSET_STOP_INDEX = CONTEXT_WINDOW_PRESETS.findIndex((preset) => preset.value === 256e3);
1551
- const pillStyle = {
1578
+ /** Snapshot shown when the session's directory face is unavailable. */
1579
+ const UNAVAILABLE_STATE = {
1580
+ status: "loading",
1581
+ groups: [],
1582
+ current: null,
1583
+ error: null
1584
+ };
1585
+ const rootStyle = {
1586
+ position: "relative",
1587
+ display: "inline-flex"
1588
+ };
1589
+ const triggerStyle = {
1552
1590
  display: "inline-flex",
1553
1591
  alignItems: "center",
1554
- gap: "4px",
1555
- height: "24px",
1556
- padding: "0 8px",
1557
- background: "var(--dsw-alias-bg-surface, #fff)",
1558
- color: "var(--dsw-alias-label-secondary)",
1592
+ gap: "6px",
1593
+ height: "26px",
1594
+ padding: "0 10px",
1595
+ background: "var(--dsw-alias-bg-layer-1)",
1596
+ color: "var(--dsw-alias-label-primary)",
1559
1597
  border: "1px solid var(--dsw-alias-border-l2)",
1560
- borderRadius: "6px",
1561
- fontSize: "11px",
1562
- lineHeight: "16px",
1563
- fontFamily: "var(--ds-font-family-code, monospace)",
1598
+ borderRadius: "8px",
1599
+ fontSize: "12px",
1600
+ lineHeight: "18px",
1564
1601
  cursor: "pointer",
1565
- whiteSpace: "nowrap"
1602
+ whiteSpace: "nowrap",
1603
+ maxWidth: "220px"
1604
+ };
1605
+ const triggerNameStyle = {
1606
+ minWidth: 0,
1607
+ overflow: "hidden",
1608
+ textOverflow: "ellipsis"
1609
+ };
1610
+ const triggerEffortStyle = {
1611
+ flex: "0 0 auto",
1612
+ maxWidth: "72px",
1613
+ overflow: "hidden",
1614
+ textOverflow: "ellipsis",
1615
+ color: "var(--dsw-alias-label-tertiary)"
1616
+ };
1617
+ const chevronStyle = {
1618
+ flex: "0 0 auto",
1619
+ fontSize: "9px",
1620
+ color: "var(--dsw-alias-label-tertiary)"
1566
1621
  };
1567
1622
  const popStyle = {
1568
1623
  position: "absolute",
1569
1624
  bottom: "calc(100% + 8px)",
1570
- right: "0",
1625
+ left: "0",
1571
1626
  zIndex: 1200,
1572
- minWidth: "260px",
1573
- padding: "10px",
1574
- background: "var(--dsw-alias-bg-layer-3, rgba(127,127,127,0.05))",
1627
+ width: "320px",
1628
+ padding: "8px",
1629
+ background: "var(--dsw-alias-bg-layer-3)",
1575
1630
  color: "var(--dsw-alias-label-primary)",
1576
1631
  border: "1px solid var(--dsw-alias-border-l2)",
1577
1632
  borderRadius: "10px",
1578
1633
  boxShadow: "0 8px 28px rgba(0,0,0,0.18)",
1579
1634
  display: "flex",
1580
1635
  flexDirection: "column",
1581
- gap: "8px"
1636
+ gap: "4px"
1582
1637
  };
1583
1638
  const backdropStyle = {
1584
1639
  position: "fixed",
1585
1640
  inset: 0,
1586
1641
  zIndex: 1199
1587
1642
  };
1588
- const rowStyle = {
1643
+ const modelsStyle = {
1644
+ maxHeight: "320px",
1645
+ overflowY: "auto",
1646
+ display: "flex",
1647
+ flexDirection: "column",
1648
+ gap: "2px"
1649
+ };
1650
+ const providerToggleStyle = {
1589
1651
  display: "flex",
1590
1652
  alignItems: "center",
1591
- gap: "8px",
1653
+ gap: "6px",
1654
+ width: "100%",
1655
+ padding: "6px 8px",
1656
+ border: "none",
1657
+ borderRadius: "6px",
1658
+ background: "transparent",
1659
+ color: "var(--dsw-alias-label-secondary)",
1660
+ font: "inherit",
1592
1661
  fontSize: "12px",
1593
- lineHeight: "18px",
1594
- color: "var(--dsw-alias-label-secondary)"
1662
+ cursor: "pointer",
1663
+ textAlign: "left"
1595
1664
  };
1596
- const labelStyle = {
1665
+ const providerNameStyle = {
1666
+ flex: "1 1 auto",
1667
+ fontWeight: 600
1668
+ };
1669
+ const providerMetaStyle = {
1597
1670
  flex: "0 0 auto",
1598
- minWidth: "0",
1671
+ color: "var(--dsw-alias-label-tertiary)",
1672
+ fontSize: "11px"
1673
+ };
1674
+ /** The model-line row CONTAINER: highlight surface + flex parent of pick/select/chip.
1675
+ * Wraps so the inline window editor (a flex item too) takes its own full line. */
1676
+ const modelRowStyle = {
1677
+ display: "flex",
1678
+ flexWrap: "wrap",
1679
+ alignItems: "center",
1680
+ gap: "6px",
1681
+ width: "100%",
1682
+ borderRadius: "6px"
1683
+ };
1684
+ const modelRowActiveStyle = {
1685
+ ...modelRowStyle,
1686
+ background: "var(--dsw-alias-state-business-primary-weak, var(--dsw-alias-interactive-bg-hover, transparent))"
1687
+ };
1688
+ /** The pick button inside the row: name/description/✓, keeps the row's old padding. */
1689
+ const modelPickStyle = {
1690
+ flex: "1 1 auto",
1691
+ minWidth: 0,
1692
+ display: "flex",
1693
+ alignItems: "center",
1694
+ gap: "6px",
1695
+ padding: "6px 4px 6px 18px",
1696
+ border: "none",
1697
+ background: "transparent",
1698
+ color: "var(--dsw-alias-label-primary)",
1699
+ font: "inherit",
1700
+ fontSize: "12px",
1701
+ cursor: "pointer",
1702
+ textAlign: "left"
1703
+ };
1704
+ const modelCopyStyle = {
1705
+ flex: "1 1 auto",
1706
+ minWidth: 0,
1707
+ display: "flex",
1708
+ flexDirection: "column",
1709
+ gap: "1px"
1710
+ };
1711
+ const modelNameStyle = {
1599
1712
  overflow: "hidden",
1600
1713
  textOverflow: "ellipsis",
1714
+ whiteSpace: "nowrap"
1715
+ };
1716
+ const checkStyle = {
1717
+ flex: "0 0 auto",
1718
+ color: "var(--dsw-alias-state-business-primary)"
1719
+ };
1720
+ const chipStyle = {
1721
+ flex: "0 0 auto",
1722
+ height: "18px",
1723
+ padding: "0 6px",
1724
+ border: "1px solid var(--dsw-alias-border-l2)",
1725
+ borderRadius: "5px",
1726
+ background: "var(--dsw-alias-bg-layer-1)",
1727
+ color: "var(--dsw-alias-label-secondary)",
1728
+ fontSize: "11px",
1729
+ lineHeight: "16px",
1730
+ fontFamily: "var(--ds-font-family-code, monospace)",
1731
+ fontVariantNumeric: "tabular-nums",
1732
+ cursor: "pointer",
1601
1733
  whiteSpace: "nowrap",
1602
- color: "var(--dsw-alias-label-tertiary)"
1734
+ marginRight: "8px"
1735
+ };
1736
+ const chipDisabledStyle = {
1737
+ ...chipStyle,
1738
+ cursor: "default",
1739
+ opacity: .55
1740
+ };
1741
+ const selectStyle = {
1742
+ flex: "0 0 auto",
1743
+ height: "18px",
1744
+ maxWidth: "96px",
1745
+ padding: "0 2px",
1746
+ border: "1px solid var(--dsw-alias-border-l2)",
1747
+ borderRadius: "5px",
1748
+ background: "var(--dsw-alias-bg-layer-1)",
1749
+ color: "var(--dsw-alias-label-secondary)",
1750
+ font: "inherit",
1751
+ fontSize: "11px",
1752
+ lineHeight: "16px",
1753
+ cursor: "pointer",
1754
+ colorScheme: "dark light"
1755
+ };
1756
+ const editorRowStyle = {
1757
+ flex: "1 1 100%",
1758
+ display: "flex",
1759
+ alignItems: "center",
1760
+ gap: "6px",
1761
+ margin: "2px 8px 6px 18px",
1762
+ padding: "6px",
1763
+ border: "1px solid var(--dsw-alias-border-l2)",
1764
+ borderRadius: "6px",
1765
+ background: "var(--dsw-alias-bg-layer-1)",
1766
+ fontSize: "12px"
1767
+ };
1768
+ const labelStyle = {
1769
+ flex: "0 0 auto",
1770
+ color: "var(--dsw-alias-label-tertiary)",
1771
+ whiteSpace: "nowrap"
1603
1772
  };
1604
1773
  const sliderStyle = {
1605
1774
  flex: "1 1 auto",
1606
- minWidth: "56px",
1775
+ minWidth: "48px",
1607
1776
  height: "14px",
1608
1777
  margin: "0",
1609
1778
  accentColor: "var(--dsw-alias-state-business-primary)",
@@ -1611,23 +1780,12 @@ window.__ModuleLoader__.load({
1611
1780
  };
1612
1781
  const valueStyle = {
1613
1782
  flex: "0 0 auto",
1614
- minWidth: "40px",
1783
+ minWidth: "36px",
1615
1784
  textAlign: "right",
1616
1785
  color: "var(--dsw-alias-label-primary)",
1617
1786
  fontFamily: "var(--ds-font-family-code, monospace)",
1618
1787
  fontVariantNumeric: "tabular-nums"
1619
1788
  };
1620
- const glyphButtonStyle = {
1621
- flex: "0 0 auto",
1622
- height: "18px",
1623
- padding: "0 5px",
1624
- border: "1px solid transparent",
1625
- borderRadius: "4px",
1626
- background: "transparent",
1627
- color: "var(--dsw-alias-label-tertiary)",
1628
- font: "inherit",
1629
- cursor: "pointer"
1630
- };
1631
1789
  const actionButtonStyle = {
1632
1790
  flex: "0 0 auto",
1633
1791
  height: "18px",
@@ -1639,11 +1797,6 @@ window.__ModuleLoader__.load({
1639
1797
  font: "inherit",
1640
1798
  cursor: "pointer"
1641
1799
  };
1642
- const customRowStyle = {
1643
- display: "flex",
1644
- alignItems: "center",
1645
- gap: "6px"
1646
- };
1647
1800
  const inputStyle = {
1648
1801
  flex: "1 1 auto",
1649
1802
  minWidth: "0",
@@ -1651,13 +1804,26 @@ window.__ModuleLoader__.load({
1651
1804
  padding: "2px 6px",
1652
1805
  border: "1px solid var(--dsw-alias-border-l2)",
1653
1806
  borderRadius: "5px",
1654
- background: "var(--dsw-alias-bg-surface, #fff)",
1807
+ background: "var(--dsw-alias-bg-layer-1)",
1655
1808
  color: "var(--dsw-alias-label-primary)",
1656
1809
  font: "inherit"
1657
1810
  };
1658
1811
  const errorStyle = {
1659
1812
  flex: "0 0 auto",
1660
- color: "var(--dsw-alias-danger, #e5484d)"
1813
+ color: "var(--dsw-alias-state-error-primary)",
1814
+ fontSize: "11px"
1815
+ };
1816
+ const statusStyle = {
1817
+ padding: "10px 8px",
1818
+ fontSize: "12px",
1819
+ color: "var(--dsw-alias-label-tertiary)"
1820
+ };
1821
+ const errorBannerStyle = {
1822
+ padding: "6px 8px",
1823
+ borderRadius: "6px",
1824
+ background: "var(--dsw-alias-interactive-bg-hover-danger)",
1825
+ color: "var(--dsw-alias-state-error-primary)",
1826
+ fontSize: "11px"
1661
1827
  };
1662
1828
  /** The user-layer `providers` value of the llm-pi-ai namespace, when present. */
1663
1829
  function providersOf(snapshot) {
@@ -1680,46 +1846,19 @@ window.__ModuleLoader__.load({
1680
1846
  ...defaultContextWindow === void 0 ? {} : { defaultContextWindow }
1681
1847
  };
1682
1848
  }
1683
- /**
1684
- * The stable trajectory selector: the seat memoizes its selection on the
1685
- * selector reference, so it must not be a fresh closure per render. Selecting
1686
- * the trajectory view snapshot (a store-owned reference, not a derived object)
1687
- * keeps the selected value stable between snapshots — a selector that built a
1688
- * new object would re-render forever.
1689
- * @param snapshot - the current conversation snapshot.
1690
- * @returns the trajectory view snapshot, absent while the view is unregistered.
1691
- */
1692
- const selectTrajectory = (snapshot) => snapshot.views?.get?.("trajectory");
1693
- /**
1694
- * The current session's active model, taken from the trajectory ledger's
1695
- * latest assistant request prompt config. Absent for a blank session (no
1696
- * request yet) — the control then renders disabled.
1697
- * @param trajectory - the trajectory view snapshot, when the view is registered.
1698
- */
1699
- function activeModelOf(trajectory) {
1700
- if (typeof trajectory !== "object" || trajectory === null) return void 0;
1701
- const requests = trajectory.requests ?? [];
1702
- for (let index = requests.length - 1; index >= 0; index -= 1) {
1703
- const config = requests[index]?.prompt?.config;
1704
- if (requests[index]?.purpose === "assistant" && typeof config?.provider === "string" && typeof config?.model === "string") return {
1705
- provider: config.provider,
1706
- model: config.model
1707
- };
1708
- }
1709
- }
1710
1849
  /** One model entry's declared contextWindow, when present. */
1711
1850
  function contextWindowOf(model) {
1712
1851
  const value = model["contextWindow"];
1713
1852
  return typeof value === "number" && Number.isFinite(value) && value > 0 ? value : void 0;
1714
1853
  }
1715
- /**
1716
- * The slider stop nearest to a committed token count; a window that matches no
1717
- * preset still parks the thumb on its closest stop.
1718
- * @param value - the committed context window, when one is set.
1719
- * @returns the stop index, or the unset park position.
1720
- */
1854
+ /** A provider's model entry in the llm-pi-ai user layer, when present. */
1855
+ function piModelEntry(providers, provider, model) {
1856
+ const profile = providers[provider];
1857
+ return profile !== void 0 && Array.isArray(profile.models) ? profile.models.find((candidate) => typeof candidate === "object" && candidate !== null && candidate["id"] === model) : void 0;
1858
+ }
1859
+ /** The slider stop nearest to a committed token count. */
1721
1860
  function stopIndexOf(value) {
1722
- if (value === void 0) return UNSET_STOP_INDEX;
1861
+ if (value === void 0) return Math.max(0, UNSET_STOP_INDEX);
1723
1862
  let best = 0;
1724
1863
  let bestDistance = Number.POSITIVE_INFINITY;
1725
1864
  CONTEXT_WINDOW_PRESETS.forEach((preset, index) => {
@@ -1732,89 +1871,99 @@ window.__ModuleLoader__.load({
1732
1871
  return best;
1733
1872
  }
1734
1873
  /**
1735
- * The composer context-window quick control. Renders nothing when this harness
1736
- * line provides no conversation seat, so a missing seat never leaves a dead
1737
- * control (or a crash) in the tool row.
1738
- * @param props - injected scopes, session standard seats, copy.
1739
- */
1740
- function ContextQuick(props) {
1741
- const useConversation = props.useConversation;
1742
- if (typeof useConversation !== "function") return null;
1743
- return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(ContextQuickControl, {
1744
- ...props,
1745
- useConversation
1746
- });
1747
- }
1748
- /**
1749
- * The bound control: a value pill that opens a one-row slider popover
1750
- * (preset slider, committed value, collapsed custom-integer editor, Clear).
1751
- * Custom gateways and official DeepSeek models are both supported (see module
1752
- * doc for the namespace each writes).
1753
- * @param props - injected scopes, the present conversation seat, copy.
1874
+ * The model-seat panel: replaces the shipped model selector on this seat and
1875
+ * renders one picker whose every model line carries a context-window chip
1876
+ * (the "max context window" editor moved into each line).
1877
+ * @param props - injected directory + config forms, session seat, copy.
1754
1878
  */
1755
- function ContextQuickControl({ useConversation, piAiScope, deepseekScope, t }) {
1756
- const active = activeModelOf(useConversation(selectTrajectory));
1757
- const official = active !== void 0 && active.provider === DEEPSEEK_PROVIDER;
1879
+ function ModelPanel({ directory, piAiScope, deepseekScope, t }) {
1880
+ const state = (0, react.useSyncExternalStore)((listener) => directory?.store.subscribe(listener) ?? (() => {}), () => directory?.store.getSnapshot() ?? UNAVAILABLE_STATE);
1758
1881
  const piSnapshot = (0, react.useSyncExternalStore)((listener) => piAiScope.subscribe(listener), () => piAiScope.getSnapshot());
1759
1882
  const dsSnapshot = (0, react.useSyncExternalStore)((listener) => deepseekScope.subscribe(listener), () => deepseekScope.getSnapshot());
1760
- const snapshot = official ? dsSnapshot : piSnapshot;
1761
- const readonly = snapshot.status === "unavailable" || !snapshot.writable;
1762
- const providers = official ? {} : providersOf(piSnapshot);
1763
- const dsSection = official ? deepseekSectionOf(dsSnapshot) : void 0;
1764
- let currentWindow;
1765
- let writableTarget = false;
1766
- if (official && active !== void 0) {
1767
- const models = dsSection?.models ?? [];
1768
- const index = models.findIndex((model) => model["id"] === active.model);
1769
- currentWindow = index >= 0 ? contextWindowOf(models[index]) : void 0;
1770
- if (currentWindow === void 0) currentWindow = dsSection?.defaultContextWindow;
1771
- writableTarget = true;
1772
- } else if (active !== void 0) {
1773
- const profile = providers[active.provider];
1774
- const model = profile !== void 0 && Array.isArray(profile.models) ? profile.models.find((candidate) => typeof candidate === "object" && candidate !== null && candidate["id"] === active.model) : void 0;
1775
- currentWindow = model === void 0 ? void 0 : contextWindowOf(model);
1776
- writableTarget = model !== void 0;
1777
- }
1778
1883
  const [open, setOpen] = (0, react.useState)(false);
1884
+ const [expanded, setExpanded] = (0, react.useState)(() => /* @__PURE__ */ new Set());
1885
+ const [editing, setEditing] = (0, react.useState)(null);
1779
1886
  const [draft, setDraft] = (0, react.useState)(null);
1780
1887
  const [custom, setCustom] = (0, react.useState)(false);
1781
1888
  const [raw, setRaw] = (0, react.useState)("");
1782
1889
  const [error, setError] = (0, react.useState)(null);
1783
1890
  const [busy, setBusy] = (0, react.useState)(false);
1784
- const disabled = readonly || busy || active === void 0 || !writableTarget;
1785
- const stop = draft ?? stopIndexOf(currentWindow);
1786
- /** Commit (or delete) the active model's context window. */
1787
- const commitWindow = (value) => {
1788
- if (active === void 0 || snapshot.status !== "ready" || !writableTarget) {
1789
- setDraft(null);
1790
- return;
1891
+ const rootRef = (0, react.useRef)(null);
1892
+ (0, react.useEffect)(() => {
1893
+ if (!open) return;
1894
+ directory?.load().catch(() => {});
1895
+ }, [directory, open]);
1896
+ const close = (0, react.useCallback)(() => {
1897
+ setOpen(false);
1898
+ setEditing(null);
1899
+ setError(null);
1900
+ }, []);
1901
+ (0, react.useEffect)(() => {
1902
+ if (!open) return;
1903
+ const onOutside = (event) => {
1904
+ const target = event.target;
1905
+ if (target instanceof Node && rootRef.current?.contains(target)) return;
1906
+ close();
1907
+ };
1908
+ document.addEventListener("mousedown", onOutside);
1909
+ return () => document.removeEventListener("mousedown", onOutside);
1910
+ }, [close, open]);
1911
+ const writable = piSnapshot.status === "ready" && piSnapshot.writable && dsSnapshot.status === "ready" && dsSnapshot.writable;
1912
+ const current = (0, react.useMemo)(() => {
1913
+ if (state.current === null) return void 0;
1914
+ for (const group of state.groups) {
1915
+ if (group.id !== state.current.provider) continue;
1916
+ const model = group.models.find((candidate) => candidate.id === state.current?.model);
1917
+ if (model !== void 0) return {
1918
+ model,
1919
+ name: model.name
1920
+ };
1791
1921
  }
1922
+ }, [state]);
1923
+ const providers = (0, react.useMemo)(() => providersOf(piSnapshot), [piSnapshot]);
1924
+ const dsSection = (0, react.useMemo)(() => deepseekSectionOf(dsSnapshot), [dsSnapshot]);
1925
+ /** The effective window of one model line, resolved against its family. */
1926
+ const windowOf = (provider, model) => {
1927
+ if (provider === DEEPSEEK_PROVIDER) {
1928
+ const models = dsSection.models ?? [];
1929
+ const index = models.findIndex((entry) => entry["id"] === model);
1930
+ return index >= 0 ? contextWindowOf(models[index]) : dsSection.defaultContextWindow;
1931
+ }
1932
+ const entry = piModelEntry(providers, provider, model);
1933
+ return entry === void 0 ? void 0 : contextWindowOf(entry);
1934
+ };
1935
+ /** Whether one model line has a config write target. */
1936
+ const writableLine = (provider, model) => {
1937
+ if (!writable) return false;
1938
+ if (provider === DEEPSEEK_PROVIDER) return true;
1939
+ return piModelEntry(providers, provider, model) !== void 0;
1940
+ };
1941
+ /** Commit (or delete) one model line's context window. */
1942
+ const commitWindow = (provider, model, value) => {
1792
1943
  setBusy(true);
1793
- if (official) {
1794
- const models = (deepseekSectionOf(dsSnapshot).models ?? []).map((model) => ({ ...model }));
1795
- const index = models.findIndex((model) => model["id"] === active.model);
1796
- (index >= 0 ? deepseekScope.set("models", models.map((model, at) => {
1797
- if (at !== index) return model;
1944
+ const done = () => {
1945
+ setBusy(false);
1946
+ setDraft(null);
1947
+ };
1948
+ if (provider === DEEPSEEK_PROVIDER) {
1949
+ const models = (deepseekSectionOf(dsSnapshot).models ?? []).map((entry) => ({ ...entry }));
1950
+ const index = models.findIndex((entry) => entry["id"] === model);
1951
+ (index >= 0 ? deepseekScope.set("models", models.map((entry, at) => {
1952
+ if (at !== index) return entry;
1798
1953
  if (value === void 0) {
1799
- const rest = { ...model };
1954
+ const rest = { ...entry };
1800
1955
  delete rest["contextWindow"];
1801
1956
  return rest;
1802
1957
  }
1803
1958
  return {
1804
- ...model,
1959
+ ...entry,
1805
1960
  contextWindow: value
1806
1961
  };
1807
- })) : deepseekScope.set("defaultContextWindow", value === void 0 ? DEEPSEEK_DEFAULT_WINDOW : value)).then(() => {
1808
- setBusy(false);
1809
- setDraft(null);
1810
- }).catch(() => {
1811
- setBusy(false);
1812
- setDraft(null);
1813
- });
1962
+ })) : deepseekScope.set("defaultContextWindow", value === void 0 ? DEEPSEEK_DEFAULT_WINDOW : value)).then(done, done);
1814
1963
  return;
1815
1964
  }
1816
1965
  const next = structuredClone(providers);
1817
- const entry = next[active.provider]?.models?.find((candidate) => typeof candidate === "object" && candidate !== null && candidate["id"] === active.model);
1966
+ const entry = piModelEntry(next, provider, model);
1818
1967
  if (entry === void 0) {
1819
1968
  setBusy(false);
1820
1969
  setDraft(null);
@@ -1822,25 +1971,15 @@ window.__ModuleLoader__.load({
1822
1971
  }
1823
1972
  if (value === void 0) delete entry["contextWindow"];
1824
1973
  else entry["contextWindow"] = value;
1825
- piAiScope.set("providers", next).then(() => {
1826
- setBusy(false);
1827
- setDraft(null);
1828
- }).catch(() => {
1829
- setBusy(false);
1830
- setDraft(null);
1831
- });
1832
- };
1833
- /** Write the stop the gesture landed on; a drag only moves the draft. */
1834
- const commitStop = () => {
1835
- if (disabled || draft === null) return;
1836
- commitWindow(CONTEXT_WINDOW_PRESETS[draft]?.value);
1974
+ piAiScope.set("providers", next).then(done, done);
1837
1975
  };
1838
1976
  /** Validate and commit the custom input; empty clears. */
1839
1977
  const applyCustom = () => {
1978
+ if (editing === null) return;
1840
1979
  const trimmed = raw.trim();
1841
1980
  if (trimmed === "") {
1842
1981
  setError(null);
1843
- commitWindow(void 0);
1982
+ commitWindow(editing.provider, editing.model, void 0);
1844
1983
  return;
1845
1984
  }
1846
1985
  const validation = validateContextWindow(trimmed);
@@ -1849,138 +1988,308 @@ window.__ModuleLoader__.load({
1849
1988
  return;
1850
1989
  }
1851
1990
  setError(null);
1852
- commitWindow(validation.value);
1991
+ commitWindow(editing.provider, editing.model, validation.value);
1992
+ };
1993
+ const openEditor = (provider, model) => {
1994
+ setEditing({
1995
+ provider,
1996
+ model
1997
+ });
1998
+ setDraft(null);
1999
+ setCustom(false);
2000
+ setRaw("");
2001
+ setError(null);
2002
+ };
2003
+ const toggleProvider = (provider) => {
2004
+ setExpanded((previous) => {
2005
+ const next = new Set(previous);
2006
+ if (next.has(provider)) next.delete(provider);
2007
+ else next.add(provider);
2008
+ return next;
2009
+ });
2010
+ };
2011
+ const chooseModel = (provider, model) => {
2012
+ if (busy || directory === void 0) return;
2013
+ setBusy(true);
2014
+ directory.select({
2015
+ provider,
2016
+ model
2017
+ }).then(() => {
2018
+ setBusy(false);
2019
+ close();
2020
+ }).catch(() => {
2021
+ setBusy(false);
2022
+ });
1853
2023
  };
1854
- const value = draft === null ? currentWindow === void 0 ? t("input.context.unset") : formatContextWindow(currentWindow) : formatContextWindow(CONTEXT_WINDOW_PRESETS[draft]?.value ?? 0);
2024
+ /** Commit one model line's reasoning effort; empty string = provider default (omit the field). */
2025
+ const chooseEffort = (provider, model, effort) => {
2026
+ if (busy || directory === void 0) return;
2027
+ setBusy(true);
2028
+ directory.select({
2029
+ provider,
2030
+ model,
2031
+ ...effort === "" ? {} : { reasoningEffort: effort }
2032
+ }).then(() => {
2033
+ setBusy(false);
2034
+ }).catch(() => {
2035
+ setBusy(false);
2036
+ });
2037
+ };
2038
+ const triggerLabel = current?.name ?? state.current?.model ?? t("model.panel.choose");
2039
+ const currentReasoning = current?.model.reasoning;
2040
+ const effectiveEffort = state.current?.reasoningEffort ?? currentReasoning?.defaultEffort;
2041
+ const effortLabel = currentReasoning === void 0 ? void 0 : effectiveEffort === void 0 ? t("input.effort.default") : currentReasoning.efforts.find((level) => level.id === effectiveEffort)?.name ?? effectiveEffort;
1855
2042
  return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
1856
- style: { position: "relative" },
1857
- children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("button", {
2043
+ ref: rootRef,
2044
+ style: rootStyle,
2045
+ children: [/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("button", {
1858
2046
  type: "button",
1859
- disabled,
2047
+ style: triggerStyle,
1860
2048
  "aria-expanded": open,
1861
- "aria-label": t("input.context.title"),
1862
- title: active === void 0 ? t("input.context.noModel") : `${active.provider}/${active.model}`,
1863
- style: {
1864
- ...pillStyle,
1865
- cursor: disabled ? "default" : "pointer",
1866
- opacity: disabled ? .55 : 1
1867
- },
2049
+ "aria-haspopup": "dialog",
2050
+ "aria-label": t("model.panel.choose"),
2051
+ title: state.current === null ? triggerLabel : `${state.current.provider}/${triggerLabel}`,
1868
2052
  onClick: () => {
1869
- setOpen((value) => !value);
1870
- setError(null);
2053
+ if (open) close();
2054
+ else {
2055
+ setOpen(true);
2056
+ setError(null);
2057
+ }
1871
2058
  },
1872
- children: value
2059
+ children: [
2060
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
2061
+ style: triggerNameStyle,
2062
+ children: triggerLabel
2063
+ }),
2064
+ effortLabel !== void 0 && /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
2065
+ style: triggerEffortStyle,
2066
+ children: effortLabel
2067
+ }),
2068
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
2069
+ style: chevronStyle,
2070
+ children: open ? "▲" : "▼"
2071
+ })
2072
+ ]
1873
2073
  }), open ? /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(react_jsx_runtime.Fragment, { children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
1874
2074
  style: backdropStyle,
1875
- onClick: () => {
1876
- setOpen(false);
1877
- setError(null);
1878
- }
2075
+ onClick: close
1879
2076
  }), /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
1880
2077
  style: popStyle,
1881
- role: "group",
1882
- "aria-label": t("input.context.title"),
2078
+ role: "dialog",
2079
+ "aria-label": t("model.panel.choose"),
1883
2080
  children: [/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
1884
- style: rowStyle,
2081
+ style: modelsStyle,
1885
2082
  children: [
1886
- /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
1887
- style: labelStyle,
1888
- title: t("input.context.globalHint"),
1889
- children: t("input.context.title")
2083
+ directory === void 0 && /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
2084
+ style: statusStyle,
2085
+ children: t("model.panel.unavailable")
1890
2086
  }),
1891
- /* @__PURE__ */ (0, react_jsx_runtime.jsx)("input", {
1892
- type: "range",
1893
- min: 0,
1894
- max: CONTEXT_WINDOW_PRESETS.length - 1,
1895
- step: 1,
1896
- value: stop,
1897
- disabled,
1898
- "aria-label": t("input.context.title"),
1899
- style: {
1900
- ...sliderStyle,
1901
- cursor: disabled ? "default" : "pointer",
1902
- opacity: disabled ? .55 : 1
1903
- },
1904
- onChange: (event) => {
1905
- setDraft(Number(event.currentTarget.value));
1906
- },
1907
- onPointerUp: commitStop,
1908
- onKeyUp: commitStop,
1909
- onBlur: commitStop
1910
- }),
1911
- /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
1912
- style: valueStyle,
1913
- children: value
1914
- }),
1915
- /* @__PURE__ */ (0, react_jsx_runtime.jsx)("button", {
1916
- type: "button",
1917
- disabled,
1918
- "aria-label": t("input.context.custom"),
1919
- "aria-expanded": custom,
1920
- title: t("input.context.custom"),
1921
- style: {
1922
- ...glyphButtonStyle,
1923
- cursor: disabled ? "default" : "pointer",
1924
- opacity: disabled ? .55 : 1
1925
- },
1926
- onClick: () => {
1927
- setCustom((open) => !open);
1928
- setError(null);
1929
- },
1930
- children: "⋯"
1931
- }),
1932
- /* @__PURE__ */ (0, react_jsx_runtime.jsx)("button", {
1933
- type: "button",
1934
- disabled: disabled || currentWindow === void 0,
1935
- style: {
1936
- ...actionButtonStyle,
1937
- cursor: disabled || currentWindow === void 0 ? "default" : "pointer",
1938
- opacity: disabled || currentWindow === void 0 ? .55 : 1
1939
- },
1940
- onClick: () => {
1941
- setDraft(null);
1942
- setError(null);
1943
- setRaw("");
1944
- commitWindow(void 0);
1945
- },
1946
- children: t("input.context.clear")
1947
- })
1948
- ]
1949
- }), custom ? /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
1950
- style: customRowStyle,
1951
- children: [
1952
- /* @__PURE__ */ (0, react_jsx_runtime.jsx)("input", {
1953
- type: "text",
1954
- inputMode: "numeric",
1955
- value: raw,
1956
- disabled,
1957
- placeholder: t("input.context.customPlaceholder"),
1958
- "aria-label": t("input.context.customPlaceholder"),
1959
- style: inputStyle,
1960
- onChange: (event) => {
1961
- setRaw(event.currentTarget.value);
1962
- },
1963
- onKeyDown: (event) => {
1964
- if (event.key === "Enter") applyCustom();
1965
- }
2087
+ directory !== void 0 && state.status === "loading" && state.groups.length === 0 && /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
2088
+ style: statusStyle,
2089
+ children: t("model.panel.loading")
1966
2090
  }),
1967
- /* @__PURE__ */ (0, react_jsx_runtime.jsx)("button", {
1968
- type: "button",
1969
- disabled,
1970
- style: {
1971
- ...actionButtonStyle,
1972
- cursor: disabled ? "default" : "pointer",
1973
- opacity: disabled ? .55 : 1
1974
- },
1975
- onClick: applyCustom,
1976
- children: t("input.context.apply")
2091
+ directory !== void 0 && state.groups.map((group) => {
2092
+ const isExpanded = expanded.has(group.id);
2093
+ const name = group.name ?? group.label ?? group.id;
2094
+ const activeModel = state.current?.provider === group.id ? state.current.model : void 0;
2095
+ return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("section", { children: [/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("button", {
2096
+ type: "button",
2097
+ style: providerToggleStyle,
2098
+ "aria-expanded": isExpanded,
2099
+ onClick: () => toggleProvider(group.id),
2100
+ children: [
2101
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
2102
+ style: providerNameStyle,
2103
+ children: name
2104
+ }),
2105
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
2106
+ style: providerMetaStyle,
2107
+ children: group.models.length
2108
+ }),
2109
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
2110
+ style: chevronStyle,
2111
+ children: isExpanded ? "▼" : "▶"
2112
+ })
2113
+ ]
2114
+ }), isExpanded && group.models.map((model) => {
2115
+ const active = activeModel === model.id;
2116
+ const lineWritable = writableLine(group.id, model.id);
2117
+ const lineWindow = windowOf(group.id, model.id);
2118
+ const isEditing = editing !== null && editing.provider === group.id && editing.model === model.id;
2119
+ const lineEffort = active ? state.current?.reasoningEffort ?? model.reasoning?.defaultEffort : model.reasoning?.defaultEffort;
2120
+ return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
2121
+ style: active ? modelRowActiveStyle : modelRowStyle,
2122
+ children: [
2123
+ /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("button", {
2124
+ type: "button",
2125
+ role: "option",
2126
+ "aria-selected": active,
2127
+ style: modelPickStyle,
2128
+ disabled: busy,
2129
+ onClick: () => chooseModel(group.id, model.id),
2130
+ children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
2131
+ style: modelCopyStyle,
2132
+ children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
2133
+ style: modelNameStyle,
2134
+ children: model.name
2135
+ })
2136
+ }), active && /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
2137
+ style: checkStyle,
2138
+ "aria-hidden": "true",
2139
+ children: "✓"
2140
+ })]
2141
+ }),
2142
+ model.reasoning !== void 0 && /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("select", {
2143
+ "aria-label": t("input.effort.title"),
2144
+ title: t("input.effort.title"),
2145
+ style: selectStyle,
2146
+ disabled: busy,
2147
+ value: lineEffort ?? "",
2148
+ onClick: (event) => event.stopPropagation(),
2149
+ onChange: (event) => {
2150
+ event.stopPropagation();
2151
+ const value = event.currentTarget.value;
2152
+ const target = value === "" ? model.reasoning?.defaultEffort : value;
2153
+ if (target !== void 0) chooseEffort(group.id, model.id, target);
2154
+ },
2155
+ children: [
2156
+ model.reasoning.defaultEffort !== void 0 && /* @__PURE__ */ (0, react_jsx_runtime.jsx)("option", {
2157
+ value: "",
2158
+ children: t("input.effort.default")
2159
+ }),
2160
+ model.reasoning.defaultEffort === void 0 && /* @__PURE__ */ (0, react_jsx_runtime.jsx)("option", {
2161
+ value: "",
2162
+ hidden: true,
2163
+ children: t("input.effort.default")
2164
+ }),
2165
+ model.reasoning.efforts.map((level) => /* @__PURE__ */ (0, react_jsx_runtime.jsx)("option", {
2166
+ value: level.id,
2167
+ children: level.name
2168
+ }, level.id))
2169
+ ]
2170
+ }),
2171
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
2172
+ role: "button",
2173
+ tabIndex: 0,
2174
+ "aria-label": t("input.context.title"),
2175
+ title: lineWritable ? t("input.context.globalHint") : t("model.panel.noTarget"),
2176
+ style: lineWritable && !busy ? chipStyle : chipDisabledStyle,
2177
+ onClick: (event) => {
2178
+ event.stopPropagation();
2179
+ if (!lineWritable || busy) return;
2180
+ if (isEditing) {
2181
+ setEditing(null);
2182
+ return;
2183
+ }
2184
+ openEditor(group.id, model.id);
2185
+ },
2186
+ onKeyDown: (event) => {
2187
+ if (event.key !== "Enter" && event.key !== " ") return;
2188
+ event.preventDefault();
2189
+ event.stopPropagation();
2190
+ if (!lineWritable || busy) return;
2191
+ openEditor(group.id, model.id);
2192
+ },
2193
+ children: lineWindow === void 0 ? t("input.context.unset") : formatContextWindow(lineWindow)
2194
+ }),
2195
+ isEditing && /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
2196
+ style: editorRowStyle,
2197
+ children: [
2198
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
2199
+ style: labelStyle,
2200
+ title: t("input.context.globalHint"),
2201
+ children: t("model.panel.window")
2202
+ }),
2203
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)("input", {
2204
+ type: "range",
2205
+ min: 0,
2206
+ max: CONTEXT_WINDOW_PRESETS.length - 1,
2207
+ step: 1,
2208
+ value: draft ?? stopIndexOf(lineWindow),
2209
+ disabled: busy,
2210
+ "aria-label": t("input.context.title"),
2211
+ style: sliderStyle,
2212
+ onChange: (event) => {
2213
+ setDraft(Number(event.currentTarget.value));
2214
+ },
2215
+ onPointerUp: () => {
2216
+ if (draft === null) return;
2217
+ commitWindow(group.id, model.id, CONTEXT_WINDOW_PRESETS[draft]?.value);
2218
+ },
2219
+ onKeyUp: () => {
2220
+ if (draft === null) return;
2221
+ commitWindow(group.id, model.id, CONTEXT_WINDOW_PRESETS[draft]?.value);
2222
+ }
2223
+ }),
2224
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
2225
+ style: valueStyle,
2226
+ children: draft === null ? lineWindow === void 0 ? t("input.context.unset") : formatContextWindow(lineWindow) : formatContextWindow(CONTEXT_WINDOW_PRESETS[draft]?.value ?? 0)
2227
+ }),
2228
+ custom ? /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(react_jsx_runtime.Fragment, { children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("input", {
2229
+ type: "text",
2230
+ inputMode: "numeric",
2231
+ value: raw,
2232
+ disabled: busy,
2233
+ placeholder: t("input.context.customPlaceholder"),
2234
+ "aria-label": t("input.context.customPlaceholder"),
2235
+ style: inputStyle,
2236
+ onChange: (event) => {
2237
+ setRaw(event.currentTarget.value);
2238
+ },
2239
+ onKeyDown: (event) => {
2240
+ if (event.key === "Enter") applyCustom();
2241
+ }
2242
+ }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("button", {
2243
+ type: "button",
2244
+ disabled: busy,
2245
+ style: actionButtonStyle,
2246
+ onClick: applyCustom,
2247
+ children: t("input.context.apply")
2248
+ })] }) : /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(react_jsx_runtime.Fragment, { children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("button", {
2249
+ type: "button",
2250
+ disabled: busy,
2251
+ "aria-label": t("input.context.custom"),
2252
+ title: t("input.context.custom"),
2253
+ style: actionButtonStyle,
2254
+ onClick: () => {
2255
+ setCustom(true);
2256
+ setError(null);
2257
+ },
2258
+ children: "⋯"
2259
+ }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("button", {
2260
+ type: "button",
2261
+ disabled: busy || lineWindow === void 0,
2262
+ style: {
2263
+ ...actionButtonStyle,
2264
+ opacity: lineWindow === void 0 ? .55 : 1
2265
+ },
2266
+ onClick: () => {
2267
+ setDraft(null);
2268
+ setError(null);
2269
+ commitWindow(group.id, model.id, void 0);
2270
+ },
2271
+ children: t("input.context.clear")
2272
+ })] }),
2273
+ error !== null && /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
2274
+ style: errorStyle,
2275
+ children: error
2276
+ })
2277
+ ]
2278
+ })
2279
+ ]
2280
+ }, group.id + ":" + model.id);
2281
+ })] }, group.id);
1977
2282
  }),
1978
- error !== null && /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
1979
- style: errorStyle,
1980
- children: error
2283
+ directory !== void 0 && state.status !== "loading" && state.groups.length === 0 && /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
2284
+ style: statusStyle,
2285
+ children: t("model.panel.empty")
1981
2286
  })
1982
2287
  ]
1983
- }) : null]
2288
+ }), directory !== void 0 && state.error !== null && /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
2289
+ style: errorBannerStyle,
2290
+ role: "status",
2291
+ children: state.error
2292
+ })]
1984
2293
  })] }) : null]
1985
2294
  });
1986
2295
  }
@@ -1995,16 +2304,24 @@ window.__ModuleLoader__.load({
1995
2304
  "settingsScope"
1996
2305
  ];
1997
2306
  /**
1998
- * Client plugin body: dictionaries plus the settings card registration.
2307
+ * Client plugin body: dictionaries, the settings card, and the model-seat
2308
+ * panel registration.
1999
2309
  * @param ctx - client root context.
2000
2310
  */
2001
2311
  function apply(ctx) {
2002
- ctx.effect(() => ctx.locale.register(NS, {
2003
- zh,
2004
- en,
2005
- ja,
2006
- ko
2007
- }), "dsh-thinking-levels: dictionaries");
2312
+ ctx.effect(() => {
2313
+ const disposers = [
2314
+ ctx.locale.register(NS, {
2315
+ zh,
2316
+ en
2317
+ }),
2318
+ ctx.locale.register(NS, "ja", ja),
2319
+ ctx.locale.register(NS, "ko", ko)
2320
+ ];
2321
+ return () => {
2322
+ for (const dispose of disposers) dispose();
2323
+ };
2324
+ }, "dsh-thinking-levels: dictionaries");
2008
2325
  ctx.slots.inject("settings.plugin.item", function* () {
2009
2326
  yield ctx.slots.register({
2010
2327
  name: "settings.plugin.item",
@@ -2019,18 +2336,35 @@ window.__ModuleLoader__.load({
2019
2336
  }
2020
2337
  }, ThinkingLevelsCard);
2021
2338
  });
2022
- ctx.slots.inject("conversation.input.right", function* () {
2023
- yield ctx.slots.register({
2024
- name: "conversation.input.right",
2025
- id: "context-window-quick",
2026
- locale: NS,
2027
- inject: () => {
2028
- return {
2029
- piAiScope: ctx.settingsScope.bind({ namespace: "llm-pi-ai" }),
2030
- deepseekScope: ctx.settingsScope.bind({ namespace: "llm-deepseek" })
2031
- };
2032
- }
2033
- }, ContextQuick);
2339
+ ctx.inject([
2340
+ "modelDirectories",
2341
+ "sessions",
2342
+ "remote",
2343
+ "remote.session"
2344
+ ], (scope) => {
2345
+ const directories = scope.modelDirectories;
2346
+ if (directories === void 0) return;
2347
+ ctx.slots.inject("conversation.input.model", function* () {
2348
+ yield ctx.slots.register({
2349
+ name: "conversation.input.model",
2350
+ id: "context-window-model-panel",
2351
+ priority: -1,
2352
+ locale: NS,
2353
+ inject: (sessionId) => {
2354
+ let directory;
2355
+ try {
2356
+ directory = directories.directoryFor(sessionId);
2357
+ } catch {
2358
+ directory = void 0;
2359
+ }
2360
+ return {
2361
+ directory,
2362
+ piAiScope: ctx.settingsScope.bind({ namespace: "llm-pi-ai" }),
2363
+ deepseekScope: ctx.settingsScope.bind({ namespace: "llm-deepseek" })
2364
+ };
2365
+ }
2366
+ }, ModelPanel);
2367
+ });
2034
2368
  });
2035
2369
  }
2036
2370
  //#endregion