dsh-thinking-levels 1.0.0-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
@@ -447,7 +447,7 @@ window.__ModuleLoader__.load({
447
447
  padding: "3px 8px",
448
448
  fontSize: "13px"
449
449
  };
450
- const sectionStyle = {
450
+ const sectionStyle$1 = {
451
451
  marginTop: "14px",
452
452
  paddingTop: "12px",
453
453
  borderTop: "1px solid var(--dsw-alias-border-l2)"
@@ -883,14 +883,14 @@ window.__ModuleLoader__.load({
883
883
  commitContextWindow(entry, void 0);
884
884
  };
885
885
  if (unavailable) return /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
886
- style: sectionStyle,
886
+ style: sectionStyle$1,
887
887
  children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)("p", {
888
888
  style: hintStyle,
889
889
  children: t("card.capabilities.unavailable")
890
890
  })
891
891
  });
892
892
  if (allEntries.length === 0) return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
893
- style: sectionStyle,
893
+ style: sectionStyle$1,
894
894
  children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("p", {
895
895
  style: fieldLabelStyle,
896
896
  children: t("card.capabilities")
@@ -903,7 +903,7 @@ window.__ModuleLoader__.load({
903
903
  const visible = needle === "" ? allEntries : allEntries.filter((entry) => entry.modelId.toLowerCase().includes(needle) || entry.providerId.toLowerCase().includes(needle));
904
904
  const providerIds = [...new Set(visible.map((entry) => entry.providerId))];
905
905
  return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
906
- style: sectionStyle,
906
+ style: sectionStyle$1,
907
907
  children: [
908
908
  /* @__PURE__ */ (0, react_jsx_runtime.jsx)("p", {
909
909
  style: fieldLabelStyle,
@@ -1508,22 +1508,15 @@ window.__ModuleLoader__.load({
1508
1508
  //#endregion
1509
1509
  //#region src/client/context-quick.tsx
1510
1510
  /**
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.
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).
1519
1514
  *
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.
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.
1527
1520
  *
1528
1521
  * Two model families are served, each with its own writable settings
1529
1522
  * namespace (both consumed live by `resolveModelInfo(...).context.contextWindow`,
@@ -1548,42 +1541,13 @@ window.__ModuleLoader__.load({
1548
1541
  const DEEPSEEK_DEFAULT_WINDOW = 1e6;
1549
1542
  /** Slider stop an unset window parks on: the thumb needs a position, the readout stays "unset". */
1550
1543
  const UNSET_STOP_INDEX = CONTEXT_WINDOW_PRESETS.findIndex((preset) => preset.value === 256e3);
1551
- const pillStyle = {
1552
- display: "inline-flex",
1553
- 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)",
1559
- 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)",
1564
- cursor: "pointer",
1565
- whiteSpace: "nowrap"
1566
- };
1567
- const popStyle = {
1568
- position: "absolute",
1569
- bottom: "calc(100% + 8px)",
1570
- right: "0",
1571
- zIndex: 1200,
1572
- minWidth: "260px",
1573
- padding: "10px",
1574
- background: "var(--dsw-alias-bg-layer-3, rgba(127,127,127,0.05))",
1575
- color: "var(--dsw-alias-label-primary)",
1576
- border: "1px solid var(--dsw-alias-border-l2)",
1577
- borderRadius: "10px",
1578
- boxShadow: "0 8px 28px rgba(0,0,0,0.18)",
1544
+ const sectionStyle = {
1579
1545
  display: "flex",
1580
1546
  flexDirection: "column",
1581
- gap: "8px"
1582
- };
1583
- const backdropStyle = {
1584
- position: "fixed",
1585
- inset: 0,
1586
- zIndex: 1199
1547
+ gap: "6px",
1548
+ marginTop: "4px",
1549
+ paddingTop: "7px",
1550
+ borderTop: "1px solid var(--dsw-alias-border-l1)"
1587
1551
  };
1588
1552
  const rowStyle = {
1589
1553
  display: "flex",
@@ -1683,25 +1647,24 @@ window.__ModuleLoader__.load({
1683
1647
  /**
1684
1648
  * The stable trajectory selector: the seat memoizes its selection on the
1685
1649
  * 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
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
1688
1652
  * 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.
1653
+ * @param snapshot - the current Trajectory view snapshot.
1654
+ * @returns the assembled request ledger.
1691
1655
  */
1692
- const selectTrajectory = (snapshot) => snapshot.views?.get?.("trajectory");
1656
+ const selectRequests = (snapshot) => snapshot.requests;
1693
1657
  /**
1694
1658
  * The current session's active model, taken from the trajectory ledger's
1695
1659
  * 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.
1660
+ * request yet) — the control then renders read-only/disabled.
1661
+ * @param requests - the trajectory ledger's request views.
1698
1662
  */
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 {
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 {
1705
1668
  provider: config.provider,
1706
1669
  model: config.model
1707
1670
  };
@@ -1714,7 +1677,7 @@ window.__ModuleLoader__.load({
1714
1677
  }
1715
1678
  /**
1716
1679
  * The slider stop nearest to a committed token count; a window that matches no
1717
- * preset still parks the thumb on its closest stop.
1680
+ * preset (typed through the card) still parks the thumb on its closest stop.
1718
1681
  * @param value - the committed context window, when one is set.
1719
1682
  * @returns the stop index, or the unset park position.
1720
1683
  */
@@ -1732,28 +1695,14 @@ window.__ModuleLoader__.load({
1732
1695
  return best;
1733
1696
  }
1734
1697
  /**
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.
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).
1738
1702
  * @param props - injected scopes, session standard seats, copy.
1739
1703
  */
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.
1754
- */
1755
- function ContextQuickControl({ useConversation, piAiScope, deepseekScope, t }) {
1756
- const active = activeModelOf(useConversation(selectTrajectory));
1704
+ function ContextQuick({ useTrajectory, piAiScope, deepseekScope, t }) {
1705
+ const active = activeModelOf(useTrajectory(selectRequests));
1757
1706
  const official = active !== void 0 && active.provider === DEEPSEEK_PROVIDER;
1758
1707
  const piSnapshot = (0, react.useSyncExternalStore)((listener) => piAiScope.subscribe(listener), () => piAiScope.getSnapshot());
1759
1708
  const dsSnapshot = (0, react.useSyncExternalStore)((listener) => deepseekScope.subscribe(listener), () => deepseekScope.getSnapshot());
@@ -1775,7 +1724,6 @@ window.__ModuleLoader__.load({
1775
1724
  currentWindow = model === void 0 ? void 0 : contextWindowOf(model);
1776
1725
  writableTarget = model !== void 0;
1777
1726
  }
1778
- const [open, setOpen] = (0, react.useState)(false);
1779
1727
  const [draft, setDraft] = (0, react.useState)(null);
1780
1728
  const [custom, setCustom] = (0, react.useState)(false);
1781
1729
  const [raw, setRaw] = (0, react.useState)("");
@@ -1852,136 +1800,112 @@ window.__ModuleLoader__.load({
1852
1800
  commitWindow(validation.value);
1853
1801
  };
1854
1802
  const value = draft === null ? currentWindow === void 0 ? t("input.context.unset") : formatContextWindow(currentWindow) : formatContextWindow(CONTEXT_WINDOW_PRESETS[draft]?.value ?? 0);
1855
- return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
1856
- style: { position: "relative" },
1857
- children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("button", {
1858
- type: "button",
1859
- disabled,
1860
- "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
- },
1868
- onClick: () => {
1869
- setOpen((value) => !value);
1870
- setError(null);
1871
- },
1872
- children: value
1873
- }), open ? /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(react_jsx_runtime.Fragment, { children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
1874
- style: backdropStyle,
1875
- onClick: () => {
1876
- setOpen(false);
1877
- setError(null);
1878
- }
1879
- }), /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
1880
- style: popStyle,
1881
- role: "group",
1882
- "aria-label": t("input.context.title"),
1883
- children: [/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
1884
- style: rowStyle,
1885
- children: [
1886
- /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
1887
- style: labelStyle,
1888
- title: t("input.context.globalHint"),
1889
- children: t("input.context.title")
1890
- }),
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
- }
1966
- }),
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")
1977
- }),
1978
- error !== null && /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
1979
- style: errorStyle,
1980
- children: error
1981
- })
1982
- ]
1983
- }) : null]
1984
- })] }) : null]
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,
1809
+ children: [
1810
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
1811
+ style: labelStyle,
1812
+ title: t("input.context.globalHint"),
1813
+ children: t("input.context.title")
1814
+ }),
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
1835
+ }),
1836
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
1837
+ style: valueStyle,
1838
+ children: value
1839
+ }),
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"),
1846
+ style: {
1847
+ ...glyphButtonStyle,
1848
+ cursor: disabled ? "default" : "pointer",
1849
+ opacity: disabled ? .55 : 1
1850
+ },
1851
+ onClick: () => {
1852
+ setCustom((open) => !open);
1853
+ setError(null);
1854
+ },
1855
+ children: "⋯"
1856
+ }),
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", {
1904
+ style: errorStyle,
1905
+ children: error
1906
+ })
1907
+ ]
1908
+ }) : null]
1985
1909
  });
