dsh-gufa-code 1.3.113 → 1.3.114

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/README.md CHANGED
@@ -64,7 +64,7 @@ dsh plugin add dsh-gufa-code
64
64
  ### 左侧面板
65
65
 
66
66
  - **资源管理器**:懒加载文件树、Git 状态颜色、错误/问题点、目录改动标记;
67
- - **源代码管理**:分支、ahead/behind(点击可推送/拉取)、更改列表、暂存/取消暂存、提交(`⌘⇧↵`,只提交已暂存的改动;未暂存改动需先手动「全部暂存」)、Git Graph(泳道图 + 提交文件 + 查看某次提交的文件)、撤销上次提交、丢弃全部、逐文件还原;
67
+ - **源代码管理**:分支、ahead/behind(点击可推送/拉取)、更改列表、暂存/取消暂存、提交(`⌘⇧↵`:已有暂存时只提交暂存内容;一个都没暂存时才自动全部暂存后提交)、Git Graph(泳道图 + 提交文件 + 查看某次提交的文件)、撤销上次提交、丢弃全部、逐文件还原;
68
68
  - **SSH**:解析 `~/.ssh/config`,点一下就在终端里 `ssh <alias>`;
69
69
  - **终端**:真实 PTY + xterm,多标签、新建/关闭、自动 resize、明暗主题,SSH 与任意命令都行。
70
70
 
package/client.js CHANGED
@@ -16,7 +16,7 @@ const GUFA_NS = 'gufa-code'
16
16
  const G = {}
17
17
  G.NS = GUFA_NS
18
18
  /** 客户端构建标记(排查页面是否加载了新代码时看标题栏) */
19
- G.BUILD = '1.3.113'
19
+ G.BUILD = '1.3.114'
20
20
  G.PANEL_ID = 'gufa-code'
21
21
  /** 从哪个工作区点进来的(工作区菜单/节点按钮写入,App 启动时消费)。 */
22
22
  G.pendingEntryWorkspace = null
