dsh-ws-recency 0.34.2 → 0.35.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 (4) hide show
  1. package/README.md +16 -0
  2. package/client.js +226 -16
  3. package/index.js +1 -1
  4. package/package.json +1 -1
package/README.md CHANGED
@@ -207,6 +207,22 @@ DSH 原生的置顶只把会话顶到**它所属工作区分组的第一行**,
207
207
 
208
208
  交接在每轮回复下方的动作行里;Token 统计在输入框上方的「分析」胶囊里;删除会话(移入回收站)的菜单项在 0.34.0 移除——要恢复它,把 `ctx.slots.inject("sidebar.workspaces.session.menu.item", … , TrashMenuItem)` 那段注册加回去即可,宿主侧的删除/回收站路由一直都在。
209
209
 
210
+ ## 插件功能开关
211
+
212
+ 侧栏多了一个「插件功能」面板(滑块图标),每一项都能单独开关,默认全开:
213
+
214
+ | 开关 | 关掉之后 |
215
+ |---|---|
216
+ | 侧栏会话管理 | 旧会话折叠、会话颜色、置顶分区都停下,并撤掉已画的标记,侧栏回到宿主原样 |
217
+ | 标记需要跟进 | 会话菜单里的标记与侧栏旁边的圆点消失 |
218
+ | 搜索会话内容 | 搜索面板与其入口消失;如果你已经装了别的搜索插件,用它就行 |
219
+ | 回收站 | 回收站面板消失,归档与彻底删除改由宿主/别处处理 |
220
+ | Token 消耗统计 | 输入框上方的「用量分析」胶囊与统计面板消失 |
221
+ | 交接到新会话 | 每轮回复下方的交接按钮消失 |
222
+ | 移动到工作区 | 会话菜单里的移动项消失 |
223
+
224
+ 面板底部有「全部启用」一键恢复。开关状态和别的偏好一起存在本地,重装升级不丢。
225
+
210
226
  ## 已知边界
211
227
 
212
228
  - 依赖宿主 DOM:分组容器带 `_groupSection`、分组头带 `data-row-key="workspace:<id>"`、行带 `data-row-key="session:<id>"`、溢出按钮类名含 `sessionOverflowButton`。宿主改结构就要跟着改。
package/client.js CHANGED
@@ -76,6 +76,49 @@
76
76
  var MAX_DAYS = 90;
77
77
  var DEFAULT_DAYS = 3;
78
78
 
79
+ /**
80
+ * Which parts of this plugin are on.
81
+ *
82
+ * The plugin grew several unrelated abilities; someone who already has
83
+ * another plugin for search, or for statistics, should be able to turn that
84
+ * part off here instead of living with two answers for one question.
85
+ */
86
+ var FEATURE_IDS = ["sidebar", "followUp", "search", "trash", "stats", "handoff", "move"];
87
+ var FEATURE_DEFAULTS = {
88
+ sidebar: true,
89
+ followUp: true,
90
+ search: true,
91
+ trash: true,
92
+ stats: true,
93
+ handoff: true,
94
+ move: true,
95
+ };
96
+
97
+ /**
98
+ * Wrap a component in one feature switch.
99
+ *
100
+ * The wrapper calls exactly one hook on every render, then decides: a guard
101
+ * inside the component itself would change its hook count the moment the
102
+ * switch flips, and React rejects that. Switching off unmounts the component,
103
+ * so its background work stops with it.
104
+ */
105
+ function withFeature(Component, feature) {
106
+ var FeatureGated = function (props) {
107
+ var settingsNow = typeof props.useStore === "function" ? props.useStore(function (state) { return state; }) : data.settings;
108
+ if (!featureOn(settingsNow, feature)) return null;
109
+ return h(Component, props);
110
+ };
111
+ FeatureGated.__featureGate = feature;
112
+ return FeatureGated;
113
+ }
114
+
115
+ /** One feature's switch, with `on` as the default for a missing value. */
116
+ function featureOn(state, name) {
117
+ var bag = state !== null && state !== undefined ? state.features : undefined;
118
+ if (bag !== null && bag !== undefined && typeof bag === "object" && typeof bag[name] === "boolean") return bag[name];
119
+ return FEATURE_DEFAULTS[name] !== false;
120
+ }
121
+
79
122
  /** Turns behind the newest that make a jump ask first; 0 disables asking. */
