Skip to content

Commit cd0a3c9

Browse files
fix(mobile): address review on PR parity
- Keep polling checks after a failed read; only a host answering null stops it. - Drop replies loaded via Load more after one is edited, so the next load reads the new body. - Treat the labels and edit sheets as workspace overlays. - Share the reaction signature helper from client-runtime. Co-Authored-By: Claude Opus 5.5 <[email protected]>
1 parent 60bd464 commit cd0a3c9

6 files changed

Lines changed: 37 additions & 19 deletions

File tree

‎apps/mobile/src/Stack.tsx‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -476,6 +476,8 @@ const THREAD_LINKING_PREFIX = "threads/:environmentId/:threadId";
476476
const WORKSPACE_OVERLAY_ROUTES = new Set([
477477
"PullRequestReview",
478478
"PullRequestInlineComment",
479+
"PullRequestLabels",
480+
"PullRequestEdit",
479481
"ConnectOnboarding",
480482
"Connections",
481483
"ConnectionsNew",

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

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import { Toolbar } from "../../components/ui/Toolbar";
22
import { AppActivityIndicator } from "../../components/ui/AppActivityIndicator";
33
import { useAtomRefresh } from "@effect/atom-react";
4-
import { useNavigation, type StaticScreenProps } from "@react-navigation/native";
4+
import { useFocusEffect, useNavigation, type StaticScreenProps } from "@react-navigation/native";
55
import {
66
type AtomCommandResult,
77
squashAtomCommandFailure,
@@ -64,6 +64,15 @@ function Discussion({ params }: { params: PullRequestParams & { readonly discuss
6464
const [error, setError] = useState<string | null>(null);
6565
const [notice, setNotice] = useState<string | null>(null);
6666
const [composerHeight, setComposerHeight] = useState(64);
67+
// Replies from "Load more" live only here, outside the activity an edit refreshes. After one
68+
// is edited, drop the loaded pages so the next load reads the new body instead of the old one.
69+
const extraEdited = useRef(false);
70+
useFocusEffect(() => {
71+
if (!extraEdited.current) return;
72+
extraEdited.current = false;
73+
setExtra([]);
74+
setCursor(undefined);
75+
});
6776
const operation = async (run: () => Promise<AtomCommandResult<unknown, unknown> | undefined>) => {
6877
if (pending.current) return;
6978
pending.current = true;
@@ -206,6 +215,10 @@ function Discussion({ params }: { params: PullRequestParams & { readonly discuss
206215
comment={{ ...comment, kind: "review-comment" }}
207216
permissions={permissions}
208217
onChanged={refresh}
218+
onEdit={() => {
219+
if (extra.some((loaded) => loaded.id === comment.id))
220+
extraEdited.current = true;
221+
}}
209222
/>
210223
</View>
211224
))}

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

Lines changed: 7 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import {
55
pullRequestReactionEmoji,
66
pullRequestReactionName,
77
pullRequestReactionTooltip,
8+
pullRequestReactionsSignature,
89
} from "@t3tools/client-runtime/pull-request-reactions";
910
import type {
1011
PullRequestComment,
@@ -28,12 +29,6 @@ import { usePullRequestPermissions } from "./usePullRequestPermissions";
2829
const EMPTY_PENDING: ReadonlyMap<PullRequestReactionContent, boolean> = new Map();
2930
const PILL = "min-h-8 flex-row items-center gap-1 rounded-full border px-2.5 active:opacity-70";
3031

31-
function reactionsSignature(reactions: ReadonlyArray<PullRequestReaction>) {
32-
return reactions
33-
.map((reaction) => `${reaction.content}:${reaction.count}:${reaction.viewerHasReacted ? 1 : 0}`)
34-
.join(" ");
35-
}
36-
3732
function ReactionPills(props: {
3833
readonly params: PullRequestParams;
3934
readonly reactions: ReadonlyArray<PullRequestReaction>;
@@ -46,7 +41,7 @@ function ReactionPills(props: {
4641
const setReaction = useAtomCommand(composerPullRequests.setReaction, { reportFailure: false });
4742
// Keyed by what the host last reported, so a refresh that lands the change drops the overlay.
4843
const [pending, setPending] = useState({ signature: "", values: EMPTY_PENDING });
49-
const signature = reactionsSignature(props.reactions);
44+
const signature = pullRequestReactionsSignature(props.reactions);
5045
const values = pending.signature === signature ? pending.values : EMPTY_PENDING;
5146
const shown = applyPendingPullRequestReactions(props.reactions, values);
5247
const toggle = async (content: PullRequestReactionContent, reacted: boolean) => {
@@ -153,6 +148,7 @@ export function PullRequestCommentFooter(props: {
153148
"canEditComment" | "canReact"
154149
>;
155150
readonly onChanged: () => void;
151+
readonly onEdit?: () => void;
156152
}) {
157153
const navigation = useNavigation();
158154
const { comment } = props;
@@ -174,7 +170,8 @@ export function PullRequestCommentFooter(props: {
174170
<Pressable
175171
accessibilityRole="button"
176172
accessibilityLabel="Edit comment"
177-
onPress={() =>
173+
onPress={() => {
174+
props.onEdit?.();
178175
navigation.navigate("PullRequestEdit", {
179176
...props.params,
180177
field: "comment",
@@ -185,8 +182,8 @@ export function PullRequestCommentFooter(props: {
185182
author: comment.author,
186183
...(comment.canEdit === undefined ? {} : { canEdit: comment.canEdit }),
187184
},
188-
})
189-
}
185+
});
186+
}}
190187
className={cn(PILL, "ml-auto border-transparent")}
191188
>
192189
<SymbolView name="pencil" size={13} tintColorClassName="accent-icon-muted" />

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

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,9 @@ export function usePullRequestLiveChecks(
2828
);
2929
// Both reads carry the server's observedAt; without it the poll is the fresher stream.
3030
const live = resolvePullRequestDetailChecks(detail, checks.data, true);
31-
const enabled = connected && live?.state === "open" && checks.isSuccess && checks.data !== null;
31+
// A failed read keeps polling; only a host that answers "no checks" (null) stops it.
32+
const enabled =
33+
connected && supported && live?.state === "open" && !(checks.isSuccess && checks.data === null);
3234
const intervalMs = pullRequestChecksRefreshIntervalMs(live?.checks ?? []);
3335
const { refresh } = checks;
3436
useFocusEffect(() => {

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

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -20,19 +20,14 @@ import {
2020
pullRequestReactionEmoji,
2121
pullRequestReactionName,
2222
pullRequestReactionTooltip,
23+
pullRequestReactionsSignature,
2324
} from "@t3tools/client-runtime/pull-request-reactions";
2425

2526
const PILL_CLASS =
2627
"inline-flex h-6 shrink-0 items-center gap-1 rounded-full border px-2 text-xs outline-none transition-colors focus-visible:ring-2 focus-visible:ring-inset focus-visible:ring-ring";
2728

2829
const EMPTY_PENDING: ReadonlyMap<PullRequestReactionContent, boolean> = new Map();
2930

30-
function reactionsSignature(reactions: ReadonlyArray<PullRequestReaction>): string {
31-
return reactions
32-
.map((reaction) => `${reaction.content}:${reaction.count}:${reaction.viewerHasReacted ? 1 : 0}`)
33-
.join(" ");
34-
}
35-
3631
export function PullRequestReactionBar({
3732
reactions,
3833
canReact,
@@ -60,7 +55,7 @@ export function PullRequestReactionBar({
6055
reportFailure: false,
6156
});
6257

63-
const signature = reactionsSignature(reactions);
58+
const signature = pullRequestReactionsSignature(reactions);
6459
const values = pending.signature === signature ? pending.values : EMPTY_PENDING;
6560
const shown = applyPendingPullRequestReactions(reactions, values);
6661

‎packages/client-runtime/src/pullRequestReactions.ts‎

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,15 @@ export function pullRequestReactionTooltip(reaction: PullRequestReaction): strin
7272
return `${joinNames(parts)} reacted with ${pullRequestReactionName(reaction.content)} emoji`;
7373
}
7474

75+
/** Changes whenever the host reports different reactions, so pending overlays can reset. */
76+
export function pullRequestReactionsSignature(
77+
reactions: ReadonlyArray<PullRequestReaction>,
78+
): string {
79+
return reactions
80+
.map((reaction) => `${reaction.content}:${reaction.count}:${reaction.viewerHasReacted ? 1 : 0}`)
81+
.join(" ");
82+
}
83+
7584
export function applyPendingPullRequestReactions(
7685
reactions: ReadonlyArray<PullRequestReaction>,
7786
pending: ReadonlyMap<PullRequestReactionContent, boolean>,

0 commit comments

Comments
 (0)