dsh-ws-recency 0.13.0 → 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 +128 -70
  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.0/dsh-ws-recency-0.13.0.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}",
@@ -132,11 +133,19 @@
132
133
  ".wsr-move-title{font-weight:500;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}",
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
- ".wsr-trash-row{display:flex;align-items:center;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:inline-flex;align-items:center;gap:6px;border:none;background:0 0;color:var(--dsw-alias-label-tertiary);font:inherit;cursor:pointer;padding:4px 8px;border-radius:6px}",
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:12px}",
139
- ".wsr-trash-actions{display:flex;gap:6px;flex:none}",
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
+ ".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}",
145
+ ".wsr-trash-actions{display:flex;gap:6px;flex:none;align-items:center;white-space:nowrap}",
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}",
147
+ ".wsr-btn:hover{background:var(--dsw-alias-interactive-bg-hover,rgba(255,255,255,.08))}",
148
+ ".wsr-btn-danger{border-color:var(--dsw-alias-state-error-primary,#d9534f);color:var(--dsw-alias-state-error-primary,#d9534f)}",
140
149
  ".wsr-danger{border-color:var(--dsw-alias-state-error-primary,#d9534f);color:var(--dsw-alias-state-error-primary,#d9534f)}",
141
150
  ".wsr-chart{display:flex;flex-direction:column;gap:6px}",
142
151
  ".wsr-chart-title{font-size:11px;color:var(--dsw-alias-label-tertiary)}",
@@ -239,7 +248,7 @@
239
248
  "trash.purge": "彻底删除",
240
249
  "trash.confirmRestore": "恢复到原来的工作区?",
241
250
  "trash.confirmPurge": "彻底删除这份日志?不可恢复。",
242
- "trash.restored": "已恢复,并重新挂回原工作区。若侧栏还没出现,去「补登记游离会话」点一下扫描(或重启应用)刷新列表。",
251
+ "trash.restored": "已恢复,并重新挂回原工作区。若侧栏还没出现,点下面的「刷新界面」,或在本页右上角点「扫描并刷新」。",
243
252
  "trash.purged": "已彻底删除。",
244
253
  "trash.working": "处理中…",
245
254
  "trash.failed": "操作失败:",
@@ -318,7 +327,7 @@
318
327
  "trash.purge": "Delete for good",
319
328
  "trash.confirmRestore": "Restore it to its original workspace?",
320
329
  "trash.confirmPurge": "Delete this log for good? This cannot be undone.",
321
- "trash.restored": "Restored and re-attached to its workspace. If the sidebar has not picked it up, run the \"Adopt unlisted sessions\" scan (or restart the app).",
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.",
322
331
  "trash.purged": "Deleted for good.",
323
332
  "trash.working": "Working\u2026",
324
333
  "trash.failed": "Action failed: ",
@@ -915,6 +924,53 @@
915
924
  return typeof id === "string" && id !== "" ? id : null;
916
925
  }
917
926
 
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
+ var clone;
947
+ try {
948
+ clone = template.cloneNode(true);
949
+ } catch (error) {
950
+ return;
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";
972
+ }
973
+
918
974
  /** The nearest horizontal flex row above the stats: the whole footer dock. */
919
975
  function composerDockOf(row) {
920
976
  var node = row;
@@ -1043,12 +1099,14 @@
1043
1099
  var settings = settingsOf();
1044
1100
  if (!ready(sessions) || !ready(workspaces)) {
1045
1101
  decorateComposerStats();
1102
+ decorateFooterAction();
1046
1103
  return;
1047
1104
  }
1048
1105
 
1049
1106
  var entries = collect();
1050
1107
  if (entries.length === 0) {
1051
1108
  decorateComposerStats();
1109
+ decorateFooterAction();
1052
1110
  return;
1053
1111
  }
1054
1112
 
@@ -1057,6 +1115,7 @@
1057
1115
  renderPinned(entries, sessions, workspaces, settings);
1058
1116
  if (settings.colors) decorateRows(entries, sessions, data.statuses, settings);
1059
1117
  decorateComposerStats();
1118
+ decorateFooterAction();
1060
1119
  }
1061
1120
 
1062
1121
  function schedule() {
@@ -1664,12 +1723,20 @@
1664
1723
  backdrop.appendChild(panel);
1665
1724
  var head = statsDiv("wsr-modal-head");
1666
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);
1667
1733
  var close = document.createElement("button");
1668
1734
  close.type = "button";
1669
1735
  close.className = "wsr-modal-close";
1670
1736
  close.textContent = "\u00d7";
1671
1737
  close.addEventListener("click", closeStatsPanel);
1672
- head.appendChild(close);
1738
+ tools.appendChild(close);
1739
+ head.appendChild(tools);
1673
1740
  panel.appendChild(head);
1674
1741
  var body = statsDiv("wsr-modal-body");
1675
1742
  panel.appendChild(body);
