Skip to content

armgit / macro

Public Imported from GitHub
0

Macro is a unified workspace for teams: email, chat, docs, tasks, agents, calls, and CRM — @-linked together with shared AI memory.

fix(files): upload dropped files into the open folder (#7598)

Eric Hayes7857983f7a29
diff --git a/apps/web/src/features/block-project/component/Block.test.tsx b/apps/web/src/features/block-project/component/Block.test.tsx
new file mode 100644
index 0000000000..6266d7ba15
--- /dev/null
+++ b/apps/web/src/features/block-project/component/Block.test.tsx
@@ -0,0 +1,120 @@
+import {
+ cleanup,
+ fireEvent,
+ render,
+ screen,
+ waitFor,
+} from '@solidjs/testing-library';
+import type { ParentProps } from 'solid-js';
+import { afterEach, expect, it, vi } from 'vitest';
+import Block from './Block';
+
+const upload = vi.hoisted(() => ({
+ files: vi.fn().mockResolvedValue([]),
+}));
+
+vi.mock('@app/features/next-soup/actions', () => ({
+ useBlockEntityCommands: () => {},
+}));
+vi.mock('@app/features/next-soup/create-soup-state', () => ({
+ createSoupState: () => ({}),
+}));
+vi.mock('@app/features/next-soup/filters/filter-store', () => ({
+ defineQueryFilters: () => ({}),
+}));
+vi.mock('@app/features/next-soup/filters/query-filters', () => ({
+ soupItemMatchesProjectMembership: () => true,
+}));
+vi.mock('@app/features/next-soup/soup-context', () => ({
+ SoupContextProvider: (props: ParentProps) => props.children,
+}));
+vi.mock('@app/features/next-soup/soup-view/soup-view-context', () => ({
+ SoupViewContextProvider: (props: ParentProps) => props.children,
+}));
+vi.mock('@app/features/next-soup/soup-view/soup-view', async () => {
+ const { SoupViewFileDropzone } = await import(
+ '@app/features/next-soup/soup-view/soup-view-file-dropzone'
+ );
+ return {
+ SoupViewList: (props: { uploadProjectId?: string }) => (
+ <SoupViewFileDropzone projectId={props.uploadProjectId}>
+ <div data-testid="folder-list">Folder contents</div>
+ </SoupViewFileDropzone>
+ ),
+ };
+});
+vi.mock('@components/app/side-panel', () => ({
+ SidePanel: { Layout: (props: ParentProps) => props.children },
+}));
+vi.mock('@components/app/split-layout/layout', () => ({
+ useSplitLayout: () => ({}),
+}));
+vi.mock('@core/block', () => ({ useBlockId: () => 'new-folder' }));
+vi.mock('@core/component/DocumentBlockContainer', () => ({
+ DocumentBlockContainer: (props: ParentProps) => props.children,
+}));
+vi.mock('@core/component/FileDropOverlay', () => ({
+ FileDropOverlay: (props: ParentProps) => props.children,
+}));
+vi.mock('@core/component/Toast/Toast', () => ({ toast: {} }));
+vi.mock('@core/constant/allBlocks', () => ({
+ fileTypeToBlockName: () => 'unknown',
+}));
+vi.mock('@core/directive/fileSelector', () => ({ fileSelector: () => {} }));
+vi.mock('@core/signal/blockElement', () => ({
+ blockHotkeyScopeSignal: { get: () => 'folder-scope' },
+}));
+vi.mock('@core/util/upload', () => ({
+ uploadFiles: upload.files,
+ handleFileFolderDrop: async (
+ entries: FileSystemFileEntry[],
+ _folders: FileSystemDirectoryEntry[],
+ onFilesReady: (files: File[]) => Promise<void>
+ ) => {
+ const files = await Promise.all(
+ entries.map(
+ (entry) => new Promise<File>((resolve) => entry.file(resolve))
+ )
+ );
+ await onFilesReady(files);
+ },
+}));
+vi.mock('@queries/history/history', () => ({ refetchHistory: () => {} }));
+vi.mock('@queries/soup/cache', () => ({ refetchSoupEntity: () => {} }));
+vi.mock('@service-storage/util/refetchResources', () => ({
+ refetchResources: () => {},
+}));
+vi.mock('./project-scoped-panel', () => ({
+ useProjectScopedPanel: () => ({}),
+}));
+vi.mock('./sidepanel/ProjectSidePanelSections', () => ({
+ ProjectSidePanelSections: () => null,
+}));
+vi.mock('./TopBar', () => ({ TopBar: () => null }));
+
+afterEach(() => {
+ cleanup();
+ vi.clearAllMocks();
+});
+
+it.each([1, 2])(
+ 'uploads %i dropped computer files into the open folder',
+ async (count) => {
+ render(() => <Block />);
+ const files = Array.from(
+ { length: count },
+ (_, index) =>
+ new File(['contents'], `file-${index}.txt`, { type: 'text/plain' })
+ );
+
+ fireEvent.drop(screen.getByTestId('folder-list'), {
+ dataTransfer: { items: [], files, types: ['Files'] },
+ });
+
+ await waitFor(() =>
+ expect(upload.files).toHaveBeenCalledExactlyOnceWith(files, 'dss', {
+ projectId: 'new-folder',
+ })
+ );
+ }
+);
diff --git a/apps/web/src/features/block-project/component/Block.tsx b/apps/web/src/features/block-project/component/Block.tsx
index de287e50d0..69691e0971 100644
--- a/apps/web/src/features/block-project/component/Block.tsx
+++ b/apps/web/src/features/block-project/component/Block.tsx
@@ -176,7 +176,11 @@ const ProjectEntityListContent = (props: ProjectEntityListProps) => {
emailView: 'all',
})}
>
- <SoupViewList customScrollbarHidden={true} scopeId={props.scopeId} />
+ <SoupViewList
+ customScrollbarHidden={true}
+ scopeId={props.scopeId}
+ uploadProjectId={props.projectId}
+ />
</SoupViewContextProvider>
</SoupContextProvider>
);
diff --git a/docs/AGENT_GUIDE/surfaces.md b/docs/AGENT_GUIDE/surfaces.md
index 88fa2d9735..3da011481e 100644
--- a/docs/AGENT_GUIDE/surfaces.md
+++ b/docs/AGENT_GUIDE/surfaces.md
@@ -1037,7 +1037,12 @@ combine to narrow the results. Created by is hidden while My Files
is restricted to your own files. Recent offers only file-scope filtering.
`Sort files` offers modified, created, and viewed dates.
Recent uses the viewer's own interaction order and does not offer a sort override.
-The New menu and drag/drop uploads target the selected folder. File rows retain
+The New menu and drag/drop uploads target the selected folder. In a folder
+opened in its own split or an inline preview, drop files from the computer onto
+the empty state or file list, then reopen the folder to verify membership.
+Check both one file and multiple files; the nested list drop target must retain
+the open folder as the upload destination.
+File rows retain
selection and context menus; ordinary folder clicks and Enter browse inside Drive,
while Markdown, code/CSV, image, video, PDF/DOCX, canvas, and unrecognized file
clicks and Enter replace the list with a breadcrumbed detail. Those detail