Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 6 additions & 11 deletions apps/web/src/components/PullRequestThreadDialog.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -44,13 +44,6 @@ interface PullRequestThreadDialogProps {
onPrepared: (input: { branch: string; worktreePath: string | null }) => Promise<void> | void;
}

// The prepare action keys on this scope, and the compiler would rebuild it every
// render because hooks run after it.
function useSourceControlScope(environmentId: EnvironmentId, cwd: string | null) {
"use memo";
return { environmentId, cwd };
}

function pullRequestStatusTone(state: string | undefined): string {
switch (state) {
case "merged":
Expand Down Expand Up @@ -108,17 +101,19 @@ export function PullRequestThreadDialog({

const parsedReference = parsePullRequestReference(reference);
const parsedDebouncedReference = parsePullRequestReference(debouncedReference);
const sourceControlScope = useSourceControlScope(environmentId, cwd);
const pullRequestResolution = usePullRequestResolution({
...sourceControlScope,
environmentId,
cwd,
reference: open ? parsedDebouncedReference : null,
});
const cachedPullRequest =
readCachedPullRequestResolution({
...sourceControlScope,
environmentId,
cwd,
reference: parsedReference,
})?.pullRequest ?? null;
const preparePullRequestThreadAction = usePreparePullRequestThreadAction(sourceControlScope);
// The prepare action keys on this scope object, so it only ever reaches the hook.
const preparePullRequestThreadAction = usePreparePullRequestThreadAction({ environmentId, cwd });
const canOperateThread = useEnvironmentScope(environmentId, AuthOrchestrationOperateScope);

const liveResolvedPullRequest =
Expand Down
Loading