Skip to content

Beautiful, AI-native markdown IDE and LLM wiki

fix(ok): collapse a folder from its pinned sidebar header (PRD-7617) (#3254)

tim-inkeep0b734960d691
diff --git a/.changeset/sticky-folder-header-collapse.md b/.changeset/sticky-folder-header-collapse.md
new file mode 100644
index 000000000..950b4926b
--- /dev/null
+++ b/.changeset/sticky-folder-header-collapse.md
@@ -0,0 +1,5 @@
+---
+"@inkeep/open-knowledge": patch
+---
+
+Clicking a folder's pinned header in the Files sidebar now collapses the folder. When you scroll down inside a large expanded folder, its header row pins to the top of the sidebar. Clicking that pinned row did nothing visible: the sidebar treated it as a click on an unselected folder and re-opened the folder instead of collapsing it, while the same row clicked at its natural position in the list collapsed as expected. The pinned row now collapses the folder and scrolls back to it, so the row stays under your cursor.
diff --git a/packages/app/package.json b/packages/app/package.json
index e21ae9aa3..5e92ee142 100644
--- a/packages/app/package.json
+++ b/packages/app/package.json
@@ -27,7 +27,7 @@
"measure:stress": "bash scripts/measure-stress.sh",
"measure:sweep": "bash scripts/measure-sweep.sh",
"perf:compare": "bash scripts/perf-compare.sh",
- "test:e2e": "playwright test tests/stress/ux-interactions.e2e.ts tests/stress/file-tree-create.e2e.ts tests/stress/file-tree-drag-to-root.e2e.ts tests/stress/file-tree-deselect-to-root.e2e.ts tests/stress/create-then-rename-editable.e2e.ts tests/stress/find-replace.e2e.ts tests/stress/editor-tabs.e2e.ts tests/stress/crdt-stress.e2e.ts tests/stress/slash-command.e2e.ts tests/stress/paste-fidelity.e2e.ts tests/stress/fr-7a-disconnect-source-mode.e2e.ts tests/stress/docs-open.e2e.ts tests/stress/frozen-table-headers.e2e.ts tests/stress/asset-embed.e2e.ts tests/stress/asset-embed-advanced.e2e.ts tests/stress/asset-click-dispatch.e2e.ts tests/stress/handoff.e2e.ts tests/stress/multi-agent-presence.e2e.ts tests/stress/editor-mode-persistence.e2e.ts tests/stress/lint-config-toggle.e2e.ts tests/stress/plugin-enable-notice.e2e.ts tests/stress/schema-edit-fields-view.e2e.ts tests/stress/sidebar-search-pill.e2e.ts tests/stress/navigation-history.e2e.ts tests/stress/command-palette-semantic.e2e.ts tests/stress/agent-activity-panel.e2e.ts tests/stress/drop-pipeline-auto-open.e2e.ts tests/stress/command-palette-flicker.e2e.ts tests/stress/cm6-list-hanging-indent.e2e.ts tests/stress/ng7-rapid-nav-coherence.e2e.ts tests/stress/reveal-on-activate.e2e.ts tests/stress/selection-indicator.e2e.ts tests/stress/new-file-cross-doc-bleed.e2e.ts tests/stress/editor-mode-flip-cross-doc-bleed.e2e.ts tests/stress/editor-area-viewport-resize.e2e.ts tests/stress/qa-sidebar-responsive.e2e.ts tests/stress/prd-6955-reassertion-repro.e2e.ts tests/stress/prd-6955-reassertion-wedge.e2e.ts tests/stress/prd-6914-repro.e2e.ts tests/stress/showall-lazy-tree.e2e.ts tests/stress/tabs-component-strip.e2e.ts tests/stress/source-find-scroll.e2e.ts tests/stress/harness-app-warmth.e2e.ts tests/stress/qa-canary-authoring-both-modes.e2e.ts tests/stress/qa-canary-live-typing.e2e.ts tests/stress/keystroke-cadence-danger-space.e2e.ts tests/stress/jsx-unregistered-backspace-delete.e2e.ts tests/stress/jsx-unregistered-ime-concurrent.e2e.ts tests/stress/jsx-backspace-delete.e2e.ts tests/stress/link-authoring-bytes.e2e.ts tests/stress/link-authoring-apex.e2e.ts tests/stress/command-palette-parity.e2e.ts tests/stress/settings-search.e2e.ts tests/stress/chip-popover-positioning.e2e.ts tests/stress/docs-open-scroll-restore.e2e.ts tests/stress/file-tree-decoration-chip-strip-repro.e2e.ts tests/stress/grip-click-nodeselect.e2e.ts tests/stress/jsx-halo-semantics.e2e.ts tests/stress/jsx-image-body-click.e2e.ts tests/stress/jsx-prop-panel-placeholder.e2e.ts tests/stress/jsx-range-encompass-halo.e2e.ts tests/stress/jsx-wildcard-convert.e2e.ts tests/stress/markdown-lint.e2e.ts tests/stress/frontmatter-schema-badge.e2e.ts tests/stress/unified-problems.e2e.ts tests/stress/mid-type-recovery.e2e.ts tests/stress/observer-a-multi-client.e2e.ts tests/stress/outline-toolbar-occlusion.e2e.ts tests/stress/quiet-tree-hidden-doc.e2e.ts tests/stress/raw-mdx-fallback-onblur-upgrade.e2e.ts tests/stress/rename-noext-probe.e2e.ts tests/stress/show-ok-folders.e2e.ts tests/stress/source-polish.e2e.ts tests/stress/warm-skeleton-scroll-restore.e2e.ts tests/stress/props-toggle-scroll-preserve.e2e.ts tests/stress/yjs-no-dual-import.e2e.ts tests/stress/graph-panel-surfaces.e2e.ts tests/stress/asset-embed-real-fidelity.e2e.ts tests/stress/rename-content-preservation.e2e.ts tests/stress/rename-consolidation.e2e.ts tests/stress/outline-active-heading.e2e.ts tests/stress/outline-navigation.e2e.ts tests/stress/prd-7627-default-swatch.e2e.ts tests/stress/clipboard-dollar-math-source-fallback.e2e.ts tests/stress/source-mode-undo-keymap.e2e.ts tests/stress/timeline-recovered-restore.e2e.ts tests/stress/blank-line-preservation.e2e.ts tests/stress/landing-helpers.e2e.ts tests/stress/mode-switch-landing.e2e.ts tests/stress/mode-switch-ordinal-divergence.e2e.ts tests/stress/comment-annotation-visibility.e2e.ts tests/stress/qa-miles-edge-blanks.e2e.ts tests/stress/prop-upload.e2e.ts tests/stress/slash-command-auto-open.e2e.ts tests/stress/clipboard-relative-url-source-fallback.e2e.ts tests/stress/editor-split-view.e2e.ts",
+ "test:e2e": "playwright test tests/stress/ux-interactions.e2e.ts tests/stress/file-tree-create.e2e.ts tests/stress/file-tree-drag-to-root.e2e.ts tests/stress/file-tree-deselect-to-root.e2e.ts tests/stress/file-tree-sticky-collapse.e2e.ts tests/stress/create-then-rename-editable.e2e.ts tests/stress/find-replace.e2e.ts tests/stress/editor-tabs.e2e.ts tests/stress/crdt-stress.e2e.ts tests/stress/slash-command.e2e.ts tests/stress/paste-fidelity.e2e.ts tests/stress/fr-7a-disconnect-source-mode.e2e.ts tests/stress/docs-open.e2e.ts tests/stress/frozen-table-headers.e2e.ts tests/stress/asset-embed.e2e.ts tests/stress/asset-embed-advanced.e2e.ts tests/stress/asset-click-dispatch.e2e.ts tests/stress/handoff.e2e.ts tests/stress/multi-agent-presence.e2e.ts tests/stress/editor-mode-persistence.e2e.ts tests/stress/lint-config-toggle.e2e.ts tests/stress/plugin-enable-notice.e2e.ts tests/stress/schema-edit-fields-view.e2e.ts tests/stress/sidebar-search-pill.e2e.ts tests/stress/navigation-history.e2e.ts tests/stress/command-palette-semantic.e2e.ts tests/stress/agent-activity-panel.e2e.ts tests/stress/drop-pipeline-auto-open.e2e.ts tests/stress/command-palette-flicker.e2e.ts tests/stress/cm6-list-hanging-indent.e2e.ts tests/stress/ng7-rapid-nav-coherence.e2e.ts tests/stress/reveal-on-activate.e2e.ts tests/stress/selection-indicator.e2e.ts tests/stress/new-file-cross-doc-bleed.e2e.ts tests/stress/editor-mode-flip-cross-doc-bleed.e2e.ts tests/stress/editor-area-viewport-resize.e2e.ts tests/stress/qa-sidebar-responsive.e2e.ts tests/stress/prd-6955-reassertion-repro.e2e.ts tests/stress/prd-6955-reassertion-wedge.e2e.ts tests/stress/prd-6914-repro.e2e.ts tests/stress/showall-lazy-tree.e2e.ts tests/stress/tabs-component-strip.e2e.ts tests/stress/source-find-scroll.e2e.ts tests/stress/harness-app-warmth.e2e.ts tests/stress/qa-canary-authoring-both-modes.e2e.ts tests/stress/qa-canary-live-typing.e2e.ts tests/stress/keystroke-cadence-danger-space.e2e.ts tests/stress/jsx-unregistered-backspace-delete.e2e.ts tests/stress/jsx-unregistered-ime-concurrent.e2e.ts tests/stress/jsx-backspace-delete.e2e.ts tests/stress/link-authoring-bytes.e2e.ts tests/stress/link-authoring-apex.e2e.ts tests/stress/command-palette-parity.e2e.ts tests/stress/settings-search.e2e.ts tests/stress/chip-popover-positioning.e2e.ts tests/stress/docs-open-scroll-restore.e2e.ts tests/stress/file-tree-decoration-chip-strip-repro.e2e.ts tests/stress/grip-click-nodeselect.e2e.ts tests/stress/jsx-halo-semantics.e2e.ts tests/stress/jsx-image-body-click.e2e.ts tests/stress/jsx-prop-panel-placeholder.e2e.ts tests/stress/jsx-range-encompass-halo.e2e.ts tests/stress/jsx-wildcard-convert.e2e.ts tests/stress/markdown-lint.e2e.ts tests/stress/frontmatter-schema-badge.e2e.ts tests/stress/unified-problems.e2e.ts tests/stress/mid-type-recovery.e2e.ts tests/stress/observer-a-multi-client.e2e.ts tests/stress/outline-toolbar-occlusion.e2e.ts tests/stress/quiet-tree-hidden-doc.e2e.ts tests/stress/raw-mdx-fallback-onblur-upgrade.e2e.ts tests/stress/rename-noext-probe.e2e.ts tests/stress/show-ok-folders.e2e.ts tests/stress/source-polish.e2e.ts tests/stress/warm-skeleton-scroll-restore.e2e.ts tests/stress/props-toggle-scroll-preserve.e2e.ts tests/stress/yjs-no-dual-import.e2e.ts tests/stress/graph-panel-surfaces.e2e.ts tests/stress/asset-embed-real-fidelity.e2e.ts tests/stress/rename-content-preservation.e2e.ts tests/stress/rename-consolidation.e2e.ts tests/stress/outline-active-heading.e2e.ts tests/stress/outline-navigation.e2e.ts tests/stress/prd-7627-default-swatch.e2e.ts tests/stress/clipboard-dollar-math-source-fallback.e2e.ts tests/stress/source-mode-undo-keymap.e2e.ts tests/stress/timeline-recovered-restore.e2e.ts tests/stress/blank-line-preservation.e2e.ts tests/stress/landing-helpers.e2e.ts tests/stress/mode-switch-landing.e2e.ts tests/stress/mode-switch-ordinal-divergence.e2e.ts tests/stress/comment-annotation-visibility.e2e.ts tests/stress/qa-miles-edge-blanks.e2e.ts tests/stress/prop-upload.e2e.ts tests/stress/slash-command-auto-open.e2e.ts tests/stress/clipboard-relative-url-source-fallback.e2e.ts tests/stress/editor-split-view.e2e.ts",
"test:e2e:install-browsers": "playwright install chromium webkit firefox",
"test:visual": "playwright test --config playwright.visual.config.ts",
"test:visual:update": "playwright test --config playwright.visual.config.ts --update-snapshots",
diff --git a/packages/app/src/components/FileTree.preview-tabs.dom.test.tsx b/packages/app/src/components/FileTree.preview-tabs.dom.test.tsx
index eb97bbc83..0d29c32b7 100644
--- a/packages/app/src/components/FileTree.preview-tabs.dom.test.tsx
+++ b/packages/app/src/components/FileTree.preview-tabs.dom.test.tsx
@@ -269,6 +269,17 @@ vi.doMock('@pierre/trees/react', () => ({
>
docs/
</div>
+ {/* Pierre's pinned folder header: same row, no role and no aria-selected. */}
+ <div
+ data-testid="sticky-docs"
+ data-item-path="docs/"
+ data-item-type="folder"
+ data-file-tree-sticky-row="true"
+ data-file-tree-sticky-path="docs/"
+ tabIndex={-1}
+ >
+ docs/
+ </div>
</div>
),
}));
@@ -328,4 +339,20 @@ describe('FileTree preview-tab activation', () => {
expect(window.location.hash).toBe('#/docs/');
expect(notifySidebarFileSelectedMock).toHaveBeenCalledTimes(2);
});
+
+ test('leaves a click on a pinned folder header to the tree, so it collapses instead of reopening', async () => {
+ render(<FileTree />);
+
+ await screen.findByTestId('fake-pierre-tree');
+ await waitFor(() => expect(model.getItem('docs/')).not.toBeNull());
+
+ fireEvent.click(screen.getByTestId('sticky-docs'));
+
+ // The pre-fix path reached navigation through `queueMicrotask`, so one
+ // flush is all it takes to catch it. A `waitFor` would pass on its first
+ // synchronous check and prove nothing.
+ await Promise.resolve();
+ expect(openTargetMock).not.toHaveBeenCalled();
+ expect(window.location.hash).toBe('');
+ });
});
diff --git a/packages/app/src/components/FileTree.tsx b/packages/app/src/components/FileTree.tsx
index c28e06ef7..f89be1b3b 100644
--- a/packages/app/src/components/FileTree.tsx
+++ b/packages/app/src/components/FileTree.tsx
@@ -3430,6 +3430,14 @@ export function FileTree({
}
return;
}
+ // The pinned folder-header overlay renders a second element for the same
+ // row: it carries `data-item-path` but no `aria-selected`, so the folder
+ // branch below would read every click on it as a first click and re-expand
+ // instead of collapsing. Pierre's own sticky click handling collapses the
+ // folder and scrolls the canonical row back into view, which is the whole
+ // gesture, so stay out of its way.
+ if (item.dataset.fileTreeStickyRow === 'true') return;
+
const wasSelected = item.getAttribute('aria-selected') === 'true';
const rawPath = item.dataset.itemPath;
diff --git a/packages/app/tests/stress/file-tree-sticky-collapse.e2e.ts b/packages/app/tests/stress/file-tree-sticky-collapse.e2e.ts
new file mode 100644
index 000000000..0a660744b
--- /dev/null
+++ b/packages/app/tests/stress/file-tree-sticky-collapse.e2e.ts
@@ -0,0 +1,74 @@
+/**
+ * Pinned folder header — click to collapse (composition boundary).
+ *
+ * The DOM suite (`FileTree.preview-tabs.dom.test.tsx`) pins the app-side half
+ * against a stubbed Pierre tree: the click-capture handler must stay out of the
+ * way on a pinned row. Everything the fix then leans on lives in the real tree
+ * and no stub can produce it — the pinned overlay only exists once a real
+ * virtualized list scrolls, and the collapse plus canonical-row reveal are the
+ * library's own sticky click plan. This file covers that gesture end to end.
+ */
+
+import type { Page } from '@playwright/test';
+import { expect, test } from './_helpers';
+
+/**
+ * Children seeded under the fixture folder. The sidebar shows roughly 21 rows
+ * at the 26px row height in the 720px-tall viewport, so this leaves the folder
+ * header well above the fold once the list is scrolled.
+ */
+const CHILD_COUNT = 60;
+
+function uniqueStamp(): string {
+ return `${Date.now().toString(36)}${Math.floor(Math.random() * 1e8).toString(36)}`;
+}
+
+const sidebar = (page: Page) => page.locator('[data-slot="sidebar-container"]');
+
+/**
+ * The pinned overlay row. Pierre renders it without `role="treeitem"`, so it
+ * never collides with the canonical row's locator even while both are mounted.
+ */
+const pinnedHeader = (page: Page) => sidebar(page).locator('[data-file-tree-sticky-row="true"]');
+
+test('clicking a pinned folder header collapses the folder', async ({ page, api }) => {
+ const folder = `sticky-collapse-${uniqueStamp()}`;
+
+ await api.seedDocs(
+ Array.from({ length: CHILD_COUNT }, (_, index) => ({
+ name: `${folder}/child-${String(index).padStart(3, '0')}`,
+ markdown: `# child ${index}\n`,
+ })),
+ );
+
+ // Navigating into the folder reveals its row regardless of what earlier
+ // specs left in this worker's content tree.
+ await page.goto(`/#/${folder}/`);
+ await page.waitForLoadState('domcontentloaded');
+
+ const folderRow = sidebar(page).getByRole('treeitem', { name: folder, exact: true });
+ await expect(folderRow).toBeVisible({ timeout: 30_000 });
+
+ // Row CLICK navigates to the folder route; ArrowRight is the expand gesture.
+ if ((await folderRow.getAttribute('aria-expanded')) !== 'true') {
+ await folderRow.focus();
+ await folderRow.press('ArrowRight');
+ }
+ await expect(folderRow).toHaveAttribute('aria-expanded', 'true');
+
+ // Scroll down through the children until the header pins to the top. The
+ // overlay only mounts above a non-zero scrollTop, and how far that takes
+ // depends on what else the worker's tree holds, so wheel until it appears.
+ await expect(async () => {
+ await sidebar(page).hover();
+ await page.mouse.wheel(0, 400);
+ await expect(pinnedHeader(page)).toBeVisible({ timeout: 1_000 });
+ }).toPass({ timeout: 30_000 });
+
+ await pinnedHeader(page).click();
+
+ // Pierre's sticky click plan: collapse the directory, then reveal the
+ // canonical row. Collapsed, there is nothing left to pin.
+ await expect(folderRow).toHaveAttribute('aria-expanded', 'false');
+ await expect(pinnedHeader(page)).toHaveCount(0);
+});