Skip to content
Open
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
2 changes: 1 addition & 1 deletion apps/code/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@
"@opentelemetry/semantic-conventions": "^1.39.0",
"@parcel/watcher": "^2.5.6",
"@phosphor-icons/react": "^2.1.10",
"@pierre/diffs": "^1.1.21",
"@pierre/diffs": "^1.2.10",
"@posthog/agent": "workspace:*",
"@posthog/api-client": "workspace:*",
"@posthog/core": "workspace:*",
Expand Down
2 changes: 1 addition & 1 deletion packages/core/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
"dependencies": {
"@modelcontextprotocol/ext-apps": "^1.1.2",
"@modelcontextprotocol/sdk": "^1.12.1",
"@pierre/diffs": "^1.1.21",
"@pierre/diffs": "^1.2.10",
"@posthog/api-client": "workspace:*",
"@posthog/di": "workspace:*",
"@posthog/platform": "workspace:*",
Expand Down
22 changes: 22 additions & 0 deletions packages/core/src/code-review/diffAnnotations.test.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import type { FileDiffMetadata } from "@pierre/diffs";
import { describe, expect, it } from "vitest";
import {
buildCommentMergedOptions,
buildDraftAnnotations,
buildHunkAnnotations,
getLastChangeLineNumber,
Expand Down Expand Up @@ -80,3 +81,24 @@ describe("buildDraftAnnotations", () => {
});
});
});

describe("buildCommentMergedOptions", () => {
it.each([
{ hasOpenComment: false, expectedEnabled: true },
{ hasOpenComment: true, expectedEnabled: false },
])(
"with hasOpenComment=$hasOpenComment sets selection/gutter enabled=$expectedEnabled and routes both callbacks to the handler",
({ hasOpenComment, expectedEnabled }) => {
const handler = () => {};
const merged = buildCommentMergedOptions(
undefined,
hasOpenComment,
handler,
);
expect(merged.enableLineSelection).toBe(expectedEnabled);
expect(merged.enableGutterUtility).toBe(expectedEnabled);
expect(merged.onLineSelectionEnd).toBe(handler);
expect(merged.onGutterUtilityClick).toBe(handler);
},
);
});
Comment on lines 83 to +104

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Prefer parameterised tests for boolean toggle behaviour

The two new buildCommentMergedOptions cases only differ on the hasOpenComment flag and the expected value of enableLineSelection/enableGutterUtility. Expressing them as a single it.each table (e.g. [false, true, true], [true, false, false]) would make it easier to see the invariant and add future cases without duplicating the setup.

Prompt To Fix With AI
This is a comment left during a code review.
Path: packages/core/src/code-review/diffAnnotations.test.ts
Line: 83-100

Comment:
**Prefer parameterised tests for boolean toggle behaviour**

The two new `buildCommentMergedOptions` cases only differ on the `hasOpenComment` flag and the expected value of `enableLineSelection`/`enableGutterUtility`. Expressing them as a single `it.each` table (e.g. `[false, true, true], [true, false, false]`) would make it easier to see the invariant and add future cases without duplicating the setup.

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!

1 change: 1 addition & 0 deletions packages/core/src/code-review/diffAnnotations.ts
Original file line number Diff line number Diff line change
Expand Up @@ -61,5 +61,6 @@ export function buildCommentMergedOptions(
enableLineSelection: !hasOpenComment,
enableGutterUtility: !hasOpenComment,
onLineSelectionEnd: handleLineSelectionEnd,
onGutterUtilityClick: handleLineSelectionEnd,
};
}
2 changes: 1 addition & 1 deletion packages/ui/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@
"@lezer/highlight": "^1.2.3",
"@modelcontextprotocol/ext-apps": "^1.1.2",
"@modelcontextprotocol/sdk": "^1.12.1",
"@pierre/diffs": "^1.1.21",
"@pierre/diffs": "^1.2.10",
"@posthog/agent": "workspace:*",
"@posthog/api-client": "workspace:*",
"@posthog/core": "workspace:*",
Expand Down
2 changes: 1 addition & 1 deletion packages/ui/src/features/code-review/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,5 +9,5 @@ export const DIFF_METRICS = {
lineHeight: 20,
diffHeaderHeight: 31,
hunkSeparatorHeight: 32,
fileGap: 8,
spacing: 8,
} as const;
57 changes: 44 additions & 13 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions pnpm-workspace.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ minimumReleaseAgeExclude:
- '@anthropic-ai/claude-agent-sdk-win32-x64'
- '@anthropic-ai/sdk'
- '@pierre/diffs'
- '@pierre/theming'
- '@posthog/quill'
- '@posthog/quill-tokens'
- '@tanstack/devtools-core'
Expand Down
Loading