Skip to content
Closed
Show file tree
Hide file tree
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
21 changes: 0 additions & 21 deletions apps/web/src/components/ChatView.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4344,24 +4344,6 @@ export default function ChatView(props: ChatViewProps) {
readonly threadKey: string;
readonly reference: ThreadLinkedPullRequest | null;
} | null>(null);
const openProjectPullRequest = useCallback(
(number: number) => {
if (
!supportsPullRequests ||
!activeThreadRef ||
!activeProject ||
activeProjectRepository === null
) {
return;
}
useRightPanelStore.getState().openPullRequest(activeThreadRef, {
projectId: activeProject.id,
repository: activeProjectRepository,
number,
});
},
[activeProject, activeProjectRepository, activeThreadRef, supportsPullRequests],
);
const proactivePanelObservationRef = useRef<ReturnType<
typeof observeProactivePanelUserChoice
> | null>(null);
Expand Down Expand Up @@ -8673,9 +8655,6 @@ export default function ChatView(props: ChatViewProps) {
) : null}
{!rightPanelControlsAtRoot && !rightPanelControlsInPanel ? panelLayoutControls : null}
<ChatHeader
{...(!supportsPullRequests || activeProjectRepository === null
? {}
: { onOpenPullRequest: openProjectPullRequest })}
activeThreadEnvironmentId={activeThread.environmentId}
activeThreadId={activeThread.id}
{...(routeKind === "draft" && draftId ? { draftId } : {})}
Expand Down
61 changes: 20 additions & 41 deletions apps/web/src/components/GitActionsControl.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -111,11 +111,6 @@ interface GitActionsControlProps {
gitCwd: string | null;
activeThreadRef: ScopedThreadRef | null;
draftId?: DraftId;
/**
* Opens the thread's own change request beside it. Absent when the thread has no project to
* place it against, in which case it still opens in the browser.
*/
onOpenPullRequest?: ((number: number) => void) | undefined;
}

interface PendingDefaultBranchAction {
Expand Down Expand Up @@ -947,7 +942,6 @@ export default function GitActionsControl({
gitCwd,
activeThreadRef,
draftId,
onOpenPullRequest,
}: GitActionsControlProps) {
const updateThreadMetadata = useAtomCommand(
threadEnvironment.updateMetadata,
Expand All @@ -964,7 +958,6 @@ export default function GitActionsControl({
[activeThreadRef],
);
const openPrLink = useOpenPrLink(activeThreadRef ?? undefined);
const openLink = useOpenLink(activeThreadRef);
const activeDraftThread = useComposerDraftStore((store) =>
draftId
? store.getDraftSession(draftId)
Expand Down Expand Up @@ -1193,35 +1186,21 @@ export default function GitActionsControl({
};
}, [activeEnvironmentId, gitCwd, refreshVcsStatus]);

const openExistingPr = useCallback(async () => {
const openPr = gitStatusForActions?.pr?.state === "open" ? gitStatusForActions.pr : null;
// Beside the thread where it was made, the way the browser opens beside it. Checked before
// the shell, which opening in the app does not need.
if (openPr && onOpenPullRequest) {
onOpenPullRequest(openPr.number);
return;
}
const prUrl = openPr?.url ?? null;
if (!prUrl) {
toastManager.add({
type: "error",
title: "No open pull request found.",
data: threadToastData,
});
return;
}
void openLink(prUrl).catch((err: unknown) => {
console.error(err);
toastManager.add(
stackedThreadToast({
const openExistingPr = useCallback(
(event: MouseEvent<HTMLElement>) => {
const prUrl = gitStatusForActions?.pr?.state === "open" ? gitStatusForActions.pr.url : null;
if (!prUrl) {
toastManager.add({
type: "error",
title: "Unable to open pull request link",
description: err instanceof Error ? err.message : "An error occurred.",
...(threadToastData !== undefined ? { data: threadToastData } : {}),
}),
);
});
}, [gitStatusForActions, onOpenPullRequest, openLink, threadToastData]);
title: "No open pull request found.",
data: threadToastData,
});
return;
}
openPrLink(event, prUrl);
},
[gitStatusForActions, openPrLink, threadToastData],
);

runGitActionWithToast = useEffectEvent(
async ({
Expand Down Expand Up @@ -1504,9 +1483,9 @@ export default function GitActionsControl({
});
};

const runQuickAction = () => {
const runQuickAction = (event: MouseEvent<HTMLElement>) => {
if (quickAction.kind === "open_pr") {
void openExistingPr();
openExistingPr(event);
return;
}
if (quickAction.kind === "open_publish") {
Expand Down Expand Up @@ -1567,10 +1546,10 @@ export default function GitActionsControl({
}
};

const openDialogForMenuItem = (item: GitActionMenuItem) => {
const openDialogForMenuItem = (event: MouseEvent<HTMLElement>, item: GitActionMenuItem) => {
if (item.disabled) return;
if (item.kind === "open_pr") {
void openExistingPr();
openExistingPr(event);
return;
}
if (item.dialogAction === "push") {
Expand Down Expand Up @@ -1754,8 +1733,8 @@ export default function GitActionsControl({
<MenuItem
key={`${item.id}-${item.label}`}
disabled={item.disabled}
onClick={() => {
openDialogForMenuItem(item);
onClick={(event) => {
openDialogForMenuItem(event, item);
}}
>
<GitActionItemIcon icon={item.icon} SourceControlIcon={SourceControlIcon} />
Expand Down
3 changes: 0 additions & 3 deletions apps/web/src/components/chat/ChatHeader.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,6 @@ interface ChatHeaderProps {
availableEditors: ReadonlyArray<EditorId>;
rightPanelOpen: boolean;
gitCwd: string | null;
readonly onOpenPullRequest?: ((number: number) => void) | undefined;
onNewThreadInProject: () => void;
onOpenProjectSettings?: (() => void) | undefined;
onRunProjectScript: (script: ProjectScript) => void;
Expand Down Expand Up @@ -132,7 +131,6 @@ export const ChatHeader = memo(function ChatHeader({
availableEditors,
rightPanelOpen,
gitCwd,
onOpenPullRequest,
onNewThreadInProject,
onOpenProjectSettings,
onRunProjectScript,
Expand Down Expand Up @@ -433,7 +431,6 @@ export const ChatHeader = memo(function ChatHeader({
<GitActionsControl
gitCwd={gitCwd}
activeThreadRef={scopeThreadRef(activeThreadEnvironmentId, activeThreadId)}
onOpenPullRequest={onOpenPullRequest}
{...(draftId ? { draftId } : {})}
/>
)}
Expand Down
Loading