dsh-ui-controller 0.2.2 → 0.2.4

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/CHANGELOG.md CHANGED
@@ -2,6 +2,28 @@
2
2
 
3
3
  Notable changes to `dsh-ui-controller`.
4
4
 
5
+ ## 0.2.4 — 2026-11-15
6
+ ### Changed
7
+ - The launcher never shows a folded count anymore (user m20715); the counter
8
+ is removed, and a stale 「更多 (N)」left by an older build is restored to the
9
+ bare label.
10
+ ### Fixed
11
+ - The More menu no longer flashes a bordered row for one frame before the host
12
+ look arrives: the sample is taken from the first row's ref (after the menu
13
+ is in the DOM, before the browser paints), and the fallback row is
14
+ host-shaped (no border, host padding and height).
15
+ - A borrowed glyph keeps the ids its own drawing references, so `<use href="#symbol">`
16
+ icons stay intact instead of turning into empty boxes.
17
+
18
+ ## 0.2.3 — 2026-11-15
19
+
20
+ ### Fixed
21
+
22
+ - A launcher count existed for one release; the number, its painter and its
23
+ label combinator were removed in 0.2.4 after the user asked for no number
24
+ at all (m20715: 「直接不显示那个 数字了」). A stale count painted by this
25
+ release is normalised back to the bare label.
26
+
5
27
  ## 0.2.2 — 2026-11-15
6
28
 
7
29
  ### Fixed
package/README.md CHANGED
@@ -186,7 +186,7 @@ Two sentences that belong in any answer about ordering:
186
186
  node --check client.js
187
187
  node --check index.js
188
188
  node --check test/classify.test.mjs
189
- node test/classify.test.mjs # expect: PASS — 40 groups
189
+ node test/classify.test.mjs # expect: PASS — 43 groups
190
190
  node ..\..\cangku\tmp\261114_gate_ui_controller.mjs # static gate, separate script
