Skip to content

Commit 8fbc22c

Browse files
authored
feat(mobile): link, unlink and watch a thread's pull requests from its sheet (#20394)
1 parent 2e16cf2 commit 8fbc22c

58 files changed

Lines changed: 1315 additions & 390 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

‎apps/mobile/src/Stack.tsx‎

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,7 @@ import { GitBranchesSheet } from "./features/threads/git/GitBranchesSheet";
6767
import { GitCommitSheet } from "./features/threads/git/GitCommitSheet";
6868
import { GitConfirmSheet } from "./features/threads/git/GitConfirmSheet";
6969
import { GitOverviewSheet } from "./features/threads/git/GitOverviewSheet";
70+
import { ThreadPullRequestsSheet } from "./features/threads/ThreadPullRequestsSheet";
7071
import { ThreadAgentsSheet } from "./features/threads/ThreadAgentsSheet";
7172
import { ThreadQueueSheet } from "./features/threads/ThreadQueueControl";
7273
import { ThreadRouteScreen } from "./features/threads/ThreadRouteScreen";
@@ -550,6 +551,7 @@ const WORKSPACE_OVERLAY_ROUTES = new Set([
550551
"SettingsLegal",
551552
"SettingsSheet",
552553
"ThreadAgents",
554+
"ThreadPullRequests",
553555
"ThreadQueue",
554556
"ThreadReviewComment",
555557
"ThreadDevicePreview",
@@ -871,6 +873,15 @@ const RootStackConfig = createWorkspaceStackNavigator({
871873
sheetGrabberVisible: true,
872874
},
873875
}),
876+
ThreadPullRequests: createNativeStackScreen({
877+
screen: ThreadPullRequestsSheet,
878+
linking: `${THREAD_LINKING_PREFIX}/pull-requests`,
879+
options: {
880+
...FORM_SHEET_PRESENTATION_OPTIONS,
881+
sheetAllowedDetents: [0.55, 0.92],
882+
sheetGrabberVisible: true,
883+
},
884+
}),
874885
GitCommit: createNativeStackScreen({
875886
screen: GitCommitSheet,
876887
linking: `${THREAD_LINKING_PREFIX}/git/commit`,

‎apps/mobile/src/components/ui/Dialog.android.tsx‎

Lines changed: 35 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -117,6 +117,7 @@ export function Host() {
117117
inputInitialValue={
118118
presented.kind === "text-input" ? presented.request.initialValue : undefined
119119
}
120+
inputPlaceholder={presented.kind === "text-input" ? presented.request.placeholder : undefined}
120121
onInputChange={setInputValue}
121122
onCancel={handleCancel}
122123
onConfirm={handleConfirm}
@@ -200,29 +201,39 @@ function DialogPresentation(props: DialogPresentationProps) {
200201
</AlertDialog.Title>
201202
{props.inputInitialValue !== undefined ? (
202203
<AlertDialog.Text>
203-
<OutlinedTextField
204-
autoFocus
205-
singleLine
206-
value={inputState}
207-
selection={inputSelection}
208-
onValueChange={props.onInputChange}
209-
textStyle={inputTypography}
210-
keyboardOptions={{ imeAction: "done" }}
211-
keyboardActions={{
212-
onDone: confirm,
213-
}}
214-
colors={{
215-
focusedTextColor: colors["--color-foreground"],
216-
unfocusedTextColor: colors["--color-foreground"],
217-
focusedIndicatorColor: colors["--color-focus"],
218-
unfocusedIndicatorColor: colors["--color-border"],
219-
cursorColor: colors["--color-focus"],
220-
}}
221-
>
222-
<OutlinedTextField.Label>
223-
<Text style={bodyTypography}>{props.request.title}</Text>
224-
</OutlinedTextField.Label>
225-
</OutlinedTextField>
204+
<Column verticalArrangement={{ spacedBy: 16 }}>
205+
{props.request.message ? (
206+
<Text style={bodyTypography}>{props.request.message}</Text>
207+
) : null}
208+
<OutlinedTextField
209+
autoFocus
210+
singleLine
211+
value={inputState}
212+
selection={inputSelection}
213+
onValueChange={props.onInputChange}
214+
textStyle={inputTypography}
215+
keyboardOptions={{ imeAction: "done" }}
216+
keyboardActions={{
217+
onDone: confirm,
218+
}}
219+
colors={{
220+
focusedTextColor: colors["--color-foreground"],
221+
unfocusedTextColor: colors["--color-foreground"],
222+
focusedIndicatorColor: colors["--color-focus"],
223+
unfocusedIndicatorColor: colors["--color-border"],
224+
cursorColor: colors["--color-focus"],
225+
}}
226+
>
227+
<OutlinedTextField.Label>
228+
<Text style={bodyTypography}>{props.request.title}</Text>
229+
</OutlinedTextField.Label>
230+
{props.inputPlaceholder ? (
231+
<OutlinedTextField.Placeholder>
232+
<Text style={bodyTypography}>{props.inputPlaceholder}</Text>
233+
</OutlinedTextField.Placeholder>
234+
) : null}
235+
</OutlinedTextField>
236+
</Column>
226237
</AlertDialog.Text>
227238
) : props.request.message ? (
228239
<AlertDialog.Text>
@@ -253,6 +264,7 @@ interface DialogPresentationProps {
253264
"title" | "message" | "cancelText" | "confirmText" | "destructive"
254265
>;
255266
readonly inputInitialValue?: string;
267+
readonly inputPlaceholder?: string;
256268
readonly onInputChange?: (value: string) => void;
257269
readonly onCancel: () => void;
258270
readonly onConfirm: (inputValue?: string) => void;

‎apps/mobile/src/components/ui/Dialog.tsx‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ export function confirm(request: ConfirmDialogRequest): void {
2222
export function prompt(request: TextInputDialogRequest): void {
2323
Alert.prompt(
2424
request.title,
25-
undefined,
25+
request.message,
2626
[
2727
{ text: request.cancelText ?? "Cancel", style: "cancel", onPress: request.onCancel },
2828
{ text: request.confirmText, onPress: (value) => request.onConfirm(value ?? "") },

‎apps/mobile/src/components/ui/Dialog.types.ts‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@ export type ConfirmDialogRequest = {
1010

1111
export type TextInputDialogRequest = {
1212
readonly title: string;
13+
readonly message?: string;
14+
readonly placeholder?: string;
1315
readonly initialValue: string;
1416
readonly cancelText?: string;
1517
readonly confirmText: string;

‎apps/mobile/src/components/ui/Sheet.tsx‎

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,12 @@
11
import { useId, useState } from "react";
22
import { Platform, View } from "react-native";
3-
import { FormSheet, Screen, ScreenStack, ScreenStackHeaderConfig } from "react-native-screens";
4-
import { useResolveClassNames, withUniwind } from "uniwind";
3+
import { FormSheet, ScreenStack } from "react-native-screens";
4+
import { useResolveClassNames } from "uniwind";
55

66
import { nativeHeaderScrollEdgeEffects } from "../../native/StackHeader";
7+
import { NativeHeader, NativeScreen } from "../../native/ThemedScreenStack";
78

89
const HEADER_SCROLL_EDGE_EFFECTS = nativeHeaderScrollEdgeEffects(Platform.OS, Platform.Version);
9-
const NativeScreen = withUniwind(Screen);
10-
const NativeHeader = withUniwind(ScreenStackHeaderConfig, {
11-
color: { fromClassName: "tintColorClassName", styleProperty: "accentColor" },
12-
titleColor: { fromClassName: "titleColorClassName", styleProperty: "accentColor" },
13-
});
1410

1511
export type { SheetProps } from "./Sheet.types";
1612
import type { SheetProps } from "./Sheet.types";

‎apps/mobile/src/features/home/HomeScreen.tsx‎

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,8 @@ import {
6363
ThreadListV2WorkingShelfHeader,
6464
} from "../threads/thread-list-v2-items";
6565
import { useThreadRowProviderInstanceResolver } from "../threads/thread-provider-instance";
66+
import { useOpenThreadPullRequests } from "../threads/use-open-thread-pull-requests";
67+
import type { ThreadPrPresentation } from "../../state/thread-pr-presentation";
6668
import {
6769
buildThreadListV2Items,
6870
getThreadListV2OrderedSection,
@@ -330,6 +332,14 @@ export function HomeScreen(props: HomeScreenProps) {
330332
const handleScrollBeginDrag = useCallback(() => {
331333
openSwipeableRef.current?.close();
332334
}, []);
335+
const openThreadPullRequests = useOpenThreadPullRequests();
336+
const handleOpenThreadPullRequests = useCallback(
337+
(thread: EnvironmentThreadShell, pr: ThreadPrPresentation) => {
338+
openSwipeableRef.current?.close();
339+
openThreadPullRequests(thread, pr);
340+
},
341+
[openThreadPullRequests],
342+
);
333343
const onFabScroll = useFabScroll();
334344
const listRef = useRef<LegendListRef>(null);
335345
const searchMode = workspace?.state.tabs.threads.searchMode;
@@ -769,6 +779,7 @@ export function HomeScreen(props: HomeScreenProps) {
769779
)}
770780
searchQuery={props.searchQuery}
771781
onSelectThread={props.onSelectThread}
782+
onOpenThreadPullRequests={handleOpenThreadPullRequests}
772783
onDeleteThread={handleDeleteThread}
773784
onArchiveThread={props.onArchiveThread}
774785
onRenameThread={handleRenameThread}
@@ -802,6 +813,7 @@ export function HomeScreen(props: HomeScreenProps) {
802813
},
803814
[
804815
handleDeleteThread,
816+
handleOpenThreadPullRequests,
805817
activeReorderEnvironmentIds,
806818
handleMoveThread,
807819
handlePinThread,

‎apps/mobile/src/features/home/ThreadListToolbar.tsx‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ import { WorkspaceConnectionTitle } from "./WorkspaceConnectionTitle";
2323
import { useWorkspaceState } from "../../state/workspace";
2424
import { useAndroidControlSizing } from "../../components/ui/useAndroidControlSizing";
2525
import { useToolbarLayout } from "../../components/ui/useToolbarLayout";
26+
import { PullRequestGlyph } from "../pull-requests/pullRequestGlyphs";
2627

2728
/** One toolbar height for the compact list and expanded sidebar, including search. */
2829
export function ThreadListToolbar(props: {
@@ -129,7 +130,7 @@ export function ThreadListToolbar(props: {
129130
{props.sidebar && workspace ? (
130131
<AndroidHeaderIconButton
131132
accessibilityLabel="Show pull requests"
132-
icon="arrow.triangle.pull"
133+
icon={PullRequestGlyph.pullRequest}
133134
onPress={showPullRequests}
134135
/>
135136
) : null}

‎apps/mobile/src/features/keyboard/CommandPalette.tsx‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ import {
3838
} from "./commandPaletteItems";
3939
import { parseActiveThreadPath, type HardwareKeyboardCommand } from "./hardwareKeyboardCommands";
4040
import { threadJumpIndex } from "./threadKeyboardShortcuts";
41+
import { PullRequestGlyph } from "../pull-requests/pullRequestGlyphs";
4142

4243
const PALETTE_COMMANDS: ReadonlyArray<HardwareKeyboardCommand> = [
4344
"commandPalette",
@@ -59,7 +60,7 @@ const ACTION_ICONS: Record<string, AppSymbolName> = {
5960
archive: "archivebox",
6061
files: "doc.text",
6162
terminal: "terminal",
62-
review: "arrow.triangle.pull",
63+
review: PullRequestGlyph.pullRequest,
6364
copyThreadReference: "link",
6465
};
6566

‎apps/mobile/src/features/layout/AdaptiveWorkspaceLayout.tsx‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,7 @@ import { AndroidWorkspaceSidebar } from "../workspace/AndroidWorkspaceSidebar";
6464
import { useAndroidWorkspaceSelection } from "../workspace/useAndroidWorkspaceSelection";
6565
import { HomeListOptionsProvider } from "../home/home-list-options";
6666
import { ThreadNavigationSidebar } from "../threads/ThreadNavigationSidebar";
67+
import { useOpenThreadPullRequests } from "../threads/use-open-thread-pull-requests";
6768
import { RenderErrorBoundary, RenderFailureView } from "../../components/RenderErrorBoundary";
6869
import { WORKSPACE_PANE_TIMING } from "./workspace-pane-animation";
6970
import { WorkspaceInspectorPane } from "./workspace-inspector-pane";
@@ -460,6 +461,8 @@ function AdaptiveWorkspaceLayoutContent(
460461
});
461462
}, [navigation]);
462463

464+
const handleOpenThreadPullRequests = useOpenThreadPullRequests();
465+
463466
const handleNewThreadOnBranch = useCallback(
464467
(thread: EnvironmentThreadShell) => {
465468
navigation.navigate("NewTaskSheet", {
@@ -758,6 +761,7 @@ function AdaptiveWorkspaceLayoutContent(
758761
onNewThreadInProject={handleNewThreadInProject}
759762
onNewThreadOnBranch={handleNewThreadOnBranch}
760763
onSelectThread={handleSelectThread}
764+
onOpenThreadPullRequests={handleOpenThreadPullRequests}
761765
onSearchQueryChange={setPrimarySidebarSearchQuery}
762766
searchQuery={primarySidebarSearchQuery}
763767
/>

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

Lines changed: 29 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -11,14 +11,23 @@ import {
1111
THREAD_LIST_V2_SIDEBAR_ROW_STYLE,
1212
THREAD_LIST_V2_SIDEBAR_ROW_CONTAINER_STYLE,
1313
} from "../threads/thread-list-v2-row-appearance";
14-
import { PullRequestAvatar, PullRequestDiffStats } from "./PullRequestPresentation";
14+
import {
15+
PullRequestAvatar,
16+
PullRequestConflictBadge,
17+
PullRequestDiffStats,
18+
} from "./PullRequestPresentation";
1519
import {
1620
pullRequestLabelColor,
1721
pullRequestListReviewStatus,
1822
pullRequestListRowsAreEqual,
1923
type EnvironmentPullRequestListEntry,
2024
} from "./pullRequestList";
21-
import { pullRequestStatus } from "./pullRequestStatus";
25+
import {
26+
pullRequestChecksStatus,
27+
pullRequestConflict,
28+
pullRequestStatus,
29+
} from "./pullRequestStatus";
30+
import { PullRequestGlyph } from "./pullRequestGlyphs";
2231

2332
export const PullRequestListRow = memo(
2433
function PullRequestListRow(props: {
@@ -47,13 +56,9 @@ export const PullRequestListRow = memo(
4756
? "text-drawer-foreground-muted"
4857
: "text-foreground-tertiary";
4958
const status = pullRequestStatus(item);
59+
const conflict = pullRequestConflict(item);
5060
const review = pullRequestListReviewStatus(item);
51-
const checkTint =
52-
item.checksState === "passing"
53-
? "accent-adaptive-emerald-600-400"
54-
: item.checksState === "failing"
55-
? "accent-danger-foreground"
56-
: "accent-warning-foreground";
61+
const checks = item.checksState ? pullRequestChecksStatus(item.checksState) : null;
5762
return (
5863
<View style={props.sidebar ? THREAD_LIST_V2_SIDEBAR_ROW_CONTAINER_STYLE : undefined}>
5964
<Menu
@@ -65,7 +70,7 @@ export const PullRequestListRow = memo(
6570
<Pressable
6671
accessibilityRole="button"
6772
accessibilityState={{ selected: props.selected, busy: props.busy }}
68-
accessibilityLabel={`Pull request ${item.number}, ${item.title}, ${status.label}, by ${item.author?.login ?? "unknown author"}${review ? `, ${review.accessibleLabel}` : ""}${item.checksState ? `, checks ${item.checksState}` : ""}${item.stack ? `, stack ${item.stack.position} of ${item.stack.size}` : ""}${item.labels.length ? `, ${item.labels.map((label) => label.name).join(", ")}` : ""}, ${item.additions} additions, ${item.deletions} deletions`}
73+
accessibilityLabel={`Pull request ${item.number}, ${item.title}, ${status.label}${conflict ? `, ${conflict.label.toLowerCase()}` : ""}, by ${item.author?.login ?? "unknown author"}${review ? `, ${review.accessibleLabel}` : ""}${item.checksState ? `, checks ${item.checksState}` : ""}${item.stack ? `, stack ${item.stack.position} of ${item.stack.size}` : ""}${item.labels.length ? `, ${item.labels.map((label) => label.name).join(", ")}` : ""}, ${item.additions} additions, ${item.deletions} deletions`}
6974
accessibilityHint="Double tap to open. Touch and hold for quick actions."
7075
onPress={() => props.onSelect(item)}
7176
disabled={props.busy}
@@ -79,8 +84,19 @@ export const PullRequestListRow = memo(
7984
props.busy && "opacity-50",
8085
)}
8186
>
82-
<View className={props.sidebar ? "pt-0.5" : "pt-2.5"}>
87+
<View className={cn("self-start", props.sidebar ? "pt-0.5" : "pt-2.5")}>
8388
<SymbolView name={status.icon} size={20} tintColorClassName={status.tint} />
89+
{conflict ? (
90+
<PullRequestConflictBadge
91+
surfaceClassName={
92+
props.selected
93+
? "text-thread-selected"
94+
: props.sidebar
95+
? "text-drawer"
96+
: "text-screen"
97+
}
98+
/>
99+
) : null}
84100
</View>
85101
<View
86102
className={cn(
@@ -96,7 +112,7 @@ export const PullRequestListRow = memo(
96112
{item.stack ? (
97113
<View className="flex-row items-center gap-1">
98114
<SymbolView
99-
name="square.3.layers.3d"
115+
name={PullRequestGlyph.stack}
100116
size={12}
101117
tintColorClassName={
102118
props.selected
@@ -155,19 +171,9 @@ export const PullRequestListRow = memo(
155171
</Text>
156172
) : null}
157173
</View>
158-
{item.checksState ? (
174+
{checks ? (
159175
<View className="shrink-0" accessibilityLabel={`Checks ${item.checksState}`}>
160-
<SymbolView
161-
name={
162-
item.checksState === "passing"
163-
? "checkmark.circle"
164-
: item.checksState === "failing"
165-
? "xmark.circle.fill"
166-
: "clock"
167-
}
168-
size={13}
169-
tintColorClassName={checkTint}
170-
/>
176+
<SymbolView name={checks.icon} size={13} tintColorClassName={checks.tint} />
171177
</View>
172178
) : null}
173179
{review ? (

0 commit comments

Comments
 (0)