Skip to content

Beautiful, AI-native markdown IDE and LLM wiki

PRD-9596 Show one header row in the narrow-window Files cover (#6913)

Andrew Mikofalvyf6c8941b45e3
diff --git a/.changeset/narrow-files-cover-single-header.md b/.changeset/narrow-files-cover-single-header.md
new file mode 100644
index 000000000..caad45ec8
--- /dev/null
+++ b/.changeset/narrow-files-cover-single-header.md
@@ -0,0 +1,5 @@
+---
+'@inkeep/open-knowledge': patch
+---
+
+On phones and narrow windows, the Files view now has a single header row, with Back beside the project name and the file toolbar.
diff --git a/docs/content/features/git/sync.mdx b/docs/content/features/git/sync.mdx
index 8c93aa4fd..b4c03a1d6 100644
--- a/docs/content/features/git/sync.mdx
+++ b/docs/content/features/git/sync.mdx
@@ -67,7 +67,7 @@ If an incoming update conflicts with your edits, sync pauses and the menu lists
## Resolving a conflict
-When a remote update conflicts with your local edits, OpenKnowledge surfaces the conflict in three places at once: the conflicted file gains a `⚠` badge on its tab, a pinned **Conflicts** section appears at the top of the file tree listing every conflicted file, and the editor area swaps from the normal editor to a unified diff view.
+When a remote update conflicts with your local edits, OpenKnowledge surfaces the conflict in three places at once: the conflicted file gains a `⚠` badge on its tab, a pinned **Conflicts** section listing every conflicted file appears at the top of the file tree (on a phone or a narrow window, where Files opens over the editor, it sits below the file list instead), and the editor area swaps from the normal editor to a unified diff view.
Click the badged tab or any row in the Conflicts section to focus the conflict.
diff --git a/packages/app/src/components/EditorArea.tsx b/packages/app/src/components/EditorArea.tsx
index be881b80f..143bb38fb 100644
--- a/packages/app/src/components/EditorArea.tsx
+++ b/packages/app/src/components/EditorArea.tsx
@@ -850,7 +850,6 @@ function EditorAreaInner({
} = useSidebar();
const fileListHost = useFileListHost();
const [filesCoverTarget, setFilesCoverTarget] = useState<HTMLDivElement | null>(null);
- const filesBackRef = useRef<HTMLButtonElement | null>(null);
const [agentsContainer, setAgentsContainer] = useState<HTMLElement | null>(null);
const [rightTerminalContainer, setRightTerminalContainer] = useState<HTMLDivElement | null>(null);
@@ -2683,8 +2682,8 @@ function EditorAreaInner({
dismissFilesCoverEvent(false);
return;
}
- filesBackRef.current?.focus();
- }, [filesCover, fileListHost]);
+ filesCoverTarget?.querySelector<HTMLElement>('[data-files-back]')?.focus();
+ }, [filesCover, fileListHost, filesCoverTarget]);
useEffect(() => {
if (!filesCover) return;
const onKeyDown = (event: KeyboardEvent) => {
@@ -3316,27 +3315,6 @@ function EditorAreaInner({
SECONDARY_PANEL_SURFACE_CLASS,
)}
>
- <div className="flex h-11 shrink-0 items-center gap-1 px-2">
- <Button
- ref={filesBackRef}
- data-files-back=""
- variant="ghost"
- size="icon-sm"
- aria-label={t`Back to editor`}
- title={t`Back to editor`}
- onClick={() => dismissFilesCover()}
- onKeyDown={(event) => {
- if (event.key !== 'Escape' || isOverlayLayerOpen()) return;
- event.preventDefault();
- dismissFilesCover();
- }}
- >
- <ChevronLeft aria-hidden="true" />
- </Button>
- <h2 className="min-w-0 flex-1 truncate font-mono text-xs font-normal uppercase tracking-wide text-muted-foreground">
- {t`Files`}
- </h2>
- </div>
<div ref={setFilesCoverTarget} className="relative min-h-0 flex-1" />
</section>
) : null}
diff --git a/packages/app/src/components/FileSidebar.tsx b/packages/app/src/components/FileSidebar.tsx
index 7060fdf73..c3cada166 100644
--- a/packages/app/src/components/FileSidebar.tsx
+++ b/packages/app/src/components/FileSidebar.tsx
@@ -3,6 +3,7 @@
import { humanFormat } from '@inkeep/open-knowledge-core/config/errors';
import { Trans, useLingui } from '@lingui/react/macro';
import {
+ ChevronLeft,
ChevronRight,
Copy,
FilePlus,
@@ -115,6 +116,7 @@ import {
} from '@/lib/file-tree-menu-action-events';
import { VISIBLE_TARGETS } from '@/lib/handoff/targets';
import { subscribeLocalMenuAction } from '@/lib/local-menu-action-bus';
+import { isOverlayLayerOpen } from '@/lib/overlay-layers';
import { ProfilerBoundary } from '@/lib/perf';
import { revealInFileManagerLabel } from '@/lib/platform-labels';
import { revealEditorBeforeActing } from '@/lib/reveal-editor';
@@ -193,7 +195,7 @@ function FileSidebarInner() {
const isElectronHost = typeof window !== 'undefined' && window.okDesktop != null;
- const { state: sidebarState, toggleSidebar, setOpen, dismissCover } = useSidebar();
+ const { state: sidebarState, toggleSidebar, setOpen, cover, dismissCover } = useSidebar();
const isEmbedded = useIsEmbedded();
const [folderState, setFolderState] = useState(EMPTY_FOLDER_STATE);
@@ -603,7 +605,7 @@ function FileSidebarInner() {
* context menu — same a11y semantics as a Radix Slot. */}
<div className="contents" onContextMenu={handleSidebarSurfaceContextMenu}>
<SidebarContent>
- <ConflictsSection />
+ {cover ? null : <ConflictsSection />}
{}
{
<Collapsible
@@ -615,8 +617,28 @@ function FileSidebarInner() {
{}
<SidebarGroupLabel
data-sidebar-project-row=""
- className="h-11 shrink-0 gap-1 rounded-none"
+ className={cn(
+ 'h-11 shrink-0 gap-1 rounded-none',
+ cover && 'sticky top-0 z-10 bg-sidebar',
+ )}
>
+ {cover ? (
+ <Button
+ data-files-back=""
+ variant="ghost"
+ size="icon-sm"
+ aria-label={t`Back to editor`}
+ title={t`Back to editor`}
+ onClick={() => dismissCover()}
+ onKeyDown={(event) => {
+ if (event.key !== 'Escape' || isOverlayLayerOpen()) return;
+ event.preventDefault();
+ dismissCover();
+ }}
+ >
+ <ChevronLeft aria-hidden="true" />
+ </Button>
+ ) : null}
<CollapsibleTrigger
data-sidebar-root-context
className="flex min-w-0 flex-1 items-center gap-1.5"
@@ -813,6 +835,7 @@ function FileSidebarInner() {
</Collapsible>
}
{}
+ {cover ? <ConflictsSection /> : null}
{showSkillsSection ? <SkillsSidebarDock filesOpen={filesOpen} /> : null}
</SidebarContent>
<SidebarFooter className="px-0 empty:hidden">
diff --git a/packages/app/tests/stress/editor-card-side-panel-width.e2e.ts b/packages/app/tests/stress/editor-card-side-panel-width.e2e.ts
index 28bf2f8f9..de74ccabf 100644
--- a/packages/app/tests/stress/editor-card-side-panel-width.e2e.ts
+++ b/packages/app/tests/stress/editor-card-side-panel-width.e2e.ts
@@ -279,6 +279,14 @@ async function widthOf(locator: Locator): Promise<number> {
return locator.evaluate((element) => element.getBoundingClientRect().width);
}
+function ownsItsCentre(target: Locator): Promise<boolean> {
+ return target.evaluate((element) => {
+ const rect = element.getBoundingClientRect();
+ const hit = document.elementFromPoint(rect.x + rect.width / 2, rect.y + rect.height / 2);
+ return hit != null && element.contains(hit);
+ });
+}
+
async function settleFrames(page: Page): Promise<void> {
await page.evaluate(
() => new Promise((resolve) => requestAnimationFrame(() => requestAnimationFrame(resolve))),
@@ -940,6 +948,91 @@ test('Files opens as a full editor cover and Back preserves docking intent', asy
await expect(cover).not.toBeVisible();
await page.setViewportSize({ width: 1000, height: 700 });
await expect(page.locator('[data-sidebar="sidebar"]')).toBeVisible();
+ await expect(page.locator('[data-sidebar-project-row]')).toBeVisible();
+ await expect(page.locator('[data-files-cover]')).toHaveCount(0);
+ await expect(page.locator('[data-files-back]')).toHaveCount(0);
+});
+
+test('Files cover keeps Back in view when its sidebar scrolls in a short window', async ({
+ page,
+ api,
+}) => {
+ const docName = `editor-card-files-cover-short-${test.info().workerIndex}`;
+ await api.seedDocs([{ name: docName, markdown: DOC_MARKDOWN }]);
+ await page.setViewportSize({ width: 390, height: 240 });
+ await page.goto(`/#/${docName}`);
+ await waitForActiveProviderSynced(page);
+
+ await page.locator('[data-sidebar="trigger"]').click();
+ const cover = page.locator('[data-files-cover]');
+ await expect(cover).toBeVisible();
+ await cover.getByText('Skills Studio', { exact: true }).click();
+ const content = cover.locator('[data-sidebar="content"]');
+ await expect
+ .poll(() => content.evaluate((element) => element.scrollHeight - element.clientHeight))
+ .toBeGreaterThan(0);
+ const rowHeight = await cover
+ .locator('[data-sidebar-project-row]')
+ .evaluate((element) => element.getBoundingClientRect().height);
+ await content.evaluate((element) => {
+ element.scrollTop = element.scrollHeight;
+ });
+ await expect
+ .poll(() => content.evaluate((element) => element.scrollTop))
+ .toBeGreaterThanOrEqual(rowHeight);
+ const back = cover.getByRole('button', { name: 'Back to editor', exact: true });
+ await expect.poll(() => ownsItsCentre(back)).toBe(true);
+ await back.click();
+ await expect(cover).toHaveCount(0);
+});
+
+test('Files cover keeps Back as its first row when there are conflicts', async ({ page, api }) => {
+ await page.route('**/api/sync/conflicts', async (route) => {
+ await route.fulfill({
+ status: 200,
+ contentType: 'application/json',
+ body: JSON.stringify({
+ conflicts: Array.from({ length: 25 }, (_, i) => ({
+ file: `folder/conflicted-doc-number-${i}.md`,
+ detectedAt: '2026-08-05T00:00:00.000Z',
+ conflict: 'merge-native',
+ docName: `folder/conflicted-doc-number-${i}`,
+ revision: `reviewed-revision-${i}`,
+ })),
+ }),
+ });
+ });
+ const docName = `editor-card-files-cover-conflicts-${test.info().workerIndex}`;
+ await api.seedDocs([{ name: docName, markdown: DOC_MARKDOWN }]);
+ await page.setViewportSize({ width: 390, height: 700 });
+ await page.goto(`/#/${docName}`);
+ await waitForActiveProviderSynced(page);
+
+ await page.locator('[data-sidebar="trigger"]').click();
+ const cover = page.locator('[data-files-cover]');
+ await expect(cover).toBeVisible();
+ const conflicts = cover.getByTestId('conflicts-section');
+ await expect(conflicts).toBeVisible();
+ const row = cover.locator('[data-sidebar-project-row]');
+ const back = cover.getByRole('button', { name: 'Back to editor', exact: true });
+ const content = cover.locator('[data-sidebar="content"]');
+ const [contentBox, rowBox, conflictsBox] = await Promise.all([
+ content.boundingBox(),
+ row.boundingBox(),
+ conflicts.boundingBox(),
+ ]);
+ expect(Math.abs((rowBox?.y ?? -1) - (contentBox?.y ?? 0))).toBeLessThanOrEqual(1);
+ expect(conflictsBox?.y ?? 0).toBeGreaterThan((rowBox?.y ?? 0) + (rowBox?.height ?? 0) - 1);
+ await expect.poll(() => ownsItsCentre(back)).toBe(true);
+
+ const pinnedScroll = (rowBox?.height ?? 0) * 2;
+ await content.evaluate((element, top) => {
+ element.scrollTop = top;
+ }, pinnedScroll);
+ await expect
+ .poll(() => content.evaluate((element) => element.scrollTop))
+ .toBeGreaterThanOrEqual(pinnedScroll);
+ await expect.poll(() => ownsItsCentre(back)).toBe(true);
});
for (const panel of ['Files', 'information'] as const) {
@@ -966,9 +1059,22 @@ for (const panel of ['Files', 'information'] as const) {
const back = cover.getByRole('button', { name: 'Back to editor', exact: true });
await expect(back).toBeVisible();
await expect(back).toBeFocused();
- await expect(
- cover.getByRole('heading', { name: panel === 'Files' ? 'Files' : docName }),
- ).toBeVisible();
+ if (panel === 'Files') {
+ await expect(cover.getByRole('heading')).toHaveCount(0);
+ const backBox = await back.boundingBox();
+ const toolbarBox = await cover.getByRole('group', { name: 'Files toolbar' }).boundingBox();
+ expect(backBox).not.toBeNull();
+ expect(toolbarBox).not.toBeNull();
+ expect(
+ Math.abs(
+ (backBox?.y ?? 0) +
+ (backBox?.height ?? 0) / 2 -
+ ((toolbarBox?.y ?? 0) + (toolbarBox?.height ?? 0) / 2),
+ ),
+ ).toBeLessThanOrEqual(1);
+ } else {
+ await expect(cover.getByRole('heading', { name: docName })).toBeVisible();
+ }
const cardBounds = await editorCard.boundingBox();
const coverBounds = await cover.boundingBox();
expect(cardBounds).not.toBeNull();
@@ -1221,7 +1327,7 @@ test('Files cover selection reveals its document while Hide keeps Files off afte
await expect(trigger).toHaveAttribute('aria-expanded', 'false');
await trigger.click();
await expect(cover).toBeVisible();
- await expect(cover.locator(':scope > div').first().getByRole('button')).toHaveCount(1);
+ await expect(cover.getByRole('button', { name: /^Hide/ })).toHaveCount(0);
await cover.getByRole('button', { name: 'Tree view options' }).click();
await page.getByRole('menuitem', { name: 'Hide Files', exact: true }).click();
await expect(cover).not.toBeVisible();
@@ -1263,7 +1369,7 @@ test('Files menu Hide is reachable by touch and keyboard without a second cover
const cover = page.locator('[data-files-cover]');
await trigger.tap();
await expect(cover).toBeVisible();
- await expect(cover.locator(':scope > div').first().getByRole('button')).toHaveCount(1);
+ await expect(cover.getByRole('button', { name: /^Hide/ })).toHaveCount(0);
await cover.getByRole('button', { name: 'Tree view options' }).tap();
await page.getByRole('menuitem', { name: 'Hide Files', exact: true }).tap();
await expect(cover).toBeHidden();