fix(app): restore review line comments (#33481)

This commit is contained in:
Luke Parker 2026-06-23 10:01:03 +02:00 committed by GitHub
commit d111812389
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
5 changed files with 169 additions and 26 deletions

View file

@ -288,12 +288,6 @@ export function createLineCommentState<T>(props: LineCommentStateProps<T>) {
setSelected(next)
}
const finishSelection = (range: SelectedLineRange) => {
closeComment()
setSelected(range)
cancelDraft()
}
return {
draft,
setDraft,
@ -310,7 +304,6 @@ export function createLineCommentState<T>(props: LineCommentStateProps<T>) {
openEditor,
hoverComment,
cancelDraft,
finishSelection,
select: setSelected,
reset,
}
@ -322,10 +315,9 @@ export function createLineCommentController<T extends LineCommentShape>(
note: ReturnType<typeof createLineCommentState<string>>
annotations: Accessor<DiffLineAnnotation<LineCommentAnnotationMeta<T>>[]>
renderAnnotation: ReturnType<typeof createManagedLineCommentAnnotationRenderer<T>>["renderAnnotation"]
renderHoverUtility: ReturnType<typeof createLineCommentHoverRenderer>
renderGutterUtility: ReturnType<typeof createLineCommentGutterRenderer>
onLineSelected: (range: SelectedLineRange | null) => void
onLineSelectionEnd: (range: SelectedLineRange | null) => void
onLineNumberSelectionEnd: (range: SelectedLineRange | null) => void
}
export function createLineCommentController<T extends LineCommentShape>(
props: LineCommentControllerProps<T>,
@ -333,10 +325,9 @@ export function createLineCommentController<T extends LineCommentShape>(
note: ReturnType<typeof createLineCommentState<string>>
annotations: Accessor<LineCommentAnnotation<T>[]>
renderAnnotation: ReturnType<typeof createManagedLineCommentAnnotationRenderer<T>>["renderAnnotation"]
renderHoverUtility: ReturnType<typeof createLineCommentHoverRenderer>
renderGutterUtility: ReturnType<typeof createLineCommentGutterRenderer>
onLineSelected: (range: SelectedLineRange | null) => void
onLineSelectionEnd: (range: SelectedLineRange | null) => void
onLineNumberSelectionEnd: (range: SelectedLineRange | null) => void
}
export function createLineCommentController<T extends LineCommentShape>(
props: LineCommentControllerProps<T> | LineCommentControllerWithSideProps<T>,
@ -426,7 +417,7 @@ export function createLineCommentController<T extends LineCommentShape>(
}),
})
const renderHoverUtility = createLineCommentHoverRenderer({
const renderGutterUtility = createLineCommentGutterRenderer({
label: props.label,
getSelectedRange: () => {
if (note.opened()) return null
@ -452,11 +443,6 @@ export function createLineCommentController<T extends LineCommentShape>(
return
}
note.finishSelection(range)
}
const onLineNumberSelectionEnd = (range: SelectedLineRange | null) => {
if (!range) return
note.openDraft(range)
}
@ -464,10 +450,9 @@ export function createLineCommentController<T extends LineCommentShape>(
note,
annotations,
renderAnnotation,
renderHoverUtility,
renderGutterUtility,
onLineSelected,
onLineSelectionEnd,
onLineNumberSelectionEnd,
}
}
@ -569,7 +554,7 @@ export function createManagedLineCommentAnnotationRenderer<T>(props: {
}
}
export function createLineCommentHoverRenderer(props: {
export function createLineCommentGutterRenderer(props: {
label: string
getSelectedRange: Accessor<SelectedLineRange | null>
onOpenDraft: (range: SelectedLineRange) => void

View file

@ -620,13 +620,14 @@ export const SessionReview = (props: SessionReviewProps) => {
props.onDiffRendered?.()
}}
enableLineSelection={props.onLineComment != null}
enableHoverUtility={props.onLineComment != null}
enableGutterUtility={props.onLineComment != null}
onLineSelected={handleLineSelected}
onLineSelectionEnd={handleLineSelectionEnd}
onLineNumberSelectionEnd={commentsUi.onLineNumberSelectionEnd}
annotations={commentsUi.annotations()}
renderAnnotation={commentsUi.renderAnnotation}
renderHoverUtility={props.onLineComment ? commentsUi.renderHoverUtility : undefined}
renderGutterUtility={
props.onLineComment ? commentsUi.renderGutterUtility : undefined
}
selectedLines={selectedLines()}
commentedLines={commentedLines()}
media={{