dsh-ws-recency 0.13.1 → 0.13.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/README.md +2 -2
  2. package/client.js +105 -87
  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.1/dsh-ws-recency-0.13.1.tgz
138
+ dsh plugin --profile <profile> add https://github.com/chyxhtc/dsh-ws-recency/releases/download/v0.13.2/dsh-ws-recency-0.13.2.tgz
139
139
  ```
140
140
 
141
141
  装完把 `dsh-ws-recency` 加进 `~/.hypers-work/profiles/<profile>/package.json` 的 `dsh.profile.bundles`,重启应用。
package/client.js CHANGED
@@ -113,6 +113,7 @@
113
113
  ".wsr-modal-title{font-size:14px;font-weight:600}",
114
114
  ".wsr-modal-close{border:none;background:transparent;color:var(--dsw-alias-label-tertiary,#9aa0a6);font-size:18px;line-height:1;cursor:pointer;padding:2px 6px;border-radius:4px}",
115
115
  ".wsr-modal-close:hover{color:var(--dsw-alias-label-primary,#e8e8e8)}",
116
+ ".wsr-modal-tools{display:flex;align-items:center;gap:8px;flex:none}",
116
117
  ".wsr-modal-body{padding:14px;overflow:auto;display:flex;flex-direction:column;gap:12px;font-size:12px}",
117
118
  ".wsr-stats-grid{display:grid;grid-template-columns:repeat(5,1fr);gap:8px}",
118
119
  ".wsr-stats-card{background:var(--dsw-alias-bg-layer-2,rgba(255,255,255,.04));border-radius:8px;padding:8px 10px}",
@@ -133,9 +134,14 @@
133
134
  ".wsr-move-path{font-size:11px;color:var(--dsw-alias-label-tertiary);overflow:hidden;text-overflow:ellipsis;white-space:nowrap}",
134
135
  ".wsr-move-badge{font-size:11px;color:var(--dsw-alias-label-tertiary)}",
135
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))}",
136
- ".wsr-footer-action{display:flex;align-items:center;justify-content:flex-start;gap:8px;width:100%;border:none;background:0 0;color:var(--dsw-alias-label-primary,#e6e6e6);font:inherit;cursor:pointer;padding:6px 8px;border-radius:8px;text-align:left}",
137
- ".wsr-footer-action:hover{background:var(--dsw-alias-interactive-bg-hover,rgba(255,255,255,.08));color:var(--dsw-alias-label-primary)}",
138
- ".wsr-footer-label{font-size:inherit;line-height:inherit;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}",
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
+ ".wsr-footer-action:hover{background:var(--dsw-alias-interactive-bg-hover)}",
139
+ ".wsr-footer-action:active{background:var(--dsw-alias-interactive-bg-active)}",
140
+ ".wsr-footer-action:focus-visible{outline:2px solid var(--dsw-alias-brand-primary);outline-offset:3px}",
141
+ '.wsr-footer-action[data-wide="false"]{width:36px;height:36px;margin:8px 0 10px;padding:0;gap:0;border-radius:50%;justify-content:center}',
142
+ ".wsr-footer-glyph{display:inline-flex;align-items:center;justify-content:center;flex:none;width:16px;height:16px}",
143
+ '.wsr-footer-action[data-wide="false"] .wsr-footer-glyph{width:18px;height:18px}',
144
+ ".wsr-footer-label{min-width:0;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}",
139
145
  ".wsr-trash-actions{display:flex;gap:6px;flex:none;align-items:center;white-space:nowrap}",
140
146
  ".wsr-btn{border:.5px solid var(--dsw-alias-border-l2,rgba(255,255,255,.16));background:0 0;color:var(--dsw-alias-label-primary,#e6e6e6);font:inherit;font-size:12px;line-height:1.6;padding:3px 10px;border-radius:6px;cursor:pointer;white-space:nowrap;flex:none}",
141
147
  ".wsr-btn:hover{background:var(--dsw-alias-interactive-bg-hover,rgba(255,255,255,.08))}",
@@ -242,7 +248,7 @@
242
248
  "trash.purge": "彻底删除",
243
249
  "trash.confirmRestore": "恢复到原来的工作区?",
244
250
  "trash.confirmPurge": "彻底删除这份日志?不可恢复。",
245
- "trash.restored": "已恢复,并重新挂回原工作区。若侧栏还没出现,点下面的「刷新界面」(或去「补登记游离会话」点「扫描并刷新」)。",
251
+ "trash.restored": "已恢复,并重新挂回原工作区。若侧栏还没出现,点下面的「刷新界面」,或在本页右上角点「扫描并刷新」。",
246
252
  "trash.purged": "已彻底删除。",
247
253
  "trash.working": "处理中…",
248
254
  "trash.failed": "操作失败:",
@@ -321,7 +327,7 @@
321
327
  "trash.purge": "Delete for good",
322
328
  "trash.confirmRestore": "Restore it to its original workspace?",
323
329
  "trash.confirmPurge": "Delete this log for good? This cannot be undone.",
324
- "trash.restored": "Restored and re-attached to its workspace. If the sidebar has not picked it up, press \"Reload UI\" below (or run \"Scan and reload\").",
330
+ "trash.restored": "Restored and re-attached to its workspace. If the sidebar has not picked it up, press \"Reload UI\" below, or use \"Scan and reload\" at the top right of this panel.",
325
331
  "trash.purged": "Deleted for good.",
326
332
  "trash.working": "Working\u2026",
327
333
  "trash.failed": "Action failed: ",
@@ -918,37 +924,51 @@
918
924
  return typeof id === "string" && id !== "" ? id : null;
919
925
  }
920
926
 
921
- /**
922
- * Match the footer action to its neighbours.
923
- *
924
- * The footer slot stacks actions, but each shell entry carries its own
925
- * sizing; copying the metrics of the first real sibling keeps our row on
926
- * the same baseline, font size and width instead of centring a smaller one.
927
- */
927
+ /** Clone one real footer entry into the slot so the icon box and text line up. */
928
928
  function decorateFooterAction() {
929
929
  if (typeof document === "undefined") return;
930
930
  var mine = document.querySelector('[data-wsr-footer="true"]');
931
- if (mine === null || typeof mine.getAttribute !== "function") return;
931
+ if (mine === null || typeof mine.parentElement === "undefined" || mine.parentElement === null) return;
932
932
  var container = mine.parentElement;
933
- if (container === null || typeof container.querySelectorAll !== "function") return;
934
- if (typeof window === "undefined" || typeof window.getComputedStyle !== "function") return;
935
- var candidates = container.querySelectorAll("button");
933
+ if (typeof container.querySelectorAll !== "function" || typeof container.insertBefore !== "function") return;
934
+ if (container.querySelector("[data-wsr-clone]") !== null || typeof mine.style === "undefined") return;
936
935
  var template = null;
937
- for (var i = 0; i < candidates.length; i += 1) {
938
- var candidate = candidates[i];
936
+ var buttons = container.querySelectorAll("button");
937
+ for (var i = 0; i < buttons.length; i += 1) {
938
+ var candidate = buttons[i];
939
939
  if (candidate === mine) continue;
940
- if (typeof candidate.getAttribute === "function" && candidate.getAttribute("data-wsr-footer") !== null) 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;
941
942
  template = candidate;
942
943
  break;
943
944
  }
944
- if (template === null) return;
945
- var metrics = ["font-size", "font-family", "font-weight", "line-height", "padding", "gap", "width", "height", "justify-content", "color", "border-radius", "margin"];
946
- for (var k = 0; k < metrics.length; k += 1) {
947
- var value = "";
948
- try { value = window.getComputedStyle(template).getPropertyValue(metrics[k]) || ""; } catch (error) { value = ""; }
949
- if (value === "" || value === "auto") continue;
950
- mine.style[metrics[k]] = value;
945
+ if (template === null || typeof template.cloneNode !== "function") return;
946
+ var clone;
947
+ try {
948
+ clone = template.cloneNode(true);
949
+ } catch (error) {
950
+ return;
951
951
  }
952
+ var icon = typeof clone.querySelector === "function" ? clone.querySelector("svg") : null;
953
+ var labelClass = "";
954
+ if (typeof clone.querySelector === "function") {
955
+ var labelTemplate = clone.querySelector("span");
956
+ if (labelTemplate !== null && typeof labelTemplate.className === "string") labelClass = labelTemplate.className;
957
+ }
958
+ while (clone.firstChild !== null) clone.removeChild(clone.firstChild);
959
+ if (icon !== null) clone.appendChild(icon);
960
+ var label = document.createElement("span");
961
+ if (labelClass !== "") label.className = labelClass;
962
+ label.textContent = t("trash.title");
963
+ clone.appendChild(label);
964
+ clone.setAttribute("data-wsr-clone", "true");
965
+ clone.setAttribute("aria-label", t("trash.title"));
966
+ clone.addEventListener("click", function (event) {
967
+ if (event !== undefined && typeof event.preventDefault === "function") event.preventDefault();
968
+ openTrashPanel();
969
+ });
970
+ container.insertBefore(clone, mine);
971
+ mine.style.display = "none";
952
972
  }
953
973
 
954
974
  /** The nearest horizontal flex row above the stats: the whole footer dock. */
@@ -1703,12 +1723,20 @@
1703
1723
  backdrop.appendChild(panel);
1704
1724
  var head = statsDiv("wsr-modal-head");
1705
1725
  head.appendChild(statsDiv("wsr-modal-title", t("trash.title")));
1726
+ var tools = statsDiv("wsr-modal-tools");
1727
+ var adopt = document.createElement("button");
1728
+ adopt.type = "button";
1729
+ adopt.className = "wsr-btn";
1730
+ adopt.title = t("adopt.description");
1731
+ adopt.textContent = t("adopt.action");
1732
+ tools.appendChild(adopt);
1706
1733
  var close = document.createElement("button");
1707
1734
  close.type = "button";
1708
1735
  close.className = "wsr-modal-close";
1709
1736
  close.textContent = "\u00d7";
1710
1737
  close.addEventListener("click", closeStatsPanel);
1711
- head.appendChild(close);
1738
+ tools.appendChild(close);
1739
+ head.appendChild(tools);
1712
1740
  panel.appendChild(head);
1713
1741
  var body = statsDiv("wsr-modal-body");
1714
1742
  panel.appendChild(body);
@@ -1815,10 +1843,26 @@
1815
1843
  body.textContent = t("trash.failed") + (error && error.message ? error.message : error);
1816
1844
  });
1817
1845
  };
1846
+ adopt.addEventListener("click", function () {
1847
+ adopt.disabled = true;
1848
+ adopt.textContent = t("adopt.working");
1849
+ adoptUnlistedSessions(function (message) {
1850
+ adopt.disabled = false;
1851
+ adopt.textContent = t("adopt.action");
1852
+ load(message);
1853
+ });
1854
+ });
1818
1855
  load("");
1819
1856
  }
1820
1857
 
1821
- /** Sidebar footer action: the trash, one click away from the account area. */
1858
+ /**
1859
+ * Sidebar footer action: the trash, one click away from the account area.
1860
+ *
1861
+ * Geometry is the same house rule the official launchers follow
1862
+ * (`dshUpdateLauncher` / `dshMarketLauncher`): full-width seat bled 2px
1863
+ * per side, 42px tall, 12px radius. `wide` comes from the slot, so the
1864
+ * narrow rail keeps its 36px circle instead of a stretched row.
1865
+ */
1822
1866
  function TrashFooterAction(props) {
1823
1867
  var wide = props === undefined || props === null || props.wide !== false;
1824
1868
  var label = t("trash.title");
@@ -1827,63 +1871,47 @@
1827
1871
  type: "button",
1828
1872
  className: "wsr-footer-action",
1829
1873
  "data-wsr-footer": "true",
1874
+ "data-wide": wide ? "true" : "false",
1830
1875
  title: label,
1831
1876
  "aria-label": label,
1877
+ "aria-haspopup": "dialog",
1832
1878
  onClick: function () { openTrashPanel(); },
1833
1879
  },
1834
- typeof Icon === "function" ? h(Icon, {}) : null,
1880
+ typeof Icon === "function"
1881
+ ? h("span", { className: "wsr-footer-glyph", "aria-hidden": "true" }, h(Icon, { size: wide ? 16 : 18 }))
1882
+ : null,
1835
1883
  wide ? h("span", { className: "wsr-footer-label" }, label) : null);
1836
1884
  }
1837
1885
 
1838
- /** Settings -> General: re-attach sessions that belong to no workspace. */
1839
- function AdoptRow() {
1840
- var result = react.useState("");
1841
- var message = result[0];
1842
- var setMessage = result[1];
1843
- var run = function () {
1844
- setMessage(t("adopt.working"));
1845
- fetch("/ws-recency/session-adopt", { method: "POST", headers: { "content-type": "application/json" }, body: "{}" })
1846
- .then(function (response) {
1847
- return response.text().then(function (text) {
1848
- var parsed = null;
1849
- try { parsed = JSON.parse(text); } catch (error) { parsed = null; }
1850
- return { status: response.status, text: text, json: parsed };
1851
- });
1852
- })
1853
- .then(function (answer) {
1854
- if (answer.json !== null && answer.json.ok === true) {
1855
- var count = Array.isArray(answer.json.adopted) ? answer.json.adopted.length : 0;
1856
- var cleaned = typeof answer.json.cleaned === "number" ? answer.json.cleaned : 0;
1857
- var text = t("adopt.done", { n: count });
1858
- if (cleaned > 0) text += t("adopt.cleaned", { n: cleaned });
1859
- setMessage(text);
1860
- /* The scan is the refresh: reload once it has changed something. */
1861
- if (count > 0 || cleaned > 0) {
1862
- window.setTimeout(function () {
1863
- try {
1864
- if (window.location !== undefined && typeof window.location.reload === "function") window.location.reload();
1865
- } catch (error) {
1866
- /* nothing to do */
1867
- }
1868
- }, 900);
1869
- }
1870
- return;
1871
- }
1872
- setMessage(t("adopt.failed") + (answer.json && answer.json.error ? answer.json.error : answer.text.slice(0, 120)));
1873
- })
1874
- .catch(function (error) {
1875
- setMessage(t("adopt.failed") + (error && error.message ? error.message : error));
1886
+ /**
1887
+ * Re-attach sessions that belong to no workspace.
1888
+ *
1889
+ * General Settings is the host's own page, so this repair action lives in
1890
+ * our trash panel instead of posing as a shell preference there.
1891
+ */
1892
+ function adoptUnlistedSessions(done) {
1893
+ fetch("/ws-recency/session-adopt", { method: "POST", headers: { "content-type": "application/json" }, body: "{}" })
1894
+ .then(function (response) {
1895
+ return response.text().then(function (text) {
1896
+ var parsed = null;
1897
+ try { parsed = JSON.parse(text); } catch (error) { parsed = null; }
1898
+ return { status: response.status, text: text, json: parsed };
1876
1899
  });
1877
- };
1878
- return h("div", { className: "wsr-setRow" },
1879
- h("div", { className: "wsr-setText" },
1880
- h("div", { className: "wsr-setTitle" }, t("adopt.title")),
1881
- h("div", { className: "wsr-setDesc" }, message === "" ? t("adopt.description") : message),
1882
- ),
1883
- h("div", { className: "wsr-controls" },
1884
- h("button", { type: "button", className: "wsr-btn", onClick: run }, t("adopt.action")),
1885
- ),
1886
- );
1900
+ })
1901
+ .then(function (answer) {
1902
+ if (answer.json !== null && answer.json.ok === true) {
1903
+ var count = Array.isArray(answer.json.adopted) ? answer.json.adopted.length : 0;
1904
+ var cleaned = typeof answer.json.cleaned === "number" ? answer.json.cleaned : 0;
1905
+ var text = t("adopt.done", { n: count });
1906
+ if (cleaned > 0) text += t("adopt.cleaned", { n: cleaned });
1907
+ done(text);
1908
+ return;
1909
+ }
1910
+ done(t("adopt.failed") + (answer.json && answer.json.error ? answer.json.error : answer.text.slice(0, 120)));
1911
+ })
1912
+ .catch(function (error) {
1913
+ done(t("adopt.failed") + (error && error.message ? error.message : error));
1914
+ });
1887
1915
  }
1888
1916
 
1889
1917
  /** Settings -> General row: the global pinned section on/off. */
@@ -2033,16 +2061,6 @@
2033
2061
  }, TrashFooterAction);
2034
2062
  });
2035
2063
 
2036
- ctx.slots.inject("settings.general.item", function () {
2037
- return ctx.slots.register({
2038
- name: "settings.general.item",
2039
- id: "ws-recency-adopt",
2040
- order: 49,
2041
- store: prefs,
2042
- locale: NS,
2043
- }, AdoptRow);
2044
- });
2045
-
2046
2064
  ctx.slots.inject("settings.general.item", function () {
2047
2065
  return ctx.slots.register({
2048
2066
  name: "settings.general.item",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "dsh-ws-recency",
3
- "version": "0.13.1",
3
+ "version": "0.13.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, per-session token statistics split by tool, and moving a session to another workspace.",
5
5
  "license": "MIT",
6
6
  "author": "chyxhtc",