dsh-ws-recency 0.33.1 → 0.34.0

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.
Files changed (4) hide show
  1. package/README.md +11 -0
  2. package/client.js +7 -165
  3. package/index.js +1 -1
  4. package/package.json +1 -1
package/README.md CHANGED
@@ -196,6 +196,17 @@ DSH 原生的置顶只把会话顶到**它所属工作区分组的第一行**,
196
196
 
197
197
  所以用 `dsh-gateway` 之类的转接插件、或直接从局域网 IP 访问时,删除和统计都能正常用;只有**真正的跨站页面**会被 403 拒绝。0.32.1 及更早的版本只认回环地址,非回环访问一律 403(issue #3)。
198
198
 
199
+ ## 会话菜单里留下什么
200
+
201
+ 本插件只往会话「…」菜单里加两项,其余动作都由宿主或对话界面本身提供:
202
+
203
+ | 项 | 为什么还需要它 |
204
+ |---|---|
205
+ | 标记需要跟进 | 宿主没有这个概念,它是侧栏三色标记的一种 |
206
+ | 移动到工作区… | 宿主的 attach 校验 `header.cwd`,核心没有改工作区的入口 |
207
+
208
+ 交接在每轮回复下方的动作行里;Token 统计在输入框上方的「分析」胶囊里;删除会话(移入回收站)的菜单项在 0.34.0 移除——要恢复它,把 `ctx.slots.inject("sidebar.workspaces.session.menu.item", … , TrashMenuItem)` 那段注册加回去即可,宿主侧的删除/回收站路由一直都在。
209
+
199
210
  ## 已知边界
200
211
 
201
212
  - 依赖宿主 DOM:分组容器带 `_groupSection`、分组头带 `data-row-key="workspace:<id>"`、行带 `data-row-key="session:<id>"`、溢出按钮类名含 `sessionOverflowButton`。宿主改结构就要跟着改。
package/client.js CHANGED
@@ -413,7 +413,6 @@
413
413
  ".wsr-hit-time{flex:none;font-variant-numeric:tabular-nums}",
414
414
  ".wsr-hit-step{flex:none;color:var(--dsw-alias-label-secondary)}",
415
415
  ".wsr-jump-toast{position:fixed;left:50%;bottom:28px;transform:translateX(-50%);z-index:9999;padding:6px 12px;border-radius:8px;font-size:12px;background:var(--dsw-alias-bg-layer-3,rgba(32,34,38,.96));color:var(--dsw-alias-label-primary);border:.5px solid var(--dsw-alias-border-l2,rgba(255,255,255,.14));box-shadow:0 8px 24px rgba(0,0,0,.4);pointer-events:none}",
416
- ".wsr-diagnose-toast{max-width:min(680px,90vw);white-space:normal;line-height:1.6;text-align:left;font-variant-numeric:tabular-nums}",
417
416
  ".wsr-jump-loading{color:var(--dsw-alias-label-secondary)}",
418
417
  ".wsr-jump-toast-warn{border-color:color-mix(in srgb,var(--dsw-alias-state-error-primary,#d9534f) 45%,transparent);color:var(--dsw-alias-state-error-primary,#d9534f)}",
419
418
  ".wsr-hit-cwd{flex:1;min-width:0;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;direction:rtl;text-align:left}",
@@ -534,8 +533,6 @@
534
533
  "search.assistant": "助手",
535
534
  "search.turn": "第 {n} 轮",
536
535
  "search.pluginCost": "插件 {ms}ms",
537
- "menu.diagnose": "插件耗时诊断",
538
- "diagnose.report": "近 60 秒:扫描 {passes} 次 / 共 {total}ms / 最慢 {worst}ms · 页面节点 {nodes} · 已挂载轮次 {turns}",
539
536
  "search.contextShow": "看上下文",
540
537
  "search.contextHide": "收起",
541
538
  "search.coldExpanded": "第 {turn} 轮在最新一轮之前 {behind} 轮,已展开上下文;要跳转请点这一行的「打开会话」。",
@@ -753,8 +750,6 @@
753
750
  "search.assistant": "Assistant",
754
751
  "search.turn": "turn {n}",
755
752
  "search.pluginCost": "plugin {ms}ms",
756
- "menu.diagnose": "Plugin cost",
757
- "diagnose.report": "Last 60s: {passes} passes / {total}ms total / {worst}ms worst · {nodes} nodes · {turns} turns mounted",
758
753
  "search.contextShow": "Show context",
759
754
  "search.contextHide": "Hide",
760
755
  "search.coldExpanded": "Turn {turn} is {behind} turns behind the newest one, so its context is shown here; press Open session on this row to jump.",
@@ -1290,7 +1285,7 @@
1290
1285
  folded. Expanding drives the hidden host button until nothing is left
1291
1286
  unrendered, so one click reveals the whole group. */
1292
1287
  var remaining = folded + hostHidden;
1293
- /* A project that is entirely history is open because opening it is the
1288
+ /* A project that is entirely history is open because opening it is the
1294
1289
  request; there is nothing to offer to fold back. */
1295
1290
  if (expanded && !onlyHistory) {
1296
1291
  (function (entryKey) {
@@ -1930,15 +1925,6 @@
1930
1925
  * a feedback loop cannot turn into a busy main thread. */
1931
1926
  var PASS_MIN_GAP = 400;
1932
1927
  var lastPassAt = 0;
1933
- var passCount = 0;
1934
- /* Rolling record for the diagnostic row: how often the pass runs and how
1935
- long it takes, so a claim about cost can be checked on screen. */
1936
- var passSamples = [];
1937
-
1938
- function recordPass(spent) {
1939
- passSamples.push({ at: Date.now(), ms: spent });
1940
- if (passSamples.length > 200) passSamples.shift();
1941
- }
1942
1928
 
1943
1929
  function schedule() {
1944
1930
  if (disposed || timer !== null) return;
@@ -1956,15 +1942,12 @@
1956
1942
  timer = window.setTimeout(function () {
1957
1943
  timer = null;
1958
1944
  lastPassAt = Date.now();
1959
- passCount += 1;
1960
1945
  var began = Date.now();
1961
1946
  try {
1962
1947
  apply();
1963
1948
  } catch (error) {
1964
1949
  console.warn("[dsh-ws-recency] pass failed:", error);
1965
1950
  }
1966
- recordPass(Date.now() - began);
1967
- if (typeof window !== "undefined") window.__DSH_WSR_PASSES__ = passCount;
1968
1951
  }, delay);
1969
1952
  }
1970
1953
  /** `shell.overlay` occupant; it renders no chrome of its own. */
@@ -2025,87 +2008,7 @@
2025
2008
  });
2026
2009
  }
2027
2010
 
2028
- /**
2029
- * Session "..." menu row: move the session into the trash folder.
2030
- *
2031
- * DSH itself only archives; the host half of this plugin stops the work,
2032
- * detaches the bookkeeping and renames the log directory into
2033
- * `<home>/.trash/ws-recency/`. The browser half only asks for confirmation
2034
- * and posts the id.
2035
- */
2036
- /**
2037
- * Session menu row that reports this plugin's own cost.
2038
- *
2039
- * Without devtools there was no way to tell a slow plugin from a slow host,
2040
- * and several rounds went into guessing. This prints the numbers where the
2041
- * lag is felt. */
2042
- function DiagnoseMenuItem(props) {
2043
- var Item = ui.MenuItemButton;
2044
- if (typeof Item !== "function") return null;
2045
- return h(Item, {
2046
- icon: undefined,
2047
- onSelect: function () {
2048
- var now = Date.now();
2049
- var recent = passSamples.filter(function (sample) {
2050
- return now - sample.at <= 60000;
2051
- });
2052
- var total = 0;
2053
- var worst = 0;
2054
- for (var i = 0; i < recent.length; i += 1) {
2055
- total += recent[i].ms;
2056
- if (recent[i].ms > worst) worst = recent[i].ms;
2057
- }
2058
- var nodes = typeof document !== "undefined" ? document.querySelectorAll("*").length : 0;
2059
- var turns = typeof document !== "undefined" ? document.querySelectorAll("[data-chat-turn]").length : 0;
2060
- var note = statsDiv("wsr-jump-toast wsr-diagnose-toast");
2061
- note.textContent = t("diagnose.report", {
2062
- passes: String(recent.length),
2063
- total: String(total),
2064
- worst: String(worst),
2065
- nodes: String(nodes),
2066
- turns: String(turns),
2067
- });
2068
- document.body.appendChild(note);
2069
- window.setTimeout(function () {
2070
- if (note.parentElement !== null) note.remove();
2071
- }, 8000);
2072
- },
2073
- }, t("menu.diagnose"));
2074
- }
2075
-
2076
- function TrashMenuItem(props) {
2077
- var Item = ui.MenuItemButton;
2078
- if (typeof Item !== "function") return null;
2079
- var Icon = ui.IconTrashOutlineRegular;
2080
- return h(Item, {
2081
- icon: typeof Icon === "function" ? h(Icon, {}) : undefined,
2082
- onSelect: function () {
2083
- askConfirm(t("trash.confirm"), function () {
2084
- fetch("/ws-recency/session-trash?sessionId=" + encodeURIComponent(props.sessionId), {
2085
- method: "POST",
2086
- headers: { "content-type": "application/json" },
2087
- body: JSON.stringify({ sessionId: props.sessionId }),
2088
- })
2089
- .then(function (response) {
2090
- return response.text().then(function (text) {
2091
- var parsed = null;
2092
- try { parsed = JSON.parse(text); } catch (error) { parsed = null; }
2093
- return { status: response.status, text: text, json: parsed };
2094
- });
2095
- })
2096
- .then(function (result) {
2097
- if (result.json !== null && result.json.ok === true) return;
2098
- var reason = (result.json !== null && result.json.error) || (result.text || "").trim().slice(0, 120) || "(empty response)";
2099
- askNotice(t("trash.failed") + "HTTP " + result.status + " \u00b7 " + reason);
2100
- })
2101
- .catch(function (error) {
2102
- askNotice(t("trash.failed") + (error && error.message ? error.message : error));
2103
- });
2104
- });
2105
- },
2106
- }, t("menu.trash"));
2107
- }
2108
-
2011
+
2109
2012
  /* ------------------------- token statistics ------------------------- */
2110
2013
 
2111
2014
  var statsModal = null;
@@ -3806,36 +3709,8 @@
3806
3709
  return typeof Tooltip === "function" ? h(Tooltip, { label: label, side: "bottom" }, button) : button;
3807
3710
  }
