dsh-ws-recency 0.13.4 → 0.14.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 (3) hide show
  1. package/README.md +2 -2
  2. package/client.js +162 -97
  3. package/package.json +1 -1
package/README.md CHANGED
@@ -61,7 +61,7 @@ DSH 原生的置顶只把会话顶到**它所属工作区分组的第一行**,
61
61
  5. 把日志目录移动到 `~/.hypers-work/.trash/ws-recency/<sessionId>-<时间戳>/`;
62
62
  6. 广播 `api-session/removed`,浏览器立即移除该行。
63
63
 
64
- **不是物理删除**:目录只是被改名搬走。每个条目在 `.trash/ws-recency/` 下带一份 `.wsr-trash.json`(会话 id、原 cwd、时间、来源),界面里的**回收站**(侧栏底部「回收站」;它克隆相邻官方条目渲染,图标与文字才能对齐)会列出它们:
64
+ **不是物理删除**:目录只是被改名搬走。每个条目在 `.trash/ws-recency/` 下带一份 `.wsr-trash.json`(会话 id、原 cwd、时间、来源),界面里的**回收站**(侧栏面板列表里的「回收站」,与「插件」「自动化任务」同一排)会列出它们:
65
65
 
66
66
  - 「恢复」:按记录的 cwd 算回 `sessions/<project>/<id>/`,并重新挂到对应工作区;
67
67
  - 「彻底删除」:真正删掉这份日志(二次确认);
@@ -135,7 +135,7 @@ dsh plugin --profile <profile> add github:chyxhtc/dsh-ws-recency
135
135
  或固定版本的预构建包:
136
136
 
137
137
  ```powershell
138
- dsh plugin --profile <profile> add https://github.com/chyxhtc/dsh-ws-recency/releases/download/v0.13.4/dsh-ws-recency-0.13.4.tgz
138
+ dsh plugin --profile <profile> add https://github.com/chyxhtc/dsh-ws-recency/releases/download/v0.14.0/dsh-ws-recency-0.14.0.tgz
139
139
  ```
140
140
 
141
141
  装完把 `dsh-ws-recency` 加进 `~/.hypers-work/profiles/<profile>/package.json` 的 `dsh.profile.bundles`,重启应用。
package/client.js CHANGED
@@ -136,6 +136,18 @@
136
136
  ".wsr-trash-row{display:flex;align-items:flex-start;gap:8px;padding:8px 10px;border-radius:8px;background:var(--dsw-alias-bg-layer-2,rgba(255,255,255,.04))}",
137
137
  ".wsr-footer-action{display:flex;box-sizing:border-box;flex:none;align-items:center;justify-content:flex-start;gap:8px;width:calc(100% + 4px);min-width:0;height:42px;margin:4px -2px;padding:0 10px 0 8px;border:0;border-radius:12px;background:transparent;color:var(--dsw-alias-label-primary);font-family:inherit;font-size:14px;line-height:22px;text-align:left;cursor:pointer}",
138
138
  ".wsr-footer-action:hover{background:var(--dsw-alias-interactive-bg-hover)}",
139
+ ".wsr-page{display:flex;flex-direction:column;gap:10px;padding:16px 18px;min-width:0;box-sizing:border-box;height:100%;overflow:auto}",
140
+ ".wsr-page-head{display:flex;align-items:center;gap:8px}",
141
+ ".wsr-page-heading{flex:1;font-size:14px;font-weight:600;color:var(--dsw-alias-label-primary)}",
142
+ ".wsr-page-list{display:flex;flex-direction:column;gap:6px}",
143
+ ".wsr-page-row{display:flex;align-items:flex-start;gap:10px;padding:10px 12px;border-radius:8px;background:var(--dsw-alias-bg-layer-2,rgba(255,255,255,.04))}",
144
+ ".wsr-page-text{display:flex;flex-direction:column;gap:2px;min-width:0;flex:1}",
145
+ ".wsr-page-title{font-weight:500;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}",
146
+ ".wsr-page-meta{font-size:11px;color:var(--dsw-alias-label-tertiary)}",
147
+ ".wsr-page-path{font-size:11px;color:var(--dsw-alias-label-tertiary);overflow:hidden;text-overflow:ellipsis;white-space:nowrap}",
148
+ ".wsr-page-actions{display:flex;gap:6px;flex:none;align-items:center;white-space:nowrap}",
149
+ ".wsr-page-note{font-size:12px;color:var(--dsw-alias-label-tertiary);line-height:1.6}",
150
+ ".wsr-page-error{color:var(--dsw-alias-state-error-primary,#d9534f)}",
139
151
  ".wsr-footer-action:active{background:var(--dsw-alias-interactive-bg-active)}",
