dsh-thinking-levels 2.0.1 → 2.0.3

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,44 +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).
1543
+ * Model-seat panel for the composer (`conversation.input.model`).
1513
1544
  *
1514
- * Why this seat: the model *card* has no injection point (the shipped
1515
- * `ModelSelect` calls `renderSlot` zero times and owns its popup outright), so a
1516
- * plugin can only contribute inside the composer area. `conversation.input.right`
1517
- * is a session-scoped `list` seat, which is where the harness lets any plugin put
1518
- * a tool-row control. The trigger is a compact pill showing the committed value
1519
- * only; the popover holds one slider row over the shared presets, a collapsed
1520
- * custom-integer editor and Clear — no preset button grid.
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.
1521
1553
  *
1522
- * Model source: whichever session seat this harness provides, in order —
1523
- * `useTrajectory` (the trajectory ledger's `requests`, DSH 0.1.2+) or
1524
- * `useConversation` (`ConversationSnapshot.views.get('trajectory')`). Every
1525
- * renderer standard seat is a `useSyncExternalStoreWithSelector` selector hook
1526
- * and the selector is mandatory: calling one without a selector throws
1527
- * `TypeError: <minified> is not a function` inside the binding shim and takes the
1528
- * whole slot entry down. A harness that provides neither seat renders nothing
1529
- * here instead of a dead control.
1530
- *
1531
- * Two model families are served, each with its own writable settings
1532
- * namespace (both consumed live by `resolveModelInfo(...).context.contextWindow`,
1533
- * 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):
1534
1561
  * - Custom gateways (`llm-pi-ai` providers): writes the model entry's
1535
- * `contextWindow` under `providers[provider].models[i]`.
1536
- * - Official DeepSeek models (`deepseek-official`, the `llm-deepseek`
1537
- * namespace): writes the catalog model's `contextWindow` when the model is
1538
- * listed, otherwise caps via `defaultContextWindow`.
1539
- *
1540
- * Write discipline: dragging the slider only moves a local draft; the settings
1541
- * write happens once per gesture (pointer release, key release, blur), so a
1542
- * drag never floods the host with intermediate values.
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`.
1543
1567
  *
1544
- * Kept dependency-free beyond react + the injected scopes: plain HTML controls
1545
- * with token-based inline styling, and validation reuses the shared
1546
- * `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.
1547
1571
  */
1548
1572
  /** The official DeepSeek provider route owned by the llm-deepseek adapter. */
1549
1573
  const DEEPSEEK_PROVIDER = "deepseek-official";
@@ -1551,62 +1575,204 @@ window.__ModuleLoader__.load({
1551
1575
  const DEEPSEEK_DEFAULT_WINDOW = 1e6;
1552
1576
  /** Slider stop an unset window parks on: the thumb needs a position, the readout stays "unset". */
1553
1577
  const UNSET_STOP_INDEX = CONTEXT_WINDOW_PRESETS.findIndex((preset) => preset.value === 256e3);
1554
- 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 = {
1555
1590
  display: "inline-flex",
1556
1591
  alignItems: "center",
1557
- gap: "4px",
1558
- height: "24px",
1559
- padding: "0 8px",
1560
- background: "var(--dsw-alias-bg-surface, #fff)",
1561
- 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)",
1562
1597
  border: "1px solid var(--dsw-alias-border-l2)",
1563
- borderRadius: "6px",
1564
- fontSize: "11px",
1565
- lineHeight: "16px",
1566
- fontFamily: "var(--ds-font-family-code, monospace)",
1598
+ borderRadius: "8px",
1599
+ fontSize: "12px",
1600
+ lineHeight: "18px",
1567
1601
  cursor: "pointer",
1568
- 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)"
1569
1621
  };
1570
1622
  const popStyle = {
1571
1623
  position: "absolute",
1572
1624
  bottom: "calc(100% + 8px)",
1573
- right: "0",
1625
+ left: "0",
1574
1626
  zIndex: 1200,
1575
- minWidth: "260px",
1576
- padding: "10px",
1577
- 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)",
1578
1630
  color: "var(--dsw-alias-label-primary)",
1579
1631
  border: "1px solid var(--dsw-alias-border-l2)",
1580
1632
  borderRadius: "10px",
1581
1633
  boxShadow: "0 8px 28px rgba(0,0,0,0.18)",
1582
1634
  display: "flex",
1583
1635
  flexDirection: "column",
1584
- gap: "8px"
1636
+ gap: "4px"
1585
1637
  };
