dsh-git-scm 0.1.0 → 0.3.0

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/lib/client.js CHANGED
@@ -61,8 +61,14 @@
61
61
  "action.refresh": "Refresh",
62
62
  "action.fetch": "Fetch",
63
63
  "action.pull": "Pull",
64
+ "action.pullRebase": "Pull (Rebase)",
64
65
  "action.pullBranch": "Pull {name}",
65
66
  "action.push": "Push",
67
+ "action.pushTo": "Push To",
68
+ "action.forcePush": "Force Push",
69
+ "action.fetchFrom": "Fetch From",
70
+ "action.moreSync": "More fetch, pull, and push actions",
71
+ "action.publish": "Publish",
66
72
  "action.publishBranch": "Publish Branch",
67
73
  "action.generateMessage": "Generate commit message",
68
74
  "action.improveMessage": "Improve commit message",
@@ -83,15 +89,14 @@
83
89
  "action.deleteTag": "Delete {name}",
84
90
  "action.showMore": "Load more",
85
91
  "action.openDiff": "Show changes in {path}",
86
- "action.openNative": "Open in changes view",
87
92
  "action.moreChanges": "More change actions",
93
+ "action.viewTree": "View changes as tree",
94
+ "action.viewList": "View changes as list",
88
95
  "action.switchBranch": "Switch branch",
89
96
  "action.dockBottom": "Dock the preview below",
90
97
  "action.dockRight": "Dock the preview to the right",
91
98
  "action.search": "Find in the comparison",
92
99
  "action.back": "Back",
93
- "action.stageSelected": "Stage selected",
94
- "action.unstageSelected": "Unstage selected",
95
100
  "action.discardSelected": "Discard selected",
96
101
  "action.clearSelection": "Clear selection",
97
102
  "action.checkoutSelected": "Check out",
@@ -124,7 +129,19 @@
124
129
  "commit.more": "More commit actions",
125
130
  "commit.all": "Commit all changes",
126
131
  "commit.undo": "Undo last commit",
132
+ "commit.tracked": "Commit Tracked",
133
+ "commit.amendTracked": "Amend Tracked",
134
+ "commit.trackedHint": "Stages the tracked changes, then commits",
135
+ "commit.amendHint": "Rewrites the last commit",
136
+ "commit.amendNote": "This updates your most recent commit",
137
+ "commit.noMessage": "Write a commit message first",
138
+ "commit.nothingToCommit": "Nothing to commit",
139
+ "commit.resolveConflicts": "Resolve the conflicts before committing",
127
140
  "commit.abort": "Abort {operation}",
141
+ "sync.fetch": "Fetch updates from the remote",
142
+ "sync.pull": "Pull the remote commits into this branch",
143
+ "sync.push": "Push the committed changes to the remote",
144
+ "sync.publish": "Publish this branch to a remote",
128
145
  "pending.cherry-pick": "A cherry pick is in progress",
129
146
  "pending.revert": "A revert is in progress",
130
147
  "pending.merge": "A merge is in progress",
@@ -142,8 +159,6 @@
142
159
  "prompt.remoteField": "Remote URL",
143
160
  "prompt.remotePlaceholder": "https://github.com/owner/repo.git",
144
161
  "menu.showDiff": "Show changes",
145
- "menu.openNative": "Open in the app changes view",
146
- "menu.previewInPanel": "Preview in this panel",
147
162
  "menu.openFile": "Open file",
148
163
  "menu.fileHistory": "File history",
149
164
  "menu.discardAll": "Discard all changes",
@@ -172,6 +187,7 @@
172
187
  "menu.createBranchFrom": "Create branch from commit…",
173
188
  "menu.copyRemoteUrl": "Copy remote URL",
174
189
  "menu.fetchRemote": "Fetch this remote",
190
+ "menu.fetchAll": "All remotes",
175
191
  "menu.collapse": "Collapse",
176
192
  "menu.applyStash": "Apply stash",
177
193
  "menu.popStash": "Pop stash",
@@ -200,6 +216,7 @@
200
216
  "confirm.dropAllStashes": "Drop every stash? This cannot be undone.",
201
217
  "confirm.deleteTag": "Delete tag {name}?",
202
218
  "confirm.undoCommit": "Undo the last commit, keeping its changes staged?",
219
+ "confirm.forcePush": "Force push the current branch? This overwrites the remote branch when the lease allows it.",
203
220
  "confirm.abort": "Abort the {operation} in progress?",
204
221
  "confirm.submit": "Confirm",
205
222
  "confirm.cancel": "Cancel",
@@ -211,11 +228,15 @@
211
228
  "diff.close": "Close comparison",
212
229
  "diff.modeSplit": "Side-by-side view",
213
230
  "diff.modeUnified": "Single-column view",
231
+ "diff.wrapOn": "Wrap lines",
232
+ "diff.wrapOff": "Turn off line wrap",
214
233
  "diff.maximize": "Expand comparison",
215
234
  "diff.restore": "Restore comparison height",
216
235
  "diff.resize": "Drag to resize the comparison",
217
236
  "diff.unchanged": "{n} unchanged lines",
218
237
  "diff.expand": "Expand",
238
+ "diff.collapsePanel": "Collapse comparison pane",
239
+ "diff.expandPanel": "Expand comparison pane",
219
240
  "diff.searchPlaceholder": "Find in comparison",
220
241
  "diff.nextMatch": "Next match",
221
242
  "diff.previousMatch": "Previous match",
@@ -240,6 +261,37 @@
240
261
  "branch.picker.empty": "No matching branch",
241
262
  "group.changes": "Changes",
242
263
  "group.repositories": "Git repositories",
264
+ "section.worktrees": "Worktrees",
265
+ "empty.worktrees": "No linked worktrees",
266
+ "action.createWorktree": "New Worktree",
267
+ "action.removeWorktree": "Remove worktree",
268
+ "action.forceRemoveWorktree": "Force Remove",
269
+ "action.switchWorktree": "Switch to this worktree",
270
+ "action.pruneWorktrees": "Prune missing worktrees",
271
+ "action.copyWorktreePath": "Copy worktree path",
272
+ "worktree.mainCheckout": "Main checkout",
273
+ "worktree.detached": "Detached HEAD",
274
+ "worktree.bare": "Bare repository",
275
+ "worktree.locked": "Locked",
276
+ "worktree.lockedReason": "Locked: {reason}",
277
+ "worktree.prunable": "Missing",
278
+ "worktree.current": "This Session works here",
279
+ "worktree.switchTooltip": "{path} — click to move this Session here",
280
+ "worktree.dialogTitle": "New Worktree",
281
+ "worktree.branchField": "Branch name",
282
+ "worktree.branchPlaceholder": "feature/my-task",
283
+ "worktree.directoryPreview": "Worktree directory: .agents/worktrees/{slug}",
284
+ "worktree.baseNote": "The branch starts at {base}; an existing local branch is checked out instead.",
285
+ "worktree.create": "Create Worktree",
286
+ "worktree.branchRequired": "Enter a branch name",
287
+ "confirm.switchWorktree": "Move this Session into the worktree {name}? The Git panel and the Session working directory will follow.",
288
+ "confirm.removeWorktree": "Remove the worktree {name}? Its directory is deleted; committed work stays on its branch.",
289
+ "confirm.forceRemoveWorktree": "Remove the worktree {name} even though it has uncommitted changes? Those changes are lost.",
290
+ "toast.worktreeCreated": "Created worktree {name}",
291
+ "toast.worktreeRemoved": "Removed worktree {name}",
292
+ "toast.worktreeSwitched": "This Session now works in {name}",
293
+ "toast.worktreeRemoveFailed": "Could not remove the worktree",
294
+ "toast.worktreesPruned": "Pruned missing worktrees",
243
295
  "confirm.discardAll": "Discard every working-tree change? This cannot be undone.",
244
296
  "diff.stashLabel": "Stash entry",
245
297
  "empty.changes": "No changes",
@@ -262,6 +314,7 @@
262
314
  "toast.pulledBranch": "Pulled {name} — {n} commits",
263
315
  "toast.pulledBranchCurrent": "Pulled {name} — already up to date",
264
316
  "toast.pushed": "Pushed",
317
+ "toast.forcePushed": "Force pushed",
265
318
  "toast.published": "Published {branch}",
266
319
  "toast.generateFailed": "Could not generate a commit message",
267
320
  "toast.initialized": "Initialized the Git repository",
@@ -280,7 +333,6 @@
280
333
  "toast.tagDeleted": "Tag deleted",
281
334
  "toast.copied": "Copied to the clipboard",
282
335
  "toast.copyFailed": "The clipboard is not available",
283
- "toast.nativeUnavailable": "The app changes view is not available in this profile",
284
336
  "toast.fileUnavailable": "This file cannot be opened here",
285
337
  "toast.revealed": "Revealed in the file manager",
286
338
  "toast.ignored": "Added to .gitignore",
@@ -351,8 +403,14 @@
351
403
  "action.refresh": "刷新",
352
404
  "action.fetch": "抓取",
353
405
  "action.pull": "拉取",
406
+ "action.pullRebase": "拉取(变基)",
354
407
  "action.pullBranch": "拉取 {name}",
355
408
  "action.push": "推送",
409
+ "action.pushTo": "推送到远程",
410
+ "action.forcePush": "强制推送",
411
+ "action.fetchFrom": "从远程抓取",
412
+ "action.moreSync": "更多抓取、拉取和推送操作",
413
+ "action.publish": "发布",
356
414
  "action.publishBranch": "发布 Branch",
357
415
  "action.generateMessage": "生成提交信息",
358
416
  "action.improveMessage": "优化提交信息",
@@ -373,15 +431,14 @@
373
431
  "action.deleteTag": "删除 {name}",
374
432
  "action.showMore": "加载更多",
375
433
  "action.openDiff": "查看 {path} 的更改",
376
- "action.openNative": "在变更视图中打开",
377
434
  "action.moreChanges": "更多操作",
435
+ "action.viewTree": "以树形式查看更改",
436
+ "action.viewList": "以列表形式查看更改",
378
437
  "action.switchBranch": "切换分支",
379
438
  "action.dockBottom": "预览停靠到下方",
380
439
  "action.dockRight": "预览停靠到右侧",
381
440
  "action.search": "在对比中查找",
382
441
  "action.back": "返回",
383
- "action.stageSelected": "暂存所选",
384
- "action.unstageSelected": "取消暂存所选",
385
442
  "action.discardSelected": "丢弃所选",
386
443
  "action.clearSelection": "取消选择",
387
444
  "action.checkoutSelected": "切换",
@@ -414,7 +471,19 @@
414
471
  "commit.more": "更多提交操作",
415
472
  "commit.all": "提交全部更改",
416
473
  "commit.undo": "撤消上次提交",
474
+ "commit.tracked": "提交已跟踪更改",
475
+ "commit.amendTracked": "修正已跟踪更改",
476
+ "commit.trackedHint": "先暂存所有已跟踪更改,再提交",
477
+ "commit.amendHint": "重写上一次提交",
478
+ "commit.amendNote": "将更新最近一次提交",
479
+ "commit.noMessage": "请先填写提交信息",
480
+ "commit.nothingToCommit": "没有可提交的更改",
481
+ "commit.resolveConflicts": "请先解决冲突再提交",
417
482
  "commit.abort": "中止{operation}",
483
+ "sync.fetch": "从远程抓取更新",
484
+ "sync.pull": "把远程提交拉取到当前分支",
485
+ "sync.push": "把已提交的更改推送到远程",
486
+ "sync.publish": "把当前分支发布到远程",
418
487
  "pending.cherry-pick": "正在进行 Cherry Pick",
419
488
  "pending.revert": "正在进行 Revert",
420
489
  "pending.merge": "正在进行合并",
@@ -432,8 +501,6 @@
432
501
  "prompt.remoteField": "远程仓库地址",
433
502
  "prompt.remotePlaceholder": "https://github.com/owner/repo.git",
434
503
  "menu.showDiff": "查看更改",
435
- "menu.openNative": "在应用自带的变更视图中打开",
436
- "menu.previewInPanel": "在面板内预览",
437
504
  "menu.openFile": "打开文件",
438
505
  "menu.fileHistory": "查看文件历史",
439
506
  "menu.discardAll": "放弃所有更改",
@@ -462,6 +529,7 @@
462
529
  "menu.createBranchFrom": "从该提交创建分支…",
463
530
  "menu.copyRemoteUrl": "复制远程地址",
464
531
  "menu.fetchRemote": "抓取该远程",
532
+ "menu.fetchAll": "所有远程",
465
533
  "menu.collapse": "收起",
466
534
  "menu.applyStash": "应用储藏",
467
535
  "menu.popStash": "弹出储藏",
@@ -490,6 +558,7 @@
490
558
  "confirm.dropAllStashes": "删除所有储藏?此操作无法撤销。",
491
559
  "confirm.deleteTag": "删除标签 {name}?",
492
560
  "confirm.undoCommit": "撤消上次提交并保留其更改为暂存状态?",
561
+ "confirm.forcePush": "强制推送当前分支?在 lease 允许时会覆盖远程分支。",
493
562
  "confirm.abort": "中止正在进行的 {operation}?",
494
563
  "confirm.submit": "确定",
495
564
  "confirm.cancel": "取消",
@@ -501,11 +570,15 @@
501
570
  "diff.close": "关闭对比",
502
571
  "diff.modeSplit": "并排对比",
503
572
  "diff.modeUnified": "单栏对比",
573
+ "diff.wrapOn": "自动换行",
574
+ "diff.wrapOff": "关闭自动换行",
504
575
  "diff.maximize": "展开对比",
505
576
  "diff.restore": "还原对比高度",
506
577
  "diff.resize": "拖动调整对比区域高度",
507
578
  "diff.unchanged": "{n} 行未更改",
508
579
  "diff.expand": "展开",
580
+ "diff.collapsePanel": "收起对比面板",
581
+ "diff.expandPanel": "展开对比面板",
509
582
  "diff.searchPlaceholder": "在对比中查找",
510
583
  "diff.nextMatch": "下一个匹配",
511
584
  "diff.previousMatch": "上一个匹配",
@@ -530,6 +603,37 @@
530
603
  "branch.picker.empty": "没有匹配的分支",
531
604
  "group.changes": "更改",
532
605
  "group.repositories": "Git 仓库",
606
+ "section.worktrees": "工作树",
607
+ "empty.worktrees": "没有链接工作树",
608
+ "action.createWorktree": "新建工作树",
609
+ "action.removeWorktree": "删除工作树",
610
+ "action.forceRemoveWorktree": "强制删除",
611
+ "action.switchWorktree": "切换到该工作树",
612
+ "action.pruneWorktrees": "清理失效的工作树",
613
+ "action.copyWorktreePath": "复制工作树路径",
614
+ "worktree.mainCheckout": "主检出",
615
+ "worktree.detached": "分离头指针",
616
+ "worktree.bare": "裸仓库",
617
+ "worktree.locked": "已锁定",
618
+ "worktree.lockedReason": "已锁定:{reason}",
619
+ "worktree.prunable": "目录缺失",
620
+ "worktree.current": "当前会话在此工作",
621
+ "worktree.switchTooltip": "{path} — 点击把当前会话切换到这里",
622
+ "worktree.dialogTitle": "新建工作树",
623
+ "worktree.branchField": "分支名",
624
+ "worktree.branchPlaceholder": "feature/my-task",
625
+ "worktree.directoryPreview": "工作树目录:.agents/worktrees/{slug}",
626
+ "worktree.baseNote": "新分支从 {base} 创建;若该分支已存在则直接检出。",
627
+ "worktree.create": "创建工作树",
628
+ "worktree.branchRequired": "请填写分支名",
629
+ "confirm.switchWorktree": "把当前会话切换到工作树 {name}?Git 面板和会话工作目录都会跟随切换。",
630
+ "confirm.removeWorktree": "删除工作树 {name}?其目录会被删除,已提交的内容仍保留在对应分支上。",
631
+ "confirm.forceRemoveWorktree": "工作树 {name} 有未提交的更改,仍要强制删除吗?这些更改将丢失。",
632
+ "toast.worktreeCreated": "已创建工作树 {name}",
633
+ "toast.worktreeRemoved": "已删除工作树 {name}",
634
+ "toast.worktreeSwitched": "当前会话已切换到 {name}",
635
+ "toast.worktreeRemoveFailed": "删除工作树失败",
636
+ "toast.worktreesPruned": "已清理失效的工作树",
533
637
  "confirm.discardAll": "放弃所有工作区更改?此操作无法撤销。",
534
638
  "diff.stashLabel": "储藏条目",
535
639
  "empty.changes": "没有更改",
@@ -552,6 +656,7 @@
552
656
  "toast.pulledBranch": "已拉取 {name} — {n} 个提交",
553
657
  "toast.pulledBranchCurrent": "已拉取 {name} — 已是最新",
554
658
  "toast.pushed": "已推送",
659
+ "toast.forcePushed": "已强制推送",
555
660
  "toast.published": "已发布分支 {branch}",
556
661
  "toast.generateFailed": "生成提交信息失败",
557
662
  "toast.initialized": "已初始化 Git 仓库",
@@ -570,7 +675,6 @@
570
675
  "toast.tagDeleted": "已删除标签",
571
676
  "toast.copied": "已复制到剪贴板",
572
677
  "toast.copyFailed": "剪贴板不可用",
573
- "toast.nativeUnavailable": "当前配置未启用应用自带的变更视图",
574
678
  "toast.fileUnavailable": "无法在此打开该文件",
575
679
  "toast.revealed": "已在访达中显示",
576
680
  "toast.ignored": "已添加到 .gitignore",
@@ -624,15 +728,6 @@
624
728
  }
625
729
  .dgscm-repo-row { display: flex; align-items: center; gap: 6px; min-width: 0; }
626
730
  .dgscm-repo-glyph { display: inline-flex; flex: none; color: var(--dsw-alias-label-secondary); }
627
- .dgscm-repo-name {
628
- min-width: 0;
629
- overflow: hidden;
630
- font-size: 13px;
631
- font-weight: 600;
632
- line-height: 20px;
633
- text-overflow: ellipsis;
634
- white-space: nowrap;
635
- }
636
731
  .dgscm-branch-chip {
637
732
  display: inline-flex;
638
733
  flex: 0 1 auto;
@@ -693,8 +788,11 @@
693
788
  white-space: nowrap;
694
789
  }
695
790
  .dgscm-top-actions { display: flex; flex: none; align-items: center; gap: 2px; margin-left: auto; }
