🤯 LobeHub - Super-Agents on Your Team. Add super-agents to the chats your team already uses.They take on work by themselves and get better every week.
TypeScript agentagent-collaborationagent-harnessloop-engineeringmcppersonal-assistantproactive-agentskillssuper-agenttask-management
🐛 fix(knowledge-base): open file detail directly on click (#21283)
Arvin Xu6367d275cabf
diff --git a/src/features/ResourceManager/components/Explorer/hooks/useFileItemClick.desktop.test.ts b/src/features/ResourceManager/components/Explorer/hooks/useFileItemClick.desktop.test.tsindex a8ad4933d33..b39a0634654 100644--- a/src/features/ResourceManager/components/Explorer/hooks/useFileItemClick.desktop.test.ts+++ b/src/features/ResourceManager/components/Explorer/hooks/useFileItemClick.desktop.test.ts@@ -88,7 +88,6 @@ describe('useFileItemClick (desktop shell)', () => {id: 'file_1',isFolder: false,isPage: false,- libraryId: 'kb_1',openInPanel: true,});@@ -105,7 +104,7 @@ describe('useFileItemClick (desktop shell)', () => {expect(useResourceManagerStore.getState().detailPanelIsPage).toBe(false);});- it('waits out the double-click window before expanding a closed panel', async () => {+ it('opens the file editor directly when clicking an explorer row inside a knowledge base', async () => {const { result } = renderFileClick({id: 'file_1',isFolder: false,@@ -114,6 +113,61 @@ describe('useFileItemClick (desktop shell)', () => {openInPanel: true,});+ await act(async () => {+ result.current();+ });+ await flushPanelOpenDelay();++ expect(getTabRouter(TAB_ID)!.state.location.search).toBe('?view=grid&file=file_1');+ expect(useResourceManagerStore.getState().mode).toBe('editor');+ expect(useResourceManagerStore.getState().detailPanelId).toBeUndefined();+ });++ it('clears a preview left open outside the knowledge base when opening the editor', async () => {+ useResourceManagerStore.setState({ detailPanelId: 'file_other', detailPanelIsPage: true });+ const { result } = renderFileClick({+ id: 'file_1',+ isFolder: false,+ isPage: false,+ libraryId: 'kb_1',+ openInPanel: true,+ });++ await act(async () => {+ result.current();+ });++ expect(useResourceManagerStore.getState().mode).toBe('editor');+ expect(useResourceManagerStore.getState().detailPanelId).toBeUndefined();+ expect(useResourceManagerStore.getState().detailPanelIsPage).toBe(false);+ });++ it('opens the page editor directly when clicking a page inside a knowledge base', async () => {+ const { result } = renderFileClick({+ id: 'page_1',+ isFolder: false,+ isPage: true,+ libraryId: 'kb_1',+ openInPanel: true,+ });++ await act(async () => {+ result.current();+ });++ expect(getTabRouter(TAB_ID)!.state.location.search).toBe('?view=grid&file=page_1');+ expect(useResourceManagerStore.getState().mode).toBe('page');+ expect(useResourceManagerStore.getState().detailPanelId).toBeUndefined();+ });++ it('waits out the double-click window before expanding a closed panel', async () => {+ const { result } = renderFileClick({+ id: 'file_1',+ isFolder: false,+ isPage: false,+ openInPanel: true,+ });+await act(async () => {result.current();});@@ -133,7 +187,6 @@ describe('useFileItemClick (desktop shell)', () => {id: 'file_2',isFolder: false,isPage: false,- libraryId: 'kb_1',openInPanel: true,});@@ -149,7 +202,6 @@ describe('useFileItemClick (desktop shell)', () => {id: 'file_1',isFolder: false,isPage: false,- libraryId: 'kb_1',openInPanel: true,});const { result: doubleClickResult } = renderHook(@@ -173,7 +225,6 @@ describe('useFileItemClick (desktop shell)', () => {id: 'page_1',isFolder: false,isPage: true,- libraryId: 'kb_1',openInPanel: true,});diff --git a/src/features/ResourceManager/components/Explorer/hooks/useFileItemClick.ts b/src/features/ResourceManager/components/Explorer/hooks/useFileItemClick.tsindex 24eb5396c37..30e53372086 100644--- a/src/features/ResourceManager/components/Explorer/hooks/useFileItemClick.ts+++ b/src/features/ResourceManager/components/Explorer/hooks/useFileItemClick.ts@@ -11,10 +11,12 @@ export interface UseFileItemClickOptions {libraryId?: string | null;onOpen?: (id: string) => void;/**- * Explorer rows (list / masonry) preview files and pages in the inline right- * detail panel. The library sidebar tree is navigation and also stays mounted- * where no explorer (and so no panel) exists, e.g. the Permissions page, so it- * keeps opening the fullscreen editor.+ * Explorer rows (list / masonry) outside a knowledge base preview files and+ * pages in the inline right detail panel. Inside a knowledge base the content+ * itself is the point of the visit, so a click opens the detail directly. The+ * library sidebar tree is navigation and also stays mounted where no explorer+ * (and so no panel) exists, e.g. the Permissions page, so it keeps opening the+ * fullscreen editor.*/openInPanel?: boolean;slug?: string | null;@@ -56,6 +58,7 @@ export const useFileItemClick = ({const setMode = useResourceManagerStore((s) => s.setMode);const setCurrentViewItemId = useResourceManagerStore((s) => s.setCurrentViewItemId);const openDetailPanel = useResourceManagerStore((s) => s.openDetailPanel);+ const closeDetailPanel = useResourceManagerStore((s) => s.closeDetailPanel);const handleClick = useCallback(() => {const selectFile = () => {@@ -91,7 +94,7 @@ export const useFileItemClick = ({return;}- if (openInPanel) {+ if (openInPanel && !libraryId) {// A plain click is a "look at this" gesture — the promise of the explorer// is to keep the working list visible. Fullscreen focus stays available as// the explicit double click (see `useFileItemDoubleClick`).@@ -114,6 +117,10 @@ export const useFileItemClick = ({return;}+ // The preview state is global: drop a panel left open elsewhere so leaving+ // the editor doesn't reveal a stale preview.+ cancelPendingPanelOpen();+ closeDetailPanel();setCurrentViewItemId(id);setMode(isPage ? 'page' : 'editor');// Update URL query parameter for shareable links@@ -132,6 +139,7 @@ export const useFileItemClick = ({setMode,setCurrentViewItemId,openDetailPanel,+ closeDetailPanel,onOpen,]);