Conversation
Prompt To Fix All With AIThis is a comment left during a code review.
Path: apps/code/src/renderer/features/code-review/utils/resolveDiffSource.test.ts
Line: 1-96
Comment:
**Prefer parameterised tests**
All 8 test cases call the same function with different inputs — this is exactly what `it.each` is for. Per the team's standard, parameterised tests are preferred.
```ts
describe("resolveDiffSource", () => {
it.each([
// heuristic (no user choice)
{ configured: null, hasLocalChanges: true, linkedBranch: "feat/x", aheadOfDefault: 3, expected: "local", desc: "uncommitted changes → local" },
{ configured: null, hasLocalChanges: false, linkedBranch: "feat/x", aheadOfDefault: 2, expected: "branch", desc: "clean tree with commits ahead → branch" },
{ configured: null, hasLocalChanges: false, linkedBranch: null, aheadOfDefault: 0, expected: "local", desc: "no linked branch → local" },
{ configured: null, hasLocalChanges: false, linkedBranch: "feat/x", aheadOfDefault: 0, expected: "local", desc: "no commits ahead → local" },
// explicit override
{ configured: "local", hasLocalChanges: false, linkedBranch: "feat/x", aheadOfDefault: 5, expected: "local", desc: "explicit local respected even when branch available" },
{ configured: "branch", hasLocalChanges: true, linkedBranch: "feat/x", aheadOfDefault: 1, expected: "branch", desc: "explicit branch respected when available" },
{ configured: "branch", hasLocalChanges: false, linkedBranch: null, aheadOfDefault: 0, expected: "local", desc: "explicit branch falls back to local (no linked branch)" },
{ configured: "branch", hasLocalChanges: false, linkedBranch: "feat/x", aheadOfDefault: 0, expected: "local", desc: "explicit branch falls back to local (no commits ahead)" },
] as const)("$desc", ({ configured, hasLocalChanges, linkedBranch, aheadOfDefault, expected }) => {
expect(resolveDiffSource({ configured, hasLocalChanges, linkedBranch, aheadOfDefault })).toBe(expected);
});
});
```
How can I resolve this? If you propose a fix, please make it concise.
---
This is a comment left during a code review.
Path: apps/code/src/renderer/features/code-review/components/ReviewPage.tsx
Line: 201-211
Comment:
**Misleading empty state when `repoSlug` is unavailable**
When `repoInfo` is `undefined` (e.g., `useGitQueries` hasn't resolved yet or the remote origin is unset), `repoSlug` is `null` and the query is disabled. `files` stays as `EMPTY_BRANCH_FILES`, so `isLoading` is `false` and `isEmpty` is `true`, causing "No file changes to review" to appear — even though the real issue is that the repo slug couldn't be determined. A user who has commits ahead of default would see this and think the feature is broken.
Consider checking `!repoSlug` explicitly and rendering a distinct message, or keeping `isLoading={isLoading || (!repoSlug && isReviewOpen)}` to show the spinner while metadata is still resolving.
How can I resolve this? If you propose a fix, please make it concise.Reviews (1): Last reviewed commit: "feat(code): add diff source selector" | Re-trigger Greptile |
| import { describe, expect, it } from "vitest"; | ||
| import { resolveDiffSource } from "./resolveDiffSource"; | ||
|
|
||
| describe("resolveDiffSource", () => { | ||
| describe("heuristic (no user choice)", () => { | ||
| it("picks local when there are uncommitted changes", () => { | ||
| expect( | ||
| resolveDiffSource({ | ||
| configured: null, | ||
| hasLocalChanges: true, | ||
| linkedBranch: "feat/x", | ||
| aheadOfDefault: 3, | ||
| }), | ||
| ).toBe("local"); | ||
| }); | ||
|
|
||
| it("picks branch on clean tree with commits ahead", () => { | ||
| expect( | ||
| resolveDiffSource({ | ||
| configured: null, | ||
| hasLocalChanges: false, | ||
| linkedBranch: "feat/x", | ||
| aheadOfDefault: 2, | ||
| }), | ||
| ).toBe("branch"); | ||
| }); | ||
|
|
||
| it("picks local on clean tree with no linked branch", () => { | ||
| expect( | ||
| resolveDiffSource({ | ||
| configured: null, | ||
| hasLocalChanges: false, | ||
| linkedBranch: null, | ||
| aheadOfDefault: 0, | ||
| }), | ||
| ).toBe("local"); | ||
| }); | ||
|
|
||
| it("picks local on clean tree with linked branch but no commits ahead", () => { | ||
| expect( | ||
| resolveDiffSource({ | ||
| configured: null, | ||
| hasLocalChanges: false, | ||
| linkedBranch: "feat/x", | ||
| aheadOfDefault: 0, | ||
| }), | ||
| ).toBe("local"); | ||
| }); | ||
| }); | ||
|
|
||
| describe("explicit override", () => { | ||
| it("respects explicit local even when branch is available", () => { | ||
| expect( | ||
| resolveDiffSource({ | ||
| configured: "local", | ||
| hasLocalChanges: false, | ||
| linkedBranch: "feat/x", | ||
| aheadOfDefault: 5, | ||
| }), | ||
| ).toBe("local"); | ||
| }); | ||
|
|
||
| it("respects explicit branch when available", () => { | ||
| expect( | ||
| resolveDiffSource({ | ||
| configured: "branch", | ||
| hasLocalChanges: true, | ||
| linkedBranch: "feat/x", | ||
| aheadOfDefault: 1, | ||
| }), | ||
| ).toBe("branch"); | ||
| }); | ||
|
|
||
| it("falls back to local when explicit branch is unavailable (no linked branch)", () => { | ||
| expect( | ||
| resolveDiffSource({ | ||
| configured: "branch", | ||
| hasLocalChanges: false, | ||
| linkedBranch: null, | ||
| aheadOfDefault: 0, | ||
| }), | ||
| ).toBe("local"); | ||
| }); | ||
|
|
||
| it("falls back to local when explicit branch is unavailable (no commits ahead)", () => { | ||
| expect( | ||
| resolveDiffSource({ | ||
| configured: "branch", | ||
| hasLocalChanges: false, | ||
| linkedBranch: "feat/x", | ||
| aheadOfDefault: 0, | ||
| }), | ||
| ).toBe("local"); | ||
| }); | ||
| }); | ||
| }); |
There was a problem hiding this comment.
All 8 test cases call the same function with different inputs — this is exactly what it.each is for. Per the team's standard, parameterised tests are preferred.
describe("resolveDiffSource", () => {
it.each([
// heuristic (no user choice)
{ configured: null, hasLocalChanges: true, linkedBranch: "feat/x", aheadOfDefault: 3, expected: "local", desc: "uncommitted changes → local" },
{ configured: null, hasLocalChanges: false, linkedBranch: "feat/x", aheadOfDefault: 2, expected: "branch", desc: "clean tree with commits ahead → branch" },
{ configured: null, hasLocalChanges: false, linkedBranch: null, aheadOfDefault: 0, expected: "local", desc: "no linked branch → local" },
{ configured: null, hasLocalChanges: false, linkedBranch: "feat/x", aheadOfDefault: 0, expected: "local", desc: "no commits ahead → local" },
// explicit override
{ configured: "local", hasLocalChanges: false, linkedBranch: "feat/x", aheadOfDefault: 5, expected: "local", desc: "explicit local respected even when branch available" },
{ configured: "branch", hasLocalChanges: true, linkedBranch: "feat/x", aheadOfDefault: 1, expected: "branch", desc: "explicit branch respected when available" },
{ configured: "branch", hasLocalChanges: false, linkedBranch: null, aheadOfDefault: 0, expected: "local", desc: "explicit branch falls back to local (no linked branch)" },
{ configured: "branch", hasLocalChanges: false, linkedBranch: "feat/x", aheadOfDefault: 0, expected: "local", desc: "explicit branch falls back to local (no commits ahead)" },
] as const)("$desc", ({ configured, hasLocalChanges, linkedBranch, aheadOfDefault, expected }) => {
expect(resolveDiffSource({ configured, hasLocalChanges, linkedBranch, aheadOfDefault })).toBe(expected);
});
});Prompt To Fix With AI
This is a comment left during a code review.
Path: apps/code/src/renderer/features/code-review/utils/resolveDiffSource.test.ts
Line: 1-96
Comment:
**Prefer parameterised tests**
All 8 test cases call the same function with different inputs — this is exactly what `it.each` is for. Per the team's standard, parameterised tests are preferred.
```ts
describe("resolveDiffSource", () => {
it.each([
// heuristic (no user choice)
{ configured: null, hasLocalChanges: true, linkedBranch: "feat/x", aheadOfDefault: 3, expected: "local", desc: "uncommitted changes → local" },
{ configured: null, hasLocalChanges: false, linkedBranch: "feat/x", aheadOfDefault: 2, expected: "branch", desc: "clean tree with commits ahead → branch" },
{ configured: null, hasLocalChanges: false, linkedBranch: null, aheadOfDefault: 0, expected: "local", desc: "no linked branch → local" },
{ configured: null, hasLocalChanges: false, linkedBranch: "feat/x", aheadOfDefault: 0, expected: "local", desc: "no commits ahead → local" },
// explicit override
{ configured: "local", hasLocalChanges: false, linkedBranch: "feat/x", aheadOfDefault: 5, expected: "local", desc: "explicit local respected even when branch available" },
{ configured: "branch", hasLocalChanges: true, linkedBranch: "feat/x", aheadOfDefault: 1, expected: "branch", desc: "explicit branch respected when available" },
{ configured: "branch", hasLocalChanges: false, linkedBranch: null, aheadOfDefault: 0, expected: "local", desc: "explicit branch falls back to local (no linked branch)" },
{ configured: "branch", hasLocalChanges: false, linkedBranch: "feat/x", aheadOfDefault: 0, expected: "local", desc: "explicit branch falls back to local (no commits ahead)" },
] as const)("$desc", ({ configured, hasLocalChanges, linkedBranch, aheadOfDefault, expected }) => {
expect(resolveDiffSource({ configured, hasLocalChanges, linkedBranch, aheadOfDefault })).toBe(expected);
});
});
```
How can I resolve this? If you propose a fix, please make it concise.Note: If this suggestion doesn't match your team's coding style, reply to this and let me know. I'll remember it for next time!
| const { data: files = EMPTY_BRANCH_FILES, isLoading } = useQuery( | ||
| trpc.git.getBranchChangedFiles.queryOptions( | ||
| { repo: repoSlug as string, branch }, | ||
| { | ||
| enabled: isReviewOpen && !!repoSlug, | ||
| staleTime: 30_000, | ||
| refetchInterval: 30_000, | ||
| retry: 1, | ||
| }, | ||
| ), | ||
| ); |
There was a problem hiding this comment.
Misleading empty state when
repoSlug is unavailable
When repoInfo is undefined (e.g., useGitQueries hasn't resolved yet or the remote origin is unset), repoSlug is null and the query is disabled. files stays as EMPTY_BRANCH_FILES, so isLoading is false and isEmpty is true, causing "No file changes to review" to appear — even though the real issue is that the repo slug couldn't be determined. A user who has commits ahead of default would see this and think the feature is broken.
Consider checking !repoSlug explicitly and rendering a distinct message, or keeping isLoading={isLoading || (!repoSlug && isReviewOpen)} to show the spinner while metadata is still resolving.
Prompt To Fix With AI
This is a comment left during a code review.
Path: apps/code/src/renderer/features/code-review/components/ReviewPage.tsx
Line: 201-211
Comment:
**Misleading empty state when `repoSlug` is unavailable**
When `repoInfo` is `undefined` (e.g., `useGitQueries` hasn't resolved yet or the remote origin is unset), `repoSlug` is `null` and the query is disabled. `files` stays as `EMPTY_BRANCH_FILES`, so `isLoading` is `false` and `isEmpty` is `true`, causing "No file changes to review" to appear — even though the real issue is that the repo slug couldn't be determined. A user who has commits ahead of default would see this and think the feature is broken.
Consider checking `!repoSlug` explicitly and rendering a distinct message, or keeping `isLoading={isLoading || (!repoSlug && isReviewOpen)}` to show the spinner while metadata is still resolving.
How can I resolve this? If you propose a fix, please make it concise.
Problem
for local tasks we only show one diff - just the local diff state
this means when you push changes or open a PR, the diff panel becomes empty
Changes
adds a new diff source selector dropdown menu
right now it has two options:
this will include "PR" as an option soon!
How did you test this?
manully