791
+ .dgscm-sync-row { display: flex; align-items: center; gap: 6px; min-width: 0; }
792
+ .dgscm-sync-actions { display: flex; flex: none; align-items: center; gap: 1px; margin-left: auto; }
696
793
  .dgscm-sync {
697
794
  display: flex;
795
+ flex: 1 1 auto;
698
796
  align-items: center;
699
797
  gap: 6px;
700
798
  min-width: 0;
@@ -781,16 +879,14 @@
781
879
  .dgscm-textarea::placeholder { color: var(--dsw-alias-label-tertiary); }
782
880
  .dgscm-textarea:focus { border-color: var(--dsw-alias-brand-primary); }
783
881
  .dgscm-commit-row { display: flex; align-items: center; gap: 8px; }
784
- .dgscm-check {
785
- display: inline-flex;
786
- align-items: center;
787
- gap: 5px;
788
- color: var(--dsw-alias-label-secondary);
882
+ .dgscm-commit-note {
883
+ min-width: 0;
884
+ overflow: hidden;
885
+ color: var(--dsw-alias-label-tertiary);
789
886
  font-size: 11px;
790
- cursor: pointer;
791
- user-select: none;
887
+ text-overflow: ellipsis;
888
+ white-space: nowrap;
792
889
  }
793
- .dgscm-check input { margin: 0; accent-color: var(--dsw-alias-brand-primary); }
794
890
 
795
891
  .dgscm-button {
796
892
  display: inline-flex;
@@ -824,66 +920,112 @@
824
920
  .dgscm-button--quiet:hover:not(:disabled) { background: var(--dsw-alias-interactive-bg-hover); }
825
921
  .dgscm-button:disabled { opacity: 0.4; cursor: not-allowed; }
826
922
  .dgscm-commit-actions { display: flex; align-items: center; gap: 0; margin-left: auto; }
827
- /* The commit split button: the host's small control geometry (sm) on the
828
- dimmed primary surface (the secondary variant the desktop dialogs use), so
829
- the action sits quieter than a full primary button in the dark theme. The
830
- label pairs with the dimmed fill through the normal label token. Every state
831
- below is scoped to these two classes, so other buttons keep their own rules
832
- and the generic dgscm-button styles stay untouched. */
833
- .dgscm-split-more {
923
+
924
+ /* The Zed-style split control: one quiet pill whose left segment performs the
925
+ default action and whose chevron opens the rest. The header's sync control
926
+ and the commit action reuse the same surface so they read as one family;
927
+ each modifier only changes the geometry. The fill is the dimmed primary
928
+ surface, so the pill sits quieter than a full primary button. */
929
+ .dgscm-split-button,
930
+ .dgscm-sync-control {
834
931
  display: inline-flex;
835
932
  flex: none;
933
+ align-items: stretch;
934
+ height: 24px;
935
+ overflow: hidden;
936
+ border-radius: var(--dsw-radius-sm, 8px);
937
+ background: var(--dsw-alias-button-primary-dimmed, var(--dsw-alias-bg-layer-2));
938
+ color: var(--dsw-alias-label-primary);
939
+ }
940
+ .dgscm-split-button--commit { height: 28px; }
941
+ .dgscm-split-main,
942
+ .dgscm-sync-primary {
943
+ display: inline-flex;
836
944
  align-items: center;
837
945
  justify-content: center;
838
- width: 28px;
839
- height: 28px;
946
+ gap: 5px;
947
+ min-width: 0;
948
+ padding: 0 8px;
949
+ border: none;
950
+ background: transparent;
951
+ color: inherit;
952
+ font: inherit;
953
+ font-size: 11px;
954
+ font-weight: 500;
955
+ line-height: 18px;
956
+ white-space: nowrap;
957
+ cursor: pointer;
958
+ }
959
+ .dgscm-split-button--commit .dgscm-split-main { min-width: 88px; padding: 0 12px; font-size: 12px; }
960
+ .dgscm-sync-text { letter-spacing: 0.01em; }
961
+ .dgscm-sync-count {
962
+ display: inline-flex;
963
+ align-items: center;
964
+ color: var(--dsw-alias-label-secondary);
965
+ font-family: var(--ds-font-family-code, ui-monospace, Menlo, monospace);
966
+ font-size: 10px;
967
+ line-height: 1;
968
+ }
969
+ /* The pill counts sit on the dimmed fill rather than the darker sidebar, so
970
+ mixing in the label colour keeps them legible (the sync row repeats the
971
+ same counts on the darker surface). */
972
+ .dgscm-sync-count--ahead { color: color-mix(in srgb, var(--dsw-alias-state-success-primary) 78%, var(--dsw-alias-label-primary)); }
973
+ .dgscm-sync-count--behind { color: color-mix(in srgb, var(--dsw-alias-state-warn-primary) 78%, var(--dsw-alias-label-primary)); }
974
+ .dgscm-split-toggle,
975
+ .dgscm-sync-toggle {
976
+ display: inline-flex;
977
+ flex: none;
978
+ align-items: center;
979
+ justify-content: center;
980
+ width: 20px;
840
981
  padding: 0;
841
982
  border: none;
842
983
  border-left: 1px solid color-mix(in srgb, var(--dsw-alias-label-primary) 20%, transparent);
843
- border-radius: 0 var(--dsw-radius-sm, 8px) var(--dsw-radius-sm, 8px) 0;
844
- background: var(--dsw-alias-button-primary-dimmed, var(--dsw-alias-bg-layer-2));
845
- color: var(--dsw-alias-label-primary);
984
+ background: transparent;
985
+ color: var(--dsw-alias-label-secondary);
846
986
  cursor: pointer;
847
987
  }
848
- .dgscm-commit-submit {
849
- height: 28px;
850
- padding: 0 12px;
851
- border-radius: var(--dsw-radius-sm, 8px) 0 0 var(--dsw-radius-sm, 8px);
852
- background: var(--dsw-alias-button-primary-dimmed, var(--dsw-alias-bg-layer-2));
853
- color: var(--dsw-alias-label-primary);
854
- font-size: 12px;
855
- line-height: 18px;
856
- font-weight: 500;
857
- min-width: 76px;
858
- }
859
- /* Hover: one subtle step of the label colour mixed into the dimmed fill, which
860
- lightens it on the dark theme and darkens it on the light theme, so the step
861
- stays theme-correct instead of jumping to the bright primary hover. */
988
+ .dgscm-split-button--commit .dgscm-split-toggle { width: 26px; }
989
+ .dgscm-split-toggle svg,
990
+ .dgscm-sync-toggle svg { pointer-events: none; }
991
+ /* Hover steps the shared pill fill with the label colour, so the light theme
992
+ darkens and the dark theme lightens by the same rule. */
862
993
  @media (hover: hover) {
863
- .dgscm-commit-submit:hover:not(:disabled),
864
- .dgscm-split-more:hover:not(:disabled) {
994
+ .dgscm-split-main:hover:not(:disabled),
995
+ .dgscm-split-toggle:hover:not(:disabled),
996
+ .dgscm-sync-primary:hover:not(:disabled),
997
+ .dgscm-sync-toggle:hover:not(:disabled) {
865
998
  background: color-mix(in srgb, var(--dsw-alias-button-primary-dimmed, var(--dsw-alias-bg-layer-2)) 88%, var(--dsw-alias-label-primary));
866
999
  }
867
1000
  }
868
1001
  /* Pressed: DSH defines no separate pressed token for primary buttons, so the
869
1002
  pressed state deliberately keeps the hover fill instead of inventing one. */
870
- .dgscm-commit-submit:active:not(:disabled),
871
- .dgscm-split-more:active:not(:disabled) {
1003
+ .dgscm-split-main:active:not(:disabled),
1004
+ .dgscm-split-toggle:active:not(:disabled),
1005
+ .dgscm-sync-primary:active:not(:disabled),
1006
+ .dgscm-sync-toggle:active:not(:disabled) {
872
1007
  background: color-mix(in srgb, var(--dsw-alias-button-primary-dimmed, var(--dsw-alias-bg-layer-2)) 88%, var(--dsw-alias-label-primary));
873
1008
  }
874
- /* Focus: the host focus-ring tokens. The host's pointer-modality rule still
875
- suppresses the ring for pointer focus, exactly as it does for host buttons. */
876
- .dgscm-commit-submit:focus-visible,
877
- .dgscm-split-more:focus-visible {
1009
+ /* Focus: the host focus-ring tokens, inset so the ring follows the segment
1010
+ instead of bleeding past the pill's rounded outline. */
1011
+ .dgscm-split-main:focus-visible,
1012
+ .dgscm-split-toggle:focus-visible,
1013
+ .dgscm-sync-primary:focus-visible,
1014
+ .dgscm-sync-toggle:focus-visible {
878
1015
  outline: var(--dsw-focus-ring-width, 2px) solid var(--dsw-focus-ring-color, var(--dsw-alias-state-business-primary));
879
- outline-offset: 1px;
1016
+ outline-offset: -2px;
880
1017
  }
881
- /* Disabled: host parity (dimmed, not-allowed), scoped to the two controls. */
882
- .dgscm-commit-submit:disabled,
883
- .dgscm-split-more:disabled {
1018
+ /* Disabled: host parity (dimmed, not-allowed), scoped to the split segments. */
1019
+ .dgscm-split-main:disabled,
1020
+ .dgscm-split-toggle:disabled,
1021
+ .dgscm-sync-primary:disabled,
1022
+ .dgscm-sync-toggle:disabled {
884
1023
  opacity: 0.4;
885
1024
  cursor: not-allowed;
886
1025
  }
1026
+ /* A remote operation or commit in progress spins the glyph in place. */
1027
+ .dgscm-sync-primary[aria-busy='true'] svg,
1028
+ .dgscm-split-main[aria-busy='true'] svg { animation: dgscm-spin 900ms linear infinite; }
887
1029
 
888
1030
  .dgscm-scroll { flex: 1 1 auto; min-height: 0; overflow: auto; overscroll-behavior: contain; padding-bottom: 16px; }
889
1031
 
@@ -1024,9 +1166,25 @@
1024
1166
  .dgscm-branch-flag { display: inline-flex; align-items: center; color: var(--dsw-alias-label-tertiary); }
1025
1167
  .dgscm-branch-flag--unpublished { color: var(--dsw-alias-state-success-primary); font-family: var(--ds-font-family-code, ui-monospace, Menlo, monospace); font-size: 10px; font-weight: 700; }
1026
1168
  .dgscm-branch-flag--current { color: var(--dsw-alias-label-secondary); }
1169
+ /* Worktree rows: the folder glyph is a checkout, a missing directory is an
1170
+ error tone, a locked worktree says so in the warn tone. */
1171
+ .dgscm-row-glyph--worktree { color: var(--dsw-alias-brand-primary); }
1172
+ .dgscm-row-note--warn { color: var(--dsw-alias-state-warn-primary); }
1173
+ .dgscm-row--prunable .dgscm-row-name { color: var(--dsw-alias-label-tertiary); }
1174
+ /* Keep the branch name whole: the relative directory suffix shrinks first. */
1175
+ .dgscm-row--worktree .dgscm-row-dir { flex-shrink: 999; }
1176
+ /* The remote name stays whole; a long URL ellipsizes against it. */
1177
+ .dgscm-row--remote .dgscm-row-name { flex-shrink: 0; }
1178
+ .dgscm-row--remote .dgscm-row-dir { flex-shrink: 999; }
1179
+ .dgscm-worktree-flag--missing { display: inline-flex; flex: none; color: var(--dsw-alias-state-error-primary); }
1180
+ .dgscm-badge--worktree {
1181
+ background: color-mix(in srgb, var(--dsw-alias-brand-primary) 14%, transparent);
1182
+ color: var(--dsw-alias-brand-primary);
1183
+ }
1184
+ /* A linked checkout is marked by a glyph badge: the word would push the branch
1185
+ chip out of the header at common sidebar widths. */
1186
+ .dgscm-badge--icon { height: 18px; padding: 0 4px; }
1027
1187
  .dgscm-row-chevron { display: inline-flex; flex: none; width: 14px; justify-content: center; }
1028
- .dgscm-row-check { display: inline-flex; flex: none; align-items: center; margin: 0; }
1029
- .dgscm-row-check input { width: 12px; height: 12px; margin: 0; accent-color: var(--dsw-alias-brand-primary); cursor: pointer; }
1030
1188
  .dgscm-row-mark {
1031
1189
  display: inline-flex;
1032
1190
  flex: none;
@@ -1046,6 +1204,21 @@
1046
1204
  text-overflow: ellipsis;
1047
1205
  white-space: nowrap;
1048
1206
  }
1207
+ /* A narrow change row gives up the directory suffix before the file name:
1208
+ the suffix absorbs the shortage first, and the name only truncates once it
1209
+ is gone. */
1210
+ .dgscm-row--file .dgscm-row-dir { flex-shrink: 999; }
1211
+ /* Change tree: file rows pad past the folder chevron so a file glyph lines up
1212
+ with a folder glyph at the same depth. */
1213
+ .dgscm-row--dir { cursor: pointer; }
1214
+ .dgscm-row-treepad { flex: none; width: 14px; }
1215
+ .dgscm-row-glyph--folder { color: var(--dsw-alias-label-tertiary); }
1216
+ .dgscm-row--dir .dgscm-row-name { font-weight: 500; }
1217
+ /* A directory shows its changed-file count only while hovered or focused,
1218
+ together with its actions. */
1219
+ .dgscm-row--dir .dgscm-row-note { opacity: 0; }
1220
+ .dgscm-row--dir:hover .dgscm-row-note,
1221
+ .dgscm-row--dir:focus-within .dgscm-row-note { opacity: 1; }
1049
1222
  .dgscm-row-end { display: flex; flex: none; align-items: center; gap: 4px; margin-left: auto; }
1050
1223
  .dgscm-row-actions {
1051
1224
  display: flex;
@@ -1153,7 +1326,7 @@
1153
1326
  .dgscm-main { display: flex; flex: 1 1 auto; flex-direction: column; min-width: 0; min-height: 0; overflow: hidden; }
1154
1327
  .dgscm-root--row { flex-direction: row; }
1155
1328
  .dgscm-root--row > .dgscm-main { flex: 1 1 auto; min-width: 300px; }
1156
- .dgscm-diffpane--right { height: auto !important; width: 360px; border-top: none; border-left: 0.5px solid var(--dsw-alias-border-l1); }
1329
+ .dgscm-diffpane--right { height: auto !important; width: 360px; min-width: 280px; border-top: none; border-left: 0.5px solid var(--dsw-alias-border-l1); }
1157
1330
  /* The pane's left edge is itself a resize handle, so the border can be dragged;
1158
1331
  it also overlaps the list column by 2px, so it clears the sticky headers. */
1159
1332
  .dgscm-resize-edge {
@@ -1303,6 +1476,31 @@
1303
1476
  text-overflow: ellipsis;
1304
1477
  white-space: nowrap;
1305
1478
  }
1479
+ /* The title is the comparison's disclosure control: clicking it folds the body. */
1480
+ .dgscm-diff-title {
1481
+ display: flex;
1482
+ flex: 1 1 auto;
1483
+ align-items: center;
1484
+ gap: 3px;
1485
+ min-width: 0;
1486
+ height: 26px;
1487
+ padding: 0 4px 0 2px;
1488
+ border: none;
1489
+ border-radius: 4px;
1490
+ background: transparent;
1491
+ color: inherit;
1492
+ font: inherit;
1493
+ text-align: left;
1494
+ cursor: pointer;
1495
+ }
1496
+ .dgscm-diff-title:hover { background: var(--dsw-alias-interactive-bg-hover); }
1497
+ .dgscm-diff-title:focus-visible { outline: none; box-shadow: inset 0 0 0 1px var(--dsw-alias-brand-primary); }
1498
+ .dgscm-diff-title .dgscm-diff-path { padding-left: 0; }
1499
+ .dgscm-diff-head--collapsed { border-bottom: none; }
1500
+ /* The collapsed pane hides the body instead of unmounting it, so its scroll
1501
+ position and expanded context runs survive a fold. */
1502
+ .dgscm-diffpane--collapsed .dgscm-diff-body { display: none; }
1503
+ .dgscm-diffpane--collapsed .dgscm-diff-search { display: none; }
1306
1504
  .dgscm-diff-stats { display: flex; flex: none; align-items: center; gap: 5px; font-family: var(--ds-font-family-code, ui-monospace, Menlo, monospace); font-size: 11px; }
1307
1505
  .dgscm-diff-added { color: var(--dsw-alias-state-success-primary); }
1308
1506
  .dgscm-diff-deleted { color: var(--dsw-alias-state-error-primary); }
@@ -1344,6 +1542,12 @@
1344
1542
  white-space: pre-wrap;
1345
1543
  word-break: break-all;
1346
1544
  }
1545
+ /* Word-wrap toggle: without it, long lines stay on one line and scroll. */
1546
+ .dgscm-diff-body--nowrap .dgscm-difftext {
1547
+ white-space: pre;
1548
+ word-break: normal;
1549
+ overflow-wrap: normal;
1550
+ }
1347
1551
  .dgscm-diffgap {
1348
1552
  display: flex;
1349
1553
  align-items: center;
@@ -1441,9 +1645,11 @@
1441
1645
  .dgscm-review-path { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
1442
1646
  .dgscm-review-dir { min-width: 0; overflow: hidden; color: var(--dsw-alias-label-tertiary); font-size: 10px; text-overflow: ellipsis; white-space: nowrap; }
1443
1647
  .dgscm-review-counts { display: flex; flex: none; gap: 6px; margin-left: auto; font-family: var(--ds-font-family-code, ui-monospace, Menlo, monospace); font-size: 10px; }
1648
+ /* The review row keeps the tracking status on the right, beside the line counts. */
1649
+ .dgscm-review-end { display: flex; flex: none; align-items: center; gap: 4px; margin-left: auto; }
1444
1650
  .dgscm-review-add { color: var(--dsw-alias-state-success-primary); }
1445
1651
  .dgscm-review-del { color: var(--dsw-alias-state-error-primary); }
1446
- .dgscm-review-subject { min-width: 0; overflow: hidden; color: var(--dsw-alias-label-secondary); font-size: 11px; text-overflow: ellipsis; white-space: nowrap; }
1652
+ .dgscm-review-subject { flex: 1 1 auto; min-width: 0; overflow: hidden; color: var(--dsw-alias-label-secondary); font-size: 11px; text-overflow: ellipsis; white-space: nowrap; }
1447
1653
  .dgscm-review-filter { flex: none; padding: 4px 8px; border-bottom: 0.5px solid var(--dsw-alias-border-l1); background: var(--dsw-alias-bg-layer-1); }
1448
1654
 
1449
1655
  .dgscm-popover {
@@ -1649,10 +1855,19 @@
1649
1855
  .dgscm-native-label { display: none; }
1650
1856
  }
1651
1857
 
1858
+ @container dgscm (max-width: 380px) {
1859
+ /* The linked-checkout glyph yields to the repo name and branch chip in
1860
+ narrow panels; the Worktrees section still marks the current checkout. */
1861
+ .dgscm-badge--worktree { display: none; }
1862
+ }
1863
+
1652
1864
  @container dgscm (max-width: 340px) {
1653
- .dgscm-row-dir { display: none; }
1654
- .dgscm-repo-name { max-width: 40%; }
1655
1865
  .dgscm-row-meta { display: none; }
1866
+ /* Below 340px the header keeps only the essentials: the pill drops its
1867
+ counts (the sync row repeats them) and the branch chip drops its publish
1868
+ button, which the pill's own Publish primary already covers. */
1869
+ .dgscm-sync-count { display: none; }
1870
+ .dgscm-branch-publish { display: none; }
1656
1871
  }
1657
1872
 
1658
1873
  /* Publish call to action: the dimmed primary surface, full width, while the
@@ -1690,7 +1905,9 @@
1690
1905
  overflow: hidden;
1691
1906
  border: 0.5px solid var(--dsw-alias-border-l2);
1692
1907
  border-radius: 6px;
1693
- background: var(--dsw-menu-surface-fill, var(--dsw-alias-bg-overlay));
1908
+ /* Opaque, not the translucent menu surface: the tip floats over the panel
1909
+ header, where a transparent fill let the underlying toolbar show through. */
1910
+ background: var(--dsw-alias-bg-layer-2, var(--dsw-menu-surface-fill, var(--dsw-alias-bg-overlay)));
1694
1911
  box-shadow: var(--dsw-elevation-prominent, 0 3px 8px rgba(0, 0, 0, 0.2));
1695
1912
  color: var(--dsw-alias-label-primary);
1696
1913
  font-size: 11px;
@@ -1701,6 +1918,18 @@
1701
1918
  pointer-events: none;
1702
1919
  }
1703
1920
 
1921
+ /* The New Worktree dialog: branch field plus the derived pool directory. */
1922
+ .dgscm-worktree-dialog { max-width: 400px; }
1923
+ .dgscm-worktree-dialog .dgscm-modal-note { margin-bottom: 10px; }
1924
+ .dgscm-worktree-preview {
1925
+ margin-bottom: 6px;
1926
+ color: var(--dsw-alias-label-secondary);
1927
+ font-family: var(--ds-font-family-code, ui-monospace, Menlo, monospace);
1928
+ font-size: 11px;
1929
+ line-height: 16px;
1930
+ overflow-wrap: anywhere;
1931
+ }
1932
+
1704
1933
  /* The GitHub publish dialog: repository name then one row per destination. */
1705
1934
  .dgscm-publish-dialog { width: min(420px, 100%); }
1706
1935
  .dgscm-publish-dialog .dgscm-modal-card { max-width: 420px; }
@@ -1932,6 +2161,10 @@
1932
2161
  function PushIcon(props) {
1933
2162
  return h(Glyph, props, h("path", { d: "M8 13.4V3.2" }), h("path", { d: "M4.3 6.9 8 3.2l3.7 3.7" }));
1934
2163
  }
2164
+ /** Word-wrap glyph: text lines with a returning arrow. */
2165
+ function WrapIcon(props) {
2166
+ return h(Glyph, props, h("path", { d: "M2.6 4h10.8" }), h("path", { d: "M2.6 8h8.6" }), h("path", { d: "M2.6 12h4.4" }), h("path", { d: "M11.2 8a2.1 2.1 0 0 1 0 4.2H8.6" }), h("path", { d: "M10 10.4 8.4 12.2l1.6 1.8" }));
2167
+ }
1935
2168
  /** Check glyph. */
1936
2169
  function CheckIcon(props) {
1937
2170
  return h(Glyph, props, h("path", { d: "M3.2 8.4 6.4 11.6 12.8 4.6" }));
@@ -1952,6 +2185,16 @@
1952
2185
  function TrashIcon(props) {
1953
2186
  return h(Glyph, props, h("path", { d: "M2.8 4.4h10.4" }), h("path", { d: "M6.4 4.4V3a.8.8 0 0 1 .8-.8h1.6a.8.8 0 0 1 .8.8v1.4" }), h("path", { d: "M4.2 4.4l.6 8.1a.9.9 0 0 0 .9.8h4.6a.9.9 0 0 0 .9-.8l.6-8.1" }));
1954
2187
  }
2188
+ /** Lock glyph, for a locked worktree. */
2189
+ function LockIcon(props) {
2190
+ return h(Glyph, props, h("rect", {
2191
+ x: 3.6,
2192
+ y: 7.2,
2193
+ width: 8.8,
2194
+ height: 6.2,
2195
+ rx: 1.2
2196
+ }), h("path", { d: "M5.6 7.2V5.4a2.4 2.4 0 0 1 4.8 0v1.8" }));
2197
+ }
1955
2198
  /** Chevron glyph; rotation shows the disclosure state. */
1956
2199
  function ChevronIcon({ open = false, size = 12, ...rest }) {
1957
2200
  return h("span", { className: `dgscm-chevron${open ? " dgscm-chevron--open" : ""}` }, h(Glyph, {
@@ -1975,6 +2218,10 @@
1975
2218
  function FileIcon(props) {
1976
2219
  return h(Glyph, props, h("path", { d: "M4.2 2.6h4.9l3.1 3.1v7.7H4.2z" }), h("path", { d: "M9.1 2.6v3.1h3.1" }));
1977
2220
  }
2221
+ /** Folder glyph. */
2222
+ function FolderIcon(props) {
2223
+ return h(Glyph, props, h("path", { d: "M2.4 4.4a1 1 0 0 1 1-1h2.4l1.3 1.4h5.5a1 1 0 0 1 1 1v6.2a1 1 0 0 1-1 1H3.4a1 1 0 0 1-1-1z" }));
2224
+ }
1978
2225
  /** More (horizontal dots) glyph. */
1979
2226
  function MoreIcon(props) {
1980
2227
  return h(Glyph, {
@@ -2014,6 +2261,10 @@
2014
2261
  function RowsIcon(props) {
2015
2262
  return h(Glyph, props, h("path", { d: "M2.8 4h10.4M2.8 8h10.4M2.8 12h10.4" }));
2016
2263
  }
2264
+ /** Directory-tree glyph, for switching a change list to its tree view. */
2265
+ function TreeIcon(props) {
2266
+ return h(Glyph, props, h("path", { d: "M3.2 3.2v9.6" }), h("path", { d: "M3.2 5.2h3M3.2 8h5.4M3.2 10.8h6.8" }));
2267
+ }
2017
2268
  /** Side-by-side (two columns) glyph. */
2018
2269
  function ColumnsIcon(props) {
2019
2270
  return h(Glyph, props, h("rect", {
@@ -2099,6 +2350,7 @@
2099
2350
  PushIcon,
2100
2351
  CloudUploadIcon,
2101
2352
  SparkleIcon,
2353
+ WrapIcon,
2102
2354
  CheckIcon,
2103
2355
  PlusIcon,
2104
2356
  MinusIcon,
@@ -2109,16 +2361,19 @@
2109
2361
  CloseIcon,
2110
2362
  WarnIcon,
2111
2363
  FileIcon,
2364
+ FolderIcon,
2112
2365
  MoreIcon,
2113
2366
  CopyIcon,
2114
2367
  ExternalIcon,
2115
2368
  RowsIcon,
2369
+ TreeIcon,
2116
2370
  ColumnsIcon,
2117
2371
  MaximizeIcon,
2118
2372
  RestoreIcon,
2119
2373
  DockBottomIcon,
2120
2374
  DockRightIcon,
2121
2375
  SearchIcon,
2376
+ LockIcon,
2122
2377
  HistoryIcon,
2123
2378
  CaretIcon,
2124
2379
  SpinnerIcon
@@ -2269,18 +2524,22 @@
2269
2524
  publishGithub: "action.publishBranch",
2270
2525
  commit: "commit.submit",
2271
2526
  cherryPick: "toast.cherryPicked",
2272
- revert: "toast.reverted"
2527
+ revert: "toast.reverted",
2528
+ worktreeAdd: "action.createWorktree",
2529
+ worktreeRemove: "action.removeWorktree",
2530
+ worktreePrune: "action.pruneWorktrees",
2531
+ switchWorktree: "action.switchWorktree"
2273
2532
  };
2533
+ /** Directory slug the host gives a branch inside the repository's worktree pool. */
2534
+ function worktreeSlugOf(branch) {
2535
+ return String(branch ?? "").trim().replace(/[^A-Za-z0-9._-]+/g, "-").replace(/^[-.]+|[-.]+$/g, "");
2536
+ }
2274
2537
  /** Build the `dsh-resource://file/session/…` address of one Session-relative file. */
2275
2538
  function fileAddressOf(sessionId, path) {
2276
2539
  const encode = (segment) => encodeURIComponent(segment).replace(/%3A/gi, ":");
2277
2540
  const normalized = path.replace(/\\/g, "/").replace(/^(?:\.\/)+/, "");
2278
2541
  return `dsh-resource://file/session/${encode(String(sessionId))}/${normalized.split("/").map(encode).join("/")}`;
2279
2542
  }
2280
- /** The app's own local-changes view: the address its router claims for one Session. */
2281
- function nativeChangesAddress(sessionId) {
2282
- return `dsh-resource://forge-changes/${encodeURIComponent(String(sessionId))}/local`;
2283
- }
2284
2543
  /** Context lines kept on each side of a collapsed unchanged run. */
2285
2544
  var DIFF_CONTEXT_KEEP = 3;
2286
2545
  /** Shortest unchanged run worth collapsing. */
@@ -2293,6 +2552,12 @@
2293
2552
  var DIFF_HEIGHT_MIN = 140;
2294
2553
  /** Room the list above the comparison keeps when the pane is dragged or expanded. */
2295
2554
  var DIFF_HEIGHT_RESERVED = 170;
2555
+ /**
2556
+ * localStorage key of the comparison pane's word-wrap preference.
2557
+ */
2558
+ var DIFF_WRAP_KEY = "dsh-git-scm.diff-wrap";
2559
+ /** Whether the comparison wraps long lines when nothing is stored. */
2560
+ var DIFF_WRAP_DEFAULT = true;
2296
2561
  /** localStorage key of the preview dock side. */
2297
2562
  var PREVIEW_LAYOUT_KEY = "dsh-git-scm.preview-layout";
2298
2563
  /** localStorage key of the preview width when docked to the right. */
@@ -2300,9 +2565,11 @@
2300
2565
  /** Width the preview opens with when docked to the right. */
2301
2566
  var PREVIEW_WIDTH_DEFAULT = 360;
2302
2567
  /** Smallest preview width when docked to the right. */
2303
- var PREVIEW_WIDTH_MIN = 160;
2568
+ var PREVIEW_WIDTH_MIN = 280;
2304
2569
  /** Narrowest left column allowed when the preview is docked to the right. */
2305
2570
  var PREVIEW_WIDTH_RESERVED = 300;
2571
+ /** Panel width below which the comparison docks below the list and starts collapsed. */
2572
+ var PREVIEW_NARROW_WIDTH = 580;
2306
2573
  /** Read the stored dock side. */
2307
2574
  function readPreviewLayout() {
2308
2575
  try {
@@ -2332,6 +2599,36 @@
2332
2599
  localStorage.setItem(PREVIEW_WIDTH_KEY, String(Math.round(px)));
2333
2600
  } catch {}
2334
2601
  }
2602
+ /** Read the stored word-wrap preference, falling back to wrapping. */
2603
+ function readDiffWrap() {
2604
+ try {
2605
+ return localStorage.getItem(DIFF_WRAP_KEY) !== "0";
2606
+ } catch {
2607
+ return DIFF_WRAP_DEFAULT;
2608
+ }
2609
+ }
2610
+ /** Remember the comparison pane's word-wrap preference across mounts. */
2611
+ function storeDiffWrap(wrapped) {
2612
+ try {
2613
+ localStorage.setItem(DIFF_WRAP_KEY, wrapped ? "1" : "0");
2614
+ } catch {}
2615
+ }
2616
+ /** localStorage key of the change-list view: the flat list or the directory tree. */
2617
+ var CHANGE_VIEW_KEY = "dsh-git-scm.change-view";
2618
+ /** Read the stored change-list view; the flat list is the default. */
2619
+ function readChangeView() {
2620
+ try {
2621
+ return localStorage.getItem(CHANGE_VIEW_KEY) === "tree" ? "tree" : "list";
2622
+ } catch {
2623
+ return "list";
2624
+ }
2625
+ }
2626
+ /** Remember the change-list view across panel mounts. */
2627
+ function storeChangeView(view) {
2628
+ try {
2629
+ localStorage.setItem(CHANGE_VIEW_KEY, view);
2630
+ } catch {}
2631
+ }
2335
2632
  /** Read the stored comparison height, falling back to the default. */
2336
2633
  function readDiffHeight() {
2337
2634
  try {
@@ -2386,6 +2683,26 @@
2386
2683
  localStorage.setItem(COMMIT_RULES_KEY, JSON.stringify(rules));
2387
2684
  } catch {}
2388
2685
  }
2686
+ /** Unified-diff header lines that only repeat what the comparison's own head shows. */
2687
+ var DIFF_HEADER_NOISE = [
2688
+ "diff --git ",
2689
+ "index ",
2690
+ "--- ",
2691
+ "+++ ",
2692
+ "similarity index ",
2693
+ "dissimilarity index "
2694
+ ];
2695
+ /**
2696
+ * Whether one pre-hunk line can be hidden: paths, blob hashes and rename
2697
+ * similarity all repeat the comparison head or the change list, so showing
2698
+ * them only costs rows. Meaningful header lines (new/deleted file, mode
2699
+ * change, rename/copy endpoints, "no newline") are still rendered.
2700
+ * @param {string} line - a unified-diff header line.
2701
+ * @returns {boolean} whether the line is redundant plumbing.
2702
+ */
2703
+ function isDiffHeaderNoise(line) {
2704
+ return DIFF_HEADER_NOISE.some((prefix) => line.startsWith(prefix));
2705
+ }
2389
2706
  /**
2390
2707
  * Parse one unified patch into renderable rows with old/new line numbers.
2391
2708
  * @param {string} text - the patch text.
@@ -2414,7 +2731,7 @@
2414
2731
  continue;
2415
2732
  }
2416
2733
  if (!inHunk) {
2417
- if (line.length > 0) rows.push({
2734
+ if (line.length > 0 && !isDiffHeaderNoise(line)) rows.push({
2418
2735
  type: "meta",
2419
2736
  text: line
2420
2737
  });
@@ -2579,7 +2896,7 @@
2579
2896
  const h = React.createElement;
2580
2897
  const { useCallback, useEffect, useMemo, useRef, useState } = React;
2581
2898
  const icons = createIcons(React);
2582
- const { BranchIcon, CheckIcon, ChevronIcon, CloseIcon, CommitIcon, DiscardIcon, FetchIcon, FileIcon, MergeIcon, MinusIcon, MoreIcon, PlusIcon, PullIcon, PushIcon, RefreshIcon, RemoteIcon, RepoIcon, StashIcon, TagIcon, WarnIcon, ExternalIcon, RowsIcon, ColumnsIcon, MaximizeIcon, RestoreIcon, DockBottomIcon, DockRightIcon, SearchIcon, HistoryIcon, CaretIcon, BackIcon, CopyIcon, TrashIcon, SpinnerIcon, CloudUploadIcon, SparkleIcon } = icons;
2899
+ const { BranchIcon, CheckIcon, ChevronIcon, CloseIcon, CommitIcon, DiscardIcon, FetchIcon, FileIcon, FolderIcon, MergeIcon, MinusIcon, MoreIcon, PlusIcon, PullIcon, PushIcon, RefreshIcon, RemoteIcon, RepoIcon, StashIcon, TagIcon, WarnIcon, ExternalIcon, RowsIcon, TreeIcon, ColumnsIcon, MaximizeIcon, RestoreIcon, DockBottomIcon, DockRightIcon, SearchIcon, HistoryIcon, CaretIcon, BackIcon, CopyIcon, TrashIcon, SpinnerIcon, CloudUploadIcon, SparkleIcon, WrapIcon } = icons;
2583
2900
  const { ContextMenu } = createMenu(React, icons);
2584
2901
  /**
2585
2902
  * Build the error a failed Git call is reported with.
@@ -2634,14 +2951,75 @@
2634
2951
  * @returns {{ dir: string, base: string }} the split path.
2635
2952
  */
2636
2953
  function splitPath(path) {
2637
- const at = Math.max(path.lastIndexOf("/"), path.lastIndexOf("\\"));
2954
+ const trimmed = String(path).replace(/[\\/]+$/, "");
2955
+ const at = Math.max(trimmed.lastIndexOf("/"), trimmed.lastIndexOf("\\"));
2638
2956
  return at < 0 ? {
2639
2957
  dir: "",
2640
- base: path
2958
+ base: trimmed
2641
2959
  } : {
2642
- dir: path.slice(0, at),
2643
- base: path.slice(at + 1)
2960
+ dir: trimmed.slice(0, at),
2961
+ base: trimmed.slice(at + 1)
2962
+ };
2963
+ }
2964
+ /**
2965
+ * Whether a change entry names a directory rather than a file. A Host that
2966
+ * collapses untracked directories reports them with a trailing separator.
2967
+ * @param {string} path - repository-relative change path.
2968
+ * @returns {boolean} whether the entry is a directory.
2969
+ */
2970
+ function isDirectoryEntry(path) {
2971
+ return typeof path === "string" && /[\\/]$/.test(path);
2972
+ }
2973
+ /**
2974
+ * Group changed files into a directory tree.
2975
+ * @param {object[]} files - changed files carrying repository-relative paths.
2976
+ * @returns {object} the root node: `{ dirs: Map, files: object[] }`.
2977
+ */
2978
+ function buildChangeTree(files) {
2979
+ const root = {
2980
+ dirs: /* @__PURE__ */ new Map(),
2981
+ files: []
2644
2982
  };
2983
+ for (const file of files) {
2984
+ const segments = String(file.path).replace(/\\/g, "/").split("/").filter((segment) => segment !== "");
2985
+ let node = root;
2986
+ for (let index = 0; index < segments.length - 1; index += 1) {
2987
+ const name = segments[index];
2988
+ let child = node.dirs.get(name);
2989
+ if (child === void 0) {
2990
+ child = {
2991
+ name,
2992
+ path: segments.slice(0, index + 1).join("/"),
2993
+ dirs: /* @__PURE__ */ new Map(),
2994
+ files: []
2995
+ };
2996
+ node.dirs.set(name, child);
2997
+ }
2998
+ node = child;
2999
+ }
3000
+ node.files.push(file);
3001
+ }
3002
+ return root;
3003
+ }
3004
+ /**
3005
+ * Count the changed files of one directory subtree.
3006
+ * @param {object} node - a node of the change tree.
3007
+ * @returns {number} the number of changed files underneath.
3008
+ */
3009
+ function countTreeFiles(node) {
3010
+ let count = node.files.length;
3011
+ for (const child of node.dirs.values()) count += countTreeFiles(child);
3012
+ return count;
3013
+ }
3014
+ /**
3015
+ * Collect the changed files of one directory subtree.
3016
+ * @param {object} node - a node of the change tree.
3017
+ * @returns {object[]} the changed files underneath.
3018
+ */
3019
+ function collectTreeFiles(node) {
3020
+ const files = [...node.files];
3021
+ for (const child of node.dirs.values()) files.push(...collectTreeFiles(child));
3022
+ return files;
2645
3023
  }
2646
3024
  /**
2647
3025
  * Render a timestamp as a coarse relative time in the active language.
@@ -2724,13 +3102,14 @@
2724
3102
  * @param {object} props - `label`, `onClick`, `disabled`, `busy`, and children.
2725
3103
  * @returns {object} the button.
2726
3104
  */
2727
- function IconButton({ label, onClick, disabled = false, busy = false, className = "", children }) {
3105
+ function IconButton({ label, onClick, disabled = false, busy = false, className = "", pressed = void 0, children }) {
2728
3106
  return h("button", {
2729
3107
  type: "button",
2730
3108
  className: `dgscm-icon-button${busy ? " dgscm-icon-button--spinning" : ""}${className === "" ? "" : ` ${className}`}`,
2731
3109
  title: label,
2732
3110
  "aria-label": label,
2733
3111
  "aria-busy": busy || void 0,
3112
+ "aria-pressed": pressed === void 0 ? void 0 : pressed ? "true" : "false",
2734
3113
  disabled,
2735
3114
  onClick: (event) => {
2736
3115
  event.stopPropagation();
@@ -2802,36 +3181,31 @@
2802
3181
  return { paddingLeft: `${14 + depth * 14}px` };
2803
3182
  }
2804
3183
  /**
2805
- * One change row: status letter, path, and its quick actions.
2806
- * @param {object} props - the change, its group, selection state, handlers, and copy.
3184
+ * One change row: icon, path, quick actions, and its tracking status.
3185
+ * @param {object} props - the change, its group, selection state, handlers, copy,
3186
+ * and the tree depth with whether the directory suffix is shown.
2807
3187
  * @returns {object} the row.
2808
3188
  */
2809
- function ChangeRow({ file, group, selected, disabled, t, onActivate, onToggleSelected, onContextMenu, onQuickStage, onQuickUnstage, onQuickDiscard }) {
3189
+ function ChangeRow({ file, group, selected, disabled, t, depth = 0, showDir = true, onActivate, onContextMenu, onQuickStage, onQuickUnstage, onQuickDiscard }) {
2810
3190
  const { dir, base } = splitPath(file.path);
2811
3191
  const canStage = group !== "staged";
3192
+ const FileGlyph = isDirectoryEntry(file.path) ? FolderIcon : FileIcon;
2812
3193
  return h("div", {
2813
3194
  className: `dgscm-row dgscm-row--file${selected ? " dgscm-row--selected" : ""}`,
2814
3195
  role: "button",
2815
3196
  tabIndex: 0,
2816
3197
  title: t("action.openDiff", { path: file.path }),
3198
+ style: indent(depth),
2817
3199
  onClick: onActivate,
2818
3200
  onKeyDown: activateOnKey(onActivate),
2819
3201
  onContextMenu
2820
- }, h("span", {
2821
- className: "dgscm-row-check",
2822
- onClick: (event) => {
2823
- event.stopPropagation();
2824
- }
2825
- }, h("input", {
2826
- type: "checkbox",
2827
- checked: selected,
2828
- disabled,
2829
- "aria-label": t("action.stageSelected"),
2830
- onChange: () => onToggleSelected()
2831
- })), h("span", { className: `dgscm-row-mark dgscm-status--${STATUS_CLASS[file.status] ?? "modified"}` }, statusLetter(file)), h(FileIcon, {
3202
+ }, showDir === false ? h("span", {
3203
+ className: "dgscm-row-treepad",
3204
+ "aria-hidden": true
3205
+ }) : null, h(FileGlyph, {
2832
3206
  size: 13,
2833
3207
  className: "dgscm-row-glyph"
2834
- }), h("span", { className: "dgscm-row-name" }, base), dir === "" ? null : h("span", { className: "dgscm-row-dir" }, dir), h("div", {
3208
+ }), h("span", { className: "dgscm-row-name" }, base), dir === "" || showDir === false ? null : h("span", { className: "dgscm-row-dir" }, dir), h("span", { className: "dgscm-row-end" }, h("div", {
2835
3209
  className: "dgscm-row-actions",
2836
3210
  onClick: (event) => {
2837
3211
  event.stopPropagation();
@@ -2851,7 +3225,41 @@
2851
3225
  label: t("action.discard", { path: file.path }),
2852
3226
  disabled,
2853
3227
  onClick: onQuickDiscard
2854
- }, h(DiscardIcon, { size: 13 }))));
3228
+ }, h(DiscardIcon, { size: 13 }))), h("span", { className: `dgscm-row-mark dgscm-status--${STATUS_CLASS[file.status] ?? "modified"}` }, statusLetter(file))));
3229
+ }
3230
+ /**
3231
+ * One directory row of the change tree: disclosure, folder glyph, name, hover
3232
+ * actions for the files underneath, and their count. A compacted chain shows
3233
+ * as `parent / child / grandchild`.
3234
+ * @param {object} props - directory identity, depth, disclosure state, file count,
3235
+ * hover actions, handlers, and copy.
3236
+ * @returns {object} the row.
3237
+ */
3238
+ function ChangeDirRow({ name, path, depth, open, count, t, actions, onToggle }) {
3239
+ return h("div", {
3240
+ className: "dgscm-row dgscm-row--dir",
3241
+ role: "button",
3242
+ tabIndex: 0,
3243
+ "aria-expanded": open,
3244
+ title: path,
3245
+ style: indent(depth),
3246
+ onClick: onToggle,
3247
+ onKeyDown: activateOnKey(onToggle)
3248
+ }, h("span", { className: "dgscm-row-chevron" }, h(ChevronIcon, { open })), h(FolderIcon, {
3249
+ size: 13,
3250
+ className: "dgscm-row-glyph dgscm-row-glyph--folder"
3251
+ }), h("span", { className: "dgscm-row-name" }, name), h("span", { className: "dgscm-row-end" }, h("div", {
3252
+ className: "dgscm-row-actions",
3253
+ onClick: (event) => {
3254
+ event.stopPropagation();
3255
+ },
3256
+ onKeyDown: (event) => {
3257
+ event.stopPropagation();
3258
+ }
3259
+ }, actions), h("span", {
3260
+ className: "dgscm-row-note",
3261
+ title: t("tree.fileCount", { n: count })
3262
+ }, String(count))));
2855
3263
  }
2856
3264
  /**
2857
3265
  * One branch row: disclosure, name, tracking state, quick checkout, and its
@@ -2902,6 +3310,47 @@
2902
3310
  }, "▲+") : null, branch.current === true ? h("span", { className: "dgscm-branch-flag dgscm-branch-flag--current" }, h(CheckIcon, { size: 12 })) : null), date === "" ? null : h("span", { className: "dgscm-row-note" }, `· ${date}`)));
2903
3311
  }
2904
3312
  /**
3313
+ * One worktree row: checkout directory, branch (or detached HEAD), state, and
3314
+ * its menu. Clicking a non-current checkout asks to move the Session there.
3315
+ * @param {object} props - the worktree, path label, handlers, and copy.
3316
+ * @returns {object} the row.
3317
+ */
3318
+ function WorktreeRow({ worktree, pathLabel, t, onSwitch, onMenu, onContextMenu }) {
3319
+ const current = worktree.current === true;
3320
+ const missing = worktree.prunable === true;
3321
+ const name = worktree.branch !== null && worktree.branch !== void 0 ? worktree.branch : worktree.detached === true ? `${t("worktree.detached")} ${worktree.head ?? ""}`.trim() : worktree.bare === true ? t("worktree.bare") : worktree.name;
3322
+ const activate = () => {
3323
+ if (current || missing) return;
3324
+ onSwitch(worktree);
3325
+ };
3326
+ return h("div", {
3327
+ className: `dgscm-row dgscm-row--clickable dgscm-row--worktree${current ? " dgscm-row--current" : ""}${missing ? " dgscm-row--prunable" : ""}`,
3328
+ role: "button",
3329
+ tabIndex: 0,
3330
+ title: current ? `${worktree.path} — ${t("worktree.current")}` : t("worktree.switchTooltip", { path: worktree.path }),
3331
+ onClick: activate,
3332
+ onKeyDown: activateOnKey(activate),
3333
+ onContextMenu
3334
+ }, h("span", {
3335
+ className: "dgscm-row-chevron",
3336
+ "aria-hidden": "true"
3337
+ }), h("span", { className: "dgscm-row-glyph dgscm-row-glyph--worktree" }, h(FolderIcon, { size: 13 })), h("span", { className: `dgscm-row-name${current ? " dgscm-row-name--current" : ""}` }, name), h("span", { className: "dgscm-row-dir" }, pathLabel), worktree.locked === true ? h("span", {
3338
+ className: "dgscm-row-note dgscm-row-note--warn",
3339
+ title: worktree.lockReason === null || worktree.lockReason === void 0 ? t("worktree.locked") : t("worktree.lockedReason", { reason: worktree.lockReason })
3340
+ }, t("worktree.locked")) : null, h("div", {
3341
+ className: "dgscm-row-actions",
3342
+ onClick: (event) => {
3343
+ event.stopPropagation();
3344
+ }
3345
+ }, h(IconButton, {
3346
+ label: t("action.more"),
3347
+ onClick: onMenu
3348
+ }, h(MoreIcon, { size: 13 }))), h("span", { className: "dgscm-row-end" }, missing ? h("span", {
3349
+ className: "dgscm-worktree-flag dgscm-worktree-flag--missing",
3350
+ title: worktree.pruneReason === null || worktree.pruneReason === void 0 ? t("worktree.prunable") : worktree.pruneReason
3351
+ }, h(WarnIcon, { size: 12 })) : null, current ? h("span", { className: "dgscm-branch-flag dgscm-branch-flag--current" }, h(CheckIcon, { size: 12 })) : null));
3352
+ }
3353
+ /**
2905
3354
  * One commit row: disclosure, hash, subject, and author/time.
2906
3355
  * @param {object} props - the commit, depth, disclosure state, handlers, and copy.
2907
3356
  * @returns {object} the row.
@@ -2926,7 +3375,7 @@
2926
3375
  function CommitFileRow({ file, depth, t, onOpen, onContextMenu }) {
2927
3376
  const { dir, base } = splitPath(file.path);
2928
3377
  return h("div", {
2929
- className: "dgscm-row dgscm-row--file",
3378
+ className: "dgscm-row dgscm-row--file dgscm-row--commit-file",
2930
3379
  style: indent(depth),
2931
3380
  role: "button",
2932
3381
  tabIndex: 0,
@@ -2934,10 +3383,10 @@
2934
3383
  onClick: onOpen,
2935
3384
  onKeyDown: activateOnKey(onOpen),
2936
3385
  onContextMenu
2937
- }, h("span", { className: `dgscm-row-mark dgscm-status--${STATUS_CLASS[file.status] ?? "modified"}` }, statusLetter(file)), h(FileIcon, {
3386
+ }, h(FileIcon, {
2938
3387
  size: 13,
2939
3388
  className: "dgscm-row-glyph"
2940
- }), h("span", { className: "dgscm-row-name" }, base), dir === "" ? null : h("span", { className: "dgscm-row-dir" }, dir));
3389
+ }), h("span", { className: "dgscm-row-name" }, base), dir === "" ? null : h("span", { className: "dgscm-row-dir" }, dir), h("span", { className: "dgscm-row-end" }, h("span", { className: `dgscm-row-mark dgscm-status--${STATUS_CLASS[file.status] ?? "modified"}` }, statusLetter(file))));
2941
3390
  }
2942
3391
  /**
2943
3392
  * One remote row: disclosure, name, and its URL.
@@ -2946,7 +3395,7 @@
2946
3395
  */
2947
3396
  function RemoteRow({ remote, branchCount, open, t, onToggle, onContextMenu }) {
2948
3397
  return h("div", {
2949
- className: "dgscm-row dgscm-row--clickable",
3398
+ className: "dgscm-row dgscm-row--clickable dgscm-row--remote",
2950
3399
  role: "button",
2951
3400
  tabIndex: 0,
2952
3401
  title: remote.url,
@@ -3080,14 +3529,14 @@
3080
3529
  * @param {object} props - the loaded history, dock controls, and copy.
3081
3530
  * @returns {object} the history pane.
3082
3531
  */
3083
- function HistoryPane({ state, layout, onLayout, maximized, onMaximize, onClose, onOpenCommit, t }) {
3532
+ function HistoryPane({ state, layout, layoutFixed = false, onLayout, maximized, onMaximize, onClose, onOpenCommit, t }) {
3084
3533
  return h("div", { className: "dgscm-history" }, h("div", { className: "dgscm-diff-head" }, h(IconButton, {
3085
3534
  label: t("diff.close"),
3086
3535
  onClick: onClose
3087
3536
  }, h(CloseIcon, { size: 14 })), h("span", { className: "dgscm-badge dgscm-badge--brand" }, t("history.badge")), h("span", {
3088
3537
  className: "dgscm-diff-path",
3089
3538
  title: state.path
3090
- }, state.path), h("span", { className: "dgscm-diff-stats" }, state.phase === "ready" ? String(state.commits.length) : ""), h(IconButton, {
3539
+ }, state.path), h("span", { className: "dgscm-diff-stats" }, state.phase === "ready" ? String(state.commits.length) : ""), layoutFixed ? null : h(IconButton, {
3091
3540
  label: layout === "right" ? t("action.dockBottom") : t("action.dockRight"),
3092
3541
  onClick: () => onLayout(layout === "right" ? "bottom" : "right")
3093
3542
  }, layout === "right" ? h(DockBottomIcon, { size: 14 }) : h(DockRightIcon, { size: 14 })), h(IconButton, {
@@ -3110,7 +3559,7 @@
3110
3559
  * @param {object} props - the loaded review, dock controls, and copy.
3111
3560
  * @returns {object} the commit review pane.
3112
3561
  */
3113
- function ReviewPane({ review, layout, onLayout, maximized, onMaximize, onClose, onOpenFile, t }) {
3562
+ function ReviewPane({ review, layout, layoutFixed = false, onLayout, maximized, onMaximize, onClose, onOpenFile, t }) {
3114
3563
  const [query, setQuery] = useState("");
3115
3564
  const [filterOpen, setFilterOpen] = useState(false);
3116
3565
  const filterRef = useRef(null);
@@ -3131,7 +3580,7 @@
3131
3580
  setFilterOpen((current) => !current);
3132
3581
  if (filterOpen) setQuery("");
3133
3582
  }
3134
- }, h(SearchIcon, { size: 14 })), h(IconButton, {
3583
+ }, h(SearchIcon, { size: 14 })), layoutFixed ? null : h(IconButton, {
3135
3584
  label: layout === "right" ? t("action.dockBottom") : t("action.dockRight"),
3136
3585
  onClick: () => onLayout(layout === "right" ? "bottom" : "right")
3137
3586
  }, layout === "right" ? h(DockBottomIcon, { size: 14 }) : h(DockRightIcon, { size: 14 })), h(IconButton, {
@@ -3155,10 +3604,10 @@
3155
3604
  className: "dgscm-review-row",
3156
3605
  title: t("action.openDiff", { path: file.path }),
3157
3606
  onClick: () => onOpenFile(file)
3158
- }, h("span", { className: `dgscm-row-mark dgscm-status--${STATUS_CLASS[file.status] ?? "modified"}` }, statusLetter(file)), h(FileIcon, {
3607
+ }, h(FileIcon, {
3159
3608
  size: 13,
3160
3609
  className: "dgscm-row-glyph"
3161
- }), h("span", { className: "dgscm-review-path" }, base), dir === "" ? null : h("span", { className: "dgscm-review-dir" }, dir), h("span", { className: "dgscm-review-counts" }, file.additions === null || file.additions === void 0 ? null : h("span", { className: "dgscm-review-add" }, `+${file.additions}`), file.deletions === null || file.deletions === void 0 ? null : h("span", { className: "dgscm-review-del" }, `−${file.deletions}`)));
3610
+ }), h("span", { className: "dgscm-review-path" }, base), dir === "" ? null : h("span", { className: "dgscm-review-dir" }, dir), h("span", { className: "dgscm-review-end" }, h("span", { className: `dgscm-row-mark dgscm-status--${STATUS_CLASS[file.status] ?? "modified"}` }, statusLetter(file)), h("span", { className: "dgscm-review-counts" }, file.additions === null || file.additions === void 0 ? null : h("span", { className: "dgscm-review-add" }, `+${file.additions}`), file.deletions === null || file.deletions === void 0 ? null : h("span", { className: "dgscm-review-del" }, `−${file.deletions}`))));
3162
3611
  }) : null));
3163
3612
  }
3164
3613
  /**
@@ -3279,6 +3728,57 @@
3279
3728
  }, prompt.submitLabel))));
3280
3729
  }
3281
3730
  /**
3731
+ * The New Worktree dialog: branch name plus the directory the host will use.
3732
+ * @param {object} props - dialog state, base branch, handlers, and copy.
3733
+ * @returns {object} the overlay.
3734
+ */
3735
+ function WorktreeDialog({ state, base, onChange, onCancel, onSubmit, t }) {
3736
+ const inputRef = useRef(null);
3737
+ useEffect(() => {
3738
+ inputRef.current?.focus();
3739
+ }, []);
3740
+ useEffect(() => {
3741
+ const onKeyDown = (event) => {
3742
+ if (event.key === "Escape" && !state.submitting) onCancel();
3743
+ };
3744
+ window.addEventListener("keydown", onKeyDown);
3745
+ return () => window.removeEventListener("keydown", onKeyDown);
3746
+ }, [onCancel, state.submitting]);
3747
+ const slug = worktreeSlugOf(state.branch);
3748
+ return h("div", {
3749
+ className: "dgscm-modal",
3750
+ onClick: state.submitting ? void 0 : onCancel
3751
+ }, h("div", {
3752
+ className: "dgscm-modal-card dgscm-worktree-dialog",
3753
+ role: "dialog",
3754
+ "aria-modal": "true",
3755
+ onClick: (event) => event.stopPropagation(),
3756
+ onKeyDown: (event) => {
3757
+ if (event.key === "Enter" && !event.shiftKey) {
3758
+ event.preventDefault();
3759
+ if (!state.submitting && slug.length > 0) onSubmit();
3760
+ }
3761
+ }
3762
+ }, h("div", { className: "dgscm-modal-title" }, t("worktree.dialogTitle")), h("div", { className: "dgscm-modal-field" }, h("label", { className: "dgscm-modal-label" }, t("worktree.branchField")), h("input", {
3763
+ ref: inputRef,
3764
+ className: "dgscm-input",
3765
+ value: state.branch,
3766
+ placeholder: t("worktree.branchPlaceholder"),
3767
+ disabled: state.submitting,
3768
+ onChange: (event) => onChange(event.target.value)
3769
+ })), slug.length === 0 ? null : h("div", { className: "dgscm-worktree-preview" }, t("worktree.directoryPreview", { slug })), h("div", { className: "dgscm-modal-note" }, t("worktree.baseNote", { base })), state.error === null || state.error === void 0 ? null : h("div", { className: "dgscm-modal-error" }, state.error), h("div", { className: "dgscm-modal-actions" }, h("button", {
3770
+ type: "button",
3771
+ className: "dgscm-button dgscm-button--quiet",
3772
+ disabled: state.submitting,
3773
+ onClick: onCancel
3774
+ }, t("prompt.cancel")), h("button", {
3775
+ type: "button",
3776
+ className: "dgscm-button dgscm-button--primary",
3777
+ disabled: state.submitting || slug.length === 0,
3778
+ onClick: () => onSubmit()
3779
+ }, state.submitting ? t("toast.busy") : t("worktree.create")))));
3780
+ }
3781
+ /**
3282
3782
  * The GitHub publish dialog: repository name plus private and public choices.
3283
3783
  * @param {object} props - dialog state, rename/publish/cancel handlers, and copy.
3284
3784
  * @returns {object} the overlay.
@@ -3341,12 +3841,15 @@
3341
3841
  * longer than the collapse threshold render as an expandable marker, the way
3342
3842
  * the host's own review views fold context, and every row carries the old and
3343
3843
  * new line numbers it names. The search box walks every match in the visible
3344
- * rows and scrolls the current one into view.
3345
- * @param {object} props - the opened view, display mode, dock controls, and copy.
3844
+ * rows and scrolls the current one into view. The title row is a disclosure
3845
+ * control that folds the body; a narrow column starts folded and a fullscreen
3846
+ * Sidebar opens it docked right.
3847
+ * @param {object} props - the opened view, display mode, dock controls, collapse state, and copy.
3346
3848
  * @returns {object} the comparison pane.
3347
3849
  */
3348
- function DiffPane({ view, mode, onMode, onClose, onNative, onMaximize, maximized, layout, onLayout, onBack, backLabel, searchSignal = 0, t }) {
3850
+ function DiffPane({ view, mode, onMode, onClose, onMaximize, maximized, layout, layoutFixed = false, onLayout, onBack, backLabel, searchSignal = 0, collapsed = false, onToggleCollapsed, t }) {
3349
3851
  const [expanded, setExpanded] = useState(() => /* @__PURE__ */ new Set());
3852
+ const [wrap, setWrap] = useState(readDiffWrap);
3350
3853
  const [searchOpen, setSearchOpen] = useState(false);
3351
3854
  const [query, setQuery] = useState("");
3352
3855
  const [activeMatch, setActiveMatch] = useState(0);
@@ -3463,6 +3966,9 @@
3463
3966
  setQuery("");
3464
3967
  setActiveMatch(0);
3465
3968
  };
3969
+ useEffect(() => {
3970
+ if (collapsed) closeSearch();
3971
+ }, [collapsed]);
3466
3972
  /** Render one line with the query's matches highlighted. */
3467
3973
  const highlighted = (entryKey, text) => {
3468
3974
  const found = matches.length === 0 ? [] : matches.filter((match) => match.key === entryKey);
@@ -3516,35 +4022,53 @@
3516
4022
  key,
3517
4023
  className: "dgscm-diffpair"
3518
4024
  }, diffHalf(pair.left, "left", `${key}-l`), diffHalf(pair.right, "right", `${key}-r`));
4025
+ /** Flip the pane's word-wrap preference and persist it. */
4026
+ const toggleWrap = () => {
4027
+ setWrap((current) => {
4028
+ const next = !current;
4029
+ storeDiffWrap(next);
4030
+ return next;
4031
+ });
4032
+ };
3519
4033
  const matchLabel = query.trim().length === 0 ? "" : matches.length === 0 ? t("diff.noMatches") : t("diff.matchPosition", {
3520
4034
  index: activeMatch + 1,
3521
4035
  total: matches.length
3522
4036
  });
3523
- return h("div", { className: "dgscm-diff" }, h("div", { className: "dgscm-diff-head" }, onBack === void 0 ? null : h(IconButton, {
4037
+ return h("div", { className: "dgscm-diff" }, h("div", { className: `dgscm-diff-head${collapsed ? " dgscm-diff-head--collapsed" : ""}` }, onBack === void 0 ? null : h(IconButton, {
3524
4038
  label: backLabel,
3525
4039
  onClick: onBack
3526
4040
  }, h(BackIcon, { size: 14 })), h(IconButton, {
3527
4041
  label: t("diff.close"),
3528
4042
  onClick: onClose
3529
- }, h(CloseIcon, { size: 14 })), view.source.kind === "commit" ? h("span", { className: "dgscm-badge dgscm-badge--brand" }, t("diff.commitLabel", { short: view.source.short ?? "" })) : null, view.source.kind === "stash" ? h("span", { className: "dgscm-badge dgscm-badge--brand" }, `stash@{${view.source.index}}`) : null, h("span", {
4043
+ }, h(CloseIcon, { size: 14 })), view.source.kind === "commit" ? h("span", { className: "dgscm-badge dgscm-badge--brand" }, t("diff.commitLabel", { short: view.source.short ?? "" })) : null, view.source.kind === "stash" ? h("span", { className: "dgscm-badge dgscm-badge--brand" }, `stash@{${view.source.index}}`) : null, h("button", {
4044
+ type: "button",
4045
+ className: "dgscm-diff-title",
4046
+ "aria-expanded": collapsed ? "false" : "true",
4047
+ title: collapsed ? t("diff.expandPanel") : t("diff.collapsePanel"),
4048
+ onClick: onToggleCollapsed
4049
+ }, h(ChevronIcon, {
4050
+ open: !collapsed,
4051
+ size: 12
4052
+ }), h("span", {
3530
4053
  className: "dgscm-diff-path",
3531
4054
  title: view.path
3532
- }, view.path), diff !== null && diff !== void 0 ? h("span", { className: "dgscm-diff-stats" }, h("span", { className: "dgscm-diff-added" }, `+${diff.added}`), h("span", { className: "dgscm-diff-deleted" }, `−${diff.deleted}`)) : null, h(IconButton, {
4055
+ }, view.path)), diff !== null && diff !== void 0 ? h("span", { className: "dgscm-diff-stats" }, h("span", { className: "dgscm-diff-added" }, `+${diff.added}`), h("span", { className: "dgscm-diff-deleted" }, `−${diff.deleted}`)) : null, collapsed ? null : h(React.Fragment, null, h(IconButton, {
3533
4056
  label: `${t("action.search")} (${searchKey})`,
3534
4057
  onClick: () => searchOpen ? closeSearch() : setSearchOpen(true)
3535
4058
  }, h(SearchIcon, { size: 14 })), h(IconButton, {
3536
4059
  label: mode === "split" ? t("diff.modeUnified") : t("diff.modeSplit"),
3537
4060
  onClick: () => onMode(mode === "split" ? "unified" : "split")
3538
- }, mode === "split" ? h(RowsIcon, { size: 14 }) : h(ColumnsIcon, { size: 14 })), onNative === void 0 ? null : h(IconButton, {
3539
- label: t("action.openNative"),
3540
- onClick: onNative
3541
- }, h(ExternalIcon, { size: 14 })), h(IconButton, {
4061
+ }, mode === "split" ? h(RowsIcon, { size: 14 }) : h(ColumnsIcon, { size: 14 })), h(IconButton, {
4062
+ label: wrap ? t("diff.wrapOff") : t("diff.wrapOn"),
4063
+ pressed: wrap,
4064
+ onClick: toggleWrap
4065
+ }, h(WrapIcon, { size: 14 })), layoutFixed ? null : h(IconButton, {
3542
4066
  label: layout === "right" ? t("action.dockBottom") : t("action.dockRight"),
3543
4067
  onClick: () => onLayout(layout === "right" ? "bottom" : "right")
3544
4068
  }, layout === "right" ? h(DockBottomIcon, { size: 14 }) : h(DockRightIcon, { size: 14 })), h(IconButton, {
3545
4069
  label: maximized ? t("diff.restore") : t("diff.maximize"),
3546
4070
  onClick: onMaximize
3547
- }, maximized ? h(RestoreIcon, { size: 14 }) : h(MaximizeIcon, { size: 14 }))), searchOpen ? h("div", { className: "dgscm-diff-search" }, h("input", {
4071
+ }, maximized ? h(RestoreIcon, { size: 14 }) : h(MaximizeIcon, { size: 14 })))), h(React.Fragment, null, searchOpen ? h("div", { className: "dgscm-diff-search" }, h("input", {
3548
4072
  ref: searchRef,
3549
4073
  className: "dgscm-diff-search-input",
3550
4074
  value: query,
@@ -3580,18 +4104,21 @@
3580
4104
  onClick: closeSearch
3581
4105
  }, h(CloseIcon, { size: 12 }))) : null, h("div", {
3582
4106
  ref: bodyRef,
3583
- className: `dgscm-diff-body${mode === "split" ? " dgscm-diff-body--split" : ""}`
4107
+ className: `dgscm-diff-body${mode === "split" ? " dgscm-diff-body--split" : ""}${wrap ? "" : " dgscm-diff-body--nowrap"}`
3584
4108
  }, view.loading === true ? h("div", { className: "dgscm-diff-note" }, t("diff.loading")) : null, view.error !== null && view.error !== void 0 ? h("div", {
3585
4109
  className: "dgscm-diff-note",
3586
4110
  style: { color: "var(--dsw-alias-state-error-primary)" }
3587
- }, view.error) : null, view.loading !== true && view.error === null && diff !== null && diff !== void 0 ? h(React.Fragment, null, diff.binary === true ? h("div", { className: "dgscm-diff-note" }, t("diff.binary")) : null, diff.tooLarge === true ? h("div", { className: "dgscm-diff-note" }, t("diff.tooLarge")) : null, diff.binary !== true && rows.length === 0 ? h("div", { className: "dgscm-diff-note" }, t("diff.empty")) : null, diff.binary !== true ? mode === "split" ? pairs.map((pair, index) => splitRow(pair, `pair-${index}`)) : rows.map((row, index) => unifiedRow(row, `row-${index}`)) : null, truncated ? h("div", { className: "dgscm-diff-note" }, t("diff.tooLarge")) : null) : null));
4111
+ }, view.error) : null, view.loading !== true && view.error === null && diff !== null && diff !== void 0 ? h(React.Fragment, null, diff.binary === true ? h("div", { className: "dgscm-diff-note" }, t("diff.binary")) : null, diff.tooLarge === true ? h("div", { className: "dgscm-diff-note" }, t("diff.tooLarge")) : null, diff.binary !== true && rows.length === 0 ? h("div", { className: "dgscm-diff-note" }, t("diff.empty")) : null, diff.binary !== true ? mode === "split" ? pairs.map((pair, index) => splitRow(pair, `pair-${index}`)) : rows.map((row, index) => unifiedRow(row, `row-${index}`)) : null, truncated ? h("div", { className: "dgscm-diff-note" }, t("diff.tooLarge")) : null) : null)));
3588
4112
  }
3589
4113
  /**
3590
4114
  * The right-Sidebar source-control page.
3591
4115
  * @param {object} props - the tab's `sessionId` and localized `t`.
3592
4116
  * @returns {object} the panel.
3593
4117
  */
3594
- function ScmPanel({ sessionId, t, openNativeChanges, openFile, localeId }) {
4118
+ function ScmPanel({ sessionId, t, openFile, localeId, useTabInfo }) {
4119
+ const tabInfo = typeof useTabInfo === "function" ? useTabInfo() : void 0;
4120
+ const tabActions = tabInfo?.tab?.actions;
4121
+ const sidebarFullscreen = tabInfo?.sidebar?.fullscreen === true;
3595
4122
  const [phase, setPhase] = useState("loading");
3596
4123
  const [summary, setSummary] = useState(null);
3597
4124
  const [failure, setFailure] = useState(null);
@@ -3608,11 +4135,14 @@
3608
4135
  groupRepositories: true,
3609
4136
  staged: true,
3610
4137
  changes: true,
4138
+ worktrees: true,
3611
4139
  branches: true,
3612
4140
  remotes: false,
3613
4141
  stashes: false,
3614
4142
  tags: false
3615
4143
  });
4144
+ const [changeView, setChangeView] = useState(readChangeView);
4145
+ const [collapsedDirs, setCollapsedDirs] = useState({});
3616
4146
  const [nodes, setNodes] = useState({});
3617
4147
  const [selection, setSelection] = useState({
3618
4148
  group: null,
@@ -3625,9 +4155,12 @@
3625
4155
  const [dragging, setDragging] = useState(false);
3626
4156
  const [previewLayout, setPreviewLayout] = useState(readPreviewLayout);
3627
4157
  const [previewWidth, setPreviewWidth] = useState(readPreviewWidth);
4158
+ const [comparisonCollapsed, setComparisonCollapsed] = useState(false);
4159
+ const [narrowPreview, setNarrowPreview] = useState(false);
3628
4160
  const [branchPicker, setBranchPicker] = useState(null);
3629
4161
  const [tip, setTip] = useState(null);
3630
4162
  const [githubPublish, setGithubPublish] = useState(null);
4163
+ const [worktreeDialog, setWorktreeDialog] = useState(null);
3631
4164
  const [generating, setGenerating] = useState(false);
3632
4165
  const [commitRules, setCommitRules] = useState(readCommitRules);
3633
4166
  const [initializing, setInitializing] = useState(false);
@@ -3636,6 +4169,10 @@
3636
4169
  const [review, setReview] = useState(null);
3637
4170
  const [searchSignal, setSearchSignal] = useState(0);
3638
4171
  const [refreshing, setRefreshing] = useState(false);
4172
+ const autoLayout = sidebarFullscreen && !narrowPreview ? "right" : narrowPreview ? "bottom" : previewLayout;
4173
+ const collapsedPane = comparisonCollapsed && view !== null;
4174
+ const paneLayout = collapsedPane ? "bottom" : autoLayout;
4175
+ const layoutFixed = sidebarFullscreen || narrowPreview;
3639
4176
  const loadSeq = useRef(0);
3640
4177
  const busyRef = useRef(false);
3641
4178
  const nodesRef = useRef(nodes);
@@ -3651,6 +4188,10 @@
3651
4188
  const generateLongPressRef = useRef(false);
3652
4189
  const commitRulesRef = useRef(commitRules);
3653
4190
  const amendBackupRef = useRef(null);
4191
+ const menuAnchorRef = useRef({
4192
+ x: 0,
4193
+ y: 0
4194
+ });
3654
4195
  useEffect(() => {
3655
4196
  nodesRef.current = nodes;
3656
4197
  }, [nodes]);
@@ -3663,6 +4204,26 @@
3663
4204
  useEffect(() => {
3664
4205
  commitRulesRef.current = commitRules;
3665
4206
  }, [commitRules]);
4207
+ useEffect(() => {
4208
+ const node = rootRef.current;
4209
+ if (node === null) return void 0;
4210
+ const measure = () => {
4211
+ const width = node.clientWidth;
4212
+ if (width > 0) setNarrowPreview(width < PREVIEW_NARROW_WIDTH);
4213
+ };
4214
+ measure();
4215
+ if (typeof ResizeObserver === "function") {
4216
+ const observer = new ResizeObserver(measure);
4217
+ observer.observe(node);
4218
+ return () => observer.disconnect();
4219
+ }
4220
+ window.addEventListener("resize", measure);
4221
+ return () => window.removeEventListener("resize", measure);
4222
+ }, [phase]);
4223
+ useEffect(() => {
4224
+ if (narrowPreview) setComparisonCollapsed(true);
4225
+ else if (sidebarFullscreen) setComparisonCollapsed(false);
4226
+ }, [narrowPreview, sidebarFullscreen]);
3666
4227
  useEffect(() => {
3667
4228
  if (phase !== "ready" || !publishAfterInit) return void 0;
3668
4229
  setPublishAfterInit(false);
@@ -3719,6 +4280,7 @@
3719
4280
  setMessage("");
3720
4281
  setAmend(false);
3721
4282
  setNodes({});
4283
+ setCollapsedDirs({});
3722
4284
  setSelection({
3723
4285
  group: null,
3724
4286
  paths: [],
@@ -3726,9 +4288,11 @@
3726
4288
  });
3727
4289
  setHistory(null);
3728
4290
  setReview(null);
4291
+ setComparisonCollapsed(false);
3729
4292
  setBranchPicker(null);
3730
4293
  setTip(null);
3731
4294
  setGithubPublish(null);
4295
+ setWorktreeDialog(null);
3732
4296
  setGenerating(false);
3733
4297
  setInitializing(false);
3734
4298
  setPublishAfterInit(false);
@@ -3771,22 +4335,23 @@
3771
4335
  const focused = document.activeElement;
3772
4336
  if (!(focused !== null && focused !== void 0 && root.contains(focused)) && !pointerInsideRef.current) return;
3773
4337
  event.preventDefault();
4338
+ if (collapsedPane) setComparisonCollapsed(false);
3774
4339
  setSearchSignal((current) => current + 1);
3775
4340
  };
3776
4341
  document.addEventListener("keydown", onKeyDown);
3777
4342
  return () => document.removeEventListener("keydown", onKeyDown);
3778
- }, [view]);
4343
+ }, [view, collapsedPane]);
3779
4344
  useEffect(() => {
3780
4345
  if (!dragging) return void 0;
3781
4346
  const previousCursor = document.body.style.cursor;
3782
4347
  const previousSelect = document.body.style.userSelect;
3783
- document.body.style.cursor = previewLayout === "right" ? "col-resize" : "row-resize";
4348
+ document.body.style.cursor = paneLayout === "right" ? "col-resize" : "row-resize";
3784
4349
  document.body.style.userSelect = "none";
3785
4350
  return () => {
3786
4351
  document.body.style.cursor = previousCursor;
3787
4352
  document.body.style.userSelect = previousSelect;
3788
4353
  };
3789
- }, [dragging, previewLayout]);
4354
+ }, [dragging, paneLayout]);
3790
4355
  useEffect(() => {
3791
4356
  if (notice === null || notice.action !== void 0) return void 0;
3792
4357
  const timer = setTimeout(() => setNotice(null), notice.tone === "error" ? 9e3 : 3500);
@@ -3913,6 +4478,21 @@
3913
4478
  [key]: !current[key]
3914
4479
  }));
3915
4480
  }, []);
4481
+ /** Switch the change sections between the flat list and the directory tree. */
4482
+ const toggleChangeView = useCallback(() => {
4483
+ setChangeView((current) => {
4484
+ const next = current === "list" ? "tree" : "list";
4485
+ storeChangeView(next);
4486
+ return next;
4487
+ });
4488
+ }, []);
4489
+ /** Collapse or expand one directory of the change tree. */
4490
+ const toggleChangeDir = useCallback((key) => {
4491
+ setCollapsedDirs((current) => ({
4492
+ ...current,
4493
+ [key]: current[key] !== true
4494
+ }));
4495
+ }, []);
3916
4496
  /**
3917
4497
  * Run one mutating Git operation, then re-read the snapshot.
3918
4498
  * @param {string} operation - the Host operation name.
@@ -3971,33 +4551,18 @@
3971
4551
  onConfirm
3972
4552
  });
3973
4553
  }, []);
3974
- /**
3975
- * Hand one working-tree file to the app's own changes view (the rich
3976
- * side-by-side diff), scrolled to that file. A profile without that view
3977
- * answers false, which this reports instead of failing silently.
3978
- * @param {string} path - repository-relative path.
3979
- */
3980
- const openNative = useCallback((path) => {
3981
- if (typeof openNativeChanges !== "function") {
3982
- setNotice({
3983
- tone: "error",
3984
- title: t("toast.nativeUnavailable")
3985
- });
3986
- return;
3987
- }
3988
- if (openNativeChanges(path) !== true) setNotice({
3989
- tone: "error",
3990
- title: t("toast.nativeUnavailable")
3991
- });
3992
- }, [openNativeChanges, t]);
3993
4554
  /** Open one working-tree file in the app's own code view (line numbers + highlighting). */
3994
4555
  const openFileAt = useCallback((path) => {
3995
- if (typeof openFile === "function" && openFile(path) === true) return;
4556
+ if (typeof openFile === "function" && openFile(path, tabActions) === true) return;
3996
4557
  setNotice({
3997
4558
  tone: "error",
3998
4559
  title: t("toast.fileUnavailable")
3999
4560
  });
4000
- }, [openFile, t]);
4561
+ }, [
4562
+ openFile,
4563
+ t,
4564
+ tabActions
4565
+ ]);
4001
4566
  /** Copy text and report the outcome. */
4002
4567
  const copy = useCallback(async (text) => {
4003
4568
  const ok = await copyText(text);
@@ -4016,14 +4581,40 @@
4016
4581
  anchor: null
4017
4582
  });
4018
4583
  }, []);
4019
- /** Open the context menu at the pointer. */
4584
+ /** Open the context menu at the pointer; remembers the anchor for its submenus. */
4020
4585
  const openMenu = useCallback((event, items) => {
4021
- event.preventDefault();
4022
- event.stopPropagation();
4586
+ event?.preventDefault?.();
4587
+ event?.stopPropagation?.();
4588
+ const position = {
4589
+ x: event?.clientX ?? 0,
4590
+ y: event?.clientY ?? 0
4591
+ };
4592
+ menuAnchorRef.current = position;
4593
+ setMenu({
4594
+ ...position,
4595
+ items: items.filter((item) => item !== void 0)
4596
+ });
4597
+ }, []);
4598
+ /** Open a menu at an already measured anchor, replacing the one on screen. */
4599
+ const openMenuAt = useCallback((position, items) => {
4600
+ setMenu({
4601
+ x: position.x,
4602
+ y: position.y,
4603
+ items: items.filter((item) => item !== void 0)
4604
+ });
4605
+ }, []);
4606
+ /** Open a menu directly under one control, the way a split button's chevron does. */
4607
+ const openMenuBelow = useCallback((element, items) => {
4608
+ const rect = typeof element?.getBoundingClientRect === "function" ? element.getBoundingClientRect() : null;
4609
+ const position = rect === null ? menuAnchorRef.current : {
4610
+ x: rect.left,
4611
+ y: rect.bottom + 2
4612
+ };
4613
+ menuAnchorRef.current = position;
4023
4614
  setMenu({
4024
- x: event.clientX,
4025
- y: event.clientY,
4026
- items: items.filter((item) => item !== void 0 && item !== null)
4615
+ x: position.x,
4616
+ y: position.y,
4617
+ items: items.filter((item) => item !== void 0)
4027
4618
  });
4028
4619
  }, []);
4029
4620
  /** Open one working-tree file's diff. */
@@ -4391,12 +4982,48 @@
4391
4982
  run,
4392
4983
  t
4393
4984
  ]);
4394
- /** Initialize a repository in the Session directory, then let the panel read it. */
4395
- const initializeRepository = async () => {
4396
- if (initializing) return;
4397
- setInitializing(true);
4398
- try {
4399
- await callGit(sessionId, "action", { operation: "initRepository" });
4985
+ /**
4986
+ * The commit button's action: with nothing staged it stages the tracked
4987
+ * changes first (the Zed "Commit Tracked" behavior), then commits them.
4988
+ * @returns {Promise<void>} settles after the attempt.
4989
+ */
4990
+ const commitTracked = useCallback(async () => {
4991
+ if (message.trim().length === 0) {
4992
+ setNotice({
4993
+ tone: "error",
4994
+ title: t("toast.failed"),
4995
+ detail: t("commit.noMessage")
4996
+ });
4997
+ return;
4998
+ }
4999
+ const snapshot = summary?.changes ?? {};
5000
+ if ((Array.isArray(snapshot.conflicted) ? snapshot.conflicted : []).length > 0) {
5001
+ setNotice({
5002
+ tone: "error",
5003
+ title: t("toast.failed"),
5004
+ detail: t("commit.resolveConflicts")
5005
+ });
5006
+ return;
5007
+ }
5008
+ const staged = Array.isArray(snapshot.staged) ? snapshot.staged : [];
5009
+ const tracked = Array.isArray(snapshot.unstaged) ? snapshot.unstaged : [];
5010
+ if (staged.length === 0 && tracked.length > 0) {
5011
+ if (!await run("stage", { paths: tracked.map((file) => file.path) }, null)) return;
5012
+ }
5013
+ await commit(false);
5014
+ }, [
5015
+ message,
5016
+ summary,
5017
+ run,
5018
+ commit,
5019
+ t
5020
+ ]);
5021
+ /** Initialize a repository in the Session directory, then let the panel read it. */
5022
+ const initializeRepository = async () => {
5023
+ if (initializing) return;
5024
+ setInitializing(true);
5025
+ try {
5026
+ await callGit(sessionId, "action", { operation: "initRepository" });
4400
5027
  await load();
4401
5028
  setNotice({
4402
5029
  tone: "success",
@@ -4498,11 +5125,13 @@
4498
5125
  const staged = changes.staged ?? [];
4499
5126
  const unstaged = changes.unstaged ?? [];
4500
5127
  const untracked = changes.untracked ?? [];
5128
+ const conflicted = changes.conflicted ?? [];
4501
5129
  const workingChanges = [
4502
- ...changes.conflicted ?? [],
5130
+ ...conflicted,
4503
5131
  ...unstaged,
4504
5132
  ...untracked
4505
5133
  ];
5134
+ const trackedChanges = unstaged;
4506
5135
  const branches = summary.branches ?? {
4507
5136
  local: [],
4508
5137
  remote: []
@@ -4513,9 +5142,37 @@
4513
5142
  const working = busy !== null;
4514
5143
  const pending = repo.pending ?? null;
4515
5144
  const pendingLabel = pending === null ? "" : t(`pending.${pending}`);
4516
- const canCommit = message.trim().length > 0 && !working && (staged.length > 0 || amend && repo.head !== null);
5145
+ const canCommit = message.trim().length > 0 && !working && conflicted.length === 0 && (staged.length > 0 || trackedChanges.length > 0 || amend && repo.head !== null);
4517
5146
  /** Whether the current branch has never been pushed and can be published. */
4518
5147
  const unpublished = repo.detached !== true && repo.unborn !== true && repo.upstream === null;
5148
+ /** Registered worktrees of the repository, the main checkout first. */
5149
+ const worktrees = Array.isArray(summary.worktrees) ? summary.worktrees : [];
5150
+ const currentWorktree = worktrees.find((entry) => entry.current === true) ?? null;
5151
+ /** Display name of one worktree: its branch, detached HEAD, or bare state. */
5152
+ const worktreeLabel = (worktree) => worktree.branch !== null && worktree.branch !== void 0 ? worktree.branch : worktree.detached === true ? `${t("worktree.detached")} ${worktree.head ?? ""}`.trim() : worktree.bare === true ? t("worktree.bare") : worktree.name;
5153
+ /** Compact directory label of one worktree, relative to this checkout when nested. */
5154
+ const worktreePathLabel = (worktree) => {
5155
+ if (worktree.main === true) return t("worktree.mainCheckout");
5156
+ const path = String(worktree.path ?? "").replace(/\\/g, "/");
5157
+ const rootPath = String(repo.root ?? "").replace(/\\/g, "/");
5158
+ if (path.startsWith(`${rootPath}/`)) return path.slice(rootPath.length + 1);
5159
+ return path.split("/").filter((part) => part.length > 0).slice(-2).join("/");
5160
+ };
5161
+ /** The commit action's label: what a click will actually do. */
5162
+ const commitLabel = () => {
5163
+ if (amend) return staged.length > 0 || trackedChanges.length === 0 ? t("commit.amend") : t("commit.amendTracked");
5164
+ if (staged.length > 0) return t("commit.submit");
5165
+ return trackedChanges.length > 0 ? t("commit.tracked") : t("commit.submit");
5166
+ };
5167
+ /** Why the commit action is disabled, or what it will do when enabled. */
5168
+ const commitTitle = () => {
5169
+ if (conflicted.length > 0) return t("commit.resolveConflicts");
5170
+ if (message.trim().length === 0) return t("commit.noMessage");
5171
+ if (staged.length === 0 && trackedChanges.length === 0 && !(amend && repo.head !== null)) return t("commit.nothingToCommit");
5172
+ if (working) return t("toast.busy");
5173
+ if (amend) return t("commit.amendHint");
5174
+ return staged.length > 0 ? t("commit.submit") : t("commit.trackedHint");
5175
+ };
4519
5176
  /** Show one hover tip anchored above the element it describes. */
4520
5177
  const showTip = (event, text) => {
4521
5178
  const rect = event?.currentTarget?.getBoundingClientRect?.();
@@ -4630,6 +5287,218 @@
4630
5287
  }
4631
5288
  await run("publish", {}, t("toast.published", { branch: repo.branch }));
4632
5289
  };
5290
+ /** Open the New Worktree dialog. */
5291
+ const openWorktreeDialog = () => {
5292
+ if (working) return;
5293
+ setWorktreeDialog({
5294
+ branch: "",
5295
+ error: null,
5296
+ submitting: false
5297
+ });
5298
+ };
5299
+ /** Keep the New Worktree dialog's branch field and error in step with typing. */
5300
+ const updateWorktreeBranch = (value) => {
5301
+ setWorktreeDialog((current) => current === null ? null : {
5302
+ ...current,
5303
+ branch: value,
5304
+ error: null
5305
+ });
5306
+ };
5307
+ /** Create one worktree, then offer to move this Session into it. */
5308
+ const createWorktree = async () => {
5309
+ const state = worktreeDialog;
5310
+ if (state === null || state.submitting === true || busyRef.current) return;
5311
+ const branch = state.branch.trim();
5312
+ if (branch.length === 0) {
5313
+ setWorktreeDialog({
5314
+ ...state,
5315
+ error: t("worktree.branchRequired")
5316
+ });
5317
+ return;
5318
+ }
5319
+ busyRef.current = true;
5320
+ setWorktreeDialog({
5321
+ ...state,
5322
+ submitting: true,
5323
+ error: null
5324
+ });
5325
+ setBusy({ operation: "worktreeAdd" });
5326
+ try {
5327
+ const data = await callGit(sessionId, "action", {
5328
+ operation: "worktreeAdd",
5329
+ branch
5330
+ });
5331
+ const createdPath = typeof data?.worktreePath === "string" ? data.worktreePath : null;
5332
+ const createdBranch = typeof data?.branch === "string" ? data.branch : branch;
5333
+ setWorktreeDialog(null);
5334
+ const created = {
5335
+ path: createdPath,
5336
+ branch: createdBranch,
5337
+ name: createdBranch,
5338
+ current: false
5339
+ };
5340
+ setNotice({
5341
+ tone: "success",
5342
+ title: t("toast.worktreeCreated", { name: createdBranch }),
5343
+ ...createdPath === null ? {} : { action: {
5344
+ label: t("action.switchWorktree"),
5345
+ run: () => {
5346
+ switchToWorktree(created);
5347
+ }
5348
+ } }
5349
+ });
5350
+ await load();
5351
+ } catch (error) {
5352
+ const detail = failureText(error, t);
5353
+ setWorktreeDialog((current) => current === null ? null : {
5354
+ ...current,
5355
+ submitting: false,
5356
+ error: detail
5357
+ });
5358
+ } finally {
5359
+ busyRef.current = false;
5360
+ setBusy(null);
5361
+ }
5362
+ };
5363
+ /** Move this Session's working directory into one registered worktree. */
5364
+ const switchToWorktree = async (worktree) => {
5365
+ if (busyRef.current) return;
5366
+ busyRef.current = true;
5367
+ setBusy({ operation: "switchWorktree" });
5368
+ try {
5369
+ await callGit(sessionId, "action", {
5370
+ operation: "switchWorktree",
5371
+ path: worktree.path
5372
+ });
5373
+ setNotice({
5374
+ tone: "success",
5375
+ title: t("toast.worktreeSwitched", { name: worktreeLabel(worktree) })
5376
+ });
5377
+ setView(null);
5378
+ setReview(null);
5379
+ setHistory(null);
5380
+ setNodes({});
5381
+ setSelection({
5382
+ group: null,
5383
+ paths: [],
5384
+ anchor: null
5385
+ });
5386
+ setMessage("");
5387
+ setAmend(false);
5388
+ amendBackupRef.current = null;
5389
+ await load();
5390
+ } catch (error) {
5391
+ setNotice({
5392
+ tone: "error",
5393
+ title: t("toast.failed"),
5394
+ detail: failureText(error, t)
5395
+ });
5396
+ } finally {
5397
+ busyRef.current = false;
5398
+ setBusy(null);
5399
+ }
5400
+ };
5401
+ /** Ask before moving this Session into another checkout. */
5402
+ const requestSwitchWorktree = (worktree) => {
5403
+ ask(t("confirm.switchWorktree", { name: worktreeLabel(worktree) }), () => {
5404
+ setConfirm(null);
5405
+ switchToWorktree(worktree);
5406
+ });
5407
+ };
5408
+ /**
5409
+ * Remove one linked worktree. A dirty checkout is refused first; the failure
5410
+ * notice then offers the explicit force path so uncommitted work is lost only
5411
+ * after a second confirmation.
5412
+ */
5413
+ const removeWorktree = async (worktree, force = false) => {
5414
+ if (busyRef.current) return;
5415
+ busyRef.current = true;
5416
+ setBusy({ operation: "worktreeRemove" });
5417
+ try {
5418
+ await callGit(sessionId, "action", {
5419
+ operation: "worktreeRemove",
5420
+ path: worktree.path,
5421
+ ...force ? { force: true } : {}
5422
+ });
5423
+ setNotice({
5424
+ tone: "success",
5425
+ title: t("toast.worktreeRemoved", { name: worktreeLabel(worktree) })
5426
+ });
5427
+ await load();
5428
+ } catch (error) {
5429
+ setNotice({
5430
+ tone: "error",
5431
+ title: t("toast.worktreeRemoveFailed"),
5432
+ detail: failureText(error, t),
5433
+ ...force ? {} : { action: {
5434
+ label: t("action.forceRemoveWorktree"),
5435
+ run: () => ask(t("confirm.forceRemoveWorktree", { name: worktreeLabel(worktree) }), () => {
5436
+ setConfirm(null);
5437
+ removeWorktree(worktree, true);
5438
+ })
5439
+ } }
5440
+ });
5441
+ } finally {
5442
+ busyRef.current = false;
5443
+ setBusy(null);
5444
+ }
5445
+ };
5446
+ /** Ask before deleting one linked worktree. */
5447
+ const requestRemoveWorktree = (worktree) => {
5448
+ ask(t("confirm.removeWorktree", { name: worktreeLabel(worktree) }), () => {
5449
+ setConfirm(null);
5450
+ removeWorktree(worktree, false);
5451
+ });
5452
+ };
5453
+ /** Worktree section actions: create a checkout, prune registrations whose directories are gone. */
5454
+ const worktreeAddMenuItems = () => [
5455
+ {
5456
+ label: t("action.createWorktree"),
5457
+ icon: h(PlusIcon, { size: 14 }),
5458
+ disabled: working || repo.unborn === true,
5459
+ run: openWorktreeDialog
5460
+ },
5461
+ null,
5462
+ {
5463
+ label: t("action.pruneWorktrees"),
5464
+ icon: h(TrashIcon, { size: 14 }),
5465
+ disabled: working || !worktrees.some((entry) => entry.prunable === true),
5466
+ run: () => {
5467
+ run("worktreePrune", {}, t("toast.worktreesPruned"));
5468
+ }
5469
+ }
5470
+ ];
5471
+ /** One worktree row's menu: move here, copy the path, and remove or prune it. */
5472
+ const worktreeMenuItems = (worktree) => [
5473
+ {
5474
+ label: t("action.switchWorktree"),
5475
+ icon: h(BranchIcon, { size: 14 }),
5476
+ disabled: working || worktree.current === true || worktree.prunable === true,
5477
+ run: () => requestSwitchWorktree(worktree)
5478
+ },
5479
+ {
5480
+ label: t("action.copyWorktreePath"),
5481
+ icon: h(CopyIcon, { size: 14 }),
5482
+ run: () => {
5483
+ copy(worktree.path);
5484
+ }
5485
+ },
5486
+ null,
5487
+ worktree.prunable === true ? {
5488
+ label: t("action.pruneWorktrees"),
5489
+ icon: h(TrashIcon, { size: 14 }),
5490
+ disabled: working,
5491
+ run: () => {
5492
+ run("worktreePrune", {}, t("toast.worktreesPruned"));
5493
+ }
5494
+ } : {
5495
+ label: t("action.removeWorktree"),
5496
+ icon: h(TrashIcon, { size: 14 }),
5497
+ danger: true,
5498
+ disabled: working || worktree.current === true || worktree.main === true || worktree.bare === true,
5499
+ run: () => requestRemoveWorktree(worktree)
5500
+ }
5501
+ ];
4633
5502
  /**
4634
5503
  * Items of the sparkle control's hold menu: language and message style.
4635
5504
  * @param {object} rules - the rules the menu reflects.
@@ -4769,11 +5638,14 @@
4769
5638
  const total = rootRef.current?.clientHeight ?? 600;
4770
5639
  return Math.max(DIFF_HEIGHT_MIN, Math.min(value, Math.max(DIFF_HEIGHT_MIN, total - DIFF_HEIGHT_RESERVED)));
4771
5640
  };
4772
- /** Clamp a requested pane width so the list never drops below its 300px minimum. */
5641
+ /**
5642
+ * Clamp a requested pane width: the right dock keeps at least 280px, and
5643
+ * stops widening once the list would drop below its 300px reservation.
5644
+ */
4773
5645
  const clampPaneWidth = (value) => {
4774
5646
  const total = rootRef.current?.clientWidth ?? 800;
4775
- const available = Math.max(0, total - PREVIEW_WIDTH_RESERVED);
4776
- return Math.min(Math.max(value, Math.min(PREVIEW_WIDTH_MIN, available)), available);
5647
+ const maximum = Math.max(PREVIEW_WIDTH_MIN, total - PREVIEW_WIDTH_RESERVED);
5648
+ return Math.min(Math.max(value, PREVIEW_WIDTH_MIN), maximum);
4777
5649
  };
4778
5650
  const previewOpen = view !== null || review !== null || history !== null;
4779
5651
  const paneHeight = diffMaximized ? clampPaneHeight((rootRef.current?.clientHeight ?? 600) - DIFF_HEIGHT_RESERVED) : clampPaneHeight(diffHeight);
@@ -4797,7 +5669,7 @@
4797
5669
  /** Track the divider while the pointer is down. */
4798
5670
  const moveResize = (event) => {
4799
5671
  if (dragRef.current === null) return;
4800
- if (previewLayout === "right") {
5672
+ if (paneLayout === "right") {
4801
5673
  const next = clampPaneWidth(dragRef.current.startWidth - (event.clientX - dragRef.current.startX));
4802
5674
  widthRef.current = next;
4803
5675
  setDiffMaximized(false);
@@ -4812,7 +5684,7 @@
4812
5684
  /** Restore the default size of the active dock. */
4813
5685
  const resetResize = () => {
4814
5686
  setDiffMaximized(false);
4815
- if (previewLayout === "right") {
5687
+ if (paneLayout === "right") {
4816
5688
  const next = clampPaneWidth(PREVIEW_WIDTH_DEFAULT);
4817
5689
  widthRef.current = next;
4818
5690
  setPreviewWidth(next);
@@ -4829,7 +5701,7 @@
4829
5701
  if (dragRef.current === null) return;
4830
5702
  dragRef.current = null;
4831
5703
  setDragging(false);
4832
- if (previewLayout === "right") storePreviewWidth(widthRef.current);
5704
+ if (paneLayout === "right") storePreviewWidth(widthRef.current);
4833
5705
  else storeDiffHeight(heightRef.current);
4834
5706
  };
4835
5707
  /** Switch the preview between the bottom and right docks. */
@@ -4928,32 +5800,245 @@
4928
5800
  setConfirm(null);
4929
5801
  run("undoCommit", {}, t("toast.undone"));
4930
5802
  })
4931
- },
4932
- null,
4933
- {
5803
+ }
5804
+ ];
5805
+ /** Label, glyph, counts, and click action of the sync control's primary segment. */
5806
+ const syncPrimary = () => {
5807
+ const remoteOperation = working && [
5808
+ "fetch",
5809
+ "pull",
5810
+ "push",
5811
+ "publish",
5812
+ "publishGithub"
5813
+ ].includes(busy?.operation);
5814
+ if (unpublished) return {
5815
+ label: t("action.publish"),
5816
+ icon: CloudUploadIcon,
5817
+ title: t("sync.publish"),
5818
+ busy: working && [
5819
+ "publish",
5820
+ "publishGithub",
5821
+ "push"
5822
+ ].includes(busy?.operation),
5823
+ disabled: working,
5824
+ counts: [],
5825
+ run: () => {
5826
+ publish(true);
5827
+ }
5828
+ };
5829
+ if (repo.detached === true || repo.unborn === true) return {
4934
5830
  label: t("action.fetch"),
4935
- icon: h(FetchIcon, { size: 14 }),
5831
+ icon: FetchIcon,
5832
+ title: t("sync.fetch"),
5833
+ busy: remoteOperation,
4936
5834
  disabled: working,
5835
+ counts: [],
4937
5836
  run: () => {
4938
5837
  run("fetch", { all: true }, fetchSuccess);
4939
5838
  }
4940
- },
5839
+ };
5840
+ if (repo.behind > 0) {
5841
+ const counts = [{
5842
+ tone: "behind",
5843
+ text: `↓${repo.behind}`
5844
+ }];
5845
+ if (repo.ahead > 0) counts.push({
5846
+ tone: "ahead",
5847
+ text: `↑${repo.ahead}`
5848
+ });
5849
+ return {
5850
+ label: t("action.pull"),
5851
+ icon: PullIcon,
5852
+ title: t("sync.pull"),
5853
+ busy: working && busy?.operation === "pull",
5854
+ disabled: working,
5855
+ counts,
5856
+ run: () => {
5857
+ run("pull", {}, t("toast.pulled"));
5858
+ }
5859
+ };
5860
+ }
5861
+ if (repo.ahead > 0) return {
5862
+ label: t("action.push"),
5863
+ icon: PushIcon,
5864
+ title: t("sync.push"),
5865
+ busy: working && busy?.operation === "push",
5866
+ disabled: working,
5867
+ counts: [{
5868
+ tone: "ahead",
5869
+ text: `↑${repo.ahead}`
5870
+ }],
5871
+ run: () => {
5872
+ run("push", {}, t("toast.pushed"));
5873
+ }
5874
+ };
5875
+ return {
5876
+ label: t("action.fetch"),
5877
+ icon: FetchIcon,
5878
+ title: t("sync.fetch"),
5879
+ busy: remoteOperation,
5880
+ disabled: working,
5881
+ counts: [],
5882
+ run: () => {
5883
+ run("fetch", { all: true }, fetchSuccess);
5884
+ }
5885
+ };
5886
+ };
5887
+ /** The remotes a Fetch From or Push To submenu can target. */
5888
+ const remoteTargets = () => remotes.map((remote) => remote.name);
5889
+ /** Submenu: fetch one named remote, or all of them when there is a choice. */
5890
+ const openFetchFromMenu = () => {
5891
+ const names = remoteTargets();
5892
+ const items = [{ heading: t("section.remotes") }, ...names.map((name) => ({
5893
+ label: name,
5894
+ icon: h(RemoteIcon, { size: 14 }),
5895
+ run: () => {
5896
+ run("fetch", { remote: name }, fetchSuccess);
5897
+ }
5898
+ }))];
5899
+ if (names.length > 1) items.push(null, {
5900
+ label: t("menu.fetchAll"),
5901
+ icon: h(FetchIcon, { size: 14 }),
5902
+ run: () => {
5903
+ run("fetch", { all: true }, fetchSuccess);
5904
+ }
5905
+ });
5906
+ openMenuAt(menuAnchorRef.current, items);
5907
+ };
5908
+ /** Submenu: push the current branch to one named remote. */
5909
+ const openPushToMenu = () => {
5910
+ openMenuAt(menuAnchorRef.current, [{ heading: t("section.remotes") }, ...remoteTargets().map((name) => ({
5911
+ label: name,
5912
+ icon: h(RemoteIcon, { size: 14 }),
5913
+ run: () => {
5914
+ if (repo.upstream === null) run("push", {
5915
+ setUpstream: true,
5916
+ remote: name
5917
+ }, t("toast.published", { branch: repo.branch }));
5918
+ else run("push", { remote: name }, t("toast.pushed"));
5919
+ }
5920
+ }))]);
5921
+ };
5922
+ /** The remote commands behind the sync control's chevron. */
5923
+ const syncMenuItems = () => {
5924
+ const noRemote = remotes.length === 0;
5925
+ const noUpstream = repo.upstream === null;
5926
+ const noBranch = repo.detached === true || repo.unborn === true;
5927
+ return [
5928
+ {
5929
+ label: t("action.fetch"),
5930
+ disabled: working,
5931
+ run: () => {
5932
+ run("fetch", { all: true }, fetchSuccess);
5933
+ }
5934
+ },
5935
+ {
5936
+ label: t("action.fetchFrom"),
5937
+ disabled: working || noRemote,
5938
+ run: openFetchFromMenu
5939
+ },
5940
+ {
5941
+ label: t("action.pull"),
5942
+ disabled: working || noBranch || noUpstream,
5943
+ run: () => {
5944
+ run("pull", {}, t("toast.pulled"));
5945
+ }
5946
+ },
5947
+ {
5948
+ label: t("action.pullRebase"),
5949
+ disabled: working || noBranch || noUpstream,
5950
+ run: () => {
5951
+ run("pull", { rebase: true }, t("toast.pulled"));
5952
+ }
5953
+ },
5954
+ null,
5955
+ {
5956
+ label: t("action.push"),
5957
+ disabled: working || noBranch || noUpstream || noRemote,
5958
+ run: () => {
5959
+ run("push", {}, t("toast.pushed"));
5960
+ }
5961
+ },
5962
+ {
5963
+ label: t("action.pushTo"),
5964
+ disabled: working || noBranch || noRemote,
5965
+ run: openPushToMenu
5966
+ },
5967
+ {
5968
+ label: t("action.forcePush"),
5969
+ disabled: working || noBranch || noUpstream || noRemote,
5970
+ run: () => ask(t("confirm.forcePush"), () => {
5971
+ setConfirm(null);
5972
+ run("push", { forceWithLease: true }, t("toast.forcePushed"));
5973
+ })
5974
+ }
5975
+ ];
5976
+ };
5977
+ /** The Zed-style split control: a state-driven primary action and its menu. */
5978
+ const syncControl = () => {
5979
+ const primary = syncPrimary();
5980
+ const PrimaryIcon = primary.icon;
5981
+ return h("div", { className: "dgscm-sync-control" }, h("button", {
5982
+ type: "button",
5983
+ className: "dgscm-sync-primary",
5984
+ title: primary.title,
5985
+ "aria-label": primary.label,
5986
+ "aria-busy": primary.busy ? "true" : void 0,
5987
+ disabled: primary.disabled,
5988
+ onClick: (event) => {
5989
+ event.stopPropagation();
5990
+ if (primary.disabled) return;
5991
+ primary.run();
5992
+ }
5993
+ }, primary.busy ? h(SpinnerIcon, { size: 13 }) : h(PrimaryIcon, { size: 13 }), h("span", { className: "dgscm-sync-text" }, primary.label), primary.counts.map((entry) => h("span", {
5994
+ key: entry.tone,
5995
+ className: `dgscm-sync-count dgscm-sync-count--${entry.tone}`
5996
+ }, entry.text))), h("button", {
5997
+ type: "button",
5998
+ className: "dgscm-sync-toggle",
5999
+ title: t("action.moreSync"),
6000
+ "aria-label": t("action.moreSync"),
6001
+ disabled: working,
6002
+ onClick: (event) => {
6003
+ event.stopPropagation();
6004
+ openMenuBelow(event.currentTarget, syncMenuItems());
6005
+ }
6006
+ }, h(CaretIcon, { size: 12 })));
6007
+ };
6008
+ /** Options behind the commit split button's chevron. */
6009
+ const commitMenuItems = () => [
4941
6010
  {
4942
- label: t("action.pull"),
4943
- icon: h(PullIcon, { size: 14 }),
4944
- disabled: working || repo.upstream === null || repo.detached === true,
6011
+ label: message.trim().length > 0 ? t("action.improveMessage") : t("action.generateMessage"),
6012
+ icon: h(SparkleIcon, { size: 14 }),
6013
+ disabled: working || generating,
4945
6014
  run: () => {
4946
- run("pull", {}, t("toast.pulled"));
6015
+ generateMessage();
4947
6016
  }
4948
6017
  },
6018
+ null,
4949
6019
  {
4950
- label: unpublished ? t("action.publishBranch") : t("action.push"),
4951
- icon: h(unpublished ? CloudUploadIcon : PushIcon, { size: 14 }),
4952
- disabled: working || repo.detached === true || repo.unborn === true,
6020
+ label: t("commit.amend"),
6021
+ checked: amend,
6022
+ disabled: working || repo.head === null,
6023
+ run: () => toggleAmend(!amend)
6024
+ },
6025
+ null,
6026
+ {
6027
+ label: t("commit.all"),
6028
+ icon: h(CommitIcon, { size: 14 }),
6029
+ disabled: working || message.trim().length === 0,
4953
6030
  run: () => {
4954
- if (unpublished) publish();
4955
- else run("push", {}, t("toast.pushed"));
6031
+ commit(true);
4956
6032
  }
6033
+ },
6034
+ {
6035
+ label: t("commit.undo"),
6036
+ icon: h(DiscardIcon, { size: 14 }),
6037
+ disabled: working || repo.head === null || pending !== null,
6038
+ run: () => ask(t("confirm.undoCommit"), () => {
6039
+ setConfirm(null);
6040
+ run("undoCommit", {}, t("toast.undone"));
6041
+ })
4957
6042
  }
4958
6043
  ];
4959
6044
  /** Header controls of the staged section: the selection command joins the bulk command. */
@@ -4978,56 +6063,157 @@
4978
6063
  run("stageAll", {}, t("toast.staged"));
4979
6064
  }
4980
6065
  }, h(PlusIcon, { size: 13 })));
4981
- /** Rows of one change section. */
4982
- const changeRows = (section, list) => {
4983
- const selected = selectedSet(section);
4984
- return list.map((file) => {
4985
- const kind = kindOf(section, file);
4986
- return h(ChangeRow, {
6066
+ /**
6067
+ * One change row; `list` is the section order selection ranges use.
6068
+ * @param {string} section - `staged` or `changes`.
6069
+ * @param {object} file - the changed file.
6070
+ * @param {object[]} list - visible files of the section, in visual order.
6071
+ * @param {number} depth - tree indentation depth.
6072
+ * @param {boolean} showDir - whether the row appends the directory suffix.
6073
+ * @returns {object} the row element.
6074
+ */
6075
+ const fileChangeRow = (section, file, list, depth = 0, showDir = true) => {
6076
+ const kind = kindOf(section, file);
6077
+ return h(ChangeRow, {
6078
+ key: `${section}:${file.path}`,
6079
+ file,
6080
+ group: kind,
6081
+ selected: selectedSet(section).has(file.path),
6082
+ disabled: working,
6083
+ t,
6084
+ depth,
6085
+ showDir,
6086
+ onActivate: (event) => {
6087
+ if (event?.metaKey === true || event?.ctrlKey === true) {
6088
+ togglePath(section, file.path);
6089
+ return;
6090
+ }
6091
+ if (event?.shiftKey === true) {
6092
+ extendSelection(section, file.path, list);
6093
+ return;
6094
+ }
6095
+ select(section, [file.path], file.path);
6096
+ if (isDirectoryEntry(file.path)) return;
6097
+ openWorktreeDiff(file, kind);
6098
+ },
6099
+ onContextMenu: (event) => openMenu(event, fileMenu(file, kind, section, list)),
6100
+ onQuickStage: () => {
6101
+ run("stage", { paths: targetFiles(section, file.path, list).map((entry) => entry.path) }, t("toast.staged"));
6102
+ },
6103
+ onQuickUnstage: () => {
6104
+ run("unstage", { paths: targetFiles(section, file.path, list).map((entry) => entry.path) }, t("toast.unstaged"));
6105
+ },
6106
+ onQuickDiscard: () => discardFiles(targetFiles(section, file.path, list))
6107
+ });
6108
+ };
6109
+ /** Rows of one change section as a flat list. */
6110
+ const changeRows = (section, list) => list.map((file) => fileChangeRow(section, file, list));
6111
+ /**
6112
+ * Rows of one change section as a directory tree. Directories sort before
6113
+ * their files; the visible file order becomes the selection range.
6114
+ * @param {string} section - `staged` or `changes`.
6115
+ * @param {object[]} list - the section's changed files.
6116
+ * @returns {object[]} directory and file rows in display order.
6117
+ */
6118
+ const changeTreeRows = (section, list) => {
6119
+ const entries = [];
6120
+ /**
6121
+ * Merge a single-child directory chain into one row, the way the Explorer
6122
+ * compacts folders: a directory with no files and exactly one child joins
6123
+ * that child, repeating until a branch or a file stops the chain.
6124
+ * @param {object} dir - the first directory of the chain.
6125
+ * @returns {{ node: object, name: string }} the deepest directory and its
6126
+ * combined label.
6127
+ */
6128
+ const compactChain = (dir) => {
6129
+ let node = dir;
6130
+ const names = [dir.name];
6131
+ while (node.files.length === 0 && node.dirs.size === 1) {
6132
+ node = [...node.dirs.values()][0];
6133
+ names.push(node.name);
6134
+ }
6135
+ return {
6136
+ node,
6137
+ name: names.join(" / ")
6138
+ };
6139
+ };
6140
+ const walk = (node, depth) => {
6141
+ const dirs = [...node.dirs.values()].sort((left, right) => left.name.localeCompare(right.name));
6142
+ for (const dir of dirs) {
6143
+ const chain = compactChain(dir);
6144
+ const key = `${section}:${chain.node.path}`;
6145
+ const open = collapsedDirs[key] !== true;
6146
+ entries.push({
6147
+ kind: "dir",
6148
+ key: `dir:${key}`,
6149
+ dir: chain.node,
6150
+ name: chain.name,
6151
+ depth,
6152
+ open,
6153
+ count: countTreeFiles(chain.node),
6154
+ files: collectTreeFiles(chain.node)
6155
+ });
6156
+ if (open) walk(chain.node, depth + 1);
6157
+ }
6158
+ const files = node.files.slice().sort((left, right) => left.path.localeCompare(right.path));
6159
+ for (const file of files) entries.push({
6160
+ kind: "file",
4987
6161
  key: `${section}:${file.path}`,
4988
6162
  file,
4989
- group: kind,
4990
- selected: selected.has(file.path),
6163
+ depth
6164
+ });
6165
+ };
6166
+ walk(buildChangeTree(list), 0);
6167
+ const ordered = entries.filter((entry) => entry.kind === "file").map((entry) => entry.file);
6168
+ return entries.map((entry) => {
6169
+ if (entry.kind === "file") return fileChangeRow(section, entry.file, ordered, entry.depth, false);
6170
+ const paths = entry.files.map((file) => file.path);
6171
+ const actions = section === "staged" ? [h(IconButton, {
6172
+ key: "unstage",
6173
+ label: t("action.unstage", { path: entry.dir.path }),
6174
+ disabled: working,
6175
+ onClick: () => {
6176
+ run("unstage", { paths }, t("toast.unstaged"));
6177
+ }
6178
+ }, h(MinusIcon, { size: 13 }))] : [h(IconButton, {
6179
+ key: "stage",
6180
+ label: t("action.stage", { path: entry.dir.path }),
4991
6181
  disabled: working,
6182
+ onClick: () => {
6183
+ run("stage", { paths }, t("toast.staged"));
6184
+ }
6185
+ }, h(PlusIcon, { size: 13 })), h(IconButton, {
6186
+ key: "discard",
6187
+ label: t("action.discard", { path: entry.dir.path }),
6188
+ disabled: working,
6189
+ onClick: () => discardFiles(entry.files)
6190
+ }, h(DiscardIcon, { size: 13 }))];
6191
+ return h(ChangeDirRow, {
6192
+ key: entry.key,
6193
+ name: entry.name,
6194
+ path: entry.dir.path,
6195
+ depth: entry.depth,
6196
+ open: entry.open,
6197
+ count: entry.count,
4992
6198
  t,
4993
- onActivate: (event) => {
4994
- if (event?.metaKey === true || event?.ctrlKey === true) {
4995
- togglePath(section, file.path);
4996
- return;
4997
- }
4998
- if (event?.shiftKey === true) {
4999
- extendSelection(section, file.path, list);
5000
- return;
5001
- }
5002
- select(section, [file.path], file.path);
5003
- openWorktreeDiff(file, kind);
5004
- },
5005
- onToggleSelected: () => togglePath(section, file.path),
5006
- onContextMenu: (event) => openMenu(event, fileMenu(file, kind, section, list)),
5007
- onQuickStage: () => {
5008
- run("stage", { paths: targetFiles(section, file.path, list).map((entry) => entry.path) }, t("toast.staged"));
5009
- },
5010
- onQuickUnstage: () => {
5011
- run("unstage", { paths: targetFiles(section, file.path, list).map((entry) => entry.path) }, t("toast.unstaged"));
5012
- },
5013
- onQuickDiscard: () => discardFiles(targetFiles(section, file.path, list))
6199
+ actions,
6200
+ onToggle: () => toggleChangeDir(`${section}:${entry.dir.path}`)
5014
6201
  });
5015
6202
  });
5016
6203
  };
6204
+ /** Rows of one change section in the selected view. */
6205
+ const changeSectionRows = (section, list) => changeView === "tree" ? changeTreeRows(section, list) : changeRows(section, list);
5017
6206
  /** Context menu of one change row. */
5018
6207
  const fileMenu = (file, kind, section, list) => {
5019
6208
  const files = targetFiles(section, file.path, list);
5020
6209
  const paths = files.map((entry) => entry.path);
5021
6210
  const untrackedOnly = files.length > 0 && files.every((entry) => entry.status === "untracked");
6211
+ const directoryRow = isDirectoryEntry(file.path);
5022
6212
  return [
5023
6213
  {
5024
6214
  label: t("menu.showDiff"),
5025
- icon: h(ExternalIcon, { size: 14 }),
5026
- run: () => openNative(file.path)
5027
- },
5028
- {
5029
- label: t("menu.previewInPanel"),
5030
6215
  icon: h(RowsIcon, { size: 14 }),
6216
+ disabled: directoryRow,
5031
6217
  run: () => {
5032
6218
  openWorktreeDiff(file, kind);
5033
6219
  }
@@ -5035,12 +6221,13 @@
5035
6221
  {
5036
6222
  label: t("menu.openFile"),
5037
6223
  icon: h(ExternalIcon, { size: 14 }),
5038
- disabled: file.status === "deleted",
6224
+ disabled: directoryRow || file.status === "deleted",
5039
6225
  run: () => openFileAt(file.path)
5040
6226
  },
5041
6227
  {
5042
6228
  label: t("menu.fileHistory"),
5043
6229
  icon: h(HistoryIcon, { size: 14 }),
6230
+ disabled: directoryRow,
5044
6231
  run: () => {
5045
6232
  openFileHistory(file.path);
5046
6233
  }
@@ -5465,15 +6652,19 @@
5465
6652
  return rows;
5466
6653
  };
5467
6654
  return h("div", {
5468
- className: `dgscm-root${previewLayout === "right" ? " dgscm-root--row" : ""}`,
6655
+ className: `dgscm-root${paneLayout === "right" ? " dgscm-root--row" : ""}`,
5469
6656
  ref: attachRoot
5470
- }, h("div", { className: "dgscm-main" }, h("div", { className: "dgscm-top" }, h("div", { className: "dgscm-repo-row" }, h(RepoIcon, {
5471
- size: 15,
5472
- className: "dgscm-repo-glyph"
5473
- }), h("span", {
5474
- className: "dgscm-repo-name",
5475
- title: repo.root
5476
- }, repo.name), repo.detached === true ? h("span", { className: "dgscm-badge" }, repo.head === null ? "HEAD" : repo.head.short) : h("span", { className: "dgscm-branch-chip" }, h("button", {
6657
+ }, h("div", { className: "dgscm-main" }, h("div", { className: "dgscm-top" }, h("div", { className: "dgscm-repo-row" }, h("span", {
6658
+ className: "dgscm-repo-glyph",
6659
+ role: "img",
6660
+ "aria-label": repo.name,
6661
+ title: repo.name
6662
+ }, h(RepoIcon, { size: 15 })), repo.isWorktree === true ? h("span", {
6663
+ className: "dgscm-badge dgscm-badge--worktree dgscm-badge--icon",
6664
+ title: currentWorktree === null ? repo.root : `${t("repo.worktree")} — ${currentWorktree.path}`,
6665
+ "aria-label": t("repo.worktree"),
6666
+ role: "img"
6667
+ }, h(FolderIcon, { size: 12 })) : null, repo.detached === true ? h("span", { className: "dgscm-badge" }, repo.head === null ? "HEAD" : repo.head.short) : h("span", { className: "dgscm-branch-chip" }, h("button", {
5477
6668
  ref: chipRef,
5478
6669
  type: "button",
5479
6670
  className: "dgscm-branch-chip-name",
@@ -5514,33 +6705,7 @@
5514
6705
  reloadOpenNodes();
5515
6706
  });
5516
6707
  }
5517
- }, h(RefreshIcon, { size: 15 })), h(IconButton, {
5518
- label: t("action.fetch"),
5519
- disabled: working,
5520
- busy: busy?.operation === "fetch",
5521
- onClick: () => {
5522
- run("fetch", { all: true }, fetchSuccess);
5523
- }
5524
- }, h(FetchIcon, { size: 15 })), h(IconButton, {
5525
- label: t("action.pull"),
5526
- disabled: working || repo.upstream === null || repo.detached === true,
5527
- busy: busy?.operation === "pull",
5528
- onClick: () => {
5529
- run("pull", {}, t("toast.pulled"));
5530
- }
5531
- }, h(PullIcon, { size: 15 })), h(IconButton, {
5532
- label: unpublished ? t("action.publishBranch") : t("action.push"),
5533
- disabled: working || repo.detached === true || repo.unborn === true,
5534
- busy: busy?.operation === "push" || busy?.operation === "publish" || busy?.operation === "publishGithub",
5535
- onClick: () => {
5536
- if (unpublished) publish();
5537
- else run("push", {}, t("toast.pushed"));
5538
- }
5539
- }, h(unpublished ? CloudUploadIcon : PushIcon, { size: 15 })), h(IconButton, {
5540
- label: t("action.moreChanges"),
5541
- disabled: working,
5542
- onClick: (event) => openMenu(event, changesMoreMenuItems())
5543
- }, h(MoreIcon, { size: 15 })))), working ? h("div", { className: "dgscm-sync" }, h("span", { className: "dgscm-sync-label" }, `${t(BUSY_LABEL[busy.operation] ?? "toast.busy")}…`)) : h("div", { className: "dgscm-sync" }, repo.detached === true ? h("span", { className: "dgscm-sync-label" }, t("repo.detached", { commit: repo.head === null ? "" : repo.head.short })) : repo.upstream === null ? h("span", { className: "dgscm-sync-label" }, t("repo.noUpstream")) : h(React.Fragment, null, repo.ahead > 0 ? h("span", {
6708
+ }, h(RefreshIcon, { size: 15 })), syncControl())), h("div", { className: "dgscm-sync-row" }, working ? h("div", { className: "dgscm-sync" }, h("span", { className: "dgscm-sync-label" }, `${t(BUSY_LABEL[busy.operation] ?? "toast.busy")}…`)) : h("div", { className: "dgscm-sync" }, repo.detached === true ? h("span", { className: "dgscm-sync-label" }, t("repo.detached", { commit: repo.head === null ? "" : repo.head.short })) : repo.upstream === null ? h("span", { className: "dgscm-sync-label" }, t("repo.noUpstream")) : h(React.Fragment, null, repo.ahead > 0 ? h("span", {
5544
6709
  className: "dgscm-count dgscm-count--ahead",
5545
6710
  title: t("ahead.label", { n: repo.ahead })
5546
6711
  }, h(PushIcon, { size: 11 }), String(repo.ahead)) : null, repo.behind > 0 ? h("span", {
@@ -5549,7 +6714,14 @@
5549
6714
  }, h(PullIcon, { size: 11 }), String(repo.behind)) : null, h("span", {
5550
6715
  className: "dgscm-sync-label",
5551
6716
  title: repo.upstream
5552
- }, repo.ahead === 0 && repo.behind === 0 ? t("repo.synced", { upstream: repo.upstream }) : repo.upstream)), h("span", { className: "dgscm-sep" }, "·"), h("span", { className: "dgscm-sync-label" }, repo.lastFetchAt === null || repo.lastFetchAt === void 0 ? t("repo.neverFetched") : t("repo.fetched", { time: relativeTime(repo.lastFetchAt, t) })))), pending === null ? null : h("div", { className: "dgscm-banner" }, h("span", { className: "dgscm-banner-glyph" }, h(WarnIcon, { size: 13 })), h("span", { className: "dgscm-banner-text" }, pendingLabel), h("button", {
6717
+ }, repo.ahead === 0 && repo.behind === 0 ? t("repo.synced", { upstream: repo.upstream }) : repo.upstream)), h("span", { className: "dgscm-sep" }, "·"), h("span", { className: "dgscm-sync-label" }, repo.lastFetchAt === null || repo.lastFetchAt === void 0 ? t("repo.neverFetched") : t("repo.fetched", { time: relativeTime(repo.lastFetchAt, t) }))), h("div", { className: "dgscm-sync-actions" }, h(IconButton, {
6718
+ label: changeView === "tree" ? t("action.viewList") : t("action.viewTree"),
6719
+ onClick: toggleChangeView
6720
+ }, h(changeView === "tree" ? RowsIcon : TreeIcon, { size: 14 })), h(IconButton, {
6721
+ label: t("action.moreChanges"),
6722
+ disabled: working,
6723
+ onClick: (event) => openMenu(event, changesMoreMenuItems())
6724
+ }, h(MoreIcon, { size: 14 }))))), pending === null ? null : h("div", { className: "dgscm-banner" }, h("span", { className: "dgscm-banner-glyph" }, h(WarnIcon, { size: 13 })), h("span", { className: "dgscm-banner-text" }, pendingLabel), h("button", {
5553
6725
  type: "button",
5554
6726
  className: "dgscm-link-button dgscm-link-button--primary dgscm-banner-action",
5555
6727
  disabled: working,
@@ -5568,7 +6740,7 @@
5568
6740
  onKeyDown: (event) => {
5569
6741
  if (event.key === "Enter" && (event.metaKey || event.ctrlKey)) {
5570
6742
  event.preventDefault();
5571
- commit(false);
6743
+ commitTracked();
5572
6744
  }
5573
6745
  }
5574
6746
  }), h("button", {
@@ -5619,57 +6791,26 @@
5619
6791
  onClick: () => {
5620
6792
  publish(true);
5621
6793
  }
5622
- }, h(CloudUploadIcon, { size: 15 }), t("action.publishBranch")) : h(React.Fragment, null, h("label", {
5623
- className: "dgscm-check",
5624
- title: t("commit.amend")
5625
- }, h("input", {
5626
- type: "checkbox",
5627
- checked: amend,
5628
- disabled: working || repo.head === null,
5629
- onChange: (event) => toggleAmend(event.target.checked)
5630
- }), h("span", null, t("commit.amend"))), h("div", { className: "dgscm-commit-actions" }, h("button", {
6794
+ }, h(CloudUploadIcon, { size: 15 }), t("action.publishBranch")) : h(React.Fragment, null, amend && !working ? h("span", { className: "dgscm-commit-note" }, t("commit.amendNote")) : null, h("div", { className: "dgscm-commit-actions" }, h("div", { className: "dgscm-split-button dgscm-split-button--commit" }, h("button", {
5631
6795
  type: "button",
5632
- className: "dgscm-button dgscm-button--primary dgscm-commit-submit",
6796
+ className: "dgscm-split-main dgscm-commit-submit",
5633
6797
  disabled: !canCommit,
5634
- title: staged.length === 0 && !amend ? t("commit.nothingStaged") : t("commit.submit"),
6798
+ title: commitTitle(),
6799
+ "aria-busy": busy?.operation === "commit" ? "true" : void 0,
5635
6800
  onClick: () => {
5636
- commit(false);
6801
+ commitTracked();
5637
6802
  }
5638
- }, busy?.operation === "commit" ? t("toast.busy") : t("commit.submit")), h("button", {
6803
+ }, busy?.operation === "commit" ? h(SpinnerIcon, { size: 13 }) : null, h("span", null, commitLabel())), h("button", {
5639
6804
  type: "button",
5640
- className: "dgscm-split-more",
6805
+ className: "dgscm-split-toggle dgscm-commit-more",
5641
6806
  title: t("commit.more"),
5642
6807
  "aria-label": t("commit.more"),
5643
- disabled: working || message.trim().length === 0 && workingChanges.length === 0,
5644
- onClick: (event) => openMenu(event, [
5645
- {
5646
- label: message.trim().length > 0 ? t("action.improveMessage") : t("action.generateMessage"),
5647
- icon: h(SparkleIcon, { size: 14 }),
5648
- disabled: working || generating,
5649
- run: () => {
5650
- generateMessage();
5651
- }
5652
- },
5653
- null,
5654
- {
5655
- label: t("commit.all"),
5656
- icon: h(CommitIcon, { size: 14 }),
5657
- disabled: working,
5658
- run: () => {
5659
- commit(true);
5660
- }
5661
- },
5662
- {
5663
- label: t("commit.undo"),
5664
- icon: h(DiscardIcon, { size: 14 }),
5665
- disabled: working || repo.head === null || pending !== null,
5666
- run: () => ask(t("confirm.undoCommit"), () => {
5667
- setConfirm(null);
5668
- run("undoCommit", {}, t("toast.undone"));
5669
- })
5670
- }
5671
- ])
5672
- }, h("span", { className: "dgscm-chevron dgscm-chevron--open" }, h(ChevronIcon, { open: true }))))))), h("div", {
6808
+ disabled: working,
6809
+ onClick: (event) => {
6810
+ event.stopPropagation();
6811
+ openMenuBelow(event.currentTarget, commitMenuItems());
6812
+ }
6813
+ }, h(CaretIcon, { size: 12 }))))))), h("div", {
5673
6814
  className: "dgscm-scroll",
5674
6815
  onClick: clearSelectionOnBlank
5675
6816
  }, staged.length === 0 ? null : h(Section, {
@@ -5680,7 +6821,7 @@
5680
6821
  open: sections.staged,
5681
6822
  onToggle: () => toggleSection("staged"),
5682
6823
  actions: stagedActions()
5683
- }, changeRows("staged", staged)), h(Section, {
6824
+ }, changeSectionRows("staged", staged)), h(Section, {
5684
6825
  id: "changes",
5685
6826
  title: t("section.changes"),
5686
6827
  count: workingChanges.length,
@@ -5688,12 +6829,32 @@
5688
6829
  open: sections.changes,
5689
6830
  onToggle: () => toggleSection("changes"),
5690
6831
  actions: changesActions()
5691
- }, workingChanges.length === 0 ? h("div", { className: "dgscm-section-note" }, t("empty.changes")) : changeRows("changes", workingChanges)), h(Group, {
6832
+ }, workingChanges.length === 0 ? h("div", { className: "dgscm-section-note" }, t("empty.changes")) : changeSectionRows("changes", workingChanges)), h(Group, {
5692
6833
  id: "repositories",
5693
6834
  title: t("group.repositories"),
5694
6835
  open: sections.groupRepositories,
5695
6836
  onToggle: () => toggleSection("groupRepositories")
5696
6837
  }, h(Section, {
6838
+ id: "worktrees",
6839
+ title: t("section.worktrees"),
6840
+ count: worktrees.length,
6841
+ open: sections.worktrees,
6842
+ onToggle: () => toggleSection("worktrees"),
6843
+ glyph: h(FolderIcon, { size: 13 }),
6844
+ actions: h(IconButton, {
6845
+ label: t("action.createWorktree"),
6846
+ disabled: working || repo.unborn === true,
6847
+ onClick: (event) => openMenu(event, worktreeAddMenuItems())
6848
+ }, h(PlusIcon, { size: 13 }))
6849
+ }, worktrees.length === 0 ? h("div", { className: "dgscm-section-note" }, t("empty.worktrees")) : worktrees.map((worktree) => h(WorktreeRow, {
6850
+ key: `worktree:${worktree.path}`,
6851
+ worktree,
6852
+ pathLabel: worktreePathLabel(worktree),
6853
+ t,
6854
+ onSwitch: requestSwitchWorktree,
6855
+ onMenu: (event) => openMenu(event, worktreeMenuItems(worktree)),
6856
+ onContextMenu: (event) => openMenu(event, worktreeMenuItems(worktree))
6857
+ }))), h(Section, {
5697
6858
  id: "branches",
5698
6859
  title: t("section.branches"),
5699
6860
  count: branches.local.length,
@@ -5812,10 +6973,10 @@
5812
6973
  })
5813
6974
  }
5814
6975
  ])
5815
- })))))), previewOpen ? h(React.Fragment, null, h("div", {
5816
- className: `dgscm-divider${previewLayout === "right" ? " dgscm-divider--vertical" : ""}${dragging ? " dgscm-divider--active" : ""}`,
6976
+ })))))), previewOpen ? h(React.Fragment, null, collapsedPane ? null : h("div", {
6977
+ className: `dgscm-divider${paneLayout === "right" ? " dgscm-divider--vertical" : ""}${dragging ? " dgscm-divider--active" : ""}`,
5817
6978
  role: "separator",
5818
- "aria-orientation": previewLayout === "right" ? "vertical" : "horizontal",
6979
+ "aria-orientation": paneLayout === "right" ? "vertical" : "horizontal",
5819
6980
  "aria-label": t("diff.resize"),
5820
6981
  title: t("diff.resize"),
5821
6982
  onPointerDown: startResize,
@@ -5824,9 +6985,9 @@
5824
6985
  onPointerCancel: endResize,
5825
6986
  onDoubleClick: resetResize
5826
6987
  }), h("div", {
5827
- className: `dgscm-diffpane${previewLayout === "right" ? " dgscm-diffpane--right" : ""}`,
5828
- style: previewLayout === "right" ? { width: `${paneWidth}px` } : { height: `${paneHeight}px` }
5829
- }, previewLayout === "right" ? h("div", {
6988
+ className: `dgscm-diffpane${paneLayout === "right" ? " dgscm-diffpane--right" : ""}${collapsedPane ? " dgscm-diffpane--collapsed" : ""}`,
6989
+ style: paneLayout === "right" ? { width: `${paneWidth}px` } : collapsedPane ? void 0 : { height: `${paneHeight}px` }
6990
+ }, paneLayout === "right" ? h("div", {
5830
6991
  className: "dgscm-resize-edge",
5831
6992
  "aria-hidden": true,
5832
6993
  onPointerDown: startResize,
@@ -5840,18 +7001,21 @@
5840
7001
  mode: diffMode,
5841
7002
  onMode: setDiffMode,
5842
7003
  onClose: closePreview,
5843
- onNative: view.source.kind === "worktree" || view.source.kind === "staged" || view.source.kind === "untracked" ? () => openNative(view.path) : void 0,
5844
7004
  onMaximize: () => setDiffMaximized((current) => !current),
5845
7005
  maximized: diffMaximized,
5846
7006
  searchSignal,
5847
- layout: previewLayout,
7007
+ layout: paneLayout,
7008
+ layoutFixed,
7009
+ collapsed: collapsedPane,
7010
+ onToggleCollapsed: () => setComparisonCollapsed((current) => !current),
5848
7011
  onLayout: switchLayout,
5849
7012
  onBack: view.fromHistory === true && history !== null ? backToHistory : view.fromReview === true && review !== null ? () => setView(null) : void 0,
5850
7013
  backLabel: view.fromHistory === true ? t("history.back") : t("review.back"),
5851
7014
  t
5852
7015
  }) : review !== null ? h(ReviewPane, {
5853
7016
  review,
5854
- layout: previewLayout,
7017
+ layout: paneLayout,
7018
+ layoutFixed,
5855
7019
  onLayout: switchLayout,
5856
7020
  maximized: diffMaximized,
5857
7021
  onMaximize: () => setDiffMaximized((current) => !current),
@@ -5862,7 +7026,8 @@
5862
7026
  t
5863
7027
  }) : h(HistoryPane, {
5864
7028
  state: history,
5865
- layout: previewLayout,
7029
+ layout: paneLayout,
7030
+ layoutFixed,
5866
7031
  onLayout: switchLayout,
5867
7032
  maximized: diffMaximized,
5868
7033
  onMaximize: () => setDiffMaximized((current) => !current),
@@ -5885,6 +7050,17 @@
5885
7050
  prompt,
5886
7051
  onCancel: () => setPrompt(null),
5887
7052
  t
7053
+ }), worktreeDialog === null ? null : h(WorktreeDialog, {
7054
+ state: worktreeDialog,
7055
+ base: repo.branch === null || repo.branch === void 0 ? "HEAD" : repo.branch,
7056
+ onChange: updateWorktreeBranch,
7057
+ onCancel: () => {
7058
+ if (worktreeDialog.submitting !== true) setWorktreeDialog(null);
7059
+ },
7060
+ onSubmit: () => {
7061
+ createWorktree();
7062
+ },
7063
+ t
5888
7064
  }), menu === null ? null : h(ContextMenu, {
5889
7065
  menu,
5890
7066
  onClose: () => {
@@ -5958,6 +7134,80 @@
5958
7134
  */
5959
7135
  function apply(ctx) {
5960
7136
  const t = ctx.locale.bind(NS);
7137
+ /**
7138
+ * Preview tabs this panel opened, by Session id, so later opens update the
7139
+ * same tab instead of stacking one tab per file.
7140
+ * @type {Map<string, string>}
7141
+ */
7142
+ const previewTabs = /* @__PURE__ */ new Map();
7143
+ /**
7144
+ * Opens whose preview tab the right Sidebar has not published yet.
7145
+ * @type {Map<string, { address: string, before: Set<string> }>}
7146
+ */
7147
+ const pendingPreviewOpens = /* @__PURE__ */ new Map();
7148
+ /**
7149
+ * Record the tab the right Sidebar published for one Session and file address.
7150
+ * @param {string} sessionId - the Session that owns the file.
7151
+ * @param {string} address - the resource address that was opened.
7152
+ * @param {Set<string>} before - tab ids present before the open.
7153
+ * @returns {boolean} whether a matching tab was found.
7154
+ */
7155
+ const rememberPreviewTab = (sessionId, address, before) => {
7156
+ const snapshot = ctx.sidebarRight?.openTabs?.getSnapshot?.();
7157
+ if (!Array.isArray(snapshot)) return false;
7158
+ const matches = snapshot.filter((tab) => tab.sessionId === sessionId && tab.contentId === address);
7159
+ const chosen = matches.find((tab) => !before.has(tab.tabId)) ?? matches[0];
7160
+ if (chosen === void 0) return false;
7161
+ previewTabs.set(sessionId, chosen.tabId);
7162
+ return true;
7163
+ };
7164
+ ctx.effect(() => {
7165
+ const source = ctx.sidebarRight?.openTabs;
7166
+ if (typeof source?.subscribe !== "function" || typeof source?.getSnapshot !== "function") return void 0;
7167
+ const sync = () => {
7168
+ for (const [sessionId, pending] of pendingPreviewOpens) if (rememberPreviewTab(sessionId, pending.address, pending.before)) pendingPreviewOpens.delete(sessionId);
7169
+ };
7170
+ const unsubscribe = source.subscribe(sync);
7171
+ sync();
7172
+ return unsubscribe;
7173
+ }, "dsh-git-scm: file preview tracking");
7174
+ /**
7175
+ * Open one Session-relative file in the app's code view. The first open
7176
+ * splits the panel's docked pane (change list left, preview right); later
7177
+ * opens replace the preview tab this panel opened.
7178
+ * @param {string} sessionId - the Session that owns the file.
7179
+ * @param {string} path - repository-relative file path.
7180
+ * @param {object} [actions] - the tab's own navigation actions, when supplied.
7181
+ * @returns {boolean} whether an installed view claimed the file address.
7182
+ */
7183
+ const openFilePreview = (sessionId, path, actions) => {
7184
+ const address = fileAddressOf(sessionId, path);
7185
+ const snapshot = ctx.sidebarRight?.openTabs?.getSnapshot?.();
7186
+ const before = new Set(Array.isArray(snapshot) ? snapshot.filter((tab) => tab.sessionId === sessionId).map((tab) => tab.tabId) : []);
7187
+ const tracked = previewTabs.get(sessionId);
7188
+ const trackedAlive = tracked !== void 0 && before.has(tracked);
7189
+ try {
7190
+ if (trackedAlive) ctx.sidebarRight.openResource(address, {
7191
+ replaceTab: tracked,
7192
+ revealIfOpened: true
7193
+ });
7194
+ else if (typeof actions?.openResource === "function") actions.openResource(address, {
7195
+ preferNewPane: true,
7196
+ revealIfOpened: true
7197
+ });
7198
+ else ctx.sidebarRight.openResource(address, {
7199
+ preferNewPane: true,
7200
+ revealIfOpened: true
7201
+ });
7202
+ } catch {
7203
+ return false;
7204
+ }
7205
+ if (!rememberPreviewTab(sessionId, address, before)) pendingPreviewOpens.set(sessionId, {
7206
+ address,
7207
+ before
7208
+ });
7209
+ return true;
7210
+ };
5961
7211
  ctx.effect(() => ctx.locale.register(NS, "en", EN), "dsh-git-scm: copy en");
5962
7212
  ctx.effect(() => ctx.locale.register(NS, "zh", ZH), "dsh-git-scm: copy zh");
5963
7213
  ctx.effect(() => {
@@ -5986,31 +7236,13 @@
5986
7236
  inject: (sessionId) => ({
5987
7237
  localeId: () => ctx.locale.getLocale().active,
5988
7238
  /**
5989
- * Open the app's own local-changes view scrolled to one file.
5990
- * @param {string} path - repository-relative path.
5991
- * @returns {boolean} whether the address was claimed by an installed view.
5992
- */
5993
- openNativeChanges: (path) => {
5994
- try {
5995
- ctx.sidebarRight.openResource(nativeChangesAddress(sessionId), { params: { path } });
5996
- return true;
5997
- } catch {
5998
- return false;
5999
- }
6000
- },
6001
- /**
6002
- * Open one Session-relative file in the app's own code view.
7239
+ * Open one Session-relative file in the app's own code view, reusing the
7240
+ * preview tab this panel opened.
6003
7241
  * @param {string} path - repository-relative file path.
7242
+ * @param {object} [actions] - the enclosing tab's navigation actions.
6004
7243
  * @returns {boolean} whether the address was claimed by an installed view.
6005
7244
  */
6006
- openFile: (path) => {
6007
- try {
6008
- ctx.sidebarRight.openResource(fileAddressOf(sessionId, path));
6009
- return true;
6010
- } catch {
6011
- return false;
6012
- }
6013
- }
7245
+ openFile: (path, actions) => openFilePreview(sessionId, path, actions)
6014
7246
  })
6015
7247
  }, ScmPanel)), "dsh-git-scm: tab body");
6016
7248
  ctx.effect(() => ctx.slots.inject("sidebar.right.pane.tab.title", () => ctx.slots.register({