🙌 OpenHands: AI-Driven Development
feat(home): keep Automations pane visible when empty (#16372)
Graham Neubigc3d7077271fd
diff --git a/.pr/automations-empty-pane.png b/.pr/automations-empty-pane.pngnew file mode 100644index 0000000000..203d3fbb12Binary files /dev/null and b/.pr/automations-empty-pane.png differdiff --git a/__tests__/components/features/home/featured-automations-section.test.tsx b/__tests__/components/features/home/featured-automations-section.test.tsxindex c75b3149a3..31f0771ac1 100644--- a/__tests__/components/features/home/featured-automations-section.test.tsx+++ b/__tests__/components/features/home/featured-automations-section.test.tsx@@ -222,7 +222,7 @@ describe("home automations composer layout", () => {expect(AutomationService.getAutomations).not.toHaveBeenCalled();});- it("renders nothing when there are no enabled automations", async () => {+ it("keeps the pane visible with an add prompt when there are no enabled automations", async () => {vi.mocked(AutomationService.getAutomations).mockResolvedValue({automations: [makeAutomation({ enabled: false })],total: 1,@@ -233,9 +233,17 @@ describe("home automations composer layout", () => {await waitFor(() =>expect(AutomationService.getAutomations).toHaveBeenCalledTimes(1),);+ // The pane stays visible to nudge users toward adding automations.expect(- screen.queryByTestId("running-automations-list"),- ).not.toBeInTheDocument();+ await screen.findByTestId("running-automations-list"),+ ).toBeInTheDocument();+ expect(+ screen.getByTestId("running-automations-empty-hint"),+ ).toBeInTheDocument();+ expect(screen.getByTestId("home-automations-manage")).toHaveAttribute(+ "href",+ "/automations",+ );});it("lists enabled automations with live run status and conversation links", async () => {diff --git a/src/components/features/home/featured-automations/running-automations-list.tsx b/src/components/features/home/featured-automations/running-automations-list.tsxindex 8eb832a256..23652ba556 100644--- a/src/components/features/home/featured-automations/running-automations-list.tsx+++ b/src/components/features/home/featured-automations/running-automations-list.tsx@@ -212,6 +212,7 @@ export function RunningAutomationsList() {isBackendHealthy,isHealthLoading,isError,+ isAutomationsLoading,enabledAutomations,runStates,} = useHomeAutomations();@@ -245,10 +246,12 @@ export function RunningAutomationsList() {!isExpanded && items.length > HOME_AUTOMATIONS_PREVIEW_LIMIT;const canViewAll = isExpanded && items.length >= MAX_HOME_AUTOMATION_CHIPS;- if (isHealthLoading || !isBackendHealthy || isError || items.length === 0) {+ if (isHealthLoading || !isBackendHealthy || isError || isAutomationsLoading) {return null;}+ const isEmpty = items.length === 0;+return (<sectionaria-labelledby="running-automations-heading"@@ -278,23 +281,32 @@ export function RunningAutomationsList() {</StyledTooltip></div>- <ul- aria-label={t(I18nKey.FEATURED_AUTOMATIONS$RECENT_GROUP_LABEL)}- className="divide-y divide-[var(--oh-border-subtle)] overflow-hidden rounded-xl border border-[var(--oh-border-subtle)] bg-[var(--oh-surface)]"- >- {visibleItems.map((item) => {- const automation = automationById.get(item.id);- if (!automation) return null;- return (- <RunningAutomationRow- key={item.id}- item={item}- automation={automation}- runState={runStates.get(item.id) ?? UNKNOWN_RUN_STATE}- />- );- })}- </ul>+ {isEmpty ? (+ <p+ data-testid="running-automations-empty-hint"+ className="rounded-xl border border-[var(--oh-border-subtle)] bg-[var(--oh-surface)] px-4 py-3 text-xs text-[var(--oh-text-secondary)]"+ >+ {t(I18nKey.FEATURED_AUTOMATIONS$EMPTY_HINT)}+ </p>+ ) : (+ <ul+ aria-label={t(I18nKey.FEATURED_AUTOMATIONS$RECENT_GROUP_LABEL)}+ className="divide-y divide-[var(--oh-border-subtle)] overflow-hidden rounded-xl border border-[var(--oh-border-subtle)] bg-[var(--oh-surface)]"+ >+ {visibleItems.map((item) => {+ const automation = automationById.get(item.id);+ if (!automation) return null;+ return (+ <RunningAutomationRow+ key={item.id}+ item={item}+ automation={automation}+ runState={runStates.get(item.id) ?? UNKNOWN_RUN_STATE}+ />+ );+ })}+ </ul>+ )}{canViewMore ? (<div className="mt-2 flex justify-start">diff --git a/src/i18n/translation.json b/src/i18n/translation.jsonindex 249bc6290d..6c7eb8f938 100644--- a/src/i18n/translation.json+++ b/src/i18n/translation.json@@ -35767,6 +35767,23 @@"uk": "Переглянути всі","ca": "Mostra-ho tot"},+ "FEATURED_AUTOMATIONS$EMPTY_HINT": {+ "en": "No automations yet. Add one to automate repetitive work.",+ "ja": "オートメーションがありません。反復作業を自動化するには追加してください。",+ "zh-CN": "还没有自动化。添加一个以自动化重复性工作。",+ "zh-TW": "尚未有自動化。新增一個以自動化重複性工作。",+ "ko-KR": "자동화가 없습니다. 반복 작업을 자동화하려면 추가하세요.",+ "no": "Ingen automatiseringer ennå. Legg til en for å automatisere gjentakende arbeid.",+ "it": "Nessuna automazione ancora. Aggiungine una per automatizzare il lavoro ripetitivo.",+ "pt": "Nenhuma automação ainda. Adicione uma para automatizar trabalho repetitivo.",+ "es": "Aún no hay automatizaciones. Añade una para automatizar tareas repetitivas.",+ "ar": "لا أتمتة بعد. أضف واحدة لأتمتة العمل المتكرر.",+ "fr": "Aucune automatisation pour l'instant. Ajoutez-en une pour automatiser le travail répétitif.",+ "tr": "Henüz otomasyon yok. Tekrarlayan işleri otomatikleştirmek için bir tane ekleyin.",+ "de": "Noch keine Automatisierungen. Füge eine hinzu, um wiederkehrende Aufgaben zu automatisieren.",+ "uk": "Ще немає автоматизацій. Додайте одну, щоб автоматизувати повторювану роботу.",+ "ca": "Encara no hi ha automatitzacions. Afegeix-ne una per automatitzar tasques repetitives."+ },"FEATURED_AUTOMATIONS$RUN_ACTIVITY_LABEL": {"en": "{{count}} recent runs","ja": "最近の実行 {{count}} 件",