dsh-better-sidebar-left 0.1.6 → 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
@@ -10,7 +10,7 @@
10
10
  首个版本。把五个「会话管理类」插件合并成一个聚合包,插件列表里只出现一行。
11
11
 
12
12
  - 组件(全部从 **GitHub 仓库的本地检出** vendor,不从 npm 取):
13
- `dsh-delete-session` 0.5.0、`dsh-session-relocate` 0.3.1、`dsh-session-rename-dblclick` 0.2.0、
13
+ `dsh-delete-session` 0.5.0、`dsh-session-relocate` 0.3.1、`dsh-session-rename-dblclick` 0.3.0、
14
14
  `dsh-session-counts` 0.0.3、`dsh-declutter` 0.2.0。
15
15
  每个的上游 commit 钉在 `package.json` 的 `dsh.vendorSources`,`npm run verify:manifest` 离线核对。
16
16
  - 单一行身份:`cordis.patch.yml` 插 1 行裸包名 + 5 行 `dsh-better-sidebar-left/<后缀>`;
package/README.en.md CHANGED
@@ -11,7 +11,7 @@ Five session-management plugins in one install. **The plugin list grows by exact
11
11
  |---|---|
12
12
  | `dsh-delete-session` 0.5.0 | **Delete a session** from the sidebar row menu: a risk list (log, workspace files, quarantine folder) first, nothing touched until you confirm; plus a multi-select footer bar for batches |
13
13
  | `dsh-session-relocate` 0.3.1 | **Move across workspaces**: row menu, context menu, or drag the session row onto the target workspace - a crash-recoverable transaction, open-but-idle sessions included |
14
- | `dsh-session-rename-dblclick` 0.2.0 | **Rename in place**: one click on the header title, a double click on a sidebar row; the pill follows the shipped title (40px, 22px radius, outline on hover, brand ring while editing), Enter saves, Esc cancels |
14
+ | `dsh-session-rename-dblclick` 0.3.0 | **Rename in place**: one click on the header title, a double click on a sidebar row; the pill follows the shipped title (40px, 22px radius, outline on hover, brand ring while editing), Enter saves, Esc cancels |
15
15
  | `dsh-session-counts` 0.0.3 | **Per-workspace counts**: a badge at the end of each workspace row and a total next to the section label, following the archived filter |
16
16
  | `dsh-declutter` 0.2.0 | **Declutter**: failed/empty/synthesised turns fold away per a rule table (view attributes only, reversible, log untouched) + sidebar tidying (brand row, New session, More buttons, top gap, panel visibility and order) |
17
17
 
package/README.md CHANGED
@@ -10,7 +10,7 @@
10
10
  |---|---|
11
11
  | `dsh-delete-session` 0.5.0 | 侧栏会话行「…」菜单里的**删除会话**:先给风险清单(日志 / 工作区文件 / 隔离目录),确认后才动手;另有批量多选底栏 |
12
12
  | `dsh-session-relocate` 0.3.1 | **跨工作区移动**:会话行「…」菜单、右键菜单、直接把会话行拖到目标工作区;崩溃可恢复的事务,打开中但空闲的会话也能搬 |
13
- | `dsh-session-rename-dblclick` 0.2.0 | **就地改名**:顶栏标题单击、侧栏行双击;胶囊尺寸/配色照官方标题(40px、22px 圆角、悬停描边、聚焦品牌色),Enter 存 / Esc 取消 |
13
+ | `dsh-session-rename-dblclick` 0.3.0 | **就地改名**:顶栏标题单击、侧栏行双击;胶囊尺寸/配色照官方标题(40px、22px 圆角、悬停描边、聚焦品牌色),Enter 存 / Esc 取消 |
14
14
  | `dsh-session-counts` 0.0.3 | **工作区会话数**:每行行尾显示计数,表头显示总数,口径跟随「已归档」筛选 |
15
15
  | `dsh-declutter` 0.2.0 | **收纳与整理**:会话内失败轮/空轮/合成轮按规则表收起(只加视图属性,可逆,不改日志)+ 侧栏藏品牌行 /「新会话」/「更多」/顶部空隙,面板显隐与排序 |
16
16
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "dsh-better-sidebar-left",
3
- "version": "0.1.6",
3
+ "version": "0.2.4",
4
4
  "description": "Session management for DeepSeek Harness in one install: delete a session with a risk-checked confirmation, move one across workspaces (menu and drag), rename one by double-clicking its title, show per-workspace session counts, and declutter both the sidebar and the conversation's collapsed turns. Self-contained: the plugin list shows this one row, and the five components are vendored inside it - installing this plugin installs nothing else.",
5
5
  "type": "module",
6
6
  "main": "src/index.js",
@@ -68,8 +68,8 @@
68
68
  "dsh-delete-session": {
69
69
  "repo": "https://github.com/DDDMUC/dsh-delete-session",
70
70
  "ref": "main",
71
- "commit": "ace70523d299b57ab4d86563f99b728ffdc0150f",
72
- "version": "0.5.0"
71
+ "commit": "53671e41695ffcbd8c802f2a4da277a8ead0d82f",
72
+ "version": "0.5.1"
73
73
  },
