dsh-ui-controller 0.2.3 → 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.
Files changed (4) hide show
  1. package/CHANGELOG.md +17 -7
  2. package/README.md +8 -7
  3. package/client.js +45 -111
  4. package/package.json +46 -46
package/CHANGELOG.md CHANGED
@@ -2,17 +2,27 @@
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
+
5
18
  ## 0.2.3 — 2026-11-15
6
19
 
7
20
  ### Fixed
8
21
 
9
- - **The number after More is the sidebar's own truth.** It used to come from
10
- our fold record, while the rows actually off screen are decided by the host's
11
- pin state — so a record naming two panels could sit next to five hidden rows
12
- and paint `更多 (2)`. `foldedRowCount` now counts "panels we know about minus
13
- rows still on screen", reading `display:none` on the row and on any wrapper
14
- the fold pass hid. When the sidebar cannot be read (collapsed, not mounted) the
15
- launcher keeps its bare label instead of guessing a zero.
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.
16
26
 
17
27
  ## 0.2.2 — 2026-11-15
18
28
 
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 — 41 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,12 +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 launcher number is counted from the
205
- DOM (panels minus the rows still on screen, including rows hidden behind a
206
- wrapper) so it can never drift from what the sidebar actually hides, and it
207
- agrees with the rows the menu lists; the count label repaints through the
208
- `nav.panelList` ancestor and only when its text changes; folding hides the live
209
- 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
210
211
  the menu borrows a live host item's class list and computed size instead of any
211
212
  hardcoded name; each menu row copies the panel glyph from the live sidebar row
212
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.3';
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;
@@ -1894,14 +1886,21 @@ function glyphCloneOf(row) {
1894
1886
  for (const match of raw.matchAll(/(?:#|url\()["']?([A-Za-z_][\w.:-]*)/g)) referenced.add(match[1]);
1895
1887
  }
1896
1888
  };
1897
- rememberRefs(clone);
1898
- if (typeof clone.querySelectorAll === 'function') {
1899
- try {
1900
- for (const tagged of Array.from(clone.querySelectorAll('*'))) rememberRefs(tagged);
1901
- } catch {
1902
- /* best effort */
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);
1903
1901
  }
1904
- }
1902
+ };
1903
+ eachNode(clone, rememberRefs);
1905
1904
  const dropId = (element) => {
1906
1905
  const name = element?.getAttribute?.('id');
1907
1906
  if (typeof name !== 'string' || name === '') return;
@@ -1912,14 +1911,7 @@ function glyphCloneOf(row) {
1912
1911
  /* best effort */
1913
1912
  }
1914
1913
  };
1915
- dropId(clone);
1916
- if (typeof clone.querySelectorAll === 'function') {
1917
- try {
1918
- for (const tagged of Array.from(clone.querySelectorAll('[id]'))) dropId(tagged);
1919
- } catch {
1920
- /* best effort */
1921
- }
1922
- }
1914
+ eachNode(clone, dropId);
1923
1915
  return clone;
1924
1916
  }
1925
1917
 
@@ -2105,56 +2097,6 @@ function sidebarMoreReplay(entries, settings, storage) {
2105
2097
  return entries.filter((entry) => entry.pinned === true && wanted.has(entry.id)).map((entry) => entry.id);
2106
2098
  }
2107
2099
 
