@lyhue1991/dsh-soup 0.5.1 → 0.5.2

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/lib/client.js +20 -7
  2. package/package.json +1 -1
package/lib/client.js CHANGED
@@ -265,6 +265,7 @@ window.__ModuleLoader__.load({
265
265
  'explorer.close': '关闭',
266
266
  'explorer.closePanel': '关闭资源管理器',
267
267
  'explorer.emptyDir': '(空目录)',
268
+ 'explorer.waitCwd': '正在获取会话目录…',
268
269
  'explorer.bulkSelected': '已选 {n} 项 · 拖到文件夹可移动',
269
270
  'explorer.readFail': '读取失败',
270
271
  'explorer.actionFail': '失败',
@@ -335,6 +336,7 @@ window.__ModuleLoader__.load({
335
336
  'explorer.close': 'Close',
336
337
  'explorer.closePanel': 'Close explorer',
337
338
  'explorer.emptyDir': '(empty)',
339
+ 'explorer.waitCwd': 'Waiting for the session directory…',
338
340
  'explorer.bulkSelected': '{n} selected · drag onto a folder to move',
339
341
  'explorer.readFail': 'Failed to read',
340
342
  'explorer.actionFail': 'Failed',
@@ -522,9 +524,15 @@ window.__ModuleLoader__.load({
522
524
  var res = await rpc('sessionCwd', { sessionId: sessionId })
523
525
  if (res && res.ok && res.cwd) return res.cwd
524
526
  }
525
- // 已知会话但不能确定其工作目录时,回退到文件系统根,而不是"宿主启动目录"——
526
- // 后者(root)会让资源管理器误显示与当前会话无关的启动路径。
527
- return '/'
527
+ // 已知会话但尚未拿到 cwd 时不要猜路径:猜测 '/' 正好会撞上桌面端
528
+ // 工作区围栏(Desktop 主进程通常从用户主目录启动)。等 useSessions
529
+ // 补上 cwd 后 effect 会重跑。
530
+ if (sessionId) return undefined
531
+ // 无当前会话(例如启动时右栏先挂载)回退到宿主 root;它一定在围栏内,
532
+ // 而文件系统根 '/' 不一定在。
533
+ var rootRes = await rpc('root')
534
+ if (rootRes && rootRes.ok && rootRes.root) return rootRes.root
535
+ return undefined
528
536
  }
529
537
 
530
538
  async function trackSession(sessionId, cwdHint) {
@@ -532,6 +540,10 @@ window.__ModuleLoader__.load({
532
540
  activeSessionId = sessionId || null
533
541
  var cwd = await defaultCwd(sessionId, cwdHint)
534
542
  if (generation !== sessionTrackGeneration) return
543
+ if (!cwd) {
544
+ setState({ cwd: '', tree: [], selected: new Set(), renaming: null, newItem: null, menu: null, error: '', notice: '', files: [] })
545
+ return
546
+ }
535
547
  // 换项目时展开状态没有跨项目意义;回到同一项目则保留。
536
548
  if (expandedDirsCwd !== cwd) {
537
549
  expandedDirs.clear()
@@ -1496,7 +1508,7 @@ window.__ModuleLoader__.load({
1496
1508
  var widthRef = React.useRef(DETAILS_DEFAULT)
1497
1509
  var dragRef = React.useRef({ startX: 0, startW: 0, active: false })
1498
1510
 
1499
- React.useEffect(function () { trackSession(sessionId, cwdRef.current) }, [sessionId])
1511
+ React.useEffect(function () { trackSession(sessionId, cwdRef.current) }, [sessionId, liveCwd])
1500
1512
 
1501
1513
  var setFrameWidth = React.useCallback(function (w) {
1502
1514
  var frame = frameRef.current
@@ -1594,7 +1606,8 @@ window.__ModuleLoader__.load({
1594
1606
  ))
1595
1607
  }
1596
1608
  if (s.tree.length === 0 && !(state.newItem && state.newItem.parent === state.cwd)) {
1597
- bodyChildren.push(create('div', { key: '__empty__', className: 'expl-muted' }, T('explorer.emptyDir')))
1609
+ bodyChildren.push(create('div', { key: '__empty__', className: 'expl-muted' },
1610
+ s.cwd ? T('explorer.emptyDir') : T('explorer.waitCwd')))
1598
1611
  } else {
1599
1612
  s.tree.forEach(function (node) { bodyChildren.push(create(Row, { key: node.path, node: node, depth: 0 })) })
1600
1613
  }
@@ -1690,7 +1703,7 @@ window.__ModuleLoader__.load({
1690
1703
  }) : undefined
1691
1704
  var cwdRef = React.useRef(liveCwd)
1692
1705
  cwdRef.current = liveCwd || cwdRef.current
1693
- React.useEffect(function () { trackSession(sessionId, cwdRef.current) }, [sessionId])
1706
+ React.useEffect(function () { trackSession(sessionId, cwdRef.current) }, [sessionId, liveCwd])
1694
1707
  return create('button', {
1695
1708
  type: 'button',
1696
1709
  className: 'expl-toggle expl-tool' + (s.open ? ' expl-active' : ''),
@@ -1724,7 +1737,7 @@ window.__ModuleLoader__.load({
1724
1737
  }) : undefined
1725
1738
  React.useEffect(function () {
1726
1739
  if (blank) trackSession(sessionId, liveCwd)
1727
- }, [blank, sessionId])
1740
+ }, [blank, sessionId, liveCwd])
1728
1741
  if (!blank) return null
1729
1742
  return create('div', { className: 'expl-hero-dock' },
1730
1743
  create('button', {
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@lyhue1991/dsh-soup",
3
3
  "description": "DSH 项目资源管理器:右侧 details 列文件树(并列网格、宽度对齐宿主 details 合同 300-520px),有 Session log 时在其右侧、空白新会话在输入框上方右端提供 📁 切换按钮;支持多选、双击展开/打开、右键菜单(打开/系统打开/重命名/废纸篓/新建/复制路径)、拖拽移动、上传。文件「打开」在会话区新增「文件」标签页(原生 conversation.view,与对话/轨迹同级):文本可编辑 ⌘S 保存、图片预览、二进制提示。附带模型吞吐徽标:输入框正上方显示「正在等待模型...」与彩色 t/s 徽标(数据来自 llm/stream 真实流)。附带 GoalBar 多行展示:把原生单行截断 GoalBar 放开为多行完整显示,编辑用 textarea,工具与数据仍走原生 goal。",
4
- "version": "0.5.1",
4
+ "version": "0.5.2",
5
5
  "type": "module",
6
6
  "main": "lib/index.js",
7
7
  "exports": {