dsh-ws-recency 0.31.1 → 0.32.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 +1 -0
- package/client.js +102 -43
- package/index.js +38 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -168,6 +168,7 @@ DSH 原生的置顶只把会话顶到**它所属工作区分组的第一行**,
|
|
|
168
168
|
- 搜的是**对话正文**:你的提问 + 助手的回复;不搜思维链、不搜工具参数和工具结果(那些会让命中被日志噪声淹没);
|
|
169
169
|
- 多个词用空格分隔,**要求同时出现在同一条消息里**(AND);大小写不敏感,纯字面匹配,不支持正则;
|
|
170
170
|
- 范围用**控件**选,不用记语法:搜索框下面有「工作区」下拉、「会话标题」输入框、「角色」三个按钮(全部 / 我 / 助手)。改控件会用当前关键词自动重搜;
|
|
171
|
+
- **只选范围、不输关键词也可以搜**:这时答案是「符合范围的会话列表」(标题、工作区、路径、时间),点一下就打开——用来找「那件事是哪个会话」。会话模式按会话标题匹配,不读正文,所以很快;
|
|
171
172
|
- 搜索框里仍然可以写匹配方式:`"一个词组"`(整句匹配)、`a|b` 或 `a or b`(任一即可)、`-词`(排除);
|
|
172
173
|
- 想用键盘也行:`ws:工作区`、`in:会话标题`、`role:user|assistant`,中文别名 `工作区:` / `会话:` / `角色:` 同样可用。控件与语法同时给出时,**以控件为准**(那是屏幕上看得见的选择);
|
|
173
174
|
- 结果按新到旧排列,每条给出角色、会话标题、所属工作区、第几轮/第几步,以及带高亮的片段;
|
package/client.js
CHANGED
|
@@ -525,6 +525,7 @@
|
|
|
525
525
|
"search.filterSessionPlaceholder": "包含…(回车)",
|
|
526
526
|
"search.filterRole": "角色",
|
|
527
527
|
"search.filterAll": "全部",
|
|
528
|
+
"search.sessionResults": "会话({n})",
|
|
528
529
|
"search.history": "最近搜索",
|
|
529
530
|
"search.historyRun": "再搜一次:{query}",
|
|
530
531
|
"search.historyDrop": "从历史里删除",
|
|
@@ -736,6 +737,7 @@
|
|
|
736
737
|
"search.filterSessionPlaceholder": "title contains… (Enter)",
|
|
737
738
|
"search.filterRole": "Role",
|
|
738
739
|
"search.filterAll": "All",
|
|
740
|
+
"search.sessionResults": "Sessions ({n})",
|
|
739
741
|
"search.history": "Recent",
|
|
740
742
|
"search.historyRun": "Search again: {query}",
|
|
741
743
|
"search.historyDrop": "Remove from history",
|
|
@@ -4669,9 +4671,46 @@
|
|
|
4669
4671
|
return searchHitRow(props.hit, props.terms, props.onJump, extra);
|
|
4670
4672
|
}
|
|
4671
4673
|
|
|
4674
|
+
/**
|
|
4675
|
+
* One session, for a search that narrowed by title or workspace only.
|
|
4676
|
+
*
|
|
4677
|
+
* Without words there is nothing to point at inside a transcript, so the
|
|
4678
|
+
* useful answer is the session itself: its title, where it lives, and when.
|
|
4679
|
+
*/
|
|
4680
|
+
function SearchSessionRow(props) {
|
|
4681
|
+
var item = props.item;
|
|
4682
|
+
var when = formatWhen(Number(item.at) || 0);
|
|
4683
|
+
return h("div", {
|
|
4684
|
+
className: "wsr-hit wsr-session-hit",
|
|
4685
|
+
title: item.title || "",
|
|
4686
|
+
onClick: function () {
|
|
4687
|
+
if (typeof props.onOpen === "function") props.onOpen();
|
|
4688
|
+
},
|
|
4689
|
+
},
|
|
4690
|
+
h("div", { className: "wsr-hit-head" },
|
|
4691
|
+
h("span", { className: "wsr-hit-title", title: item.title || "" }, item.title || props.shortId),
|
|
4692
|
+
typeof item.workspace === "string" && item.workspace !== "" ? h("span", { className: "wsr-hit-ws" }, item.workspace) : null,
|
|
4693
|
+
),
|
|
4694
|
+
h("div", { className: "wsr-hit-meta" },
|
|
4695
|
+
when !== "" ? h("span", { className: "wsr-hit-time" }, when) : null,
|
|
4696
|
+
typeof item.cwd === "string" && item.cwd !== "" ? h("span", { className: "wsr-hit-cwd" }, item.cwd) : null,
|
|
4697
|
+
),
|
|
4698
|
+
h("div", { className: "wsr-hit-actions" },
|
|
4699
|
+
h("button", {
|
|
4700
|
+
type: "button",
|
|
4701
|
+
className: "wsr-hit-context-jump",
|
|
4702
|
+
onClick: function (event) {
|
|
4703
|
+
if (event !== undefined && typeof event.stopPropagation === "function") event.stopPropagation();
|
|
4704
|
+
if (typeof props.onOpen === "function") props.onOpen();
|
|
4705
|
+
},
|
|
4706
|
+
}, t("search.openSession")),
|
|
4707
|
+
),
|
|
4708
|
+
);
|
|
4709
|
+
}
|
|
4710
|
+
|
|
4672
4711
|
function SearchPanelPage(props) {
|
|
4673
4712
|
var state = react.useState(searchLast === null
|
|
4674
|
-
? { loaded: false, query: "", hits: [], terms: [], scanned: 0, total: 0, pending: 0, took: 0, busy: false, error: "" }
|
|
4713
|
+
? { loaded: false, query: "", hits: [], sessions: [], terms: [], scanned: 0, total: 0, pending: 0, took: 0, busy: false, error: "" }
|
|
4675
4714
|
: searchLast);
|
|
4676
4715
|
var view = state[0];
|
|
4677
4716
|
var setView = state[1];
|
|
@@ -4701,11 +4740,14 @@
|
|
|
4701
4740
|
var query = typeof text === "string" ? text.trim() : "";
|
|
4702
4741
|
searchGeneration += 1;
|
|
4703
4742
|
var generation = searchGeneration;
|
|
4704
|
-
|
|
4743
|
+
/* A filter alone is a question too: "which session was that?". */
|
|
4744
|
+
var hasFilters = searchFilters.workspace !== "" || searchFilters.session !== ""
|
|
4745
|
+
|| searchFilters.role !== "";
|
|
4746
|
+
if (query === "" && !hasFilters) {
|
|
4705
4747
|
commit({ loaded: true, query: "", hits: [], terms: [], scanned: 0, total: 0, pending: 0, took: 0, busy: false, error: "" });
|
|
4706
4748
|
return;
|
|
4707
4749
|
}
|
|
4708
|
-
if (typeof actions.pushSearch === "function") actions.pushSearch(query);
|
|
4750
|
+
if (query !== "" && typeof actions.pushSearch === "function") actions.pushSearch(query);
|
|
4709
4751
|
commit({ loaded: true, query: query, hits: view.hits, terms: view.terms, scanned: view.scanned, total: view.total, pending: view.pending, took: view.took, busy: true, error: "" });
|
|
4710
4752
|
var ask = function (needRefresh) {
|
|
4711
4753
|
searchPost({
|
|
@@ -4725,6 +4767,7 @@
|
|
|
4725
4767
|
loaded: true,
|
|
4726
4768
|
query: query,
|
|
4727
4769
|
hits: Array.isArray(json.hits) ? json.hits : [],
|
|
4770
|
+
sessions: Array.isArray(json.sessions) ? json.sessions : [],
|
|
4728
4771
|
terms: Array.isArray(json.terms) ? json.terms : [],
|
|
4729
4772
|
scanned: json.scanned || 0,
|
|
4730
4773
|
total: json.total || 0,
|
|
@@ -4763,6 +4806,16 @@
|
|
|
4763
4806
|
},
|
|
4764
4807
|
});
|
|
4765
4808
|
|
|
4809
|
+
var sessionRows = (Array.isArray(view.sessions) ? view.sessions : []).map(function (item, index) {
|
|
4810
|
+
var row = h(SearchSessionRow, {
|
|
4811
|
+
item: item,
|
|
4812
|
+
shortId: shortSessionId(String(item.sessionId || "")),
|
|
4813
|
+
onOpen: function () { openSessionRow(item.sessionId); },
|
|
4814
|
+
});
|
|
4815
|
+
row.key = "session:" + String(item.sessionId || index);
|
|
4816
|
+
return row;
|
|
4817
|
+
});
|
|
4818
|
+
|
|
4766
4819
|
var rows = view.hits.map(function (hit, index) {
|
|
4767
4820
|
var row = h(SearchHitRow, {
|
|
4768
4821
|
hit: hit,
|
|
@@ -4777,40 +4830,11 @@
|
|
|
4777
4830
|
h("div", { className: "wsr-page-head" },
|
|
4778
4831
|
h("div", { className: "wsr-page-heading" }, t("search.title")),
|
|
4779
4832
|
),
|
|
4780
|
-
|
|
4781
|
-
|
|
4782
|
-
|
|
4783
|
-
var text = String(item);
|
|
4784
|
-
return h("span", { className: "wsr-search-chip", key: text + ":" + String(index) },
|
|
4785
|
-
h("button", {
|
|
4786
|
-
type: "button",
|
|
4787
|
-
className: "wsr-search-chip-run",
|
|
4788
|
-
title: t("search.historyRun", { query: text }),
|
|
4789
|
-
onClick: function () {
|
|
4790
|
-
searchDraft = text;
|
|
4791
|
-
run(text, false);
|
|
4792
|
-
},
|
|
4793
|
-
}, text),
|
|
4794
|
-
h("button", {
|
|
4795
|
-
type: "button",
|
|
4796
|
-
className: "wsr-search-chip-drop",
|
|
4797
|
-
title: t("search.historyDrop"),
|
|
4798
|
-
"aria-label": t("search.historyDrop"),
|
|
4799
|
-
onClick: function (event) {
|
|
4800
|
-
if (event !== undefined && typeof event.stopPropagation === "function") event.stopPropagation();
|
|
4801
|
-
if (typeof actions.dropSearch === "function") actions.dropSearch(text);
|
|
4802
|
-
},
|
|
4803
|
-
}, "\u00d7"),
|
|
4804
|
-
);
|
|
4805
|
-
}),
|
|
4806
|
-
h("button", {
|
|
4807
|
-
type: "button",
|
|
4808
|
-
className: "wsr-search-history-clear",
|
|
4809
|
-
onClick: function () {
|
|
4810
|
-
if (typeof actions.clearSearches === "function") actions.clearSearches();
|
|
4811
|
-
},
|
|
4812
|
-
}, t("search.historyClear")),
|
|
4833
|
+
h("div", { className: "wsr-search-bar" },
|
|
4834
|
+
input,
|
|
4835
|
+
h("button", { type: "button", className: "wsr-btn", onClick: function () { run(searchDraft, false); } }, t("search.run")),
|
|
4813
4836
|
),
|
|
4837
|
+
h("div", { className: "wsr-search-hint" }, t("search.hint")),
|
|
4814
4838
|
h("div", { className: "wsr-search-filters" },
|
|
4815
4839
|
h("label", { className: "wsr-filter" },
|
|
4816
4840
|
h("span", { className: "wsr-filter-label" }, t("search.filterWorkspace")),
|
|
@@ -4883,17 +4907,52 @@
|
|
|
4883
4907
|
})(),
|
|
4884
4908
|
),
|
|
4885
4909
|
),
|
|
4886
|
-
h("div", { className: "wsr-search-
|
|
4887
|
-
|
|
4888
|
-
|
|
4889
|
-
|
|
4910
|
+
historyList.length === 0 ? null : h("div", { className: "wsr-search-history" },
|
|
4911
|
+
h("span", { className: "wsr-search-history-label" }, t("search.history")),
|
|
4912
|
+
historyList.map(function (item, index) {
|
|
4913
|
+
var text = String(item);
|
|
4914
|
+
return h("span", { className: "wsr-search-chip", key: text + ":" + String(index) },
|
|
4915
|
+
h("button", {
|
|
4916
|
+
type: "button",
|
|
4917
|
+
className: "wsr-search-chip-run",
|
|
4918
|
+
title: t("search.historyRun", { query: text }),
|
|
4919
|
+
onClick: function () {
|
|
4920
|
+
searchDraft = text;
|
|
4921
|
+
run(text, false);
|
|
4922
|
+
},
|
|
4923
|
+
}, text),
|
|
4924
|
+
h("button", {
|
|
4925
|
+
type: "button",
|
|
4926
|
+
className: "wsr-search-chip-drop",
|
|
4927
|
+
title: t("search.historyDrop"),
|
|
4928
|
+
"aria-label": t("search.historyDrop"),
|
|
4929
|
+
onClick: function (event) {
|
|
4930
|
+
if (event !== undefined && typeof event.stopPropagation === "function") event.stopPropagation();
|
|
4931
|
+
if (typeof actions.dropSearch === "function") actions.dropSearch(text);
|
|
4932
|
+
},
|
|
4933
|
+
}, "\u00d7"),
|
|
4934
|
+
);
|
|
4935
|
+
}),
|
|
4936
|
+
h("button", {
|
|
4937
|
+
type: "button",
|
|
4938
|
+
className: "wsr-search-history-clear",
|
|
4939
|
+
onClick: function () {
|
|
4940
|
+
if (typeof actions.clearSearches === "function") actions.clearSearches();
|
|
4941
|
+
},
|
|
4942
|
+
}, t("search.historyClear")),
|
|
4890
4943
|
),
|
|
4891
|
-
|
|
4944
|
+
view.busy ? h("div", { className: "wsr-page-note" }, t("search.searching")) : null,
|
|
4892
4945
|
view.error !== "" ? h("div", { className: "wsr-page-note wsr-page-error" }, view.error) : null,
|
|
4893
4946
|
view.pending > 0 ? h("div", { className: "wsr-page-note" }, t("search.indexing", { n: String(view.pending) })) : null,
|
|
4894
4947
|
view.loaded && !view.busy ? h("div", { className: "wsr-page-note" }, t("search.summary", { hits: String(view.hits.length), sessions: String(view.total), ms: String(view.took) })) : null,
|
|
4895
|
-
view.loaded && !view.busy && view.hits.length === 0 ? h("div", { className: "wsr-page-note" }, t("search.empty")) : null,
|
|
4896
|
-
|
|
4948
|
+
view.loaded && !view.busy && view.hits.length === 0 && sessionRows.length === 0 ? h("div", { className: "wsr-page-note" }, t("search.empty")) : null,
|
|
4949
|
+
sessionRows.length > 0
|
|
4950
|
+
? h("div", { className: "wsr-page-list" },
|
|
4951
|
+
h("div", { className: "wsr-search-history-label" }, t("search.sessionResults", { n: String(sessionRows.length) })),
|
|
4952
|
+
sessionRows,
|
|
4953
|
+
)
|
|
4954
|
+
: null,
|
|
4955
|
+
sessionRows.length === 0 ? h("div", { className: "wsr-page-list" }, rows) : null,
|
|
4897
4956
|
);
|
|
4898
4957
|
}
|
|
4899
4958
|
|
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.32.0";
|
|
36
36
|
|
|
37
37
|
/**
|
|
38
38
|
* Exact routes the client half calls. Registered on the bare web server, so they
|
|
@@ -1000,6 +1000,43 @@ export async function searchSessions(ctx, query, options = {}) {
|
|
|
1000
1000
|
}
|
|
1001
1001
|
sessions.sort((a, b) => b.updatedAt - a.updatedAt);
|
|
1002
1002
|
|
|
1003
|
+
/* No words, but a filter: the question is "which session was that?", so the
|
|
1004
|
+
answer is sessions, not messages. Listing them needs no transcript work. */
|
|
1005
|
+
if (parsed.terms.length === 0 && parsed.groups.length === 0) {
|
|
1006
|
+
const matchedSessions = [];
|
|
1007
|
+
for (const session of sessions) {
|
|
1008
|
+
const cwd = normalizedPath(session.header.cwd);
|
|
1009
|
+
if (parsed.filters.workspace !== "") {
|
|
1010
|
+
const name = String(workspaceByPath.get(cwd) ?? "").toLowerCase();
|
|
1011
|
+
if (name.indexOf(parsed.filters.workspace) === -1) continue;
|
|
1012
|
+
}
|
|
1013
|
+
if (parsed.filters.session !== "") {
|
|
1014
|
+
const headerTitle = typeof session.header.title === "string" ? session.header.title.toLowerCase() : "";
|
|
1015
|
+
if (headerTitle.indexOf(parsed.filters.session) === -1) continue;
|
|
1016
|
+
}
|
|
1017
|
+
matchedSessions.push({
|
|
1018
|
+
sessionId: session.id,
|
|
1019
|
+
title: typeof session.header.title === "string" ? session.header.title : "",
|
|
1020
|
+
workspace: workspaceByPath.get(cwd) ?? "",
|
|
1021
|
+
cwd: typeof session.header.cwd === "string" ? session.header.cwd : "",
|
|
1022
|
+
at: session.updatedAt,
|
|
1023
|
+
sizeBytes: session.sizeBytes,
|
|
1024
|
+
});
|
|
1025
|
+
if (matchedSessions.length >= SEARCH_TOTAL_CAP) break;
|
|
1026
|
+
}
|
|
1027
|
+
return {
|
|
1028
|
+
ok: true,
|
|
1029
|
+
query: "",
|
|
1030
|
+
terms: [],
|
|
1031
|
+
hits: [],
|
|
1032
|
+
sessions: matchedSessions,
|
|
1033
|
+
scanned: sessions.length,
|
|
1034
|
+
total: sessions.length,
|
|
1035
|
+
pending: 0,
|
|
1036
|
+
took: Date.now() - started,
|
|
1037
|
+
};
|
|
1038
|
+
}
|
|
1039
|
+
|
|
1003
1040
|
const refresh = options.refresh === true;
|
|
1004
1041
|
const hits = [];
|
|
1005
1042
|
let scanned = 0;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "dsh-ws-recency",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.32.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",
|