Skip to content

Commit 19850f3

Browse files
committed
fix(review): keep guide generation glimmer running
1 parent 35f0572 commit 19850f3

4 files changed

Lines changed: 27 additions & 12 deletions

File tree

‎apps/mobile/src/features/pull-requests/guide/GuideGeneratingHeading.tsx‎

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,14 @@ import Svg, { Defs, LinearGradient, Rect, Stop } from "react-native-svg";
1414
import { AppText as Text } from "../../../components/AppText";
1515
import { useAppearancePreferences } from "../../settings/appearance/AppearancePreferencesProvider";
1616

17-
/** Match the desktop heading's three glimmer sweeps; stop when hidden or motion is reduced. */
18-
export function GuideGeneratingHeading({ rewriting = false }: { readonly rewriting?: boolean }) {
17+
/** Glimmer throughout generation; pause while hidden, backgrounded, or motion is reduced. */
18+
export function GuideGeneratingHeading({
19+
rewriting = false,
20+
visible = true,
21+
}: {
22+
readonly rewriting?: boolean;
23+
readonly visible?: boolean;
24+
}) {
1925
const label = rewriting ? "Rewriting guide…" : "Generating guide…";
2026
const { themeVariables: colors } = useAppearancePreferences();
2127
const focused = useIsFocused();
@@ -40,12 +46,12 @@ export function GuideGeneratingHeading({ rewriting = false }: { readonly rewriti
4046
useEffect(() => {
4147
cancelAnimation(progress);
4248
progress.set(0);
43-
if (reduceMotion || !active || !focused || !width) return;
49+
if (reduceMotion || !active || !focused || !visible || !width) return;
4450
progress.set(
45-
withRepeat(withTiming(1, { duration: 2400, easing: Easing.inOut(Easing.ease) }), 3),
51+
withRepeat(withTiming(1, { duration: 2400, easing: Easing.inOut(Easing.ease) }), -1),
4652
);
4753
return () => cancelAnimation(progress);
48-
}, [active, focused, progress, reduceMotion, width]);
54+
}, [active, focused, progress, reduceMotion, visible, width]);
4955
const animated = useAnimatedStyle(() => ({
5056
transform: [{ translateX: -width + progress.get() * width * 2 }],
5157
}));
@@ -61,7 +67,7 @@ export function GuideGeneratingHeading({ rewriting = false }: { readonly rewriti
6167
>
6268
{label}
6369
</Text>
64-
{!reduceMotion && active && focused && width > 0 ? (
70+
{!reduceMotion && active && focused && visible && width > 0 ? (
6571
<MaskedView
6672
pointerEvents="none"
6773
accessible={false}

‎apps/mobile/src/features/pull-requests/guide/GuideNotice.tsx‎

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,14 @@ import { GuideGeneratingHeading } from "./GuideGeneratingHeading";
1010

1111
const NOTICE_ENTER = FadeIn.delay(180).duration(120).reduceMotion(ReduceMotion.System);
1212

13-
export function GuideNotice({ state }: { readonly state: ReturnType<typeof useReviewGuide> }) {
13+
/** Keep the action in one place as loading, writing, and retry states change. */
14+
export function GuideNotice({
15+
state,
16+
active = true,
17+
}: {
18+
readonly state: ReturnType<typeof useReviewGuide>;
19+
readonly active?: boolean;
20+
}) {
1421
const notice = guideNoticeState(state);
1522
if (notice.kind === "ready") return null;
1623
const compact = state.data?.guide != null;
@@ -33,7 +40,7 @@ export function GuideNotice({ state }: { readonly state: ReturnType<typeof useRe
3340
if (notice.kind === "writing") {
3441
return (
3542
<View className="mb-3 gap-1 py-2">
36-
<GuideGeneratingHeading rewriting={compact} />
43+
<GuideGeneratingHeading rewriting={compact} visible={active} />
3744
<Text className="text-xs text-foreground-muted">
3845
{compact
3946
? "Keep reading while the guide updates."

‎apps/mobile/src/features/pull-requests/guide/PullRequestGuideScreen.tsx‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -72,11 +72,11 @@ export function PullRequestGuideContent({
7272
) : (
7373
<>
7474
{guide ? (
75-
<GuideNotice state={state} />
75+
<GuideNotice state={state} active={active} />
7676
) : (
7777
<View className="flex-row items-start gap-2">
7878
<View className="min-w-0 flex-1">
79-
<GuideNotice state={state} />
79+
<GuideNotice state={state} active={active} />
8080
</View>
8181
<GuideViewOptionsButton />
8282
</View>

‎apps/web/src/components/pullRequest/PullRequestGuideTab.tsx‎

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ import { SparklesIcon, TriangleAlertIcon } from "lucide-react";
88
import { useEffect, useEffectEvent, useMemo, useRef, type ReactNode } from "react";
99

1010
import type { ReviewCommentContext } from "~/reviewCommentContext";
11+
import { observeVisibleAnimation } from "~/lib/visibleAnimation";
1112

1213
import { Alert, AlertAction, AlertDescription } from "../ui/alert";
1314
import { Button } from "../ui/button";
@@ -172,12 +173,13 @@ export function PullRequestGuideTab({
172173
<div className="mb-4 flex flex-col gap-2" aria-busy={running}>
173174
<style>{`
174175
@keyframes guide-status-glimmer { from { background-position: 100% 0; } to { background-position: -100% 0; } }
175-
[data-guide-generating] { background: linear-gradient(100deg, var(--muted-foreground) 35%, var(--foreground) 50%, var(--muted-foreground) 65%); background-size: 200% 100%; background-clip: text; color: transparent; animation: guide-status-glimmer 2.4s ease-in-out 3; }
176+
[data-guide-generating] { background: linear-gradient(100deg, var(--muted-foreground) 35%, var(--foreground) 50%, var(--muted-foreground) 65%); background-size: 200% 100%; background-clip: text; color: transparent; animation: guide-status-glimmer 2.4s ease-in-out infinite; animation-play-state: var(--visible-animation-state, paused); }
176177
@media (prefers-reduced-motion: reduce) { [data-guide-generating] { animation: none; } }
177178
`}</style>
178179
<h2
180+
ref={running && active ? observeVisibleAnimation : undefined}
179181
role="status"
180-
data-guide-generating={running || undefined}
182+
data-guide-generating={(running && active) || undefined}
181183
className="text-sm font-medium"
182184
>
183185
{failure ??

0 commit comments

Comments
 (0)