Skip to content

Commit 856324a

Browse files
committed
fix: preserve filters across manual and auto refresh (#12)
Manual refresh from the Toolbar button was sending getLog without filter state, causing the backend to drop the saved filters while the webview UI continued to show them as active. Auto refresh via refreshAll only passed remoteFilter to git log (branch filter was lost) and the fullRefresh handler unconditionally reset both filter UIs. - Toolbar now delegates refresh to an onRefresh callback so App.svelte can include the current branch and remote filters in the request. - refreshAll passes both currentRemoteFilter and currentBranchFilter to git log and includes them in the fullRefresh payload. - The fullRefresh handler now syncs filter UI from the payload instead of clearing it, so file-watcher refreshes keep filters intact while repo switches (which clear filters on the backend) still reset the UI.
1 parent 4f21985 commit 856324a

3 files changed

Lines changed: 19 additions & 8 deletions

File tree

src/panels/MainPanel.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1182,7 +1182,7 @@ export class MainPanel {
11821182
const sortOrder = vscode.workspace.getConfiguration('gitGraphPlus').get<'author-date' | 'date' | 'topological'>('graphSortOrder', 'topological');
11831183
const refreshLimit = this.currentLimit || 1000;
11841184
const [allFetched, branches, tags, remotes, stashes, worktrees] = await Promise.all([
1185-
this.gitService.log({ limit: refreshLimit + 1, sortOrder, remoteFilter: this.currentRemoteFilter }),
1185+
this.gitService.log({ limit: refreshLimit + 1, sortOrder, remoteFilter: this.currentRemoteFilter, branches: this.currentBranchFilter }),
11861186
this.gitService.branches(),
11871187
this.gitService.tags(),
11881188
this.gitService.remotes(),
@@ -1198,7 +1198,7 @@ export class MainPanel {
11981198
this.panel.webview.postMessage({
11991199
type: 'fullRefresh',
12001200
payload: {
1201-
logData: { commits: allCommits, hasMore, currentLimit: this.currentLimit, graph, paths: fg.paths, links: fg.links, dots: fg.dots, commitLeftMargin: fg.commitLeftMargin },
1201+
logData: { commits: allCommits, hasMore, currentLimit: this.currentLimit, graph, paths: fg.paths, links: fg.links, dots: fg.dots, commitLeftMargin: fg.commitLeftMargin, remoteFilter: this.currentRemoteFilter, branches: this.currentBranchFilter },
12021202
branchData: { branches, tags, remotes, stashes, worktrees },
12031203
},
12041204
});

webview-ui/src/App.svelte

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -77,8 +77,8 @@
7777
branchStore.setData(msg.payload);
7878
break;
7979
case 'fullRefresh':
80-
remoteFilter = [];
81-
branchFilter = [];
80+
remoteFilter = msg.payload.logData.remoteFilter ?? [];
81+
branchFilter = msg.payload.logData.branches ?? [];
8282
branchStore.setData(msg.payload.branchData);
8383
commitStore.setData(msg.payload.logData);
8484
break;
@@ -301,7 +301,15 @@
301301
</script>
302302

303303
<div class="app-container" class:resizing>
304-
<Toolbar />
304+
<Toolbar onRefresh={() => {
305+
vscode.postMessage({ type: 'getLog', payload: {
306+
limit: commitStore.currentLimit || undefined,
307+
branches: branchFilter.length > 0 ? [...branchFilter] : undefined,
308+
remoteFilter: remoteFilter.length > 0 ? [...remoteFilter] : undefined,
309+
}});
310+
vscode.postMessage({ type: 'getBranches' });
311+
vscode.postMessage({ type: 'getRepoList' });
312+
}} />
305313

306314
{#if conflict}
307315
<div class="conflict-banner banner-card" transition:slide={{ duration: 150 }}>

webview-ui/src/components/layout/Toolbar.svelte

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,11 @@
1212
1313
const vscode = getVsCodeApi();
1414
15+
interface Props {
16+
onRefresh?: () => void;
17+
}
18+
let { onRefresh = () => {} }: Props = $props();
19+
1520
let showAddRemote = $state(false);
1621
let showRepoDropdown = $state(false);
1722
let showFlowDropdown = $state(false);
@@ -21,9 +26,7 @@
2126
2227
function refresh() {
2328
uiStore.operating = 'refresh';
24-
vscode.postMessage({ type: 'getLog', payload: { limit: 1000 } });
25-
vscode.postMessage({ type: 'getBranches' });
26-
vscode.postMessage({ type: 'getRepoList' });
29+
onRefresh();
2730
}
2831
2932
function switchToGraph() {

0 commit comments

Comments
 (0)