140
152
  ".wsr-footer-action:focus-visible{outline:2px solid var(--dsw-alias-brand-primary);outline-offset:3px}",
141
153
  '.wsr-footer-action[data-wide="false"]{width:36px;height:36px;margin:8px 0 10px;padding:0;gap:0;border-radius:50%;justify-content:center}',
@@ -237,6 +249,7 @@
237
249
  "adopt.cleaned": "清理了 {n} 处重复/失效的工作区归属。",
238
250
  "adopt.failed": "扫描失败:",
239
251
  "ui.reload": "刷新界面",
252
+ "ui.refresh": "刷新列表",
240
253
  "trash.title": "回收站",
241
254
  "trash.description": "被删除的会话会移到这里(日志目录),可以恢复,也可以彻底删除。",
242
255
  "trash.open": "打开",
@@ -316,6 +329,7 @@
316
329
  "adopt.cleaned": " Cleared {n} stale membership(s).",
317
330
  "adopt.failed": "Scan failed: ",
318
331
  "ui.reload": "Reload UI",
332
+ "ui.refresh": "Refresh",
319
333
  "trash.title": "Trash",
320
334
  "trash.description": "Deleted sessions land here (their log directory). Restore them, or delete them for good.",
321
335
  "trash.open": "Open",
@@ -924,89 +938,6 @@
924
938
  return typeof id === "string" && id !== "" ? id : null;
925
939
  }
926
940
 
927
- /** Clone one real footer entry into the slot so the icon box and text line up. */
928
- function decorateFooterAction() {
929
- if (typeof document === "undefined") return;
930
- var mine = document.querySelector('[data-wsr-footer="true"]');
931
- if (mine === null || typeof mine.parentElement === "undefined" || mine.parentElement === null) return;
932
- var container = mine.parentElement;
933
- if (typeof container.querySelectorAll !== "function" || typeof container.insertBefore !== "function") return;
934
- if (container.querySelector("[data-wsr-clone]") !== null || typeof mine.style === "undefined") return;
935
- var template = null;
936
- var buttons = container.querySelectorAll("button");
937
- for (var i = 0; i < buttons.length; i += 1) {
938
- var candidate = buttons[i];
939
- if (candidate === mine) continue;
940
- if (typeof candidate.closest === "function" && candidate.closest("[data-wsr-footer]") !== null) continue;
941
- if (typeof candidate.querySelector !== "function" || candidate.querySelector("svg") === null) continue;
942
- template = candidate;
943
- break;
944
- }
945
- if (template === null || typeof template.cloneNode !== "function") return;
946
- /* The button usually sits inside a row wrapper that owns the width and the
947
- alignment; cloning only the button loses them and the label wraps. */
948
- var rowSource = template.parentElement !== null && template.parentElement !== undefined && template.parentElement !== container
949
- ? template.parentElement
950
- : template;
951
- var clone;
952
- try {
953
- clone = rowSource.cloneNode(true);
954
- } catch (error) {
955
- return;
956
- }
957
- var icon = typeof clone.querySelector === "function" ? clone.querySelector("svg") : null;
958
- var labelClass = "";
959
- if (typeof clone.querySelector === "function") {
960
- var labelTemplate = clone.querySelector("span");
961
- if (labelTemplate !== null && typeof labelTemplate.className === "string") labelClass = labelTemplate.className;
962
- }
963
- /* The wrapper may rely on inline styles from React rather than classes. */
964
- if (typeof window !== "undefined" && typeof window.getComputedStyle === "function") {
965
- var metrics = ["display", "width", "min-width", "align-items", "justify-content", "gap", "padding", "font-size", "font-family", "font-weight", "line-height", "color"];
966
- for (var mi = 0; mi < metrics.length; mi += 1) {
967
- var value = "";
968
- try { value = window.getComputedStyle(rowSource).getPropertyValue(metrics[mi]) || ""; } catch (error) { value = ""; }
969
- if (value !== "" && value !== "auto") clone.style[metrics[mi]] = value;
970
- }
971
- clone.style.whiteSpace = "nowrap";
972
- }
973
- /* Keep the wrapper that holds the icon (it owns the size and baseline) and
974
- drop only the template's text. */
975
- var iconChild = icon;
976
- while (iconChild !== null && iconChild.parentElement !== null && iconChild.parentElement !== undefined && iconChild.parentElement !== clone) {
977
- iconChild = iconChild.parentElement;
978
- }
979
- var kids = Array.prototype.slice.call(clone.children || []);
980
- for (var k = 0; k < kids.length; k += 1) {
981
- if (kids[k] !== iconChild) clone.removeChild(kids[k]);
982
- }
983
- var label = document.createElement("span");
984
- if (labelClass !== "") label.className = labelClass;
985
- label.textContent = t("trash.title");
986
- label.style.whiteSpace = "nowrap";
987
- label.style.overflow = "hidden";
988
- label.style.textOverflow = "ellipsis";
989
- clone.appendChild(label);
990
- clone.setAttribute("data-wsr-clone", "true");
991
- clone.setAttribute("aria-label", t("trash.title"));
992
- clone.addEventListener("click", function (event) {
993
- if (event !== undefined && typeof event.preventDefault === "function") event.preventDefault();
994
- openTrashPanel();
995
- });
996
- /* Keep the template's icon box (it owns the size and the baseline) but put
997
- our own trash glyph inside it. */
998
- var ourSvg = typeof mine.querySelector === "function" ? mine.querySelector("svg") : null;
999
- if (icon !== null && ourSvg !== null && icon.parentElement !== null && icon.parentElement !== undefined) {
1000
- try {
1001
- icon.parentElement.replaceChild(ourSvg, icon);
1002
- } catch (error) {
1003
- /* keep the template icon */
1004
- }
1005
- }
1006
- container.insertBefore(clone, mine);
1007
- mine.style.display = "none";
1008
- }
1009
-
1010
941
  /** The nearest horizontal flex row above the stats: the whole footer dock. */
