feat(pull-requests): link multiple pull requests to threads (#10839)

This commit is contained in:
Julius Marminge authored and GitHub committed 2026-09-09 15:50:58 -07:00
1 parent 383cc40f4d
commit afb84898be
172 files changed
+12063 -914

No files matched your search

@@ -31,6 +31,7 @@ function makeThread(
interactionMode: "default",
branch: null,
worktreePath: null,
pullRequests: [],
latestTurn: null,
createdAt: "2026-06-01T00:00:00.000Z",
updatedAt: "2026-06-01T00:00:00.000Z",
@@ -43,6 +43,7 @@ function makeThread(id: string, projectId: ProjectId): EnvironmentThreadShell {
interactionMode: "default",
branch: null,
worktreePath: null,
pullRequests: [],
latestTurn: null,
createdAt: "2026-06-01T00:00:00.000Z",
updatedAt: "2026-06-01T00:00:00.000Z",
@@ -36,6 +36,7 @@ function makeThread(
interactionMode: "default",
branch: null,
worktreePath: null,
pullRequests: [],
latestTurn: null,
createdAt: "2026-06-01T00:00:00.000Z",
updatedAt: "2026-06-01T00:00:00.000Z",
@@ -44,6 +44,7 @@ export function HardwareKeyboardCommandProvider({
? null
: resolveThreadReferenceCopyTarget({
threadId: activeThread?.id ?? activeThreadRef.threadId,
pullRequests: activeThread?.pullRequests,
linkedPullRequestUrl:
(activeThread?.linkedPullRequest ?? activeThread?.branchPullRequest)?.url ?? null,
}),
@@ -4,6 +4,10 @@ import {
getGitActionDisabledReason,
requiresDefaultBranchConfirmation,
} from "@t3tools/client-runtime/state/vcs";
import {
resolveThreadPullRequestChains,
threadPullRequestKeyOf,
} from "@t3tools/shared/threadPullRequests";
import { EnvironmentId, ThreadId } from "@t3tools/contracts";
import {
CommonActions,
@@ -49,8 +53,17 @@ export function GitOverviewSheet(props: GitOverviewSheetProps) {
const isInspector = presentation === "inspector";
const environmentId = EnvironmentId.make(props.route.params.environmentId);
const threadId = ThreadId.make(props.route.params.threadId);
const { selectedThread } = useThreadSelection();
const { selectedThread, selectedEnvironmentRuntime } = useThreadSelection();
const { selectedThreadCwd, selectedThreadWorktreePath } = useSelectedThreadWorktree();
const supportsLinkedPrSnapshots =
selectedEnvironmentRuntime?.serverConfig?.environment.capabilities.threadPullRequests === true;
const linkedPrChains = useMemo(
() =>
resolveThreadPullRequestChains(
supportsLinkedPrSnapshots ? (selectedThread?.pullRequests ?? []) : [],
),
[selectedThread?.pullRequests, supportsLinkedPrSnapshots],
);
const gitState = useSelectedThreadGitState();
const gitActions = useSelectedThreadGitActions();
const theme = useUniwindTheme();
@@ -285,6 +298,50 @@ export function GitOverviewSheet(props: GitOverviewSheetProps) {
/>
</View>
{linkedPrChains.length > 0 ? (
<View className="gap-2">
<Text className="px-1 text-xs font-t3-bold text-foreground-muted">
Linked pull requests
</Text>
{linkedPrChains.map((chain) => (
<View
key={threadPullRequestKeyOf(chain.layers[0]!)}
className="overflow-hidden rounded-2xl border border-border bg-card px-3 py-1"
>
{chain.layers.length > 1 ? (
<View className="flex-row items-center gap-2 px-1 pt-2 pb-1">
<SymbolView
name="square.3.layers.3d"
size={14}
tintColorClassName="accent-foreground-muted"
/>
<Text className="text-xs text-foreground-muted">
{chain.kind === "native" ? "Stack" : "Branch stack"} · {chain.layers.length} PRs
· bottom to top
</Text>
</View>
) : null}
{chain.layers.map((link, index) => (
<View key={threadPullRequestKeyOf(link)}>
{index > 0 ? <View className="ml-12 h-px bg-border" /> : null}
<SheetListRow
icon="arrow.triangle.pull"
title={`#${link.number} ${link.snapshot?.title ?? "Pull request"}`}
subtitle={`${link.repository} · ${link.snapshot === null ? "Status pending" : link.snapshot.isDraft && link.snapshot.state === "open" ? "Draft" : link.snapshot.state}`}
onPress={() => {
void tryOpenExternalUrl(link.url, "pull-request").then((opened) => {
if (!opened)
Alert.alert("Unable to open PR", "The pull request could not be opened.");
});
}}
/>
</View>
))}
</View>
))}
</View>
) : null}
{currentWorktreePath ? <MetaCard label="Worktree" value={currentWorktreePath} /> : null}
</ScrollView>
);
@@ -56,6 +56,7 @@ function pullRequestTintColor(
return dark ? "#34d399" : "#059669";
case "merged":
return dark ? "#a78bfa" : "#7c3aed";
case null:
case "closed":
return dark ? "#a1a1aa" : "#71717a";
}
@@ -618,15 +619,30 @@ export const ThreadListRow = memo(function ThreadListRow(props: {
</>
) : null}
{pr !== null ? (
<View className="flex-row items-center gap-0.5">
<PullRequestIcon
size={compact ? 13 : 11}
color={
visuallySelected
? String(effectiveSelectedForeground)
: pullRequestTintColor(pr, colorScheme)
}
/>
<View
className="flex-row items-center gap-0.5"
accessibilityLabel={pr.accessibilityLabel}
>
{pr.kind === "stack" ? (
<SymbolView
name="square.3.layers.3d"
size={compact ? 13 : 11}
tintColor={
visuallySelected
? String(effectiveSelectedForeground)
: pullRequestTintColor(pr, colorScheme)
}
/>
) : (
<PullRequestIcon
size={compact ? 13 : 11}
color={
visuallySelected
? String(effectiveSelectedForeground)
: pullRequestTintColor(pr, colorScheme)
}
/>
)}
<Text
className={`${compact ? "text-sm" : "text-xs"} font-t3-medium ${
visuallySelected
@@ -870,20 +870,35 @@ export const ThreadListV2Row = memo(function ThreadListV2Row(props: {
<View className="flex-1" />
)}
{pr ? (
<Text
accessibilityLabel={pr.accessibilityLabel}
className={cn(
"text-xs",
selected
? materialYouStyleLayoutActive
? "text-thread-selected-foreground"
: "text-user-bubble-foreground"
: pr.textClassName,
)}
style={{ fontFamily: MONO_FONT }}
>
#{pr.label}
</Text>
<View className="flex-row items-center gap-1" accessibilityLabel={pr.accessibilityLabel}>
{pr.kind === "stack" ? (
<SymbolView
name="square.3.layers.3d"
size={12}
tintColorClassName={
selected
? materialYouStyleLayoutActive
? "accent-thread-selected-foreground"
: "accent-user-bubble-foreground"
: "accent-foreground-muted"
}
/>
) : null}
<Text
accessibilityLabel={pr.accessibilityLabel}
className={cn(
"text-xs",
selected
? materialYouStyleLayoutActive
? "text-thread-selected-foreground"
: "text-user-bubble-foreground"
: pr.textClassName,
)}
style={{ fontFamily: MONO_FONT }}
>
{pr.kind === "stack" ? pr.label : `#${pr.label}`}
</Text>
</View>
) : null}
{props.providerInstance ? (
<ProviderInstanceIcon
@@ -47,6 +47,7 @@ function makeThread(
interactionMode: "default",
branch: null,
worktreePath: null,
pullRequests: [],
latestTurn: null,
createdAt: "2026-06-01T00:00:00.000Z",
updatedAt: "2026-06-01T00:00:00.000Z",