dsh-better-sidebar-left 0.2.0 → 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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "dsh-better-sidebar-left",
3
- "version": "0.2.0",
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",
@@ -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 =====
@@ -7338,10 +7338,12 @@ window.__ModuleLoader__.load({
7338
7338
  const react = require('react')
7339
7339
 
7340
7340
  const NS = 'dsh-declutter'
7341
- const VERSION = '0.2.0'
7341
+ const VERSION = '0.2.4'
7342
7342
  const ROUTE_PREFIX = '/dsh-declutter'
7343
7343
  // Same cadence the sibling plugins use for transcript polling.
7344
7344
  const REFRESH_INTERVAL_MS = 3000
7345
+ const REFRESH_MAX_MS = 30000
7346
+ const STATE_TIMEOUT_MS = 15000
7345
7347
  // How often the view side is allowed to tell the host about its anchors.
7346
7348
  const REPORT_INTERVAL_MS = 2000
7347
7349
 
@@ -7368,6 +7370,7 @@ window.__ModuleLoader__.load({
7368
7370
  // manage `data-dshdc-*`, so the collapsed state survives every re-render.
7369
7371
 
7370
7372
  const CSS = [
7373
+ '[class*="_panelUnpin"]{display:none!important}',
7371
7374
  '[data-dshdc-collapsed="1"] > *:not([data-dshdc-toggle]){display:none!important}',
7372
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}',
7373
7376
  '.dshdc-toggle:hover{color:var(--dsw-alias-label-secondary,#61666d)}',
@@ -7629,13 +7632,30 @@ window.__ModuleLoader__.load({
7629
7632
  this.lastReportKey = ''
7630
7633
  this.observer = null
7631
7634
  this.timer = null
7635
+ this.inFlight = false
7636
+ this.nextDelay = REFRESH_INTERVAL_MS
7632
7637
  }
7633
7638
 
7634
7639
  async load() {
7635
- const response = await fetch(ROUTE_PREFIX + '/state?sessionId=' + encodeURIComponent(this.sessionId), {
7636
- credentials: 'same-origin',
7637
- headers: { accept: 'application/json' },
7638
- })
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
+ }
7639
7659
  // 400 means the route is mounted but this request was rejected; 404 means
7640
7660
  // the plugin is not installed at all. Both leave the view untouched.
7641
7661
  if (!response.ok) throw new Error('state ' + response.status)
@@ -7702,11 +7722,22 @@ window.__ModuleLoader__.load({
7702
7722
  })
7703
7723
  }
7704
7724
  kick()
7705
- this.timer = window.setInterval(() => {
7725
+ const tick = () => {
7726
+ if (this.detached) return
7706
7727
  // Polling an off-screen tab is pure cost; resume on the next visible tick.
7707
- 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()
7708
7733
  kick()
7709
- }, 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)
7710
7741
 
7711
7742
  // The trajectory view is a virtual list: it discards rows and creates new
7712
7743
  // ones as the user scrolls, so a marker placed once is gone almost
@@ -7756,6 +7787,8 @@ window.__ModuleLoader__.load({
7756
7787
  // sidebar/DOM layer: stylesheet rules, panel stamping and ordering, session-
7757
7788
  // menu hiding, the settings page and its entry in the panel list. It keeps
7758
7789
  // its own storage keys so switches made before the merge survive.
7790
+ let sidebarSettingsCard = null
7791
+
7759
7792
  function mountSidebar(ctx) {
7760
7793
  const React = require('react')
7761
7794
  const h = React.createElement
@@ -7771,6 +7804,7 @@ window.__ModuleLoader__.load({
7771
7804
  const PANEL_ENTRY_LABEL = '隐藏与整理'
7772
7805
  /** Panel id: the URL segment (#/panel/<id>) and the main slot key. */
7773
7806
  const PANEL_ENTRY_ID = 'hide-rows'
7807
+ const PANEL_ENTRY_ENABLED = false
7774
7808
  /** The sidebar draws the row; this slot contributes the icon in front of it. */
7775
7809
  function PanelEntry() {
7776
7810
  return h(
@@ -9367,7 +9401,7 @@ window.__ModuleLoader__.load({
9367
9401
  // carries the icon and label, and the main slot with the same key is the
9368
9402
  // page the shell routes #/panel/<id> to. Without the second registration
9369
9403
  // the click falls back to whatever panel was open before.
9370
- if (ctx.slots && typeof ctx.slots.inject === 'function') {
9404
+ if (PANEL_ENTRY_ENABLED && ctx.slots && typeof ctx.slots.inject === 'function') {
9371
9405
  ctx.effect(() =>
9372
9406
  ctx.slots.inject('sidebar.panellist', () =>
9373
9407
  ctx.slots.register(
@@ -9415,6 +9449,7 @@ window.__ModuleLoader__.load({
9415
9449
  }
9416
9450
 
9417
9451
  sidebarApply(ctx)
9452
+ sidebarSettingsCard = SettingsCard
9418
9453
  }
9419
9454
  // ==== end sidebar half ===================================================
9420
9455
 
@@ -9463,6 +9498,7 @@ window.__ModuleLoader__.load({
9463
9498
  exports.apply = apply
9464
9499
  exports.inject = ['slots', 'locale']
9465
9500
  exports.version = VERSION
9501
+ exports.__settings = { get SettingsCard() { return sidebarSettingsCard } }
9466
9502
  // Exported for the view-side unit tests, which run this file against a
9467
9503
  // minimal DOM stub instead of a browser.
9468
9504
  exports.__test = { sweep, sweepInjectedNodes, adoptNode, readTurn, wantedTurns, surfaceMounted, DeclutterController, NS, VERSION }
@@ -9485,7 +9521,7 @@ window.__ModuleLoader__.load({
9485
9521
  const NS = 'dsh-better-sidebar-left'
9486
9522
 
9487
9523
  /** Keep in sync with package.json and src/components.js. */
9488
- const PLUGIN_VERSION = '0.2.0'
9524
+ const PLUGIN_VERSION = '0.2.4'
9489
9525
 
9490
9526
  /** Presence marker the live verifier reads. */
9491
9527
  const DEBUG_KEY = '__DSH_BETTER_SIDEBAR_LEFT__'
@@ -9514,7 +9550,6 @@ window.__ModuleLoader__.load({
9514
9550
  * The other four keep their card only when installed standalone;
9515
9551
  * docs/INTEROP.md section 6 says what a component has to export to appear here.
9516
9552
  */
9517
- const CONFIG_CARDS = [{ id: 'dsh-session-relocate', path: ['__settings', 'ChildrenSetting'] }]
9518
9553
 
9519
9554
  /**
9520
9555
  * The cordis services this bundle's apply() needs, as the UNION of what every
@@ -9561,7 +9596,22 @@ window.__ModuleLoader__.load({
9561
9596
  settingsNone: '这个组件没有把设置卡导出给本页;单独安装时它落在自己的插件行上。',
9562
9597
  loading: '读取状态…',
9563
9598
  failed: '状态加载失败,稍后重试。',
9599
+ loading: '读取状态…',
9600
+ failed: '状态加载失败,稍后重试。',
9564
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: '返回概览',
9565
9615
  }
9566
9616
 
9567
9617
  const en = {
@@ -9592,6 +9642,19 @@ window.__ModuleLoader__.load({
9592
9642
  loading: 'Reading state…',
9593
9643
  failed: 'Could not read the state. Try again in a moment.',
9594
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',
9595
9658
  }
9596
9659
 
9597
9660
  /** The component table, generated by tools/build.mjs from src/components.js. */
@@ -9800,26 +9863,39 @@ window.__ModuleLoader__.load({
9800
9863
  },
9801
9864
  {
9802
9865
  "component": "dsh-declutter",
9803
- "name": "sidebar.panellist",
9804
- "id": "hide-rows",
9805
- "order": 20
9806
- },
9866
+ "name": "plugins.row.config",
9867
+ "key": "dsh-declutter#dsh-declutter"
9868
+ }
9869
+ ],
9870
+ "settingsCards": [
9807
9871
  {
9808
9872
  "component": "dsh-declutter",
9809
- "name": "main",
9810
- "key": "hide-rows"
9873
+ "exportPath": "__settings.SettingsCard"
9811
9874
  },
9812
9875
  {
9813
- "component": "dsh-declutter",
9814
- "name": "plugins.row.config",
9815
- "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"
9816
9882
  }
9817
9883
  ]
9818
9884
  }
9819
9885
 
9886
+ const CONFIG_CARDS = INTEROP.settingsCards.map((card) => ({ id: card.component, path: card.exportPath.split('.') }))
9887
+
9820
9888
  // --- styles ----------------------------------------------------------------
9821
9889
 
9822
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}',
9823
9899
  '.dbsl-wrap{display:flex;flex-direction:column;gap:10px;font-size:13px;line-height:1.5}',
9824
9900
  '.dbsl-lead{color:var(--dsw-alias-label-secondary);margin:0}',
9825
9901
  '.dbsl-count{font-weight:600;margin:0}',
@@ -9879,6 +9955,8 @@ window.__ModuleLoader__.load({
9879
9955
  * click does nothing" failure this package exists to prevent: the page shows
9880
9956
  * the failure and the marker carries it.
9881
9957
  */
9958
+ const appliedModules = {}
9959
+
9882
9960
  function applyVendored(ctx, id) {
9883
9961
  try {
9884
9962
  const plugin = vendoredModule(id)
@@ -9886,6 +9964,7 @@ window.__ModuleLoader__.load({
9886
9964
  console.error('[' + NS + '] vendored ' + id + ' has no apply()', plugin)
9887
9965
  return { ok: false, error: 'no apply()' }
9888
9966
  }
9967
+ appliedModules[id] = plugin
9889
9968
  const result = plugin.apply(ctx)
9890
9969
  // A component whose apply() is async must not be able to fail silently.
9891
9970
  if (result !== null && typeof result === 'object' && typeof result.then === 'function') {
@@ -9921,7 +10000,7 @@ window.__ModuleLoader__.load({
9921
10000
  const entry = CONFIG_CARDS.filter((candidate) => candidate.id === id)[0]
9922
10001
  if (entry === undefined) return null
9923
10002
  try {
9924
- const plugin = vendoredModule(id)
10003
+ const plugin = appliedModules[id] !== undefined ? appliedModules[id] : vendoredModule(id)
9925
10004
  if (plugin === null || plugin === undefined) return null
9926
10005
  let value = plugin
9927
10006
  for (let index = 0; index < entry.path.length; index += 1) {
@@ -10043,7 +10122,7 @@ window.__ModuleLoader__.load({
10043
10122
  return typeof value === 'string' ? value : String(value)
10044
10123
  }
10045
10124
 
10046
- function renderRow(component, copy, t, locale) {
10125
+ function renderRow(component, copy, t, locale, options) {
10047
10126
  const state = stateOf(component)
10048
10127
  const badgeClass =
10049
10128
  state === 'mounted' ? 'dbsl-badge dbsl-badgeOk' : state === 'installed' ? 'dbsl-badge dbsl-badgeOff' : 'dbsl-badge dbsl-badgeNone'
@@ -10062,7 +10141,8 @@ window.__ModuleLoader__.load({
10062
10141
  if (why !== null) children.push(h('p', { className: 'dbsl-why', key: 'why' }, why))
10063
10142
  const failure = failures[component.id]
10064
10143
  if (failure !== undefined) children.push(h('p', { className: 'dsss-warn', key: 'failure' }, t('applyFailed') + ' ' + failure))
10065
- if (component.versionMatch === false) {
10144
+ const skipMismatch = options !== undefined && options !== null && options.skipMismatch === true
10145
+ if (component.versionMatch === false && !skipMismatch) {
10066
10146
  children.push(h('p', { className: 'dbsl-warn', key: 'mismatch' }, t('versionMismatch') + ' ' + String(component.installedVersion)))
10067
10147
  }
10068
10148
  return h('div', { className: 'dbsl-row', key: component.id }, children)
@@ -10082,6 +10162,84 @@ window.__ModuleLoader__.load({
10082
10162
  ])
10083
10163
  }
10084
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
+
10085
10243
  /** This plugin page. Set by apply() so the panel never reaches for a global. */
10086
10244
  let ownCtx = null
10087
10245
 
@@ -10167,6 +10325,14 @@ window.__ModuleLoader__.load({
10167
10325
  ctx.slots.register({ name: 'plugins.row.config', key: NS + '#' + NS, locale: NS }, SidebarPanel),
10168
10326
  )
10169
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
+
10170
10336
  ctx.effect(
10171
10337
  () => () => {
10172
10338
  delete globalThis[DEBUG_KEY]
@@ -10188,6 +10354,9 @@ window.__ModuleLoader__.load({
10188
10354
  exports.NS = NS
10189
10355
  exports.STATUS_ROUTE = STATUS_ROUTE
10190
10356
  exports.SidebarPanel = SidebarPanel
10357
+ exports.LeftRailPage = LeftRailPage
10358
+ exports.LeftRailIcon = LeftRailIcon
10359
+ exports.railLabel = railLabel
10191
10360
  exports.stateOf = stateOf
10192
10361
  exports.shouldMount = shouldMount
10193
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.2.0'
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,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
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
  }