dsh-ws-recency 0.35.0 → 0.35.2

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 +1 -1
  2. package/client.js +195 -74
  3. package/index.js +1 -1
  4. package/package.json +1 -1
package/README.md CHANGED
@@ -209,7 +209,7 @@ DSH 原生的置顶只把会话顶到**它所属工作区分组的第一行**,
209
209
 
210
210
  ## 插件功能开关
211
211
 
212
- 侧栏多了一个「插件功能」面板(滑块图标),每一项都能单独开关,默认全开:
212
+ 开关在插件自己的页面上:侧栏「插件」→ `dsh-ws-recency` → 页面底部的「插件功能」一节(`plugins.detail.section`)。每一项都能单独开关,默认全开:
213
213
 
214
214
  | 开关 | 关掉之后 |
215
215
  |---|---|
package/client.js CHANGED
@@ -398,6 +398,9 @@
398
398
  ".wsr-amplified-subtitle{font-size:11px;font-weight:600;color:var(--dsw-alias-label-secondary);margin-top:4px}",
399
399
  ".wsr-amplified-lead{font-size:11px;line-height:1.6;color:var(--dsw-alias-label-tertiary)}",
400
400
  ".wsr-stats-footnote{padding-top:6px;border-top:.5px solid rgba(255,255,255,.06)}",
401
+ ".wsr-plugin-features{display:flex;flex-direction:column;gap:2px;margin-top:18px;padding-top:14px;border-top:1px solid var(--dsw-alias-border-1,rgba(255,255,255,.10))}",
402
+ ".wsr-features-head{display:flex;align-items:center;justify-content:space-between;gap:12px;padding:2px 2px 6px}",
403
+ ".wsr-features-title{font-size:14px;font-weight:600}",
401
404
  ".wsr-toggle{width:100%;height:28px;padding:0 12px 0 calc(28px + var(--dsh-workspace-indent,0px));cursor:pointer;text-align:left;color:var(--dsw-alias-label-tertiary);background:0 0;border:none;font-size:12px}",
402
405
  ".wsr-toggle:hover{color:var(--dsw-alias-label-secondary)}",
403
406
  '[' + STATE_ATTR + '="running"] [class*="_title"]{color:#4f8ef7}',
@@ -2019,6 +2022,11 @@
2019
2022
 