3808
3711
 
3809
- /** Session "..." menu row: hand the work over to a fresh Session. */
3810
- function HandoffMenuItem(props) {
3811
- var Item = ui.MenuItemButton;
3812
- if (typeof Item !== "function") return null;
3813
- var Icon = ui.IconDataOutlineRegular;
3814
- return h(Item, {
3815
- icon: typeof Icon === "function" ? h(Icon, {}) : undefined,
3816
- onSelect: function () {
3817
- /* Open the conversation first so the running handoff (and later the
3818
- card) is visible; the prompt itself does not need the composer. */
3819
- var service = data.service;
3820
- if (service !== null && service !== undefined && typeof service.openSession === "function") {
3821
- try { service.openSession(props.sessionId); } catch (error) { /* the send still lands */ }
3822
- }
3823
- startHandoff(props.sessionId);
3824
- },
3825
- }, t("menu.handoff"));
3826
- }
3827
-
3828
- /** Session "..." menu row: token statistics of that session. */
3829
- function StatsMenuItem(props) {
3830
- var Item = ui.MenuItemButton;
3831
- if (typeof Item !== "function") return null;
3832
- var Icon = ui.IconDataOutlineRegular;
3833
- return h(Item, {
3834
- icon: typeof Icon === "function" ? h(Icon, {}) : undefined,
3835
- onSelect: function () { openStatsPanel(props.sessionId); },
3836
- }, t("menu.stats"));
3837
- }
3838
-
3712
+
3713
+
3839
3714
  /** Settings -> General row: ask before a jump that loads a lot of history. */