@@ -262,6 +262,7 @@ const DICT_ZH = {
262
262
  'git.noUpstreamHint': '当前分支还没有上游:点标题栏 ↑ 推送一次即可自动创建上游(git push -u)',
263
263
  'git.discardFile': '还原该文件的改动',
264
264
  'git.commitStagedOnlyHint': '只提交「已暂存」的改动;未暂存的改动会留在工作区',
265
+ 'git.autoStageHint': '完全没有暂存时,点提交会自动暂存全部改动再提交;已有暂存时只提交暂存内容',
265
266
  'git.commitNeedsMessage': '请先填写提交信息,再按 ⌘⇧↵ 提交',
266
267
  'git.more': '更多操作',
267
268
  'git.viewDiff': '查看改动对比',
@@ -512,6 +513,7 @@ const DICT_EN = {
512
513
  'git.noUpstreamHint': 'No upstream for this branch yet: click ↑ in the header to push once (auto git push -u)',
513
514
  'git.discardFile': 'Revert this file',
514
515
  'git.commitStagedOnlyHint': 'Only staged changes are committed; unstaged changes stay in the working tree',
516
+ 'git.autoStageHint': 'If nothing is staged, Commit auto-stages everything first; once something is staged, only staged changes are committed',
515
517
  'git.commitNeedsMessage': 'Write a commit message first, then press ⌘⇧↵',
516
518
  'git.more': 'More actions',
517
519
  'git.viewDiff': 'View diff',
@@ -8801,12 +8803,16 @@ G.GitPanel = function GitPanel(props) {
8801
8803
  setError(t('git.commitNeedsMessage'))
8802
8804
  return
8803
8805
  }
8804
- if (staged.length === 0) {
8805
- setError(t('git.noStagedHint'))
8806
+ if (changes.length === 0) {
8807
+ setError(t('git.noChanges'))
8806
8808
  return
8807
8809
  }
8808
8810
  void act(async () => {
8809
- /* 只提交「已暂存」的改动;未暂存改动保持原样(需要时用「全部暂存」) */
8811
+ /* 有已暂存改动时只提交暂存内容;一个都没暂存时才自动全部暂存再提交(快捷模式) */
8812
+ if (staged.length === 0) {
8813
+ const toStage = changes.filter((item) => item.staged !== true).map((item) => item.path)
8814
+ if (toStage.length > 0) await G.api('git.stage', { root, paths: toStage })
8815
+ }
8810
8816
  await G.api('git.commit', { root, message: text })
8811
8817
  setMessage('')
8812
8818
  })
@@ -8992,15 +8998,15 @@ G.GitPanel = function GitPanel(props) {
8992
8998
  },
8993
8999
  )
8994
9000
  : null,
8995
- changes.length > 0
8996
- ? h('div', { className: 'gufa-hint' }, staged.length === 0 ? t('git.noStagedHint') : t('git.commitStagedOnlyHint'))
9001
+ changes.length > 0 && (staged.length === 0 || unstaged.length > 0)
9002
+ ? h('div', { className: 'gufa-hint' }, staged.length === 0 ? t('git.autoStageHint') : t('git.commitStagedOnlyHint'))
8997
9003
  : null,
8998
9004
  changes.length > 0
8999
9005
  ? h(
9000
9006
  'div',
9001
9007
  { className: 'gufa-row', style: { justifyContent: 'flex-end', alignItems: 'center', gap: 8 } },
9002
9008
  staged.length > 0 ? h('span', { className: 'gufa-hint' }, `${t('git.staged')} (${staged.length})`) : null,
9003
- h(G.Button, { disabled: pending || message.trim() === '' || staged.length === 0, primary: true, onClick: commit }, pending ? h(G.Spinner) : null, t('git.commit')),
9009
+ h(G.Button, { disabled: pending || message.trim() === '' || changes.length === 0, primary: true, onClick: commit }, pending ? h(G.Spinner) : null, t('git.commit')),
9004
9010
  )
9005
9011
  : null,
9006
9012
  staged.length > 0 ? h('div', { className: 'gufa-hint' }, `${t('git.staged')} (${staged.length})`) : null,
@@ -7,8 +7,8 @@
7
7
  <key>CFBundleDisplayName</key><string>古法编程悬浮层</string>
8
8
  <key>CFBundleExecutable</key><string>gufa-float</string>
9
9
  <key>CFBundlePackageType</key><string>APPL</string>
10
- <key>CFBundleShortVersionString</key><string>1.3.113</string>
11
- <key>CFBundleVersion</key><string>1.3.113</string>
10
+ <key>CFBundleShortVersionString</key><string>1.3.114</string>
11
+ <key>CFBundleVersion</key><string>1.3.114</string>
12
12
  <key>LSUIElement</key><true/>
13
13
  <key>NSHighResolutionCapable</key><true/>
14
14
  <key>NSPrincipalClass</key><string>NSApplication</string>
@@ -72,8 +72,8 @@
72
72
 
73
73
  ## 0.13 Git 提交只提交已暂存(1.3.113)
74
74
 
75
- - 旧实现里客户端点「提交」会先 `git.stage` 所有未暂存文件再 `git.commit`,导致用户只想提交暂存区却把所有改动都提交了。**提交按钮/⌘⇧↵ 绝不能自动暂存**。
76
- - 正确行为:`staged.length === 0` 时直接提示 `git.noStagedHint` 并禁用提交;有暂存时只调 `git.commit`(Host 本来就是 `git commit -m`,只消费 index)。未暂存改动保留在工作区,需要时用「全部暂存」。
75
+ - 旧实现点「提交」永远先 `git.stage` 所有未暂存文件再 `git.commit`,导致有暂存+未暂存时把两者都提交了,暂存失去意义。
76
+ - 正确策略(两层):`staged.length > 0` 时**只**调 `git.commit`(Host 是 `git commit -m`,只消费 index),未暂存保持不动;`staged.length === 0` 且存在改动时才自动 `git.stage` 全部再提交(快捷模式)。按钮只在没有改动或没填 message 时禁用。
77
77
  - 单测覆盖:暂存 `src/staged.ts`、保留未跟踪 `src/unstaged.ts` 后提交,断言 unstaged 文件不在 HEAD 且仍出现在 status 的未暂存列表里。
78
78
 
79
79
  ## 1. 弹窗/菜单层级:只有一个正确做法(反复踩过多次,最终定案)
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "dsh-gufa-code",
3
- "version": "1.3.113",
3
+ "version": "1.3.114",
4
4
  "description": "古法编程 · AI 辅助:一键把 DSH 主面板变成 VS Code 风格 IDE(Monaco 编辑器、文件树、Git、SSH、真实终端 + 右侧官方会话);主张亲手写、每个改动心中有数,AI 是助理、你是第一责任人",
5
5
  "icon": "icon.svg",
6
6
  "keywords": [
@@ -254,6 +254,7 @@ const DICT_ZH = {
254
254
  'git.noUpstreamHint': '当前分支还没有上游:点标题栏 ↑ 推送一次即可自动创建上游(git push -u)',
255
255
  'git.discardFile': '还原该文件的改动',
256
256
  'git.commitStagedOnlyHint': '只提交「已暂存」的改动;未暂存的改动会留在工作区',
257
+ 'git.autoStageHint': '完全没有暂存时,点提交会自动暂存全部改动再提交;已有暂存时只提交暂存内容',
257
258
  'git.commitNeedsMessage': '请先填写提交信息,再按 ⌘⇧↵ 提交',
258
259
  'git.more': '更多操作',
259
260
  'git.viewDiff': '查看改动对比',
@@ -504,6 +505,7 @@ const DICT_EN = {
504
505
  'git.noUpstreamHint': 'No upstream for this branch yet: click ↑ in the header to push once (auto git push -u)',
505
506
  'git.discardFile': 'Revert this file',
506
507
  'git.commitStagedOnlyHint': 'Only staged changes are committed; unstaged changes stay in the working tree',
508
+ 'git.autoStageHint': 'If nothing is staged, Commit auto-stages everything first; once something is staged, only staged changes are committed',
507
509
  'git.commitNeedsMessage': 'Write a commit message first, then press ⌘⇧↵',
508
510
  'git.more': 'More actions',
509
511
  'git.viewDiff': 'View diff',
@@ -1147,12 +1147,16 @@ G.GitPanel = function GitPanel(props) {
1147
1147
  setError(t('git.commitNeedsMessage'))
1148
1148
  return
1149
1149
  }
1150
- if (staged.length === 0) {
1151
- setError(t('git.noStagedHint'))
1150
+ if (changes.length === 0) {
1151
+ setError(t('git.noChanges'))
1152
1152
  return
1153
1153
  }
1154
1154
  void act(async () => {
1155
- /* 只提交「已暂存」的改动;未暂存改动保持原样(需要时用「全部暂存」) */
1155
+ /* 有已暂存改动时只提交暂存内容;一个都没暂存时才自动全部暂存再提交(快捷模式) */
1156
+ if (staged.length === 0) {
1157
+ const toStage = changes.filter((item) => item.staged !== true).map((item) => item.path)
1158
+ if (toStage.length > 0) await G.api('git.stage', { root, paths: toStage })
1159
+ }
1156
1160
  await G.api('git.commit', { root, message: text })
1157
1161
  setMessage('')
1158
1162
  })
@@ -1338,15 +1342,15 @@ G.GitPanel = function GitPanel(props) {
1338
1342
  },
1339
1343
  )
1340
1344
  : null,
1341
- changes.length > 0
1342
- ? h('div', { className: 'gufa-hint' }, staged.length === 0 ? t('git.noStagedHint') : t('git.commitStagedOnlyHint'))
1345
+ changes.length > 0 && (staged.length === 0 || unstaged.length > 0)
1346
+ ? h('div', { className: 'gufa-hint' }, staged.length === 0 ? t('git.autoStageHint') : t('git.commitStagedOnlyHint'))
1343
1347
  : null,
1344
1348
  changes.length > 0
1345
1349
  ? h(
1346
1350
  'div',
1347
1351
  { className: 'gufa-row', style: { justifyContent: 'flex-end', alignItems: 'center', gap: 8 } },
1348
1352
  staged.length > 0 ? h('span', { className: 'gufa-hint' }, `${t('git.staged')} (${staged.length})`) : null,
1349
- h(G.Button, { disabled: pending || message.trim() === '' || staged.length === 0, primary: true, onClick: commit }, pending ? h(G.Spinner) : null, t('git.commit')),
1353
+ h(G.Button, { disabled: pending || message.trim() === '' || changes.length === 0, primary: true, onClick: commit }, pending ? h(G.Spinner) : null, t('git.commit')),
1350
1354
  )
1351
1355
  : null,
1352
1356
  staged.length > 0 ? h('div', { className: 'gufa-hint' }, `${t('git.staged')} (${staged.length})`) : null,