Skip to content

πŸ™Œ OpenHands: AI-Driven Development

feat: add close control to Getting started checklist (#18185)

Devin3b2c7d7b7071
diff --git a/__tests__/components/features/sidebar/sidebar-onboarding-checklist.test.tsx b/__tests__/components/features/sidebar/sidebar-onboarding-checklist.test.tsx
index 94db61b10d..0faff73196 100644
--- a/__tests__/components/features/sidebar/sidebar-onboarding-checklist.test.tsx
+++ b/__tests__/components/features/sidebar/sidebar-onboarding-checklist.test.tsx
@@ -20,6 +20,7 @@ import SuperAdminSetupGuide from "#/components/features/setup-guide/super-admin-
import { ActiveBackendProvider } from "#/contexts/active-backend-context";
import { server } from "#/mocks/node";
import { ONBOARDING_COMPLETED_STORAGE_KEY } from "#/components/features/onboarding/use-onboarding-completion";
+import { GettingStartedChecklistSwitch } from "#/components/features/settings/app-settings/getting-started-checklist-switch";
import { SidebarOnboardingChecklist } from "#/components/features/sidebar/sidebar-onboarding-checklist";
import {
OPENHANDS_SLACK_COMMUNITY_URL,
@@ -28,6 +29,7 @@ import {
SIDEBAR_ONBOARDING_CHECKLIST_SLACK_JOINED_STORAGE_KEY,
} from "#/components/features/sidebar/sidebar-onboarding-checklist.constants";
import {
+ readSidebarOnboardingChecklistDismissed,
readSidebarOnboardingChecklistMinimized,
readSidebarOnboardingChecklistSlackJoined,
} from "#/components/features/sidebar/sidebar-onboarding-checklist-storage";
@@ -69,7 +71,7 @@ vi.mock("#/hooks/query/use-llm-profiles", () => ({
useLlmProfiles: () => mockUseLlmProfiles(),
}));
-function renderChecklist() {
+function renderChecklist({ withSettingsSwitch = false } = {}) {
const queryClient = new QueryClient({
defaultOptions: { queries: { retry: false }, mutations: { retry: false } },
});
@@ -86,6 +88,7 @@ function renderChecklist() {
<QueryClientProvider client={queryClient}>
<NavigationProvider value={navigation}>
<SidebarOnboardingChecklist collapsed={false} />
+ {withSettingsSwitch ? <GettingStartedChecklistSwitch /> : null}
</NavigationProvider>
</QueryClientProvider>,
),
@@ -97,7 +100,9 @@ describe("SidebarOnboardingChecklist", () => {
beforeEach(() => {
window.localStorage.clear();
window.localStorage.setItem(ONBOARDING_COMPLETED_STORAGE_KEY, "1");
- window.localStorage.removeItem(SIDEBAR_ONBOARDING_CHECKLIST_MINIMIZED_STORAGE_KEY);
+ window.localStorage.removeItem(
+ SIDEBAR_ONBOARDING_CHECKLIST_MINIMIZED_STORAGE_KEY,
+ );
window.localStorage.removeItem(
SIDEBAR_ONBOARDING_CHECKLIST_CUSTOMIZE_EXPLORED_STORAGE_KEY,
);
@@ -284,9 +289,52 @@ describe("SidebarOnboardingChecklist", () => {
expect(readSidebarOnboardingChecklistMinimized()).toBe(false);
});
+ it.each([
+ ["expanded", false],
+ ["minimized", true],
+ ] as const)(
+ "dismisses from the %s state and updates the Application switch",
+ async (_label, minimized) => {
+ if (minimized) {
+ window.localStorage.setItem(
+ SIDEBAR_ONBOARDING_CHECKLIST_MINIMIZED_STORAGE_KEY,
+ "true",
+ );
+ }
+ const user = userEvent.setup();
+ renderChecklist({ withSettingsSwitch: true });
+
+ const switchControl = screen.getByTestId(
+ "show-getting-started-checklist-switch",
+ );
+ await user.click(
+ screen.getByRole("button", {
+ name: I18nKey.SIDEBAR$ONBOARDING_CHECKLIST_DISMISS,
+ }),
+ );
+
+ expect(readSidebarOnboardingChecklistDismissed()).toBe(true);
+ expect(readSidebarOnboardingChecklistMinimized()).toBe(minimized);
+ expect(
+ screen.queryByTestId("sidebar-onboarding-checklist"),
+ ).not.toBeInTheDocument();
+ expect(switchControl).not.toBeChecked();
+
+ await user.click(switchControl);
+
+ expect(readSidebarOnboardingChecklistDismissed()).toBe(false);
+ expect(
+ screen.getByTestId("sidebar-onboarding-checklist"),
+ ).toHaveAttribute("data-minimized", String(minimized));
+ },
+ );
+
it("hides when collapsed", () => {
const queryClient = new QueryClient({
- defaultOptions: { queries: { retry: false }, mutations: { retry: false } },
+ defaultOptions: {
+ queries: { retry: false },
+ mutations: { retry: false },
+ },
});
const navigation: NavigationContextValue = {
currentPath: "/",
diff --git a/src/components/features/sidebar/sidebar-onboarding-checklist.tsx b/src/components/features/sidebar/sidebar-onboarding-checklist.tsx
index 7ec5d84f1d..cc75b5040c 100644
--- a/src/components/features/sidebar/sidebar-onboarding-checklist.tsx
+++ b/src/components/features/sidebar/sidebar-onboarding-checklist.tsx
@@ -1,10 +1,11 @@
import { Tooltip } from "@heroui/react";
-import { Check, ChevronDown } from "lucide-react";
+import { Check, ChevronDown, X } from "lucide-react";
import { useTranslation } from "react-i18next";
import { NavigationLink } from "#/components/shared/navigation-link";
import { useTracking } from "#/hooks/use-tracking";
import { I18nKey } from "#/i18n/declaration";
import { cn } from "#/utils/utils";
+import { hoverRevealActionClassName } from "#/utils/hover-reveal-classes";
import {
getSidebarOnboardingChecklistHref,
isExternalSidebarOnboardingChecklistItem,
@@ -147,6 +148,7 @@ export function SidebarOnboardingChecklist({
completedCount,
isVisible,
isMinimized,
+ dismiss,
toggleMinimized,
markJoinSlackComplete,
} = useSidebarOnboardingChecklist();
@@ -160,7 +162,7 @@ export function SidebarOnboardingChecklist({
data-testid="sidebar-onboarding-checklist"
data-minimized={isMinimized ? "true" : "false"}
className={cn(
- "w-full shrink-0 overflow-hidden rounded-xl border border-border",
+ "group w-full shrink-0 overflow-hidden rounded-xl border border-border",
"bg-surface-raised shadow-sm",
)}
>
@@ -213,6 +215,18 @@ export function SidebarOnboardingChecklist({
)}
/>
</span>
+ <button
+ type="button"
+ aria-label={t(I18nKey.SIDEBAR$ONBOARDING_CHECKLIST_DISMISS)}
+ onClick={dismiss}
+ className={cn(
+ "relative z-10 inline-flex size-7 shrink-0 items-center justify-center rounded-md text-muted",
+ "transition-opacity motion-reduce:transition-none hover:text-content",
+ hoverRevealActionClassName(),
+ )}
+ >
+ <X className="size-4" />
+ </button>
</div>
</div>