dsh-ws-recency 0.33.0 → 0.33.2

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 (3) hide show
  1. package/client.js +34 -117
  2. package/index.js +7 -2
  3. package/package.json +1 -1
package/client.js CHANGED
@@ -365,7 +365,7 @@
365
365
  ".wsr-hit-actions{display:flex;gap:6px;justify-content:flex-end;margin-top:2px}",
366
366
  ".wsr-hit-context-toggle,.wsr-hit-context-jump{border:.5px solid var(--dsw-alias-border-l2,rgba(255,255,255,.14));background:0 0;color:var(--dsw-alias-label-tertiary);font:inherit;font-size:11px;line-height:18px;padding:0 8px;border-radius:9px;cursor:pointer}",
367
367
  ".wsr-hit-context-toggle:hover,.wsr-hit-context-jump:hover{color:var(--dsw-alias-label-primary);border-color:var(--dsw-alias-border-l3,rgba(255,255,255,.24))}",
368
- ".wsr-hit-context{max-height:38vh;overflow:auto;margin-top:4px;padding:6px 8px;border-radius:6px;background:var(--dsw-alias-bg-layer-2,rgba(255,255,255,.04));color:var(--dsw-alias-label-secondary);font-size:11px;line-height:1.65;white-space:pre-wrap;word-break:break-word}",
368
+ ".wsr-hit-context{max-height:42vh;overflow:auto;margin-top:4px;padding:8px 10px;border-radius:6px;background:var(--dsw-alias-bg-layer-2,rgba(255,255,255,.04));color:var(--dsw-alias-label-secondary);font-size:12px;line-height:1.75;white-space:pre-wrap;word-break:break-word;tab-size:2}",
369
369
  /* A column flex box with a fixed height shrinks its children once the
370
370
  content is taller than the box, and the shortest row goes first - that
371
371
  is how the recent-searches row vanished only after a search returned
@@ -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,13 +533,9 @@
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
- "search.coldJump": "这一轮在最新一轮之前 {behind} 轮,跳过去要加载大量历史,可能十几秒。",
542
- "search.coldContext": "只看上下文",
543
- "search.coldJumpAnyway": "仍然跳过去",
538
+ "search.coldExpanded": "第 {turn} 轮在最新一轮之前 {behind} 轮,已展开上下文;要跳转请点这一行的「打开会话」。",
544
539
  "search.settings.coldTitle": "跳转前确认",
545
540
  "search.settings.coldDesc": "命中离最新一轮超过这么多轮时先问一句;0 表示每次都直接跳。",
546
541
  "search.openSession": "打开会话",
@@ -755,13 +750,9 @@
755
750
  "search.assistant": "Assistant",
756
751
  "search.turn": "turn {n}",
757
752
  "search.pluginCost": "plugin {ms}ms",
758
- "menu.diagnose": "Plugin cost",
759
- "diagnose.report": "Last 60s: {passes} passes / {total}ms total / {worst}ms worst · {nodes} nodes · {turns} turns mounted",
760
753
  "search.contextShow": "Show context",
761
754
  "search.contextHide": "Hide",
762
- "search.coldJump": "This turn is {behind} turns behind the newest one; jumping there loads a lot of history and can take a while.",
763
- "search.coldContext": "Show context",
764
- "search.coldJumpAnyway": "Jump anyway",
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.",
765
756
  "search.settings.coldTitle": "Ask before a long jump",
766
757
  "search.settings.coldDesc": "Ask when a hit is this many turns behind the newest one; 0 jumps every time.",
767
758
  "search.openSession": "Open session",
@@ -1934,15 +1925,6 @@
1934
1925
  * a feedback loop cannot turn into a busy main thread. */
1935
1926
  var PASS_MIN_GAP = 400;
1936
1927
  var lastPassAt = 0;
1937
- var passCount = 0;
1938
- /* Rolling record for the diagnostic row: how often the pass runs and how
1939
- long it takes, so a claim about cost can be checked on screen. */
1940
- var passSamples = [];
1941
-
1942
- function recordPass(spent) {
1943
- passSamples.push({ at: Date.now(), ms: spent });
1944
- if (passSamples.length > 200) passSamples.shift();
1945
- }
1946
1928
 
1947
1929
  function schedule() {
1948
1930
  if (disposed || timer !== null) return;
@@ -1960,15 +1942,12 @@
1960
1942
  timer = window.setTimeout(function () {
1961
1943
  timer = null;
1962
1944
  lastPassAt = Date.now();
1963
- passCount += 1;
1964
1945
  var began = Date.now();
1965
1946
  try {
1966
1947
  apply();
1967
1948
  } catch (error) {
1968
1949
  console.warn("[dsh-ws-recency] pass failed:", error);
1969
1950
  }
1970
- recordPass(Date.now() - began);
1971
- if (typeof window !== "undefined") window.__DSH_WSR_PASSES__ = passCount;
1972
1951
  }, delay);
1973
1952
  }