80
123
  var DEFAULT_COLD_JUMP = 40;
81
124
  var MAX_COLD_JUMP = 500;
@@ -522,6 +565,26 @@
522
565
  "adopt.done": "已补登记 {n} 个会话。",
523
566
  "adopt.cleaned": "清理了 {n} 处重复/失效的工作区归属。",
524
567
  "adopt.failed": "扫描失败:",
568
+ "features.title": "插件功能",
569
+ "features.on": "已启用",
570
+ "features.off": "已关闭",
571
+ "features.reset": "全部启用",
572
+ "features.note": "只关掉你不需要的部分:关掉的入口会从界面上消失,相关的后台逻辑也会停下。",
573
+ "features.takesEffect": "当前启用 {on} / {all} 项。",
574
+ "features.sidebar.title": "侧栏会话管理",
575
+ "features.sidebar.desc": "旧会话折叠、会话颜色、置顶分区。关掉后侧栏交回宿主原样。",
576
+ "features.followUp.title": "标记需要跟进",
577
+ "features.followUp.desc": "会话菜单里的标记与侧栏旁边的圆点。",
578
+ "features.search.title": "搜索会话内容",
579
+ "features.search.desc": "侧栏搜索面板:全文搜索、筛选、跳转。装了别的搜索插件可以关掉这个。",
580
+ "features.trash.title": "回收站",
581
+ "features.trash.desc": "侧栏回收站面板:管理已归档会话和彻底删除。",
582
+ "features.stats.title": "Token 消耗统计",
583
+ "features.stats.desc": "输入框上方的「用量分析」胶囊与统计面板。",
584
+ "features.handoff.title": "交接到新会话",
585
+ "features.handoff.desc": "每轮回复下方的交接按钮,把要点写成文档带到新会话。",
586
+ "features.move.title": "移动到工作区",
587
+ "features.move.desc": "把会话改登记到另一个工作区(会重写日志 header,需重启后操作)。",
525
588
  "search.title": "搜索会话内容",
526
589
  "search.placeholder": "输入关键词后回车;多个词用空格分隔,要求同时出现",
527
590
  "search.run": "搜索",
@@ -739,6 +802,26 @@
739
802
  "adopt.done": "Re-attached {n} session(s).",
740
803
  "adopt.cleaned": " Cleared {n} stale membership(s).",
741
804
  "adopt.failed": "Scan failed: ",
805
+ "features.title": "Plugin features",
806
+ "features.on": "On",
807
+ "features.off": "Off",
808
+ "features.reset": "Enable all",
809
+ "features.note": "Turn off only what you do not need: the entry disappears from the interface and its background work stops.",
810
+ "features.takesEffect": "{on} of {all} features are on.",
811
+ "features.sidebar.title": "Sidebar session management",
812
+ "features.sidebar.desc": "Folding old sessions, session colours, the pinned section. Off returns the sidebar to the host.",
813
+ "features.followUp.title": "Follow-up marks",
814
+ "features.followUp.desc": "The mark in the session menu and the dot beside the row.",
815
+ "features.search.title": "Search sessions",
816
+ "features.search.desc": "The search panel: full text, filters, jumping. Turn it off if another search plugin owns this.",
817
+ "features.trash.title": "Trash",
818
+ "features.trash.desc": "The trash panel: manage archived sessions and delete for good.",
819
+ "features.stats.title": "Token statistics",
820
+ "features.stats.desc": "The usage pill above the composer and the statistics panel.",
821
+ "features.handoff.title": "Hand off to a new session",
822
+ "features.handoff.desc": "The action under each reply that carries the gist into a fresh session.",
823
+ "features.move.title": "Move to workspace",
824
+ "features.move.desc": "Re-register a session under another workspace (rewrites the log header; restart first).",
742
825
  "search.title": "Search session content",
