Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 5 additions & 2 deletions src/renderer/src/state/actions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -193,6 +193,7 @@ async function handleRepoChanged(reason: 'worktree' | 'refs' | 'both'): Promise<
if (reason !== 'worktree') {
await Promise.all([refreshBranches(), refreshStashes()]);
if (store.get().view === 'history') await loadHistory(true);
else patchHistory({ stale: true });
}
await loadDiff(true);
if (store.get().precommitReview.run) void refreshPrecommitStaleness();
Expand Down Expand Up @@ -760,7 +761,7 @@ export function setView(view: View): void {
store.set({ view });
if (view === 'history') {
const h = store.get().history;
if (!h.commits.length) void loadHistory(true);
if (!h.commits.length || h.stale) void loadHistory(true);
else if (!h.selectedShas.length) selectCommit(h.commits[0].sha);
} else if (view === 'stashes') {
void loadStashesView();
Expand Down Expand Up @@ -931,7 +932,7 @@ export async function loadHistory(reset: boolean): Promise<void> {
if (store.get().currentRepo?.path !== repo.path) return;
const commits = reset ? page.commits : [...h.commits, ...page.commits];
const stillSelected = store.get().history.selectedShas.filter((sha) => commits.some((c) => c.sha === sha));
patchHistory({ commits, hasMore: page.hasMore, loading: false, slowSearch: false, error: null, selectedShas: stillSelected, details: stillSelected.length === 1 ? store.get().history.details : null });
patchHistory({ commits, hasMore: page.hasMore, loading: false, slowSearch: false, error: null, selectedShas: stillSelected, details: stillSelected.length === 1 ? store.get().history.details : null, stale: store.get().history.stale && !(reset && h.stale) });
if (store.get().view === 'history' && stillSelected.length === 0 && commits.length) selectCommit(commits[0].sha);
else if (stillSelected.length === 1 && reset) void loadCommitDetails(stillSelected[0]);
} catch (err) {
Expand Down Expand Up @@ -1344,6 +1345,7 @@ export async function fetchRemote(): Promise<void> {
const repo = store.get().currentRepo;
if (!repo) return;
await runOperation('Fetch', () => invoke('git.fetch', repo.path, null));
void loadCurrentPullRequest(true);
}

export async function pull(): Promise<void> {
Expand All @@ -1352,6 +1354,7 @@ export async function pull(): Promise<void> {
const outcome = await runOperation('Pull', () => invoke('git.pull', repo.path));
if (outcome?.status === 'conflicts') reportOutcome(outcome, 'Pull');
else if (outcome?.status === 'complete') showToast({ kind: 'success', title: 'Pulled latest changes' });
void loadCurrentPullRequest(true);
}

export async function push(force = false): Promise<void> {
Expand Down
4 changes: 3 additions & 1 deletion src/renderer/src/state/store.ts
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,8 @@ export interface HistoryState {
error: string | null;
/** Set when the most recent commit-details load failed; cleared on the next successful load and when a new load starts. */
detailsError: string | null;
/** Set when refs changed (commit/branch move) while the History tab was not the active view, so switching back reloads instead of showing a cached list. */
stale: boolean;
}

export interface ReviewState {
Expand Down Expand Up @@ -484,7 +486,7 @@ export const initialChanges: ChangesState = {

export const initialStashesView: StashesViewState = { loading: false, selectedSha: null, files: [], filesLoading: false, selectedFile: null };

export const initialHistory: HistoryState = { commits: [], hasMore: false, loading: false, search: '', query: EMPTY_HISTORY_QUERY, freeText: '', queryError: null, slowSearch: false, selectedShas: [], details: null, detailsLoading: false, selectedFile: null, matchingFiles: null, dragging: null, path: null, pathHistory: null, error: null, detailsError: null };
export const initialHistory: HistoryState = { commits: [], hasMore: false, loading: false, search: '', query: EMPTY_HISTORY_QUERY, freeText: '', queryError: null, slowSearch: false, selectedShas: [], details: null, detailsLoading: false, selectedFile: null, matchingFiles: null, dragging: null, path: null, pathHistory: null, error: null, detailsError: null, stale: false };

export const initialDiff: DiffState = { key: null, diff: null, loading: false, error: null, selectedLines: null, blameOn: false, blame: null, blameLoading: false, activeBlameId: null, highlightTerm: null };

Expand Down
Loading