191
191
  ```
192
192
 
@@ -201,9 +201,13 @@ its own groups: entries group under their slot with empty seats in their own zon
201
201
  the three filters count what they keep, folding starts closed and survives a
202
202
  re-render, and the static fallback still draws slot heads when no live snapshot is
203
203
  available. The sidebar-more behaviour has groups of its own: replay folds only
204
- what the record and `foldAll` ask for; the count label repaints through the
205
- `nav.panelList` ancestor and only when its text changes; folding hides the live
206
- rows and restores them on the way out, leaving rows it cannot identify alone; and
204
+ what the record and `foldAll` ask for; the launcher carries no number at all — the counter is gone, and a
205
+ stale count painted by an older build is normalised back to the bare label on
206
+ every pass; the first frame of the menu already carries the host row look (the
207
+ sample is taken in the row ref, before the browser paints, so the fallback
208
+ class never reaches the screen and the old bordered fallback style is gone);
209
+ folding hides the live rows and restores them on the way out,
210
+ leaving rows it cannot identify alone; and
207
211
  the menu borrows a live host item's class list and computed size instead of any
208
212
  hardcoded name; each menu row copies the panel glyph from the live sidebar row
209
213
  (runtime clone taken from the drawing inside the host's slot anchor, ids and
package/client.js CHANGED
@@ -27,7 +27,7 @@
27
27
  * slots sort by `priority → order`, everything else by `priority` alone.
28
28
  */
29
29
 
30
- const VERSION = '0.2.2';
30
+ const VERSION = '0.2.4';
31
31
 
32
32
  const NS = 'uiController';
33
33
  const SECTION_ID = 'ui-controller';
@@ -78,8 +78,7 @@ const PAGE_CSS = [
78
78
  '.uic-filter[data-on="true"]{border-color:var(--dsw-alias-state-business-primary);color:var(--dsw-alias-state-business-primary)}',
79
79
  '.uic-sidebarMore{display:flex;flex-direction:column;gap:6px;margin-top:12px;padding-top:10px;border-top:1px solid var(--dsw-alias-border-l2)}',
80
80
  '.uic-sidebarMoreRow{display:flex;align-items:center;gap:8px;font-size:13px;line-height:20px}',
81
- '.uic-moreRow{display:flex;align-items:center;justify-content:space-between;gap:8px;padding:4px 2px;font-size:13px;line-height:20px}',
82
- '.uic-moreRow + .uic-moreRow{border-top:1px solid var(--dsw-alias-border-l2)}',
81
+ '.uic-moreRow{display:flex;align-items:center;justify-content:space-between;gap:8px;min-height:34px;padding:0 8px;font-size:13px;line-height:20px}',
83
82
  '.uic-moreRowName{overflow:hidden;text-overflow:ellipsis;white-space:nowrap}',
84
83
  '.uic-moreRowMain{display:flex;align-items:center;gap:8px;min-width:0;flex:1 1 auto}',
85
84
  '.uic-moreGlyph{display:inline-flex;align-items:center;justify-content:center;flex:none;width:16px;height:16px;overflow:hidden}',
@@ -167,11 +166,6 @@ function computeFold(panels, settings) {
167
166
  return [];
168
167
  }
169
168
 
170
- /** The More launcher's text: "更多 (3)", and the bare label at zero. */
171
- function moreLabel(base, count) {
172
- return count > 0 ? base + ' (' + count + ')' : base;
173
- }
174
-
175
169
  const PRESET_NAME_MAX = 40;
176
170
  const SELECTOR_MAX = 240;
177
171
  const LOCATOR_LIMIT = 400;
@@ -1741,8 +1735,6 @@ const moreTouched = new Map();
1741
1735
  panel's row once it is pinned away, so the icon has to be kept from the last
1742
1736
  time that row was on screen. */
1743
1737
  const moreGlyphs = new Map();
1744
- const moreTitle = { title: null, original: null };
1745
-
1746
1738
  /** Resolve a panel entry's label the way the host does (thunk first, then string, then id). */
1747
1739
  function entryLabelOf(entry) {
1748
1740
  const raw = entry?.options?.label ?? entry?.label;
@@ -1865,22 +1857,61 @@ function glyphCloneOf(row) {
1865
1857
  clone = null;
1866
1858
  }
1867
1859
  if (clone === null) return null;
1868
- /* A cloned SVG can carry ids; the clone root counts as well, because
1869
- querySelectorAll only sees descendants. A cloned wrapper could also still
1870
- name a host slot, which must never be duplicated. */
1860
+ /* A cloned wrapper must never name a host slot twice. Ids are different: an
1861
+ icon drawn by the host is usually an <svg> whose <use href="#name"> points
1862
+ at a symbol, and stripping that symbol's id turns the icon into an empty
1863
+ box - the broken glyphs seen in the More menu. Keep every id the drawing
1864
+ itself refers to and drop only the decorative ones. */
1871
1865
  try {
1872
- clone.removeAttribute?.('id');
1873
1866
  clone.removeAttribute?.('data-slot');
1874
1867
  } catch {
1875
- /* ids are cosmetic in an icon */
1868
+ /* best effort */
1876
1869
  }
1877
- if (typeof clone.querySelectorAll === 'function') {
1870
+ const referenced = new Set();
1871
+ const rememberRefs = (element) => {
1872
+ if (element === null || element === undefined) return;
1873
+ const names = [];
1874
+ for (const key of ['href', 'xlink:href']) {
1875
+ const value = element.getAttribute?.(key);
1876
+ if (typeof value === 'string') names.push(value);
1877
+ }
1878
+ const style = element.getAttribute?.('style');
1879
+ if (typeof style === 'string') names.push(style);
1880
+ for (const value of element.getAttributeNames?.() ?? []) {
1881
+ if (value === 'href' || value === 'xlink:href' || value === 'style') continue;
1882
+ const raw = element.getAttribute?.(value);
1883
+ if (typeof raw === 'string') names.push(raw);
1884
+ }
1885
+ for (const raw of names) {
1886
+ for (const match of raw.matchAll(/(?:#|url\()["']?([A-Za-z_][\w.:-]*)/g)) referenced.add(match[1]);
1887
+ }
1888
+ };
1889
+ /* Walk children instead of querySelectorAll: the selector engine is not
1890
+ guaranteed on every node a browser hands back, and a missed child here
1891
+ would drop an id that an icon's <use> still points at. */
1892
+ const eachNode = (root, visit) => {
1893
+ const stack = [root];
1894
+ while (stack.length > 0) {
1895
+ const current = stack.pop();
1896
+ if (current === null || current === undefined) continue;
1897
+ visit(current);
1898
+ const kids = current.children;
1899
+ if (kids === undefined || kids === null) continue;
1900
+ for (const kid of Array.from(kids)) stack.push(kid);
1901
+ }
1902
+ };
1903
+ eachNode(clone, rememberRefs);
1904
+ const dropId = (element) => {
1905
+ const name = element?.getAttribute?.('id');
1906
+ if (typeof name !== 'string' || name === '') return;
1907
+ if (referenced.has(name)) return;
1878
1908
  try {
1879
- for (const tagged of Array.from(clone.querySelectorAll('[id]'))) tagged.removeAttribute?.('id');
1909
+ element.removeAttribute('id');
1880
1910
  } catch {
1881
1911
  /* best effort */
1882
1912
  }
1883
- }
1913
+ };
1914
+ eachNode(clone, dropId);
1884
1915
  return clone;
1885
1916
  }
1886
1917
 
@@ -2066,12 +2097,6 @@ function sidebarMoreReplay(entries, settings, storage) {
2066
2097
  return entries.filter((entry) => entry.pinned === true && wanted.has(entry.id)).map((entry) => entry.id);
2067
2098
  }
2068
2099
 
2069
- /** The count the launcher shows: folded ids that still name a live panel. */
2070
- function sidebarMoreCount(panels, settings, storage) {
2071
- if (settings?.sidebarMore?.foldAll === true) return computeFold(panels, settings).length;
2072
- return cleanFolded(readSidebarMore(storage).folded, panels).length;
2073
- }
2074
-
2075
2100
  /** Write one panel's pin through the host callback and keep the record honest. */
2076
2101
  function writeSidebarPin(id, pinned, entries, settings, storage) {
2077
2102
  if (sidebarWrite === null) return;
@@ -2117,12 +2142,19 @@ function SidebarMoreMenu(props) {
2117
2142
  }
2118
2143
  }
2119
2144
 
2120
- /* The host menu items live in the same list as our rows; borrowing their
2121
- class list and fixed dimensions makes every row look host-drawn. The
2122
- sample is taken a tick later so the official items exist by then. */
2123
- if (sampled === null && typeof setTimeout === 'function') {
2124
- setTimeout(() => setSampled(sampleMoreItem(doc)), 0);
2125
- }
2145
+ /* The host menu items share this list, so borrowing their class list is what
2146
+ makes our rows look host-drawn. The sample cannot wait for a setTimeout
2147
+ tick: that painted the fallback row for one frame and the switch was
2148
+ visible. React runs ref callbacks after the whole menu is in the DOM and
2149
+ before the browser paints, so the first row's ref takes the sample there
2150
+ and the fallback class never reaches the screen. */
2151
+ const ensureSample = () => {
2152
+ if (sampled !== null) return true;
2153
+ const taken = sampleMoreItem(doc);
2154
+ if (taken === null) return false;
2155
+ setSampled(taken);
2156
+ return true;
2157
+ };
2126
2158
 
2127
2159
  /**
2128
2160
  * Flip one panel. `folded` is the state the row is showing: true means the
@@ -2160,6 +2192,7 @@ function SidebarMoreMenu(props) {
2160
2192
  type: 'button',
2161
2193
  className: rowClass,
2162
2194
  style: rowStyle,
2195
+ ref: ensureSample,
2163
2196
  'data-uic-more-row': entry.id,
2164
2197
  onClick: () => { onOpen(entry.id); onDismiss(); },
2165
2198
  }, [
@@ -2201,13 +2234,12 @@ function SidebarMoreMenu(props) {
2201
2234
  ]);
2202
2235
  }
2203
2236
 
2204
- /**
2205
- * Paint the folded count onto the host's launcher row: find the More button by
2206
- * its own aria-label, then rewrite only the title span. The aria-label stays
2207
- * untouched (screen readers keep "更多"); a missing button is skipped
2208
- * silently.
2237
+ /** Restore the host's own launcher label. Older builds painted a folded count
2238
+ * onto the title span ("更多 (2)"); the counter is gone now, so this pass makes
2239
+ * sure the span always reads exactly what the aria-label says. Idempotent: it
2240
+ * only writes when the text differs, and it never adds a number itself.
2209
2241
  */
2210
- function paintMoreCount(doc, panels, settings, storageRef, titleInfo) {
2242
+ function normalizeMoreTitle(doc) {
2211
2243
  if (doc === null || typeof doc.querySelectorAll !== 'function') return;
2212
2244
  let candidates = [];
2213
2245
  try {
@@ -2236,16 +2268,8 @@ function paintMoreCount(doc, panels, settings, storageRef, titleInfo) {
2236
2268
  }
2237
2269
  }
2238
2270
  if (title === null || title === undefined) return;
2239
- if (titleInfo.title !== null && titleInfo.title !== title) return;
2240
- if (titleInfo.title === null) {
2241
- titleInfo.title = title;
2242
- titleInfo.original = title.textContent ?? '';
2243
- }
2244
- const count = sidebarMoreCount(panels.map((panel) => panel.id), settings, storageRef);
2245
- /** The aria-label is the stable base; the title may already carry a painted count. */
2246
2271
  const base = launcher.getAttribute('aria-label') ?? '';
2247
- const wanted = moreLabel(base, count);
2248
- if (title.textContent !== wanted) title.textContent = wanted;
2272
+ if (title.textContent !== base) title.textContent = base;
2249
2273
  }
2250
2274
 
2251
2275
  function apply(ctx) {
@@ -2263,9 +2287,8 @@ function apply(ctx) {
2263
2287
  entriesOf('sidebar.panellist')
2264
2288
  .map((entry) => ({ id: String(entry?.options?.id ?? ''), label: entryLabelOf(entry) }))
2265
2289
  .filter((panel) => panel.id !== '');
2266
- const paintCount = () => paintMoreCount(doc, sidebarPanelsOf(), readSettings(), storage(), moreTitle);
2267
- const applyFold = () => applyFoldState(doc, sidebarPanelsOf(), readSettings(), storage(), moreTouched);
2268
- ctx.effect(() => () => clearMoreGlyphs(), 'ui-controller: forget sampled glyphs');
2290
+ const normalizeTitle = () => normalizeMoreTitle(doc);
2291
+ const applyFold = () => applyFoldState(doc, sidebarPanelsOf(), readSettings(), storage(), moreTouched); ctx.effect(() => () => clearMoreGlyphs(), 'ui-controller: forget sampled glyphs');
2269
2292
 
2270
2293
  /* One slot only, and only after it is declared: the inject callback itself
2271
2294
  only fires once the host declares the slot, so the guard is belt and
@@ -2306,14 +2329,14 @@ function apply(ctx) {
2306
2329
  let moreObserver = null;
2307
2330
  if (doc !== null && typeof doc.body?.addEventListener === 'function' && typeof MutationObserver === 'function') {
2308
2331
  try {
2309
- moreObserver = new MutationObserver(() => { paintCount(); applyFold(); });
2332
+ moreObserver = new MutationObserver(() => { applyFold(); normalizeTitle(); });
2310
2333
  moreObserver.observe(doc.body, { childList: true, subtree: true });
2311
2334
  } catch {
2312
2335
  moreObserver = null;
2313
2336
  }
2314
2337
  }
2315
- paintCount();
2316
2338
  applyFold();
2339
+ normalizeTitle();
2317
2340
 
2318
2341
  let pickHandler = null;
2319
2342
 
@@ -2365,9 +2388,6 @@ function apply(ctx) {
2365
2388
  if (row.style !== undefined) row.style.display = original;
2366
2389
  }
2367
2390
  moreTouched.clear();
2368
- if (moreTitle.title !== null) moreTitle.title.textContent = moreTitle.original;
2369
- moreTitle.title = null;
2370
- moreTitle.original = null;
2371
2391
  sidebarWrite = null;
2372
2392
  sidebarPanels = [];
2373
2393
  sidebarReplayQueued = false;
@@ -2385,11 +2405,9 @@ function apply(ctx) {
2385
2405
  const current = readSettings();
2386
2406
  applyHidden();
2387
2407
  applyVisualOrder(doc, current, ordered);
2388
- paintCount();
2389
2408
  applyFold();
2390
- };
2391
-
2392
- applyAll();
2409
+ normalizeTitle();
2410
+ }; applyAll();
2393
2411
  const timer = setInterval(applyAll, 2000);
2394
2412
  ctx.effect(() => () => clearInterval(timer), 'ui-controller: reapply timer');
2395
2413
  ctx.effect(
@@ -2507,9 +2525,9 @@ window.__ModuleLoader__.load({
2507
2525
  writeSidebarMore,
2508
2526
  cleanFolded,
2509
2527
  computeFold,
2510
- moreLabel,
2511
2528
  sidebarMoreReplay,
2512
- sidebarMoreCount,
2529
+ normalizeMoreTitle,
2530
+ glyphCloneOf, glyphCloneOf,
2513
2531
  desiredFoldIds,
2514
2532
  foldedIdsOf,
2515
2533
  entryLabelOf,
@@ -2520,7 +2538,6 @@ window.__ModuleLoader__.load({
2520
2538
  mountMoreGlyph,
2521
2539
  panelRowOf,
2522
2540
  sampleMoreItem,
2523
- paintMoreCount,
2524
2541
  SidebarMoreMenu,
2525
2542
  DICTS,
2526
2543
  };
package/package.json CHANGED
@@ -1,46 +1,46 @@
1
- {
2
- "name": "dsh-ui-controller",
3
- "version": "0.2.2",
4
- "description": "Inspect and control the UI other plugins register into DeepSeek Harness slots (visibility, order, mirrored entries), and fold the sidebar's panels behind a single \"More (N)\" row.",
5
- "license": "MIT",
6
- "author": {
7
- "name": "MeruSu"
8
- },
9
- "repository": {
10
- "type": "git",
11
- "url": "git+https://github.com/MeruSu/dsh-ui-controller.git"
12
- },
13
- "keywords": [
14
- "dsh",
15
- "deepseek-harness",
16
- "dsh-plugin",
17
- "ui"
18
- ],
19
- "type": "module",
20
- "exports": {
21
- ".": "./index.js",
22
- "./client": "./client.js",
23
- "./package.json": "./package.json",
24
- "./locale/*.json": "./locale/*.json",
25
- "./icon": "./icon.svg"
26
- },
27
- "files": [
28
- "index.js",
29
- "client.js",
30
- "cordis.patch.yml",
31
- "README.md",
32
- "LICENSE",
33
- "locale",
34
- "icon.svg",
35
- "CHANGELOG.md"
36
- ],
37
- "dsh": {
38
- "bundle": {
39
- "patch": "./cordis.patch.yml"
40
- },
41
- "client": {
42
- "platform": "web"
43
- }
44
- },
45
- "icon": "./icon.svg"
46
- }
1
+ {
2
+ "name": "dsh-ui-controller",
3
+ "version": "0.2.4",
4
+ "description": "Inspect and control the UI other plugins register into DeepSeek Harness slots (visibility, order, mirrored entries), and fold the sidebar's panels behind a single \"More (N)\" row.",
5
+ "license": "MIT",
6
+ "author": {
7
+ "name": "MeruSu"
8
+ },
9
+ "repository": {
10
+ "type": "git",
11
+ "url": "git+https://github.com/MeruSu/dsh-ui-controller.git"
12
+ },
13
+ "keywords": [
14
+ "dsh",
15
+ "deepseek-harness",
16
+ "dsh-plugin",
17
+ "ui"
18
+ ],
19
+ "type": "module",
20
+ "exports": {
21
+ ".": "./index.js",
22
+ "./client": "./client.js",
23
+ "./package.json": "./package.json",
24
+ "./locale/*.json": "./locale/*.json",
25
+ "./icon": "./icon.svg"
26
+ },
27
+ "files": [
28
+ "index.js",
29
+ "client.js",
30
+ "cordis.patch.yml",
31
+ "README.md",
32
+ "LICENSE",
33
+ "locale",
34
+ "icon.svg",
35
+ "CHANGELOG.md"
36
+ ],
37
+ "dsh": {
38
+ "bundle": {
39
+ "patch": "./cordis.patch.yml"
40
+ },
41
+ "client": {
42
+ "platform": "web"
43
+ }
44
+ },
45
+ "icon": "./icon.svg"
46
+ }