dsh-lmw-plugin 1.0.5 → 1.0.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.
Files changed (2) hide show
  1. package/client.js +22 -32
  2. package/package.json +1 -1
package/client.js CHANGED
@@ -26,6 +26,7 @@ window.__ModuleLoader__.load({
26
26
  const { useCallback, useEffect, useMemo, useRef, useState, useSyncExternalStore } = React
27
27
 
28
28
  const NS = 'lmw'
29
+ const CLIENT_VERSION = '1.0.6'
29
30
  const ROUTE = 'lmw-plugin'
30
31
 
31
32
  /* ------------------------------------------------------------------ */
@@ -1663,14 +1664,25 @@ window.__ModuleLoader__.load({
1663
1664
  }
1664
1665
  }
1665
1666
 
1666
- /** Always-mounted guard: mark Workspaces whose directory vanished and block them. */
1667
- function WorkspaceOfflineGuard(props) {
1668
- const tr = makeT(props.translate ?? props.t)
1669
- useEffect(() => {
1670
- document.body.setAttribute('data-lmw-guard', JSON.stringify({ mounted: true }))
1671
- let statuses = { workspaces: {}, sessions: {} }
1672
- let disposed = false
1673
- let timer = 0
1667
+ /** Offline styling owned by the guard itself, so it never depends on another entry. */
1668
+ const OFFLINE_CSS = [
1669
+ '[data-lmw-offline]{opacity:.45;filter:grayscale(1);cursor:not-allowed!important}',
1670
+ '[data-lmw-offline] *{cursor:not-allowed!important}',
1671
+ '[data-lmw-offline-composer]{opacity:.55;cursor:not-allowed!important}',
1672
+ ].join('\n')
1673
+
1674
+ /** Plugin-lifetime guard: mark Workspaces whose directory vanished and block them. */
1675
+ function startWorkspaceGuard(translate) {
1676
+ const tr = makeT(translate)
1677
+ document.body.setAttribute('data-lmw-guard', JSON.stringify({ mounted: true }))
1678
+ document.documentElement.setAttribute('data-lmw-version', CLIENT_VERSION)
1679
+ const style = document.createElement('style')
1680
+ style.setAttribute('data-lmw-offline-style', '')
1681
+ style.textContent = OFFLINE_CSS
1682
+ document.head.appendChild(style)
1683
+ let statuses = { workspaces: {}, sessions: {} }
1684
+ let disposed = false
1685
+ let timer = 0
1674
1686
 
1675
1687
  const mark = () => {
1676
1688
  try {
@@ -1775,26 +1787,11 @@ window.__ModuleLoader__.load({
1775
1787
  document.addEventListener('keydown', blockRow, true)
1776
1788
  for (const type of ['keydown', 'beforeinput', 'paste', 'drop']) document.addEventListener(type, blockInput, true)
1777
1789
  const interval = window.setInterval(() => { void load() }, 20000)
1778
- // Mark first: a broken optional subscription must never keep the guard
1779
- // from running at all.
1780
1790
  void load()
1781
- let unsubscribe = () => {}
1782
- try {
1783
- const list = workspaces?.list
1784
- if (list !== undefined && typeof list.subscribe === 'function') {
1785
- unsubscribe = list.subscribe(() => {
1786
- schedule()
1787
- void load()
1788
- }) ?? (() => {})
1789
- }
1790
- } catch (error) {
1791
- console.error('[lmw-plugin] workspace list subscription failed:', error)
1792
- }
1793
1791
 
1794
1792
  return () => {
1795
1793
  disposed = true
1796
1794
  observer.disconnect()
1797
- unsubscribe()
1798
1795
  window.clearInterval(interval)
1799
1796
  document.removeEventListener('click', blockRow, true)
1800
1797
  document.removeEventListener('keydown', blockRow, true)
@@ -1804,9 +1801,8 @@ window.__ModuleLoader__.load({
1804
1801
  row.removeAttribute('data-lmw-offline')
1805
1802
  row.removeAttribute('aria-disabled')
1806
1803
  }
1804
+ style.remove()
1807
1805
  }
1808
- }, [workspaces, tr])
1809
- return null
1810
1806
  }
1811
1807
 
1812
1808
  function SortDialog(props) {
@@ -2120,13 +2116,7 @@ window.__ModuleLoader__.load({
2120
2116
  inject: () => ({ store: sortStore, translate: t }),
2121
2117
  }, SortDialog))
2122
2118
 
2123
- ctx.slots.inject('shell.overlay', () => ctx.slots.register({
2124
- name: 'shell.overlay',
2125
- id: 'lmw-workspace-offline',
2126
- order: 920,
2127
- locale: NS,
2128
- inject: () => ({ workspaces: ctx.workspaces, translate: t }),
2129
- }, WorkspaceOfflineGuard))
2119
+ ctx.effect(() => startWorkspaceGuard(t), 'lmw: workspace offline guard')
2130
2120
 
2131
2121
  ctx.slots.inject('shell.overlay', () => ctx.slots.register({
2132
2122
  name: 'shell.overlay',
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "dsh-lmw-plugin",
3
- "version": "1.0.5",
3
+ "version": "1.0.6",
4
4
  "description": "Session assignment, session import, and workspace path subtitles for DeepSeek Harness",
5
5
  "type": "module",
6
6
  "license": "MIT",