743
826
  "search.placeholder": "Type a word and press Enter; separate words with spaces to require all of them",
744
827
  "search.run": "Search",
@@ -1828,6 +1911,12 @@
1828
1911
  */
1829
1912
  function decorateComposerStats() {
1830
1913
  if (typeof document === "undefined") return;
1914
+ /* Switch off: take the pill away rather than leave a dead one. */
1915
+ if (!featureOn(data.settings, "stats")) {
1916
+ var stale = document.querySelector("[data-wsr-composer-analysis]");
1917
+ if (stale !== null && typeof stale.remove === "function") stale.remove();
1918
+ return;
1919
+ }
1831
1920
  var existing = document.querySelector("[data-wsr-composer-analysis]");
1832
1921
  var seat = document.querySelector("[data-composer-seat]");
1833
1922
  var anchors = seat === null || typeof seat.querySelectorAll !== "function" ? [] : seat.querySelectorAll("[data-composer-stat]");
@@ -1953,6 +2042,23 @@
1953
2042
  }, delay);
1954
2043
  }
1955
2044
  /** `shell.overlay` occupant; it renders no chrome of its own. */
2045
+ /** Remove every mark this plugin paints on the sidebar rows. */
2046
+ function unpaintSidebar() {
2047
+ if (typeof document === "undefined") return;
2048
+ try {
2049
+ var painted = document.querySelectorAll("[data-wsr-rank],[data-wsr-dot]");
2050
+ for (var i = 0; i < painted.length; i += 1) {
2051
+ painted[i].removeAttribute("data-wsr-rank");
2052
+ painted[i].removeAttribute("data-wsr-dot");
2053
+ painted[i].style.removeProperty("order");
2054
+ }
2055
+ var hidden = document.querySelectorAll(".wsr-hidden");
2056
+ for (var j = 0; j < hidden.length; j += 1) hidden[j].classList.remove("wsr-hidden");
2057
+ } catch (error) {
2058
+ /* a half-painted list is not worth a crash */
2059
+ }
2060
+ }
2061
+
1956
2062
  function Sorter(props) {
1957
2063
  if (typeof props.useSessions === "function") {
1958
2064
  data.sessions = props.useSessions(function (state) { return state; });
@@ -1968,7 +2074,15 @@
1968
2074
  }
1969
2075
  if (props.actions !== undefined && props.actions !== null) data.actions = props.actions;
1970
2076
  if (typeof props.t === "function") data.t = props.t;
1971
- react.useEffect(function () { schedule(); });
2077
+ /* With the sidebar half off, drop our paint and stop the timer. */
2078
+ var sidebarOn = featureOn(data.settings, "sidebar");
2079
+ react.useEffect(function () {
2080
+ if (sidebarOn) {
2081
+ schedule();
2082
+ return;
2083
+ }
2084
+ unpaintSidebar();
2085
+ });
1972
2086
  return null;
1973
2087
  }
1974
2088
 
@@ -5203,6 +5317,14 @@
5203
5317
  }
5204
5318
 
5205
5319
  /** The sidebar's trash entry glyph. */
5320
+ /** Sidebar glyph for the feature switches. */
5321
+ function FeaturesPanelIcon(props) {
5322
+ var Icon = ui.IconSlidersTwoOutlineRegular;
5323
+ if (typeof Icon !== "function") return null;
5324
+ var size = props !== undefined && props !== null && typeof props.size === "number" ? props.size : 16;
5325
+ return h(Icon, { size: size });
5326
+ }
5327
+
5206
5328
  function TrashPanelIcon(props) {
5207
5329
  var Icon = ui.IconTrashOutlineRegular;
5208
5330
  if (typeof Icon !== "function") return null;
@@ -5210,6 +5332,61 @@
5210
5332
  return h(Icon, { size: size });
5211
5333
  }
