Add file preview comments and task toggles #3115
Mergedjuliusmarmingemerged 3 commits into
main fromrefs/pull/3115/headmerged by juliusmarminge View on GitHubgithub-actions[bot](GitHub profile, opens in a new tab) added labelsvouch:trusted
github-actions[bot](GitHub profile, opens in a new tab) added labelssize:XXL
- apps/web/src/components/files/FilePreviewPanel.tsx line 363Resolvedby cursor[bot](GitHub profile, opens in a new tab)@@ -119,0 +432,21 @@432+ threadRef: ScopedThreadRef;433+}) {434+ const saveCoordinator = useFileSaveCoordinator({435+ environmentId,436+ cwd,437+ relativePath,438+ onPendingChange,439+ });440+441+ return (442+ <ScrollArea className="min-h-0 flex-1">443+ <ChatMarkdown444+ text={contents}445+ cwd={cwd}446+ threadRef={threadRef}447+ className="mx-auto max-w-4xl px-6 py-5"448+ onTaskListChange={({ markerOffset, checked }) => {449+ const nextContents = setMarkdownTaskChecked(contents, markerOffset, checked);450+ if (nextContents === contents) return;451+ setProjectFileQueryData(environmentId, cwd, relativePath, nextContents);452+ saveCoordinator.change(nextContents);
- apps/web/src/reviewCommentContext.ts lines 52 to 58Resolvedby macroscopeapp[bot](GitHub profile, opens in a new tab)@@ -25,3 +39,6 @@2539 const REVIEW_COMMENT_ATTRIBUTE_PATTERN = /([a-zA-Z][a-zA-Z0-9_-]*)="([^"]*)"/g;2640 const REVIEW_COMMENT_DIFF_FENCE_PATTERN = /```diff\s*\n([\s\S]*?)\n```/;274142+function escapeReviewCommentAttribute(value: string): string {43+ return value.replace(/&/g, "&").replace(/"/g, """).replace(/</g, "<");44+}
- apps/web/src/reviewCommentContext.ts line 95Resolvedby cursor[bot](GitHub profile, opens in a new tab)@@ -48,10 +76,17 @@4876 }49775078 function extractReviewCommentText(rawBody: string): string {51- const fenceIndex = rawBody.indexOf("```diff");79+ const fenceIndex = rawBody.search(REVIEW_COMMENT_FENCE_PATTERN);5280 const commentBody = fenceIndex >= 0 ? rawBody.slice(0, fenceIndex) : rawBody;5381 return commentBody.trim();5482 }558356-function extractReviewCommentDiff(rawBody: string): string {57- return rawBody.match(REVIEW_COMMENT_DIFF_FENCE_PATTERN)?.[1]?.trim() ?? "";84+function extractReviewCommentFence(rawBody: string): {85+ language: string;86+ contents: string;87+} {88+ const match = rawBody.match(REVIEW_COMMENT_FENCE_PATTERN);89+ return {90+ language: match?.[2]?.trim() || "diff",91+ contents: match?.[3] ?? "",92+ };apps/web/src/components/diffs/AnnotatableFileDiff.tsx line 53OutdatedResolvedby cursor[bot](GitHub profile, opens in a new tab)@@ -0,0 +33,21 @@33+ filePath: string;34+ sectionId: string;35+ sectionTitle: string;36+ composerDraftTarget: ScopedThreadRef | DraftId;37+ options: FileDiffProps<DiffCommentAnnotationGroup>["options"];38+ renderHeaderPrefix: (fileDiff: FileDiffMetadata) => ReactNode;39+}40+41+export function AnnotatableFileDiff({42+ fileDiff,43+ filePath,44+ sectionId,45+ sectionTitle,46+ composerDraftTarget,47+ options,48+ renderHeaderPrefix,49+}: AnnotatableFileDiffProps) {50+ const addReviewComment = useComposerDraftStore((store) => store.addReviewComment);51+ const removeReviewComment = useComposerDraftStore((store) => store.removeReviewComment);52+ const [selectedRange, setSelectedRange] = useState<SelectedLineRange | null>(null);53+ const [lineAnnotations, setLineAnnotations] = useState<DiffCommentLineAnnotation[]>([]);
- @@ -0,0 +46,21 @@46+ filePath="src/app.ts"47+ sectionId="turn:2"48+ sectionTitle="Turn 2"49+ composerDraftTarget={threadRef}50+ renderHeaderPrefix={() => null}51+ options={{52+ diffStyle: "unified",53+ lineDiffType: "none",54+ themeType: "light",55+ }}56+ />57+ );58+}59+60+async function getRenderedDiff() {61+ return vi.waitFor(() => {62+ const element = document.querySelector<HTMLElement>("diffs-container");63+ expect(element?.shadowRoot).not.toBeNull();64+ return element!;65+ });66+}
- @@ -0,0 +173,21 @@173+ id,174+ sectionId,175+ sectionTitle,176+ filePath,177+ fileDiff,178+ range,179+ text: "",180+ });181+ if (!comment) return;182+183+ const draftEntry: DiffCommentAnnotationEntry = {184+ id,185+ kind: "draft",186+ range,187+ rangeLabel: comment.rangeLabel,188+ text: "",189+ };190+ setDraftAnnotation({191+ side: annotationSide(range),192+ lineNumber: range.end,193+ metadata: { entries: [draftEntry] },
juliusmarminge merged thisc2ca9de
juliusmarminge closed this
Sign in to join this conversation.



Important
Review skipped#
Auto reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the
.coderabbit.yamlfile in this repository. To trigger a single review, invoke the@coderabbitai reviewcommand.⚙️ Run configuration
Configuration used: Repository UI
Review profile: CHILL
Plan: Pro
Run ID:
52800d07-51b8-403e-8c17-c6721e17f102You can disable this status message by setting the
reviews.review_statustofalsein the CodeRabbit configuration file.Use the checkbox below for a quick retry:
✨ Finishing Touches
🧪 Generate unit tests (beta)
Comment `@coderabbitai help` to get the list of available commands and usage tips.