@@ -1737,7 +1804,7 @@
1737
1804
  if (entry.restorable === true) {
1738
1805
  var restore = document.createElement("button");
1739
1806
  restore.type = "button";
1740
- restore.className = "wsr-step";
1807
+ restore.className = "wsr-btn";
1741
1808
  restore.textContent = t("trash.restore");
1742
1809
  restore.addEventListener("click", function () {
1743
1810
  if (typeof window.confirm === "function" && !window.confirm(t("trash.confirmRestore"))) return;
@@ -1753,7 +1820,7 @@
1753
1820
  }
1754
1821
  var purge = document.createElement("button");
1755
1822
  purge.type = "button";
1756
- purge.className = "wsr-step wsr-danger";
1823
+ purge.className = "wsr-btn wsr-btn-danger";
1757
1824
  purge.textContent = t("trash.purge");
1758
1825
  purge.addEventListener("click", function () {
1759
1826
  if (typeof window.confirm === "function" && !window.confirm(t("trash.confirmPurge"))) return;
@@ -1776,10 +1843,26 @@
1776
1843
  body.textContent = t("trash.failed") + (error && error.message ? error.message : error);
1777
1844
  });
1778
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
+ });
1779
1855
  load("");
1780
1856
  }
1781
1857
 
1782
- /** 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
+ */
1783
1866
  function TrashFooterAction(props) {
1784
1867
  var wide = props === undefined || props === null || props.wide !== false;
1785
1868
  var label = t("trash.title");
@@ -1787,63 +1870,48 @@
1787
1870
  return h("button", {
1788
1871
  type: "button",
1789
1872
  className: "wsr-footer-action",
1873
+ "data-wsr-footer": "true",
1874
+ "data-wide": wide ? "true" : "false",
1790
1875
  title: label,
1791
1876
  "aria-label": label,
1877
+ "aria-haspopup": "dialog",
1792
1878
  onClick: function () { openTrashPanel(); },
1793
1879
  },
1794
- 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,
1795
1883
  wide ? h("span", { className: "wsr-footer-label" }, label) : null);
1796
1884
  }
1797
1885
 
1798
- /** Settings -> General: re-attach sessions that belong to no workspace. */
1799
- function AdoptRow() {
1800
- var result = react.useState("");
1801
- var message = result[0];
1802
- var setMessage = result[1];
1803
- var run = function () {
1804
- setMessage(t("adopt.working"));
1805
- fetch("/ws-recency/session-adopt", { method: "POST", headers: { "content-type": "application/json" }, body: "{}" })
1806
- .then(function (response) {
1807
- return response.text().then(function (text) {
1808
- var parsed = null;
1809
- try { parsed = JSON.parse(text); } catch (error) { parsed = null; }
1810
- return { status: response.status, text: text, json: parsed };
1811
- });
1812
- })
1813
- .then(function (answer) {
1814
- if (answer.json !== null && answer.json.ok === true) {
1815
- var count = Array.isArray(answer.json.adopted) ? answer.json.adopted.length : 0;
1816
- var cleaned = typeof answer.json.cleaned === "number" ? answer.json.cleaned : 0;
1817
- var text = t("adopt.done", { n: count });
1818
- if (cleaned > 0) text += t("adopt.cleaned", { n: cleaned });
1819
- setMessage(text);
1820
- /* The scan is the refresh: reload once it has changed something. */
1821
- if (count > 0 || cleaned > 0) {
1822
- window.setTimeout(function () {
1823
- try {
1824
- if (window.location !== undefined && typeof window.location.reload === "function") window.location.reload();
1825
- } catch (error) {
1826
- /* nothing to do */
1827
- }
1828
- }, 900);
1829
- }
1830
- return;
1831
- }
1832
- setMessage(t("adopt.failed") + (answer.json && answer.json.error ? answer.json.error : answer.text.slice(0, 120)));
1833
- })
1834
- .catch(function (error) {
1835
- 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 };
1836
1899
  });
1837
- };
1838
- return h("div", { className: "wsr-setRow" },
1839
- h("div", { className: "wsr-setText" },
1840
- h("div", { className: "wsr-setTitle" }, t("adopt.title")),
1841
- h("div", { className: "wsr-setDesc" }, message === "" ? t("adopt.description") : message),
1842
- ),
1843
- h("div", { className: "wsr-controls" },
1844
- h("button", { type: "button", className: "wsr-step", onClick: run }, t("adopt.action")),
1845
- ),
1846
- );
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
+ });
1847
1915
  }
1848
1916
 
1849
1917
  /** Settings -> General row: the global pinned section on/off. */
@@ -1993,16 +2061,6 @@
1993
2061
  }, TrashFooterAction);
1994
2062
  });
1995
2063
 
1996
- ctx.slots.inject("settings.general.item", function () {
1997
- return ctx.slots.register({
1998
- name: "settings.general.item",
1999
- id: "ws-recency-adopt",
2000
- order: 49,
2001
- store: prefs,
2002
- locale: NS,
2003
- }, AdoptRow);
2004
- });
2005
-
2006
2064
  ctx.slots.inject("settings.general.item", function () {
2007
2065
  return ctx.slots.register({
2008
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.0",
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",