2108
- /**
2109
- * How many panels are really behind the More button, counted from the sidebar
2110
- * instead of from our own intent record. Two things can hide a panel: the host
2111
- * drops the row of a pinned panel, and our fold pass sets display:none on the
2112
- * rest — so "panels we know about minus rows still on screen" is the only number
2113
- * that cannot drift from what the user sees. Returns null when the sidebar is not
2114
- * readable (collapsed, not mounted yet): the caller keeps the bare label rather
2115
- * than inventing a number.
2116
- */
2117
- function foldedRowCount(doc, panels) {
2118
- if (doc === null || doc === undefined || typeof doc.querySelectorAll !== 'function') return null;
2119
- const total = panels.filter((panel) => panel.id !== 'plugins').length;
2120
- if (total === 0) return 0;
2121
- let rows = [];
2122
- try {
2123
- rows = Array.from(doc.querySelectorAll('nav[class*="panelList"] button[class*="panelRow"]'));
2124
- } catch {
2125
- rows = [];
2126
- }
2127
- if (rows.length === 0) return null;
2128
- /* Identify a row by the panel it draws: the aria-label is the rendered title,
2129
- which is what the host also uses for the row it removes. */
2130
- const byName = new Map();
2131
- for (const panel of panels) {
2132
- if (panel.label !== undefined && panel.label !== '') byName.set(String(panel.label), panel.id);
2133
- byName.set(String(panel.id), panel.id);
2134
- }
2135
- const hiddenInTree = (row) => {
2136
- let node = row;
2137
- for (let depth = 0; node !== null && node !== undefined && depth < 8; depth += 1) {
2138
- if (node.hidden === true) return true;
2139
- if (node.style?.display === 'none') return true;
2140
- node = node.parentElement ?? null;
2141
- }
2142
- return false;
2143
- };
2144
- let shown = 0;
2145
- for (const row of rows) {
2146
- const aria = row.getAttribute?.('aria-label') ?? '';
2147
- /* The launcher is a panel row too; it is never a panel behind itself. */
2148
- if (MORE_TITLES.has(aria)) continue;
2149
- const id = byName.get(aria) ?? null;
2150
- /* Rows we cannot name are not ours to count, and plugins never folds. */
2151
- if (id === null || id === 'plugins') continue;
2152
- if (hiddenInTree(row) === true) continue;
2153
- shown += 1;
2154
- }
2155
- return Math.max(0, total - shown);
2156
- }
2157
-
2158
2100
  /** Write one panel's pin through the host callback and keep the record honest. */
2159
2101
  function writeSidebarPin(id, pinned, entries, settings, storage) {
2160
2102
  if (sidebarWrite === null) return;
@@ -2200,12 +2142,19 @@ function SidebarMoreMenu(props) {
2200
2142
  }
2201
2143
  }
2202
2144
 
2203
- /* The host menu items live in the same list as our rows; borrowing their
2204
- class list and fixed dimensions makes every row look host-drawn. The
2205
- sample is taken a tick later so the official items exist by then. */
2206
- if (sampled === null && typeof setTimeout === 'function') {
2207
- setTimeout(() => setSampled(sampleMoreItem(doc)), 0);
2208
- }
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
+ };
2209
2158
 
2210
2159
  /**
2211
2160
  * Flip one panel. `folded` is the state the row is showing: true means the
@@ -2243,6 +2192,7 @@ function SidebarMoreMenu(props) {
2243
2192
  type: 'button',
2244
2193
  className: rowClass,
2245
2194
  style: rowStyle,
2195
+ ref: ensureSample,
2246
2196
  'data-uic-more-row': entry.id,
2247
2197
  onClick: () => { onOpen(entry.id); onDismiss(); },
2248
2198
  }, [
@@ -2284,13 +2234,12 @@ function SidebarMoreMenu(props) {
2284
2234
  ]);
2285
2235
  }
2286
2236
 
2287
- /**
2288
- * Paint the folded count onto the host's launcher row: find the More button by
2289
- * its own aria-label, then rewrite only the title span. The aria-label stays
2290
- * untouched (screen readers keep "更多"); a missing button is skipped
2291
- * 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.
2292
2241
  */
