dsh-better-sidebar-left 0.1.6 → 0.2.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/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.0",
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",
@@ -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",
package/src/client.js CHANGED
@@ -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 =====
@@ -9423,7 +9485,7 @@ window.__ModuleLoader__.load({
9423
9485
  const NS = 'dsh-better-sidebar-left'
9424
9486
 
9425
9487
  /** Keep in sync with package.json and src/components.js. */
9426
- const PLUGIN_VERSION = '0.1.6'
9488
+ const PLUGIN_VERSION = '0.2.0'
9427
9489
 
9428
9490
  /** Presence marker the live verifier reads. */
9429
9491
  const DEBUG_KEY = '__DSH_BETTER_SIDEBAR_LEFT__'
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.0'
28
28
 
29
29
  /**
30
30
  * The five components, in the order the user meets them in the sidebar.
@@ -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
2
  "dsh-delete-session": "0.5.0",
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
6
  "dsh-declutter": "0.2.0"
7
7
  }