dsh-better-sidebar-left 0.2.0 → 0.3.0

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/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.3.0'
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'],
@@ -191,6 +189,23 @@ export const COMPONENTS = [
191
189
  prefixes: ['data-dshdc-rule', 'data-dshdc-turn', 'data-dshdc-toggle', 'data-dshdc-badge', 'data-dshdc-collapsed', 'data-dsh-sidebar-declutter'],
192
190
  },
193
191
  },
192
+ {
193
+ id: 'dsh-settings-launcher',
194
+ package: 'dsh-settings-launcher',
195
+ suffix: 'launcher',
196
+ feature: 'launcher',
197
+ kind: 'maintenance',
198
+ repo: 'https://github.com/DDDMUC/dsh-settings-launcher',
199
+ title: { zh: '账号入口', en: 'Account entry' },
200
+ pitch: {
201
+ zh: '侧栏账号入口的两个独立开关:悬浮自动展开原版菜单、点击直达设置;两个都关就是官方原样。',
202
+ en: 'Two independent switches for the sidebar account entry: auto-expand the stock menu on hover, and go straight to Settings on click. Both off is the stock behaviour.',
203
+ },
204
+ slots: [{ name: 'plugins.row.config', key: 'dsh-settings-launcher#settings-launcher' }],
205
+ routes: [],
206
+ hostInject: [],
207
+ dom: { allocated: 'dsd', prefixes: ['data-dsd-style', 'data-dsd-cards', 'dsd-'] },
208
+ },
194
209
  ]
195
210
 
196
211
  /** Component ids, in manifest order. */
@@ -237,13 +252,16 @@ export const INTEROP = {
237
252
  {
238
253
  component: 'dsh-declutter',
239
254
  conflictsWith: 'dsh-sidebar-declutter',
240
- slotIds: ['sidebar-declutter-collapse', 'hide-rows'],
255
+ slotIds: ['sidebar-declutter-collapse'],
241
256
  storageKeys: ['dsh-sidebar-declutter', 'dsh-hide-new-session', 'dsh-sidebar-declutter.menu'],
242
257
  resolution: 'disable the standalone dsh-sidebar-declutter bundle while this plugin is enabled',
243
258
  },
244
259
  ],
245
260
  settingsCards: [
261
+ { component: 'dsh-declutter', exportPath: '__settings.SettingsCard', label: { zh: '收纳与整理', en: 'Declutter' } },
262
+ { component: 'dsh-delete-session', exportPath: '__settings.SettingsCard', label: { zh: '删除会话', en: 'Delete a session' } },
246
263
  { component: 'dsh-session-relocate', exportPath: '__settings.ChildrenSetting', label: { zh: '连同子对话', en: 'Include child conversations' } },
264
+ { component: 'dsh-settings-launcher', exportPath: '__settings.SwitchCard', label: { zh: '账号入口', en: 'Account entry' } },
247
265
  ],
248
266
  /** This plugin's own registrations: one row config seat, nothing else. */
249
267
  pluginSlots: [{ name: 'plugins.row.config', key: PLUGIN_ID + '#' + PLUGIN_ID }],
@@ -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.3, 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
@@ -0,0 +1,9 @@
1
+ // dsh-settings-launcher host half (dsh-settings-launcher.js), VENDORED by tools/vendor.mjs - DO NOT EDIT.
2
+ //
3
+ // Source: ../dsh-better-sidebar-left-src/components/dsh-settings-launcher/src/index.js (v0.0.2, sha256 5aeab291ba2a47d9)
4
+ // Regenerate with npm run vendor; test/sync.test.js fails when this is stale.
5
+ //
6
+ // src/shell.js mounts the copy named after the component, which is why this
7
+ // package installs with no runtime dependency on the component package.
8
+ /** Host half of the bundle; the Client module owns the UI. */
9
+ export function apply() {}
@@ -1,7 +1,8 @@
1
1
  {
2
- "dsh-delete-session": "0.5.0",
2
+ "dsh-delete-session": "0.5.3",
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
+ "dsh-settings-launcher": "0.0.2"
7
8
  }