1011
942
  function composerDockOf(row) {
1012
943
  var node = row;
@@ -1135,14 +1066,12 @@
1135
1066
  var settings = settingsOf();
1136
1067
  if (!ready(sessions) || !ready(workspaces)) {
1137
1068
  decorateComposerStats();
1138
- decorateFooterAction();
1139
1069
  return;
1140
1070
  }
1141
1071
 
1142
1072
  var entries = collect();
1143
1073
  if (entries.length === 0) {
1144
1074
  decorateComposerStats();
1145
- decorateFooterAction();
1146
1075
  return;
1147
1076
  }
1148
1077
 
@@ -1151,7 +1080,6 @@
1151
1080
  renderPinned(entries, sessions, workspaces, settings);
1152
1081
  if (settings.colors) decorateRows(entries, sessions, data.statuses, settings);
1153
1082
  decorateComposerStats();
1154
- decorateFooterAction();
1155
1083
  }
1156
1084
 
1157
1085
  function schedule() {
@@ -1891,6 +1819,115 @@
1891
1819
  load("");
1892
1820
  }
1893
1821
 
1822
+ /* --------------------------- trash panel page ------------------------ */
1823
+
1824
+ function trashPost(payload) {
1825
+ return fetch("/ws-recency/trash", {
1826
+ method: "POST",
1827
+ headers: { "content-type": "application/json" },
1828
+ body: JSON.stringify(payload),
1829
+ }).then(function (response) {
1830
+ return response.text().then(function (text) {
1831
+ var parsed = null;
1832
+ try { parsed = JSON.parse(text); } catch (error) { parsed = null; }
1833
+ return { status: response.status, text: text, json: parsed };
1834
+ });
1835
+ });
1836
+ }
1837
+
1838
+ /** The sidebar's trash entry glyph. */
1839
+ function TrashPanelIcon(props) {
1840
+ var Icon = ui.IconTrashOutlineRegular;
1841
+ if (typeof Icon !== "function") return null;
1842
+ var size = props !== undefined && props !== null && typeof props.size === "number" ? props.size : 16;
1843
+ return h(Icon, { size: size });
1844
+ }
1845
+
1846
+ /** The trash page itself: same data as the dialog, rendered in the main region. */
1847
+ function TrashPanelPage() {
1848
+ var state = react.useState({ loaded: false, entries: [], note: "", failed: "" });
1849
+ var view = state[0];
1850
+ var setView = state[1];
1851
+
1852
+ var load = function (note) {
1853
+ trashPost({ action: "list" }).then(function (answer) {
1854
+ if (answer.json === null || answer.json.ok !== true) {
1855
+ setView({ loaded: true, entries: [], note: "", failed: t("trash.failed") + "HTTP " + answer.status + " \u00b7 " + (answer.text || "").slice(0, 120) });
1856
+ return;
1857
+ }
1858
+ setView({ loaded: true, entries: Array.isArray(answer.json.entries) ? answer.json.entries : [], note: note === undefined ? "" : note, failed: "" });
1859
+ }).catch(function (error) {
1860
+ setView({ loaded: true, entries: [], note: "", failed: t("trash.failed") + (error && error.message ? error.message : error) });
1861
+ });
1862
+ };
1863
+
1864
+ react.useEffect(function () { load(""); }, []);
1865
+
1866
+ var act = function (entry, action) {
1867
+ var question = action === "restore" ? t("trash.confirmRestore") : t("trash.confirmPurge");
1868
+ if (typeof window.confirm === "function" && !window.confirm(question)) return;
1869
+ load(t("trash.working"));
1870
+ trashPost({ action: action, name: entry.name }).then(function (result) {
1871
+ var ok = result.json !== null && result.json.ok === true;
1872
+ load(ok ? (action === "restore" ? t("trash.restored") : t("trash.purged")) : t("trash.failed") + (result.json && result.json.error ? result.json.error : result.text));
1873
+ }).catch(function (error) {
1874
+ load(t("trash.failed") + (error && error.message ? error.message : error));
1875
+ });
1876
+ };
1877
+
1878
+ var rows = [];
1879
+ for (var i = 0; i < view.entries.length; i += 1) {
1880
+ (function (entry) {
1881
+ var meta = [];
1882
+ if (entry.reason === "delete") meta.push(t("trash.reason.delete"));
1883
+ else if (entry.reason === "move") meta.push(t("trash.reason.move"));
1884
+ meta.push(formatBytes(entry.sizeBytes));
1885
+ var when = formatWhen(entry.at);
1886
+ if (when !== "") meta.push(when);
1887
+ var actions = [h("button", {
1888
+ type: "button",
1889
+ className: "wsr-btn",
1890
+ onClick: function () { act(entry, "restore"); },
1891
+ }, t("trash.restore"))].filter(function () { return entry.restorable === true; });
1892
+ actions.push(h("button", {
1893
+ type: "button",
1894
+ className: "wsr-btn wsr-btn-danger",
1895
+ onClick: function () { act(entry, "purge"); },
1896
+ }, t("trash.purge")));
1897
+ rows.push(h("div", { className: "wsr-page-row", key: entry.name },
1898
+ h("div", { className: "wsr-page-text" },
1899
+ h("div", { className: "wsr-page-title" }, entry.sessionId === null ? entry.name : entry.sessionId),
1900
+ h("div", { className: "wsr-page-meta" }, meta.join(" \u00b7 ")),
1901
+ typeof entry.cwd === "string" && entry.cwd !== "" ? h("div", { className: "wsr-page-path" }, entry.cwd) : null,
1902
+ ),
1903
+ h("div", { className: "wsr-page-actions" }, actions),
1904
+ ));
1905
+ })(view.entries[i]);
1906
+ }
1907
+
1908
+ return h("div", { className: "wsr-page" },
1909
+ h("div", { className: "wsr-page-head" },
1910
+ h("div", { className: "wsr-page-heading" }, t("trash.title")),
1911
+ h("button", {
1912
+ type: "button",
1913
+ className: "wsr-btn",
1914
+ onClick: function () { load(""); },
1915
+ }, t("ui.refresh")),
1916
+ h("button", {
1917
+ type: "button",
1918
+ className: "wsr-btn",
1919
+ onClick: function () { reloadButton().click(); },
1920
+ }, t("ui.reload")),
1921
+ ),
1922
+ view.note !== "" ? h("div", { className: "wsr-page-note" }, view.note) : null,
1923
+ view.failed !== "" ? h("div", { className: "wsr-page-note wsr-page-error" }, view.failed) : null,
1924
+ !view.loaded ? h("div", { className: "wsr-page-note" }, t("trash.loading"))
1925
+ : view.entries.length === 0 ? h("div", { className: "wsr-page-note" }, t("trash.empty"))
1926
+ : h("div", { className: "wsr-page-list" }, rows),
1927
+ h("div", { className: "wsr-page-note" }, t("trash.note")),
1928
+ );
1929
+ }
1930
+
1894
1931
  /**
1895
1932
  * Sidebar footer action: the trash, one click away from the account area.
1896
1933
  *
@@ -1906,17 +1943,36 @@
1906
1943
  return h("button", {
1907
1944
  type: "button",
1908
1945
  className: "wsr-footer-action",
1909
- "data-wsr-footer": "true",
1910
- "data-wide": wide ? "true" : "false",
1911
1946
  title: label,
1912
1947
  "aria-label": label,
1913
1948
  "aria-haspopup": "dialog",
1949
+ style: {
1950
+ boxSizing: "border-box",
1951
+ width: "100%",
1952
+ alignSelf: "stretch",
1953
+ display: "flex",
1954
+ alignItems: "center",
1955
+ justifyContent: "flex-start",
1956
+ gap: "10px",
1957
+ minHeight: "40px",
1958
+ padding: "0 10px",
1959
+ border: "none",
1960
+ background: "transparent",
1961
+ color: "var(--dsw-alias-label-primary)",
1962
+ borderRadius: "10px",
1963
+ font: "inherit",
1964
+ fontSize: "14px",
1965
+ lineHeight: "22px",
1966
+ cursor: "pointer",
1967
+ textAlign: "left",
1968
+ },
1914
1969
  onClick: function () { openTrashPanel(); },
1915
1970
  },
1916
- typeof Icon === "function"
1917
- ? h("span", { className: "wsr-footer-glyph", "aria-hidden": "true" }, h(Icon, { size: wide ? 16 : 18 }))
1918
- : null,
1919
- wide ? h("span", { className: "wsr-footer-label" }, label) : null);
1971
+ h("span", {
1972
+ style: { display: "inline-flex", alignItems: "center", justifyContent: "center", width: "20px", height: "20px", flex: "none" },
1973
+ "aria-hidden": "true",
1974
+ }, typeof Icon === "function" ? h(Icon, { size: 18 }) : null),
1975
+ wide ? h("span", { style: { whiteSpace: "nowrap", overflow: "hidden", textOverflow: "ellipsis" } }, label) : null);
1920
1976
  }
1921
1977
 
1922
1978
  /**
@@ -2088,13 +2144,22 @@
2088
2144
  }, ColorsRow);
2089
2145
  });
2090
2146
 
2091
- ctx.slots.inject("sidebar.footer.action", function () {
2147
+ ctx.slots.inject("sidebar.panellist", function () {
2148
+ return ctx.slots.register({
2149
+ name: "sidebar.panellist",
2150
+ id: "ws-recency-trash",
2151
+ order: 20,
2152
+ locale: NS,
2153
+ label: function () { return t("trash.title"); },
2154
+ }, TrashPanelIcon);
2155
+ });
2156
+
2157
+ ctx.slots.inject("main", function () {
2092
2158
  return ctx.slots.register({
2093
- name: "sidebar.footer.action",
2094
- id: "ws-recency-trash-footer",
2095
- order: 30,
2159
+ name: "main",
2160
+ key: "ws-recency-trash",
2096
2161
  locale: NS,
2097
- }, TrashFooterAction);
2162
+ }, TrashPanelPage);
2098
2163
  });
2099
2164
 
2100
2165
  ctx.slots.inject("settings.general.item", function () {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "dsh-ws-recency",
3
- "version": "0.13.4",
3
+ "version": "0.14.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, per-session token statistics split by tool, and moving a session to another workspace.",
5
5
  "license": "MIT",
6
6
  "author": "chyxhtc",