dsh-gufa-code 1.1.0 → 1.1.1

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/client.js CHANGED
@@ -9967,13 +9967,15 @@ G.GufaApp = function GufaApp(props) {
9967
9967
 
9968
9968
  /* 「仅切换 IDE 项目」:项目固定为用户手动打开的目录,不跟随 DSH 会话/工作区 */
9969
9969
  const projectPinnedRef = useRef(false)
9970
+ /* 会话弹窗里选了别的工作区的会话:右侧会话保持不动,不再自动把 IDE 项目切过去 */
9971
+ const sessionPinnedRef = useRef(false)
9970
9972
 
9971
9973
  /* ── 右侧 AI 面板与当前工作区保持一致 ─────────────────────────────────
9972
9974
  * ChatDock 停靠的是 DSH「主视图会话」,但主视图会话可能属于别的工作区
9973
9975
  * (重启恢复、手动切换会话后常见)。项目根变化时自动切到当前工作区的会话。 */
9974
9976
  const dockSyncRef = useRef('')
9975
9977
  useEffect(() => {
9976
- if (projectPinnedRef.current === true) return undefined
9978
+ if (projectPinnedRef.current === true || sessionPinnedRef.current === true) return undefined
9977
9979
  if (project === null || typeof project.root !== 'string' || project.root === '') return undefined
9978
9980
  if (dockSyncRef.current === project.root) return undefined
9979
9981
  if (typeof sessionCwd === 'string' && sessionCwd !== '' && sessionCwd === project.root) {
@@ -10226,6 +10228,7 @@ G.GufaApp = function GufaApp(props) {
10226
10228
  const switchWorkspace = useCallback(async (workspace) => {
10227
10229
  if (workspace === null || workspace === undefined) return
10228
10230
  projectPinnedRef.current = false
10231
+ sessionPinnedRef.current = false
10229
10232
  const service = workspaceService()
10230
10233
  try {
10231
10234
  if (service !== undefined && service !== null && typeof service.openWorkspace === 'function' && typeof workspace.id === 'string') {
@@ -10266,6 +10269,7 @@ G.GufaApp = function GufaApp(props) {
10266
10269
  if (workspace === null || workspace === undefined || typeof workspace.path !== 'string' || workspace.path === '') return
10267
10270
  try {
10268
10271
  projectPinnedRef.current = true
10272
+ sessionPinnedRef.current = false
10269
10273
  await openProjectPath(workspace.path)
10270
10274
  closeWorkspaceDialog()
10271
10275
  showBanner('已切换 IDE 项目(当前会话保持不变)', 'success')
@@ -10349,6 +10353,7 @@ G.GufaApp = function GufaApp(props) {
10349
10353
  /* 经典界面里切换工作区时:当前主视图会话的 cwd 变化 → 跟随打开对应项目 */
10350
10354
  const lastSessionCwdRef = useRef(null)
10351
10355
  useEffect(() => {
10356
+ if (sessionPinnedRef.current === true) return
10352
10357
  if (typeof sessionCwd !== 'string' || sessionCwd === '') return
10353
10358
  const previous = lastSessionCwdRef.current
10354
10359
  lastSessionCwdRef.current = sessionCwd
@@ -10499,30 +10504,22 @@ G.GufaApp = function GufaApp(props) {
10499
10504
 
10500
10505
  /* 从会话弹窗打开会话:可同时切换到该会话所属工作区的项目 */
10501
10506
  const openSessionInWorkspace = useCallback((sessionId, workspacePath) => {
10502
- projectPinnedRef.current = false
10503
10507
  const service = workspaceService()
10504
10508
  const path = typeof workspacePath === 'string' ? workspacePath : ''
10505
- void (async () => {
10506
- try {
10507
- if (service !== undefined && service !== null && typeof service.openSession === 'function') service.openSession(sessionId)
10508
- else setBanner('当前界面不支持切换会话')
10509
- } catch (error) {
10510
- setBanner(G.errorText(error))
10511
- }
10512
- if (path !== '' && project !== null && project.root !== path) {
10513
- try {
10514
- await openProjectPath(path)
10515
- setBanner('')
10516
- } catch (error) {
10517
- setBanner(G.errorText(error))
10518
- }
10519
- }
10520
- })()
10521
- }, [project, openProjectPath])
10509
+ /* 只切右侧会话:选了别的工作区的会话时,左侧项目/工作区保持不动 */
10510
+ sessionPinnedRef.current = path !== '' && project !== null && path !== project.root
10511
+ lastSessionCwdRef.current = null
10512
+ try {
10513
+ if (service !== undefined && service !== null && typeof service.openSession === 'function') service.openSession(sessionId)
10514
+ else setBanner('当前界面不支持切换会话')
10515
+ setBanner('')
10516
+ } catch (error) {
10517
+ setBanner(G.errorText(error))
10518
+ }
10519
+ }, [project])
10522
10520
 
10523
10521
  /* 从会话弹窗新建会话:在弹窗选中的工作区里新建,并切换 IDE 项目 */
10524
10522
  const startNewSessionInWorkspace = useCallback((workspacePath) => {
10525
- projectPinnedRef.current = false
10526
10523
  const service = workspaceService()
10527
10524
  const path = typeof workspacePath === 'string' ? workspacePath : ''
10528
10525
  void (async () => {
@@ -10537,19 +10534,19 @@ G.GufaApp = function GufaApp(props) {
10537
10534
  }
10538
10535
  try {
10539
10536
  if (service !== undefined && service !== null && typeof service.startSession === 'function') {
10537
+ /* 只新建会话,不切左侧项目;跨工作区时 pin 住避免自动同步 */
10538
+ sessionPinnedRef.current = path !== '' && project !== null && path !== project.root
10540
10539
  if (workspaceId !== null) service.startSession(workspaceId)
10541
10540
  else service.startSession()
10541
+ setBanner('')
10542
10542
  } else {
10543
10543
  setBanner('当前界面不支持新建会话')
10544
- return
10545
10544
  }
10546
- if (path !== '' && project !== null && project.root !== path) await openProjectPath(path)
10547
- setBanner('')
10548
10545
  } catch (error) {
10549
10546
  setBanner(G.errorText(error))
10550
10547
  }
10551
10548
  })()
10552
- }, [project, openProjectPath])
10549
+ }, [project])
10553
10550
 
10554
10551
  const activeFileForChat = useMemo(() => {
10555
10552
  if (activeTab === null || activeTab.kind === 'diff' || activeTab.kind === 'graph') return null
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "dsh-gufa-code",
3
- "version": "1.1.0",
3
+ "version": "1.1.1",
4
4
  "description": "古法编程 · AI 辅助:在 DSH Web 界面一键进入 VS Code 风格 IDE(Monaco 编辑器、文件树、Git、SSH、真实终端与右侧 AI 聊天)",
5
5
  "icon": "icon.svg",
6
6
  "keywords": [
@@ -789,13 +789,15 @@ G.GufaApp = function GufaApp(props) {
789
789
 
790
790
  /* 「仅切换 IDE 项目」:项目固定为用户手动打开的目录,不跟随 DSH 会话/工作区 */
791
791
  const projectPinnedRef = useRef(false)
792
+ /* 会话弹窗里选了别的工作区的会话:右侧会话保持不动,不再自动把 IDE 项目切过去 */
793
+ const sessionPinnedRef = useRef(false)
792
794
 
793
795
  /* ── 右侧 AI 面板与当前工作区保持一致 ─────────────────────────────────
794
796
  * ChatDock 停靠的是 DSH「主视图会话」,但主视图会话可能属于别的工作区
795
797
  * (重启恢复、手动切换会话后常见)。项目根变化时自动切到当前工作区的会话。 */
796
798
  const dockSyncRef = useRef('')
797
799
  useEffect(() => {
798
- if (projectPinnedRef.current === true) return undefined
800
+ if (projectPinnedRef.current === true || sessionPinnedRef.current === true) return undefined
799
801
  if (project === null || typeof project.root !== 'string' || project.root === '') return undefined
800
802
  if (dockSyncRef.current === project.root) return undefined
801
803
  if (typeof sessionCwd === 'string' && sessionCwd !== '' && sessionCwd === project.root) {
@@ -1048,6 +1050,7 @@ G.GufaApp = function GufaApp(props) {
1048
1050
  const switchWorkspace = useCallback(async (workspace) => {
1049
1051
  if (workspace === null || workspace === undefined) return
1050
1052
  projectPinnedRef.current = false
1053
+ sessionPinnedRef.current = false
1051
1054
  const service = workspaceService()
1052
1055
  try {
1053
1056
  if (service !== undefined && service !== null && typeof service.openWorkspace === 'function' && typeof workspace.id === 'string') {
@@ -1088,6 +1091,7 @@ G.GufaApp = function GufaApp(props) {
1088
1091
  if (workspace === null || workspace === undefined || typeof workspace.path !== 'string' || workspace.path === '') return
1089
1092
  try {
1090
1093
  projectPinnedRef.current = true
1094
+ sessionPinnedRef.current = false
1091
1095
  await openProjectPath(workspace.path)
1092
1096
  closeWorkspaceDialog()
1093
1097
  showBanner('已切换 IDE 项目(当前会话保持不变)', 'success')
@@ -1171,6 +1175,7 @@ G.GufaApp = function GufaApp(props) {
1171
1175
  /* 经典界面里切换工作区时:当前主视图会话的 cwd 变化 → 跟随打开对应项目 */
1172
1176
  const lastSessionCwdRef = useRef(null)
1173
1177
  useEffect(() => {
1178
+ if (sessionPinnedRef.current === true) return
1174
1179
  if (typeof sessionCwd !== 'string' || sessionCwd === '') return
1175
1180
  const previous = lastSessionCwdRef.current
1176
1181
  lastSessionCwdRef.current = sessionCwd
@@ -1321,30 +1326,22 @@ G.GufaApp = function GufaApp(props) {
1321
1326
 
1322
1327
  /* 从会话弹窗打开会话:可同时切换到该会话所属工作区的项目 */
1323
1328
  const openSessionInWorkspace = useCallback((sessionId, workspacePath) => {
1324
- projectPinnedRef.current = false
1325
1329
  const service = workspaceService()
1326
1330
  const path = typeof workspacePath === 'string' ? workspacePath : ''
1327
- void (async () => {
1328
- try {
1329
- if (service !== undefined && service !== null && typeof service.openSession === 'function') service.openSession(sessionId)
1330
- else setBanner('当前界面不支持切换会话')
1331
- } catch (error) {
1332
- setBanner(G.errorText(error))
1333
- }
1334
- if (path !== '' && project !== null && project.root !== path) {
1335
- try {
1336
- await openProjectPath(path)
1337
- setBanner('')
1338
- } catch (error) {
1339
- setBanner(G.errorText(error))
1340
- }
1341
- }
1342
- })()
1343
- }, [project, openProjectPath])
1331
+ /* 只切右侧会话:选了别的工作区的会话时,左侧项目/工作区保持不动 */
1332
+ sessionPinnedRef.current = path !== '' && project !== null && path !== project.root
1333
+ lastSessionCwdRef.current = null
1334
+ try {
1335
+ if (service !== undefined && service !== null && typeof service.openSession === 'function') service.openSession(sessionId)
1336
+ else setBanner('当前界面不支持切换会话')
1337
+ setBanner('')
1338
+ } catch (error) {
1339
+ setBanner(G.errorText(error))
1340
+ }
1341
+ }, [project])
1344
1342
 
1345
1343
  /* 从会话弹窗新建会话:在弹窗选中的工作区里新建,并切换 IDE 项目 */
1346
1344
  const startNewSessionInWorkspace = useCallback((workspacePath) => {
1347
- projectPinnedRef.current = false
1348
1345
  const service = workspaceService()
1349
1346
  const path = typeof workspacePath === 'string' ? workspacePath : ''
1350
1347
  void (async () => {
@@ -1359,19 +1356,19 @@ G.GufaApp = function GufaApp(props) {
1359
1356
  }
1360
1357
  try {
1361
1358
  if (service !== undefined && service !== null && typeof service.startSession === 'function') {
1359
+ /* 只新建会话,不切左侧项目;跨工作区时 pin 住避免自动同步 */
1360
+ sessionPinnedRef.current = path !== '' && project !== null && path !== project.root
1362
1361
  if (workspaceId !== null) service.startSession(workspaceId)
1363
1362
  else service.startSession()
1363
+ setBanner('')
1364
1364
  } else {
1365
1365
  setBanner('当前界面不支持新建会话')
1366
- return
1367
1366
  }
1368
- if (path !== '' && project !== null && project.root !== path) await openProjectPath(path)
1369
- setBanner('')
1370
1367
  } catch (error) {
1371
1368
  setBanner(G.errorText(error))
1372
1369
  }
1373
1370
  })()
1374
- }, [project, openProjectPath])
1371
+ }, [project])
1375
1372
 
1376
1373
  const activeFileForChat = useMemo(() => {
1377
1374
  if (activeTab === null || activeTab.kind === 'diff' || activeTab.kind === 'graph') return null