TypeScript
feat(mobile): manage labels, edit PRs and comments, react, and refresh checks live (#24602)
Julius Marmingeedb2b2f3657b
diff --git a/apps/mobile/src/Stack.tsx b/apps/mobile/src/Stack.tsxindex 2fed9166e27..c22c2ccbfd7 100644--- a/apps/mobile/src/Stack.tsx+++ b/apps/mobile/src/Stack.tsx@@ -32,6 +32,8 @@ import {import { PullRequestFilesSheet } from "./features/pull-requests/PullRequestFiles";import { PullRequestReviewSheet } from "./features/pull-requests/PullRequestReviewSheet";import { PullRequestReviewersScreen } from "./features/pull-requests/PullRequestReviewersScreen";+import { PullRequestLabelsScreen } from "./features/pull-requests/PullRequestLabelsScreen";+import { PullRequestEditScreen } from "./features/pull-requests/PullRequestEditScreen";import { PullRequestFilterSearchScreen } from "./features/pull-requests/PullRequestFilterSearchScreen";import {RenderErrorBoundary,@@ -669,6 +671,20 @@ const RootStackConfig = createWorkspaceStackNavigator({headerBackVisible: false,},}),+ PullRequestLabels: createNativeStackScreen({+ screen: PullRequestLabelsScreen,+ // Presented like PullRequestFilterSearch, whose search sheet it shares.+ options:+ Platform.OS === "android"+ ? { presentation: "card", headerShown: false }+ : {+ ...DETAIL_HEADER_OPTIONS,+ ...HORIZONTAL_FORM_SHEET_OPTIONS,+ sheetAllowedDetents: formSheetDetents(0.75),+ sheetGrabberVisible: true,+ headerBackVisible: false,+ },+ }),PullRequestFilterSearch: createNativeStackScreen({screen: PullRequestFilterSearchScreen,// Android pushes it like the branch picker; a formSheet there leaves the list's header@@ -707,6 +723,15 @@ const RootStackConfig = createWorkspaceStackNavigator({sheetGrabberVisible: true,},}),+ PullRequestEdit: createNativeStackScreen({+ screen: PullRequestEditScreen,+ options: {+ ...(Platform.OS === "ios" ? SHEET_GLASS_HEADER_OPTIONS : undefined),+ ...HORIZONTAL_FORM_SHEET_OPTIONS,+ sheetAllowedDetents: formSheetDetents(0.75),+ sheetGrabberVisible: true,+ },+ }),Thread: createNativeStackScreen({screen: ThreadRouteScreen,linking: { path: "threads/:environmentId?/:threadId?", alias: ["new/draft"] },diff --git a/apps/mobile/src/components/ui/AppSymbol.tsx b/apps/mobile/src/components/ui/AppSymbol.tsxindex e2685dd5db2..d5e01ede21b 100644--- a/apps/mobile/src/components/ui/AppSymbol.tsx+++ b/apps/mobile/src/components/ui/AppSymbol.tsx@@ -44,6 +44,8 @@ import IconCircleCheck from "@tabler/icons-react-native/IconCircleCheck";import IconCircleDashed from "@tabler/icons-react-native/IconCircleDashed";import IconCircleDot from "@tabler/icons-react-native/IconCircleDot";import IconCircleXFilled from "@tabler/icons-react-native/IconCircleXFilled";+import IconMoodPlus from "@tabler/icons-react-native/IconMoodPlus";+import IconTag from "@tabler/icons-react-native/IconTag";import IconTicket from "@tabler/icons-react-native/IconTicket";import IconClock from "@tabler/icons-react-native/IconClock";import IconCode from "@tabler/icons-react-native/IconCode";@@ -184,6 +186,8 @@ const ANDROID_ICON_BY_SF_SYMBOL = {"calendar.badge.clock": IconCalendarClock,clock: IconClock,timer: IconClock,+ "face.smiling": IconMoodPlus,+ tag: IconTag,ticket: IconTicket,cloud: IconCloud,cube: IconBox,diff --git a/apps/mobile/src/features/pull-requests/PullRequestDescription.tsx b/apps/mobile/src/features/pull-requests/PullRequestDescription.tsxindex 5f499ec5c07..8b7a51d5624 100644--- a/apps/mobile/src/features/pull-requests/PullRequestDescription.tsx+++ b/apps/mobile/src/features/pull-requests/PullRequestDescription.tsx@@ -5,7 +5,7 @@ import {PullRequestMediaContext,} from "./PullRequestMedia";import { PullRequestSectionHeading } from "./PullRequestSectionHeading";-import { useContext, useMemo, useState } from "react";+import { useContext, useMemo, useState, type ReactNode } from "react";import { Platform, Pressable, ScrollView, StyleSheet, View } from "react-native";import Svg, { Defs, LinearGradient, Rect, Stop } from "react-native-svg";import { pullRequestImageSource } from "./pullRequestMediaSource";@@ -25,6 +25,7 @@ export function PullRequestDescription(props: {readonly onCollapse: () => void;readonly expanded: boolean;readonly onExpandedChange: (expanded: boolean) => void;+ readonly footer?: ReactNode;}) {const { expanded, onExpandedChange } = props;const [bodyHeight, setBodyHeight] = useState(0);@@ -138,6 +139,7 @@ export function PullRequestDescription(props: {) : (<Text className="text-sm text-foreground-muted">No description provided.</Text>)}+ {props.footer}</View>{content.attachments.length ? (<View className="gap-3">diff --git a/apps/mobile/src/features/pull-requests/PullRequestDiscussionScreen.tsx b/apps/mobile/src/features/pull-requests/PullRequestDiscussionScreen.tsxindex 68ab91b3a3f..ecd811f4954 100644--- a/apps/mobile/src/features/pull-requests/PullRequestDiscussionScreen.tsx+++ b/apps/mobile/src/features/pull-requests/PullRequestDiscussionScreen.tsx@@ -1,7 +1,7 @@import { Toolbar } from "../../components/ui/Toolbar";import { AppActivityIndicator } from "../../components/ui/AppActivityIndicator";import { useAtomRefresh } from "@effect/atom-react";-import { useNavigation, type StaticScreenProps } from "@react-navigation/native";+import { useFocusEffect, useNavigation, type StaticScreenProps } from "@react-navigation/native";import {type AtomCommandResult,squashAtomCommandFailure,@@ -24,6 +24,7 @@ import { useAtomCommand } from "../../state/use-atom-command";import { useEnvironmentQuery } from "../../state/query";import { PullRequestMarkdown, PullRequestMarkdownRepository } from "./PullRequestMarkdown";import { PullRequestAvatar } from "./PullRequestPresentation";+import { PullRequestCommentFooter } from "./PullRequestReactions";import { pullRequestTarget, type PullRequestParams } from "./usePullRequestDiff";import { usePullRequestPermissions } from "./usePullRequestPermissions";import { pullRequestReviewKey } from "./pullRequestReviewDrafts";@@ -63,6 +64,15 @@ function Discussion({ params }: { params: PullRequestParams & { readonly discussconst [error, setError] = useState<string | null>(null);const [notice, setNotice] = useState<string | null>(null);const [composerHeight, setComposerHeight] = useState(64);+ // Replies from "Load more" live only here, outside the activity an edit refreshes. After one+ // is edited, drop the loaded pages so the next load reads the new body instead of the old one.+ const extraEdited = useRef(false);+ useFocusEffect(() => {+ if (!extraEdited.current) return;+ extraEdited.current = false;+ setExtra([]);+ setCursor(undefined);+ });const operation = async (run: () => Promise<AtomCommandResult<unknown, unknown> | undefined>) => {if (pending.current) return;pending.current = true;@@ -200,6 +210,16 @@ function Discussion({ params }: { params: PullRequestParams & { readonly discuss</Text></View><PullRequestMarkdown markdown={comment.body} />+ <PullRequestCommentFooter+ params={params}+ comment={{ ...comment, kind: "review-comment" }}+ permissions={permissions}+ onChanged={refresh}+ onEdit={() => {+ if (extra.some((loaded) => loaded.id === comment.id))+ extraEdited.current = true;+ }}+ /></View>))}{nextCursor ? (diff --git a/apps/mobile/src/features/pull-requests/PullRequestEditScreen.tsx b/apps/mobile/src/features/pull-requests/PullRequestEditScreen.tsxnew file mode 100644index 00000000000..8546302b7cf--- /dev/null+++ b/apps/mobile/src/features/pull-requests/PullRequestEditScreen.tsx@@ -0,0 +1,169 @@+import { useNavigation, type StaticScreenProps } from "@react-navigation/native";+import {+ capitalizeTerm,+ sourceControlClients,+} from "@t3tools/client-runtime/source-control-clients";+import { squashAtomCommandFailure } from "@t3tools/client-runtime/state/runtime";+import { useAtomValue } from "@effect/atom-react";+import type { PullRequestComment } from "@t3tools/contracts";+import { AsyncResult } from "effect/reactivity";+import { useRef, useState } from "react";+import { AppText as Text, AppTextInput as TextInput } from "../../components/ui/AppText";+import { Button } from "../../components/ui/Button";+import { composerPullRequests } from "../../state/pull-requests";+import { useEnvironmentQuery } from "../../state/query";+import { useAtomCommand } from "../../state/use-atom-command";+import { PullRequestSheetContent } from "./PullRequestSheetContent";+import { pullRequestTarget, type PullRequestParams } from "./usePullRequestDiff";+import { usePullRequestPermissions } from "./usePullRequestPermissions";++export type PullRequestEditParams = PullRequestParams &+ (+ | { readonly field: "title" | "body" }+ | {+ readonly field: "comment";+ /** Carried along because a reply loaded page by page is not in the cached activity. */+ readonly comment: Pick<PullRequestComment, "id" | "body" | "author" | "canEdit"> & {+ readonly kind: "issue-comment" | "review-comment";+ };+ }+ );++export function PullRequestEditScreen({ route }: StaticScreenProps<PullRequestEditParams>) {+ const params = route.params;+ const navigation = useNavigation();+ const target = pullRequestTarget(params);+ const detail = useEnvironmentQuery(composerPullRequests.detail(target));+ const pr = detail.data;+ const permissions = usePullRequestPermissions(params, pr);+ const update = useAtomCommand(composerPullRequests.update, { reportFailure: false });+ const updateComment = useAtomCommand(composerPullRequests.updateComment, {+ reportFailure: false,+ });+ const singular = sourceControlClients.get(pr?.provider).changeRequest.singular;+ const original =+ params.field === "comment"+ ? params.comment.body+ : params.field === "title"+ ? (pr?.title ?? null)+ : (pr?.body ?? null);+ const [draft, setDraft] = useState<string | null>(null);+ const value = draft ?? original ?? "";+ const [busy, setBusy] = useState(false);+ const [error, setError] = useState<string | null>(null);+ const inFlight = useRef(false);+ const allowed =+ params.field === "comment"+ ? permissions.canEditComment(params.comment)+ : permissions.canEditChangeRequest;+ const canWrite = useAtomValue(+ (params.field === "comment"+ ? composerPullRequests.updateComment+ : composerPullRequests.update+ ).permissionAtom(target.environmentId),+ );+ // Name the first thing in the way, so the notice says what would actually fix it.+ const readOnlyReason =+ !pr || allowed+ ? null+ : !permissions.connected+ ? "Reconnect to save changes."+ : !canWrite+ ? "This device isn't allowed to change source control on this environment."+ : params.field === "comment"+ ? "You can't edit this comment."+ : `You can't edit this ${singular}.`;+ const unchanged = draft === null || draft === original;+ const invalid = params.field === "title" && value.trim().length === 0;+ const save = async () => {+ if (!allowed || unchanged || invalid || inFlight.current) return;+ inFlight.current = true;+ setBusy(true);+ setError(null);+ const result =+ params.field === "comment"+ ? await updateComment({+ ...target,+ input: {+ ...target.input,+ commentId: params.comment.id,+ kind: params.comment.kind,+ body: value,+ },+ })+ : await update({+ ...target,+ input: {+ ...target.input,+ ...(params.field === "title" ? { title: value.trim() } : { body: value }),+ },+ });+ inFlight.current = false;+ setBusy(false);+ if (AsyncResult.isFailure(result)) {+ const cause = squashAtomCommandFailure(result);+ setError(cause instanceof Error ? cause.message : "The provider refused the change.");+ return;+ }+ // updateComment refreshes the activity on its own; a title or body lives on the detail.+ if (params.field !== "comment") detail.refresh();+ navigation.goBack();+ };+ const title =+ params.field === "title"+ ? "Edit title"+ : params.field === "body"+ ? "Edit description"+ : "Edit comment";+ return (+ <PullRequestSheetContent+ busy={busy}+ title={title}+ subtitle={`#${params.number} · ${params.repository}`}+ footer={+ <Button+ fullWidth+ tone="contrast"+ label={busy ? "Saving…" : "Save"}+ loading={busy}+ disabled={!allowed || unchanged || invalid || original === null}+ onPress={() => void save()}+ />+ }+ >+ <TextInput+ multiline={params.field !== "title"}+ editable={!busy && original !== null}+ autoFocus+ accessibilityLabel={+ params.field === "title"+ ? `${capitalizeTerm(singular)} title`+ : params.field === "body"+ ? `${capitalizeTerm(singular)} description`+ : "Comment"+ }+ placeholder={params.field === "title" ? "Title" : "Write in Markdown…"}+ placeholderTextColorClassName="accent-foreground-muted"+ maxLength={params.field === "title" ? 1024 : 65536}+ value={value}+ onChangeText={setDraft}+ returnKeyType={params.field === "title" ? "done" : undefined}+ onSubmitEditing={params.field === "title" ? () => void save() : undefined}+ className={+ params.field === "title"+ ? "min-h-12 rounded-[20px] bg-grouped-card px-4 text-base text-foreground"+ : "min-h-48 rounded-[20px] bg-grouped-card p-4 text-base text-foreground"+ }+ style={params.field === "title" ? undefined : { textAlignVertical: "top" }}+ />+ {readOnlyReason ? (+ <Text className="text-xs text-foreground-muted">{readOnlyReason}</Text>+ ) : null}+ {error || detail.error ? (+ <Text selectable className="text-sm text-danger-foreground">+ {error ?? detail.error}+ </Text>+ ) : null}+ </PullRequestSheetContent>+ );+}diff --git a/apps/mobile/src/features/pull-requests/PullRequestFilterSearchScreen.tsx b/apps/mobile/src/features/pull-requests/PullRequestFilterSearchScreen.tsxindex 09bd4e2628b..b932412d2f1 100644--- a/apps/mobile/src/features/pull-requests/PullRequestFilterSearchScreen.tsx+++ b/apps/mobile/src/features/pull-requests/PullRequestFilterSearchScreen.tsx@@ -8,25 +8,17 @@ import {} from "@t3tools/contracts";import * as Option from "effect/Option";import { AsyncResult, Atom } from "effect/reactivity";-import { useRef, useState } from "react";-import { FlatList, Platform, View, type TextInputInstance } from "react-native";+import { useState } from "react";+import { FlatList, Platform } from "react-native";-import { AndroidScreenHeader } from "../../components/ui/AndroidScreenHeader";import { AppActivityIndicator } from "../../components/ui/AppActivityIndicator";import { EmptyState } from "../../components/ui/EmptyState";-import { SearchField } from "../../components/ui/SearchField";import { SelectionRow } from "../../components/ui/SelectionRow";-import { SheetHeader } from "../../components/ui/SheetHeader";-import { Toolbar } from "../../components/ui/Toolbar";-import { NativeStackScreenOptions } from "../../native/StackHeader";-import { useNativeMailSearchToolbar } from "../../native/use-native-mail-search-toolbar";import { composerPullRequests } from "../../state/pull-requests";import { useDebouncedValue } from "../../state/queries";-import {- createNativeMailSearchToolbarItem,- NATIVE_MAIL_SEARCH_TOOLBAR_CONTENT_INSET,-} from "../layout/native-mail-search-toolbar";import { pullRequestFilterChoices, pullRequestLabelColors } from "./pullRequestList";+import { PullRequestLabelDot } from "./PullRequestLabelDot";+import { PullRequestSearchSheet } from "./PullRequestSearchSheet";import { usePullRequestListControls } from "./usePullRequestListControls";export type PullRequestFilterSearchParams = {@@ -63,8 +55,6 @@ export function PullRequestFilterSearchScreen({const { kind, environmentId, environmentIds, suggestions, labelColors } = route.params;const listControls = usePullRequestListControls();const controls = listControls.controlsFor(environmentId);- const integratedSearch = useNativeMailSearchToolbar();- const searchRef = useRef<TextInputInstance>(null);const [query, setQuery] = useState("");const typed = query.trim().slice(0, 100);const sent = useDebouncedValue(typed, 250);@@ -121,124 +111,67 @@ export function PullRequestFilterSearchScreen({});};const placeholder = kind === "labels" ? "Search labels" : "Search authors";- const list = (- <FlatList- data={rows}- keyExtractor={(value) => value.toLowerCase()}- className="flex-1"- contentInsetAdjustmentBehavior="automatic"- automaticallyAdjustKeyboardInsets={Platform.OS === "ios"}- keyboardDismissMode={Platform.OS === "ios" ? "interactive" : "on-drag"}- keyboardShouldPersistTaps="handled"- showsVerticalScrollIndicator={false}- contentContainerStyle={{- paddingHorizontal: 16,- paddingTop: 16,- paddingBottom: integratedSearch ? NATIVE_MAIL_SEARCH_TOOLBAR_CONTENT_INSET + 16 : 16,- }}- renderItem={({ item, index }) => (- <SelectionRow- title={item}- role={kind === "labels" ? "checkbox" : "radio"}- selected={isSelected(item)}- isFirst={index === 0}- isLast={index === rows.length - 1}- leading={- kind === "labels" ? (- // Uncolored labels keep the dot's room so every name starts at the same edge.- <View- className="size-2.5 rounded-full"- style={{ backgroundColor: colors[item.toLowerCase()] ?? "transparent" }}+ return (+ <PullRequestSearchSheet+ title={kind === "labels" ? "Filter by label" : "Filter by author"}+ placeholder={placeholder}+ closeAccessibilityLabel={kind === "labels" ? "Close label filter" : "Close author filter"}+ clearAccessibilityLabel={kind === "labels" ? "Clear label search" : "Clear author search"}+ searchTextChangeId="pr-filter-option-search"+ query={query}+ onQueryChange={setQuery}+ >+ {({ paddingBottom }) => (+ <FlatList+ data={rows}+ keyExtractor={(value) => value.toLowerCase()}+ className="flex-1"+ contentInsetAdjustmentBehavior="automatic"+ automaticallyAdjustKeyboardInsets={Platform.OS === "ios"}+ keyboardDismissMode={Platform.OS === "ios" ? "interactive" : "on-drag"}+ keyboardShouldPersistTaps="handled"+ showsVerticalScrollIndicator={false}+ contentContainerStyle={{ paddingHorizontal: 16, paddingTop: 16, paddingBottom }}+ renderItem={({ item, index }) => (+ <SelectionRow+ title={item}+ role={kind === "labels" ? "checkbox" : "radio"}+ selected={isSelected(item)}+ isFirst={index === 0}+ isLast={index === rows.length - 1}+ leading={+ kind === "labels" ? (+ <PullRequestLabelDot color={colors[item.toLowerCase()] ?? null} />+ ) : undefined+ }+ onPress={() => choose(item)}+ />+ )}+ ListEmptyComponent={+ hosted.waiting || !settled ? (+ <AppActivityIndicator className="my-8" />+ ) : (+ <EmptyState+ title={+ hosted.failed+ ? "Couldn't search the host"+ : kind === "labels"+ ? "No matching labels"+ : "No matching authors"+ }+ detail={+ hosted.failed+ ? "The host didn't answer. Try again in a moment."+ : kind === "labels"+ ? "Search the labels of the repositories this list covers."+ : "Search people by name or handle on the repositories' hosts."+ }+ variant="plain"/>- ) : undefined+ )}- onPress={() => choose(item)}/>)}- ListEmptyComponent={- hosted.waiting || !settled ? (- <AppActivityIndicator className="my-8" />- ) : (- <EmptyState- title={- hosted.failed- ? "Couldn't search the host"- : kind === "labels"- ? "No matching labels"- : "No matching authors"- }- detail={- hosted.failed- ? "The host didn't answer. Try again in a moment."- : kind === "labels"- ? "Search the labels of the repositories this list covers."- : "Search people by name or handle on the repositories' hosts."- }- variant="plain"- />- )- }- />- );- const title = kind === "labels" ? "Filter by label" : "Filter by author";- if (Platform.OS === "android") {- return (- <View className="flex-1 bg-sheet" collapsable={false}>- <AndroidScreenHeader title={title} hideBottomBorder onBack={() => navigation.goBack()} />- <View className="bg-header px-4 pb-3 pt-1">- <SearchField- inputRef={searchRef}- accessibilityLabel={placeholder}- clearAccessibilityLabel={- kind === "labels" ? "Clear label search" : "Clear author search"- }- onChangeText={setQuery}- placeholder={placeholder}- value={query}- />- </View>- {list}- </View>- );- }- return (- <View className="flex-1 bg-sheet">- <SheetHeader- title={title}- onClose={() => navigation.goBack()}- accessibilityLabel={kind === "labels" ? "Close label filter" : "Close author filter"}- />- <NativeStackScreenOptions- options={{- unstable_headerToolbarItems: integratedSearch- ? () => [- createNativeMailSearchToolbarItem({- placeholder,- onSearchTextChange: setQuery,- showsSearchDismissButton: true,- searchTextChangeId: "pr-filter-option-search",- }),- ]- : undefined,- headerSearchBarOptions: integratedSearch- ? undefined- : {- placeholder,- allowToolbarIntegration: true,- autoCapitalize: "none",- hideNavigationBar: false,- obscureBackground: false,- onChangeText: (event) => setQuery(event.nativeEvent.text),- onCancelButtonPress: () => setQuery(""),- },- }}- />- {integratedSearch ? null : (- <Toolbar placement="bottom">- <Toolbar.SearchBarSlot />- </Toolbar>- )}- {list}- </View>+ </PullRequestSearchSheet>);}diff --git a/apps/mobile/src/features/pull-requests/PullRequestLabelDot.tsx b/apps/mobile/src/features/pull-requests/PullRequestLabelDot.tsxnew file mode 100644index 00000000000..a46a6e67d9c--- /dev/null+++ b/apps/mobile/src/features/pull-requests/PullRequestLabelDot.tsx@@ -0,0 +1,11 @@+import { View } from "react-native";++/** A label's color mark in pickers; uncolored labels keep its room so names line up. */+export function PullRequestLabelDot(props: { readonly color: string | null }) {+ return (+ <View+ className="size-2.5 rounded-full"+ style={{ backgroundColor: props.color ?? "transparent" }}+ />+ );+}diff --git a/apps/mobile/src/features/pull-requests/PullRequestLabelsScreen.tsx b/apps/mobile/src/features/pull-requests/PullRequestLabelsScreen.tsxnew file mode 100644index 00000000000..85a2d70da2b--- /dev/null+++ b/apps/mobile/src/features/pull-requests/PullRequestLabelsScreen.tsx@@ -0,0 +1,158 @@+import { useAtomValue } from "@effect/atom-react";+import type { StaticScreenProps } from "@react-navigation/native";+import { squashAtomCommandFailure } from "@t3tools/client-runtime/state/runtime";+import type { PullRequestLabelCandidate } from "@t3tools/contracts";+import { AsyncResult } from "effect/reactivity";+import { useRef, useState } from "react";+import { FlatList, Platform, View } from "react-native";+import { AppActivityIndicator } from "../../components/ui/AppActivityIndicator";+import { AppText as Text } from "../../components/ui/AppText";+import { Button } from "../../components/ui/Button";+import { EmptyState } from "../../components/ui/EmptyState";+import { SelectionRow } from "../../components/ui/SelectionRow";+import { composerPullRequests } from "../../state/pull-requests";+import { useEnvironmentQuery } from "../../state/query";+import { useAtomCommand } from "../../state/use-atom-command";+import { PullRequestLabelDot } from "./PullRequestLabelDot";+import { pullRequestLabelColor } from "./pullRequestList";+import { PullRequestSearchSheet } from "./PullRequestSearchSheet";+import { usePullRequestConnected } from "./usePullRequestConnected";+import { pullRequestTarget, type PullRequestParams } from "./usePullRequestDiff";++export function PullRequestLabelsScreen({ route }: StaticScreenProps<PullRequestParams>) {+ const target = pullRequestTarget(route.params);+ const pr = useEnvironmentQuery(composerPullRequests.detail(target)).data;+ const canWrite = useAtomValue(+ composerPullRequests.setLabels.permissionAtom(target.environmentId),+ );+ const connected = usePullRequestConnected(route.params.environmentId);+ const allowed =+ connected &&+ canWrite &&+ pr?.capabilities.labels === true &&+ pr.viewerPermissions.labels !== false;+ // Name the first thing in the way, so the notice says what would actually fix it.+ const readOnlyReason =+ !pr || allowed+ ? null+ : !connected+ ? "Reconnect to change labels."+ : !canWrite+ ? "This device isn't allowed to change source control on this environment."+ : pr.capabilities.labels !== true+ ? "This provider doesn't support changing labels."+ : "Changing labels needs triage access on this repository.";+ const result = useEnvironmentQuery(composerPullRequests.labelCandidates(target));+ const setLabels = useAtomCommand(composerPullRequests.setLabels, { reportFailure: false });+ const [query, setQuery] = useState("");+ const [pending, setPending] = useState<{ readonly name: string; readonly applied: boolean }>();+ const [error, setError] = useState<string | null>(null);+ const inFlight = useRef(false);+ const needle = query.trim().toLowerCase();+ // Host order, not applied-first: re-sorting on toggle would move the row out from under a tap.+ const candidates = (result.data?.candidates ?? []).filter((candidate) =>+ `${candidate.name} ${candidate.description ?? ""}`.toLowerCase().includes(needle),+ );+ const toggle = async (candidate: PullRequestLabelCandidate) => {+ if (!allowed || inFlight.current) return;+ inFlight.current = true;+ setPending({ name: candidate.name, applied: !candidate.isApplied });+ setError(null);+ const response = await setLabels({+ ...target,+ input: { ...target.input, labels: [candidate.name], applied: !candidate.isApplied },+ });+ inFlight.current = false;+ setPending(undefined);+ if (AsyncResult.isFailure(response)) {+ const cause = squashAtomCommandFailure(response);+ setError(cause instanceof Error ? cause.message : "Couldn't update this label. Try again.");+ }+ };+ return (+ <PullRequestSearchSheet+ title="Labels"+ placeholder="Search labels"+ closeAccessibilityLabel="Close labels"+ clearAccessibilityLabel="Clear label search"+ searchTextChangeId="pr-label-search"+ query={query}+ onQueryChange={setQuery}+ >+ {({ paddingBottom }) => (+ <FlatList+ data={candidates}+ keyExtractor={(candidate) => candidate.name}+ className="flex-1"+ contentInsetAdjustmentBehavior="automatic"+ automaticallyAdjustKeyboardInsets={Platform.OS === "ios"}+ keyboardDismissMode={Platform.OS === "ios" ? "interactive" : "on-drag"}+ keyboardShouldPersistTaps="handled"+ showsVerticalScrollIndicator={false}+ contentContainerStyle={{ paddingHorizontal: 16, paddingTop: 16, paddingBottom }}+ ListHeaderComponent={+ readOnlyReason || error ? (+ <View className="gap-2 pb-3">+ {readOnlyReason ? (+ <Text className="text-xs text-foreground-muted">{readOnlyReason}</Text>+ ) : null}+ {error ? (+ <Text selectable className="text-sm text-danger-foreground">+ {error}+ </Text>+ ) : null}+ </View>+ ) : undefined+ }+ renderItem={({ item, index }) => (+ <SelectionRow+ title={item.name}+ {...(item.description ? { subtitle: item.description } : {})}+ role="checkbox"+ // The change shows as soon as it is tapped; a failure puts the host's answer back.+ selected={pending?.name === item.name ? pending.applied : item.isApplied}+ disabled={!allowed}+ isFirst={index === 0}+ isLast={index === candidates.length - 1}+ leading={<PullRequestLabelDot color={pullRequestLabelColor(item.color)} />}+ onPress={() => void toggle(item)}+ />+ )}+ ListEmptyComponent={+ result.isPending && !result.data ? (+ <AppActivityIndicator className="my-8" />+ ) : (+ <View>+ <EmptyState+ title={+ result.error+ ? "Couldn't load labels"+ : needle+ ? "No matching labels"+ : "This repository has no labels"+ }+ detail={+ result.error ??+ (needle+ ? "Try another name."+ : "Create labels on the provider to use them here.")+ }+ variant="plain"+ />+ {result.error ? <Button label="Retry" onPress={result.refresh} /> : null}+ </View>+ )+ }+ ListFooterComponent={+ result.data?.truncated ? (+ <Text className="py-4 text-xs text-foreground-muted">+ This repository has more labels than are listed here. Apply the rest on the+ provider.+ </Text>+ ) : undefined+ }+ />+ )}+ </PullRequestSearchSheet>+ );+}diff --git a/apps/mobile/src/features/pull-requests/PullRequestReactions.tsx b/apps/mobile/src/features/pull-requests/PullRequestReactions.tsxnew file mode 100644index 00000000000..394fc630a00--- /dev/null+++ b/apps/mobile/src/features/pull-requests/PullRequestReactions.tsx@@ -0,0 +1,195 @@+import { useNavigation } from "@react-navigation/native";+import {+ applyPendingPullRequestReactions,+ PULL_REQUEST_REACTION_ORDER,+ pullRequestReactionEmoji,+ pullRequestReactionName,+ pullRequestReactionTooltip,+ pullRequestReactionsSignature,+} from "@t3tools/client-runtime/pull-request-reactions";+import type {+ PullRequestComment,+ PullRequestReaction,+ PullRequestReactionContent,+} from "@t3tools/contracts";+import { AsyncResult } from "effect/reactivity";+import { useState } from "react";+import { Pressable, View } from "react-native";+import { SymbolView } from "../../components/ui/AppSymbol";+import { AppText as Text } from "../../components/ui/AppText";+import * as Dialog from "../../components/ui/Dialog";+import { Menu } from "../../components/ui/Menu";+import { cn } from "../../lib/cn";+import { composerPullRequests } from "../../state/pull-requests";+import { useEnvironmentQuery } from "../../state/query";+import { useAtomCommand } from "../../state/use-atom-command";+import { pullRequestTarget, type PullRequestParams } from "./usePullRequestDiff";+import { usePullRequestPermissions } from "./usePullRequestPermissions";++const EMPTY_PENDING: ReadonlyMap<PullRequestReactionContent, boolean> = new Map();+const PILL = "min-h-8 flex-row items-center gap-1 rounded-full border px-2.5 active:opacity-70";++function ReactionPills(props: {+ readonly params: PullRequestParams;+ readonly reactions: ReadonlyArray<PullRequestReaction>;+ readonly canReact: boolean;+ /** Absent reacts to the change request itself. */+ readonly subjectId?: string;+ readonly onChanged: () => void;+}) {+ const target = pullRequestTarget(props.params);+ const setReaction = useAtomCommand(composerPullRequests.setReaction, { reportFailure: false });+ // Keyed by what the host last reported, so a refresh that lands the change drops the overlay.+ const [pending, setPending] = useState({ signature: "", values: EMPTY_PENDING });+ const signature = pullRequestReactionsSignature(props.reactions);+ const values = pending.signature === signature ? pending.values : EMPTY_PENDING;+ const shown = applyPendingPullRequestReactions(props.reactions, values);+ const toggle = async (content: PullRequestReactionContent, reacted: boolean) => {+ setPending({ signature, values: new Map([...values, [content, reacted]]) });+ const result = await setReaction({+ ...target,+ input: {+ ...target.input,+ ...(props.subjectId === undefined ? {} : { subjectId: props.subjectId }),+ content,+ reacted,+ },+ });+ if (AsyncResult.isFailure(result)) {+ setPending((current) => {+ const next = new Map(current.values);+ next.delete(content);+ return { signature: current.signature, values: next };+ });+ Dialog.alert("Couldn't save the reaction", "Try again in a moment.");+ return;+ }+ props.onChanged();+ };+ return (+ <>+ {shown.map((reaction) => (+ <Pressable+ key={reaction.content}+ accessibilityRole="button"+ accessibilityLabel={pullRequestReactionTooltip(reaction)}+ accessibilityState={{ selected: reaction.viewerHasReacted, disabled: !props.canReact }}+ disabled={!props.canReact}+ onPress={() => void toggle(reaction.content, !reaction.viewerHasReacted)}+ className={cn(+ PILL,+ reaction.viewerHasReacted+ ? "border-primary bg-primary/10"+ : "border-border-subtle bg-grouped-card",+ )}+ >+ <Text className="text-sm">{pullRequestReactionEmoji(reaction.content)}</Text>+ <Text className="text-xs font-t3-medium text-foreground-muted">{reaction.count}</Text>+ </Pressable>+ ))}+ {props.canReact ? (+ <Menu+ accessibilityLabel="Add a reaction"+ actions={PULL_REQUEST_REACTION_ORDER.map((content) => ({+ id: content,+ title: `${pullRequestReactionEmoji(content)} ${pullRequestReactionName(content)}`,+ state: shown.some(+ (reaction) => reaction.content === content && reaction.viewerHasReacted,+ )+ ? ("on" as const)+ : ("off" as const),+ }))}+ onPressAction={({ nativeEvent }) => {+ const content = PULL_REQUEST_REACTION_ORDER.find((id) => id === nativeEvent.event);+ if (!content) return;+ const reacted = shown.some(+ (reaction) => reaction.content === content && reaction.viewerHasReacted,+ );+ void toggle(content, !reacted);+ }}+ >+ <View className={cn(PILL, "border-border-subtle")}>+ <SymbolView name="face.smiling" size={15} tintColorClassName="accent-icon-muted" />+ </View>+ </Menu>+ ) : null}+ </>+ );+}++/** Reactions on the change request itself, which is where its description's reactions live. */+export function PullRequestReactions(props: { readonly params: PullRequestParams }) {+ const target = pullRequestTarget(props.params);+ const detail = useEnvironmentQuery(composerPullRequests.detail(target));+ const activity = useEnvironmentQuery(composerPullRequests.activity(target));+ const { canReact } = usePullRequestPermissions(props.params, detail.data);+ const reactions = activity.data?.reactions ?? [];+ if (!activity.data || (reactions.length === 0 && !canReact)) return null;+ return (+ <View className="flex-row flex-wrap items-center gap-1.5">+ <ReactionPills+ params={props.params}+ reactions={reactions}+ canReact={canReact}+ onChanged={activity.refresh}+ />+ </View>+ );+}++export function PullRequestCommentFooter(props: {+ readonly params: PullRequestParams;+ readonly comment: Pick<+ PullRequestComment,+ "id" | "kind" | "body" | "author" | "canEdit" | "reactions"+ >;+ readonly permissions: Pick<+ ReturnType<typeof usePullRequestPermissions>,+ "canEditComment" | "canReact"+ >;+ readonly onChanged: () => void;+ readonly onEdit?: () => void;+}) {+ const navigation = useNavigation();+ const { comment } = props;+ const reactions = comment.reactions ?? [];+ const editableKind = comment.kind === "review" ? null : comment.kind;+ const canEdit = editableKind !== null && props.permissions.canEditComment(comment);+ const { canReact } = props.permissions;+ if (reactions.length === 0 && !canReact && !canEdit) return null;+ return (+ <View className="flex-row flex-wrap items-center gap-1.5">+ <ReactionPills+ params={props.params}+ reactions={reactions}+ canReact={canReact}+ subjectId={comment.id}+ onChanged={props.onChanged}+ />+ {canEdit && editableKind !== null ? (+ <Pressable+ accessibilityRole="button"+ accessibilityLabel="Edit comment"+ onPress={() => {+ props.onEdit?.();+ navigation.navigate("PullRequestEdit", {+ ...props.params,+ field: "comment",+ comment: {+ id: comment.id,+ kind: editableKind,+ body: comment.body,+ author: comment.author,+ ...(comment.canEdit === undefined ? {} : { canEdit: comment.canEdit }),+ },+ });+ }}+ className={cn(PILL, "ml-auto border-transparent")}+ >+ <SymbolView name="pencil" size={13} tintColorClassName="accent-icon-muted" />+ <Text className="text-xs font-t3-medium text-foreground-muted">Edit</Text>+ </Pressable>+ ) : null}+ </View>+ );+}diff --git a/apps/mobile/src/features/pull-requests/PullRequestRouteScreen.tsx b/apps/mobile/src/features/pull-requests/PullRequestRouteScreen.tsxindex b013029db79..bbb962725df 100644--- a/apps/mobile/src/features/pull-requests/PullRequestRouteScreen.tsx+++ b/apps/mobile/src/features/pull-requests/PullRequestRouteScreen.tsx@@ -43,7 +43,7 @@ import {import { usePullRequestDiffHighlightFiles } from "./usePullRequestDiffHighlightFiles";import { isPullRequestTestFile } from "./pullRequestFileFilters";import { useFocusEffect, useNavigation, type StaticScreenProps } from "@react-navigation/native";-import { RegistryContext, useAtomRefresh } from "@effect/atom-react";+import { RegistryContext, useAtomRefresh, useAtomValue } from "@effect/atom-react";import { pullRequestReviewKey } from "./pullRequestReviewDrafts";import { type PullRequestDetail, type PullRequestListEntry } from "@t3tools/contracts";import { PullRequestOverviewLoading } from "./PullRequestOverviewLoading";@@ -76,6 +76,9 @@ import { SymbolView } from "../../components/ui/AppSymbol";import { relativeTime } from "../../lib/time";import { NativeStackScreenOptions } from "../../native/StackHeader";import { usePullRequestConnected } from "./usePullRequestConnected";+import { usePullRequestLiveChecks } from "./usePullRequestLiveChecks";+import { pullRequestLabelColor } from "./pullRequestList";+import { PullRequestReactions } from "./PullRequestReactions";import { composerPullRequests } from "../../state/pull-requests";import { useEnvironmentQuery } from "../../state/query";import { usePullToRefresh } from "../../state/use-pull-to-refresh";@@ -135,10 +138,15 @@ function PullRequestTabScrollView(props: ScrollViewProps) {function usePullRequestActivityRows(params: PullRequestParams, filter: ActivityFilter) {const navigation = useNavigation();const result = useEnvironmentQuery(composerPullRequests.activity(requestTarget(params)));+ const detail = useEnvironmentQuery(composerPullRequests.detail(requestTarget(params)));+ const permissions = usePullRequestPermissions(params, detail.data);const filtered = result.data ? filterPullRequestActivity(result.data, filter) : null;const rows = (() => {if (!filtered) return [];- const rows = pullRequestTimelineRows(filtered.activity, params, navigation);+ const rows = pullRequestTimelineRows(filtered.activity, params, navigation, {+ permissions,+ onChanged: result.refresh,+ });if (filter.newestFirst) {const notice = rows.at(-1)?.key === "truncated" ? rows.pop() : undefined;rows.reverse();@@ -229,6 +237,54 @@ function PullRequestIdentity(props: {);}+function PullRequestLabels(props: {+ readonly pr: PullRequestDetail;+ readonly params: PullRequestParams;+}) {+ const navigation = useNavigation();+ const connected = usePullRequestConnected(props.params.environmentId);+ const canWrite = useAtomValue(+ composerPullRequests.setLabels.permissionAtom(requestTarget(props.params).environmentId),+ );+ const editable =+ connected &&+ canWrite &&+ props.pr.capabilities.labels === true &&+ props.pr.viewerPermissions.labels !== false;+ if (!props.pr.labels.length && !editable) return null;+ return (+ <Animated.View layout={PR_ROW_LAYOUT} className="flex-row flex-wrap gap-2">+ {props.pr.labels.map((label) => {+ const color = pullRequestLabelColor(label.color);+ // Tinted like the list row's label pills, at the overview's chip size.+ return (+ <View+ key={label.name}+ className="max-w-full flex-row items-center gap-1.5 rounded-2xl bg-grouped-card px-3 py-1"+ style={color ? { backgroundColor: `${color}20` } : undefined}+ >+ {color ? (+ <View style={{ width: 6, height: 6, borderRadius: 3, backgroundColor: color }} />+ ) : null}+ <Text textRole="caption" className="shrink text-foreground-muted" numberOfLines={1}>+ {label.name}+ </Text>+ </View>+ );+ })}+ {editable ? (+ <Chip+ label={props.pr.labels.length ? "Edit" : "Add labels"}+ icon="tag"+ size="small"+ accessibilityLabel="Edit labels"+ onPress={() => navigation.navigate("PullRequestLabels", props.params)}+ />+ ) : null}+ </Animated.View>+ );+}+function PullRequestOverview(props: {readonly pr: PullRequestDetail;readonly params: PullRequestParams;@@ -252,13 +308,7 @@ function PullRequestOverview(props: {<PullRequestMergeControls pr={pr} params={props.params} stack={props.stack} /></Animated.View></PullRequestCardGroup>- {pr.labels.length ? (- <Animated.View layout={PR_ROW_LAYOUT} className="flex-row flex-wrap gap-2">- {pr.labels.map((label) => (- <Chip key={label.name} label={label.name} size="small" />- ))}- </Animated.View>- ) : null}+ <PullRequestLabels pr={pr} params={props.params} /><Animated.Viewlayout={PR_POSITION_LAYOUT}onLayout={(event) => props.onDescriptionLayout(event.nativeEvent.layout.y)}@@ -268,6 +318,7 @@ function PullRequestOverview(props: {onCollapse={props.onDescriptionCollapse}expanded={props.descriptionExpanded}onExpandedChange={props.onDescriptionExpandedChange}+ footer={<PullRequestReactions params={props.params} />}/></Animated.View></View>@@ -347,7 +398,7 @@ export function PullRequestRouteScreen({ route }: StaticScreenProps<PullRequestPconst pullRefresh = usePullToRefresh(detailAtom);const { refresh: refreshDetail } = result;useFocusEffect(() => refreshDetail());- const pr = result.data;+ const pr = usePullRequestLiveChecks(params, result.data);const summary = params.initialSummary;const identity = pr ?? summary;const terminology = sourceControlClients.get(identity?.provider).changeRequest;@@ -436,6 +487,24 @@ export function PullRequestRouteScreen({ route }: StaticScreenProps<PullRequestP},]: []),+ ...(permissions.canEditChangeRequest+ ? [+ {+ accessibilityLabel: "Edit title",+ icon: "pencil" as const,+ overflowOnly: true,+ onPress: () =>+ navigation.navigate("PullRequestEdit", { ...params, field: "title" }),+ },+ {+ accessibilityLabel: "Edit description",+ icon: "doc.text" as const,+ overflowOnly: true,+ onPress: () =>+ navigation.navigate("PullRequestEdit", { ...params, field: "body" }),+ },+ ]+ : []),...(identity? [{@@ -498,6 +567,24 @@ export function PullRequestRouteScreen({ route }: StaticScreenProps<PullRequestP<Toolbar.Label>Add comment</Toolbar.Label></Toolbar.MenuAction>) : null}+ {permissions.canEditChangeRequest ? (+ <Toolbar.MenuAction+ icon="pencil"+ onPress={() =>+ navigation.navigate("PullRequestEdit", { ...params, field: "title" })+ }+ >+ <Toolbar.Label>Edit title</Toolbar.Label>+ </Toolbar.MenuAction>+ ) : null}+ {permissions.canEditChangeRequest ? (+ <Toolbar.MenuAction+ icon="doc.text"+ onPress={() => navigation.navigate("PullRequestEdit", { ...params, field: "body" })}+ >+ <Toolbar.Label>Edit description</Toolbar.Label>+ </Toolbar.MenuAction>+ ) : null}{identity ? (<Toolbar.MenuActionicon="arrow.up.right"diff --git a/apps/mobile/src/features/pull-requests/PullRequestSearchSheet.tsx b/apps/mobile/src/features/pull-requests/PullRequestSearchSheet.tsxnew file mode 100644index 00000000000..ab7491f4949--- /dev/null+++ b/apps/mobile/src/features/pull-requests/PullRequestSearchSheet.tsx@@ -0,0 +1,99 @@+import { useNavigation } from "@react-navigation/native";+import { useRef, type ReactNode } from "react";+import { Platform, View, type TextInputInstance } from "react-native";++import { AndroidScreenHeader } from "../../components/ui/AndroidScreenHeader";+import { SearchField } from "../../components/ui/SearchField";+import { SheetHeader } from "../../components/ui/SheetHeader";+import { Toolbar } from "../../components/ui/Toolbar";+import { NativeStackScreenOptions } from "../../native/StackHeader";+import { useNativeMailSearchToolbar } from "../../native/use-native-mail-search-toolbar";+import {+ createNativeMailSearchToolbarItem,+ NATIVE_MAIL_SEARCH_TOOLBAR_CONTENT_INSET,+} from "../layout/native-mail-search-toolbar";++/**+ * A searchable picker over a pull request list or a pull request: a pushed card with a search+ * field on Android, a sheet with the native search toolbar on iOS.+ */+export function PullRequestSearchSheet(props: {+ readonly title: string;+ readonly placeholder: string;+ readonly closeAccessibilityLabel: string;+ readonly clearAccessibilityLabel: string;+ readonly searchTextChangeId: string;+ readonly query: string;+ readonly onQueryChange: (query: string) => void;+ /** Renders the list, given the bottom padding that keeps its end clear of the search bar. */+ readonly children: (list: { readonly paddingBottom: number }) => ReactNode;+}) {+ const navigation = useNavigation();+ const integratedSearch = useNativeMailSearchToolbar();+ const searchRef = useRef<TextInputInstance>(null);+ const list = props.children({+ paddingBottom: integratedSearch ? NATIVE_MAIL_SEARCH_TOOLBAR_CONTENT_INSET + 16 : 16,+ });+ if (Platform.OS === "android") {+ return (+ <View className="flex-1 bg-sheet" collapsable={false}>+ <AndroidScreenHeader+ title={props.title}+ hideBottomBorder+ onBack={() => navigation.goBack()}+ />+ <View className="bg-header px-4 pb-3 pt-1">+ <SearchField+ inputRef={searchRef}+ accessibilityLabel={props.placeholder}+ clearAccessibilityLabel={props.clearAccessibilityLabel}+ onChangeText={props.onQueryChange}+ placeholder={props.placeholder}+ value={props.query}+ />+ </View>+ {list}+ </View>+ );+ }+ return (+ <View className="flex-1 bg-sheet">+ <SheetHeader+ title={props.title}+ onClose={() => navigation.goBack()}+ accessibilityLabel={props.closeAccessibilityLabel}+ />+ <NativeStackScreenOptions+ options={{+ unstable_headerToolbarItems: integratedSearch+ ? () => [+ createNativeMailSearchToolbarItem({+ placeholder: props.placeholder,+ onSearchTextChange: props.onQueryChange,+ showsSearchDismissButton: true,+ searchTextChangeId: props.searchTextChangeId,+ }),+ ]+ : undefined,+ headerSearchBarOptions: integratedSearch+ ? undefined+ : {+ placeholder: props.placeholder,+ allowToolbarIntegration: true,+ autoCapitalize: "none",+ hideNavigationBar: false,+ obscureBackground: false,+ onChangeText: (event) => props.onQueryChange(event.nativeEvent.text),+ onCancelButtonPress: () => props.onQueryChange(""),+ },+ }}+ />+ {integratedSearch ? null : (+ <Toolbar placement="bottom">+ <Toolbar.SearchBarSlot />+ </Toolbar>+ )}+ {list}+ </View>+ );+}diff --git a/apps/mobile/src/features/pull-requests/PullRequestTimeline.tsx b/apps/mobile/src/features/pull-requests/PullRequestTimeline.tsxindex 9345d5c9ab7..424f8cdff1b 100644--- a/apps/mobile/src/features/pull-requests/PullRequestTimeline.tsx+++ b/apps/mobile/src/features/pull-requests/PullRequestTimeline.tsx@@ -4,7 +4,7 @@ import { useAppearancePreferences } from "../settings/appearance/AppearancePrefeimport IconGitCommit from "@tabler/icons-react-native/IconGitCommit";import type { PullRequestActivity, PullRequestComment } from "@t3tools/contracts";import { StackActions, type NavigationProp } from "@react-navigation/native";-import { useMemo, useState, type ReactNode } from "react";+import { useMemo, useState, type ComponentProps, type ReactNode } from "react";import { Pressable, StyleSheet, View } from "react-native";import { parseMarkdownDocument } from "../../lib/markdownDocument";import { AppText as Text } from "../../components/ui/AppText";@@ -12,6 +12,7 @@ import { SymbolView, type AppSymbolName } from "../../components/ui/AppSymbol";import { relativeTime } from "../../lib/time";import { PullRequestAvatar } from "./PullRequestPresentation";import { PullRequestMarkdown } from "./PullRequestMarkdown";+import { PullRequestCommentFooter } from "./PullRequestReactions";import { pullRequestDescriptionContent } from "./pullRequestDescriptionContent";import type { PullRequestParams } from "./usePullRequestDiff";@@ -57,7 +58,20 @@ function TimelineEvent(props: {);}-function TimelineComment({ comment }: { comment: PullRequestComment }) {+type CommentActions = {+ readonly permissions: ComponentProps<typeof PullRequestCommentFooter>["permissions"];+ readonly onChanged: () => void;+};++function TimelineComment({+ comment,+ params,+ actions,+}: {+ comment: PullRequestComment;+ params: PullRequestParams;+ actions: CommentActions;+}) {const [expanded, setExpanded] = useState(false);const { themeVariables: colors } = useAppearancePreferences();const long = comment.body.length > 450 || comment.body.split("\n").length > 8;@@ -169,6 +183,12 @@ function TimelineComment({ comment }: { comment: PullRequestComment }) {) : null}</View>) : null}+ <PullRequestCommentFooter+ params={params}+ comment={comment}+ permissions={actions.permissions}+ onChanged={actions.onChanged}+ /></TimelineEvent>);}@@ -177,6 +197,7 @@ export function pullRequestTimelineRows(activity: PullRequestActivity,params: PullRequestParams,navigation: Pick<NavigationProp<ReactNavigation.RootParamList>, "navigate" | "dispatch">,+ actions: CommentActions,) {const discussionIds = new Set(activity.reviewThreads.flatMap((thread) => thread.comments.map((comment) => comment.id)),@@ -187,7 +208,7 @@ export function pullRequestTimelineRows(.map((comment) => ({key: `comment:${comment.id}`,date: comment.createdAt,- content: <TimelineComment comment={comment} />,+ content: <TimelineComment comment={comment} params={params} actions={actions} />,})),...activity.reviewThreads.map((thread) => ({key: `discussion:${thread.id}`,diff --git a/apps/mobile/src/features/pull-requests/usePullRequestLiveChecks.ts b/apps/mobile/src/features/pull-requests/usePullRequestLiveChecks.tsnew file mode 100644index 00000000000..b7ce3397617--- /dev/null+++ b/apps/mobile/src/features/pull-requests/usePullRequestLiveChecks.ts@@ -0,0 +1,42 @@+import { useFocusEffect } from "@react-navigation/native";+import {+ pullRequestChecksRefreshIntervalMs,+ resolvePullRequestDetailChecks,+} from "@t3tools/client-runtime/pull-request-checks";+import type { PullRequestDetail } from "@t3tools/contracts";+import { useEnvironmentServerConfig } from "../../state/entities";+import { composerPullRequests } from "../../state/pull-requests";+import { useEnvironmentQuery } from "../../state/query";+import { usePullRequestConnected } from "./usePullRequestConnected";+import { pullRequestTarget, type PullRequestParams } from "./usePullRequestDiff";++/**+ * Re-reads only the checks while an open change request is on screen, so a running CI shows up+ * without paying for a full detail read every poll.+ */+export function usePullRequestLiveChecks(+ params: PullRequestParams,+ detail: PullRequestDetail | null,+): PullRequestDetail | null {+ const target = pullRequestTarget(params);+ const connected = usePullRequestConnected(target.environmentId);+ const supported =+ useEnvironmentServerConfig(target.environmentId)?.environment.capabilities.pullRequestChecks ===+ true;+ const checks = useEnvironmentQuery(+ supported && detail !== null ? composerPullRequests.checks(target) : null,+ );+ // Both reads carry the server's observedAt; without it the poll is the fresher stream.+ const live = resolvePullRequestDetailChecks(detail, checks.data, true);+ // A failed read keeps polling; only a host that answers "no checks" (null) stops it.+ const enabled =+ connected && supported && live?.state === "open" && !(checks.isSuccess && checks.data === null);+ const intervalMs = pullRequestChecksRefreshIntervalMs(live?.checks ?? []);+ const { refresh } = checks;+ useFocusEffect(() => {+ if (!enabled) return;+ const timer = setInterval(refresh, intervalMs);+ return () => clearInterval(timer);+ });+ return live;+}diff --git a/apps/mobile/src/features/pull-requests/usePullRequestPermissions.ts b/apps/mobile/src/features/pull-requests/usePullRequestPermissions.tsindex bde66bf9a4b..741b9c2ad08 100644--- a/apps/mobile/src/features/pull-requests/usePullRequestPermissions.ts+++ b/apps/mobile/src/features/pull-requests/usePullRequestPermissions.ts@@ -1,5 +1,9 @@import { useAtomValue } from "@effect/atom-react";-import type { PullRequestDetail } from "@t3tools/contracts";+import {+ canEditPullRequestChangeRequest,+ canEditPullRequestComment,+} from "@t3tools/client-runtime/pull-request-editing";+import type { PullRequestComment, PullRequestDetail } from "@t3tools/contracts";import { usePullRequestConnected } from "./usePullRequestConnected";import { composerPullRequests } from "../../state/pull-requests";import { pullRequestTarget, type PullRequestParams } from "./usePullRequestDiff";@@ -14,6 +18,13 @@ export function usePullRequestPermissions(params: PullRequestParams, pr: PullReqconst canResolve = useAtomValue(composerPullRequests.setThreadResolution.permissionAtom(environmentId),);+ const canUpdate = useAtomValue(composerPullRequests.update.permissionAtom(environmentId));+ const canUpdateComment = useAtomValue(+ composerPullRequests.updateComment.permissionAtom(environmentId),+ );+ const canSetReaction = useAtomValue(+ composerPullRequests.setReaction.permissionAtom(environmentId),+ );return {connected,canInlineComment:@@ -36,6 +47,11 @@ export function usePullRequestPermissions(params: PullRequestParams, pr: PullReqpr?.capabilities.review.resolve === true &&pr.viewerPermissions.resolve,canWrite: connected && canWrite,+ canEditChangeRequest:+ connected && canUpdate && pr !== null && canEditPullRequestChangeRequest(pr),+ canEditComment: (comment: Pick<PullRequestComment, "author" | "canEdit" | "kind">) =>+ connected && canUpdateComment && pr !== null && canEditPullRequestComment(pr, comment),+ canReact: connected && canSetReaction && pr?.capabilities.reactions === true,canComment:connected && canComment && pr?.capabilities.comment === true && pr.viewerPermissions.comment,verdicts:diff --git a/apps/web/src/components/chat/ThreadDetailsPrRow.tsx b/apps/web/src/components/chat/ThreadDetailsPrRow.tsxindex 4696e7c71a8..f6b16deb235 100644--- a/apps/web/src/components/chat/ThreadDetailsPrRow.tsx+++ b/apps/web/src/components/chat/ThreadDetailsPrRow.tsx@@ -1,3 +1,4 @@+import { resolvePullRequestDetailChecks } from "@t3tools/client-runtime/pull-request-checks";import {capitalizeTerm,sourceControlClients,@@ -35,7 +36,6 @@ import {buildFixFindingsHandoff,buildResolveConflictsPrompt,classifyPullRequestChecks,- resolvePullRequestDetailChecks,describePullRequestChecks,isPullRequestConflicting,resolvePullRequestMergeMethod,diff --git a/apps/web/src/components/pullRequest/PullRequestCodeTab.tsx b/apps/web/src/components/pullRequest/PullRequestCodeTab.tsxindex ff7593d71b5..4fcc5813084 100644--- a/apps/web/src/components/pullRequest/PullRequestCodeTab.tsx+++ b/apps/web/src/components/pullRequest/PullRequestCodeTab.tsx@@ -45,7 +45,10 @@ import { useClientSettings, updateClientSettings } from "~/hooks/useSettings";import { useRenderedAppearance } from "~/hooks/useTheme";import { areAllDiffFilesCollapsed } from "~/lib/diffCollapse";import { pullRequestFindingKey, type PullRequestFinding } from "./pullRequestDetail.logic";-import { canEditPullRequestComment, canResolvePullRequestThread } from "./pullRequestEditing.logic";+import {+ canEditPullRequestComment,+ canResolvePullRequestThread,+} from "@t3tools/client-runtime/pull-request-editing";import { orderDiffFiles } from "./pullRequestFileOrder.logic";import {buildFileDiffRenderKey,diff --git a/apps/web/src/components/pullRequest/PullRequestReactions.tsx b/apps/web/src/components/pullRequest/PullRequestReactions.tsxindex 2d197da3d93..78a55d7f24a 100644--- a/apps/web/src/components/pullRequest/PullRequestReactions.tsx+++ b/apps/web/src/components/pullRequest/PullRequestReactions.tsx@@ -20,19 +20,14 @@ import {pullRequestReactionEmoji,pullRequestReactionName,pullRequestReactionTooltip,-} from "./pullRequestReactions.logic";+ pullRequestReactionsSignature,+} from "@t3tools/client-runtime/pull-request-reactions";const PILL_CLASS ="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";const EMPTY_PENDING: ReadonlyMap<PullRequestReactionContent, boolean> = new Map();-function reactionsSignature(reactions: ReadonlyArray<PullRequestReaction>): string {- return reactions- .map((reaction) => `${reaction.content}:${reaction.count}:${reaction.viewerHasReacted ? 1 : 0}`)- .join(" ");-}-export function PullRequestReactionBar({reactions,canReact,@@ -60,7 +55,7 @@ export function PullRequestReactionBar({reportFailure: false,});- const signature = reactionsSignature(reactions);+ const signature = pullRequestReactionsSignature(reactions);const values = pending.signature === signature ? pending.values : EMPTY_PENDING;const shown = applyPendingPullRequestReactions(reactions, values);diff --git a/apps/web/src/components/pullRequest/PullRequestSummaryTab.tsx b/apps/web/src/components/pullRequest/PullRequestSummaryTab.tsxindex 38fd345c170..3807926bdfe 100644--- a/apps/web/src/components/pullRequest/PullRequestSummaryTab.tsx+++ b/apps/web/src/components/pullRequest/PullRequestSummaryTab.tsx@@ -72,7 +72,7 @@ import {import {canEditPullRequestChangeRequest,canEditPullRequestComment,-} from "./pullRequestEditing.logic";+} from "@t3tools/client-runtime/pull-request-editing";import { PullRequestMarkdown } from "./PullRequestMarkdown";import { PullRequestCommentBody } from "./PullRequestCommentBody";import { PullRequestMoreReplies } from "./PullRequestMoreReplies";diff --git a/apps/web/src/components/pullRequest/PullRequestTimelineTab.tsx b/apps/web/src/components/pullRequest/PullRequestTimelineTab.tsxindex c9036e0b98e..8bad8047826 100644--- a/apps/web/src/components/pullRequest/PullRequestTimelineTab.tsx+++ b/apps/web/src/components/pullRequest/PullRequestTimelineTab.tsx@@ -41,7 +41,7 @@ import {type PullRequestTimelineEvent,type PullRequestTimelineThread,} from "./pullRequestDetail.logic";-import { canEditPullRequestComment } from "./pullRequestEditing.logic";+import { canEditPullRequestComment } from "@t3tools/client-runtime/pull-request-editing";import { PullRequestMarkdown } from "./PullRequestMarkdown";import { PullRequestMoreReplies } from "./PullRequestMoreReplies";import { PullRequestMarkdownEditor } from "./PullRequestMarkdownEditor";diff --git a/apps/web/src/components/pullRequest/PullRequestTitleEditor.tsx b/apps/web/src/components/pullRequest/PullRequestTitleEditor.tsxindex 31ceb3cc5b7..ce6e8a80107 100644--- a/apps/web/src/components/pullRequest/PullRequestTitleEditor.tsx+++ b/apps/web/src/components/pullRequest/PullRequestTitleEditor.tsx@@ -15,7 +15,7 @@ import { Tooltip, TooltipPopup, TooltipTrigger } from "../ui/tooltip";import { PullRequestDetailTitleRow } from "./PullRequestDetailLayout";import { PullRequestEditButton } from "./PullRequestEditButton";import { readableFailure } from "./pullRequestDetail.logic";-import { canEditPullRequestChangeRequest } from "./pullRequestEditing.logic";+import { canEditPullRequestChangeRequest } from "@t3tools/client-runtime/pull-request-editing";/** The pull request title, which the reader can rename in place when the host allows it. */export function PullRequestTitleEditor({diff --git a/apps/web/src/components/pullRequest/pullRequestDetail.logic.test.ts b/apps/web/src/components/pullRequest/pullRequestDetail.logic.test.tsindex 7b0d8e31211..30567259a76 100644--- a/apps/web/src/components/pullRequest/pullRequestDetail.logic.test.ts+++ b/apps/web/src/components/pullRequest/pullRequestDetail.logic.test.ts@@ -48,7 +48,6 @@ import {checkoutFailureDescription,readPullRequestDetailSnapshot,resolveDisplayedPullRequestDetail,- resolvePullRequestDetailChecks,resolvePullRequestReferenceHost,resolvePullRequestPrimaryControl,allowsSinglePullRequestMerge,@@ -1294,59 +1293,6 @@ describe("cached pull request detail", () => {...overrides,}) as PullRequestDetail;- it("uses fresh checks for detail counts without replacing other PR fields", () => {- const pending = (name: string): PullRequestCheck => ({- name,- status: "pending",- url: null,- description: null,- });- const original = detail({ checks: [pending("build"), pending("test")] });- const checks = [pending("build"), { ...pending("test"), status: "success" as const }];- expect(resolvePullRequestDetailChecks(original, { state: "closed", checks }, true)).toEqual({- ...original,- state: "closed",- checks,- });- expect(resolvePullRequestDetailChecks(original, { state: "closed", checks }, false)).toBe(- original,- );- expect(resolvePullRequestDetailChecks(original, null, true)).toBe(original);- expect(resolvePullRequestDetailChecks(null, { state: "closed", checks }, true)).toBeNull();- });-- it("keeps newer checks when an older cached detail arrives later", () => {- const pending: PullRequestCheck = {- name: "build",- status: "pending",- url: null,- description: null,- };- const cached = detail({ observedAt: 1_000, checks: [pending] });- const checks = {- state: "open" as const,- checks: [{ ...pending, status: "success" as const }],- observedAt: 2_000,- };- const resolved = resolvePullRequestDetailChecks(cached, checks, false);- expect(resolved?.checks).toEqual(checks.checks);- expect(resolved?.observedAt).toBe(1_000);- expect(- resolvePullRequestDetailChecks(cached, { state: checks.state, checks: checks.checks }, true)- ?.checks,- ).toEqual(checks.checks);- const refreshed = detail({ observedAt: 3_000, checks: [pending] });- expect(resolvePullRequestDetailChecks(refreshed, checks, true)).toBe(refreshed);- });-- it("keeps merged details settled while applying newer checks", () => {- const merged = detail({ state: "merged", observedAt: 1_000 });- const checks = [{ name: "build", status: "success" as const, url: null, description: null }];- expect(- resolvePullRequestDetailChecks(merged, { state: "open", observedAt: 2_000, checks }, true),- ).toEqual({ ...merged, checks });- });-const makeStorage = () => {const held = new Map<string, string>();return {diff --git a/apps/web/src/components/pullRequest/pullRequestDetail.logic.ts b/apps/web/src/components/pullRequest/pullRequestDetail.logic.tsindex cbecf8a60ca..134ec30524f 100644--- a/apps/web/src/components/pullRequest/pullRequestDetail.logic.ts+++ b/apps/web/src/components/pullRequest/pullRequestDetail.logic.ts@@ -1430,22 +1430,3 @@ export function resolveDisplayedPullRequestDetail(input: {? input.cached: null;}--export function resolvePullRequestDetailChecks(- detail: PullRequestDetail | null,- checks: PullRequestChecks | null,- checksAreNewer: boolean,-): PullRequestDetail | null {- if (detail === null || checks === null) return detail;- const newer =- detail.observedAt !== undefined && checks.observedAt !== undefined- ? checks.observedAt >= detail.observedAt- : checksAreNewer;- return newer- ? {- ...detail,- state: detail.state === "merged" ? "merged" : checks.state,- checks: checks.checks,- }- : detail;-}diff --git a/apps/web/src/components/pullRequest/usePullRequestDetail.ts b/apps/web/src/components/pullRequest/usePullRequestDetail.tsindex 2ef76be9b15..a721129fbb0 100644--- a/apps/web/src/components/pullRequest/usePullRequestDetail.ts+++ b/apps/web/src/components/pullRequest/usePullRequestDetail.ts@@ -1,3 +1,4 @@+import { resolvePullRequestDetailChecks } from "@t3tools/client-runtime/pull-request-checks";import {AuthSourceControlWriteScope,type EnvironmentId,@@ -20,7 +21,6 @@ import {import {readPullRequestDetailSnapshot,resolveDisplayedPullRequestDetail,- resolvePullRequestDetailChecks,writePullRequestDetailSnapshot,} from "./pullRequestDetail.logic";import { pullRequestChecksState } from "./pullRequestPresentation";diff --git a/apps/web/src/hooks/usePullRequestChecksRefresh.ts b/apps/web/src/hooks/usePullRequestChecksRefresh.tsindex d83ca968a2d..c059bdde82f 100644--- a/apps/web/src/hooks/usePullRequestChecksRefresh.ts+++ b/apps/web/src/hooks/usePullRequestChecksRefresh.ts@@ -1,3 +1,4 @@+import { pullRequestChecksRefreshIntervalMs } from "@t3tools/client-runtime/pull-request-checks";import type { PullRequestCheck } from "@t3tools/contracts";import { useLiveRefresh } from "./useLiveRefresh";@@ -11,10 +12,6 @@ export function usePullRequestChecksRefresh(input: {useLiveRefresh(input.refresh, {key: input.key,enabled: input.enabled,- intervalMs:- input.checks.length === 0 ||- input.checks.some((check) => check.status === "pending" || check.status === "action-required")- ? 45_000- : 60_000,+ intervalMs: pullRequestChecksRefreshIntervalMs(input.checks),});}diff --git a/packages/client-runtime/package.json b/packages/client-runtime/package.jsonindex 712ea05bdcb..5ae338b7d59 100644--- a/packages/client-runtime/package.json+++ b/packages/client-runtime/package.json@@ -447,6 +447,18 @@"types": "./src/pullRequestMarkdown.ts","default": "./src/pullRequestMarkdown.ts"},+ "./pull-request-checks": {+ "types": "./src/pullRequestChecks.ts",+ "default": "./src/pullRequestChecks.ts"+ },+ "./pull-request-editing": {+ "types": "./src/pullRequestEditing.ts",+ "default": "./src/pullRequestEditing.ts"+ },+ "./pull-request-reactions": {+ "types": "./src/pullRequestReactions.ts",+ "default": "./src/pullRequestReactions.ts"+ },"./pull-request-query": {"types": "./src/pullRequestQuery.ts","default": "./src/pullRequestQuery.ts"diff --git a/packages/client-runtime/src/pullRequestChecks.test.ts b/packages/client-runtime/src/pullRequestChecks.test.tsnew file mode 100644index 00000000000..8b9f46451d9--- /dev/null+++ b/packages/client-runtime/src/pullRequestChecks.test.ts@@ -0,0 +1,62 @@+import type { PullRequestCheck, PullRequestDetail } from "@t3tools/contracts";+import { describe, expect, it } from "vite-plus/test";++import { resolvePullRequestDetailChecks } from "./pullRequestChecks.ts";++const detail = (overrides: Partial<PullRequestDetail> = {}): PullRequestDetail =>+ ({ title: "Cache the title", state: "open", checks: [], ...overrides }) as PullRequestDetail;++describe("resolvePullRequestDetailChecks", () => {+ it("uses fresh checks for detail counts without replacing other PR fields", () => {+ const pending = (name: string): PullRequestCheck => ({+ name,+ status: "pending",+ url: null,+ description: null,+ });+ const original = detail({ checks: [pending("build"), pending("test")] });+ const checks = [pending("build"), { ...pending("test"), status: "success" as const }];+ expect(resolvePullRequestDetailChecks(original, { state: "closed", checks }, true)).toEqual({+ ...original,+ state: "closed",+ checks,+ });+ expect(resolvePullRequestDetailChecks(original, { state: "closed", checks }, false)).toBe(+ original,+ );+ expect(resolvePullRequestDetailChecks(original, null, true)).toBe(original);+ expect(resolvePullRequestDetailChecks(null, { state: "closed", checks }, true)).toBeNull();+ });++ it("keeps newer checks when an older cached detail arrives later", () => {+ const pending: PullRequestCheck = {+ name: "build",+ status: "pending",+ url: null,+ description: null,+ };+ const cached = detail({ observedAt: 1_000, checks: [pending] });+ const checks = {+ state: "open" as const,+ checks: [{ ...pending, status: "success" as const }],+ observedAt: 2_000,+ };+ const resolved = resolvePullRequestDetailChecks(cached, checks, false);+ expect(resolved?.checks).toEqual(checks.checks);+ expect(resolved?.observedAt).toBe(1_000);+ expect(+ resolvePullRequestDetailChecks(cached, { state: checks.state, checks: checks.checks }, true)+ ?.checks,+ ).toEqual(checks.checks);+ const refreshed = detail({ observedAt: 3_000, checks: [pending] });+ expect(resolvePullRequestDetailChecks(refreshed, checks, true)).toBe(refreshed);+ });++ it("keeps merged details settled while applying newer checks", () => {+ const merged = detail({ state: "merged", observedAt: 1_000 });+ const checks = [{ name: "build", status: "success" as const, url: null, description: null }];+ expect(+ resolvePullRequestDetailChecks(merged, { state: "open", observedAt: 2_000, checks }, true),+ ).toEqual({ ...merged, checks });+ });+});diff --git a/packages/client-runtime/src/pullRequestChecks.ts b/packages/client-runtime/src/pullRequestChecks.tsnew file mode 100644index 00000000000..11191ffb237--- /dev/null+++ b/packages/client-runtime/src/pullRequestChecks.ts@@ -0,0 +1,30 @@+import type { PullRequestCheck, PullRequestChecks, PullRequestDetail } from "@t3tools/contracts";++export function resolvePullRequestDetailChecks(+ detail: PullRequestDetail | null,+ checks: PullRequestChecks | null,+ checksAreNewer: boolean,+): PullRequestDetail | null {+ if (detail === null || checks === null) return detail;+ const newer =+ detail.observedAt !== undefined && checks.observedAt !== undefined+ ? checks.observedAt >= detail.observedAt+ : checksAreNewer;+ return newer+ ? {+ ...detail,+ state: detail.state === "merged" ? "merged" : checks.state,+ checks: checks.checks,+ }+ : detail;+}++/** Checks still running are worth a tighter poll than a settled head. */+export function pullRequestChecksRefreshIntervalMs(+ checks: ReadonlyArray<PullRequestCheck>,+): number {+ return checks.length === 0 ||+ checks.some((check) => check.status === "pending" || check.status === "action-required")+ ? 45_000+ : 60_000;+}diff --git a/apps/web/src/components/pullRequest/pullRequestEditing.logic.test.ts b/packages/client-runtime/src/pullRequestEditing.test.tssimilarity index 99%rename from apps/web/src/components/pullRequest/pullRequestEditing.logic.test.tsrename to packages/client-runtime/src/pullRequestEditing.test.tsindex e58c01b74ce..1b473f4657d 100644--- a/apps/web/src/components/pullRequest/pullRequestEditing.logic.test.ts+++ b/packages/client-runtime/src/pullRequestEditing.test.ts@@ -11,7 +11,7 @@ import {canEditPullRequestChangeRequest,canEditPullRequestComment,canResolvePullRequestThread,-} from "./pullRequestEditing.logic";+} from "./pullRequestEditing.ts";type Subject = Pick<PullRequestDetail, "author" | "capabilities" | "viewer" | "viewerPermissions">;diff --git a/apps/web/src/components/pullRequest/pullRequestEditing.logic.ts b/packages/client-runtime/src/pullRequestEditing.tssimilarity index 100%rename from apps/web/src/components/pullRequest/pullRequestEditing.logic.tsrename to packages/client-runtime/src/pullRequestEditing.tsdiff --git a/apps/web/src/components/pullRequest/pullRequestReactions.logic.test.ts b/packages/client-runtime/src/pullRequestReactions.test.tssimilarity index 99%rename from apps/web/src/components/pullRequest/pullRequestReactions.logic.test.tsrename to packages/client-runtime/src/pullRequestReactions.test.tsindex 113c1029e7d..a88d0bbf7ac 100644--- a/apps/web/src/components/pullRequest/pullRequestReactions.logic.test.ts+++ b/packages/client-runtime/src/pullRequestReactions.test.ts@@ -1,7 +1,7 @@import type { PullRequestReaction, PullRequestReactionContent } from "@t3tools/contracts";import { describe, expect, it } from "vite-plus/test";-import { applyPendingPullRequestReactions } from "./pullRequestReactions.logic";+import { applyPendingPullRequestReactions } from "./pullRequestReactions.ts";function reaction(overrides: Partial<PullRequestReaction> = {}): PullRequestReaction {return {diff --git a/apps/web/src/components/pullRequest/pullRequestReactions.logic.ts b/packages/client-runtime/src/pullRequestReactions.tssimilarity index 91%rename from apps/web/src/components/pullRequest/pullRequestReactions.logic.tsrename to packages/client-runtime/src/pullRequestReactions.tsindex 13754209145..0c64af3835d 100644--- a/apps/web/src/components/pullRequest/pullRequestReactions.logic.ts+++ b/packages/client-runtime/src/pullRequestReactions.ts@@ -72,6 +72,15 @@ export function pullRequestReactionTooltip(reaction: PullRequestReaction): strinreturn `${joinNames(parts)} reacted with ${pullRequestReactionName(reaction.content)} emoji`;}+/** Changes whenever the host reports different reactions, so pending overlays can reset. */+export function pullRequestReactionsSignature(+ reactions: ReadonlyArray<PullRequestReaction>,+): string {+ return reactions+ .map((reaction) => `${reaction.content}:${reaction.count}:${reaction.viewerHasReacted ? 1 : 0}`)+ .join(" ");+}+export function applyPendingPullRequestReactions(reactions: ReadonlyArray<PullRequestReaction>,pending: ReadonlyMap<PullRequestReactionContent, boolean>,