| ... | @@ -262,6 +262,7 @@ import { environmentCatalog } from "../connection/catalog"; | ... | @@ -262,6 +262,7 @@ import { environmentCatalog } from "../connection/catalog"; |
| 262 | import { selectThreadTerminalUiState, useTerminalUiStateStore } from "../terminalUiStateStore"; | 262 | import { selectThreadTerminalUiState, useTerminalUiStateStore } from "../terminalUiStateStore"; |
| 263 | import { useKnownTerminalSessions, useThreadRunningTerminalIds } from "../state/terminalSessions"; | 263 | import { useKnownTerminalSessions, useThreadRunningTerminalIds } from "../state/terminalSessions"; |
| 264 | import { projectEnvironment } from "../state/projects"; | 264 | import { projectEnvironment } from "../state/projects"; |
| | 265 | import { linkedPullRequestDetailAtom } from "../state/pullRequests"; |
| 265 | import { useEnvironmentQuery } from "../state/query"; | 266 | import { useEnvironmentQuery } from "../state/query"; |
| 266 | import { | 267 | import { |
| 267 | environmentServerConfigsAtom, | 268 | environmentServerConfigsAtom, |
| ... | @@ -317,6 +318,7 @@ import { | ... | @@ -317,6 +318,7 @@ import { |
| 317 | } from "./chat/ThreadErrorBanner"; | 318 | } from "./chat/ThreadErrorBanner"; |
| 318 | import { | 319 | import { |
| 319 | resolveDisplayedThreadPr, | 320 | resolveDisplayedThreadPr, |
| | 321 | threadPullRequestRefreshSource, |
| 320 | threadChangeRequestSnapshotsAtom, | 322 | threadChangeRequestSnapshotsAtom, |
| 321 | useLinkedThreadPullRequest, | 323 | useLinkedThreadPullRequest, |
| 322 | } from "./ThreadStatusIndicators"; | 324 | } from "./ThreadStatusIndicators"; |
| ... | @@ -1745,7 +1747,7 @@ function ChatViewContent(props: ChatViewProps) { | ... | @@ -1745,7 +1747,7 @@ function ChatViewContent(props: ChatViewProps) { |
| 1745 | // the tab is found again whether or not that surface was opened with an environment on it. | 1747 | // the tab is found again whether or not that surface was opened with an environment on it. |
| 1746 | const activePullRequestSurfaceId = | 1748 | const activePullRequestSurfaceId = |
| 1747 | activeRightPanelSurface?.kind === "pull-request" ? activeRightPanelSurface.id : undefined; | 1749 | activeRightPanelSurface?.kind === "pull-request" ? activeRightPanelSurface.id : undefined; |
| 1748 | const handlePullRequestTabStatusChange = useCallback( | 1750 | const updatePullRequestTabStatusFromPanel = useCallback( |
| 1749 | (status: PullRequestTabStatus) => { | 1751 | (status: PullRequestTabStatus) => { |
| 1750 | const id = activePullRequestSurfaceId; | 1752 | const id = activePullRequestSurfaceId; |
| 1751 | if (id === undefined) return; | 1753 | if (id === undefined) return; |
| ... | @@ -1753,6 +1755,8 @@ function ChatViewContent(props: ChatViewProps) { | ... | @@ -1753,6 +1755,8 @@ function ChatViewContent(props: ChatViewProps) { |
| 1753 | }, | 1755 | }, |
| 1754 | [activePullRequestSurfaceId], | 1756 | [activePullRequestSurfaceId], |
| 1755 | ); | 1757 | ); |
| | 1758 | const refreshVcsStatus = useAtomCommand(vcsEnvironment.refreshStatus, { reportFailure: false }); |
| | 1759 | const sidebarPrRefreshKeyRef = useRef<string | null>(null); |
| 1756 | const activeFileSurface = | 1760 | const activeFileSurface = |
| 1757 | activeRightPanelSurface?.kind === "file" ? activeRightPanelSurface : null; | 1761 | activeRightPanelSurface?.kind === "file" ? activeRightPanelSurface : null; |
| 1758 | const activePreviewState = useThreadPreviewState(activeThreadRef); | 1762 | const activePreviewState = useThreadPreviewState(activeThreadRef); |
| ... | @@ -4594,6 +4598,62 @@ function ChatViewContent(props: ChatViewProps) { | ... | @@ -4594,6 +4598,62 @@ function ChatViewContent(props: ChatViewProps) { |
| 4594 | linkedPullRequest: linkedThreadPullRequest, | 4598 | linkedPullRequest: linkedThreadPullRequest, |
| 4595 | linkedPullRequestStatus, | 4599 | linkedPullRequestStatus, |
| 4596 | }); | 4600 | }); |
| | 4601 | const handlePullRequestTabStatusChange = useCallback( |
| | 4602 | (status: PullRequestTabStatus) => { |
| | 4603 | updatePullRequestTabStatusFromPanel(status); |
| | 4604 | const source = threadPullRequestRefreshSource({ |
| | 4605 | panel: status, |
| | 4606 | thread: { |
| | 4607 | repository: threadRepository, |
| | 4608 | number: linkedThreadPullRequest?.number ?? activeThreadPr?.number ?? null, |
| | 4609 | state: activeThreadPr?.state ?? null, |
| | 4610 | linked: linkedThreadPullRequest !== null, |
| | 4611 | }, |
| | 4612 | }); |
| | 4613 | if (source === null) { |
| | 4614 | sidebarPrRefreshKeyRef.current = null; |
| | 4615 | return; |
| | 4616 | } |
| | 4617 | const refreshKey = `${activeThreadKey}:${source}:${status.repository}#${status.number}:${status.state}`; |
| | 4618 | if (sidebarPrRefreshKeyRef.current === refreshKey) return; |
| | 4619 | sidebarPrRefreshKeyRef.current = refreshKey; |
| | 4620 | |
| | 4621 | if (source === "linked-detail" && activeThreadRef && linkedThreadPullRequest) { |
| | 4622 | appAtomRegistry.refresh( |
| | 4623 | linkedPullRequestDetailAtom({ |
| | 4624 | environmentId: activeThreadRef.environmentId, |
| | 4625 | input: { |
| | 4626 | projectId: linkedThreadPullRequest.projectId, |
| | 4627 | repository: linkedThreadPullRequest.repository, |
| | 4628 | number: linkedThreadPullRequest.number, |
| | 4629 | }, |
| | 4630 | }), |
| | 4631 | ); |
| | 4632 | return; |
| | 4633 | } |
| | 4634 | if (source === "vcs" && activeThreadRef && gitCwd !== null) { |
| | 4635 | void refreshVcsStatus({ |
| | 4636 | environmentId: activeThreadRef.environmentId, |
| | 4637 | input: { cwd: gitCwd }, |
| | 4638 | }).then(() => { |
| | 4639 | if (sidebarPrRefreshKeyRef.current === refreshKey) { |
| | 4640 | sidebarPrRefreshKeyRef.current = null; |
| | 4641 | } |
| | 4642 | }); |
| | 4643 | } |
| | 4644 | }, |
| | 4645 | [ |
| | 4646 | activeThreadKey, |
| | 4647 | activeThreadPr?.number, |
| | 4648 | activeThreadPr?.state, |
| | 4649 | activeThreadRef, |
| | 4650 | gitCwd, |
| | 4651 | linkedThreadPullRequest, |
| | 4652 | refreshVcsStatus, |
| | 4653 | threadRepository, |
| | 4654 | updatePullRequestTabStatusFromPanel, |
| | 4655 | ], |
| | 4656 | ); |
| 4597 | const activeThreadReferenceCopyTarget = useMemo( | 4657 | const activeThreadReferenceCopyTarget = useMemo( |
| 4598 | () => | 4658 | () => |
| 4599 | activeThreadId === null || !isServerThread | 4659 | activeThreadId === null || !isServerThread |