Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/remove-broken-upload-file-button.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@inkeep/open-knowledge": patch
---

Remove the broken "Upload file" button from the file sidebar. This drops the upload-via-file-picker entry points: the sidebar toolbar button, the folder and empty-area right-click menu items, and the empty-state button. Drag-and-drop file upload onto the file tree is unchanged.
8 changes: 0 additions & 8 deletions packages/app/src/components/FileSidebar.dom.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,6 @@ const treeCalls = {
expandAll: mock(() => {}),
startCreating: mock((_kind: 'file' | 'folder', _parentDir: string) => {}),
startCreatingFromTemplate: mock((_parentDir: string) => {}),
uploadFiles: mock((_parentDir: string) => {}),
};
const projectLocalPatch = mock((_patch: unknown) => projectPatchResult);
const showItemInFolderMock = mock((_path: string) => Promise.resolve());
Expand Down Expand Up @@ -144,7 +143,6 @@ mock.module('@/components/FileTree', () => ({
treeListeners.add(listener);
return () => treeListeners.delete(listener);
},
uploadFiles: treeCalls.uploadFiles,
};
ref?.(handle);
return () => ref?.(null);
Expand Down Expand Up @@ -402,7 +400,6 @@ describe('FileSidebar runtime behavior', () => {
treeCalls.expandAll,
treeCalls.startCreating,
treeCalls.startCreatingFromTemplate,
treeCalls.uploadFiles,
projectLocalPatch,
showItemInFolderMock,
notifyViewMenuStateChangedMock,
Expand Down Expand Up @@ -489,11 +486,9 @@ describe('FileSidebar runtime behavior', () => {
fireEvent.click(screen.getAllByRole('button', { name: 'New from template' })[0]);
fireEvent.click(screen.getByRole('button', { name: 'Daily' }));
fireEvent.click(screen.getAllByRole('button', { name: 'New folder' })[0]);
fireEvent.click(screen.getAllByRole('button', { name: 'Upload file' })[0]);
expect(treeCalls.startCreating).toHaveBeenCalledWith('file', 'docs');
expect(treeCalls.createFromTemplate).toHaveBeenCalledWith('docs', 'daily');
expect(treeCalls.startCreating).toHaveBeenCalledWith('folder', 'docs');
expect(treeCalls.uploadFiles).toHaveBeenCalledWith('docs');

expect(screen.getByRole('button', { name: 'Expand all' })).toBeTruthy();
expect(screen.getByRole('button', { name: 'Collapse all' })).toBeTruthy();
Expand All @@ -520,7 +515,6 @@ describe('FileSidebar runtime behavior', () => {
'empty-space-menu-new-file',
'empty-space-menu-new-from-template',
'empty-space-menu-new-folder',
'empty-space-menu-upload-file',
'empty-space-menu-reveal-in-finder',
'open-in-agent-empty-space-submenu',
'empty-space-menu-copy-full-path',
Expand All @@ -539,11 +533,9 @@ describe('FileSidebar runtime behavior', () => {
fireEvent.click(screen.getByTestId('empty-space-menu-new-from-template'));
fireEvent.click(screen.getByRole('menuitem', { name: 'Root daily' }));
fireEvent.click(screen.getByTestId('empty-space-menu-new-folder'));
fireEvent.click(screen.getByTestId('empty-space-menu-upload-file'));
expect(treeCalls.startCreating).toHaveBeenCalledWith('file', '');
expect(treeCalls.createFromTemplate).toHaveBeenCalledWith('', 'root-daily');
expect(treeCalls.startCreating).toHaveBeenCalledWith('folder', '');
expect(treeCalls.uploadFiles).toHaveBeenCalledWith('');

fireEvent.click(screen.getByTestId('empty-space-menu-reveal-in-finder'));
expect(showItemInFolderMock).toHaveBeenCalledWith('/tmp/open-knowledge');
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,6 @@ const treeCalls = {
expandAll: mock(() => {}),
startCreating: mock((_kind: 'file' | 'folder', _parentDir: string) => {}),
startCreatingFromTemplate: mock((_parentDir: string) => {}),
uploadFiles: mock((_parentDir: string) => {}),
};
const projectLocalPatch = mock((_patch: unknown) => ({ ok: true as const }));
let menuActionCallback: ((action: MenuAction) => void) | null = null;
Expand All @@ -85,7 +84,6 @@ mock.module('@/components/FileTree', () => ({
startCreating: treeCalls.startCreating,
startCreatingFromTemplate: treeCalls.startCreatingFromTemplate,
subscribe: () => () => {},
uploadFiles: treeCalls.uploadFiles,
};
ref?.(handle);
return () => ref?.(null);
Expand Down Expand Up @@ -232,7 +230,6 @@ describe('FileSidebar menu-action runtime routing', () => {
treeCalls.expandAll,
treeCalls.startCreating,
treeCalls.startCreatingFromTemplate,
treeCalls.uploadFiles,
]) {
fn.mockClear();
}
Expand Down
26 changes: 4 additions & 22 deletions packages/app/src/components/FileSidebar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ import {
ListCollapse,
SquarePen,
UnfoldVertical,
Upload,
} from 'lucide-react';
import { type ComponentProps, type FC, type MouseEventHandler, useEffect, useState } from 'react';
import { ErrorBoundary } from 'react-error-boundary';
Expand Down Expand Up @@ -208,10 +207,6 @@ function FileSidebarInner({ onOpenSearch }: FileSidebarProps) {
if (!workspace) return;
tree?.startCreating('folder', '');
};
const handleEmptySpaceUploadFile = () => {
if (!workspace) return;
tree?.uploadFiles('');
};
const handleEmptySpaceReveal = () => {
if (!workspace || !bridge) return;
void bridge.shell.showItemInFolder(workspace.contentDir);
Expand Down Expand Up @@ -544,11 +539,6 @@ function FileSidebarInner({ onOpenSearch }: FileSidebarProps) {
label={t`New folder`}
onClick={() => tree?.startCreating('folder', initialCreateDir)}
/>
<ToolbarButton
icon={Upload}
label={t`Upload file`}
onClick={() => tree?.uploadFiles(initialCreateDir)}
/>
</div>
</SidebarHeader>
{/*
Expand Down Expand Up @@ -662,12 +652,12 @@ function FileSidebarInner({ onOpenSearch }: FileSidebarProps) {
</ContextMenuTrigger>
<ContextMenuContent>
{/*
* Empty-space menu — 12 items, 4 sections.
* Empty-space menu — 11 items, 4 sections.
*
* Section 1: Creation and upload (always visible). New file / from
* Section 1: Creation (always visible). New file / from
* template / folder dispatch the project-root creation flow
* (parentDir = '' → contentDir). Upload opens the project-root file
* picker. Disabled when workspace hasn't resolved.
* (parentDir = '' → contentDir). Disabled when workspace hasn't
* resolved.
*
* Section 2: Act-on-project. Reveal in Finder
* is Electron-only (`if (!bridge) return null`); Open with AI submenu
Expand Down Expand Up @@ -719,14 +709,6 @@ function FileSidebarInner({ onOpenSearch }: FileSidebarProps) {
<FolderPlus aria-hidden="true" />
<Trans>New folder</Trans>
</ContextMenuItem>
<ContextMenuItem
disabled={!workspace}
onSelect={handleEmptySpaceUploadFile}
data-testid="empty-space-menu-upload-file"
>
<Upload aria-hidden="true" />
<Trans>Upload file</Trans>
</ContextMenuItem>
<ContextMenuSeparator />
{bridge ? (
<ContextMenuItem
Expand Down
73 changes: 0 additions & 73 deletions packages/app/src/components/FileTree.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,6 @@ import {
Trash2,
TriangleAlert,
UnfoldVertical,
Upload,
} from 'lucide-react';
import { __iconNode as botIcon } from 'lucide-react/dist/esm/icons/bot';
import { __iconNode as link2Icon } from 'lucide-react/dist/esm/icons/link-2';
Expand Down Expand Up @@ -483,7 +482,6 @@ interface FileTreeMenuProps {
* (`appearance.sidebar.{showHiddenFiles,showAllFiles}`). */
mergedConfig: Config | null;
onStartCreating: (kind: 'file' | 'folder', parentDir: string) => void;
onUploadFiles: (parentDir: string) => void;
/** Inline create-from-template for the given parent dir + template name —
* same inline-rename fast path as `onStartCreating`, seeded from a template.
* Drives the folder menu's "New from template" hover submenu. */
Expand Down Expand Up @@ -544,35 +542,6 @@ function isEditableKeyboardTarget(target: EventTarget | null): boolean {
);
}

function chooseSidebarUploadFiles(): Promise<readonly File[]> {
if (typeof document === 'undefined') return Promise.resolve([]);

return new Promise((resolve) => {
const input = document.createElement('input');
input.type = 'file';
input.multiple = true;
input.tabIndex = -1;
input.style.position = 'fixed';
input.style.inlineSize = '1px';
input.style.blockSize = '1px';
input.style.opacity = '0';
input.style.pointerEvents = 'none';

let settled = false;
const settle = (files: readonly File[]) => {
if (settled) return;
settled = true;
input.remove();
resolve(files);
};

input.addEventListener('change', () => settle(Array.from(input.files ?? [])), { once: true });
input.addEventListener('cancel', () => settle([]), { once: true });
document.body.append(input);
input.click();
});
}

function collectTabsToCloseForDelete(
targets: readonly FileTreeTarget[],
documents: readonly FileEntry[],
Expand Down Expand Up @@ -630,7 +599,6 @@ function FileTreeMenu({
projectLocalBinding,
mergedConfig,
onStartCreating,
onUploadFiles,
onCreateFromTemplate,
onDuplicate,
onDelete,
Expand Down Expand Up @@ -778,16 +746,6 @@ function FileTreeMenu({
<FolderPlus aria-hidden="true" />
<Trans>New folder</Trans>
</DropdownMenuItem>
<DropdownMenuItem
disabled={anyActionBusy}
onSelect={() => {
closeForInlineSurface();
onUploadFiles(treeDirectoryPathToFolderPath(item.path));
}}
>
<Upload aria-hidden="true" />
<Trans>Upload file</Trans>
</DropdownMenuItem>
<DropdownMenuSeparator />
<RevealInFileManagerMenuItem item={item} workspace={workspace} onClose={close} />
<OpenInAgentContextSubmenu
Expand Down Expand Up @@ -1044,7 +1002,6 @@ function FileTreeMenu({

export interface FileTreeHandle {
startCreating(kind: 'file' | 'folder', parentDir: string): void;
uploadFiles(parentDir: string): void;
/** Open NewItemDialog at the given parentDir so the template picker is
* reachable. Used by the native macOS File menu's "New from Template…"
* item, where an inline hover-submenu of templates isn't expressible. */
Expand Down Expand Up @@ -2404,17 +2361,6 @@ export function FileTree({ ref }: { ref?: Ref<FileTreeHandle | null> }) {
}
}

async function uploadFilesToTargetFromPicker(parentDir: string) {
if (busyPathRef.current !== null) return;
const files = await chooseSidebarUploadFiles();
if (files.length === 0) return;
const uploadBusyPath =
parentDir === ''
? FILE_TREE_EXTERNAL_FILE_DROP_BUSY_PATH
: folderPathToTreeDirectoryPath(parentDir);
await uploadExternalFilesToTarget(files, parentDir, uploadBusyPath);
}

function startCreatingFromTemplate(parentDir: string) {
setNewItemRequest({ parentDir });
}
Expand Down Expand Up @@ -2756,11 +2702,9 @@ export function FileTree({ ref }: { ref?: Ref<FileTreeHandle | null> }) {

const startCreatingRef = useRef(startCreating);
const startCreatingFromTemplateRef = useRef(startCreatingFromTemplate);
const uploadFilesRef = useRef(uploadFilesToTargetFromPicker);
useEffect(() => {
startCreatingRef.current = startCreating;
startCreatingFromTemplateRef.current = startCreatingFromTemplate;
uploadFilesRef.current = uploadFilesToTargetFromPicker;
});

useImperativeHandle(
Expand All @@ -2769,9 +2713,6 @@ export function FileTree({ ref }: { ref?: Ref<FileTreeHandle | null> }) {
startCreating(kind, parentDir) {
void startCreatingRef.current(kind, parentDir);
},
uploadFiles(parentDir) {
void uploadFilesRef.current(parentDir);
},
startCreatingFromTemplate(parentDir) {
startCreatingFromTemplateRef.current(parentDir);
},
Expand Down Expand Up @@ -3337,17 +3278,6 @@ export function FileTree({ ref }: { ref?: Ref<FileTreeHandle | null> }) {
>
<Trans>Create your first file</Trans>
</Button>
<Button
variant="link"
size="sm"
className="font-mono uppercase"
onClick={() => {
void uploadFilesToTargetFromPicker('');
}}
>
<Upload aria-hidden="true" />
<Trans>Upload file</Trans>
</Button>
</section>
);
}
Expand Down Expand Up @@ -3394,9 +3324,6 @@ export function FileTree({ ref }: { ref?: Ref<FileTreeHandle | null> }) {
projectLocalBinding={projectLocalBinding}
mergedConfig={merged}
onStartCreating={startCreating}
onUploadFiles={(parentDir) => {
void uploadFilesToTargetFromPicker(parentDir);
}}
onCreateFromTemplate={(parentDir, templateName) =>
startCreating('file', parentDir, { template: templateName })
}
Expand Down
2 changes: 0 additions & 2 deletions packages/app/src/locales/en/messages.po
Original file line number Diff line number Diff line change
Expand Up @@ -5961,8 +5961,6 @@ msgstr "Upload failed — please try again"
msgid "Upload failed: {message}"
msgstr "Upload failed: {message}"

#: src/components/FileSidebar.tsx
#: src/components/FileTree.tsx
#: src/editor/components/PropPanel.tsx
msgid "Upload file"
msgstr "Upload file"
Expand Down
2 changes: 0 additions & 2 deletions packages/app/src/locales/pseudo/messages.po
Original file line number Diff line number Diff line change
Expand Up @@ -5956,8 +5956,6 @@ msgstr ""
msgid "Upload failed: {message}"
msgstr ""

#: src/components/FileSidebar.tsx
#: src/components/FileTree.tsx
#: src/editor/components/PropPanel.tsx
msgid "Upload file"
msgstr ""
Expand Down