feat: restore git-backed review modes (#20845)

This commit is contained in:
Shoubhit Dash
2026-04-03 20:24:57 +05:30
committed by GitHub
parent 263dcf75b5
commit 35350b1d25
23 changed files with 1104 additions and 249 deletions

View File

@@ -359,11 +359,10 @@ export const SessionReview = (props: SessionReviewProps) => {
<Show when={hasDiffs()} fallback={props.empty}>
<div class="pb-6">
<Accordion multiple value={open()} onChange={handleChange}>
<For each={files()}>
{(file) => {
<For each={props.diffs}>
{(diff) => {
let wrapper: HTMLDivElement | undefined
const item = createMemo(() => diffs().get(file)!)
const file = diff.file
const expanded = createMemo(() => open().includes(file))
const mounted = createMemo(() => expanded() && (!!store.visible[file] || pinned(file)))
@@ -372,9 +371,9 @@ export const SessionReview = (props: SessionReviewProps) => {
const comments = createMemo(() => grouped().get(file) ?? [])
const commentedLines = createMemo(() => comments().map((c) => c.selection))
const beforeText = () => (typeof item().before === "string" ? item().before : "")
const afterText = () => (typeof item().after === "string" ? item().after : "")
const changedLines = () => item().additions + item().deletions
const beforeText = () => (typeof diff.before === "string" ? diff.before : "")
const afterText = () => (typeof diff.after === "string" ? diff.after : "")
const changedLines = () => diff.additions + diff.deletions
const mediaKind = createMemo(() => mediaKindFromPath(file))
const tooLarge = createMemo(() => {
@@ -385,9 +384,9 @@ export const SessionReview = (props: SessionReviewProps) => {
})
const isAdded = () =>
item().status === "added" || (beforeText().length === 0 && afterText().length > 0)
diff.status === "added" || (beforeText().length === 0 && afterText().length > 0)
const isDeleted = () =>
item().status === "deleted" || (afterText().length === 0 && beforeText().length > 0)
diff.status === "deleted" || (afterText().length === 0 && beforeText().length > 0)
const selectedLines = createMemo(() => {
const current = selection()
@@ -425,7 +424,7 @@ export const SessionReview = (props: SessionReviewProps) => {
file,
selection,
comment,
preview: selectionPreview(item(), selection),
preview: selectionPreview(diff, selection),
})
},
onUpdate: ({ id, comment, selection }) => {
@@ -434,7 +433,7 @@ export const SessionReview = (props: SessionReviewProps) => {
file,
selection,
comment,
preview: selectionPreview(item(), selection),
preview: selectionPreview(diff, selection),
})
},
onDelete: (comment) => {
@@ -513,7 +512,7 @@ export const SessionReview = (props: SessionReviewProps) => {
<span data-slot="session-review-change" data-type="added">
{i18n.t("ui.sessionReview.change.added")}
</span>
<DiffChanges changes={item()} />
<DiffChanges changes={diff} />
</div>
</Match>
<Match when={isDeleted()}>
@@ -527,7 +526,7 @@ export const SessionReview = (props: SessionReviewProps) => {
</span>
</Match>
<Match when={true}>
<DiffChanges changes={item()} />
<DiffChanges changes={diff} />
</Match>
</Switch>
<span data-slot="session-review-diff-chevron">
@@ -582,7 +581,7 @@ export const SessionReview = (props: SessionReviewProps) => {
<Dynamic
component={fileComponent}
mode="diff"
preloadedDiff={item().preloaded}
preloadedDiff={diff.preloaded}
diffStyle={diffStyle()}
onRendered={() => {
props.onDiffRendered?.()
@@ -599,17 +598,17 @@ export const SessionReview = (props: SessionReviewProps) => {
commentedLines={commentedLines()}
before={{
name: file,
contents: typeof item().before === "string" ? item().before : "",
contents: typeof diff.before === "string" ? diff.before : "",
}}
after={{
name: file,
contents: typeof item().after === "string" ? item().after : "",
contents: typeof diff.after === "string" ? diff.after : "",
}}
media={{
mode: "auto",
path: file,
before: item().before,
after: item().after,
before: diff.before,
after: diff.after,
readFile: props.readFile,
}}
/>