2293
- function paintMoreCount(doc, panels, titleInfo) {
2242
+ function normalizeMoreTitle(doc) {
2294
2243
  if (doc === null || typeof doc.querySelectorAll !== 'function') return;
2295
2244
  let candidates = [];
2296
2245
  try {
@@ -2319,16 +2268,8 @@ function paintMoreCount(doc, panels, titleInfo) {
2319
2268
  }
2320
2269
  }
2321
2270
  if (title === null || title === undefined) return;
2322
- if (titleInfo.title !== null && titleInfo.title !== title) return;
2323
- if (titleInfo.title === null) {
2324
- titleInfo.title = title;
2325
- titleInfo.original = title.textContent ?? '';
2326
- }
2327
- const count = foldedRowCount(doc, panels);
2328
- /** The aria-label is the stable base; the title may already carry a painted count. */
2329
2271
  const base = launcher.getAttribute('aria-label') ?? '';
2330
- const wanted = count === null ? base : moreLabel(base, count);
2331
- if (title.textContent !== wanted) title.textContent = wanted;
2272
+ if (title.textContent !== base) title.textContent = base;
2332
2273
  }
2333
2274
 
2334
2275
  function apply(ctx) {
@@ -2346,9 +2287,8 @@ function apply(ctx) {
2346
2287
  entriesOf('sidebar.panellist')
2347
2288
  .map((entry) => ({ id: String(entry?.options?.id ?? ''), label: entryLabelOf(entry) }))
2348
2289
  .filter((panel) => panel.id !== '');
2349
- const paintCount = () => paintMoreCount(doc, sidebarPanelsOf(), moreTitle);
2350
- const applyFold = () => applyFoldState(doc, sidebarPanelsOf(), readSettings(), storage(), moreTouched);
2351
- 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');
2352
2292
 
2353
2293
  /* One slot only, and only after it is declared: the inject callback itself
2354
2294
  only fires once the host declares the slot, so the guard is belt and
@@ -2389,14 +2329,14 @@ function apply(ctx) {
2389
2329
  let moreObserver = null;
2390
2330
  if (doc !== null && typeof doc.body?.addEventListener === 'function' && typeof MutationObserver === 'function') {
2391
2331
  try {
2392
- moreObserver = new MutationObserver(() => { applyFold(); paintCount(); });
2332
+ moreObserver = new MutationObserver(() => { applyFold(); normalizeTitle(); });
2393
2333
  moreObserver.observe(doc.body, { childList: true, subtree: true });
2394
2334
  } catch {
2395
2335
  moreObserver = null;
2396
2336
  }
2397
2337
  }
2398
2338
  applyFold();
2399
- paintCount();
2339
+ normalizeTitle();
2400
2340
 
2401
2341
  let pickHandler = null;
2402
2342
 
@@ -2448,9 +2388,6 @@ function apply(ctx) {
2448
2388
  if (row.style !== undefined) row.style.display = original;
2449
2389
  }
2450
2390
  moreTouched.clear();
2451
- if (moreTitle.title !== null) moreTitle.title.textContent = moreTitle.original;
2452
- moreTitle.title = null;
2453
- moreTitle.original = null;
2454
2391
  sidebarWrite = null;
2455
2392
  sidebarPanels = [];
2456
2393
  sidebarReplayQueued = false;
@@ -2469,10 +2406,8 @@ function apply(ctx) {
2469
2406
  applyHidden();
2470
2407
  applyVisualOrder(doc, current, ordered);
2471
2408
  applyFold();
2472
- paintCount();
2473
- };
2474
-
2475
- applyAll();
2409
+ normalizeTitle();
2410
+ }; applyAll();
2476
2411
  const timer = setInterval(applyAll, 2000);
2477
2412
  ctx.effect(() => () => clearInterval(timer), 'ui-controller: reapply timer');
2478
2413
  ctx.effect(
@@ -2590,9 +2525,9 @@ window.__ModuleLoader__.load({
2590
2525
  writeSidebarMore,
2591
2526
  cleanFolded,
2592
2527
  computeFold,
2593
- moreLabel,
2594
2528
  sidebarMoreReplay,
2595
- foldedRowCount,
2529
+ normalizeMoreTitle,
2530
+ glyphCloneOf, glyphCloneOf,
2596
2531
  desiredFoldIds,
2597
2532
  foldedIdsOf,
2598
2533
  entryLabelOf,
@@ -2603,7 +2538,6 @@ window.__ModuleLoader__.load({
2603
2538
  mountMoreGlyph,
2604
2539
  panelRowOf,
2605
2540
  sampleMoreItem,
2606
- paintMoreCount,
2607
2541
  SidebarMoreMenu,
2608
2542
  DICTS,
2609
2543
  };
package/package.json CHANGED
@@ -1,46 +1,46 @@
1
- {
2
- "name": "dsh-ui-controller",
3
- "version": "0.2.3",
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
+ }