Skip to content

The agent that grows with you

fix(desktop): make auto-project Hide from sidebar reversible via an Undo toast (#73091)

PRATHAMESH753b2a6b6e1aed
diff --git a/apps/desktop/src/app/chat/sidebar/projects/project-menu.test.tsx b/apps/desktop/src/app/chat/sidebar/projects/project-menu.test.tsx
index cbca71ca74d..8a2bb99faee 100644
--- a/apps/desktop/src/app/chat/sidebar/projects/project-menu.test.tsx
+++ b/apps/desktop/src/app/chat/sidebar/projects/project-menu.test.tsx
@@ -1,10 +1,16 @@
import { cleanup, fireEvent, render, screen } from '@testing-library/react'
import { afterEach, beforeAll, describe, expect, it, vi } from 'vitest'
+import { dismissAutoProject, restoreAutoProject } from '@/store/layout'
+import { notify } from '@/store/notifications'
+
import { ProjectMenu } from './project-menu'
import type { SidebarProjectTree } from './workspace-groups'
-afterEach(cleanup)
+afterEach(() => {
+ cleanup()
+ vi.clearAllMocks()
+})
// jsdom doesn't implement ResizeObserver; Radix's PopoverContent/Arrow use it
// (via @radix-ui/react-use-size) to measure the arrow once the popover is
@@ -35,8 +41,10 @@ vi.mock('@/i18n', () => ({
menuRename: 'Rename',
menuSetActive: 'Set active',
noColor: 'No color',
+ hiddenFromSidebar: 'Hidden from sidebar',
removeFromSidebar: 'Remove from sidebar',
- reveal: 'Reveal in file manager'
+ reveal: 'Reveal in file manager',
+ undoHide: 'Undo'
}
}
}
@@ -53,7 +61,12 @@ vi.mock('@/store/layout', () => ({
return () => {}
}
},
- dismissAutoProject: vi.fn()
+ dismissAutoProject: vi.fn(),
+ restoreAutoProject: vi.fn()
+}))
+
+vi.mock('@/store/notifications', () => ({
+ notify: vi.fn()
}))
vi.mock('@/store/projects', () => ({
@@ -75,6 +88,17 @@ const project = {
path: '/repo'
} as unknown as SidebarProjectTree
+const autoProject = {
+ color: null,
+ icon: null,
+ id: '/auto/repo',
+ isAuto: true,
+ label: 'repo',
+ path: '/auto/repo'
+} as unknown as SidebarProjectTree
+
+const tipTrigger = (el: HTMLElement) => el.closest('[data-slot="tooltip-trigger"]')
+
const openTriggerMenu = (trigger: HTMLElement) => {
// Radix's dropdown trigger opens on pointerdown (a synthetic 'click' fireEvent
// alone won't do it), so fire the full mouse sequence a real click produces —
@@ -105,4 +129,27 @@ describe('ProjectMenu', () => {
// chain rather than getting silently dropped on an intermediate wrapper.
expect(await screen.findByRole('button', { name: 'No color' })).toBeTruthy()
}, 15000)
+
+ // #73091: "Hide from sidebar" on an auto project used to be one-way — the
+ // toast had no Undo and there was no restore control, so a mis-click was
+ // permanent. Hiding must now offer an Undo whose click restores the id.
+ it('hides an auto project with an Undo toast that restores it', async () => {
+ render(<ProjectMenu isActive={false} project={autoProject} />)
+
+ openTriggerMenu(screen.getByRole('button', { name: 'Actions' }))
+
+ fireEvent.click(await screen.findByRole('menuitem', { name: 'Remove from sidebar' }))
+
+ expect(dismissAutoProject).toHaveBeenCalledWith('/auto/repo')
+
+ expect(notify).toHaveBeenCalledTimes(1)
+ const input = vi.mocked(notify).mock.calls[0][0]
+ expect(input.action?.label).toBe('Undo')
+
+ // The Undo action must reach restoreAutoProject with the captured id even
+ // though the row is gone — it closes over the id, not live menu state.
+ expect(restoreAutoProject).not.toHaveBeenCalled()
+ input.action?.onClick()
+ expect(restoreAutoProject).toHaveBeenCalledWith('/auto/repo')
+ }, 15000)
})
diff --git a/apps/desktop/src/app/chat/sidebar/projects/project-menu.tsx b/apps/desktop/src/app/chat/sidebar/projects/project-menu.tsx
index 1046f4ae893..e9b4263da86 100644
--- a/apps/desktop/src/app/chat/sidebar/projects/project-menu.tsx
+++ b/apps/desktop/src/app/chat/sidebar/projects/project-menu.tsx
@@ -22,7 +22,8 @@ import { Popover, PopoverAnchor, PopoverContent } from '@/components/ui/popover'
import { useI18n } from '@/i18n'
import { isDesktopFsRemoteMode } from '@/lib/desktop-fs'
import { cn } from '@/lib/utils'
-import { $panesFlipped, dismissAutoProject } from '@/store/layout'
+import { $panesFlipped, dismissAutoProject, restoreAutoProject } from '@/store/layout'
+import { notify } from '@/store/notifications'
import {
copyPath,
deleteProject,
@@ -59,11 +60,24 @@ function useProjectActions({
const [confirmDeleteOpen, setConfirmDeleteOpen] = useState(false)
const removeAuto = () => {
- dismissAutoProject(project.id)
+ // Capture the id now: the row unmounts (and, when scoped, the scope exits)
+ // the moment we dismiss, so Undo can't read it back off live menu state.
+ const id = project.id
+
+ dismissAutoProject(id)
if (scoped) {
onExitScope?.()
}
+
+ // The hide is persisted and otherwise irreversible — there is no other
+ // restore control — so offer a short undo window (mirrors restoreWorktree).
+ notify({
+ action: { label: p.undoHide, onClick: () => restoreAutoProject(id) },
+ durationMs: 8_000,
+ kind: 'success',
+ message: p.hiddenFromSidebar
+ })
}
const confirmDelete = async () => {
diff --git a/apps/desktop/src/i18n/en.ts b/apps/desktop/src/i18n/en.ts
index fa31d261686..188e8a24e14 100644
--- a/apps/desktop/src/i18n/en.ts
+++ b/apps/desktop/src/i18n/en.ts
@@ -3359,6 +3359,8 @@ export const en: Translations = {
removeFromSidebar: 'Hide from sidebar',
createdInPreviousContext:
"Project created on the previous connection or profile. Switch back to find it; IDEA.md wasn't written.",
+ hiddenFromSidebar: 'Hidden from sidebar',
+ undoHide: 'Undo',
createFailed: 'Could not create project',
staleBackend:
'Update the Hermes backend to create projects — your backend is older than this desktop app (Settings → Updates → Backend).',
diff --git a/apps/desktop/src/i18n/ja.ts b/apps/desktop/src/i18n/ja.ts
index 96cec6b16b1..504d6f7d18c 100644
--- a/apps/desktop/src/i18n/ja.ts
+++ b/apps/desktop/src/i18n/ja.ts
@@ -2382,6 +2382,8 @@ export const ja = defineLocale({
removeFromSidebar: 'サイドバーから削除',
createdInPreviousContext:
'プロジェクトは以前の接続またはプロファイルで作成されました。そこに戻ってください。IDEA.md は書き込まれていません。',
+ hiddenFromSidebar: 'サイドバーから非表示にしました',
+ undoHide: '元に戻す',
createFailed: 'プロジェクトを作成できませんでした',
staleBackend:
'プロジェクトを作成するには Hermes バックエンドを更新してください。バックエンドがこのデスクトップアプリより古いです(設定 → 更新 → バックエンド)。',
diff --git a/apps/desktop/src/i18n/types.ts b/apps/desktop/src/i18n/types.ts
index 72df37a3e89..e101db50eec 100644
--- a/apps/desktop/src/i18n/types.ts
+++ b/apps/desktop/src/i18n/types.ts
@@ -2942,6 +2942,8 @@ export interface Translations extends NoticeTranslations {
copyPath: string
removeFromSidebar: string
createdInPreviousContext: string
+ hiddenFromSidebar: string
+ undoHide: string
createFailed: string
staleBackend: string
deleteConfirm: string
diff --git a/apps/desktop/src/i18n/zh.ts b/apps/desktop/src/i18n/zh.ts
index 5e36910b816..34a80cff2f0 100644
--- a/apps/desktop/src/i18n/zh.ts
+++ b/apps/desktop/src/i18n/zh.ts
@@ -3252,6 +3252,8 @@ export const zh = defineLocale({
copyPath: '复制路径',
removeFromSidebar: '从侧边栏移除',
createdInPreviousContext: '项目已在之前的连接或配置文件中创建。请切换回去;IDEA.md 尚未写入。',
+ hiddenFromSidebar: '已从侧边栏隐藏',
+ undoHide: '撤销',
createFailed: '无法创建项目',
staleBackend: '请更新 Hermes 后端以创建项目——当前后端比桌面应用旧(设置 → 更新 → 后端)。',
deleteConfirm: '这会从 Hermes 中移除已保存的项目。文件、git 仓库和工作树保持不变。',
diff --git a/apps/desktop/src/store/layout.ts b/apps/desktop/src/store/layout.ts
index 44e985476d4..8b8e542115f 100644
--- a/apps/desktop/src/store/layout.ts
+++ b/apps/desktop/src/store/layout.ts
@@ -517,6 +517,18 @@ export function filterVisibleProjects<T extends { id: string; isAuto?: boolean }
return projects.filter(project => !(project.isAuto && dismissed.has(project.id)))
}
+// Reverse a dismiss: un-hide an auto-derived project so its row returns to the
+// overview. Powers the "Undo" affordance on the hide toast (accidental hides
+// were otherwise irreversible — there is no other restore control). Idempotent
+// when the id isn't currently dismissed.
+export function restoreAutoProject(id: string): void {
+ const current = $dismissedAutoProjectIds.get()
+
+ if (current.includes(id)) {
+ $dismissedAutoProjectIds.set(current.filter(projectId => projectId !== id))
+ }
+}
+
export function dismissWorktree(id: string, { removed = false }: { removed?: boolean } = {}): void {
const removedIds = $removedWorktreeIds.get().filter(worktreeId => worktreeId !== id)
$removedWorktreeIds.set(removed ? [...removedIds, id] : removedIds)