Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix issue #5179: [frontend]: Push to Github button should only push branch, but not creating a PR #5181

Merged
merged 15 commits into from
Nov 25, 2024
Merged
Show file tree
Hide file tree
Changes from 2 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
25 changes: 25 additions & 0 deletions frontend/__tests__/components/chat/chat-interface.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -281,6 +281,31 @@ describe.skip("ChatInterface", () => {
expect(within(error).getByText("Something went wrong")).toBeInTheDocument();
});

it("should render both GitHub buttons when ghToken is available", () => {
vi.mock("@remix-run/react", async (importActual) => ({
...(await importActual<typeof import("@remix-run/react")>()),
useRouteLoaderData: vi.fn(() => ({ ghToken: "test-token" })),
}));

const messages: Message[] = [
{
sender: "assistant",
content: "Hello",
imageUrls: [],
timestamp: new Date().toISOString(),
},
];
renderChatInterface(messages);

const pushButton = screen.getByRole("button", { name: "Push to GitHub" });
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's name this Push to Branch

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

const prButton = screen.getByRole("button", { name: "Push & Create PR" });
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think once the Push & Create PR button has been clicked once, we should only show one button after that. The agent (and user) will get v confused if you push and create PR, and then click "push to branch", since the PR is already opened.

Once you click "Push & Create PR" we should just have one button that says "Push changes to PR"

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done the most recent commit


expect(pushButton).toBeInTheDocument();
expect(prButton).toBeInTheDocument();
expect(pushButton).toHaveTextContent("Push to GitHub");
expect(prButton).toHaveTextContent("Push & Create PR");
});

it("should render feedback actions if there are more than 3 messages", () => {
const messages: Message[] = [
{
Expand Down
31 changes: 21 additions & 10 deletions frontend/src/components/chat-interface.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@
);
});
} catch (e) {
console.warn("Runtime ID not available in this environment");

Check warning on line 69 in frontend/src/components/chat-interface.tsx

View workflow job for this annotation

GitHub Actions / Lint frontend

Unexpected console statement
}
}
}, [status]);
Expand Down Expand Up @@ -176,16 +176,27 @@
curAgentState === AgentState.FINISHED) && (
<div className="flex flex-col gap-2 mb-2">
{rootLoaderData?.ghToken ? (
<SuggestionItem
suggestion={{
label: "Push to GitHub",
value:
"Please push the changes to GitHub and open a pull request.",
}}
onClick={(value) => {
handleSendMessage(value, []);
}}
/>
<div className="flex flex-col gap-2">
<SuggestionItem
suggestion={{
label: "Push to GitHub",
value: "Please push the changes to GitHub.",
}}
onClick={(value) => {
handleSendMessage(value, []);
}}
/>
<SuggestionItem
suggestion={{
label: "Push & Create PR",
value:
"Please push the changes to GitHub and open a pull request.",
}}
onClick={(value) => {
handleSendMessage(value, []);
}}
/>
</div>
) : (
<SuggestionItem
suggestion={{
Expand Down
Loading