1586
1638
  const backdropStyle = {
1587
1639
  position: "fixed",
1588
1640
  inset: 0,
1589
1641
  zIndex: 1199
1590
1642
  };
1591
- const rowStyle = {
1643
+ const modelsStyle = {
1644
+ maxHeight: "320px",
1645
+ overflowY: "auto",
1646
+ display: "flex",
1647
+ flexDirection: "column",
1648
+ gap: "2px"
1649
+ };
1650
+ const providerToggleStyle = {
1592
1651
  display: "flex",
1593
1652
  alignItems: "center",
1594
- 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",
1595
1661
  fontSize: "12px",
1596
- lineHeight: "18px",
1597
- color: "var(--dsw-alias-label-secondary)"
1662
+ cursor: "pointer",
1663
+ textAlign: "left"
1598
1664
  };
1599
- const labelStyle = {
1665
+ const providerNameStyle = {
1666
+ flex: "1 1 auto",
1667
+ fontWeight: 600
1668
+ };
1669
+ const providerMetaStyle = {
1600
1670
  flex: "0 0 auto",
1601
- 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 = {
1602
1712
  overflow: "hidden",
1603
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",
1604
1733
  whiteSpace: "nowrap",
1605
- 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"
1606
1772
  };
1607
1773
  const sliderStyle = {
1608
1774
  flex: "1 1 auto",
1609
- minWidth: "56px",
1775
+ minWidth: "48px",
1610
1776
  height: "14px",
1611
1777
  margin: "0",
1612
1778
  accentColor: "var(--dsw-alias-state-business-primary)",
@@ -1614,23 +1780,12 @@ window.__ModuleLoader__.load({
1614
1780
  };
1615
1781
  const valueStyle = {
1616
1782
  flex: "0 0 auto",
1617
- minWidth: "40px",
1783
+ minWidth: "36px",
1618
1784
  textAlign: "right",
1619
1785
  color: "var(--dsw-alias-label-primary)",
1620
1786
  fontFamily: "var(--ds-font-family-code, monospace)",
1621
1787
  fontVariantNumeric: "tabular-nums"
1622
1788
  };
1623
- const glyphButtonStyle = {
1624
- flex: "0 0 auto",
1625
- height: "18px",
1626
- padding: "0 5px",
1627
- border: "1px solid transparent",
1628
- borderRadius: "4px",
1629
- background: "transparent",
1630
- color: "var(--dsw-alias-label-tertiary)",
1631
- font: "inherit",
1632
- cursor: "pointer"
1633
- };
1634
1789
  const actionButtonStyle = {
1635
1790
  flex: "0 0 auto",
1636
1791
  height: "18px",
@@ -1642,11 +1797,6 @@ window.__ModuleLoader__.load({
1642
1797
  font: "inherit",
1643
1798
  cursor: "pointer"
1644
1799
  };
1645
- const customRowStyle = {
1646
- display: "flex",
1647
- alignItems: "center",
1648
- gap: "6px"
1649
- };
1650
1800
  const inputStyle = {
1651
1801
  flex: "1 1 auto",
1652
1802
  minWidth: "0",
@@ -1654,13 +1804,26 @@ window.__ModuleLoader__.load({
1654
1804
  padding: "2px 6px",
1655
1805
  border: "1px solid var(--dsw-alias-border-l2)",
1656
1806
  borderRadius: "5px",
1657
- background: "var(--dsw-alias-bg-surface, #fff)",
1807
+ background: "var(--dsw-alias-bg-layer-1)",
1658
1808
  color: "var(--dsw-alias-label-primary)",
1659
1809
  font: "inherit"
1660
1810
  };
1661
1811
  const errorStyle = {
1662
1812
  flex: "0 0 auto",
1663
- 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"
1664
1827
  };
1665
1828
  /** The user-layer `providers` value of the llm-pi-ai namespace, when present. */
1666
1829
  function providersOf(snapshot) {
@@ -1683,54 +1846,19 @@ window.__ModuleLoader__.load({
1683
1846
  ...defaultContextWindow === void 0 ? {} : { defaultContextWindow }
1684
1847
  };
1685
1848
  }
1686
- /**
1687
- * The stable trajectory-ledger selector (the `useTrajectory` seat): the seat
1688
- * memoizes its selection on the selector reference, so it must not be a fresh
1689
- * closure per render. The ledger is a store-owned array whose reference only
1690
- * moves when the trajectory changes.
1691
- * @param snapshot - the current trajectory snapshot.
1692
- * @returns the request ledger.
1693
- */
1694
- const selectRequests = (snapshot) => snapshot.requests;
1695
- /**
1696
- * The stable trajectory-view selector (the `useConversation` seat): selecting
1697
- * the view snapshot (a store-owned reference, not a derived object) keeps the
1698
- * selected value stable between snapshots — a selector that built a new object
1699
- * would re-render forever.
1700
- * @param snapshot - the current conversation snapshot.
1701
- * @returns the trajectory view snapshot, absent while the view is unregistered.
1702
- */
1703
- const selectTrajectory = (snapshot) => snapshot.views?.get?.("trajectory");
1704
- /**
1705
- * The current session's active model, taken from the trajectory ledger's
1706
- * latest assistant request prompt config. Absent for a blank session (no
1707
- * request yet) — the control then renders disabled.
1708
- * @param source - the request ledger, or a trajectory snapshot carrying it.
1709
- * @returns the provider/model pair, or undefined when the ledger has none.
1710
- */
1711
- function activeModelOf(source) {
1712
- const requests = Array.isArray(source) ? source ?? [] : typeof source === "object" && source !== null ? source.requests ?? [] : [];
1713
- for (let index = requests.length - 1; index >= 0; index -= 1) {
1714
- const config = requests[index]?.prompt?.config;
1715
- if (requests[index]?.purpose === "assistant" && typeof config?.provider === "string" && typeof config?.model === "string") return {
1716
- provider: config.provider,
1717
- model: config.model
1718
- };
1719
- }
1720
- }
1721
1849
  /** One model entry's declared contextWindow, when present. */
1722
1850
  function contextWindowOf(model) {
1723
1851
  const value = model["contextWindow"];
1724
1852
  return typeof value === "number" && Number.isFinite(value) && value > 0 ? value : void 0;
1725
1853
  }
1726
- /**
1727
- * The slider stop nearest to a committed token count; a window that matches no
1728
- * preset still parks the thumb on its closest stop.
1729
- * @param value - the committed context window, when one is set.
1730
- * @returns the stop index, or the unset park position.
1731
- */
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. */
1732
1860
  function stopIndexOf(value) {
1733
- if (value === void 0) return UNSET_STOP_INDEX;
1861
+ if (value === void 0) return Math.max(0, UNSET_STOP_INDEX);
1734
1862
  let best = 0;
1735
1863
  let bestDistance = Number.POSITIVE_INFINITY;
1736
1864
  CONTEXT_WINDOW_PRESETS.forEach((preset, index) => {
@@ -1743,111 +1871,99 @@ window.__ModuleLoader__.load({
1743
1871
  return best;
1744
1872
  }
1745
1873
  /**
1746
- * The composer context-window quick control. Renders nothing when this harness
1747
- * provides neither session seat, so a missing seat never leaves a dead control
1748
- * (or a crash) in the tool row.
1749
- * @param props - injected scopes, session standard seats, copy.
1750
- */
1751
- function ContextQuick(props) {
1752
- if (typeof props.useTrajectory === "function") return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(TrajectoryBound, {
1753
- ...props,
1754
- useTrajectory: props.useTrajectory
1755
- });
1756
- if (typeof props.useConversation === "function") return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(ConversationBound, {
1757
- ...props,
1758
- useConversation: props.useConversation
1759
- });
1760
- return null;
1761
- }
1762
- /**
1763
- * The trajectory-seat binding (DSH 0.1.2+).
1764
- * @param props - the control props plus the present trajectory seat.
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.
1765
1878
  */
1766
- function TrajectoryBound({ useTrajectory, ...rest }) {
1767
- return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(ContextQuickView, {
1768
- ...rest,
1769
- active: activeModelOf(useTrajectory(selectRequests))
1770
- });
1771
- }
1772
- /**
1773
- * The conversation-seat binding (harness lines without the trajectory seat).
1774
- * @param props - the control props plus the present conversation seat.
1775
- */
1776
- function ConversationBound({ useConversation, ...rest }) {
1777
- return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(ContextQuickView, {
1778
- ...rest,
1779
- active: activeModelOf(useConversation(selectTrajectory))
1780
- });
1781
- }
1782
- /**
1783
- * The bound control: a value pill that opens a one-row slider popover
1784
- * (preset slider, committed value, collapsed custom-integer editor, Clear).
1785
- * Custom gateways and official DeepSeek models are both supported (see module
1786
- * doc for the namespace each writes).
1787
- * @param props - injected scopes, the resolved active model, copy.
1788
- */
1789
- function ContextQuickView({ active, piAiScope, deepseekScope, t }) {
1790
- 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);
1791
1881
  const piSnapshot = (0, react.useSyncExternalStore)((listener) => piAiScope.subscribe(listener), () => piAiScope.getSnapshot());
1792
1882
  const dsSnapshot = (0, react.useSyncExternalStore)((listener) => deepseekScope.subscribe(listener), () => deepseekScope.getSnapshot());
1793
- const snapshot = official ? dsSnapshot : piSnapshot;
1794
- const readonly = snapshot.status === "unavailable" || !snapshot.writable;
1795
- const providers = official ? {} : providersOf(piSnapshot);
1796
- const dsSection = official ? deepseekSectionOf(dsSnapshot) : void 0;
1797
- let currentWindow;
1798
- let writableTarget = false;
1799
- if (official && active !== void 0) {
1800
- const models = dsSection?.models ?? [];
1801
- const index = models.findIndex((model) => model["id"] === active.model);
1802
- currentWindow = index >= 0 ? contextWindowOf(models[index]) : void 0;
1803
- if (currentWindow === void 0) currentWindow = dsSection?.defaultContextWindow;
1804
- writableTarget = true;
1805
- } else if (active !== void 0) {
1806
- const profile = providers[active.provider];
1807
- const model = profile !== void 0 && Array.isArray(profile.models) ? profile.models.find((candidate) => typeof candidate === "object" && candidate !== null && candidate["id"] === active.model) : void 0;
1808
- currentWindow = model === void 0 ? void 0 : contextWindowOf(model);
1809
- writableTarget = model !== void 0;
1810
- }
1811
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);
1812
1886
  const [draft, setDraft] = (0, react.useState)(null);
1813
1887
  const [custom, setCustom] = (0, react.useState)(false);
1814
1888
  const [raw, setRaw] = (0, react.useState)("");
1815
1889
  const [error, setError] = (0, react.useState)(null);
1816
1890
  const [busy, setBusy] = (0, react.useState)(false);
1817
- const disabled = readonly || busy || active === void 0 || !writableTarget;
1818
- const stop = draft ?? stopIndexOf(currentWindow);
1819
- /** Commit (or delete) the active model's context window. */
1820
- const commitWindow = (value) => {
1821
- if (active === void 0 || snapshot.status !== "ready" || !writableTarget) {
1822
- setDraft(null);
1823
- 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
+ };
1824
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) => {
1825
1943
  setBusy(true);
1826
- if (official) {
1827
- const models = (deepseekSectionOf(dsSnapshot).models ?? []).map((model) => ({ ...model }));
1828
- const index = models.findIndex((model) => model["id"] === active.model);
1829
- (index >= 0 ? deepseekScope.set("models", models.map((model, at) => {
1830
- 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;
1831
1953
  if (value === void 0) {
1832
- const rest = { ...model };
1954
+ const rest = { ...entry };
1833
1955
  delete rest["contextWindow"];
1834
1956
  return rest;
1835
1957
  }
1836
1958
  return {
1837
- ...model,
1959
+ ...entry,
1838
1960
  contextWindow: value
1839
1961
  };
1840
- })) : deepseekScope.set("defaultContextWindow", value === void 0 ? DEEPSEEK_DEFAULT_WINDOW : value)).then(() => {
1841
- setBusy(false);
1842
- setDraft(null);
1843
- }).catch(() => {
1844
- setBusy(false);
1845
- setDraft(null);
1846
- });
1962
+ })) : deepseekScope.set("defaultContextWindow", value === void 0 ? DEEPSEEK_DEFAULT_WINDOW : value)).then(done, done);
1847
1963
  return;
1848
1964
  }
1849
1965
  const next = structuredClone(providers);
1850
- const entry = next[active.provider]?.models?.find((candidate) => typeof candidate === "object" && candidate !== null && candidate["id"] === active.model);
1966
+ const entry = piModelEntry(next, provider, model);
1851
1967
  if (entry === void 0) {
1852
1968
  setBusy(false);
1853
1969
  setDraft(null);
@@ -1855,25 +1971,15 @@ window.__ModuleLoader__.load({
1855
1971
  }
1856
1972
  if (value === void 0) delete entry["contextWindow"];
1857
1973
  else entry["contextWindow"] = value;
1858
- piAiScope.set("providers", next).then(() => {
1859
- setBusy(false);
1860
- setDraft(null);
1861
- }).catch(() => {
1862
- setBusy(false);
1863
- setDraft(null);
1864
- });
1865
- };
1866
- /** Write the stop the gesture landed on; a drag only moves the draft. */
1867
- const commitStop = () => {
1868
- if (disabled || draft === null) return;
1869
- commitWindow(CONTEXT_WINDOW_PRESETS[draft]?.value);
1974
+ piAiScope.set("providers", next).then(done, done);
1870
1975
  };
1871
1976
  /** Validate and commit the custom input; empty clears. */
1872
1977
  const applyCustom = () => {
1978
+ if (editing === null) return;
1873
1979
  const trimmed = raw.trim();
1874
1980
  if (trimmed === "") {
1875
1981
  setError(null);
1876
- commitWindow(void 0);
1982
+ commitWindow(editing.provider, editing.model, void 0);
1877
1983
  return;
1878
1984
  }
1879
1985
  const validation = validateContextWindow(trimmed);
@@ -1882,138 +1988,308 @@ window.__ModuleLoader__.load({
1882
1988
  return;
1883
1989
  }
1884
1990
  setError(null);
1885
- 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);
1886
2002
  };
1887
- const value = draft === null ? currentWindow === void 0 ? t("input.context.unset") : formatContextWindow(currentWindow) : formatContextWindow(CONTEXT_WINDOW_PRESETS[draft]?.value ?? 0);
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
+ });
2023
+ };
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;
1888
2042
  return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
1889
- style: { position: "relative" },
1890
- children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("button", {
2043
+ ref: rootRef,
2044
+ style: rootStyle,
2045
+ children: [/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("button", {
1891
2046
  type: "button",
1892
- disabled,
2047
+ style: triggerStyle,
1893
2048
  "aria-expanded": open,
1894
- "aria-label": t("input.context.title"),
1895
- title: active === void 0 ? t("input.context.noModel") : `${active.provider}/${active.model}`,
1896
- style: {
1897
- ...pillStyle,
1898
- cursor: disabled ? "default" : "pointer",
1899
- opacity: disabled ? .55 : 1
1900
- },
2049
+ "aria-haspopup": "dialog",
2050
+ "aria-label": t("model.panel.choose"),
2051
+ title: state.current === null ? triggerLabel : `${state.current.provider}/${triggerLabel}`,
1901
2052
  onClick: () => {
1902
- setOpen((value) => !value);
1903
- setError(null);
2053
+ if (open) close();
2054
+ else {
2055
+ setOpen(true);
2056
+ setError(null);
2057
+ }
1904
2058
  },
1905
- 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
+ ]
1906
2073
  }), open ? /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(react_jsx_runtime.Fragment, { children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
1907
2074
  style: backdropStyle,
1908
- onClick: () => {
1909
- setOpen(false);
1910
- setError(null);
1911
- }
2075
+ onClick: close
1912
2076
  }), /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
1913
2077
  style: popStyle,
1914
- role: "group",
1915
- "aria-label": t("input.context.title"),
2078
+ role: "dialog",
2079
+ "aria-label": t("model.panel.choose"),
1916
2080
  children: [/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
1917
- style: rowStyle,
2081
+ style: modelsStyle,
1918
2082
  children: [
1919
- /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
1920
- style: labelStyle,
1921
- title: t("input.context.globalHint"),
1922
- 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")
1923
2086
  }),
1924
- /* @__PURE__ */ (0, react_jsx_runtime.jsx)("input", {
1925
- type: "range",
1926
- min: 0,
1927
- max: CONTEXT_WINDOW_PRESETS.length - 1,
1928
- step: 1,
1929
- value: stop,
1930
- disabled,
1931
- "aria-label": t("input.context.title"),
1932
- style: {
1933
- ...sliderStyle,
1934
- cursor: disabled ? "default" : "pointer",
1935
- opacity: disabled ? .55 : 1
1936
- },
1937
- onChange: (event) => {
1938
- setDraft(Number(event.currentTarget.value));
1939
- },
1940
- onPointerUp: commitStop,
1941
- onKeyUp: commitStop,
1942
- onBlur: commitStop
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")
1943
2090
  }),
1944
- /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
1945
- style: valueStyle,
1946
- children: value
1947
- }),
1948
- /* @__PURE__ */ (0, react_jsx_runtime.jsx)("button", {
1949
- type: "button",
1950
- disabled,
1951
- "aria-label": t("input.context.custom"),
1952
- "aria-expanded": custom,
1953
- title: t("input.context.custom"),
1954
- style: {
1955
- ...glyphButtonStyle,
1956
- cursor: disabled ? "default" : "pointer",
1957
- opacity: disabled ? .55 : 1
1958
- },
1959
- onClick: () => {
1960
- setCustom((open) => !open);
1961
- setError(null);
1962
- },
1963
- children: "⋯"
1964
- }),
1965
- /* @__PURE__ */ (0, react_jsx_runtime.jsx)("button", {
1966
- type: "button",
1967
- disabled: disabled || currentWindow === void 0,
1968
- style: {
1969
- ...actionButtonStyle,
1970
- cursor: disabled || currentWindow === void 0 ? "default" : "pointer",
1971
- opacity: disabled || currentWindow === void 0 ? .55 : 1
1972
- },
1973
- onClick: () => {
1974
- setDraft(null);
1975
- setError(null);
1976
- setRaw("");
1977
- commitWindow(void 0);
1978
- },
1979
- children: t("input.context.clear")
1980
- })
1981
- ]
1982
- }), custom ? /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
1983
- style: customRowStyle,
1984
- children: [
1985
- /* @__PURE__ */ (0, react_jsx_runtime.jsx)("input", {
1986
- type: "text",
1987
- inputMode: "numeric",
1988
- value: raw,
1989
- disabled,
1990
- placeholder: t("input.context.customPlaceholder"),
1991
- "aria-label": t("input.context.customPlaceholder"),
1992
- style: inputStyle,
1993
- onChange: (event) => {
1994
- setRaw(event.currentTarget.value);
1995
- },
1996
- onKeyDown: (event) => {
1997
- if (event.key === "Enter") applyCustom();
1998
- }
1999
- }),
2000
- /* @__PURE__ */ (0, react_jsx_runtime.jsx)("button", {
2001
- type: "button",
2002
- disabled,
2003
- style: {
2004
- ...actionButtonStyle,
2005
- cursor: disabled ? "default" : "pointer",
2006
- opacity: disabled ? .55 : 1
2007
- },
2008
- onClick: applyCustom,
2009
- 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);
2010
2282
  }),
2011
- error !== null && /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
2012
- style: errorStyle,
2013
- 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")
2014
2286
  })
2015
2287
  ]
2016
- }) : 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
+ })]
2017
2293
  })] }) : null]
