TypeScript
refactor(web): the pull request thread dialog keeps its caching without "use memo" hooks (#20742)
Julius Marminge0ad3fd64360e
diff --git a/apps/web/src/components/PullRequestThreadDialog.tsx b/apps/web/src/components/PullRequestThreadDialog.tsxindex 8b0bcd13ca6..0d56bcd9283 100644--- a/apps/web/src/components/PullRequestThreadDialog.tsx+++ b/apps/web/src/components/PullRequestThreadDialog.tsx@@ -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":@@ -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 =