5212
5334
 
5335
+ /** One switch: a title, what it costs to turn off, and a toggle. */
5336
+ function FeatureRow(props) {
5337
+ var settings = props.useStore(function (state) { return state; });
5338
+ var on = featureOn(settings, props.id);
5339
+ return h("div", { className: "wsr-setRow", "data-wsr-feature": props.id },
5340
+ h("div", { className: "wsr-setText" },
5341
+ h("div", { className: "wsr-setTitle" }, props.title),
5342
+ h("div", { className: "wsr-setDesc" }, props.description),
5343
+ ),
5344
+ h("div", { className: "wsr-controls" },
5345
+ h("button", {
5346
+ type: "button",
5347
+ className: on ? "wsr-toggle wsr-toggle-on" : "wsr-toggle",
5348
+ "aria-pressed": on ? "true" : "false",
5349
+ "data-wsr-feature-toggle": props.id,
5350
+ onClick: function () { props.actions.setFeature(props.id); },
5351
+ }, t(on ? "features.on" : "features.off")),
5352
+ ),
5353
+ );
5354
+ }
5355
+
5356
+ /** The settings page: every ability of the plugin, on or off. */
5357
+ function FeaturesPanelPage(props) {
5358
+ var settings = props.useStore(function (state) { return state; });
5359
+ var rows = FEATURE_IDS.map(function (id) {
5360
+ return h(FeatureRow, {
5361
+ key: id,
5362
+ id: id,
5363
+ title: t("features." + id + ".title"),
5364
+ description: t("features." + id + ".desc"),
5365
+ useStore: props.useStore,
5366
+ actions: props.actions,
5367
+ });
5368
+ });
5369
+ return h("div", { className: "wsr-page wsr-features-page" },
5370
+ h("div", { className: "wsr-page-head" },
5371
+ h("div", { className: "wsr-page-heading" }, t("features.title")),
5372
+ h("button", {
5373
+ type: "button",
5374
+ className: "wsr-btn",
5375
+ "data-wsr-features-reset": "true",
5376
+ onClick: function () { props.actions.resetFeatures(); },
5377
+ }, t("features.reset")),
5378
+ ),
5379
+ h("div", { className: "wsr-page-list" },
5380
+ h("div", { className: "wsr-setNote" }, t("features.note")),
5381
+ rows,
5382
+ h("div", { className: "wsr-setNote" }, t("features.takesEffect", {
5383
+ on: String(FEATURE_IDS.filter(function (id) { return featureOn(settings, id); }).length),
5384
+ all: String(FEATURE_IDS.length),
5385
+ })),
5386
+ ),
5387
+ );
5388
+ }
5389
+
5213
5390
  /**
5214
5391
  * The trash page itself: the plugin's trash (deleted logs) on top, the
5215
5392
  * Host's archive set (hidden sessions whose logs are still in place)
@@ -5632,7 +5809,7 @@
5632
5809
  }
5633
5810
  var prefs = clientStore.defineStore({
5634
5811
  init: function () {
5635
- return { enabled: true, foldDays: DEFAULT_DAYS, keepActive: true, colors: true, pinnedSection: true, argMode: "tool", followUps: {}, searchHistory: [], coldJumpTurns: DEFAULT_COLD_JUMP };
5812
+ return { enabled: true, foldDays: DEFAULT_DAYS, keepActive: true, colors: true, pinnedSection: true, argMode: "tool", followUps: {}, searchHistory: [], coldJumpTurns: DEFAULT_COLD_JUMP, features: {} };
5636
5813
  },
5637
5814
  persist: "dsh.ws-recency.prefs.v1",
5638
5815
  actions: {
@@ -5641,6 +5818,14 @@
5641
5818
  setColors: function (draft, value) { draft.colors = value === true; },
5642
5819
  setPinnedSection: function (draft, value) { draft.pinnedSection = value === true; },
5643
5820
  setArgMode: function (draft, value) { draft.argMode = value === "agent" ? "agent" : "tool"; },
5821
+ setFeature: function (draft, name) {
5822
+ if (FEATURE_IDS.indexOf(String(name)) === -1) return;
5823
+ if (draft.features === null || draft.features === undefined || typeof draft.features !== "object") draft.features = {};
5824
+ draft.features[String(name)] = !featureOn(draft, String(name));
5825
+ },
5826
+ resetFeatures: function (draft) {
5827
+ draft.features = {};
5828
+ },
5644
5829
  setColdJumpTurns: function (draft, value) {
5645
5830
  var next = Number(value);
5646
5831
  if (!Number.isFinite(next)) return;
@@ -5736,7 +5921,7 @@
5736
5921
  order: 45,
5737
5922
  store: prefs,
5738
5923
  locale: NS,
5739
- }, SettingsRow);
5924
+ }, withFeature(SettingsRow, "sidebar"));
5740
5925
  });
5741
5926
 
5742
5927
  ctx.slots.inject("settings.general.item", function () {
@@ -5746,7 +5931,7 @@
5746
5931
  order: 45,
5747
5932
  store: prefs,
5748
5933
  locale: NS,
5749
- }, ColdJumpRow);
5934
+ }, withFeature(ColdJumpRow, "search"));
5750
5935
  });
5751
5936
 
5752
5937
  ctx.slots.inject("settings.general.item", function () {
@@ -5756,7 +5941,7 @@
5756
5941
  order: 46,
5757
5942
  store: prefs,
5758
5943
  locale: NS,
5759
- }, ColorsRow);
5944
+ }, withFeature(ColorsRow, "sidebar"));
5760
5945
  });
5761
5946
 
5762
5947
  if (SEARCH_ENABLED) {
@@ -5765,9 +5950,10 @@
5765
5950
  name: "sidebar.panellist",
5766
5951
  id: "ws-recency-search",
5767
5952
  order: 19,
5953
+ store: prefs,
5768
5954
  locale: NS,
5769
5955
  label: function () { return t("search.title"); },
5770
- }, SearchPanelIcon);
5956
+ }, withFeature(SearchPanelIcon, "search"));
5771
5957
  });
5772
5958
 
5773
5959
  ctx.slots.inject("main", function () {
@@ -5776,27 +5962,49 @@
5776
5962
  key: "ws-recency-search",
5777
5963
  locale: NS,
5778
5964
  store: prefs,
5779
- }, SearchPanelPage);
5965
+ }, withFeature(SearchPanelPage, "search"));
5780
5966
  });
5781
5967
  }
5782
5968
 
5783
5969
 
5970
+ ctx.slots.inject("sidebar.panellist", function () {
5971
+ return ctx.slots.register({
5972
+ name: "sidebar.panellist",
5973
+ id: "ws-recency-features",
5974
+ order: 21,
5975
+ store: prefs,
5976
+ locale: NS,
5977
+ label: function () { return t("features.title"); },
5978
+ }, FeaturesPanelIcon);
5979
+ });
5980
+
5784
5981
  ctx.slots.inject("sidebar.panellist", function () {
5785
5982
  return ctx.slots.register({
5786
5983
  name: "sidebar.panellist",
5787
5984
  id: "ws-recency-trash",
5788
5985
  order: 20,
5986
+ store: prefs,
5789
5987
  locale: NS,
5790
5988
  label: function () { return t("trash.title"); },
5791
- }, TrashPanelIcon);
5989
+ }, withFeature(TrashPanelIcon, "trash"));
5990
+ });
5991
+
5992
+ ctx.slots.inject("main", function () {
5993
+ return ctx.slots.register({
5994
+ name: "main",
5995
+ key: "ws-recency-features",
5996
+ store: prefs,
5997
+ locale: NS,
5998
+ }, FeaturesPanelPage);
5792
5999
  });
5793
6000
 
5794
6001
  ctx.slots.inject("main", function () {
5795
6002
  return ctx.slots.register({
5796
6003
  name: "main",
5797
6004
  key: "ws-recency-trash",
6005
+ store: prefs,
5798
6006
  locale: NS,
5799
- }, TrashPanelPage);
6007
+ }, withFeature(TrashPanelPage, "trash"));
5800
6008
  });
5801
6009
 
5802
6010
  ctx.slots.inject("settings.general.item", function () {
@@ -5806,7 +6014,7 @@
5806
6014
  order: 47,
5807
6015
  store: prefs,
5808
6016
  locale: NS,
5809
- }, PinSectionRow);
6017
+ }, withFeature(PinSectionRow, "sidebar"));
5810
6018
  });
5811
6019
 
5812
6020
  ctx.slots.inject("settings.general.item", function () {
@@ -5816,7 +6024,7 @@
5816
6024
  order: 48,
5817
6025
  store: prefs,
5818
6026
  locale: NS,
5819
- }, ArgModeRow);
6027
+ }, withFeature(ArgModeRow, "stats"));
5820
6028
  });
5821
6029
 
5822
6030
  ctx.slots.inject("conversation.chat.assistant-actions", function () {
@@ -5824,9 +6032,10 @@
5824
6032
  name: "conversation.chat.assistant-actions",
5825
6033
  id: "ws-recency-handoff",
5826
6034
  order: 20,
6035
+ store: prefs,
5827
6036
  locale: NS,
5828
6037
  inject: function (sessionId) { return { sessionId: sessionId }; },
5829
- }, HandoffTurnAction);
6038
+ }, withFeature(HandoffTurnAction, "handoff"));
5830
6039
  });
5831
6040
 
5832
6041
  ctx.slots.inject("conversation.chat.turnTail", function () {
@@ -5834,9 +6043,10 @@
5834
6043
  name: "conversation.chat.turnTail",
5835
6044
  id: "ws-recency-handoff-card",
5836
6045
  order: 30,
6046
+ store: prefs,
5837
6047
  locale: NS,
5838
6048
  inject: function (sessionId) { return { sessionId: sessionId }; },
5839
- }, HandoffTailCard);
6049
+ }, withFeature(HandoffTailCard, "handoff"));
5840
6050
  });
5841
6051
 
5842
6052
  ctx.slots.inject("sidebar.workspaces.session.menu.item", function () {
@@ -5846,7 +6056,7 @@
5846
6056
  order: MENU_ORDER,
5847
6057
  store: prefs,
5848
6058
  locale: NS,
5849
- }, FollowUpMenuItem);
6059
+ }, withFeature(FollowUpMenuItem, "followUp"));
5850
6060
  });
5851
6061
 
5852
6062
  ctx.slots.inject("sidebar.session.row.leading", function () {
@@ -5856,7 +6066,7 @@
5856
6066
  order: 400,
5857
6067
  store: prefs,
5858
6068
  locale: NS,
5859
- }, FollowUpDot);
6069
+ }, withFeature(FollowUpDot, "followUp"));
5860
6070
  });
5861
6071
 
5862
6072
  ctx.slots.inject("sidebar.workspaces.session.menu.item", function () {
@@ -5866,7 +6076,7 @@
5866
6076
  order: 690,
5867
6077
  store: prefs,
5868
6078
  locale: NS,
5869
- }, MoveMenuItem);
6079
+ }, withFeature(MoveMenuItem, "move"));
5870
6080
  });
5871
6081
 
5872
6082
 
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.34.2";
35
+ export const HOST_VERSION = "0.35.0";
36
36
 
37
37
  /**
38
38
  * Exact routes the client half calls. Registered on the bare web server, so they
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "dsh-ws-recency",
3
- "version": "0.34.2",
3
+ "version": "0.35.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",