dsh-ws-recency 0.13.5 → 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 +137 -5
  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.5/dsh-ws-recency-0.13.5.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",
@@ -1805,6 +1819,115 @@
1805
1819
  load("");
1806
1820
  }
1807
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
+
1808
1931
  /**
1809
1932
  * Sidebar footer action: the trash, one click away from the account area.
1810
1933
  *
@@ -2021,13 +2144,22 @@
2021
2144
  }, ColorsRow);
2022
2145
  });
2023
2146
 
2024
- 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 () {
2025
2158
  return ctx.slots.register({
2026
- name: "sidebar.footer.action",
2027
- id: "ws-recency-trash-footer",
2028
- order: 30,
2159
+ name: "main",
2160
+ key: "ws-recency-trash",
2029
2161
  locale: NS,
2030
- }, TrashFooterAction);
2162
+ }, TrashPanelPage);
2031
2163
  });
2032
2164
 
2033
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.5",
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",