π OpenHands: AI-Driven Development
fix: place Commits toggle beside Diff in the Files panel (#1812)
Hiep Le67588e198eb1
diff --git a/__tests__/routes/files-tab.test.tsx b/__tests__/routes/files-tab.test.tsxindex 0319b0ba3a..c3a7dfc380 100644--- a/__tests__/routes/files-tab.test.tsx+++ b/__tests__/routes/files-tab.test.tsx@@ -1,5 +1,5 @@/* eslint-disable react/jsx-props-no-spreading */-import { render, screen, waitFor } from "@testing-library/react";+import { render, screen, waitFor, within } from "@testing-library/react";import userEvent from "@testing-library/user-event";import { QueryClient, QueryClientProvider } from "@tanstack/react-query";import { describe, it, expect, vi, beforeEach } from "vitest";@@ -653,6 +653,28 @@ describe("FilesTab", () => {).not.toBeInTheDocument();});+ it("renders the Commits option between Diff and Files", () => {+ // Arrange β beforeEach default: commits supported.+ useHasAttachedSourceMock.mockReturnValue({+ hasAttachedSource: true,+ isLoading: false,+ });++ // Act+ renderTab();++ // Assert β Commits sits beside Diff, ahead of Files: Diff β Commits β Files.+ const toggle = screen.getByTestId("files-tab-diff-toggle");+ const order = within(toggle)+ .getAllByRole("radio")+ .map((option) => option.getAttribute("data-testid"));+ expect(order).toEqual([+ "files-tab-diff-toggle-option-on",+ "files-tab-diff-toggle-option-commits",+ "files-tab-diff-toggle-option-off",+ ]);+ });+it("switches the panel to the commits view when the Commits option is selected", async () => {// Arrangeconst user = userEvent.setup();diff --git a/src/routes/files-tab.tsx b/src/routes/files-tab.tsxindex 9a4812d701..3dcb428fe8 100644--- a/src/routes/files-tab.tsx+++ b/src/routes/files-tab.tsx@@ -156,7 +156,6 @@ function FilesTab() {value={activeView}options={[{ value: "on", label: t(I18nKey.FILES$DIFF_VIEW) },- { value: "off", label: t(I18nKey.COMMON$FILES) },...(showCommitsOption? [{@@ -165,6 +164,7 @@ function FilesTab() {},]: []),+ { value: "off", label: t(I18nKey.COMMON$FILES) },]}onChange={(value) => {if (value === "commits") {