Skip to content

πŸ™Œ OpenHands: AI-Driven Development

fix: remove inner edge gaps in empty and diff states (#213)

Hiep Le75d67e2ff3a1
diff --git a/__tests__/routes/changes-tab.test.tsx b/__tests__/routes/changes-tab.test.tsx
index 1cf2513d18..013507a473 100644
--- a/__tests__/routes/changes-tab.test.tsx
+++ b/__tests__/routes/changes-tab.test.tsx
@@ -67,4 +67,45 @@ describe("Changes Tab", () => {
screen.queryByText("DIFF_VIEWER$NO_CHANGES"),
).not.toBeInTheDocument();
});
+
+ it("should render the Protip alongside the empty state when there are no changes", () => {
+ vi.mocked(useUnifiedGetGitChanges).mockReturnValue({
+ data: [],
+ isLoading: false,
+ isFetching: false,
+ isSuccess: true,
+ isError: false,
+ error: null,
+ refetch: vi.fn(),
+ });
+ vi.mocked(useAgentState).mockReturnValue({
+ curAgentState: AgentState.RUNNING,
+ });
+
+ render(<GitChanges />, { wrapper });
+
+ expect(screen.getByText("TIPS$PROTIP:")).toBeInTheDocument();
+ });
+
+ it("should hide the Protip when the git changes request errors", () => {
+ vi.mocked(useUnifiedGetGitChanges).mockReturnValue({
+ data: [],
+ isLoading: false,
+ isFetching: false,
+ isSuccess: false,
+ isError: true,
+ error: { message: "fatal: not a git repository" } as unknown as Error,
+ refetch: vi.fn(),
+ });
+ vi.mocked(useAgentState).mockReturnValue({
+ curAgentState: AgentState.RUNNING,
+ });
+
+ render(<GitChanges />, { wrapper });
+
+ expect(screen.queryByText("TIPS$PROTIP:")).not.toBeInTheDocument();
+ expect(
+ screen.getByText("DIFF_VIEWER$NOT_A_GIT_REPO"),
+ ).toBeInTheDocument();
+ });
});
diff --git a/src/routes/changes-tab.tsx b/src/routes/changes-tab.tsx
index 658f9d1695..0e97c7220d 100644
--- a/src/routes/changes-tab.tsx
+++ b/src/routes/changes-tab.tsx
@@ -67,10 +67,10 @@ function GitChanges() {
]);
return (
- <main className="h-full overflow-y-scroll md:pr-1.5 flex flex-col items-stretch custom-scrollbar-always">
+ <main className="h-full w-full flex flex-col items-stretch">
{!isSuccess || !gitChanges.length ? (
- <div className="relative flex h-full w-full items-center">
- <div className="absolute inset-x-0 top-1/2 -translate-y-1/2">
+ <div className="flex flex-col h-full w-full">
+ <div className="flex-1 flex items-center justify-center">
{statusMessage && (
<StatusMessage>
{statusMessage.map((msg) => (
@@ -82,25 +82,22 @@ function GitChanges() {
<EmptyChangesMessage />
)}
</div>
-
- <div className="absolute inset-x-0 bottom-0">
- {!isError && gitChanges?.length === 0 && (
- <div className="max-w-2xl mx-4 mb-4 text-m bg-tertiary p-4 text-left md:mx-auto">
- <RandomTip />
- </div>
- )}
- </div>
+ {!isError && isSuccess && gitChanges.length === 0 && (
+ <div className="w-full text-m bg-tertiary p-4 text-left">
+ <RandomTip />
+ </div>
+ )}
</div>
) : (
- gitChanges
- .slice(0, 100)
- .map((change) => (
+ <div className="h-full overflow-y-auto flex flex-col items-stretch custom-scrollbar-always">
+ {gitChanges.slice(0, 100).map((change) => (
<FileDiffViewer
key={change.path}
path={change.path}
type={change.status}
/>
- ))
+ ))}
+ </div>
)}
</main>
);