finch-git-branch 0.3.1 → 0.3.3

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.
@@ -699,7 +699,7 @@
699
699
  changes: "Changes",
700
700
  graph: "Graph",
701
701
  message: "Message (⌘Enter to commit)",
702
- commit: "Commit",
702
+ commit: "Commit Manually",
703
703
  aiCommit: "Ask {finchName} to commit",
704
704
  aiCommitAnnotationTitle: "{finchName} will commit",
705
705
  aiCommitNote: "Commit the current Git changes.",
@@ -734,7 +734,7 @@
734
734
  changes: "更改",
735
735
  graph: "图表",
736
736
  message: "消息(⌘Enter 提交)",
737
- commit: "提交",
737
+ commit: "由人类提交",
738
738
  aiCommit: "让{finchName}提交",
739
739
  aiCommitAnnotationTitle: "{finchName}来提交",
740
740
  aiCommitNote: "提交当前 Git 改动。",
package/dist/scm-panel.js CHANGED
@@ -144,6 +144,9 @@ async function createDiffFile(label, filePath, content) {
144
144
  async function fileAtRevision(repoPath, revision, filePath) {
145
145
  return runGit(repoPath, ['show', `${revision}:${filePath}`], 15_000, false).catch(() => '');
146
146
  }
147
+ async function hasStagedChanges(repoPath) {
148
+ return Boolean(await runGit(repoPath, ['diff', '--cached', '--name-only']));
149
+ }
147
150
  export function activateScmPanel(ctx) {
148
151
  ctx.subscriptions.push(panelUi(ctx).onDidOpenPanel((panel) => {
149
152
  let cwd = '';
@@ -182,12 +185,12 @@ export function activateScmPanel(ctx) {
182
185
  // Also push config immediately: an already-live Webview may not emit finch:env again
183
186
  // after the mini tool backend is reloaded.
184
187
  void sendConfig().catch(() => undefined);
185
- const setScope = async (message, useCurrentWorkspace = false) => {
186
- const webviewCwd = typeof message.cwd === 'string' ? message.cwd : '';
187
- // Session switches can retain a live Webview without replaying finch:env.
188
- // The backend workspace follows the active session and is authoritative for heartbeat refreshes.
189
- const activeCwd = ctx.workspace.directoryPath ?? ctx.workspace.projectPath ?? '';
190
- const nextCwd = useCurrentWorkspace && activeCwd ? activeCwd : webviewCwd;
188
+ const setScope = async (message) => {
189
+ // A Panel belongs to the Session that opened it. Its bridged finch:env cwd
190
+ // remains the only reliable scope after switching other Spaces/Sessions;
191
+ // ctx.workspace describes the globally active workspace and can belong to
192
+ // a different Session by the time this callback runs.
193
+ const nextCwd = typeof message.cwd === 'string' ? message.cwd : '';
191
194
  const nextScopeKey = typeof message.scopeKey === 'string' ? message.scopeKey : (scopeKey || nextCwd);
192
195
  if (nextScopeKey === scopeKey && nextCwd === cwd)
193
196
  return false;
@@ -265,12 +268,12 @@ export function activateScmPanel(ctx) {
265
268
  return;
266
269
  }
267
270
  if (message.type === 'refresh') {
268
- await setScope(message, true);
271
+ await setScope(message);
269
272
  await refresh(message.silent !== true);
270
273
  return;
271
274
  }
272
275
  if (message.type === 'syncWorkspace') {
273
- const changed = await setScope(message, true);
276
+ const changed = await setScope(message);
274
277
  await sendConfig();
275
278
  if (changed || repos.length === 0)
276
279
  await refresh();
@@ -324,16 +327,13 @@ export function activateScmPanel(ctx) {
324
327
  const text = String(result.values?.message ?? '').trim();
325
328
  if (!text)
326
329
  return;
327
- // 提交由人类在自己的终端手动执行,扩展只生成命令,不再自动 git commit。
328
- const escaped = text.replace(/\\/g, '\\\\').replace(/"/g, '\\"');
329
- await ctx.ui.showModalDialog({
330
- title: ctx.i18n.t('git.scm.commit.manual.title'),
331
- description: ctx.i18n.t('git.scm.commit.manual.desc'),
332
- message: `\`git add -A\`\n\`git commit -m "${escaped}"\``,
333
- actions: [
334
- { id: 'ok', label: ctx.i18n.t('git.scm.commit.manual.ok'), variant: 'primary' },
335
- ],
336
- });
330
+ await runGit(repoPath, ['add', '-A']);
331
+ if (!await hasStagedChanges(repoPath)) {
332
+ await toast(ctx.i18n.t('git.scm.commit.empty'), 'info');
333
+ return;
334
+ }
335
+ await runGit(repoPath, ['commit', '-m', text, '-m', 'Co-authored-by: 帕亚 <noreply@finchwork.app>']);
336
+ await toast(ctx.i18n.t('git.scm.commit.success'));
337
337
  }
338
338
  if (message.type === 'discard') {
339
339
  const file = allowedFile(repoPath, message.filePath);
package/i18n/en-US.json CHANGED
@@ -59,9 +59,6 @@
59
59
  "git.scm.commit.cancel": "Cancel",
60
60
  "git.scm.commit.success": "Committed changes",
61
61
  "git.scm.commit.empty": "No changes to commit",
62
- "git.scm.commit.manual.title": "Commit Manually",
63
- "git.scm.commit.manual.desc": "The commit will be made by you in your terminal. Copy and run the commands below:",
64
- "git.scm.commit.manual.ok": "Done",
65
62
  "git.scm.stage.success": "Staged changes",
66
63
  "git.scm.unstage.success": "Unstaged changes",
67
64
  "git.scm.stageAll.success": "Staged all changes",
package/i18n/zh-CN.json CHANGED
@@ -59,9 +59,6 @@
59
59
  "git.scm.commit.cancel": "取消",
60
60
  "git.scm.commit.success": "已提交更改",
61
61
  "git.scm.commit.empty": "没有需要提交的更改",
62
- "git.scm.commit.manual.title": "请手动提交",
63
- "git.scm.commit.manual.desc": "提交将由你在终端手动执行,请复制并运行以下命令:",
64
- "git.scm.commit.manual.ok": "完成",
65
62
  "git.scm.stage.success": "已暂存",
66
63
  "git.scm.unstage.success": "已取消暂存",
67
64
  "git.scm.stageAll.success": "已暂存全部更改",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "finch-git-branch",
3
- "version": "0.3.1",
3
+ "version": "0.3.3",
4
4
  "description": "Git Source Control for Finch Composer toolbar.",
5
5
  "author": {
6
6
  "name": "Finch Team",