2018
2294
  });
2019
2295
  }
@@ -2028,12 +2304,11 @@ window.__ModuleLoader__.load({
2028
2304
  "settingsScope"
2029
2305
  ];
2030
2306
  /**
2031
- * Client plugin body: dictionaries plus the settings card registration.
2307
+ * Client plugin body: dictionaries, the settings card, and the model-seat
2308
+ * panel registration.
2032
2309
  * @param ctx - client root context.
2033
2310
  */
2034
2311
  function apply(ctx) {
2035
- const slots = ctx.get("slots");
2036
- if (slots === void 0) return;
2037
2312
  ctx.effect(() => {
2038
2313
  const disposers = [
2039
2314
  ctx.locale.register(NS, {
@@ -2047,8 +2322,8 @@ window.__ModuleLoader__.load({
2047
2322
  for (const dispose of disposers) dispose();
2048
2323
  };
2049
2324
  }, "dsh-thinking-levels: dictionaries");
2050
- slots.inject("settings.plugin.item", function* () {
2051
- yield slots.register({
2325
+ ctx.slots.inject("settings.plugin.item", function* () {
2326
+ yield ctx.slots.register({
2052
2327
  name: "settings.plugin.item",
2053
2328
  id: THINKING_LEVELS_NS,
2054
2329
  key: THINKING_LEVELS_NS,
@@ -2061,18 +2336,35 @@ window.__ModuleLoader__.load({
2061
2336
  }
2062
2337
  }, ThinkingLevelsCard);
2063
2338
  });
2064
- slots.inject("conversation.input.right", function* () {
2065
- yield slots.register({
2066
- name: "conversation.input.right",
2067
- id: "context-window-quick",
2068
- locale: NS,
2069
- inject: () => {
2070
- return {
2071
- piAiScope: ctx.settingsScope.bind({ namespace: "llm-pi-ai" }),
2072
- deepseekScope: ctx.settingsScope.bind({ namespace: "llm-deepseek" })
2073
- };
2074
- }
2075
- }, 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
+ });
2076
2368
  });
2077
2369
  }
2078
2370
  //#endregion