1974
1953
  /** `shell.overlay` occupant; it renders no chrome of its own. */
@@ -2037,46 +2016,7 @@
2037
2016
  * `<home>/.trash/ws-recency/`. The browser half only asks for confirmation
2038
2017
  * and posts the id.
2039
2018
  */
2040
- /**
2041
- * Session menu row that reports this plugin's own cost.
2042
- *
2043
- * Without devtools there was no way to tell a slow plugin from a slow host,
2044
- * and several rounds went into guessing. This prints the numbers where the
2045
- * lag is felt. */
2046
- function DiagnoseMenuItem(props) {
2047
- var Item = ui.MenuItemButton;
2048
- if (typeof Item !== "function") return null;
2049
- return h(Item, {
2050
- icon: undefined,
2051
- onSelect: function () {
2052
- var now = Date.now();
2053
- var recent = passSamples.filter(function (sample) {
2054
- return now - sample.at <= 60000;
2055
- });
2056
- var total = 0;
2057
- var worst = 0;
2058
- for (var i = 0; i < recent.length; i += 1) {
2059
- total += recent[i].ms;
2060
- if (recent[i].ms > worst) worst = recent[i].ms;
2061
- }
2062
- var nodes = typeof document !== "undefined" ? document.querySelectorAll("*").length : 0;
2063
- var turns = typeof document !== "undefined" ? document.querySelectorAll("[data-chat-turn]").length : 0;
2064
- var note = statsDiv("wsr-jump-toast wsr-diagnose-toast");
2065
- note.textContent = t("diagnose.report", {
2066
- passes: String(recent.length),
2067
- total: String(total),
2068
- worst: String(worst),
2069
- nodes: String(nodes),
2070
- turns: String(turns),
2071
- });
2072
- document.body.appendChild(note);
2073
- window.setTimeout(function () {
2074
- if (note.parentElement !== null) note.remove();
2075
- }, 8000);
2076
- },
2077
- }, t("menu.diagnose"));
2078
- }
2079
-
2019
+
2080
2020
  function TrashMenuItem(props) {
2081
2021
  var Item = ui.MenuItemButton;
2082
2022
  if (typeof Item !== "function") return null;
@@ -4912,10 +4852,12 @@
4912
4852
  for ten seconds without warning. */
4913
4853
  var cold = props.coldAfter > 0
4914
4854
  && Number(props.hit.turns) - Number(props.hit.turn) > props.coldAfter;
4915
- var openContext = function () { opened[1](true); };
4916
4855
  var go = function () {
4917
4856
  if (cold) {
4918
- askColdJump(props.hit, props.onJump, openContext);
4857
+ /* Showing the context here is cheaper and more readable than a
4858
+ modal, and the row's own button is the explicit "jump anyway". */
4859
+ opened[1](true);
4860
+ announceColdHint(props.hit);
4919
4861
  return;
4920
4862
  }
4921
4863
  if (typeof props.onJump === "function") props.onJump();
@@ -4941,7 +4883,9 @@
4941
4883
  },
4942
4884
  }, t("search.openSession")),
4943
4885
  ),
4944
- opened[0] === true ? h("div", { className: "wsr-hit-context" }, context) : null,
4886
+ opened[0] === true
4887
+ ? h("div", { className: "wsr-hit-context" }, highlightSnippet(context, props.terms))
4888
+ : null,
4945
4889
  ];
4946
4890
  return searchHitRow(props.hit, props.terms, go, extra);
4947
4891
  }
@@ -4983,51 +4927,33 @@
4983
4927
  );
4984
4928
  }
4985
4929
 
