GeezerVison is showing github.com — fix(server): link thread PRs without an open client (#10101) · EvilBorsch/t3code@223ff44
File treeExpand file treeCollapse file tree Open diff view settings Some content is hiddenLarge Commits have some content hidden by default. Use the searchbox below for content that may be hidden. Dismiss bannerExpand file treeCollapse file tree Open diff view settings Collapse file Copy file name to clipboardExpand all lines: apps/mobile/src/features/home/HomeScreen.tsx +1-21Lines changed: 1 addition & 21 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -416,14 +416,6 @@ export function HomeScreen(props: HomeScreenProps) { | 416 | 416 | [threadListV2Enabled, projectGroups, effectiveGroupDisplayStates, hasSearchQuery], | 417 | 417 | ); | 418 | 418 |
| 419 | | - const projectCwdByKey = useMemo(() => { | 420 | | - const map = new Map<string, string>(); | 421 | | - for (const project of props.projects) { | 422 | | - map.set(scopedProjectKey(project.environmentId, project.id), project.workspaceRoot); | 423 | | - } | 424 | | - return map; | 425 | | - }, [props.projects]); | 426 | | - | 427 | 419 | const projectByKey = useMemo(() => { | 428 | 420 | const map = new Map<string, EnvironmentProject>(); | 429 | 421 | for (const project of props.projects) { | @@ -850,9 +842,6 @@ export function HomeScreen(props: HomeScreenProps) { | 850 | 842 | onPinThread={handlePinThread} | 851 | 843 | onUnpinThread={handleUnpinThread} | 852 | 844 | onMovePinnedThread={handleMovePinnedThread} | 853 | | - projectCwd={ | 854 | | - projectCwdByKey.get(scopedProjectKey(thread.environmentId, thread.projectId)) ?? null | 855 | | - } | 856 | 845 | onSwipeableClose={handleSwipeableClose} | 857 | 846 | onSwipeableWillOpen={handleSwipeableWillOpen} | 858 | 847 | /> | @@ -875,7 +864,6 @@ export function HomeScreen(props: HomeScreenProps) { | 875 | 864 | machineByEnvironmentId, | 876 | 865 | pinReorderEnvironmentIds, | 877 | 866 | projectByKey, | 878 | | - projectCwdByKey, | 879 | 867 | props.onArchiveThread, | 880 | 868 | props.onDeletePendingTask, | 881 | 869 | props.onSelectPendingTask, | @@ -903,7 +891,6 @@ export function HomeScreen(props: HomeScreenProps) { | 903 | 891 | const v2ExtraData = useMemo( | 904 | 892 | () => ({ | 905 | 893 | projectByKey, | 906 | | - projectCwdByKey, | 907 | 894 | projectTitleByProjectKey: v2ProjectTitleByProjectKey, | 908 | 895 | serverConfigs, | 909 | 896 | savedConnectionsById: props.savedConnectionsById, | @@ -913,7 +900,6 @@ export function HomeScreen(props: HomeScreenProps) { | 913 | 900 | }), | 914 | 901 | [ | 915 | 902 | projectByKey, | 916 | | - projectCwdByKey, | 917 | 903 | props.searchQuery, | 918 | 904 | props.savedConnectionsById, | 919 | 905 | serverConfigs, | @@ -925,12 +911,11 @@ export function HomeScreen(props: HomeScreenProps) { | 925 | 911 |
| 926 | 912 | const extraData = useMemo( | 927 | 913 | () => ({ | 928 | | - projectCwdByKey, | 929 | 914 | savedConnectionsById: props.savedConnectionsById, | 930 | 915 | searchQuery: props.searchQuery, | 931 | 916 | threadSearchMatchByKey, | 932 | 917 | }), | 933 | | - [projectCwdByKey, props.savedConnectionsById, props.searchQuery, threadSearchMatchByKey], | | 918 | + [props.savedConnectionsById, props.searchQuery, threadSearchMatchByKey], | 934 | 919 | ); | 935 | 920 |
| 936 | 921 | const renderItem = useCallback( | @@ -982,10 +967,6 @@ export function HomeScreen(props: HomeScreenProps) { | 982 | 967 | props.savedConnectionsById[thread.environmentId]?.environmentLabel ?? null | 983 | 968 | } | 984 | 969 | environmentMachine={machineByEnvironmentId.get(thread.environmentId)} | 985 | | - projectCwd={ | 986 | | - projectCwdByKey.get(scopedProjectKey(thread.environmentId, thread.projectId)) ?? | 987 | | - null | 988 | | - } | 989 | 970 | isLast={item.isLast} | 990 | 971 | searchMatch={threadSearchMatchByKey.get( | 991 | 972 | threadSearchMatchKey({ | @@ -1021,7 +1002,6 @@ export function HomeScreen(props: HomeScreenProps) { | 1021 | 1002 | handleSwipeableWillOpen, | 1022 | 1003 | handleRegenerateThreadTitle, | 1023 | 1004 | machineByEnvironmentId, | 1024 | | - projectCwdByKey, | 1025 | 1005 | props.onArchiveThread, | 1026 | 1006 | props.onDeletePendingTask, | 1027 | 1007 | props.onDeleteThread, | |
Collapse file Copy file name to clipboardExpand all lines: apps/mobile/src/features/keyboard/HardwareKeyboardCommandProvider.tsx +4-33Lines changed: 4 additions & 33 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -12,10 +12,8 @@ import { | 12 | 12 |
| 13 | 13 | import { tryCopyTextWithHaptic } from "../../lib/copyTextWithHaptic"; | 14 | 14 | import { T3KeyboardCommands } from "../../native/T3KeyboardCommands"; | 15 | | -import { useProject, useThreadShell } from "../../state/entities"; | 16 | | -import { useEnvironmentQuery } from "../../state/query"; | | 15 | +import { useThreadShell } from "../../state/entities"; | 17 | 16 | import type { GitActionProgress } from "../../state/use-vcs-action-state"; | 18 | | -import { vcsEnvironment } from "../../state/vcs"; | 19 | 17 | import { GitActionProgressOverlay } from "../threads/GitActionProgressOverlay"; | 20 | 18 | import { | 21 | 19 | dispatchHardwareKeyboardCommand, | @@ -40,43 +38,16 @@ export function HardwareKeyboardCommandProvider({ | 40 | 38 | const navigation = useNavigation(); | 41 | 39 | const activeThreadRef = useMemo(() => parseActiveThreadPath(pathname), [pathname]); | 42 | 40 | const activeThread = useThreadShell(activeThreadRef); | 43 | | - const activeProjectRef = useMemo( | 44 | | - () => | 45 | | - activeThread === null | 46 | | - ? null | 47 | | - : { | 48 | | - environmentId: activeThread.environmentId, | 49 | | - projectId: activeThread.projectId, | 50 | | - }, | 51 | | - [activeThread], | 52 | | - ); | 53 | | - const activeProject = useProject(activeProjectRef); | 54 | | - const activeThreadCwd = activeThread?.worktreePath ?? activeProject?.workspaceRoot ?? null; | 55 | | - const gitStatus = useEnvironmentQuery( | 56 | | - activeThread !== null && | 57 | | - activeThread.linkedPullRequest == null && | 58 | | - activeThread.branch !== null && | 59 | | - activeThreadCwd !== null | 60 | | - ? vcsEnvironment.status({ | 61 | | - environmentId: activeThread.environmentId, | 62 | | - input: { cwd: activeThreadCwd }, | 63 | | - }) | 64 | | - : null, | 65 | | - ).data; | 66 | | - const detectedPullRequestUrl = | 67 | | - activeThread?.branch != null && gitStatus?.refName === activeThread.branch | 68 | | - ? (gitStatus.pr?.url ?? null) | 69 | | - : null; | 70 | 41 | const copyTarget = useMemo( | 71 | 42 | () => | 72 | 43 | activeThreadRef === null | 73 | 44 | ? null | 74 | 45 | : resolveThreadReferenceCopyTarget({ | 75 | 46 | threadId: activeThread?.id ?? activeThreadRef.threadId, | 76 | | - linkedPullRequestUrl: activeThread?.linkedPullRequest?.url ?? null, | 77 | | - detectedPullRequestUrl, | | 47 | + linkedPullRequestUrl: | | 48 | + (activeThread?.linkedPullRequest ?? activeThread?.branchPullRequest)?.url ?? null, | 78 | 49 | }), | 79 | | - [activeThread, activeThreadRef, detectedPullRequestUrl], | | 50 | + [activeThread, activeThreadRef], | 80 | 51 | ); | 81 | 52 | const [copyFeedback, setCopyFeedback] = useState<GitActionProgress>(EMPTY_COPY_FEEDBACK); | 82 | 53 | const copyRequestIdRef = useRef(0); | |
Collapse file Copy file name to clipboardExpand all lines: apps/mobile/src/features/threads/ThreadNavigationSidebar.tsx -15Lines changed: 0 additions & 15 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -353,13 +353,6 @@ function ThreadNavigationSidebarPane( | 353 | 353 | }), | 354 | 354 | [threadListV2Enabled, groups, groupDisplayStates, hasSearchQuery], | 355 | 355 | ); | 356 | | - const projectCwdByKey = useMemo(() => { | 357 | | - const map = new Map<string, string>(); | 358 | | - for (const project of projects) { | 359 | | - map.set(scopedProjectKey(project.environmentId, project.id), project.workspaceRoot); | 360 | | - } | 361 | | - return map; | 362 | | - }, [projects]); | 363 | 356 | const projectByKey = useMemo(() => { | 364 | 357 | const map = new Map<string, EnvironmentProject>(); | 365 | 358 | for (const project of projects) { | @@ -742,7 +735,6 @@ function ThreadNavigationSidebarPane( | 742 | 735 | () => ({ | 743 | 736 | selectedThreadKey: props.selectedThreadKey ?? "", | 744 | 737 | projectByKey, | 745 | | - projectCwdByKey, | 746 | 738 | projectTitleByProjectKey, | 747 | 739 | savedConnectionsById, | 748 | 740 | serverConfigs, | @@ -752,7 +744,6 @@ function ThreadNavigationSidebarPane( | 752 | 744 | [ | 753 | 745 | props.selectedThreadKey, | 754 | 746 | projectByKey, | 755 | | - projectCwdByKey, | 756 | 747 | projectTitleByProjectKey, | 757 | 748 | savedConnectionsById, | 758 | 749 | serverConfigs, | @@ -914,7 +905,6 @@ function ThreadNavigationSidebarPane( | 914 | 905 | onPinThread={pinThread} | 915 | 906 | onUnpinThread={unpinThread} | 916 | 907 | onMovePinnedThread={movePinnedThread} | 917 | | - projectCwd={projectCwdByKey.get(scopeKey) ?? null} | 918 | 908 | onSwipeableClose={handleSwipeableClose} | 919 | 909 | onSwipeableWillOpen={handleSwipeableWillOpen} | 920 | 910 | simultaneousSwipeGesture={sidebarScrollGesture} | @@ -1000,10 +990,6 @@ function ThreadNavigationSidebarPane( | 1000 | 990 | savedConnectionsById[thread.environmentId]?.environmentLabel ?? null | 1001 | 991 | } | 1002 | 992 | environmentMachine={machineByEnvironmentId.get(thread.environmentId)} | 1003 | | - projectCwd={ | 1004 | | - projectCwdByKey.get(scopedProjectKey(thread.environmentId, thread.projectId)) ?? | 1005 | | - null | 1006 | | - } | 1007 | 993 | isLast={item.isLast} | 1008 | 994 | searchMatch={threadSearchMatchByKey.get( | 1009 | 995 | threadSearchMatchKey({ | @@ -1054,7 +1040,6 @@ function ThreadNavigationSidebarPane( | 1054 | 1040 | pinThread, | 1055 | 1041 | pinningEnvironmentIds, | 1056 | 1042 | projectByKey, | 1057 | | - projectCwdByKey, | 1058 | 1043 | projectTitleByProjectKey, | 1059 | 1044 | regenerateThreadTitle, | 1060 | 1045 | props.onNewThreadInProject, | |
Collapse file Copy file name to clipboardExpand all lines: apps/mobile/src/features/threads/thread-list-items.tsx +1-2Lines changed: 1 addition & 2 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -416,7 +416,6 @@ export const ThreadListRow = memo(function ThreadListRow(props: { | 416 | 416 | readonly thread: EnvironmentThreadShell; | 417 | 417 | readonly environmentLabel: string | null; | 418 | 418 | readonly environmentMachine?: EnvironmentMachineKind; | 419 | | - readonly projectCwd: string | null; | 420 | 419 | readonly searchMatch?: EnvironmentThreadSearchMatch; | 421 | 420 | readonly searchQuery?: string; | 422 | 421 | readonly isLast: boolean; | @@ -453,7 +452,7 @@ export const ThreadListRow = memo(function ThreadListRow(props: { | 453 | 452 | const { thread, onSelectThread, onArchiveThread, onDeleteThread, onRegenerateThreadTitle } = | 454 | 453 | props; | 455 | 454 | const status = resolveThreadStatus(thread); | 456 | | - const pr = useThreadPr(thread, props.projectCwd); | | 455 | + const pr = useThreadPr(thread); | 457 | 456 | const timestamp = relativeTime( | 458 | 457 | thread.latestUserMessageAt ?? thread.updatedAt ?? thread.createdAt, | 459 | 458 | ); | |
Collapse file Copy file name to clipboardExpand all lines: apps/mobile/src/features/threads/thread-list-v2-items.tsx +1-2Lines changed: 1 addition & 2 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -377,7 +377,6 @@ export const ThreadListV2Row = memo(function ThreadListV2Row(props: { | 377 | 377 | readonly canMovePinnedDown?: boolean; | 378 | 378 | readonly onSwipeableWillOpen: (methods: SwipeableMethods) => void; | 379 | 379 | readonly onSwipeableClose: (methods: SwipeableMethods) => void; | 380 | | - readonly projectCwd?: string | null; | 381 | 380 | readonly searchMatch?: EnvironmentThreadSearchMatch; | 382 | 381 | readonly searchQuery?: string; | 383 | 382 | readonly simultaneousSwipeGesture?: ComponentProps< | @@ -403,7 +402,7 @@ export const ThreadListV2Row = memo(function ThreadListV2Row(props: { | 403 | 402 | const snoozedRow = props.snoozed === true; | 404 | 403 | const pinnedRow = props.pinned === true; | 405 | 404 |
| 406 | | - const pr = useThreadPr(thread, props.projectCwd ?? props.project?.workspaceRoot ?? null); | | 405 | + const pr = useThreadPr(thread); | 407 | 406 |
| 408 | 407 | const theme = useUniwindTheme(); | 409 | 408 | const screenColor = theme["--color-screen"]; | |
Collapse file Copy file name to clipboardExpand all lines: apps/mobile/src/state/use-thread-pr.ts +23-46Lines changed: 23 additions & 46 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -12,9 +12,8 @@ import { connectionAtomRuntime } from "../connection/runtime"; | 12 | 12 | import { appAtomRegistry } from "./atom-registry"; | 13 | 13 | import { useEnvironmentQuery } from "./query"; | 14 | 14 | import { presentThreadPr, type ThreadPrPresentation } from "./thread-pr-presentation"; | 15 | | -import { vcsEnvironment } from "./vcs"; | 16 | 15 |
| 17 | | -const linkedPullRequestDetailAtom = createLinkedPullRequestSummaryAtomFamily(connectionAtomRuntime); | | 16 | +const pullRequestSummaryAtom = createLinkedPullRequestSummaryAtomFamily(connectionAtomRuntime); | 18 | 17 | const MAX_THREAD_PR_SNAPSHOTS = 500; | 19 | 18 |
| 20 | 19 | interface ThreadPrSnapshot { | @@ -23,7 +22,7 @@ interface ThreadPrSnapshot { | 23 | 22 | } | 24 | 23 |
| 25 | 24 | // One bounded cache survives row virtualization without retaining one live | 26 | | -// atom for every thread, branch, directory, or linked pull request ever seen. | | 25 | +// atom for every thread or pull request ever seen. | 27 | 26 | const threadPrSnapshotsAtom = Atom.make<ReadonlyMap<string, ThreadPrSnapshot>>(new Map()).pipe( | 28 | 27 | Atom.keepAlive, | 29 | 28 | Atom.withLabel("mobile:thread-pr-snapshots"), | @@ -36,20 +35,13 @@ export { | 36 | 35 | } from "./thread-pr-presentation"; | 37 | 36 |
| 38 | 37 | /** | 39 | | - * Live PR status for a thread's branch. Subscriptions are deduplicated per | 40 | | - * (environmentId, cwd) by the atom family, so many rows on the same worktree | 41 | | - * or project root share one stream — and virtualization means only visible | 42 | | - * rows subscribe at all. | | 38 | + * Live status for a thread's server-provided PR. Visible rows share a summary | | 39 | + * request for the same PR in the same environment. | 43 | 40 | */ | 44 | | -export function useThreadPr( | 45 | | - thread: EnvironmentThreadShell, | 46 | | - projectCwd: string | null, | 47 | | -): ThreadPrPresentation | null { | 48 | | - const cwd = thread.worktreePath ?? projectCwd; | | 41 | +export function useThreadPr(thread: EnvironmentThreadShell): ThreadPrPresentation | null { | | 42 | + const pullRequestRef = thread.linkedPullRequest ?? thread.branchPullRequest ?? null; | 49 | 43 | const threadKey = scopedThreadKey(scopeThreadRef(thread.environmentId, thread.id)); | 50 | | - const snapshotIdentity = JSON.stringify( | 51 | | - thread.linkedPullRequest ?? { branch: thread.branch, cwd }, | 52 | | - ); | | 44 | + const snapshotIdentity = JSON.stringify(pullRequestRef); | 53 | 45 | // Select this row's entry so writes for other rows do not re-render it. | 54 | 46 | const snapshotEntry = useAtomValue( | 55 | 47 | threadPrSnapshotsAtom, | @@ -59,45 +51,30 @@ export function useThreadPr( | 59 | 51 | ), | 60 | 52 | ); | 61 | 53 | const snapshot = snapshotEntry?.identity === snapshotIdentity ? snapshotEntry.presentation : null; | 62 | | - const gitStatus = useEnvironmentQuery( | 63 | | - thread.linkedPullRequest == null && thread.branch !== null && cwd !== null | 64 | | - ? vcsEnvironment.status({ | 65 | | - environmentId: thread.environmentId, | 66 | | - input: { cwd }, | 67 | | - }) | 68 | | - : null, | 69 | | - ); | 70 | | - const linkedPullRequest = useEnvironmentQuery( | 71 | | - thread.linkedPullRequest == null | | 54 | + const pullRequestSummary = useEnvironmentQuery( | | 55 | + pullRequestRef === null | 72 | 56 | ? null | 73 | | - : linkedPullRequestDetailAtom({ | | 57 | + : pullRequestSummaryAtom({ | 74 | 58 | environmentId: thread.environmentId, | 75 | 59 | input: { | 76 | | - projectId: thread.linkedPullRequest.projectId, | 77 | | - repository: thread.linkedPullRequest.repository, | 78 | | - number: thread.linkedPullRequest.number, | | 60 | + projectId: pullRequestRef.projectId, | | 61 | + repository: pullRequestRef.repository, | | 62 | + number: pullRequestRef.number, | 79 | 63 | }, | 80 | 64 | }), | 81 | 65 | ); | 82 | 66 |
| 83 | 67 | const live = useMemo<ThreadPrPresentation | null | undefined>(() => { | 84 | | - if (thread.linkedPullRequest != null) { | 85 | | - const detail = linkedPullRequest.data; | 86 | | - return detail === null | 87 | | - ? undefined | 88 | | - : presentThreadPr(pullRequestDetailToVcsStatus(detail), { | 89 | | - kind: detail.provider, | 90 | | - name: detail.provider, | 91 | | - baseUrl: "", | 92 | | - }); | 93 | | - } | 94 | | - | 95 | | - const status = gitStatus.data; | 96 | | - if (thread.branch === null) return null; | 97 | | - if (status === null) return undefined; | 98 | | - if (status.refName !== thread.branch || !status.pr) return null; | 99 | | - return presentThreadPr(status.pr, status.sourceControlProvider); | 100 | | - }, [gitStatus.data, linkedPullRequest.data, thread.branch, thread.linkedPullRequest]); | | 68 | + if (pullRequestRef === null) return null; | | 69 | + const summary = pullRequestSummary.data; | | 70 | + return summary === null | | 71 | + ? undefined | | 72 | + : presentThreadPr(pullRequestDetailToVcsStatus(summary), { | | 73 | + kind: summary.provider, | | 74 | + name: summary.provider, | | 75 | + baseUrl: "", | | 76 | + }); | | 77 | + }, [pullRequestRef, pullRequestSummary.data]); | 101 | 78 |
| 102 | 79 | useEffect(() => { | 103 | 80 | if (live === undefined) return; | |
Collapse file Copy file name to clipboardExpand all lines: apps/mobile/src/state/use-thread-selection.ts +1Lines changed: 1 addition & 0 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -55,6 +55,7 @@ function threadDetailToShell( | 55 | 55 | branch: thread.branch, | 56 | 56 | worktreePath: thread.worktreePath, | 57 | 57 | linkedPullRequest: thread.linkedPullRequest ?? null, | | 58 | + branchPullRequest: thread.branchPullRequest ?? null, | 58 | 59 | latestTurn: thread.latestTurn, | 59 | 60 | createdAt: thread.createdAt, | 60 | 61 | updatedAt: thread.updatedAt, | |
Collapse file Copy file name to clipboardExpand all lines: apps/server/integration/OrchestrationEngineHarness.integration.ts +7Lines changed: 7 additions & 0 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -67,6 +67,7 @@ import { | 67 | 67 | } from "../src/orchestration/Services/OrchestrationEngine.ts"; | 68 | 68 | import { ThreadDeletionReactor } from "../src/orchestration/Services/ThreadDeletionReactor.ts"; | 69 | 69 | import * as ThreadSettlementReactor from "../src/orchestration/ThreadSettlementReactor.ts"; | | 70 | +import * as ThreadPullRequestReactor from "../src/orchestration/ThreadPullRequestReactor.ts"; | 70 | 71 | import { OrchestrationReactor } from "../src/orchestration/Services/OrchestrationReactor.ts"; | 71 | 72 | import { ProjectionSnapshotQuery } from "../src/orchestration/Services/ProjectionSnapshotQuery.ts"; | 72 | 73 | import { | @@ -394,6 +395,12 @@ export const makeOrchestrationIntegrationHarness = ( | 394 | 395 | drainThrough: () => Effect.void, | 395 | 396 | }), | 396 | 397 | ), | | 398 | + Layer.provideMerge( | | 399 | + Layer.succeed(ThreadPullRequestReactor.ThreadPullRequestReactor, { | | 400 | + start: () => Effect.void, | | 401 | + drain: Effect.void, | | 402 | + }), | | 403 | + ), | 397 | 404 | Layer.provideMerge( | 398 | 405 | Layer.succeed(ThreadSettlementReactor.ThreadSettlementReactor, { | 399 | 406 | start: () => Effect.void, | |
|