-
Notifications
You must be signed in to change notification settings - Fork 2.4k
[RFC] Plan review annotations #2865
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
Open
ricglz
wants to merge
2
commits into
pingdotgg:main
Choose a base branch
from
ricglz:plan-review-annotations
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+865
−41
Open
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,92 @@ | ||
| import "../index.css"; | ||
|
|
||
| import { useState } from "react"; | ||
| import { page } from "vitest/browser"; | ||
| import { afterEach, describe, expect, it, vi } from "vitest"; | ||
| import { render } from "vitest-browser-react"; | ||
|
|
||
| import type { ProposedPlan } from "../types"; | ||
| import type { PlanReviewAnnotation } from "../proposedPlanReview"; | ||
| import { PlanReviewPanel } from "./PlanReviewPanel"; | ||
|
|
||
| const PROPOSED_PLAN: ProposedPlan = { | ||
| id: "plan-review-browser-test" as never, | ||
| turnId: null, | ||
| planMarkdown: "# Reviewable plan\n\n- Keep composer stable.\n- Add success criteria.", | ||
| implementedAt: null, | ||
| implementationThreadId: null, | ||
| createdAt: "2026-05-29T00:00:00.000Z", | ||
| updatedAt: "2026-05-29T00:00:00.000Z", | ||
| }; | ||
|
|
||
| function findTextNode(root: Node, text: string): Text { | ||
| const walker = document.createTreeWalker(root, NodeFilter.SHOW_TEXT); | ||
| let node = walker.nextNode(); | ||
| while (node) { | ||
| if (node.textContent?.includes(text)) { | ||
| return node as Text; | ||
| } | ||
| node = walker.nextNode(); | ||
| } | ||
| throw new Error(`Unable to find text node containing "${text}".`); | ||
| } | ||
|
|
||
| function selectText(root: HTMLElement, text: string) { | ||
| const textNode = findTextNode(root, text); | ||
| const start = textNode.textContent?.indexOf(text) ?? -1; | ||
| if (start < 0) { | ||
| throw new Error(`Unable to find selection text "${text}".`); | ||
| } | ||
| const range = document.createRange(); | ||
| range.setStart(textNode, start); | ||
| range.setEnd(textNode, start + text.length); | ||
| const selection = window.getSelection(); | ||
| selection?.removeAllRanges(); | ||
| selection?.addRange(range); | ||
| root.dispatchEvent(new MouseEvent("mouseup", { bubbles: true })); | ||
| } | ||
|
|
||
| function Harness(props: { onDone: () => void }) { | ||
| const [annotations, setAnnotations] = useState<PlanReviewAnnotation[]>([]); | ||
| return ( | ||
| <div className="h-[720px] w-[720px]"> | ||
| <PlanReviewPanel | ||
| proposedPlan={PROPOSED_PLAN} | ||
| markdownCwd={undefined} | ||
| annotations={annotations} | ||
| onAnnotationsChange={setAnnotations} | ||
| onDone={props.onDone} | ||
| onBack={vi.fn()} | ||
| /> | ||
| </div> | ||
| ); | ||
| } | ||
|
|
||
| describe("PlanReviewPanel", () => { | ||
| afterEach(() => { | ||
| window.getSelection()?.removeAllRanges(); | ||
| document.body.innerHTML = ""; | ||
| }); | ||
|
|
||
| it("creates a visual comment from selected plan text and enables done", async () => { | ||
| const onDone = vi.fn(); | ||
| await render(<Harness onDone={onDone} />); | ||
|
|
||
| let reviewRoot: HTMLElement | null = null; | ||
| await vi.waitFor(() => { | ||
| reviewRoot = document.querySelector<HTMLElement>('[data-testid="plan-review-markdown"]'); | ||
| expect(reviewRoot).toBeTruthy(); | ||
| }); | ||
| selectText(reviewRoot!, "Add success criteria."); | ||
|
|
||
| await page.getByText("Comment", { exact: true }).click(); | ||
| await page.getByPlaceholder("Add a comment").fill("Needs acceptance coverage."); | ||
| await page.getByText("Save", { exact: true }).click(); | ||
|
|
||
| await expect.element(page.getByText("Needs acceptance coverage.")).toBeInTheDocument(); | ||
| await expect.element(page.getByText("Add success criteria.").first()).toBeInTheDocument(); | ||
|
|
||
| await page.getByText("Done", { exact: true }).click(); | ||
| expect(onDone).toHaveBeenCalledTimes(1); | ||
| }); | ||
| }); |
Oops, something went wrong.
Oops, something went wrong.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Annotations not cleared after finishing plan review
Medium Severity
finishPlanReviewappends annotation feedback to the composer draft but never clears the annotations fromplanReviewAnnotationsByPlanIdfor the finished plan. If the user re-opens the review for the same plan, the old annotations are still present and clicking "Done" again will duplicate the feedback in the composer.Reviewed by Cursor Bugbot for commit 52f5740. Configure here.