4986
- /** Ask whether a jump that means loading a lot of history should go ahead. */
4987
- function askColdJump(hit, onJump, onContext) {
4930
+
4931
+ /** Say why a cold hit opened its context instead of jumping. */
4932
+ function announceColdHint(hit) {
4988
4933
  if (typeof document === "undefined") return;
4989
- closeConfirm();
4990
- confirmPrevious = typeof document.activeElement !== "undefined" ? document.activeElement : null;
4991
- var backdrop = statsDiv("wsr-modal-backdrop");
4992
- backdrop.setAttribute("data-wsr-confirm", "cold");
4993
- var panel = statsDiv("wsr-confirm");
4994
- panel.setAttribute("role", "dialog");
4995
- panel.setAttribute("aria-modal", "true");
4996
- panel.setAttribute("tabindex", "-1");
4997
- panel.appendChild(statsDiv("wsr-confirm-text", t("search.coldJump", {
4998
- turn: String(hit.turn),
4999
- behind: String(Math.max(0, Number(hit.turns) - Number(hit.turn))),
5000
- })));
5001
- var actions = statsDiv("wsr-confirm-actions");
5002
- var context = document.createElement("button");
5003
- context.type = "button";
5004
- context.className = "wsr-qcancel";
5005
- context.setAttribute("data-wsr-cold-context", "true");
5006
- context.textContent = t("search.coldContext");
5007
- context.addEventListener("click", function (event) {
5008
- if (event !== undefined && typeof event.stopPropagation === "function") event.stopPropagation();
5009
- closeConfirm(null);
5010
- if (typeof onContext === "function") onContext();
5011
- });
5012
- var accept = document.createElement("button");
5013
- accept.type = "button";
5014
- accept.className = "wsr-qsubmit";
5015
- accept.setAttribute("data-wsr-cold-jump", "true");
5016
- accept.textContent = t("search.coldJumpAnyway");
5017
- accept.addEventListener("click", function (event) {
5018
- if (event !== undefined && typeof event.stopPropagation === "function") event.stopPropagation();
5019
- closeConfirm(null);
5020
- if (typeof onJump === "function") onJump();
5021
- });
5022
- actions.appendChild(context);
5023
- actions.appendChild(accept);
5024
- panel.appendChild(actions);
5025
- backdrop.appendChild(panel);
5026
- document.body.appendChild(backdrop);
5027
- try { if (typeof panel.focus === "function") panel.focus(); } catch (error) { /* focus is a nicety */ }
4934
+ try {
4935
+ var note = statsDiv("wsr-jump-toast");
4936
+ note.textContent = t("search.coldExpanded", {
4937
+ turn: String(hit.turn),
4938
+ behind: String(Math.max(0, Number(hit.turns) - Number(hit.turn))),
4939
+ });
4940
+ document.body.appendChild(note);
4941
+ window.setTimeout(function () {
4942
+ if (note.parentElement !== null) note.remove();
4943
+ }, 6000);
4944
+ } catch (error) {
4945
+ /* a toast is a nicety */
4946
+ }
5028
4947
  }
5029
4948
 
5030
4949
  function SearchPanelPage(props) {
4950
+ /* A previous build could leave its own backdrop behind; clear it. */
4951
+ try {
4952
+ var strays = document.querySelectorAll('[data-wsr-confirm="cold"]');
4953
+ for (var stray = 0; stray < strays.length; stray += 1) strays[stray].remove();
4954
+ } catch (error) {
4955
+ /* nothing to clean */
4956
+ }
5031
4957
  var state = react.useState(searchLast === null
5032
4958
  ? { loaded: false, query: "", hits: [], sessions: [], terms: [], scanned: 0, total: 0, pending: 0, took: 0, busy: false, error: "" }
5033
4959
  : searchLast);
@@ -6020,15 +5946,6 @@
6020
5946
  }, StatsMenuItem);
6021
5947
  });
6022
5948
 
6023
- ctx.slots.inject("sidebar.workspaces.session.menu.item", function () {
6024
- return ctx.slots.register({
6025
- name: "sidebar.workspaces.session.menu.item",
6026
- id: "ws-recency-diagnose",
6027
- order: 690,
6028
- store: prefs,
6029
- locale: NS,
6030
- }, DiagnoseMenuItem);
6031
- });
6032
5949
 
6033
5950
  ctx.slots.inject("sidebar.workspaces.session.menu.item", function () {
6034
5951
  return ctx.slots.register({
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.0";
35
+ export const HOST_VERSION = "0.33.2";
36
36
 
37
37
  /**
38
38
  * Exact routes the client half calls. Registered on the bare web server, so they
@@ -910,7 +910,12 @@ function searchSeeks(text, needle) {
910
910
  */
911
911
  function searchContext(text, needle, radius) {
912
912
  const span = Number.isFinite(radius) ? radius : 420;
913
- const flat = text.replace(/\s+/g, " ");
913
+ /* Only spaces and tabs collapse: the line breaks carry the structure, and a
914
+ collapsed paragraph is much harder to read than a long one. */
915
+ const flat = text
916
+ .replace(/\r/g, "")
917
+ .replace(/[ \t]+/g, " ")
918
+ .replace(/\n{3,}/g, "\n\n");
914
919
  const index = needle === "" ? -1 : flat.toLowerCase().indexOf(needle);
915
920
  if (index < 0) return flat.slice(0, span * 2).trim();
916
921
  const from = Math.max(0, index - span);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "dsh-ws-recency",
3
- "version": "0.33.0",
3
+ "version": "0.33.2",
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",