2020
2023
  function schedule() {
2021
2024
  if (disposed || timer !== null) return;
2025
+ /* The interval keeps calling us; a switched-off half must not paint. */
2026
+ if (!featureOn(data.settings, "sidebar")) {
2027
+ unpaintSidebar();
2028
+ return;
2029
+ }
2022
2030
  sidebarAncestors = null;
2023
2031
  if (passesSuspended()) {
2024
2032
  /* One pass, once the host has finished mounting. */
@@ -2046,10 +2054,15 @@
2046
2054
  function unpaintSidebar() {
2047
2055
  if (typeof document === "undefined") return;
2048
2056
  try {
2049
- var painted = document.querySelectorAll("[data-wsr-rank],[data-wsr-dot]");
2057
+ var pinned = document.querySelectorAll('[data-wsr-pin="true"]');
2058
+ for (var k = 0; k < pinned.length; k += 1) pinned[k].remove();
2059
+ pinHost = null;
2060
+ var painted = document.querySelectorAll("[data-wsr-rank],[data-wsr-dot],[data-wsr-state],[data-wsr-pin-hidden]");
2050
2061
  for (var i = 0; i < painted.length; i += 1) {
2051
2062
  painted[i].removeAttribute("data-wsr-rank");
2052
2063
  painted[i].removeAttribute("data-wsr-dot");
2064
+ painted[i].removeAttribute("data-wsr-state");
2065
+ painted[i].removeAttribute("data-wsr-pin-hidden");
2053
2066
  painted[i].style.removeProperty("order");
2054
2067
  }
2055
2068
  var hidden = document.querySelectorAll(".wsr-hidden");
@@ -2076,6 +2089,7 @@
2076
2089
  if (typeof props.t === "function") data.t = props.t;
2077
2090
  /* With the sidebar half off, drop our paint and stop the timer. */
2078
2091
  var sidebarOn = featureOn(data.settings, "sidebar");
2092
+ if (typeof syncPanelsExposed === "function") syncPanelsExposed(data.settings);
2079
2093
  react.useEffect(function () {
2080
2094
  if (sidebarOn) {
2081
2095
  schedule();
@@ -2175,6 +2189,9 @@
2175
2189
  * never take the window's focus away.
2176
2190
  * ------------------------------------------------------------------- */
2177
2191
 
2192
+ /** Set by apply(): keeps gated panel registrations in step with the store. */
2193
+ var syncPanelsExposed = null;
2194
+
2178
2195
  var confirmBackdrop = null;
2179
2196
  var confirmPrevious = null;
2180
2197
  var confirmKey = null;
@@ -5317,13 +5334,6 @@
5317
5334
  }
5318
5335
 
5319
5336
  /** 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
5337
 
5328
5338
  function TrashPanelIcon(props) {
5329
5339
  var Icon = ui.IconTrashOutlineRegular;
@@ -5332,62 +5342,117 @@
5332
5342
  return h(Icon, { size: size });
5333
5343
  }
5334
5344
 
5335
- /** One switch: a title, what it costs to turn off, and a toggle. */
5345
+ /** One switch: a title, what it costs to turn off, and the host's own toggle. */
5336
5346
  function FeatureRow(props) {
5337
- var settings = props.useStore(function (state) { return state; });
5338
- var on = featureOn(settings, props.id);
5347
+ var on = props.on === true;
5348
+ var Switch = ui.Switch;
5349
+ var control;
5350
+ if (typeof Switch === "function") {
5351
+ control = h(Switch, {
5352
+ checked: on,
5353
+ label: props.title,
5354
+ onChange: function () {
5355
+ if (typeof props.onToggle === "function") props.onToggle(props.id);
5356
+ },
5357
+ });
5358
+ } else {
5359
+ /* Older hosts without the primitive fall back to a plain button. */
5360
+ control = h("button", {
5361
+ type: "button",
5362
+ className: on ? "wsr-toggle wsr-toggle-on" : "wsr-toggle",
5363
+ "aria-pressed": on ? "true" : "false",
5364
+ "data-wsr-feature-toggle": props.id,
5365
+ onClick: function () {
5366
+ if (typeof props.onToggle === "function") props.onToggle(props.id);
5367
+ },
5368
+ }, t(on ? "features.on" : "features.off"));
5369
+ }
5339
5370
  return h("div", { className: "wsr-setRow", "data-wsr-feature": props.id },
5340
5371
  h("div", { className: "wsr-setText" },
5341
5372
  h("div", { className: "wsr-setTitle" }, props.title),
5342
5373
  h("div", { className: "wsr-setDesc" }, props.description),
5343
5374
  ),
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
- ),
5375
+ h("div", { className: "wsr-controls", "data-wsr-feature-toggle": props.id }, control),
5353
5376
  );
5377
+ } /** The package this section belongs to, as the plugin page names it. */
5378
+ var OUR_PACKAGE = "dsh-ws-recency";
5379
+
5380
+ /** The package name a detail subject stands for, whichever shape it takes. */
5381
+ function subjectPackageName(subject) {
5382
+ if (subject === null || subject === undefined || typeof subject !== "object") return "";
5383
+ if (typeof subject.name === "string" && subject.name !== "") return subject.name;
5384
+ var pkg = subject.pkg;
5385
+ if (typeof pkg === "string") return pkg;
5386
+ if (pkg !== null && pkg !== undefined && typeof pkg === "object") {
5387
+ if (typeof pkg.name === "string") return pkg.name;
5388
+ if (typeof pkg.id === "string") return pkg.id;
5389
+ }
5390
+ var row = subject.row;
5391
+ if (row !== null && row !== undefined && typeof row === "object" && typeof row.package === "string") return row.package;
5392
+ return "";
5354
5393
  }
5355
5394
 
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; });
5395
+ /**
5396
+ * The plugin page's own section: every ability of this plugin, on or off.
5397
+ *
5398
+ * It renders nothing for another package's page, which is the contract for a
5399
+ * detail section.
5400
+ */
5401
+ function FeaturesSection(props) {
5402
+ var storeSettings = typeof props.useStore === "function" ? props.useStore(function (state) { return state; }) : data.settings;
5403
+ var name = subjectPackageName(props.subject);
5404
+ /* A row subject carries the package differently; accept both spellings. */
5405
+ if (name !== OUR_PACKAGE && String(name).indexOf(OUR_PACKAGE) !== 0) return null;
5406
+
5407
+ /* A toggle is visible at once, even where the slot hands us no store hook. */
5408
+ var overrides = react.useState({});
5409
+ var valueOf = function (id) {
5410
+ var bag = overrides[0] || {};
5411
+ if (typeof bag[id] === "boolean") return bag[id];
5412
+ return featureOn(storeSettings, id);
5413
+ };
5414
+ var setAll = function (bag) { overrides[1](bag); };
5415
+ var toggle = function (id) {
5416
+ var next = {};
5417
+ var bag = overrides[0] || {};
5418
+ next[id] = !valueOf(id);
5419
+ setAll(Object.assign({}, bag, next));
5420
+ if (props.actions !== undefined) props.actions.setFeature(id);
5421
+ };
5422
+ var reset = function () {
5423
+ setAll({});
5424
+ if (props.actions !== undefined) props.actions.resetFeatures();
5425
+ };
5426
+
5359
5427
  var rows = FEATURE_IDS.map(function (id) {
5360
5428
  return h(FeatureRow, {
5361
5429
  key: id,
5362
5430
  id: id,
5363
5431
  title: t("features." + id + ".title"),
5364
5432
  description: t("features." + id + ".desc"),
5365
- useStore: props.useStore,
5366
- actions: props.actions,
5433
+ on: valueOf(id),
5434
+ onToggle: toggle,
5367
5435
  });
5368
5436
  });
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")),
5437
+ var onCount = FEATURE_IDS.filter(function (id) { return valueOf(id); }).length;
5438
+ return h("section", { className: "wsr-plugin-features", "data-wsr-features": OUR_PACKAGE },
5439
+ h("div", { className: "wsr-features-head" },
5440
+ h("div", { className: "wsr-features-title" }, t("features.title")),
5372
5441
  h("button", {
5373
5442
  type: "button",
5374
5443
  className: "wsr-btn",
5375
5444
  "data-wsr-features-reset": "true",
5376
- onClick: function () { props.actions.resetFeatures(); },
5445
+ onClick: reset,
5377
5446
  }, t("features.reset")),
5378
5447
  ),
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
- ),
5448
+ h("div", { className: "wsr-setNote" }, t("features.note")),
5449
+ rows,
5450
+ h("div", { className: "wsr-setNote" }, t("features.takesEffect", {
5451
+ on: String(onCount),
5452
+ all: String(FEATURE_IDS.length),
5453
+ })),
5387
5454
  );
5388
- }
5389
-
5390
- /**
5455
+ } /**
5391
5456
  * The trash page itself: the plugin's trash (deleted logs) on top, the
5392
5457
  * Host's archive set (hidden sessions whose logs are still in place)
5393
5458
  * below. Both are "put away", so both are managed from here.
@@ -5945,16 +6010,7 @@
5945
6010
  });
5946
6011
 
5947
6012
  if (SEARCH_ENABLED) {
5948
- ctx.slots.inject("sidebar.panellist", function () {
5949
- return ctx.slots.register({
5950
- name: "sidebar.panellist",
5951
- id: "ws-recency-search",
5952
- order: 19,
5953
- store: prefs,
5954
- locale: NS,
5955
- label: function () { return t("search.title"); },
5956
- }, withFeature(SearchPanelIcon, "search"));
5957
- });
6013
+
5958
6014
 
5959
6015
  ctx.slots.inject("main", function () {
5960
6016
  return ctx.slots.register({
@@ -5967,35 +6023,17 @@
5967
6023
  }
5968
6024
 
5969
6025
 
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
6026
 
5981
- ctx.slots.inject("sidebar.panellist", function () {
5982
- return ctx.slots.register({
5983
- name: "sidebar.panellist",
5984
- id: "ws-recency-trash",
5985
- order: 20,
5986
- store: prefs,
5987
- locale: NS,
5988
- label: function () { return t("trash.title"); },
5989
- }, withFeature(TrashPanelIcon, "trash"));
5990
- });
6027
+
5991
6028
 
5992
- ctx.slots.inject("main", function () {
6029
+ ctx.slots.inject("plugins.detail.section", function () {
5993
6030
  return ctx.slots.register({
5994
- name: "main",
5995
- key: "ws-recency-features",
6031
+ name: "plugins.detail.section",
6032
+ id: "ws-recency-features",
6033
+ order: 60,
5996
6034
  store: prefs,
5997
6035
  locale: NS,
5998
- }, FeaturesPanelPage);
6036
+ }, FeaturesSection);
5999
6037
  });
6000
6038
 
6001
6039
  ctx.slots.inject("main", function () {
@@ -6083,6 +6121,89 @@
6083
6121
 
6084
6122
 
6085
6123
 
6124
+ /*
6125
+ * Search and trash each own a sidebar row. Hiding the glyph is not enough:
6126
+ * the row's label and its panel page are registered too, so the switch has to
6127
+ * dispose the whole injection and build it again when it comes back.
6128
+ */
6129
+ var gated = {};
6130
+ function bindPanels(feature, build) {
6131
+ gated[feature] = { build: build, dispose: null };
6132
+ syncPanels(data.settings);
6133
+ }
6134
+ function syncPanels(settings) {
6135
+ Object.keys(gated).forEach(function (feature) {
6136
+ var entry = gated[feature];
6137
+ var want = featureOn(settings, feature);
6138
+ if (want && entry.dispose === null) {
6139
+ try {
6140
+ entry.dispose = entry.build();
6141
+ } catch (error) {
6142
+ console.warn("[dsh-ws-recency] could not register " + feature + ":", error);
6143
+ }
6144
+ return;
6145
+ }
6146
+ if (!want && entry.dispose !== null) {
6147
+ try {
6148
+ entry.dispose();
6149
+ } catch (error) {
6150
+ /* already gone */
6151
+ }
6152
+ entry.dispose = null;
6153
+ }
6154
+ });
6155
+ }
6156
+ syncPanelsExposed = syncPanels;
6157
+
6158
+ bindPanels("search", function () {
6159
+ var icon = ctx.slots.inject("sidebar.panellist", function () {
6160
+ return ctx.slots.register({
6161
+ name: "sidebar.panellist",
6162
+ id: "ws-recency-search",
6163
+ order: 19,
6164
+ store: prefs,
6165
+ locale: NS,
6166
+ label: function () { return t("search.title"); },
6167
+ }, SearchPanelIcon);
6168
+ });
6169
+ var page = ctx.slots.inject("main", function () {
6170
+ return ctx.slots.register({
6171
+ name: "main",
6172
+ key: "ws-recency-search",
6173
+ store: prefs,
6174
+ locale: NS,
6175
+ }, SearchPanelPage);
6176
+ });
6177
+ return function () {
6178
+ if (typeof icon === "function") icon();
6179
+ if (typeof page === "function") page();
6180
+ };
6181
+ });
6182
+
6183
+ bindPanels("trash", function () {
6184
+ var icon = ctx.slots.inject("sidebar.panellist", function () {
6185
+ return ctx.slots.register({
6186
+ name: "sidebar.panellist",
6187
+ id: "ws-recency-trash",
6188
+ order: 20,
6189
+ store: prefs,
6190
+ locale: NS,
6191
+ label: function () { return t("trash.title"); },
6192
+ }, TrashPanelIcon);
6193
+ });
6194
+ var page = ctx.slots.inject("main", function () {
6195
+ return ctx.slots.register({
6196
+ name: "main",
6197
+ key: "ws-recency-trash",
6198
+ store: prefs,
6199
+ locale: NS,
6200
+ }, TrashPanelPage);
6201
+ });
6202
+ return function () {
6203
+ if (typeof icon === "function") icon();
6204
+ if (typeof page === "function") page();
6205
+ };
6206
+ });
6086
6207
  ctx.effect(function () {
6087
6208
  return function () { shutdown(); };
6088
6209
  }, "dsh-ws-recency: list observer");
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.0";
35
+ export const HOST_VERSION = "0.35.2";
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.35.0",
3
+ "version": "0.35.2",
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",