3840
3715
  function ColdJumpRow(props) {
3841
3716
  var settings = props.useStore(function (state) { return state; });
@@ -5982,45 +5857,9 @@
5982
5857
  }, MoveMenuItem);
5983
5858
  });
5984
5859
 
5985
- ctx.slots.inject("sidebar.workspaces.session.menu.item", function () {
5986
- return ctx.slots.register({
5987
- name: "sidebar.workspaces.session.menu.item",
5988
- id: "ws-recency-handoff",
5989
- order: 685,
5990
- store: prefs,
5991
- locale: NS,
5992
- }, HandoffMenuItem);
5993
- });
5994
5860
 
5995
- ctx.slots.inject("sidebar.workspaces.session.menu.item", function () {
5996
- return ctx.slots.register({
5997
- name: "sidebar.workspaces.session.menu.item",
5998
- id: "ws-recency-stats",
5999
- order: 710,
6000
- store: prefs,
6001
- locale: NS,
6002
- }, StatsMenuItem);
6003
- });
6004
5861
 
6005
- ctx.slots.inject("sidebar.workspaces.session.menu.item", function () {
6006
- return ctx.slots.register({
6007
- name: "sidebar.workspaces.session.menu.item",
6008
- id: "ws-recency-diagnose",
6009
- order: 690,
6010
- store: prefs,
6011
- locale: NS,
6012
- }, DiagnoseMenuItem);
6013
- });
6014
5862
 
