Skip to content

Commit 5d05095

Browse files
committed
fix(mobile): restore comments sheet layout and automatic guide loading
1 parent 8cb9d37 commit 5d05095

6 files changed

Lines changed: 83 additions & 8 deletions

File tree

‎apps/mobile/src/features/pull-requests/PullRequestCommentsSheet.tsx‎

Lines changed: 40 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import { SafeAreaView } from "react-native-safe-area-context";
77
import { SymbolView } from "../../components/AppSymbol";
88
import { AppText as Text } from "../../components/AppText";
99
import { SegmentedControl } from "../../components/SegmentedControl";
10+
import { useAppearancePreferences } from "../settings/appearance/AppearancePreferencesProvider";
1011
import { PullRequestThreadCard } from "./PullRequestCommentCard";
1112
import { PullRequestMarkdown } from "./PullRequestMarkdown";
1213
import {
@@ -27,6 +28,7 @@ export function PullRequestCommentsSheet({
2728
onClose: () => void;
2829
}) {
2930
const navigation = useNavigation();
31+
const { themeVariables: colors } = useAppearancePreferences();
3032
const draft = usePullRequestReviewDraft(params);
3133
const [status, setStatus] = useState<"resolved" | "unresolved" | "pending">("unresolved");
3234
// Threads come from the optimistic activity projection, so a resolve moves its card between
@@ -42,8 +44,16 @@ export function PullRequestCommentsSheet({
4244
selectedStatus === "resolved" ? resolved : selectedStatus === "unresolved" ? unresolved : [];
4345
const pending = selectedStatus === "pending" ? draft.comments : [];
4446
const options = [
45-
{ value: "unresolved" as const, label: "Unresolved", badge: unresolved.length },
46-
{ value: "resolved" as const, label: "Resolved", badge: resolved.length },
47+
{
48+
value: "unresolved" as const,
49+
label: "Unresolved",
50+
...(draft.activityLoaded ? { badge: unresolved.length } : {}),
51+
},
52+
{
53+
value: "resolved" as const,
54+
label: "Resolved",
55+
...(draft.activityLoaded ? { badge: resolved.length } : {}),
56+
},
4757
...(draft.comments.length
4858
? [{ value: "pending" as const, label: "Pending", badge: draft.comments.length }]
4959
: []),
@@ -55,12 +65,17 @@ export function PullRequestCommentsSheet({
5565
presentationStyle="pageSheet"
5666
onRequestClose={onClose}
5767
>
58-
<SafeAreaView className="flex-1 bg-screen">
68+
{/* SafeAreaView forwards className to a native view without Uniwind styling. */}
69+
<SafeAreaView style={{ flex: 1, backgroundColor: colors["--color-screen"] }}>
5970
<View className="flex-row items-center gap-3 px-4 pt-4 pb-1">
6071
<View className="min-w-0 flex-1">
6172
<Text className="text-base font-t3-bold">Comments</Text>
6273
<Text className="text-2xs text-foreground-muted" numberOfLines={1}>
63-
{counts.open} open · {counts.resolved} resolved
74+
{draft.activityLoaded
75+
? `${counts.open} open · ${counts.resolved} resolved`
76+
: draft.activityError
77+
? "Could not load comments"
78+
: "Loading comments…"}
6479
{draft.comments.length ? ` · ${draft.comments.length} pending` : ""}
6580
</Text>
6681
</View>
@@ -84,8 +99,9 @@ export function PullRequestCommentsSheet({
8499
/>
85100
</View>
86101
{/* Replies are written inside the cards, so the list must clear the keyboard. */}
87-
<KeyboardAvoidingView automaticOffset behavior="padding" className="flex-1">
102+
<KeyboardAvoidingView automaticOffset behavior="padding" style={{ flex: 1 }}>
88103
<ScrollView
104+
style={{ flex: 1 }}
89105
keyboardShouldPersistTaps="handled"
90106
contentContainerStyle={{ padding: 12, gap: 8 }}
91107
>
@@ -130,7 +146,25 @@ export function PullRequestCommentsSheet({
130146
onBeforeNavigate={onClose}
131147
/>
132148
))}
133-
{!threads.length && !pending.length ? (
149+
{draft.activityError ? (
150+
<View className="gap-2">
151+
<Text accessibilityRole="alert" className="text-sm text-danger-foreground">
152+
{draft.activityError}
153+
</Text>
154+
<Pressable
155+
accessibilityRole="button"
156+
onPress={draft.refreshActivity}
157+
className="min-h-11 justify-center active:opacity-70"
158+
>
159+
<Text className="text-sm font-t3-medium">Try again</Text>
160+
</Pressable>
161+
</View>
162+
) : !draft.activityLoaded && selectedStatus !== "pending" ? (
163+
<Text accessibilityLiveRegion="polite" className="text-sm text-foreground-muted">
164+
Loading comments…
165+
</Text>
166+
) : null}
167+
{draft.activityLoaded && !draft.activityError && !threads.length && !pending.length ? (
134168
<Text className="text-sm text-foreground-muted">
135169
{selectedStatus === "resolved"
136170
? "No resolved comments."

‎apps/mobile/src/features/pull-requests/PullRequestFilesSheet.tsx‎

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ import { SafeAreaView } from "react-native-safe-area-context";
33
import { AppText as Text } from "../../components/AppText";
44
import { SymbolView } from "../../components/AppSymbol";
55
import { ReviewFileTree, type ReviewFileTreeItem } from "../review/ReviewFileTree";
6+
import { useAppearancePreferences } from "../settings/appearance/AppearancePreferencesProvider";
67

78
/** Shows exactly the file set in the reader, including its chapter and filters. */
89
export function PullRequestFilesSheet({
@@ -22,14 +23,15 @@ export function PullRequestFilesSheet({
2223
readonly onSetViewed?: (paths: ReadonlyArray<string>, viewed: boolean) => void;
2324
readonly onLoadMore?: () => void;
2425
}) {
26+
const { themeVariables: colors } = useAppearancePreferences();
2527
return (
2628
<Modal
2729
visible={open}
2830
animationType="slide"
2931
presentationStyle="pageSheet"
3032
onRequestClose={onClose}
3133
>
32-
<SafeAreaView className="flex-1 bg-screen">
34+
<SafeAreaView style={{ flex: 1, backgroundColor: colors["--color-screen"] }}>
3335
<View className="flex-row items-center gap-2 border-b border-border-subtle px-4 py-1">
3436
<SymbolView name="folder" size={18} tintColorClassName="accent-icon-muted" />
3537
<Text className="min-w-0 flex-1 text-base font-t3-semibold">{title}</Text>

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

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,20 @@ export function GuideNotice({ state }: { readonly state: ReturnType<typeof useRe
1616
const compact = state.data?.guide != null;
1717
const failed = notice.kind === "failed" || notice.kind === "unavailable";
1818
const busy = notice.kind === "loading" || notice.kind === "writing";
19+
if (notice.kind === "loading" || notice.kind === "empty") {
20+
return (
21+
<View className="mb-3 gap-1 py-2" accessibilityLiveRegion="polite">
22+
<Text className="text-base font-t3-semibold text-foreground-muted">
23+
{notice.kind === "loading" ? "Loading guide…" : "Waiting to generate guide"}
24+
</Text>
25+
<Text className="text-xs text-foreground-muted">
26+
{notice.kind === "loading"
27+
? "Checking for a saved guide. You can explore the files below."
28+
: "The guide starts automatically when connected with write access."}
29+
</Text>
30+
</View>
31+
);
32+
}
1933
if (notice.kind === "writing") {
2034
return (
2135
<View className="mb-3 gap-1 py-2">

‎apps/mobile/src/features/pull-requests/guide/reviewGuideState.test.ts‎

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,13 +53,24 @@ const view = {
5353
running: false,
5454
startError: null,
5555
error: null,
56+
canWrite: true,
5657
};
5758

5859
describe("guide notice transitions", () => {
59-
it("does not flash an empty guide before the first response", () => {
60+
it("moves from loading into automatic generation without a manual action", () => {
6061
expect(guideNoticeState({ ...view, isPending: true }).kind).toBe("loading");
6162
expect(
6263
guideNoticeState({ ...view, data: { guide: null, run: null, currentHeadSha: "head" } }).kind,
64+
).toBe("writing");
65+
});
66+
67+
it("waits for write access without claiming generation has started", () => {
68+
expect(
69+
guideNoticeState({
70+
...view,
71+
canWrite: false,
72+
data: { guide: null, run: null, currentHeadSha: "head" },
73+
}).kind,
6374
).toBe("empty");
6475
});
6576

‎apps/mobile/src/features/pull-requests/guide/reviewGuideState.ts‎

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ export function guideNoticeState(state: {
1919
readonly running: boolean;
2020
readonly startError: string | null;
2121
readonly error: string | null;
22+
readonly canWrite: boolean;
2223
}) {
2324
const { guide, stale, failure } = reviewGuideState(state.data);
2425
if (state.running) {
@@ -64,6 +65,16 @@ export function guideNoticeState(state: {
6465
action: "Rewrite guide",
6566
};
6667
}
68+
// The screen starts the writer automatically; do not offer a manual action between
69+
// the initial empty response and the generation effect committing its busy state.
70+
if (!guide && state.canWrite) {
71+
return {
72+
kind: "writing" as const,
73+
title: "Generating guide",
74+
description: "Explore the files while the guide is written.",
75+
action: "Writing guide…",
76+
};
77+
}
6778
return {
6879
kind: guide ? ("ready" as const) : ("empty" as const),
6980
title: "Review guide",

‎apps/mobile/src/features/pull-requests/usePullRequestReviewDraft.ts‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -191,6 +191,9 @@ export function usePullRequestReviewDraft(params: PullRequestParams) {
191191
draft,
192192
comments,
193193
threads,
194+
activityLoaded: activity.data !== null,
195+
activityError: activity.error,
196+
refreshActivity: activity.refresh,
194197
pendingReviewId,
195198
busy: busyOperations.has(key),
196199
ready: snapshot.ready,

0 commit comments

Comments
 (0)