dsh-workspace-status 0.3.5 → 0.3.6

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
@@ -6,6 +6,16 @@ adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
6
6
 
7
7
  ## [Unreleased]
8
8
 
9
+ ## [0.3.6] - 2026-12-05
10
+
11
+ ### Added
12
+
13
+ - Forked conversations are marked in the sidebar: a branch glyph, a 14px
14
+ indent and a tooltip naming the parent, derived from the `parentId` the
15
+ session feed already carries. The marker is additive CSS plus a `title`
16
+ attribute on the row — row order, grouping and the shipped tree are
17
+ untouched, so a fork still sits where its timestamp puts it.
18
+
9
19
  ## [0.3.5] - 2026-12-05
10
20
 
11
21
  ### Added
package/client.js CHANGED
@@ -93,6 +93,11 @@ window.__ModuleLoader__.load({
93
93
  `.${SR_CLASS}{position:absolute;width:1px;height:1px;margin:-1px;padding:0;`,
94
94
  'overflow:hidden;clip:rect(0 0 0 0);clip-path:inset(50%);white-space:nowrap;border:0}',
95
95
  '.dsws-anchor{display:none!important}',
96
+ // A single branch glyph shared by every forked row; the mask keeps it
97
+ // theme-coloured through the row's own CSS variable.
98
+ ':root{--dsws-branch-icon:url("data:image/svg+xml,%3Csvg xmlns=\'http://www.w3.org/2000/svg\' ',
99
+ 'viewBox=\'0 0 16 16\' fill=\'none\' stroke=\'%23000\' stroke-width=\'1.5\' stroke-linecap=\'round\' ',
100
+ 'stroke-linejoin=\'round\'%3E%3Cpath d=\'M3.5 2.5v6a3 3 0 0 0 3 3h6\'/%3E%3Cpath d=\'M10 8.5l3 3-3 3\'/%3E%3C/svg%3E")}',
96
101
  ].join('')
97
102
 
98
103
  /**
@@ -110,6 +115,8 @@ window.__ModuleLoader__.load({
110
115
  'activity.unnamed': 'Ungrouped',
111
116
  'activity.more': 'and {n} more',
112
117
  'activity.listSeparator': ', ',
118
+ 'branch.from': 'Branched from {title}',
119
+ 'branch.fromUnknown': 'Branched from an earlier conversation',
113
120
  'pinned.title': 'Pinned',
114
121
  'pinned.untitled': 'Untitled',
115
122
  'pinned.unpin': 'Unpin',
@@ -157,6 +164,8 @@ window.__ModuleLoader__.load({
157
164
  'activity.unnamed': '未分组',
158
165
  'activity.more': '等 {n} 个',
159
166
  'activity.listSeparator': '、',
167
+ 'branch.from': '分支自 {title}',
168
+ 'branch.fromUnknown': '分支自更早的会话',
160
169
  'pinned.title': '已置顶',
161
170
  'pinned.untitled': '未命名',
162
171
  'pinned.unpin': '取消置顶',
@@ -768,6 +777,113 @@ window.__ModuleLoader__.load({
768
777
  return `${rows}{display:none!important}`
769
778
  }
770
779
 
780
+ /**
781
+ * Sessions that continue another conversation, keyed by session id.
782
+ *
783
+ * The shell keeps forks flat: the stored session records its parent and the
784
+ * sidebar summary carries it as `parentId`, but no shipped row reads the
785
+ * relation — the only hint is the "(n)" the fork action appends to the
786
+ * title. The marker gives such a row a branch glyph, an indent, and the
787
+ * parent's name in its tooltip.
788
+ *
789
+ * A self-parented row (a corrupt or hand-edited header) is ignored, and a
790
+ * parent that is no longer listed still marks the child, with a generic
791
+ * tooltip: the branch is real even when the parent was archived away.
792
+ * @param byId - session summaries from the sidebar feed.
793
+ * @returns one entry per forked session: its parent id and tooltip text.
794
+ */
795
+ function branchRows(byId) {
796
+ const rows = new Map()
797
+ if (byId === null || typeof byId !== 'object') return rows
798
+ for (const [id, row] of Object.entries(byId)) {
799
+ const parentId = row !== null && typeof row === 'object' && typeof row.parentId === 'string'
800
+ ? row.parentId
801
+ : ''
802
+ if (parentId === '' || parentId === id) continue
803
+ const parent = byId[parentId]
804
+ const parentTitle = parent !== null && typeof parent === 'object'
805
+ ? typeof parent.displayTitle === 'string' && parent.displayTitle !== ''
806
+ ? parent.displayTitle
807
+ : typeof parent.title === 'string' && parent.title !== ''
808
+ ? parent.title
809
+ : ''
810
+ : ''
811
+ rows.set(id, {
812
+ parentId,
813
+ tip: parentTitle === ''
814
+ ? message('branch.fromUnknown')
815
+ : message('branch.from', { title: parentTitle }),
816
+ })
817
+ }
818
+ return rows
819
+ }
820
+
821
+ /**
822
+ * Indent and glyph for the forked rows, one rule per row.
823
+ *
824
+ * The indent repeats the shell's own padding formula plus a step, so a row
825
+ * that already carries a workspace indent keeps it. The glyph is a masked
826
+ * background rather than a text node: it inherits the theme colour and
827
+ * cannot be selected or read out.
828
+ * @param branches - map from branchRows().
829
+ * @returns CSS text, or an empty string when nothing is forked.
830
+ */
831
+ function branchCss(branches) {
832
+ // Duck-typed rather than `instanceof Map`: the bundle is loaded in a
833
+ // separate realm, where a Map built by the shell is not this realm's Map.
834
+ if (branches === null || branches === undefined || typeof branches.keys !== 'function') return ''
835
+ if (typeof branches.size !== 'number' || branches.size === 0) return ''
836
+ const rules = []
837
+ for (const id of branches.keys()) {
838
+ const row = `[data-row-key="session:${quote(id)}"]`
839
+ rules.push(`${row}{padding-inline-start:calc(var(--dsh-sidebar-row-padding) - var(--dsh-sidebar-paint-inset) + var(--dsh-workspace-indent,0px) + 14px)}`)
840
+ rules.push(
841
+ `${row}::before{content:"";flex:none;width:12px;height:12px;margin-right:1px;`,
842
+ 'background-color:var(--dsw-alias-label-tertiary);',
843
+ '-webkit-mask:var(--dsws-branch-icon) center / 12px 12px no-repeat;',
844
+ 'mask:var(--dsws-branch-icon) center / 12px 12px no-repeat}',
845
+ )
846
+ }
847
+ return rules.join('')
848
+ }
849
+
850
+ /**
851
+ * Write the branch tooltip onto the shipped rows.
852
+ *
853
+ * CSS can indent and draw the glyph, but the parent's name only reaches a
854
+ * row through its `title` attribute, which the shell does not set on
855
+ * session rows. The marker attribute remembers that the tooltip is ours, so
856
+ * it is removed again once the session stops being a fork.
857
+ * @param doc - document that owns the sidebar.
858
+ * @param branches - map from branchRows().
859
+ */
860
+ function syncBranchTitles(doc, branches) {
861
+ if (doc === null || doc === undefined || typeof doc.querySelectorAll !== 'function') return
862
+ if (branches === null || branches === undefined || typeof branches.get !== 'function') return
863
+ let rows
864
+ try {
865
+ rows = doc.querySelectorAll('[data-row-key^="session:"]')
866
+ } catch {
867
+ return
868
+ }
869
+ for (const row of rows) {
870
+ const key = row.getAttribute('data-row-key') ?? ''
871
+ if (!key.startsWith('session:')) continue
872
+ const branch = branches.get(key.slice('session:'.length))
873
+ if (branch === undefined) {
874
+ if (row.getAttribute('data-dsws-branch-tip') !== null) {
875
+ row.removeAttribute('data-dsws-branch-tip')
876
+ row.removeAttribute('title')
877
+ }
878
+ continue
879
+ }
880
+ if (row.getAttribute('data-dsws-branch-tip') !== branch.tip) {
881
+ row.setAttribute('data-dsws-branch-tip', branch.tip)
882
+ row.setAttribute('title', branch.tip)
883
+ }
884
+ }
885
+ }
886
+
771
887
  /**
772
888
  * Static stylesheet for the pinned section. Geometry mirrors the shipped
773
889
  * sidebar: 34px workspace rows, 32px session rows, the same radii, gaps and
@@ -1794,6 +1910,23 @@ window.__ModuleLoader__.load({
1794
1910
  [items, byId, statuses, archived, watchRef],
1795
1911
  )
1796
1912
 
1913
+ const branches = React.useMemo(() => branchRows(byId), [byId])
1914
+
1915
+ // The glyph and indent are CSS; the parent's name has to be written onto
1916
+ // the shipped row, once at render and once after the list commits.
1917
+ React.useEffect(() => {
1918
+ if (typeof document === 'undefined') return undefined
1919
+ const apply = () => {
1920
+ syncBranchTitles(document, branches)
1921
+ }
1922
+ apply()
1923
+ if (typeof window === 'undefined' || typeof window.requestAnimationFrame !== 'function') return undefined
1924
+ const raf = window.requestAnimationFrame(apply)
1925
+ return () => {
1926
+ window.cancelAnimationFrame(raf)
1927
+ }
1928
+ }, [branches])
1929
+
1797
1930
  const pinnedModel = React.useMemo(
1798
1931
  () => buildPinnedView(pinned, items, byId, statuses, archived, Date.now()),
1799
1932
  [pinned, items, byId, statuses, archived],
@@ -1835,7 +1968,7 @@ window.__ModuleLoader__.load({
1835
1968
 
1836
1969
 
1837
1970
 
1838
- const cssText = BASE_CSS + PINNED_CSS + rowCss(activity)
1971
+ const cssText = BASE_CSS + PINNED_CSS + rowCss(activity) + branchCss(branches)
1839
1972
  + (portalHost === undefined ? '' : hideCss(pinnedModel.ids))
1840
1973
  const children = [h('style', { key: 'style', 'data-plugin-css': STYLE_ID }, cssText)]
1841
1974
 
@@ -1941,6 +2074,9 @@ window.__ModuleLoader__.load({
1941
2074
  relativeTime,
1942
2075
  buildPinnedView,
1943
2076
  hideCss,
2077
+ branchRows,
2078
+ branchCss,
2079
+ syncBranchTitles,
1944
2080
  sessionMark,
1945
2081
  sessionFacts,
1946
2082
  notificationEvents,
package/locale/en.json CHANGED
@@ -11,6 +11,8 @@
11
11
  "activity.unnamed": "Ungrouped",
12
12
  "activity.more": "and {n} more",
13
13
  "activity.listSeparator": ", ",
14
+ "branch.from": "Branched from {title}",
15
+ "branch.fromUnknown": "Branched from an earlier conversation",
14
16
  "pinned.title": "Pinned",
15
17
  "pinned.untitled": "Untitled",
16
18
  "pinned.unpin": "Unpin",
package/locale/zh.json CHANGED
@@ -11,6 +11,8 @@
11
11
  "activity.unnamed": "未分组",
12
12
  "activity.more": "等 {n} 个",
13
13
  "activity.listSeparator": "、",
14
+ "branch.from": "分支自 {title}",
15
+ "branch.fromUnknown": "分支自更早的会话",
14
16
  "pinned.title": "已置顶",
15
17
  "pinned.untitled": "未命名",
16
18
  "pinned.unpin": "取消置顶",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "dsh-workspace-status",
3
- "version": "0.3.5",
3
+ "version": "0.3.6",
4
4
  "description": "Workspace status marks, a pinned-conversation section and pinned-only notifications for the DeepSeek Harness sidebar.",
5
5
  "type": "module",
6
6
  "license": "MIT",