6015
- ctx.slots.inject("sidebar.workspaces.session.menu.item", function () {
6016
- return ctx.slots.register({
6017
- name: "sidebar.workspaces.session.menu.item",
6018
- id: "ws-recency-trash",
6019
- order: 700,
6020
- store: prefs,
6021
- locale: NS,
6022
- }, TrashMenuItem);
6023
- });
6024
5863
 
6025
5864
  ctx.effect(function () {
6026
5865
  return function () { shutdown(); };
@@ -6043,6 +5882,9 @@
6043
5882
  };
6044
5883
 
6045
5884
  /* Test hook: the jump and the highlighting are pure DOM helpers. */
5885
+ /* The statistics panel no longer has a menu row; tests open it here. */
5886
+ exports.__stats = { open: openStatsPanel, close: closeStatsPanel };
5887
+
6046
5888
  exports.__search = {
6047
5889
  draft: function () { return searchDraft; },
6048
5890
  highlight: highlightSnippet,
package/index.js CHANGED
@@ -32,7 +32,7 @@ import { dirname, join } from "node:path";
32
32
  export const name = "ws-recency";
33
33
 
34
34
  /** Version marker reported by the health route. */
35
- export const HOST_VERSION = "0.33.1";
35
+ export const HOST_VERSION = "0.34.0";
36
36
 
37
37
  /**
38
38
  * Exact routes the client half calls. Registered on the bare web server, so they
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "dsh-ws-recency",
3
- "version": "0.33.1",
3
+ "version": "0.34.0",
4
4
  "description": "Sidebar session management for DeepSeek Harness: workspace groups sorted by latest activity, stale history folded, a global pinned section, follow-up marks, session delete into a recoverable trash, archived sessions managed from that same trash panel, per-session token statistics with an argument/result split and an option to count tool arguments as the agent's writing, moving a session to another workspace, and a literal content search that jumps to the turn a word was said in.",
5
5
  "license": "MIT",
6
6
  "author": "chyxhtc",