-
-
Notifications
You must be signed in to change notification settings - Fork 165
feat: add Git diff preload toggle in Settings and respect it in diff loading #298
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Dimillian
merged 4 commits into
main
from
codex/github-mention-perf]-large-git-changes-freezes-the-app
Jan 31, 2026
+196
−4
Merged
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
954c933
Add git diff preload setting
Dimillian ef02020
Merge branch 'main' into codex/github-mention-perf]-large-git-changes…
Dimillian bf5fe43
fix: load local diffs when panel opens to avoid empty state
Dimillian d9056f1
test: guard git diff preloading behind panel visibility
Dimillian File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,130 @@ | ||
| // @vitest-environment jsdom | ||
| import { act, renderHook } from "@testing-library/react"; | ||
| import { beforeEach, describe, expect, it, vi } from "vitest"; | ||
| import type { WorkspaceInfo } from "../../../types"; | ||
| import { useGitPanelController } from "./useGitPanelController"; | ||
|
|
||
| const useGitDiffsMock = vi.fn(); | ||
| const useGitStatusMock = vi.fn(); | ||
| const useGitLogMock = vi.fn(); | ||
| const useGitCommitDiffsMock = vi.fn(); | ||
|
|
||
| vi.mock("../../git/hooks/useGitDiffs", () => ({ | ||
| useGitDiffs: (...args: unknown[]) => useGitDiffsMock(...args), | ||
| })); | ||
|
|
||
| vi.mock("../../git/hooks/useGitStatus", () => ({ | ||
| useGitStatus: (...args: unknown[]) => useGitStatusMock(...args), | ||
| })); | ||
|
|
||
| vi.mock("../../git/hooks/useGitLog", () => ({ | ||
| useGitLog: (...args: unknown[]) => useGitLogMock(...args), | ||
| })); | ||
|
|
||
| vi.mock("../../git/hooks/useGitCommitDiffs", () => ({ | ||
| useGitCommitDiffs: (...args: unknown[]) => useGitCommitDiffsMock(...args), | ||
| })); | ||
|
|
||
| const workspace: WorkspaceInfo = { | ||
| id: "workspace-1", | ||
| name: "CodexMonitor", | ||
| path: "/tmp/codex-monitor", | ||
| connected: true, | ||
| settings: { sidebarCollapsed: false }, | ||
| }; | ||
|
|
||
| function makeProps(overrides?: Partial<Parameters<typeof useGitPanelController>[0]>) { | ||
| return { | ||
| activeWorkspace: workspace, | ||
| gitDiffPreloadEnabled: false, | ||
| isCompact: false, | ||
| isTablet: false, | ||
| activeTab: "codex" as const, | ||
| tabletTab: "codex" as const, | ||
| setActiveTab: vi.fn(), | ||
| prDiffs: [], | ||
| prDiffsLoading: false, | ||
| prDiffsError: null, | ||
| ...overrides, | ||
| }; | ||
| } | ||
|
|
||
| function getLastEnabledArg() { | ||
| const { calls } = useGitDiffsMock.mock; | ||
| if (calls.length === 0) { | ||
| return undefined; | ||
| } | ||
| return calls[calls.length - 1]?.[2]; | ||
| } | ||
|
|
||
| beforeEach(() => { | ||
| useGitStatusMock.mockReturnValue({ | ||
| status: { | ||
| branchName: "main", | ||
| files: [], | ||
| stagedFiles: [], | ||
| unstagedFiles: [], | ||
| totalAdditions: 0, | ||
| totalDeletions: 0, | ||
| }, | ||
| refresh: vi.fn(), | ||
| }); | ||
| useGitDiffsMock.mockReturnValue({ | ||
| diffs: [], | ||
| isLoading: false, | ||
| error: null, | ||
| refresh: vi.fn(), | ||
| }); | ||
| useGitLogMock.mockReturnValue({ | ||
| entries: [], | ||
| total: 0, | ||
| ahead: 0, | ||
| behind: 0, | ||
| aheadEntries: [], | ||
| behindEntries: [], | ||
| upstream: null, | ||
| isLoading: false, | ||
| error: null, | ||
| refresh: vi.fn(), | ||
| }); | ||
| useGitCommitDiffsMock.mockReturnValue({ | ||
| diffs: [], | ||
| isLoading: false, | ||
| error: null, | ||
| }); | ||
| useGitDiffsMock.mockClear(); | ||
| }); | ||
|
|
||
| describe("useGitPanelController preload behavior", () => { | ||
| it("does not preload diffs when disabled and panel is hidden", () => { | ||
| const { result } = renderHook(() => useGitPanelController(makeProps())); | ||
|
|
||
| const initialEnabled = getLastEnabledArg(); | ||
| expect(initialEnabled).toBe(true); | ||
|
|
||
| act(() => { | ||
| result.current.setGitPanelMode("issues"); | ||
| }); | ||
|
|
||
| const lastEnabled = getLastEnabledArg(); | ||
| expect(lastEnabled).toBe(false); | ||
| }); | ||
|
|
||
| it("loads diffs when the panel becomes visible even if preload is disabled", () => { | ||
| const { result } = renderHook(() => useGitPanelController(makeProps())); | ||
|
|
||
| act(() => { | ||
| result.current.setGitPanelMode("issues"); | ||
| }); | ||
|
|
||
| const hiddenEnabled = getLastEnabledArg(); | ||
| expect(hiddenEnabled).toBe(false); | ||
|
|
||
| act(() => { | ||
| result.current.setGitPanelMode("diff"); | ||
| }); | ||
|
|
||
| const visibleEnabled = getLastEnabledArg(); | ||
| expect(visibleEnabled).toBe(true); | ||
| }); | ||
| }); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.