dsh-ws-recency 0.33.2 → 0.34.1
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 +11 -0
- package/client.js +13 -99
- package/index.js +2618 -2598
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -196,6 +196,17 @@ DSH 原生的置顶只把会话顶到**它所属工作区分组的第一行**,
|
|
|
196
196
|
|
|
197
197
|
所以用 `dsh-gateway` 之类的转接插件、或直接从局域网 IP 访问时,删除和统计都能正常用;只有**真正的跨站页面**会被 403 拒绝。0.32.1 及更早的版本只认回环地址,非回环访问一律 403(issue #3)。
|
|
198
198
|
|
|
199
|
+
## 会话菜单里留下什么
|
|
200
|
+
|
|
201
|
+
本插件只往会话「…」菜单里加两项,其余动作都由宿主或对话界面本身提供:
|
|
202
|
+
|
|
203
|
+
| 项 | 为什么还需要它 |
|
|
204
|
+
|---|---|
|
|
205
|
+
| 标记需要跟进 | 宿主没有这个概念,它是侧栏三色标记的一种 |
|
|
206
|
+
| 移动到工作区… | 宿主的 attach 校验 `header.cwd`,核心没有改工作区的入口 |
|
|
207
|
+
|
|
208
|
+
交接在每轮回复下方的动作行里;Token 统计在输入框上方的「分析」胶囊里;删除会话(移入回收站)的菜单项在 0.34.0 移除——要恢复它,把 `ctx.slots.inject("sidebar.workspaces.session.menu.item", … , TrashMenuItem)` 那段注册加回去即可,宿主侧的删除/回收站路由一直都在。
|
|
209
|
+
|
|
199
210
|
## 已知边界
|
|
200
211
|
|
|
201
212
|
- 依赖宿主 DOM:分组容器带 `_groupSection`、分组头带 `data-row-key="workspace:<id>"`、行带 `data-row-key="session:<id>"`、溢出按钮类名含 `sessionOverflowButton`。宿主改结构就要跟着改。
|
package/client.js
CHANGED
|
@@ -514,6 +514,7 @@
|
|
|
514
514
|
"move.done": "已移动到「{workspace}」。若列表没刷新,切换一下工作区或重启应用。",
|
|
515
515
|
"move.doneLive": "\n\n这个会话刚才是打开状态:建议重启应用后再继续对话,避免它沿用旧的目录。",
|
|
516
516
|
"move.repaired": "已补登记到「{workspace}」:上一次移动只搬了日志、没登记工作区,这次把它补上了。",
|
|
517
|
+
"move.live": "这个会话正开着,不能移动。先切到别的会话,或重启应用后不要打开它,再来移动。",
|
|
517
518
|
"adopt.title": "补登记游离会话",
|
|
518
519
|
"adopt.description": "修复会话归属:把“目录属于某工作区却不在任何分组”的会话挂回去,并把仍挂在旧工作区分组里的重复归属清掉。",
|
|
519
520
|
"adopt.action": "扫描并刷新",
|
|
@@ -819,6 +820,7 @@
|
|
|
819
820
|
"archive.blank": "blank draft",
|
|
820
821
|
"archive.workspace": "workspace",
|
|
821
822
|
"move.failed": "Move failed: ",
|
|
823
|
+
"move.live": "This session is open, so it cannot be moved. Switch to another conversation, or restart the app and do not open it, then move it.",
|
|
822
824
|
"stats.chart": "Where the tokens went",
|
|
823
825
|
"stats.family.shell": "shell",
|
|
824
826
|
"stats.family.files": "files",
|
|
@@ -1285,7 +1287,7 @@
|
|
|
1285
1287
|
folded. Expanding drives the hidden host button until nothing is left
|
|
1286
1288
|
unrendered, so one click reveals the whole group. */
|
|
1287
1289
|
var remaining = folded + hostHidden;
|
|
1288
|
-
/* A project that is entirely history is open because opening it is the
|
|
1290
|
+
/* A project that is entirely history is open because opening it is the
|
|
1289
1291
|
request; there is nothing to offer to fold back. */
|
|
1290
1292
|
if (expanded && !onlyHistory) {
|
|
1291
1293
|
(function (entryKey) {
|
|
@@ -2008,48 +2010,7 @@
|
|
|
2008
2010
|
});
|
|
2009
2011
|
}
|
|
2010
2012
|
|
|
2011
|
-
/**
|
|
2012
|
-
* Session "..." menu row: move the session into the trash folder.
|
|
2013
|
-
*
|
|
2014
|
-
* DSH itself only archives; the host half of this plugin stops the work,
|
|
2015
|
-
* detaches the bookkeeping and renames the log directory into
|
|
2016
|
-
* `<home>/.trash/ws-recency/`. The browser half only asks for confirmation
|
|
2017
|
-
* and posts the id.
|
|
2018
|
-
*/
|
|
2019
2013
|
|
|
2020
|
-
function TrashMenuItem(props) {
|
|
2021
|
-
var Item = ui.MenuItemButton;
|
|
2022
|
-
if (typeof Item !== "function") return null;
|
|
2023
|
-
var Icon = ui.IconTrashOutlineRegular;
|
|
2024
|
-
return h(Item, {
|
|
2025
|
-
icon: typeof Icon === "function" ? h(Icon, {}) : undefined,
|
|
2026
|
-
onSelect: function () {
|
|
2027
|
-
askConfirm(t("trash.confirm"), function () {
|
|
2028
|
-
fetch("/ws-recency/session-trash?sessionId=" + encodeURIComponent(props.sessionId), {
|
|
2029
|
-
method: "POST",
|
|
2030
|
-
headers: { "content-type": "application/json" },
|
|
2031
|
-
body: JSON.stringify({ sessionId: props.sessionId }),
|
|
2032
|
-
})
|
|
2033
|
-
.then(function (response) {
|
|
2034
|
-
return response.text().then(function (text) {
|
|
2035
|
-
var parsed = null;
|
|
2036
|
-
try { parsed = JSON.parse(text); } catch (error) { parsed = null; }
|
|
2037
|
-
return { status: response.status, text: text, json: parsed };
|
|
2038
|
-
});
|
|
2039
|
-
})
|
|
2040
|
-
.then(function (result) {
|
|
2041
|
-
if (result.json !== null && result.json.ok === true) return;
|
|
2042
|
-
var reason = (result.json !== null && result.json.error) || (result.text || "").trim().slice(0, 120) || "(empty response)";
|
|
2043
|
-
askNotice(t("trash.failed") + "HTTP " + result.status + " \u00b7 " + reason);
|
|
2044
|
-
})
|
|
2045
|
-
.catch(function (error) {
|
|
2046
|
-
askNotice(t("trash.failed") + (error && error.message ? error.message : error));
|
|
2047
|
-
});
|
|
2048
|
-
});
|
|
2049
|
-
},
|
|
2050
|
-
}, t("menu.trash"));
|
|
2051
|
-
}
|
|
2052
|
-
|
|
2053
2014
|
/* ------------------------- token statistics ------------------------- */
|
|
2054
2015
|
|
|
2055
2016
|
var statsModal = null;
|
|
@@ -3098,6 +3059,11 @@
|
|
|
3098
3059
|
if (result.json.live === true) body.textContent += t("move.doneLive");
|
|
3099
3060
|
return;
|
|
3100
3061
|
}
|
|
3062
|
+
/* The raw persistence error names no remedy. */
|
|
3063
|
+
if (result.json !== null && result.json.code === "session-live") {
|
|
3064
|
+
body.textContent = t("move.live");
|
|
3065
|
+
return;
|
|
3066
|
+
}
|
|
3101
3067
|
var reason = (result.json !== null && result.json.error) || (result.text || "").trim().slice(0, 160) || "(empty response)";
|
|
3102
3068
|
body.textContent = t("move.failed") + "HTTP " + result.status + " \u00b7 " + reason;
|
|
3103
3069
|
})
|
|
@@ -3750,36 +3716,8 @@
|
|
|
3750
3716
|
return typeof Tooltip === "function" ? h(Tooltip, { label: label, side: "bottom" }, button) : button;
|
|
3751
3717
|
}
|
|
3752
3718
|
|
|
3753
|
-
|
|
3754
|
-
|
|
3755
|
-
var Item = ui.MenuItemButton;
|
|
3756
|
-
if (typeof Item !== "function") return null;
|
|
3757
|
-
var Icon = ui.IconDataOutlineRegular;
|
|
3758
|
-
return h(Item, {
|
|
3759
|
-
icon: typeof Icon === "function" ? h(Icon, {}) : undefined,
|
|
3760
|
-
onSelect: function () {
|
|
3761
|
-
/* Open the conversation first so the running handoff (and later the
|
|
3762
|
-
card) is visible; the prompt itself does not need the composer. */
|
|
3763
|
-
var service = data.service;
|
|
3764
|
-
if (service !== null && service !== undefined && typeof service.openSession === "function") {
|
|
3765
|
-
try { service.openSession(props.sessionId); } catch (error) { /* the send still lands */ }
|
|
3766
|
-
}
|
|
3767
|
-
startHandoff(props.sessionId);
|
|
3768
|
-
},
|
|
3769
|
-
}, t("menu.handoff"));
|
|
3770
|
-
}
|
|
3771
|
-
|
|
3772
|
-
/** Session "..." menu row: token statistics of that session. */
|
|
3773
|
-
function StatsMenuItem(props) {
|
|
3774
|
-
var Item = ui.MenuItemButton;
|
|
3775
|
-
if (typeof Item !== "function") return null;
|
|
3776
|
-
var Icon = ui.IconDataOutlineRegular;
|
|
3777
|
-
return h(Item, {
|
|
3778
|
-
icon: typeof Icon === "function" ? h(Icon, {}) : undefined,
|
|
3779
|
-
onSelect: function () { openStatsPanel(props.sessionId); },
|
|
3780
|
-
}, t("menu.stats"));
|
|
3781
|
-
}
|
|
3782
|
-
|
|
3719
|
+
|
|
3720
|
+
|
|
3783
3721
|
/** Settings -> General row: ask before a jump that loads a lot of history. */
|
|
3784
3722
|
function ColdJumpRow(props) {
|
|
3785
3723
|
var settings = props.useStore(function (state) { return state; });
|
|
@@ -5926,36 +5864,9 @@
|
|
|
5926
5864
|
}, MoveMenuItem);
|
|
5927
5865
|
});
|
|
5928
5866
|
|
|
5929
|
-
ctx.slots.inject("sidebar.workspaces.session.menu.item", function () {
|
|
5930
|
-
return ctx.slots.register({
|
|
5931
|
-
name: "sidebar.workspaces.session.menu.item",
|
|
5932
|
-
id: "ws-recency-handoff",
|
|
5933
|
-
order: 685,
|
|
5934
|
-
store: prefs,
|
|
5935
|
-
locale: NS,
|
|
5936
|
-
}, HandoffMenuItem);
|
|
5937
|
-
});
|
|
5938
5867
|
|
|
5939
|
-
ctx.slots.inject("sidebar.workspaces.session.menu.item", function () {
|
|
5940
|
-
return ctx.slots.register({
|
|
5941
|
-
name: "sidebar.workspaces.session.menu.item",
|
|
5942
|
-
id: "ws-recency-stats",
|
|
5943
|
-
order: 710,
|
|
5944
|
-
store: prefs,
|
|
5945
|
-
locale: NS,
|
|
5946
|
-
}, StatsMenuItem);
|
|
5947
|
-
});
|
|
5948
5868
|
|
|
5949
5869
|
|
|
5950
|
-
ctx.slots.inject("sidebar.workspaces.session.menu.item", function () {
|
|
5951
|
-
return ctx.slots.register({
|
|
5952
|
-
name: "sidebar.workspaces.session.menu.item",
|
|
5953
|
-
id: "ws-recency-trash",
|
|
5954
|
-
order: 700,
|
|
5955
|
-
store: prefs,
|
|
5956
|
-
locale: NS,
|
|
5957
|
-
}, TrashMenuItem);
|
|
5958
|
-
});
|
|
5959
5870
|
|
|
5960
5871
|
ctx.effect(function () {
|
|
5961
5872
|
return function () { shutdown(); };
|
|
@@ -5978,6 +5889,9 @@
|
|
|
5978
5889
|
};
|
|
5979
5890
|
|
|
5980
5891
|
/* Test hook: the jump and the highlighting are pure DOM helpers. */
|
|
5892
|
+
/* The statistics panel no longer has a menu row; tests open it here. */
|
|
5893
|
+
exports.__stats = { open: openStatsPanel, close: closeStatsPanel };
|
|
5894
|
+
|
|
5981
5895
|
exports.__search = {
|
|
5982
5896
|
draft: function () { return searchDraft; },
|
|
5983
5897
|
highlight: highlightSnippet,
|