74
74
  "dsh-session-relocate": {
75
75
  "repo": "https://github.com/DDDMUC/dsh-session-relocate",
@@ -80,8 +80,8 @@
80
80
  "dsh-session-rename-dblclick": {
81
81
  "repo": "https://github.com/DDDMUC/dsh-session-rename-dblclick",
82
82
  "ref": "main",
83
- "commit": "28a621aed02d63fdaf1ee406d1eaef260d0d741b",
84
- "version": "0.2.0"
83
+ "commit": "b86a1c4f9bb4b631c75e6d87eda058b8ffce6f8c",
84
+ "version": "0.3.0"
85
85
  },
86
86
  "dsh-session-counts": {
87
87
  "repo": "https://github.com/DDDMUC/dsh-session-counts",
@@ -92,8 +92,8 @@
92
92
  "dsh-declutter": {
93
93
  "repo": "https://github.com/DDDMUC/dsh-declutter",
94
94
  "ref": "main",
95
- "commit": "0ae7873dabdc39ddd26ff7a9ea58f04841c8b003",
96
- "version": "0.2.0"
95
+ "commit": "a75b43301b0bb8525c750711a865a1b182006397",
96
+ "version": "0.2.4"
97
97
  }
98
98
  },
99
99
  "client": {
package/src/client.js CHANGED
@@ -3327,7 +3327,7 @@ window.__ModuleLoader__.load({
3327
3327
  }
3328
3328
  }
3329
3329
 
3330
- return { apply }
3330
+ return { apply, __settings: { SettingsCard: AskBeforeDeleteOption } }
3331
3331
  }
3332
3332
 
3333
3333
  // ===== vendored dsh-session-relocate =====
@@ -6184,7 +6184,6 @@ window.__ModuleLoader__.load({
6184
6184
  const ROUTE = '/dsh-session-rename/rename'
6185
6185
  const MAX_TITLE = 200
6186
6186
  const STYLE_ATTR = 'data-dsh-session-rename'
6187
- const SESSION_IN_PATH = /\/session\/([^/?#]+)/
6188
6187
 
6189
6188
  const zh = typeof navigator !== 'undefined' && /^zh/i.test(navigator.language || '')
6190
6189
  const text = zh
@@ -6318,29 +6317,6 @@ window.__ModuleLoader__.load({
6318
6317
  return null
6319
6318
  }
6320
6319
 
6321
- /**
6322
- * The Session a sidebar row names.
6323
- *
6324
- * `data-row-key` first: current builds render the row as
6325
- * `<div role="treeitem" data-row-key="session:<id>">` with an onClick. The
6326
- * anchor this module used to require no longer exists, which made every
6327
- * double-click a silent no-op. The anchor stays as a fallback.
6328
- * @param {Element} row
6329
- * @returns {string | null}
6330
- */
6331
- function sessionIdOfRow(row) {
6332
- const key = row && typeof row.getAttribute === 'function' ? row.getAttribute('data-row-key') : null
6333
- if (typeof key === 'string' && key.startsWith('session:') && key.length > 'session:'.length) {
6334
- return key.slice('session:'.length)
6335
- }
6336
- const link = row && typeof row.querySelector === 'function' ? row.querySelector('a[href*="/session/"]') : null
6337
- return sessionIdFromHref(link && link.getAttribute('href'))
6338
- }
6339
-
6340
- function sessionIdFromHref(href) {
6341
- const match = href ? SESSION_IN_PATH.exec(href) : null
6342
- return match ? match[1] : null
6343
- }
6344
6320
 
6345
6321
  /**
6346
6322
  * Map a double-clicked node to the Session title it names.
@@ -6364,16 +6340,9 @@ window.__ModuleLoader__.load({
6364
6340
  return sessionId ? { sessionId, titleEl: crumb, surface: 'header' } : null
6365
6341
  }
6366
6342
 
6367
- // sidebar row: `data-row-key="session:<id>"` is the shipped contract.
6368
- // The row is a <div role="treeitem" data-row-key=...> with an onClick, not
6369
- // a link - requiring an anchor here matched nothing in current builds, so
6370
- // every double-click was a silent no-op.
6371
- const row = el.closest('[class*="_sessionRow"], [data-row-key^="session:"]')
6372
- if (!row) return null
6373
- const titleEl = el.closest('[class*="_title"]') || row.querySelector('[class*="_title"]')
6374
- if (!titleEl || !row.contains(titleEl)) return null
6375
- const sessionId = sessionIdOfRow(row)
6376
- return sessionId ? { sessionId, titleEl, surface: 'row' } : null
6343
+ // Sidebar rows are deliberately NOT ours: clicking a row opens the session and
6344
+ // the product owns renaming there. This plugin edits the header title only.
6345
+ return null
6377
6346
  }
6378
6347
 
6379
6348
  // --- the in-place editor ---------------------------------------------------
@@ -6748,13 +6717,7 @@ window.__ModuleLoader__.load({
6748
6717
 
6749
6718
  // --- listener --------------------------------------------------------------
6750
6719
 
6751
- // The browser's own `dblclick` is the primary trigger, but some builds route
6752
- // a row click through handlers that cancel the native double-click synthesis.
6753
- // Tracking the two clicks here keeps the gesture working either way: same
6754
- // session, within 600 ms, within 8 px of the previous click.
6755
- const DOUBLE_MS = 600
6756
- const DOUBLE_PX = 8
6757
- let lastClick = null
6720
+ // (Single-click editing only: the sidebar-row double click was removed.)
6758
6721
 
6759
6722
  /**
6760
6723
  * The header title a hover is over, or null.
@@ -6785,64 +6748,160 @@ window.__ModuleLoader__.load({
6785
6748
  hideRing()
6786
6749
  }
6787
6750
 
6788
- function onDoubleClick(event) {
6751
+ // --- sidebar row click gate ------------------------------------------------
6752
+ //
6753
+ // The product navigates on `click` (Rows.tsx: onClick -> onOpen) and only opens its
6754
+ // rename dialog on the `dblclick` that follows the second click. A fast double click
6755
+ // therefore switches the session before the dialog appears. One click cannot know
6756
+ // whether a second is coming, so the first click is held briefly: if another arrives
6757
+ // within HOLD_MS both are swallowed (the product's own dblclick still opens its
6758
+ // dialog), otherwise the click is replayed so the session opens as usual.
6759
+ // Fixed at the request's value: a normal double click finishes inside the hold, so the
6760
+ // first click of a pair is never replayed. A single click on another row's title
6761
+ // therefore navigates after this delay; a slower pair is undone by the dblclick
6762
+ // handler below, which opens the previous session again.
6763
+ const HOLD_MS = 120
6764
+ let heldClick = null
6765
+ let replaying = false
6766
+ let lastReplay = null
6767
+
6768
+ function rowOfNode(node) {
6769
+ const el = elementOf(node)
6770
+ if (!el || typeof el.closest !== 'function') return null
6771
+ return el.closest('[class*="_sessionRow"], [data-row-key^="session:"]')
6772
+ }
6773
+
6774
+ function isRowSelected(row) {
6775
+ const name = row && typeof row.className === 'string' ? row.className : ''
6776
+ return /(^|\s)[A-Za-z0-9_-]*_selected(\s|$)/.test(name)
6777
+ }
6778
+
6779
+ function releaseHeldClick() {
6780
+ if (heldClick === null) return null
6781
+ const held = heldClick
6782
+ heldClick = null
6783
+ if (held.timer !== null && typeof clearTimeout === 'function') clearTimeout(held.timer)
6784
+ return held
6785
+ }
6786
+
6787
+ function replayClick(held) {
6788
+ const row = held.row
6789
+ if (!row || row.isConnected === false) return
6790
+ let event = null
6791
+ try {
6792
+ const view = typeof window === 'undefined' ? null : window
6793
+ event = new MouseEvent('click', { bubbles: true, cancelable: true, view, detail: 1, clientX: held.x, clientY: held.y })
6794
+ } catch (error) {
6795
+ event = null
6796
+ }
6797
+ if (event === null || typeof row.dispatchEvent !== 'function') return
6798
+ // Remember what this replay is about to replace: if the user turns out to be
6799
+ // double clicking (slowly), the dblclick handler below puts the previous session
6800
+ // back so the rename never leaves them somewhere else.
6801
+ let previousRow = null
6802
+ try {
6803
+ previousRow = document.querySelector('[class*="_selected"][data-row-key^="session:"]')
6804
+ } catch (error) {
6805
+ previousRow = null
6806
+ }
6807
+ lastReplay = {
6808
+ row,
6809
+ previous: previousRow !== null && previousRow !== row ? previousRow : null,
6810
+ at: Date.now(),
6811
+ }
6812
+ replaying = true
6813
+ try {
6814
+ row.dispatchEvent(event)
6815
+ } finally {
6816
+ replaying = false
6817
+ }
6818
+ }
6819
+
6820
+ /**
6821
+ * Undo a replay that turned out to be the first half of a double click.
6822
+ *
6823
+ * Fast double clicks are already handled by the hold above. A slower one (say 350ms
6824
+ * apart) lets the replay navigate first and only then fires the product dblclick, so
6825
+ * the rename would leave the user on the wrong session. Here the previous session is
6826
+ * opened again, and the product dialog keeps opening on the row that was double
6827
+ * clicked.
6828
+ */
6829
+ function onRowDoubleClick(event) {
6830
+ if (lastReplay === null) return
6789
6831
  if (event.button !== 0) return
6790
- const target = resolveTarget(event.target)
6791
- if (!target) {
6792
- lastClick = null
6793
- return
6832
+ const row = rowOfNode(event.target)
6833
+ if (row === null || row !== lastReplay.row) return
6834
+ const el = elementOf(event.target)
6835
+ const titleEl = el && typeof el.closest === 'function' ? el.closest('[class*="_title"]') : null
6836
+ if (titleEl === null || titleEl === undefined || typeof row.contains !== 'function' || !row.contains(titleEl)) return
6837
+ const replay = lastReplay
6838
+ lastReplay = null
6839
+ if (Date.now() - replay.at > 900) return
6840
+ const previous = replay.previous
6841
+ if (previous === null || previous === undefined || previous.isConnected === false) return
6842
+ let event2 = null
6843
+ try {
6844
+ const view = typeof window === 'undefined' ? null : window
6845
+ event2 = new MouseEvent('click', { bubbles: true, cancelable: true, view, detail: 1 })
6846
+ } catch (error) {
6847
+ event2 = null
6794
6848
  }
6795
- if (target.surface === 'header') {
6796
- // Leave the event alone. The current crumb is a plain <span> with no handler of
6797
- // its own (only ancestor crumbs are buttons, and those are not this node), so
6798
- // there is nothing to defend against - and swallowing it took away the native
6799
- // "double click selects a word" inside our own input, which is exactly what one
6800
- // wants while renaming.
6801
- if (editor === null) openEditor(target)
6849
+ if (event2 === null || typeof previous.dispatchEvent !== 'function') return
6850
+ replaying = true
6851
+ try {
6852
+ previous.dispatchEvent(event2)
6853
+ } finally {
6854
+ replaying = false
6855
+ }
6856
+ }
6857
+ function onRowClick(event) {
6858
+ if (replaying) return
6859
+ if (event.button !== 0) return
6860
+ if (event.detail === 0) return
6861
+ const row = rowOfNode(event.target)
6862
+ if (row === null) return
6863
+ const el = elementOf(event.target)
6864
+ const titleEl = el && typeof el.closest === 'function' ? el.closest('[class*="_title"]') : null
6865
+ if (titleEl === null || titleEl === undefined || typeof row.contains !== 'function' || !row.contains(titleEl)) return
6866
+ if (isRowSelected(row)) return
6867
+ if (event.detail >= 2) {
6868
+ if (heldClick !== null && heldClick.row === row) {
6869
+ releaseHeldClick()
6870
+ event.preventDefault()
6871
+ event.stopPropagation()
6872
+ return
6873
+ }
6874
+ // The first half of this pair was already replayed (the hold ran out); swallow
6875
+ // the second click as well and let the dblclick handler roll the navigation back.
6876
+ if (lastReplay !== null && lastReplay.row === row && Date.now() - lastReplay.at < 900) {
6877
+ event.preventDefault()
6878
+ event.stopPropagation()
6879
+ }
6802
6880
  return
6803
6881
  }
6804
- // A row is different: the product opens ITS rename dialog on this same event
6805
- // (Rows.tsx: onDoubleClick -> onRenameRequest). Swallow it whether or not our
6806
- // editor is up, otherwise the stock modal lands on top of our input.
6882
+ const previous = releaseHeldClick()
6883
+ if (previous !== null) replayClick(previous)
6807
6884
  event.preventDefault()
6808
6885
  event.stopPropagation()
6809
- if (editor) return
6810
- openEditor(target)
6886
+ heldClick = {
6887
+ row,
6888
+ x: event.clientX,
6889
+ y: event.clientY,
6890
+ at: Date.now(),
6891
+ timer: typeof setTimeout === 'function' ? setTimeout(() => {
6892
+ const held = releaseHeldClick()
6893
+ if (held !== null) replayClick(held)
6894
+ }, HOLD_MS) : null,
6895
+ }
6811
6896
  }
6812
-
6813
6897
  function onClick(event) {
6814
6898
  if (event.button !== 0) return
6815
- if (editor) return
6899
+ if (editor !== null) return
6816
6900
  const target = resolveTarget(event.target)
6817
- if (!target) {
6818
- lastClick = null
6819
- return
6820
- }
6821
- // The header title is a plain span: clicking it does nothing in the product, so
6822
- // ONE click opens the editor - that is what the reference implementation does
6823
- // (the box is always there, a click swaps its contents for an input). A sidebar
6824
- // row is different: clicking it opens the session, so it needs the deliberate
6825
- // second click.
6826
- if (target.surface === 'header') {
6827
- lastClick = null
6828
- event.preventDefault()
6829
- event.stopPropagation()
6830
- openEditor(target)
6831
- return
6832
- }
6833
- const now = Date.now()
6834
- const previous = lastClick
6835
- lastClick = { sessionId: target.sessionId, x: event.clientX, y: event.clientY, time: now }
6836
- // A real double-click reports detail 2; the timing test covers the case
6837
- // where the browser's own synthesis never happened.
6838
- const byDetail = event.detail >= 2
6839
- const byTiming = previous !== null
6840
- && previous.sessionId === target.sessionId
6841
- && now - previous.time <= DOUBLE_MS
6842
- && Math.abs(previous.x - event.clientX) <= DOUBLE_PX
6843
- && Math.abs(previous.y - event.clientY) <= DOUBLE_PX
6844
- if (!byDetail && !byTiming) return
6845
- lastClick = null
6901
+ if (target === null) return
6902
+ // Only the header title is ours: it is a plain <span> that does nothing on click
6903
+ // in the product, so one click opens the field. Sidebar rows belong to the
6904
+ // product (a click opens the session and it owns renaming there).
6846
6905
  event.preventDefault()
6847
6906
  event.stopPropagation()
6848
6907
  openEditor(target)
@@ -6856,10 +6915,11 @@ window.__ModuleLoader__.load({
6856
6915
  // a second listener pair would open two editors over the same title.
6857
6916
  if (typeof window !== 'undefined' && window.__DSH_SESSION_RENAME__) return
6858
6917
  if (typeof window !== 'undefined') window.__DSH_SESSION_RENAME__ = true
6859
- console.info('[dsh-session-rename-dblclick] ready — double-click a session title to rename')
6918
+ console.info('[dsh-session-rename-dblclick] ready — click the header title to rename')
6860
6919
  const install = () => {
6861
- document.addEventListener('dblclick', onDoubleClick, true)
6862
6920
  document.addEventListener('click', onClick, true)
6921
+ document.addEventListener('click', onRowClick, true)
6922
+ document.addEventListener('dblclick', onRowDoubleClick, true)
6863
6923
  document.addEventListener('mouseover', onHover, true)
6864
6924
  document.addEventListener('mouseout', onOut, true)
6865
6925
  // Not every environment that runs this bundle has a window (the tests drive
@@ -6870,8 +6930,11 @@ window.__ModuleLoader__.load({
6870
6930
  window.addEventListener('resize', hideRing)
6871
6931
  }
6872
6932
  return () => {
6873
- document.removeEventListener('dblclick', onDoubleClick, true)
6874
6933
  document.removeEventListener('click', onClick, true)
6934
+ document.removeEventListener('click', onRowClick, true)
6935
+ document.removeEventListener('dblclick', onRowDoubleClick, true)
6936
+ lastReplay = null
6937
+ releaseHeldClick()
6875
6938
  document.removeEventListener('mouseover', onHover, true)
6876
6939
  document.removeEventListener('mouseout', onOut, true)
6877
6940
  if (hasWindow) {
@@ -6879,7 +6942,6 @@ window.__ModuleLoader__.load({
6879
6942
  window.removeEventListener('resize', hideRing)
6880
6943
  }
6881
6944
  hideRing()
6882
- lastClick = null
6883
6945
  finish()
6884
6946
  if (typeof window !== 'undefined') window.__DSH_SESSION_RENAME__ = false
6885
6947
  }
@@ -6889,7 +6951,7 @@ window.__ModuleLoader__.load({
6889
6951
 
6890
6952
  }
6891
6953
 
6892
- return { apply, __resolveTarget: resolveTarget, __sessionIdOfRow: sessionIdOfRow, __sessionIdForHeader: sessionIdForHeader, __openEditor: openEditor, __onDoubleClick: onDoubleClick }
6954
+ return { apply, __resolveTarget: resolveTarget, __sessionIdForHeader: sessionIdForHeader, __openEditor: openEditor }
6893
6955
  }
6894
6956
 
6895
6957
  // ===== vendored dsh-session-counts =====
@@ -7276,10 +7338,12 @@ window.__ModuleLoader__.load({
7276
7338
  const react = require('react')
7277
7339
 
7278
7340
  const NS = 'dsh-declutter'
7279
- const VERSION = '0.2.0'
7341
+ const VERSION = '0.2.4'
7280
7342
  const ROUTE_PREFIX = '/dsh-declutter'
7281
7343
  // Same cadence the sibling plugins use for transcript polling.
7282
7344
  const REFRESH_INTERVAL_MS = 3000
7345
+ const REFRESH_MAX_MS = 30000
7346
+ const STATE_TIMEOUT_MS = 15000
7283
7347
  // How often the view side is allowed to tell the host about its anchors.
7284
7348
  const REPORT_INTERVAL_MS = 2000
7285
7349
 
@@ -7306,6 +7370,7 @@ window.__ModuleLoader__.load({
7306
7370
  // manage `data-dshdc-*`, so the collapsed state survives every re-render.
7307
7371
 
7308
7372
  const CSS = [
7373
+ '[class*="_panelUnpin"]{display:none!important}',
7309
7374
  '[data-dshdc-collapsed="1"] > *:not([data-dshdc-toggle]){display:none!important}',
7310
7375
  '.dshdc-toggle{grid-column:1/-1;display:inline-flex;align-items:center;gap:6px;padding:2px 0;border:0;background:transparent;color:var(--dsw-alias-label-tertiary,#8a8f98);font:inherit;font-size:var(--dsh-content-font-size-secondary,13px);line-height:calc(20px + var(--dsh-content-font-delta-secondary,0px));cursor:pointer;text-align:left}',
7311
7376
  '.dshdc-toggle:hover{color:var(--dsw-alias-label-secondary,#61666d)}',
@@ -7567,13 +7632,30 @@ window.__ModuleLoader__.load({
7567
7632
  this.lastReportKey = ''
7568
7633
  this.observer = null
7569
7634
  this.timer = null
7635
+ this.inFlight = false
7636
+ this.nextDelay = REFRESH_INTERVAL_MS
7570
7637
  }
7571
7638
 
7572
7639
  async load() {
7573
- const response = await fetch(ROUTE_PREFIX + '/state?sessionId=' + encodeURIComponent(this.sessionId), {
7574
- credentials: 'same-origin',
7575
- headers: { accept: 'application/json' },
7576
- })
7640
+ // One rebuild at a time: a slow /state used to pile up, one request per
7641
+ // poll, which is what starved the host on a large transcript.
7642
+ if (this.inFlight === true) return
7643
+ this.inFlight = true
7644
+ const controller = typeof AbortController === 'function' ? new AbortController() : null
7645
+ const abortTimer = controller === null
7646
+ ? null
7647
+ : window.setTimeout(() => controller.abort(), STATE_TIMEOUT_MS)
7648
+ let response
7649
+ try {
7650
+ response = await fetch(ROUTE_PREFIX + '/state?sessionId=' + encodeURIComponent(this.sessionId), {
7651
+ credentials: 'same-origin',
7652
+ headers: { accept: 'application/json' },
7653
+ signal: controller === null ? undefined : controller.signal,
7654
+ })
7655
+ } finally {
7656
+ if (abortTimer !== null) window.clearTimeout(abortTimer)
7657
+ this.inFlight = false
7658
+ }
7577
7659
  // 400 means the route is mounted but this request was rejected; 404 means
7578
7660
  // the plugin is not installed at all. Both leave the view untouched.
7579
7661
  if (!response.ok) throw new Error('state ' + response.status)
@@ -7640,11 +7722,22 @@ window.__ModuleLoader__.load({
7640
7722
  })
7641
7723
  }
7642
7724
  kick()
7643
- this.timer = window.setInterval(() => {
7725
+ const tick = () => {
7726
+ if (this.detached) return
7644
7727
  // Polling an off-screen tab is pure cost; resume on the next visible tick.
7645
- if (typeof document !== 'undefined' && document.hidden === true) return
7728
+ if (typeof document !== 'undefined' && document.hidden === true) {
7729
+ this.timer = window.setTimeout(tick, REFRESH_INTERVAL_MS)
7730
+ return
7731
+ }
7732
+ const startedAt = Date.now()
7646
7733
  kick()
7647
- }, REFRESH_INTERVAL_MS)
7734
+ // Back off when a rebuild is slow, never past the ceiling, and drop back
7735
+ // to the base interval as soon as it is fast again.
7736
+ const elapsed = Date.now() - startedAt
7737
+ this.nextDelay = Math.min(Math.max(REFRESH_INTERVAL_MS, elapsed * 4), REFRESH_MAX_MS)
7738
+ this.timer = window.setTimeout(tick, this.nextDelay)
7739
+ }
7740
+ this.timer = window.setTimeout(tick, REFRESH_INTERVAL_MS)
7648
7741
 
7649
7742
  // The trajectory view is a virtual list: it discards rows and creates new
7650
7743
  // ones as the user scrolls, so a marker placed once is gone almost
@@ -7694,6 +7787,8 @@ window.__ModuleLoader__.load({
7694
7787
  // sidebar/DOM layer: stylesheet rules, panel stamping and ordering, session-
7695
7788
  // menu hiding, the settings page and its entry in the panel list. It keeps
7696
7789
  // its own storage keys so switches made before the merge survive.
7790
+ let sidebarSettingsCard = null
7791
+
7697
7792
  function mountSidebar(ctx) {
7698
7793
  const React = require('react')
7699
7794
  const h = React.createElement
@@ -7709,6 +7804,7 @@ window.__ModuleLoader__.load({
7709
7804
  const PANEL_ENTRY_LABEL = '隐藏与整理'
7710
7805
  /** Panel id: the URL segment (#/panel/<id>) and the main slot key. */
7711
7806
  const PANEL_ENTRY_ID = 'hide-rows'
7807
+ const PANEL_ENTRY_ENABLED = false
7712
7808
  /** The sidebar draws the row; this slot contributes the icon in front of it. */
7713
7809
  function PanelEntry() {
7714
7810
  return h(
@@ -9305,7 +9401,7 @@ window.__ModuleLoader__.load({
9305
9401
  // carries the icon and label, and the main slot with the same key is the
9306
9402
  // page the shell routes #/panel/<id> to. Without the second registration
9307
9403
  // the click falls back to whatever panel was open before.
9308
- if (ctx.slots && typeof ctx.slots.inject === 'function') {
9404
+ if (PANEL_ENTRY_ENABLED && ctx.slots && typeof ctx.slots.inject === 'function') {
9309
9405
  ctx.effect(() =>
9310
9406
  ctx.slots.inject('sidebar.panellist', () =>
9311
9407
  ctx.slots.register(
@@ -9353,6 +9449,7 @@ window.__ModuleLoader__.load({
9353
9449
  }
9354
9450
 
9355
9451
  sidebarApply(ctx)
9452
+ sidebarSettingsCard = SettingsCard
9356
9453
  }
9357
9454
  // ==== end sidebar half ===================================================
9358
9455
 
@@ -9401,6 +9498,7 @@ window.__ModuleLoader__.load({
9401
9498
  exports.apply = apply
9402
9499
  exports.inject = ['slots', 'locale']
9403
9500
  exports.version = VERSION
9501
+ exports.__settings = { get SettingsCard() { return sidebarSettingsCard } }
9404
9502
  // Exported for the view-side unit tests, which run this file against a
9405
9503
  // minimal DOM stub instead of a browser.
9406
9504
  exports.__test = { sweep, sweepInjectedNodes, adoptNode, readTurn, wantedTurns, surfaceMounted, DeclutterController, NS, VERSION }
@@ -9423,7 +9521,7 @@ window.__ModuleLoader__.load({
9423
9521
  const NS = 'dsh-better-sidebar-left'
9424
9522
 
9425
9523
  /** Keep in sync with package.json and src/components.js. */
9426
- const PLUGIN_VERSION = '0.1.6'
9524
+ const PLUGIN_VERSION = '0.2.4'
9427
9525
 
9428
9526
  /** Presence marker the live verifier reads. */
9429
9527
  const DEBUG_KEY = '__DSH_BETTER_SIDEBAR_LEFT__'
@@ -9452,7 +9550,6 @@ window.__ModuleLoader__.load({
9452
9550
  * The other four keep their card only when installed standalone;
9453
9551
  * docs/INTEROP.md section 6 says what a component has to export to appear here.
9454
9552
  */
9455
- const CONFIG_CARDS = [{ id: 'dsh-session-relocate', path: ['__settings', 'ChildrenSetting'] }]
9456
9553
 
9457
9554
  /**
9458
9555
  * The cordis services this bundle's apply() needs, as the UNION of what every
@@ -9499,7 +9596,22 @@ window.__ModuleLoader__.load({
9499
9596
  settingsNone: '这个组件没有把设置卡导出给本页;单独安装时它落在自己的插件行上。',
9500
9597
  loading: '读取状态…',
9501
9598
  failed: '状态加载失败,稍后重试。',
9599
+ loading: '读取状态…',
9600
+ failed: '状态加载失败,稍后重试。',
9502
9601
  retry: '重试',
9602
+ panelEntry: '左栏管理',
9603
+ panelHeading: '左栏管理',
9604
+ panelLead: '这个包在左侧栏做的五件事,以及它们此刻是否真的在运行。',
9605
+ panelFoot: '开关在「插件 → dsh-better-sidebar-left」里;这里只看状态。',
9606
+ panelTabTidy: '收纳与整理',
9607
+ panelTabDelete: '删除会话',
9608
+ panelTabMove: '移动会话',
9609
+ panelState: '运行状态',
9610
+ panelVersion: '版本',
9611
+ panelPackage: '包名',
9612
+ panelWhat: '它做什么',
9613
+ panelNoSettings: '这个组件的设置项挂在它自己的插件行上,本包拿不到;要去改,请在「插件」页里点它自己那一行。',
9614
+ panelBack: '返回概览',
9503
9615
  }
9504
9616
 
9505
9617
  const en = {
@@ -9530,6 +9642,19 @@ window.__ModuleLoader__.load({
9530
9642
  loading: 'Reading state…',
9531
9643
  failed: 'Could not read the state. Try again in a moment.',
9532
9644
  retry: 'Retry',
9645
+ panelEntry: 'Left rail',
9646
+ panelHeading: 'Left rail',
9647
+ panelLead: 'The five things this package does in the left rail, and whether each one is really running right now.',
9648
+ panelFoot: 'Switches live under Plugins → dsh-better-sidebar-left; this page only reports state.',
9649
+ panelTabTidy: 'Tidy up',
9650
+ panelTabDelete: 'Delete a session',
9651
+ panelTabMove: 'Move a session',
9652
+ panelState: 'State',
9653
+ panelVersion: 'Version',
9654
+ panelPackage: 'Package',
9655
+ panelWhat: 'What it does',
9656
+ panelNoSettings: 'This component keeps its settings on its own plugin row, which this package cannot reach; open it from the Plugins page.',
9657
+ panelBack: 'Back to overview',
9533
9658
  }
9534
9659
 
9535
9660
  /** The component table, generated by tools/build.mjs from src/components.js. */
@@ -9738,26 +9863,39 @@ window.__ModuleLoader__.load({
9738
9863
  },
9739
9864
  {
9740
9865
  "component": "dsh-declutter",
9741
- "name": "sidebar.panellist",
9742
- "id": "hide-rows",
9743
- "order": 20
9744
- },
9866
+ "name": "plugins.row.config",
9867
+ "key": "dsh-declutter#dsh-declutter"
9868
+ }
9869
+ ],
9870
+ "settingsCards": [
9745
9871
  {
9746
9872
  "component": "dsh-declutter",
9747
- "name": "main",
9748
- "key": "hide-rows"
9873
+ "exportPath": "__settings.SettingsCard"
9749
9874
  },
9750
9875
  {
9751
- "component": "dsh-declutter",
9752
- "name": "plugins.row.config",
9753
- "key": "dsh-declutter#dsh-declutter"
9876
+ "component": "dsh-delete-session",
9877
+ "exportPath": "__settings.SettingsCard"
9878
+ },
9879
+ {
9880
+ "component": "dsh-session-relocate",
9881
+ "exportPath": "__settings.ChildrenSetting"
9754
9882
  }
9755
9883
  ]
9756
9884
  }
9757
9885
 
9886
+ const CONFIG_CARDS = INTEROP.settingsCards.map((card) => ({ id: card.component, path: card.exportPath.split('.') }))
9887
+
9758
9888
  // --- styles ----------------------------------------------------------------
9759
9889
 
9760
9890
  const STYLE = [
9891
+ '.dbsl-page{height:100%;min-height:0;overflow-y:auto;box-sizing:border-box;padding:14px 24px 24px 46px}',
9892
+ '.dbsl-h1{font-size:15px;font-weight:600;margin:0 0 6px}',
9893
+ '.dbsl-tabs{display:flex;align-items:center;gap:4px;flex-wrap:wrap;border-bottom:1px solid var(--dsw-alias-border-l2);padding-bottom:0;margin:2px 0 12px}',
9894
+ '.dbsl-tab{font:inherit;font-size:13px;color:var(--dsw-alias-label-secondary);background:transparent;border:0;border-bottom:2px solid transparent;padding:6px 10px;margin-bottom:-1px;cursor:pointer;border-radius:6px 6px 0 0}',
9895
+ '.dbsl-tab:hover{color:var(--dsw-alias-label-primary)}',
9896
+ '.dbsl-tabOn{color:var(--dsw-alias-label-primary);font-weight:600;border-bottom-color:var(--dsw-alias-brand-primary)}',
9897
+ '.dbsl-note{color:var(--dsw-alias-label-tertiary);font-size:12px;margin:0}',
9898
+ '.dbsl-panel{max-width:760px;display:flex;flex-direction:column;gap:10px}',
9761
9899
  '.dbsl-wrap{display:flex;flex-direction:column;gap:10px;font-size:13px;line-height:1.5}',
9762
9900
  '.dbsl-lead{color:var(--dsw-alias-label-secondary);margin:0}',
9763
9901
  '.dbsl-count{font-weight:600;margin:0}',
@@ -9817,6 +9955,8 @@ window.__ModuleLoader__.load({
9817
9955
  * click does nothing" failure this package exists to prevent: the page shows
9818
9956
  * the failure and the marker carries it.
9819
9957
  */
9958
+ const appliedModules = {}
9959
+
9820
9960
  function applyVendored(ctx, id) {
9821
9961
  try {
9822
9962
  const plugin = vendoredModule(id)
@@ -9824,6 +9964,7 @@ window.__ModuleLoader__.load({
9824
9964
  console.error('[' + NS + '] vendored ' + id + ' has no apply()', plugin)
9825
9965
  return { ok: false, error: 'no apply()' }
9826
9966
  }
9967
+ appliedModules[id] = plugin
9827
9968
  const result = plugin.apply(ctx)
9828
9969
  // A component whose apply() is async must not be able to fail silently.
9829
9970
  if (result !== null && typeof result === 'object' && typeof result.then === 'function') {
@@ -9859,7 +10000,7 @@ window.__ModuleLoader__.load({
9859
10000
  const entry = CONFIG_CARDS.filter((candidate) => candidate.id === id)[0]
9860
10001
  if (entry === undefined) return null
9861
10002
  try {
9862
- const plugin = vendoredModule(id)
10003
+ const plugin = appliedModules[id] !== undefined ? appliedModules[id] : vendoredModule(id)
9863
10004
  if (plugin === null || plugin === undefined) return null
9864
10005
  let value = plugin
9865
10006
  for (let index = 0; index < entry.path.length; index += 1) {
@@ -9981,7 +10122,7 @@ window.__ModuleLoader__.load({
9981
10122
  return typeof value === 'string' ? value : String(value)
9982
10123
  }
9983
10124
 
9984
- function renderRow(component, copy, t, locale) {
10125
+ function renderRow(component, copy, t, locale, options) {
9985
10126
  const state = stateOf(component)
9986
10127
  const badgeClass =
9987
10128
  state === 'mounted' ? 'dbsl-badge dbsl-badgeOk' : state === 'installed' ? 'dbsl-badge dbsl-badgeOff' : 'dbsl-badge dbsl-badgeNone'
@@ -10000,7 +10141,8 @@ window.__ModuleLoader__.load({
10000
10141
  if (why !== null) children.push(h('p', { className: 'dbsl-why', key: 'why' }, why))
10001
10142
  const failure = failures[component.id]
10002
10143
  if (failure !== undefined) children.push(h('p', { className: 'dsss-warn', key: 'failure' }, t('applyFailed') + ' ' + failure))
10003
- if (component.versionMatch === false) {
10144
+ const skipMismatch = options !== undefined && options !== null && options.skipMismatch === true
10145
+ if (component.versionMatch === false && !skipMismatch) {
10004
10146
  children.push(h('p', { className: 'dbsl-warn', key: 'mismatch' }, t('versionMismatch') + ' ' + String(component.installedVersion)))
10005
10147
  }
10006
10148
  return h('div', { className: 'dbsl-row', key: component.id }, children)
@@ -10020,6 +10162,84 @@ window.__ModuleLoader__.load({
10020
10162
  ])
10021
10163
  }
10022
10164
 
10165
+ // --- the left rail entry ----------------------------------------------------
10166
+
10167
+
10168
+ function LeftRailIcon(props) {
10169
+ const size = props !== null && props !== undefined && Number(props.size) > 0 ? Number(props.size) : 18
10170
+ return h(
10171
+ 'svg',
10172
+ { width: size, height: size, viewBox: '0 0 24 24', fill: 'none', 'aria-hidden': 'true' },
10173
+ h('rect', { x: 3.2, y: 4.2, width: 17.6, height: 15.6, rx: 3, stroke: 'currentColor', strokeWidth: 1.6 }),
10174
+ h('path', { d: 'M9 4.6v14.8', stroke: 'currentColor', strokeWidth: 1.6 }),
10175
+ h('path', { d: 'M12 9h5.4M12 12.4h5.4M12 15.4h3.4', stroke: 'currentColor', strokeWidth: 1.6, strokeLinecap: 'round' }),
10176
+ )
10177
+ }
10178
+
10179
+ let railTranslate = null
10180
+
10181
+ function railText(key) {
10182
+ if (railTranslate !== null) {
10183
+ const value = railTranslate(key)
10184
+ if (value !== null && value !== undefined && value !== '') return String(value)
10185
+ }
10186
+ return copyFor(zh, key) || key
10187
+ }
10188
+
10189
+ function railLabel() {
10190
+ return railText('panelEntry')
10191
+ }
10192
+
10193
+ const RAIL_TABS = [
10194
+ { id: 'dsh-declutter', labelKey: 'panelTabTidy' },
10195
+ { id: 'dsh-delete-session', labelKey: 'panelTabDelete' },
10196
+ { id: 'dsh-session-relocate', labelKey: 'panelTabMove' },
10197
+ ]
10198
+
10199
+ function availableTabs() {
10200
+ return RAIL_TABS.filter((tab) => vendoredConfigCard(tab.id) !== null)
10201
+ }
10202
+
10203
+ function railTabs(active, select) {
10204
+ const buttons = []
10205
+ const tabs = availableTabs()
10206
+ for (const tab of tabs) {
10207
+ const on = tab.id === active
10208
+ buttons.push(
10209
+ h(
10210
+ 'button',
10211
+ {
10212
+ key: tab.id,
10213
+ type: 'button',
10214
+ role: 'tab',
10215
+ 'aria-selected': on ? 'true' : 'false',
10216
+ className: on ? 'dbsl-tab dbsl-tabOn' : 'dbsl-tab',
10217
+ onClick: () => select(tab.id),
10218
+ },
10219
+ railText(tab.labelKey),
10220
+ ),
10221
+ )
10222
+ }
10223
+ return buttons.length === 0 ? null : h('div', { className: 'dbsl-tabs', role: 'tablist' }, buttons)
10224
+ }
10225
+
10226
+ function railPageOf(id) {
10227
+ const Card = vendoredConfigCard(id)
10228
+ return Card === null ? [] : [h(Card, { key: 'card-' + id, view: 'full', t: railText })]
10229
+ }
10230
+
10231
+ function LeftRailPage() {
10232
+ const tabs = availableTabs()
10233
+ const [tab, setTab] = react.useState(tabs.length === 0 ? null : tabs[0].id)
10234
+ const locale = currentLocale()
10235
+ const body = [
10236
+ h('h2', { className: 'dbsl-h1', key: 'h1' }, railText('panelHeading')),
10237
+ railTabs(tab, setTab),
10238
+ ]
10239
+ for (const node of railPageOf(tab)) body.push(node)
10240
+ return h('div', { className: 'dbsl-page' }, h('div', { className: 'dbsl-panel' }, body))
10241
+ }
10242
+
10023
10243
  /** This plugin page. Set by apply() so the panel never reaches for a global. */
10024
10244
  let ownCtx = null
10025
10245
 
@@ -10105,6 +10325,14 @@ window.__ModuleLoader__.load({
10105
10325
  ctx.slots.register({ name: 'plugins.row.config', key: NS + '#' + NS, locale: NS }, SidebarPanel),
10106
10326
  )
10107
10327
 
10328
+ railTranslate = t
10329
+ ctx.slots.inject('sidebar.panellist', () =>
10330
+ ctx.slots.register({ name: 'sidebar.panellist', id: NS, order: 40, label: railLabel }, LeftRailIcon),
10331
+ )
10332
+ ctx.slots.inject('main', () =>
10333
+ ctx.slots.register({ name: 'main', key: NS }, LeftRailPage),
10334
+ )
10335
+
10108
10336
  ctx.effect(
10109
10337
  () => () => {
10110
10338
  delete globalThis[DEBUG_KEY]
@@ -10126,6 +10354,9 @@ window.__ModuleLoader__.load({
10126
10354
  exports.NS = NS
10127
10355
  exports.STATUS_ROUTE = STATUS_ROUTE
10128
10356
  exports.SidebarPanel = SidebarPanel
10357
+ exports.LeftRailPage = LeftRailPage
10358
+ exports.LeftRailIcon = LeftRailIcon
10359
+ exports.railLabel = railLabel
10129
10360
  exports.stateOf = stateOf
10130
10361
  exports.shouldMount = shouldMount
10131
10362
  exports.mountableComponents = mountableComponents
package/src/components.js CHANGED
@@ -24,7 +24,7 @@
24
24
  export const PLUGIN_ID = 'dsh-better-sidebar-left'
25
25
 
26
26
  /** Keep in sync with package.json and src/sidebar.js. */
27
- export const PLUGIN_VERSION = '0.1.6'
27
+ export const PLUGIN_VERSION = '0.2.4'
28
28
 
29
29
  /**
30
30
  * The five components, in the order the user meets them in the sidebar.
@@ -180,8 +180,6 @@ export const COMPONENTS = [
180
180
  slots: [
181
181
  { name: 'conversation.input.overlay', id: 'declutter', order: 90 },
182
182
  { name: 'sidebar.footer.action', id: 'sidebar-declutter-collapse', order: 10 },
183
- { name: 'sidebar.panellist', id: 'hide-rows', order: 20 },
184
- { name: 'main', key: 'hide-rows' },
185
183
  { name: 'plugins.row.config', key: 'dsh-declutter#dsh-declutter' },
186
184
  ],
187
185
  routes: ['GET /dsh-declutter/state', 'POST /dsh-declutter/report'],
@@ -237,12 +235,14 @@ export const INTEROP = {
237
235
  {
238
236
  component: 'dsh-declutter',
239
237
  conflictsWith: 'dsh-sidebar-declutter',
240
- slotIds: ['sidebar-declutter-collapse', 'hide-rows'],
238
+ slotIds: ['sidebar-declutter-collapse'],
241
239
  storageKeys: ['dsh-sidebar-declutter', 'dsh-hide-new-session', 'dsh-sidebar-declutter.menu'],
242
240
  resolution: 'disable the standalone dsh-sidebar-declutter bundle while this plugin is enabled',
243
241
  },
244
242
  ],
245
243
  settingsCards: [
244
+ { component: 'dsh-declutter', exportPath: '__settings.SettingsCard', label: { zh: '收纳与整理', en: 'Declutter' } },
245
+ { component: 'dsh-delete-session', exportPath: '__settings.SettingsCard', label: { zh: '删除会话', en: 'Delete a session' } },
246
246
  { component: 'dsh-session-relocate', exportPath: '__settings.ChildrenSetting', label: { zh: '连同子对话', en: 'Include child conversations' } },
247
247
  ],
248
248
  /** This plugin's own registrations: one row config seat, nothing else. */
@@ -1,6 +1,6 @@
1
1
  // dsh-declutter host half (dsh-declutter.js), VENDORED by tools/vendor.mjs - DO NOT EDIT.
2
2
  //
3
- // Source: ../dsh-better-sidebar-left-src/components/dsh-declutter/src/index.js (v0.2.0, sha256 068db8747c003ce5)
3
+ // Source: ../dsh-better-sidebar-left-src/components/dsh-declutter/src/index.js (v0.2.4, sha256 52a9cea8ada7fc81)
4
4
  // Regenerate with npm run vendor; test/sync.test.js fails when this is stale.
5
5
  //
6
6
  // src/shell.js mounts the copy named after the component, which is why this
@@ -175,6 +175,62 @@ function createReportStore() {
175
175
  }
176
176
  }
177
177
 
178
+ // --- state cache ------------------------------------------------------------
179
+
180
+ /**
181
+ * Coalesce /state rebuilds.
182
+ *
183
+ * Building the payload reads the whole session log (sessionQuery.readSession deep
184
+ * freezes every event), so the cost grows with the transcript: a 15MB log takes
185
+ * seconds and hundreds of megabytes. The browser half polls every three seconds,
186
+ * so a single heavy session used to start a fresh rebuild per poll and starve the
187
+ * host (2026-11-23: 234 sockets, 2.4GB RSS, every request timed out).
188
+ *
189
+ * Two guards, both cheap: requests for one session share a single rebuild, and a
190
+ * payload computed moments ago is handed back as-is.
191
+ */
192
+ const STATE_TTL_MS = 1500
193
+ const STATE_CACHE_CAPACITY = 8
194
+
195
+ function createStateCache() {
196
+ const cache = new Map()
197
+ const inflight = new Map()
198
+ return {
199
+ /**
200
+ * @param sessionId - normalized session id.
201
+ * @param build - async producer of the /state body, without the outer ok.
202
+ * @returns the body, fresh or shared.
203
+ */
204
+ async get(sessionId, build) {
205
+ const hit = cache.get(sessionId)
206
+ if (hit !== undefined && Date.now() - hit.at < STATE_TTL_MS) return hit.body
207
+ const pending = inflight.get(sessionId)
208
+ if (pending !== undefined) return pending
209
+ const job = (async () => {
210
+ const body = await build()
211
+ cache.delete(sessionId)
212
+ cache.set(sessionId, { at: Date.now(), body })
213
+ while (cache.size > STATE_CACHE_CAPACITY) {
214
+ const oldest = cache.keys().next()
215
+ if (oldest.done) break
216
+ cache.delete(oldest.value)
217
+ }
218
+ return body
219
+ })()
220
+ inflight.set(sessionId, job)
221
+ try {
222
+ return await job
223
+ } finally {
224
+ inflight.delete(sessionId)
225
+ }
226
+ },
227
+ /** Drop one session: a new view-side report changes the verdicts. */
228
+ invalidate(sessionId) {
229
+ cache.delete(sessionId)
230
+ },
231
+ }
232
+ }
233
+
178
234
  // --- state -------------------------------------------------------------------
179
235
 
180
236
  /**
@@ -335,6 +391,7 @@ function failure(res, error) {
335
391
  export function apply(ctx, config = {}) {
336
392
  const resolved = resolveConfig(config)
337
393
  const reports = createReportStore()
394
+ const stateCache = createStateCache()
338
395
 
339
396
  const registerRoutes = (webServer, fiber) => {
340
397
  fiber.effect(() =>
@@ -349,7 +406,8 @@ export function apply(ctx, config = {}) {
349
406
  }
350
407
  try {
351
408
  const sessionId = requireSessionId(sessionIdFromQuery(req.url))
352
- sendJson(res, 200, { ok: true, ...(await stateOf(ctx, sessionId, reports, resolved)) })
409
+ const body = await stateCache.get(sessionId, () => stateOf(ctx, sessionId, reports, resolved))
410
+ sendJson(res, 200, { ok: true, ...body })
353
411
  } catch (error) {
354
412
  failure(res, error)
355
413
  }
@@ -378,6 +436,8 @@ export function apply(ctx, config = {}) {
378
436
  try {
379
437
  const sessionId = requireSessionId(typeof body.sessionId === 'string' ? body.sessionId.trim() : '')
380
438
  const stored = reports.put(sessionId, body)
439
+ // The verdicts just changed, so the cached payload is stale.
440
+ stateCache.invalidate(sessionId)
381
441
  sendJson(res, 200, { ok: true, ...stored })
382
442
  } catch (error) {
383
443
  failure(res, error)
@@ -1,6 +1,6 @@
1
1
  // dsh-declutter host half (dsh-declutter.logic.js), VENDORED by tools/vendor.mjs - DO NOT EDIT.
2
2
  //
3
- // Source: ../dsh-better-sidebar-left-src/components/dsh-declutter/a sibling module (v0.2.0, sha256 8fb9fbd346230656)
3
+ // Source: ../dsh-better-sidebar-left-src/components/dsh-declutter/a sibling module (v0.2.4, sha256 bd9cb9c4c4096086)
4
4
  // Regenerate with npm run vendor; test/sync.test.js fails when this is stale.
5
5
  //
6
6
  // src/shell.js mounts the copy named after the component, which is why this
@@ -51,7 +51,7 @@
51
51
  export const PLUGIN_ID = 'dsh-declutter'
52
52
 
53
53
  /** Version, kept identical to package.json and src/client.js. */
54
- export const VERSION = '0.2.0'
54
+ export const VERSION = '0.2.4'
55
55
 
56
56
  /** View namespace. Every injected attribute/element this plugin owns is prefixed with it. */
57
57
  export const NS = 'dshdc'
@@ -1,6 +1,6 @@
1
1
  // dsh-delete-session host half (dsh-delete-session.js), VENDORED by tools/vendor.mjs - DO NOT EDIT.
2
2
  //
3
- // Source: ../dsh-better-sidebar-left-src/components/dsh-delete-session/src/index.js (v0.5.0, sha256 c7a9942cc816b3f6)
3
+ // Source: ../dsh-better-sidebar-left-src/components/dsh-delete-session/src/index.js (v0.5.1, sha256 c7a9942cc816b3f6)
4
4
  // Regenerate with npm run vendor; test/sync.test.js fails when this is stale.
5
5
  //
6
6
  // src/shell.js mounts the copy named after the component, which is why this
@@ -1,6 +1,6 @@
1
1
  // dsh-session-rename-dblclick host half (dsh-session-rename-dblclick.js), VENDORED by tools/vendor.mjs - DO NOT EDIT.
2
2
  //
3
- // Source: ../dsh-better-sidebar-left-src/components/dsh-session-rename-dblclick/index.js (v0.2.0, sha256 9a1263e486e37b58)
3
+ // Source: ../dsh-better-sidebar-left-src/components/dsh-session-rename-dblclick/index.js (v0.3.0, sha256 9a1263e486e37b58)
4
4
  // Regenerate with npm run vendor; test/sync.test.js fails when this is stale.
5
5
  //
6
6
  // src/shell.js mounts the copy named after the component, which is why this
@@ -1,7 +1,7 @@
1
1
  {
2
- "dsh-delete-session": "0.5.0",
2
+ "dsh-delete-session": "0.5.1",
3
3
  "dsh-session-relocate": "0.3.1",
4
- "dsh-session-rename-dblclick": "0.2.0",
4
+ "dsh-session-rename-dblclick": "0.3.0",
5
5
  "dsh-session-counts": "0.0.3",
6
- "dsh-declutter": "0.2.0"
6
+ "dsh-declutter": "0.2.4"
7
7
  }