mirror of
https://gitea.toothfairyai.com/ToothFairyAI/tf_code.git
synced 2026-04-22 16:44:36 +00:00
fix(app): defer diff rendering
This commit is contained in:
@@ -1,4 +1,16 @@
|
|||||||
import { onCleanup, Show, Match, Switch, createMemo, createEffect, on, onMount, untrack } from "solid-js"
|
import {
|
||||||
|
onCleanup,
|
||||||
|
Show,
|
||||||
|
Match,
|
||||||
|
Switch,
|
||||||
|
createMemo,
|
||||||
|
createEffect,
|
||||||
|
createComputed,
|
||||||
|
on,
|
||||||
|
onMount,
|
||||||
|
untrack,
|
||||||
|
createSignal,
|
||||||
|
} from "solid-js"
|
||||||
import { createMediaQuery } from "@solid-primitives/media"
|
import { createMediaQuery } from "@solid-primitives/media"
|
||||||
import { createResizeObserver } from "@solid-primitives/resize-observer"
|
import { createResizeObserver } from "@solid-primitives/resize-observer"
|
||||||
import { useLocal } from "@/context/local"
|
import { useLocal } from "@/context/local"
|
||||||
@@ -406,6 +418,18 @@ export default function Page() {
|
|||||||
newSessionWorktree: "main",
|
newSessionWorktree: "main",
|
||||||
})
|
})
|
||||||
|
|
||||||
|
const [deferRender, setDeferRender] = createSignal(false)
|
||||||
|
createComputed((prev) => {
|
||||||
|
const key = sessionKey()
|
||||||
|
if (key !== prev) {
|
||||||
|
setDeferRender(true)
|
||||||
|
requestAnimationFrame(() => {
|
||||||
|
setTimeout(() => setDeferRender(false), 0)
|
||||||
|
})
|
||||||
|
}
|
||||||
|
return key
|
||||||
|
}, sessionKey())
|
||||||
|
|
||||||
const turnDiffs = createMemo(() => lastUserMessage()?.summary?.diffs ?? [])
|
const turnDiffs = createMemo(() => lastUserMessage()?.summary?.diffs ?? [])
|
||||||
const reviewDiffs = createMemo(() => (store.changes === "session" ? diffs() : turnDiffs()))
|
const reviewDiffs = createMemo(() => (store.changes === "session" ? diffs() : turnDiffs()))
|
||||||
|
|
||||||
@@ -712,35 +736,15 @@ export default function Page() {
|
|||||||
loadingClass: string
|
loadingClass: string
|
||||||
emptyClass: string
|
emptyClass: string
|
||||||
}) => (
|
}) => (
|
||||||
<Switch>
|
<Show
|
||||||
<Match when={store.changes === "turn" && !!params.id}>
|
when={!deferRender()}
|
||||||
<SessionReviewTab
|
fallback={<div class={input.loadingClass}>{language.t("session.review.loadingChanges")}</div>}
|
||||||
title={changesTitle()}
|
>
|
||||||
empty={emptyTurn()}
|
<Switch>
|
||||||
diffs={reviewDiffs}
|
<Match when={store.changes === "turn" && !!params.id}>
|
||||||
view={view}
|
|
||||||
diffStyle={input.diffStyle}
|
|
||||||
onDiffStyleChange={input.onDiffStyleChange}
|
|
||||||
onScrollRef={(el) => setTree("reviewScroll", el)}
|
|
||||||
focusedFile={tree.activeDiff}
|
|
||||||
onLineComment={(comment) => addCommentToContext({ ...comment, origin: "review" })}
|
|
||||||
onLineCommentUpdate={updateCommentInContext}
|
|
||||||
onLineCommentDelete={removeCommentFromContext}
|
|
||||||
lineCommentActions={reviewCommentActions()}
|
|
||||||
comments={comments.all()}
|
|
||||||
focusedComment={comments.focus()}
|
|
||||||
onFocusedCommentChange={comments.setFocus}
|
|
||||||
onViewFile={openReviewFile}
|
|
||||||
classes={input.classes}
|
|
||||||
/>
|
|
||||||
</Match>
|
|
||||||
<Match when={hasReview()}>
|
|
||||||
<Show
|
|
||||||
when={diffsReady()}
|
|
||||||
fallback={<div class={input.loadingClass}>{language.t("session.review.loadingChanges")}</div>}
|
|
||||||
>
|
|
||||||
<SessionReviewTab
|
<SessionReviewTab
|
||||||
title={changesTitle()}
|
title={changesTitle()}
|
||||||
|
empty={emptyTurn()}
|
||||||
diffs={reviewDiffs}
|
diffs={reviewDiffs}
|
||||||
view={view}
|
view={view}
|
||||||
diffStyle={input.diffStyle}
|
diffStyle={input.diffStyle}
|
||||||
@@ -757,39 +761,64 @@ export default function Page() {
|
|||||||
onViewFile={openReviewFile}
|
onViewFile={openReviewFile}
|
||||||
classes={input.classes}
|
classes={input.classes}
|
||||||
/>
|
/>
|
||||||
</Show>
|
</Match>
|
||||||
</Match>
|
<Match when={hasReview()}>
|
||||||
<Match when={true}>
|
<Show
|
||||||
<SessionReviewTab
|
when={diffsReady()}
|
||||||
title={changesTitle()}
|
fallback={<div class={input.loadingClass}>{language.t("session.review.loadingChanges")}</div>}
|
||||||
empty={
|
>
|
||||||
store.changes === "turn" ? (
|
<SessionReviewTab
|
||||||
emptyTurn()
|
title={changesTitle()}
|
||||||
) : (
|
diffs={reviewDiffs}
|
||||||
<div class={input.emptyClass}>
|
view={view}
|
||||||
<Mark class="w-14 opacity-10" />
|
diffStyle={input.diffStyle}
|
||||||
<div class="text-14-regular text-text-weak max-w-56">{language.t(reviewEmptyKey())}</div>
|
onDiffStyleChange={input.onDiffStyleChange}
|
||||||
</div>
|
onScrollRef={(el) => setTree("reviewScroll", el)}
|
||||||
)
|
focusedFile={tree.activeDiff}
|
||||||
}
|
onLineComment={(comment) => addCommentToContext({ ...comment, origin: "review" })}
|
||||||
diffs={reviewDiffs}
|
onLineCommentUpdate={updateCommentInContext}
|
||||||
view={view}
|
onLineCommentDelete={removeCommentFromContext}
|
||||||
diffStyle={input.diffStyle}
|
lineCommentActions={reviewCommentActions()}
|
||||||
onDiffStyleChange={input.onDiffStyleChange}
|
comments={comments.all()}
|
||||||
onScrollRef={(el) => setTree("reviewScroll", el)}
|
focusedComment={comments.focus()}
|
||||||
focusedFile={tree.activeDiff}
|
onFocusedCommentChange={comments.setFocus}
|
||||||
onLineComment={(comment) => addCommentToContext({ ...comment, origin: "review" })}
|
onViewFile={openReviewFile}
|
||||||
onLineCommentUpdate={updateCommentInContext}
|
classes={input.classes}
|
||||||
onLineCommentDelete={removeCommentFromContext}
|
/>
|
||||||
lineCommentActions={reviewCommentActions()}
|
</Show>
|
||||||
comments={comments.all()}
|
</Match>
|
||||||
focusedComment={comments.focus()}
|
<Match when={true}>
|
||||||
onFocusedCommentChange={comments.setFocus}
|
<SessionReviewTab
|
||||||
onViewFile={openReviewFile}
|
title={changesTitle()}
|
||||||
classes={input.classes}
|
empty={
|
||||||
/>
|
store.changes === "turn" ? (
|
||||||
</Match>
|
emptyTurn()
|
||||||
</Switch>
|
) : (
|
||||||
|
<div class={input.emptyClass}>
|
||||||
|
<Mark class="w-14 opacity-10" />
|
||||||
|
<div class="text-14-regular text-text-weak max-w-56">{language.t(reviewEmptyKey())}</div>
|
||||||
|
</div>
|
||||||
|
)
|
||||||
|
}
|
||||||
|
diffs={reviewDiffs}
|
||||||
|
view={view}
|
||||||
|
diffStyle={input.diffStyle}
|
||||||
|
onDiffStyleChange={input.onDiffStyleChange}
|
||||||
|
onScrollRef={(el) => setTree("reviewScroll", el)}
|
||||||
|
focusedFile={tree.activeDiff}
|
||||||
|
onLineComment={(comment) => addCommentToContext({ ...comment, origin: "review" })}
|
||||||
|
onLineCommentUpdate={updateCommentInContext}
|
||||||
|
onLineCommentDelete={removeCommentFromContext}
|
||||||
|
lineCommentActions={reviewCommentActions()}
|
||||||
|
comments={comments.all()}
|
||||||
|
focusedComment={comments.focus()}
|
||||||
|
onFocusedCommentChange={comments.setFocus}
|
||||||
|
onViewFile={openReviewFile}
|
||||||
|
classes={input.classes}
|
||||||
|
/>
|
||||||
|
</Match>
|
||||||
|
</Switch>
|
||||||
|
</Show>
|
||||||
)
|
)
|
||||||
|
|
||||||
const reviewPanel = () => (
|
const reviewPanel = () => (
|
||||||
|
|||||||
Reference in New Issue
Block a user