Skip to content

Commit 901de4e

Browse files
committed
feat(graph): add comparison panel toggle for multi-selected commits
- Add "View Changes" / "Hide Changes" toggle to the multi-select context menu - Gate comparison fetch on panel visibility so reopening reloads the diff - Esc closes the panel first, then clears the selection on a second press - Keep the multi-selection when closing the panel via the X button
1 parent 91356cd commit 901de4e

6 files changed

Lines changed: 22 additions & 3 deletions

File tree

webview-ui/src/App.svelte

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -256,7 +256,8 @@ import AmendModal from './components/modals/AmendModal.svelte';
256256
vscode.postMessage({ type: 'getBranches' });
257257
}
258258
259-
if (e.key === 'Escape' && !modalStore.anyOpen && uiStore.showBottomPanel && (uiStore.selectedCommitHash || uiStore.comparing)) {
259+
// Multi-select Esc is handled in CommitGraph (1st Esc closes the panel, 2nd clears the selection).
260+
if (e.key === 'Escape' && !modalStore.anyOpen && !uiStore.multiSelectArmed && uiStore.showBottomPanel && (uiStore.selectedCommitHash || uiStore.comparing)) {
260261
e.preventDefault();
261262
if (uiStore.commitDetailFullscreen) {
262263
uiStore.commitDetailFullscreen = false;

webview-ui/src/components/commit/CommitDetails.svelte

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -566,7 +566,7 @@
566566
<button class="tab-action-btn" aria-label={uiStore.commitDetailFullscreen ? t('details.restore') : t('details.fullscreen')} use:tooltip={uiStore.commitDetailFullscreen ? t('details.restore') : t('details.fullscreen')} onclick={() => { uiStore.commitDetailFullscreen = !uiStore.commitDetailFullscreen; }}>
567567
<i class="codicon {uiStore.commitDetailFullscreen ? 'codicon-chevron-down' : 'codicon-chevron-up'}"></i>
568568
</button>
569-
<button class="tab-action-btn" aria-label={t('common.close')} use:tooltip={t('common.close')} onclick={() => { uiStore.selectCommit(null); uiStore.showBottomPanel = false; uiStore.commitDetailFullscreen = false; }}>
569+
<button class="tab-action-btn" aria-label={t('common.close')} use:tooltip={t('common.close')} onclick={() => { if (!uiStore.multiSelectArmed) { uiStore.selectCommit(null); } uiStore.showBottomPanel = false; uiStore.commitDetailFullscreen = false; }}>
570570
<i class="codicon codicon-close"></i>
571571
</button>
572572
</div>

webview-ui/src/components/graph/CommitGraph.svelte

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -650,6 +650,13 @@
650650
.reverse();
651651
const multiItems: any[] = [];
652652
653+
// Toggle the bottom panel showing the comparison of the selected commits.
654+
multiItems.push({
655+
label: uiStore.showBottomPanel ? t('graph.hideChanges') : t('graph.viewChanges'),
656+
action: () => { uiStore.showBottomPanel = !uiStore.showBottomPanel; },
657+
});
658+
multiItems.push({ separator: true, label: '', action: () => {} });
659+
653660
const chain = getSquashChain(sel, commitStore.commitMap as Map<string, Commit>);
654661
if (chain) {
655662
multiItems.push({
@@ -1092,7 +1099,10 @@
10921099
// Orchestration: when armed selection changes, request the right compare data.
10931100
let lastCompareKey = '';
10941101
$effect(() => {
1095-
if (!uiStore.multiSelectArmed) { lastCompareKey = ''; return; }
1102+
// Only fetch the comparison while the bottom panel is open — the panel hosts
1103+
// CommitDetails, which is the listener for the compare/section responses.
1104+
// Opening it via "View Changes" re-runs this effect and (re)loads the data.
1105+
if (!uiStore.multiSelectArmed || !uiStore.showBottomPanel) { lastCompareKey = ''; return; }
10961106
const sel = uiStore.selectedCommitHashes;
10971107
if (sel.length < 2) { lastCompareKey = ''; return; }
10981108
// Order by display order (newest first).
@@ -1154,6 +1164,8 @@
11541164
if (e.key === 'Escape') {
11551165
if (bisectBadCommit) { bisectBadCommit = null; }
11561166
else if (bisectCulpritHash) { vscode.postMessage({ type: 'bisectReset' }); }
1167+
// 1st Esc closes the open bottom panel; 2nd Esc clears the selection.
1168+
else if (uiStore.multiSelectArmed && uiStore.showBottomPanel) { uiStore.showBottomPanel = false; }
11571169
else if (uiStore.multiSelectArmed) { uiStore.exitMultiSelect(); }
11581170
} else {
11591171
handleGraphNavKey(e);

webview-ui/src/lib/i18n/en.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -166,6 +166,8 @@ export const en: Record<string, string> = {
166166
'graph.commitFixup': 'Commit Fixup',
167167
'graph.savePatch': 'Save as Patch',
168168
'graph.compareToLocal': 'Compare to Local Changes',
169+
'graph.viewChanges': 'View Changes',
170+
'graph.hideChanges': 'Hide Changes',
169171
'graph.copyShortSHA': 'Copy Short SHA',
170172
'graph.copySHA': 'Copy Commit SHA',
171173
'graph.copyCommitInfo': 'Copy Commit Info',

webview-ui/src/lib/i18n/ko.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -166,6 +166,8 @@ export const ko: Record<string, string> = {
166166
'graph.commitFixup': 'Commit Fixup',
167167
'graph.savePatch': '패치로 저장',
168168
'graph.compareToLocal': '로컬 변경사항과 비교',
169+
'graph.viewChanges': '변경사항 보기',
170+
'graph.hideChanges': '변경사항 닫기',
169171
'graph.copyShortSHA': 'Short SHA 복사',
170172
'graph.copySHA': 'Commit SHA 복사',
171173
'graph.copyCommitInfo': 'Commit 정보 복사',

webview-ui/src/lib/i18n/zh.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -166,6 +166,8 @@ export const zh: Record<string, string> = {
166166
'graph.commitFixup': 'Commit Fixup',
167167
'graph.savePatch': '另存为补丁',
168168
'graph.compareToLocal': '与本地更改比较',
169+
'graph.viewChanges': '查看更改',
170+
'graph.hideChanges': '关闭更改',
169171
'graph.copyShortSHA': '复制短 SHA',
170172
'graph.copySHA': '复制提交 SHA',
171173
'graph.copyCommitInfo': '复制提交信息',

0 commit comments

Comments
 (0)