dsh-thinking-levels 0.7.2-beta.1 → 2.0.0-beta.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
@@ -68,7 +68,8 @@ window.__ModuleLoader__.load({
68
68
  "card.capabilities.contextHint": "选择预设或输入整数(2000–1000000),写入 llm-pi-ai 供上下文压力/压缩使用,无需重启即对下一请求生效。",
69
69
  "input.context.title": "上下文窗口",
70
70
  "input.context.globalHint": "全局生效:作用于所有使用该模型的会话(清除可恢复默认)",
71
- "input.context.unset": "ctx 未设",
71
+ "input.context.unset": "未设",
72
+ "input.context.custom": "自定义",
72
73
  "input.context.noModel": "暂无会话模型",
73
74
  "input.context.customPlaceholder": "自定义整数,如 256000",
74
75
  "input.context.apply": "应用",
@@ -135,7 +136,8 @@ window.__ModuleLoader__.load({
135
136
  "card.capabilities.contextHint": "Pick a preset or enter an integer (2000–1000000); written to llm-pi-ai for context pressure/compaction and applied to the next request without a restart.",
136
137
  "input.context.title": "Context window",
137
138
  "input.context.globalHint": "Applies globally to every session using this model (Clear restores the default)",
138
- "input.context.unset": "ctx unset",
139
+ "input.context.unset": "Unset",
140
+ "input.context.custom": "Custom",
139
141
  "input.context.noModel": "No session model yet",
140
142
  "input.context.customPlaceholder": "Custom integer, e.g. 256000",
141
143
  "input.context.apply": "Apply",
@@ -202,7 +204,8 @@ window.__ModuleLoader__.load({
202
204
  "card.capabilities.contextHint": "プリセットを選ぶか整数を入力(2000–1000000)。llm-pi-ai に書き込まれ、コンテキスト圧力/圧縮に使用され、再起動なしで次のリクエストに反映されます。",
203
205
  "input.context.title": "コンテキストウィンドウ",
204
206
  "input.context.globalHint": "グローバルに有効:このモデルを使用するすべてのセッションに適用されます(クリアで既定値に戻ります)",
205
- "input.context.unset": "ctx 未設定",
207
+ "input.context.unset": "未設定",
208
+ "input.context.custom": "カスタム",
206
209
  "input.context.noModel": "セッションモデルがまだありません",
207
210
  "input.context.customPlaceholder": "カスタム整数(例:256000)",
208
211
  "input.context.apply": "適用",
@@ -269,7 +272,8 @@ window.__ModuleLoader__.load({
269
272
  "card.capabilities.contextHint": "프리셋을 선택하거나 정수를 입력하세요(2000–1000000). llm-pi-ai에 기록되어 컨텍스트 압력/압축에 사용되며, 재시작 없이 다음 요청에 반영됩니다.",
270
273
  "input.context.title": "컨텍스트 창",
271
274
  "input.context.globalHint": "전역 적용: 이 모델을 사용하는 모든 세션에 적용됩니다(지우면 기본값 복원)",
272
- "input.context.unset": "ctx 미설정",
275
+ "input.context.unset": "미설정",
276
+ "input.context.custom": "사용자 지정",
273
277
  "input.context.noModel": "세션 모델이 아직 없습니다",
274
278
  "input.context.customPlaceholder": "사용자 지정 정수(예: 256000)",
275
279
  "input.context.apply": "적용",
@@ -422,7 +426,7 @@ window.__ModuleLoader__.load({
422
426
  "string-thinking",
423
427
  "ant-ling"
424
428
  ];
425
- const rowStyle = {
429
+ const rowStyle$1 = {
426
430
  display: "flex",
427
431
  alignItems: "center",
428
432
  justifyContent: "space-between",
@@ -443,7 +447,7 @@ window.__ModuleLoader__.load({
443
447
  padding: "3px 8px",
444
448
  fontSize: "13px"
445
449
  };
446
- const sectionStyle = {
450
+ const sectionStyle$1 = {
447
451
  marginTop: "14px",
448
452
  paddingTop: "12px",
449
453
  borderTop: "1px solid var(--dsw-alias-border-l2)"
@@ -459,7 +463,7 @@ window.__ModuleLoader__.load({
459
463
  lineHeight: "18px",
460
464
  color: "var(--dsw-alias-label-tertiary)"
461
465
  };
462
- const hintStyle$1 = {
466
+ const hintStyle = {
463
467
  margin: "6px 0 0",
464
468
  fontSize: "12px",
465
469
  lineHeight: "18px",
@@ -879,19 +883,19 @@ window.__ModuleLoader__.load({
879
883
  commitContextWindow(entry, void 0);
880
884
  };
881
885
  if (unavailable) return /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
882
- style: sectionStyle,
886
+ style: sectionStyle$1,
883
887
  children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)("p", {
884
- style: hintStyle$1,
888
+ style: hintStyle,
885
889
  children: t("card.capabilities.unavailable")
886
890
  })
887
891
  });
888
892
  if (allEntries.length === 0) return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
889
- style: sectionStyle,
893
+ style: sectionStyle$1,
890
894
  children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("p", {
891
895
  style: fieldLabelStyle,
892
896
  children: t("card.capabilities")
893
897
  }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("p", {
894
- style: hintStyle$1,
898
+ style: hintStyle,
895
899
  children: t("card.capabilities.empty")
896
900
  })]
897
901
  });
@@ -899,14 +903,14 @@ window.__ModuleLoader__.load({
899
903
  const visible = needle === "" ? allEntries : allEntries.filter((entry) => entry.modelId.toLowerCase().includes(needle) || entry.providerId.toLowerCase().includes(needle));
900
904
  const providerIds = [...new Set(visible.map((entry) => entry.providerId))];
901
905
  return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
902
- style: sectionStyle,
906
+ style: sectionStyle$1,
903
907
  children: [
904
908
  /* @__PURE__ */ (0, react_jsx_runtime.jsx)("p", {
905
909
  style: fieldLabelStyle,
906
910
  children: t("card.capabilities")
907
911
  }),
908
912
  /* @__PURE__ */ (0, react_jsx_runtime.jsx)("p", {
909
- style: hintStyle$1,
913
+ style: hintStyle,
910
914
  children: t("card.capabilities.hint")
911
915
  }),
912
916
  /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
@@ -941,7 +945,7 @@ window.__ModuleLoader__.load({
941
945
  }, preset.key))]
942
946
  }),
943
947
  visible.length === 0 ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)("p", {
944
- style: hintStyle$1,
948
+ style: hintStyle,
945
949
  children: t("card.capabilities.noMatches")
946
950
  }) : providerIds.map((providerId) => {
947
951
  const providerEntries = visible.filter((entry) => entry.providerId === providerId);
@@ -1320,7 +1324,7 @@ window.__ModuleLoader__.load({
1320
1324
  }, providerId);
1321
1325
  }),
1322
1326
  readonly ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)("p", {
1323
- style: hintStyle$1,
1327
+ style: hintStyle,
1324
1328
  children: t("card.readonly")
1325
1329
  }) : null
1326
1330
  ]
@@ -1417,7 +1421,7 @@ window.__ModuleLoader__.load({
1417
1421
  children: t("card.unavailable")
1418
1422
  }) : /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(react_jsx_runtime.Fragment, { children: [
1419
1423
  /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
1420
- style: rowStyle,
1424
+ style: rowStyle$1,
1421
1425
  children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("label", {
1422
1426
  htmlFor: "plugin-config-thinking-levels-level",
1423
1427
  style: labelStyle$1,
@@ -1437,7 +1441,7 @@ window.__ModuleLoader__.load({
1437
1441
  })]
1438
1442
  }),
1439
1443
  /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
1440
- style: rowStyle,
1444
+ style: rowStyle$1,
1441
1445
  children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("label", {
1442
1446
  htmlFor: "plugin-config-thinking-levels-enabled",
1443
1447
  style: labelStyle$1,
@@ -1453,7 +1457,7 @@ window.__ModuleLoader__.load({
1453
1457
  })]
1454
1458
  }),
1455
1459
  /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
1456
- style: rowStyle,
1460
+ style: rowStyle$1,
1457
1461
  children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("label", {
1458
1462
  htmlFor: "plugin-config-thinking-levels-downgrade",
1459
1463
  style: labelStyle$1,
@@ -1469,7 +1473,7 @@ window.__ModuleLoader__.load({
1469
1473
  })]
1470
1474
  }),
1471
1475
  /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
1472
- style: rowStyle,
1476
+ style: rowStyle$1,
1473
1477
  children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("label", {
1474
1478
  htmlFor: "plugin-config-thinking-levels-upgrade",
1475
1479
  style: labelStyle$1,
@@ -1504,13 +1508,15 @@ window.__ModuleLoader__.load({
1504
1508
  //#endregion
1505
1509
  //#region src/client/context-quick.tsx
1506
1510
  /**
1507
- * Context-window quick control for the composer tool row
1508
- * (`conversation.input.right`, the seat just left of the send button and next
1509
- * to the model/effort select).
1511
+ * Context-window quick control for the model menu card
1512
+ * (`conversation.input.model.section`, rendered under the Model /
1513
+ * Reasoning-effort rows of the root pane).
1510
1514
  *
1511
- * It targets the CURRENT session's active model (read from the trajectory
1512
- * view's latest assistant request) and lets the user cap that model's context
1513
- * window on the fly — presets, a custom integer, or clear to restore.
1515
+ * It targets the CURRENT session's active model (read through the session
1516
+ * `useTrajectory` standard seat) and lets the user cap that model's context
1517
+ * window on the fly. The row is deliberately compact: one label, a slider over
1518
+ * the shared presets, the committed value, a collapsed custom-integer editor
1519
+ * and Clear — no title block and no preset button grid.
1514
1520
  *
1515
1521
  * Two model families are served, each with its own writable settings
1516
1522
  * namespace (both consumed live by `resolveModelInfo(...).context.contextWindow`,
@@ -1521,107 +1527,100 @@ window.__ModuleLoader__.load({
1521
1527
  * namespace): writes the catalog model's `contextWindow` when the model is
1522
1528
  * listed, otherwise caps via `defaultContextWindow`.
1523
1529
  *
1524
- * Kept dependency-free beyond react + the injected scopes: the trigger is a
1525
- * plain pill, the popover renders inline (absolutely positioned above the tool
1526
- * row), and validation reuses the shared `validateContextWindow`.
1530
+ * Write discipline: dragging the slider only moves a local draft; the settings
1531
+ * write happens once per gesture (pointer release, key release, blur), so a
1532
+ * drag never floods the host with intermediate values.
1533
+ *
1534
+ * Kept dependency-free beyond react + the injected scopes: plain HTML controls
1535
+ * with token-based inline styling, and validation reuses the shared
1536
+ * `validateContextWindow`.
1527
1537
  */
1528
1538
  /** The official DeepSeek provider route owned by the llm-deepseek adapter. */
1529
1539
  const DEEPSEEK_PROVIDER = "deepseek-official";
1530
1540
  /** llm-deepseek's native default context capacity (DEFAULT_CONTEXT_WINDOW). */
1531
1541
  const DEEPSEEK_DEFAULT_WINDOW = 1e6;
1532
- const pillStyle = {
1533
- display: "inline-flex",
1534
- alignItems: "center",
1535
- gap: "4px",
1536
- height: "24px",
1537
- padding: "0 8px",
1538
- background: "var(--dsw-alias-bg-surface, #fff)",
1539
- color: "var(--dsw-alias-label-secondary)",
1540
- border: "1px solid var(--dsw-alias-border-l2)",
1541
- borderRadius: "6px",
1542
- fontSize: "11px",
1543
- lineHeight: "16px",
1544
- fontFamily: "var(--ds-font-family-code, monospace)",
1545
- cursor: "pointer",
1546
- whiteSpace: "nowrap"
1547
- };
1548
- const popStyle = {
1549
- position: "absolute",
1550
- bottom: "calc(100% + 8px)",
1551
- right: "0",
1552
- zIndex: 1200,
1553
- minWidth: "240px",
1554
- padding: "10px",
1555
- background: "var(--dsw-alias-bg-layer-3, rgba(127,127,127,0.05))",
1556
- color: "var(--dsw-alias-label-primary)",
1557
- border: "1px solid var(--dsw-alias-border-l2)",
1558
- borderRadius: "10px",
1559
- boxShadow: "0 8px 28px rgba(0,0,0,0.18)",
1542
+ /** Slider stop an unset window parks on: the thumb needs a position, the readout stays "unset". */
1543
+ const UNSET_STOP_INDEX = CONTEXT_WINDOW_PRESETS.findIndex((preset) => preset.value === 256e3);
1544
+ const sectionStyle = {
1560
1545
  display: "flex",
1561
1546
  flexDirection: "column",
1562
- gap: "8px"
1563
- };
1564
- const backdropStyle = {
1565
- position: "fixed",
1566
- inset: 0,
1567
- zIndex: 1199
1547
+ gap: "6px",
1548
+ marginTop: "4px",
1549
+ paddingTop: "7px",
1550
+ borderTop: "1px solid var(--dsw-alias-border-l1)"
1568
1551
  };
1569
- const labelStyle = {
1570
- margin: 0,
1552
+ const rowStyle = {
1553
+ display: "flex",
1554
+ alignItems: "center",
1555
+ gap: "8px",
1571
1556
  fontSize: "12px",
1572
1557
  lineHeight: "18px",
1573
1558
  color: "var(--dsw-alias-label-secondary)"
1574
1559
  };
1575
- const hintStyle = {
1576
- margin: 0,
1577
- fontSize: "11px",
1578
- lineHeight: "16px",
1560
+ const labelStyle = {
1561
+ flex: "0 0 auto",
1562
+ minWidth: "0",
1563
+ overflow: "hidden",
1564
+ textOverflow: "ellipsis",
1565
+ whiteSpace: "nowrap",
1579
1566
  color: "var(--dsw-alias-label-tertiary)"
1580
1567
  };
1581
- const presetRowStyle = {
1582
- display: "flex",
1583
- flexWrap: "wrap",
1584
- gap: "5px"
1568
+ const sliderStyle = {
1569
+ flex: "1 1 auto",
1570
+ minWidth: "56px",
1571
+ height: "14px",
1572
+ margin: "0",
1573
+ accentColor: "var(--dsw-alias-state-business-primary)",
1574
+ cursor: "pointer"
1585
1575
  };
1586
- const presetStyle = {
1587
- height: "22px",
1588
- padding: "0 8px",
1589
- background: "var(--dsw-alias-bg-surface, #fff)",
1590
- color: "var(--dsw-alias-label-secondary)",
1591
- border: "1px solid var(--dsw-alias-border-l2)",
1592
- borderRadius: "5px",
1593
- fontSize: "11px",
1594
- lineHeight: "16px",
1576
+ const valueStyle = {
1577
+ flex: "0 0 auto",
1578
+ minWidth: "40px",
1579
+ textAlign: "right",
1580
+ color: "var(--dsw-alias-label-primary)",
1595
1581
  fontFamily: "var(--ds-font-family-code, monospace)",
1582
+ fontVariantNumeric: "tabular-nums"
1583
+ };
1584
+ const glyphButtonStyle = {
1585
+ flex: "0 0 auto",
1586
+ height: "18px",
1587
+ padding: "0 5px",
1588
+ border: "1px solid transparent",
1589
+ borderRadius: "4px",
1590
+ background: "transparent",
1591
+ color: "var(--dsw-alias-label-tertiary)",
1592
+ font: "inherit",
1596
1593
  cursor: "pointer"
1597
1594
  };
1595
+ const actionButtonStyle = {
1596
+ flex: "0 0 auto",
1597
+ height: "18px",
1598
+ padding: "0 6px",
1599
+ border: "1px solid transparent",
1600
+ borderRadius: "4px",
1601
+ background: "transparent",
1602
+ color: "var(--dsw-alias-label-secondary)",
1603
+ font: "inherit",
1604
+ cursor: "pointer"
1605
+ };
1606
+ const customRowStyle = {
1607
+ display: "flex",
1608
+ alignItems: "center",
1609
+ gap: "6px"
1610
+ };
1598
1611
  const inputStyle = {
1599
1612
  flex: "1 1 auto",
1600
1613
  minWidth: "0",
1601
- background: "var(--dsw-alias-bg-surface, #fff)",
1602
- color: "var(--dsw-alias-label-primary)",
1614
+ boxSizing: "border-box",
1615
+ padding: "2px 6px",
1603
1616
  border: "1px solid var(--dsw-alias-border-l2)",
1604
1617
  borderRadius: "5px",
1605
- padding: "3px 8px",
1606
- fontSize: "12px",
1607
- fontFamily: "var(--ds-font-family-code, monospace)",
1608
- boxSizing: "border-box"
1609
- };
1610
- const actionStyle = {
1611
- height: "24px",
1612
- padding: "0 10px",
1613
1618
  background: "var(--dsw-alias-bg-surface, #fff)",
1614
1619
  color: "var(--dsw-alias-label-primary)",
1615
- border: "1px solid var(--dsw-alias-border-l2)",
1616
- borderRadius: "5px",
1617
- fontSize: "12px",
1618
- lineHeight: "18px",
1619
- cursor: "pointer"
1620
+ font: "inherit"
1620
1621
  };
1621
1622
  const errorStyle = {
1622
- margin: 0,
1623
- fontSize: "11px",
1624
- lineHeight: "16px",
1623
+ flex: "0 0 auto",
1625
1624
  color: "var(--dsw-alias-danger, #e5484d)"
1626
1625
  };
1627
1626
  /** The user-layer `providers` value of the llm-pi-ai namespace, when present. */
@@ -1646,16 +1645,26 @@ window.__ModuleLoader__.load({
1646
1645
  };
1647
1646
  }
1648
1647
  /**
1649
- * The current session's active model, reconstructed from the trajectory view's
1648
+ * The stable trajectory selector: the seat memoizes its selection on the
1649
+ * selector reference, so it must not be a fresh closure per render. Selecting
1650
+ * the request ledger (a snapshot-owned array, not a derived object) keeps the
1651
+ * selected value reference-stable between snapshots — a selector that built a
1652
+ * new object would re-render forever.
1653
+ * @param snapshot - the current Trajectory view snapshot.
1654
+ * @returns the assembled request ledger.
1655
+ */
1656
+ const selectRequests = (snapshot) => snapshot.requests;
1657
+ /**
1658
+ * The current session's active model, taken from the trajectory ledger's
1650
1659
  * latest assistant request prompt config. Absent for a blank session (no
1651
1660
  * request yet) — the control then renders read-only/disabled.
1661
+ * @param requests - the trajectory ledger's request views.
1652
1662
  */
1653
- function activeModelOf(session) {
1654
- if (typeof session !== "object" || session === null) return void 0;
1655
- const requests = (session.views?.get?.("trajectory"))?.requests ?? [];
1656
- for (let index = requests.length - 1; index >= 0; index -= 1) {
1657
- const config = requests[index]?.prompt?.config;
1658
- if (requests[index]?.purpose === "assistant" && typeof config?.provider === "string" && typeof config?.model === "string") return {
1663
+ function activeModelOf(requests) {
1664
+ const list = requests ?? [];
1665
+ for (let index = list.length - 1; index >= 0; index -= 1) {
1666
+ const config = list[index]?.prompt?.config;
1667
+ if (list[index]?.purpose === "assistant" && typeof config?.provider === "string" && typeof config?.model === "string") return {
1659
1668
  provider: config.provider,
1660
1669
  model: config.model
1661
1670
  };
@@ -1667,15 +1676,33 @@ window.__ModuleLoader__.load({
1667
1676
  return typeof value === "number" && Number.isFinite(value) && value > 0 ? value : void 0;
1668
1677
  }
1669
1678
  /**
1670
- * The composer context-window quick control: a pill showing the current
1671
- * session model's context window that opens an inline popover with preset
1672
- * quick-picks, a custom integer input and a clear (restore default) action.
1673
- * Custom gateways and official DeepSeek models are both supported (see module
1674
- * doc for the namespace each writes).
1679
+ * The slider stop nearest to a committed token count; a window that matches no
1680
+ * preset (typed through the card) still parks the thumb on its closest stop.
1681
+ * @param value - the committed context window, when one is set.
1682
+ * @returns the stop index, or the unset park position.
1683
+ */
1684
+ function stopIndexOf(value) {
1685
+ if (value === void 0) return UNSET_STOP_INDEX;
1686
+ let best = 0;
1687
+ let bestDistance = Number.POSITIVE_INFINITY;
1688
+ CONTEXT_WINDOW_PRESETS.forEach((preset, index) => {
1689
+ const distance = Math.abs(preset.value - value);
1690
+ if (distance < bestDistance) {
1691
+ bestDistance = distance;
1692
+ best = index;
1693
+ }
1694
+ });
1695
+ return best;
1696
+ }
1697
+ /**
1698
+ * The model card's context-window section: a preset slider, the committed
1699
+ * value, a collapsed custom-integer editor and Clear. Custom gateways and
1700
+ * official DeepSeek models are both supported (see module doc for the
1701
+ * namespace each writes).
1675
1702
  * @param props - injected scopes, session standard seats, copy.
1676
1703
  */
1677
- function ContextQuick({ useSession, piAiScope, deepseekScope, t }) {
1678
- const active = activeModelOf(useSession());
1704
+ function ContextQuick({ useTrajectory, piAiScope, deepseekScope, t }) {
1705
+ const active = activeModelOf(useTrajectory(selectRequests));
1679
1706
  const official = active !== void 0 && active.provider === DEEPSEEK_PROVIDER;
1680
1707
  const piSnapshot = (0, react.useSyncExternalStore)((listener) => piAiScope.subscribe(listener), () => piAiScope.getSnapshot());
1681
1708
  const dsSnapshot = (0, react.useSyncExternalStore)((listener) => deepseekScope.subscribe(listener), () => deepseekScope.getSnapshot());
@@ -1697,14 +1724,19 @@ window.__ModuleLoader__.load({
1697
1724
  currentWindow = model === void 0 ? void 0 : contextWindowOf(model);
1698
1725
  writableTarget = model !== void 0;
1699
1726
  }
1700
- const [open, setOpen] = (0, react.useState)(false);
1727
+ const [draft, setDraft] = (0, react.useState)(null);
1728
+ const [custom, setCustom] = (0, react.useState)(false);
1701
1729
  const [raw, setRaw] = (0, react.useState)("");
1702
1730
  const [error, setError] = (0, react.useState)(null);
1703
1731
  const [busy, setBusy] = (0, react.useState)(false);
1704
1732
  const disabled = readonly || busy || active === void 0 || !writableTarget;
1733
+ const stop = draft ?? stopIndexOf(currentWindow);
1705
1734
  /** Commit (or delete) the active model's context window. */
1706
1735
  const commitWindow = (value) => {
1707
- if (active === void 0 || snapshot.status !== "ready" || !writableTarget) return;
1736
+ if (active === void 0 || snapshot.status !== "ready" || !writableTarget) {
1737
+ setDraft(null);
1738
+ return;
1739
+ }
1708
1740
  setBusy(true);
1709
1741
  if (official) {
1710
1742
  const models = (deepseekSectionOf(dsSnapshot).models ?? []).map((model) => ({ ...model }));
@@ -1722,8 +1754,10 @@ window.__ModuleLoader__.load({
1722
1754
  };
1723
1755
  })) : deepseekScope.set("defaultContextWindow", value === void 0 ? DEEPSEEK_DEFAULT_WINDOW : value)).then(() => {
1724
1756
  setBusy(false);
1757
+ setDraft(null);
1725
1758
  }).catch(() => {
1726
1759
  setBusy(false);
1760
+ setDraft(null);
1727
1761
  });
1728
1762
  return;
1729
1763
  }
@@ -1731,21 +1765,23 @@ window.__ModuleLoader__.load({
1731
1765
  const entry = next[active.provider]?.models?.find((candidate) => typeof candidate === "object" && candidate !== null && candidate["id"] === active.model);
1732
1766
  if (entry === void 0) {
1733
1767
  setBusy(false);
1768
+ setDraft(null);
1734
1769
  return;
1735
1770
  }
1736
1771
  if (value === void 0) delete entry["contextWindow"];
1737
1772
  else entry["contextWindow"] = value;
1738
1773
  piAiScope.set("providers", next).then(() => {
1739
1774
  setBusy(false);
1775
+ setDraft(null);
1740
1776
  }).catch(() => {
1741
1777
  setBusy(false);
1778
+ setDraft(null);
1742
1779
  });
1743
1780
  };
1744
- /** Pick one preset immediately. */
1745
- const pickPreset = (value) => {
1746
- setRaw(String(value));
1747
- setError(null);
1748
- commitWindow(value);
1781
+ /** Write the stop the gesture landed on; a drag only moves the draft. */
1782
+ const commitStop = () => {
1783
+ if (disabled || draft === null) return;
1784
+ commitWindow(CONTEXT_WINDOW_PRESETS[draft]?.value);
1749
1785
  };
1750
1786
  /** Validate and commit the custom input; empty clears. */
1751
1787
  const applyCustom = () => {
@@ -1763,116 +1799,113 @@ window.__ModuleLoader__.load({
1763
1799
  setError(null);
1764
1800
  commitWindow(validation.value);
1765
1801
  };
1766
- const triggerLabel = currentWindow === void 0 ? t("input.context.unset") : formatContextWindow(currentWindow);
1767
- return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
1768
- style: {
1769
- position: "relative",
1770
- display: "inline-flex"
1771
- },
1772
- children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("button", {
1773
- type: "button",
1774
- disabled,
1775
- style: {
1776
- ...pillStyle,
1777
- cursor: disabled ? "default" : "pointer",
1778
- opacity: disabled ? .55 : 1
1779
- },
1780
- title: active === void 0 ? t("input.context.noModel") : `${active.provider}/${active.model}`,
1781
- onClick: () => {
1782
- setOpen((current) => !current);
1783
- },
1784
- children: triggerLabel
1785
- }), open ? /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(react_jsx_runtime.Fragment, { children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
1786
- style: backdropStyle,
1787
- onClick: () => setOpen(false)
1788
- }), /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
1789
- style: popStyle,
1790
- role: "dialog",
1791
- "aria-label": t("input.context.title"),
1802
+ const value = draft === null ? currentWindow === void 0 ? t("input.context.unset") : formatContextWindow(currentWindow) : formatContextWindow(CONTEXT_WINDOW_PRESETS[draft]?.value ?? 0);
1803
+ return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("section", {
1804
+ style: sectionStyle,
1805
+ role: "group",
1806
+ "aria-label": t("input.context.title"),
1807
+ children: [/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
1808
+ style: rowStyle,
1792
1809
  children: [
1793
- /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("p", {
1810
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
1794
1811
  style: labelStyle,
1795
- children: [t("input.context.title"), active !== void 0 ? ` · ${active.provider}/${active.model}` : ""]
1812
+ title: t("input.context.globalHint"),
1813
+ children: t("input.context.title")
1796
1814
  }),
1797
- /* @__PURE__ */ (0, react_jsx_runtime.jsx)("p", {
1798
- style: hintStyle,
1799
- children: t("input.context.globalHint")
1815
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)("input", {
1816
+ type: "range",
1817
+ min: 0,
1818
+ max: CONTEXT_WINDOW_PRESETS.length - 1,
1819
+ step: 1,
1820
+ value: stop,
1821
+ disabled,
1822
+ "aria-label": t("input.context.title"),
1823
+ title: active === void 0 ? t("input.context.noModel") : `${active.provider}/${active.model}`,
1824
+ style: {
1825
+ ...sliderStyle,
1826
+ cursor: disabled ? "default" : "pointer",
1827
+ opacity: disabled ? .55 : 1
1828
+ },
1829
+ onChange: (event) => {
1830
+ setDraft(Number(event.currentTarget.value));
1831
+ },
1832
+ onPointerUp: commitStop,
1833
+ onKeyUp: commitStop,
1834
+ onBlur: commitStop
1800
1835
  }),
1801
- /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
1802
- style: presetRowStyle,
1803
- children: CONTEXT_WINDOW_PRESETS.map((preset) => /* @__PURE__ */ (0, react_jsx_runtime.jsx)("button", {
1804
- type: "button",
1805
- disabled,
1806
- style: {
1807
- ...presetStyle,
1808
- cursor: disabled ? "default" : "pointer",
1809
- opacity: disabled ? .5 : 1
1810
- },
1811
- onClick: () => pickPreset(preset.value),
1812
- children: preset.label
1813
- }, preset.value))
1836
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
1837
+ style: valueStyle,
1838
+ children: value
1814
1839
  }),
1815
- /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
1840
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)("button", {
1841
+ type: "button",
1842
+ disabled,
1843
+ "aria-label": t("input.context.custom"),
1844
+ "aria-expanded": custom,
1845
+ title: t("input.context.custom"),
1816
1846
  style: {
1817
- display: "flex",
1818
- gap: "6px",
1819
- alignItems: "center"
1847
+ ...glyphButtonStyle,
1848
+ cursor: disabled ? "default" : "pointer",
1849
+ opacity: disabled ? .55 : 1
1820
1850
  },
1821
- children: [
1822
- /* @__PURE__ */ (0, react_jsx_runtime.jsx)("input", {
1823
- type: "text",
1824
- value: raw,
1825
- disabled,
1826
- placeholder: t("input.context.customPlaceholder"),
1827
- style: inputStyle,
1828
- onChange: (event) => {
1829
- setRaw(event.currentTarget.value);
1830
- },
1831
- onKeyDown: (event) => {
1832
- if (event.key === "Enter") {
1833
- setOpen(false);
1834
- applyCustom();
1835
- }
1836
- }
1837
- }),
1838
- /* @__PURE__ */ (0, react_jsx_runtime.jsx)("button", {
1839
- type: "button",
1840
- disabled,
1841
- style: {
1842
- ...actionStyle,
1843
- cursor: disabled ? "default" : "pointer",
1844
- opacity: disabled ? .5 : 1
1845
- },
1846
- onClick: () => {
1847
- setOpen(false);
1848
- applyCustom();
1849
- },
1850
- children: t("input.context.apply")
1851
- }),
1852
- /* @__PURE__ */ (0, react_jsx_runtime.jsx)("button", {
1853
- type: "button",
1854
- disabled,
1855
- style: {
1856
- ...actionStyle,
1857
- cursor: disabled ? "default" : "pointer",
1858
- opacity: disabled ? .5 : 1
1859
- },
1860
- onClick: () => {
1861
- setOpen(false);
1862
- setRaw("");
1863
- setError(null);
1864
- commitWindow(void 0);
1865
- },
1866
- children: t("input.context.clear")
1867
- })
1868
- ]
1851
+ onClick: () => {
1852
+ setCustom((open) => !open);
1853
+ setError(null);
1854
+ },
1855
+ children: "⋯"
1869
1856
  }),
1870
- error !== null && /* @__PURE__ */ (0, react_jsx_runtime.jsx)("p", {
1857
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)("button", {
1858
+ type: "button",
1859
+ disabled: disabled || currentWindow === void 0,
1860
+ style: {
1861
+ ...actionButtonStyle,
1862
+ cursor: disabled || currentWindow === void 0 ? "default" : "pointer",
1863
+ opacity: disabled || currentWindow === void 0 ? .55 : 1
1864
+ },
1865
+ onClick: () => {
1866
+ setDraft(null);
1867
+ setError(null);
1868
+ setRaw("");
1869
+ commitWindow(void 0);
1870
+ },
1871
+ children: t("input.context.clear")
1872
+ })
1873
+ ]
1874
+ }), custom ? /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
1875
+ style: customRowStyle,
1876
+ children: [
1877
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)("input", {
1878
+ type: "text",
1879
+ inputMode: "numeric",
1880
+ value: raw,
1881
+ disabled,
1882
+ placeholder: t("input.context.customPlaceholder"),
1883
+ "aria-label": t("input.context.customPlaceholder"),
1884
+ style: inputStyle,
1885
+ onChange: (event) => {
1886
+ setRaw(event.currentTarget.value);
1887
+ },
1888
+ onKeyDown: (event) => {
1889
+ if (event.key === "Enter") applyCustom();
1890
+ }
1891
+ }),
1892
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)("button", {
1893
+ type: "button",
1894
+ disabled,
1895
+ style: {
1896
+ ...actionButtonStyle,
1897
+ cursor: disabled ? "default" : "pointer",
1898
+ opacity: disabled ? .55 : 1
1899
+ },
1900
+ onClick: applyCustom,
1901
+ children: t("input.context.apply")
1902
+ }),
1903
+ error !== null && /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
1871
1904
  style: errorStyle,
1872
1905
  children: error
1873
1906
  })
1874
1907
  ]
1875
- })] }) : null]
1908
+ }) : null]
1876
1909
  });
1877
1910
  }
1878
1911
  //#endregion
@@ -1917,9 +1950,9 @@ window.__ModuleLoader__.load({
1917
1950
  }
1918
1951
  }, ThinkingLevelsCard);
1919
1952
  });
1920
- ctx.slots.inject("conversation.input.right", function* () {
1953
+ ctx.slots.inject("conversation.input.model.section", function* () {
1921
1954
  yield ctx.slots.register({
1922
- name: "conversation.input.right",
1955
+ name: "conversation.input.model.section",
1923
1956
  id: "context-window-quick",
1924
1957
  locale: NS,
1925
1958
  inject: () => {