dsh-ws-recency 0.26.2 → 0.27.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.
- package/README.md +2 -1
- package/client.js +26 -9
- package/index.js +70 -6
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -65,6 +65,7 @@ DSH 原生的置顶只把会话顶到**它所属工作区分组的第一行**,
|
|
|
65
65
|
- **移到回收站**:走下面那套正常删除,日志改名搬进 `.trash/ws-recency/`,之后仍可恢复;
|
|
66
66
|
- **彻底删除**:先移进回收站再立即清空,和回收站的「彻底删除」是同一条路径(二次确认);
|
|
67
67
|
- 宿主的归档集合变动会通过它的 workspace feed 推到浏览器,所以取消归档后侧栏会自己把行放回去,不用刷新界面。
|
|
68
|
+
- **记录失效的行(0.27.0)**:如果日志目录被外部删掉(手工删除、磁盘清理、别的工具清理),归档标记会留下来。这时这一行会标「记录失效」,三个常规动作全部隐藏——它们都会报 session not found——只留一个 **移出归档**:只清掉归档标记、工作区槽位和投影缓存,**不删除任何文件**,确认框里也写明了这一点。日志还存在的会话不会出现这个按钮。
|
|
68
69
|
|
|
69
70
|
### 删除(宿主没有的,本插件补上)
|
|
70
71
|
|
|
@@ -196,7 +197,7 @@ dsh plugin --profile <profile> add github:chyxhtc/dsh-ws-recency
|
|
|
196
197
|
或固定版本的预构建包:
|
|
197
198
|
|
|
198
199
|
```powershell
|
|
199
|
-
dsh plugin --profile <profile> add https://github.com/chyxhtc/dsh-ws-recency/releases/download/v0.
|
|
200
|
+
dsh plugin --profile <profile> add https://github.com/chyxhtc/dsh-ws-recency/releases/download/v0.27.0/dsh-ws-recency-0.27.0.tgz
|
|
200
201
|
```
|
|
201
202
|
|
|
202
203
|
装完把 `dsh-ws-recency` 加进 `~/.hypers-work/profiles/<profile>/package.json` 的 `dsh.profile.bundles`,重启应用。
|
package/client.js
CHANGED
|
@@ -197,6 +197,7 @@
|
|
|
197
197
|
".wsr-card-badge{flex:none;font-size:11px;line-height:18px;padding:0 8px;border-radius:9px;background:var(--dsw-alias-bg-layer-3,rgba(255,255,255,.08));color:var(--dsw-alias-label-secondary)}",
|
|
198
198
|
".wsr-card-badge-danger{color:var(--dsw-alias-state-error-primary,#d9534f);background:color-mix(in srgb,var(--dsw-alias-state-error-primary,#d9534f) 14%,transparent)}",
|
|
199
199
|
".wsr-card-badge-muted{color:var(--dsw-alias-label-tertiary)}",
|
|
200
|
+
".wsr-card-badge-warning{color:#d99a2b}",
|
|
200
201
|
".wsr-card-title{flex:1;min-width:0;font-size:13px;font-weight:500;color:var(--dsw-alias-label-primary);overflow:hidden;text-overflow:ellipsis;white-space:nowrap}",
|
|
201
202
|
".wsr-card-title-id{font-family:ui-monospace,SFMono-Regular,Menlo,monospace;font-size:12px;color:var(--dsw-alias-label-tertiary)}",
|
|
202
203
|
".wsr-card-actions{flex:none;display:flex;gap:6px;align-items:center;white-space:nowrap}",
|
|
@@ -443,6 +444,10 @@
|
|
|
443
444
|
"archive.confirmUnarchive": "把这个会话放回原工作区的原位置?",
|
|
444
445
|
"archive.confirmDelete": "把这个会话移入回收站?之后仍可在上面一栏恢复。",
|
|
445
446
|
"archive.confirmForget": "彻底删除这个会话的日志?不可恢复。",
|
|
447
|
+
"archive.badgeMissing": "记录失效",
|
|
448
|
+
"archive.detach": "移出归档",
|
|
449
|
+
"archive.detached": "已移出归档:只清理了归档记录,没有删除任何文件。",
|
|
450
|
+
"archive.confirmDetach": "这个会话的日志已经不在磁盘上,只剩一条归档记录。要把它移出归档列表吗?\n\n只清理记录,不会删除任何文件;如果日志以后又被恢复,需要重新归档。",
|
|
446
451
|
"archive.unarchived": "已取消归档,会话回到原来的位置。",
|
|
447
452
|
"archive.deleted": "已移入回收站,可在「已删除的会话」里恢复。",
|
|
448
453
|
"archive.forgotten": "已彻底删除。",
|
|
@@ -606,6 +611,10 @@
|
|
|
606
611
|
"archive.confirmUnarchive": "Put this session back where it was in its workspace?",
|
|
607
612
|
"archive.confirmDelete": "Move this session into the trash? You can still restore it from the section above.",
|
|
608
613
|
"archive.confirmForget": "Delete this session's log for good? This cannot be undone.",
|
|
614
|
+
"archive.badgeMissing": "record only",
|
|
615
|
+
"archive.detach": "Remove from archive",
|
|
616
|
+
"archive.detached": "Removed from the archive: only the archive record was cleared, no files were touched.",
|
|
617
|
+
"archive.confirmDetach": "This session's log is no longer on disk; only its archive record is left. Remove that record from the archive list?\n\nNo files are touched. If the log ever comes back, the session has to be archived again.",
|
|
609
618
|
"archive.unarchived": "Unarchived: the session is back in its place.",
|
|
610
619
|
"archive.deleted": "Moved into the trash; restore it from \"Deleted sessions\".",
|
|
611
620
|
"archive.forgotten": "Deleted for good.",
|
|
@@ -3697,8 +3706,9 @@
|
|
|
3697
3706
|
|
|
3698
3707
|
var actArchived = function (entry, action) {
|
|
3699
3708
|
var question = action === "unarchive" ? t("archive.confirmUnarchive")
|
|
3700
|
-
: action === "
|
|
3701
|
-
: t("archive.
|
|
3709
|
+
: action === "detach" ? t("archive.confirmDetach")
|
|
3710
|
+
: action === "forget" ? t("archive.confirmForget")
|
|
3711
|
+
: t("archive.confirmDelete");
|
|
3702
3712
|
askConfirm(question, function () {
|
|
3703
3713
|
load(t("trash.working"));
|
|
3704
3714
|
trashPost({ action: action, sessionId: entry.sessionId }).then(function (result) {
|
|
@@ -3708,6 +3718,8 @@
|
|
|
3708
3718
|
}
|
|
3709
3719
|
if (action === "unarchive") {
|
|
3710
3720
|
load(t("archive.unarchived") + (result.json.listed === false ? t("archive.noWorkspace") : ""));
|
|
3721
|
+
} else if (action === "detach") {
|
|
3722
|
+
load(t("archive.detached"));
|
|
3711
3723
|
} else if (action === "forget") {
|
|
3712
3724
|
load(t("archive.forgotten"));
|
|
3713
3725
|
} else {
|
|
@@ -3770,20 +3782,25 @@
|
|
|
3770
3782
|
if (when !== "") chips.push(when);
|
|
3771
3783
|
if (entry.blank === true) chips.push(t("archive.blank"));
|
|
3772
3784
|
var hasTitle = typeof entry.title === "string" && entry.title !== "";
|
|
3785
|
+
/* A log that is gone can only be detached from the archive set;
|
|
3786
|
+
the other three actions would all fail with "session not found". */
|
|
3787
|
+
var missing = entry.missing === true;
|
|
3773
3788
|
archivedRows.push(entryCard({
|
|
3774
3789
|
key: entry.sessionId,
|
|
3775
|
-
badge: t("archive.badge"),
|
|
3776
|
-
badgeClass: "wsr-card-badge-muted",
|
|
3790
|
+
badge: missing ? t("archive.badgeMissing") : t("archive.badge"),
|
|
3791
|
+
badgeClass: missing ? "wsr-card-badge-warning" : "wsr-card-badge-muted",
|
|
3777
3792
|
titleClass: hasTitle ? "wsr-card-title" : "wsr-card-title wsr-card-title-id",
|
|
3778
3793
|
title: hasTitle ? entry.title : entry.sessionId,
|
|
3779
3794
|
titleAttr: entry.sessionId,
|
|
3780
3795
|
chips: chips,
|
|
3781
3796
|
path: typeof entry.workspacePath === "string" && entry.workspacePath !== "" ? entry.workspacePath : entry.cwd,
|
|
3782
|
-
actions:
|
|
3783
|
-
h("button", { type: "button", className: "wsr-btn", onClick: function () { actArchived(entry, "
|
|
3784
|
-
|
|
3785
|
-
|
|
3786
|
-
|
|
3797
|
+
actions: missing
|
|
3798
|
+
? [h("button", { type: "button", className: "wsr-btn", onClick: function () { actArchived(entry, "detach"); } }, t("archive.detach"))]
|
|
3799
|
+
: [
|
|
3800
|
+
h("button", { type: "button", className: "wsr-btn", onClick: function () { actArchived(entry, "unarchive"); } }, t("archive.unarchive")),
|
|
3801
|
+
h("button", { type: "button", className: "wsr-btn", onClick: function () { actArchived(entry, "delete"); } }, t("archive.delete")),
|
|
3802
|
+
h("button", { type: "button", className: "wsr-btn wsr-btn-danger", onClick: function () { actArchived(entry, "forget"); } }, t("archive.forget")),
|
|
3803
|
+
],
|
|
3787
3804
|
}));
|
|
3788
3805
|
})(archivedList[j]);
|
|
3789
3806
|
}
|
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.
|
|
35
|
+
export const HOST_VERSION = "0.27.0";
|
|
36
36
|
|
|
37
37
|
/**
|
|
38
38
|
* Exact routes the client half calls. Registered on the bare web server, so they
|
|
@@ -1602,6 +1602,19 @@ export async function listArchivedSessions(ctx) {
|
|
|
1602
1602
|
let workspace = workspaces.find((candidate) => listedBy(candidate, raw, sessionId));
|
|
1603
1603
|
if (workspace === undefined && cwd !== null) workspace = workspaces.find((candidate) => candidate.path === cwd);
|
|
1604
1604
|
|
|
1605
|
+
/* Is the log still there? `stat` and the listing can disagree when the
|
|
1606
|
+
directory was removed under a running Host, so ask directly once and
|
|
1607
|
+
treat the answer as the authority for the row's actions. */
|
|
1608
|
+
let available = header !== undefined;
|
|
1609
|
+
if (!available) {
|
|
1610
|
+
try {
|
|
1611
|
+
const stat = await ctx.sessionPersistence.stat(sessionId);
|
|
1612
|
+
available = stat !== undefined && stat !== null;
|
|
1613
|
+
} catch {
|
|
1614
|
+
available = false;
|
|
1615
|
+
}
|
|
1616
|
+
}
|
|
1617
|
+
|
|
1605
1618
|
entries.push({
|
|
1606
1619
|
sessionId,
|
|
1607
1620
|
title,
|
|
@@ -1617,6 +1630,8 @@ export async function listArchivedSessions(ctx) {
|
|
|
1617
1630
|
workspacePath: workspace !== undefined ? workspace.path : null,
|
|
1618
1631
|
/* Whether a Workspace still lists it: an unarchive without one has nowhere to show up. */
|
|
1619
1632
|
listed: workspace !== undefined,
|
|
1633
|
+
/* The archive flag outlived its log: the row can only be detached from the set. */
|
|
1634
|
+
missing: !available,
|
|
1620
1635
|
});
|
|
1621
1636
|
}
|
|
1622
1637
|
entries.sort((a, b) => b.lastAt - a.lastAt || (a.sessionId < b.sessionId ? -1 : 1));
|
|
@@ -1669,6 +1684,52 @@ export async function restoreArchivedSession(ctx, sessionId) {
|
|
|
1669
1684
|
return { ok: true, sessionId, cwd, createdAt, listed };
|
|
1670
1685
|
}
|
|
1671
1686
|
|
|
1687
|
+
/**
|
|
1688
|
+
* Detach an archive flag whose session is gone.
|
|
1689
|
+
*
|
|
1690
|
+
* Only bookkeeping is touched: the id leaves the registry's archive set, every
|
|
1691
|
+
* Workspace listing it drops the slot, and the projection cache row goes. No
|
|
1692
|
+
* directory is removed - the point is that after an out-of-band delete the flag
|
|
1693
|
+
* is all that is left, and leaving it behind is worse than removing it.
|
|
1694
|
+
*
|
|
1695
|
+
* Refuses when the session still exists: this entry point must never be a
|
|
1696
|
+
* second, quieter way to delete a live session.
|
|
1697
|
+
*/
|
|
1698
|
+
export async function detachMissingArchive(ctx, sessionId) {
|
|
1699
|
+
if (!archivedSessionIds(ctx).includes(sessionId)) return { ok: false, error: "session is not archived" };
|
|
1700
|
+
try {
|
|
1701
|
+
const stat = await ctx.sessionPersistence.stat(sessionId);
|
|
1702
|
+
if (stat !== undefined && stat !== null) return { ok: false, error: "session still exists" };
|
|
1703
|
+
} catch {
|
|
1704
|
+
/* a failed stat is the case this action is for */
|
|
1705
|
+
}
|
|
1706
|
+
|
|
1707
|
+
try {
|
|
1708
|
+
await ctx.workspaceRegistry.unarchiveSession(sessionId);
|
|
1709
|
+
} catch (error) {
|
|
1710
|
+
return { ok: false, error: `could not unarchive: ${error instanceof Error ? error.message : String(error)}` };
|
|
1711
|
+
}
|
|
1712
|
+
const raw = await rawWorkspaceMembership();
|
|
1713
|
+
for (const workspace of ctx.workspaceRegistry.list()) {
|
|
1714
|
+
if (!listedBy(workspace, raw, sessionId)) continue;
|
|
1715
|
+
try {
|
|
1716
|
+
await workspace.detachSession(sessionId);
|
|
1717
|
+
} catch {
|
|
1718
|
+
/* keep going: the remaining holders are reported by the next listing */
|
|
1719
|
+
}
|
|
1720
|
+
}
|
|
1721
|
+
try {
|
|
1722
|
+
const domain = ctx.get("storageDomain");
|
|
1723
|
+
const projcache = typeof domain?.get === "function" ? domain.get("session_projcache") : undefined;
|
|
1724
|
+
if (projcache !== undefined) await projcache.table("sessions").delete(sessionId);
|
|
1725
|
+
} catch {
|
|
1726
|
+
/* derived data */
|
|
1727
|
+
}
|
|
1728
|
+
/* No `announceSession` here: with the log gone there is no summary to hand
|
|
1729
|
+
the sidebar, and a failed stat would only leave a stale row in view. */
|
|
1730
|
+
return { ok: true, sessionId, removedFromArchive: !archivedSessionIds(ctx).includes(sessionId) };
|
|
1731
|
+
}
|
|
1732
|
+
|
|
1672
1733
|
/**
|
|
1673
1734
|
* Delete an archived session for good.
|
|
1674
1735
|
*
|
|
@@ -1815,19 +1876,22 @@ export async function handleTrashListRequest(ctx, req, res) {
|
|
|
1815
1876
|
sendJson(res, 200, await listArchivedSessions(ctx));
|
|
1816
1877
|
return;
|
|
1817
1878
|
}
|
|
1818
|
-
if (action === "unarchive" || action === "forget" || action === "delete") {
|
|
1879
|
+
if (action === "unarchive" || action === "forget" || action === "delete" || action === "detach") {
|
|
1819
1880
|
const sessionId = sessionIdFrom(req, body);
|
|
1820
1881
|
if (sessionId === "") {
|
|
1821
1882
|
sendJson(res, 400, { ok: false, error: "sessionId required" });
|
|
1822
1883
|
return;
|
|
1823
1884
|
}
|
|
1824
1885
|
/* `delete` is the archived row's way into the recoverable trash; the other
|
|
1825
|
-
two either put the session back or erase it afterwards.
|
|
1886
|
+
two either put the session back or erase it afterwards. `detach` only
|
|
1887
|
+
sheds an archive flag whose log is already gone. */
|
|
1826
1888
|
const result = action === "unarchive"
|
|
1827
1889
|
? await restoreArchivedSession(ctx, sessionId)
|
|
1828
|
-
: action === "
|
|
1829
|
-
? await
|
|
1830
|
-
:
|
|
1890
|
+
: action === "detach"
|
|
1891
|
+
? await detachMissingArchive(ctx, sessionId)
|
|
1892
|
+
: action === "forget"
|
|
1893
|
+
? await forgetArchivedSession(ctx, sessionId)
|
|
1894
|
+
: await trashSession(ctx, sessionId);
|
|
1831
1895
|
sendJson(res, result.ok ? 200 : 500, result);
|
|
1832
1896
|
return;
|
|
1833
1897
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "dsh-ws-recency",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.27.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, 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",
|