1986
1910
  }
1987
1911
  //#endregion
@@ -1999,12 +1923,19 @@ window.__ModuleLoader__.load({
1999
1923
  * @param ctx - client root context.
2000
1924
  */
2001
1925
  function apply(ctx) {
2002
- ctx.effect(() => ctx.locale.register(NS, {
2003
- zh,
2004
- en,
2005
- ja,
2006
- ko
2007
- }), "dsh-thinking-levels: dictionaries");
1926
+ ctx.effect(() => {
1927
+ const disposers = [
1928
+ ctx.locale.register(NS, {
1929
+ zh,
1930
+ en
1931
+ }),
1932
+ ctx.locale.register(NS, "ja", ja),
1933
+ ctx.locale.register(NS, "ko", ko)
1934
+ ];
1935
+ return () => {
1936
+ for (const dispose of disposers) dispose();
1937
+ };
1938
+ }, "dsh-thinking-levels: dictionaries");
2008
1939
  ctx.slots.inject("settings.plugin.item", function* () {
2009
1940
  yield ctx.slots.register({
2010
1941
  name: "settings.plugin.item",
@@ -2019,9 +1950,9 @@ window.__ModuleLoader__.load({
2019
1950
  }
2020
1951
  }, ThinkingLevelsCard);
2021
1952
  });
2022
- ctx.slots.inject("conversation.input.right", function* () {
1953
+ ctx.slots.inject("conversation.input.model.section", function* () {
2023
1954
  yield ctx.slots.register({
2024
- name: "conversation.input.right",
1955
+ name: "conversation.input.model.section",
2025
1956
  id: "context-window-quick",
2026
1957
  locale: NS,
2027
1958
  inject: () => {