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.

feat(layout): drive view update (#6439)

Seamus44587bc7f497
diff --git a/apps/web/src/components/app/split-layout/componentRegistry.tsx b/apps/web/src/components/app/split-layout/componentRegistry.tsx
index 1572923734..9534409751 100644
--- a/apps/web/src/components/app/split-layout/componentRegistry.tsx
+++ b/apps/web/src/components/app/split-layout/componentRegistry.tsx
@@ -5,6 +5,7 @@ import { ComposeAgentSession } from '@app/features/block-agent/component/Compose
import type { EventEditorInitialValues } from '@app/features/calendar/components/composer/event-form-model';
import type { CalendarEvent } from '@app/features/calendar/types';
import { ChannelsView } from '@app/features/channels-view/channels-view';
+import { DriveView } from '@app/features/drive-view/drive-view';
import { EmailCompose } from '@app/features/email-compose/email-compose';
import { EmailView } from '@app/features/email-view/email-view';
import { GettingStarted } from '@app/features/getting-started';
@@ -445,6 +446,7 @@ registerComponent(
'documents',
withAuth((params: DocumentsComponentParams = {}) => {
usePageViewTracking('documents');
+ const newAppViews = useNewAppViews();
const user = useUserContext();
const preset = getViewPreset('documents', undefined, {
userId: user.userId(),
@@ -459,12 +461,24 @@ registerComponent(
params.initialClientFilters
);
return (
- <SoupView
- viewName="Files"
- initialFilters={initialFilters}
- initialClientFilters={initialClientFilters}
- initialGroupBy={preset?.groupBy}
- />
+ <Show when={newAppViews.ready()} fallback={<LoadingBlock />}>
+ <Show
+ when={newAppViews.enabled()}
+ fallback={
+ <SoupView
+ viewName="Files"
+ initialFilters={initialFilters}
+ initialClientFilters={initialClientFilters}
+ initialGroupBy={preset?.groupBy}
+ />
+ }
+ >
+ <DriveView
+ initialFilters={params.initialFilters}
+ initialClientFilters={params.initialClientFilters}
+ />
+ </Show>
+ </Show>
);
})
);
diff --git a/apps/web/src/features/command/Launcher.tsx b/apps/web/src/features/command/Launcher.tsx
index e133f94889..96cffea769 100644
--- a/apps/web/src/features/command/Launcher.tsx
+++ b/apps/web/src/features/command/Launcher.tsx
@@ -279,7 +279,7 @@ const createComponent = async (spec: {
export function runCreateAction(
blockName: CreatableName,
- options: { shouldInsert?: boolean; source?: string } = {}
+ options: { shouldInsert?: boolean; source?: string; projectId?: string } = {}
) {
const shouldInsert = options.shouldInsert ?? false;
// Creation analytics fire at the data-layer chokepoints (create.ts /
@@ -301,7 +301,7 @@ export function runCreateAction(
createMarkdownFile({
title: '',
content: '',
- projectId: undefined,
+ projectId: options.projectId,
source,
}),
shouldInsert,
@@ -322,6 +322,7 @@ export function runCreateAction(
const result = await createCanvasFileFromJsonString({
json: JSON.stringify({ nodes: [], edges: [] }),
title: 'New Canvas',
+ projectId: options.projectId,
source,
});
if ('error' in result) return;
@@ -342,6 +343,7 @@ export function runCreateAction(
loading: true,
createFn: () =>
createSnippet({
+ projectId: options.projectId,
title: '',
content: '',
source,
@@ -392,7 +394,12 @@ export function runCreateAction(
case 'project':
createBlock({
blockName: 'project',
- createFn: () => createProject({ name: 'New Folder', source }),
+ createFn: () =>
+ createProject({
+ name: 'New Folder',
+ source,
+ parentId: options.projectId,
+ }),
shouldInsert,
});
return;
@@ -405,6 +412,7 @@ export function runCreateAction(
code: 'print("Hello, World!")',
extension: 'py',
title: 'New Code File',
+ projectId: options.projectId,
source,
});
if (result.isErr()) return;
diff --git a/apps/web/src/features/drive-view/components/drive-navigation.tsx b/apps/web/src/features/drive-view/components/drive-navigation.tsx
new file mode 100644
index 0000000000..5790db0e72
--- /dev/null
+++ b/apps/web/src/features/drive-view/components/drive-navigation.tsx
@@ -0,0 +1,37 @@
+import { ViewSidebar } from '@app/components/view-shell';
+import ClockIcon from '@phosphor/clock.svg';
+import FilesIcon from '@phosphor/files.svg';
+import UsersIcon from '@phosphor/users.svg';
+import { For } from 'solid-js';
+import { Dynamic } from 'solid-js/web';
+import { DRIVE_TABS, type DriveLocation, type DriveTab } from '../core/types';
+
+const icons = { owned: FilesIcon, recent: ClockIcon, shared: UsersIcon };
+
+export function DriveNavigation(props: {
+ location: DriveLocation;
+ onNavigate: (tab: DriveTab) => void;
+}) {
+ return (
+ <ViewSidebar.Nav aria-label="Drive views">
+ <For each={DRIVE_TABS}>
+ {(tab) => (
+ <ViewSidebar.Item
+ active={
+ props.location.kind === 'tab' && props.location.tab === tab.id
+ }
+ class="font-normal"
+ onClick={() => props.onNavigate(tab.id)}
+ >
+ <Dynamic
+ component={icons[tab.id]}
+ class="size-4 shrink-0"
+ aria-hidden="true"
+ />
+ <span class="truncate">{tab.label}</span>
+ </ViewSidebar.Item>
+ )}
+ </For>
+ </ViewSidebar.Nav>
+ );
+}
diff --git a/apps/web/src/features/drive-view/components/folder-tree.tsx b/apps/web/src/features/drive-view/components/folder-tree.tsx
new file mode 100644
index 0000000000..d610312955
--- /dev/null
+++ b/apps/web/src/features/drive-view/components/folder-tree.tsx
@@ -0,0 +1,77 @@
+import { ViewSidebar } from '@app/components/view-shell';
+import CaretRightIcon from '@phosphor/caret-right.svg';
+import FolderIcon from '@phosphor/folder.svg';
+import { Button, cn } from '@ui';
+import { For, Show } from 'solid-js';
+import type { DriveFolderNode } from '../core/types';
+
+export function FolderTree(props: {
+ nodes: DriveFolderNode[];
+ selectedId?: string | null;
+ expandedIds: string[];
+ searching: boolean;
+ onToggle: (id: string) => void;
+ onSelect: (id: string) => void;
+}) {
+ return (
+ <ul class="flex min-w-0 flex-col gap-0.5">
+ <For each={props.nodes}>
+ {(node) => {
+ const open = () =>
+ props.searching || props.expandedIds.includes(node.id);
+ return (
+ <li class="min-w-0">
+ <div
+ class={cn(
+ 'flex min-w-0 items-center rounded-xl',
+ props.selectedId === node.id ? 'bg-active' : 'hover:bg-hover'
+ )}
+ >
+ <Show
+ when={node.children.length > 0}
+ fallback={<span class="w-6 shrink-0" />}
+ >
+ <Button
+ variant="ghost"
+ size="sm"
+ square
+ class="size-6 shrink-0 rounded-lg not-disabled:hover:bg-transparent not-disabled:hover:bg-none not-disabled:active:bg-none"
+ aria-label={`${open() ? 'Collapse' : 'Expand'} ${node.name}`}
+ aria-expanded={open()}
+ onClick={() => props.onToggle(node.id)}
+ >
+ <CaretRightIcon
+ class={cn(
+ 'size-3 transition-transform',
+ open() && 'rotate-90'
+ )}
+ />
+ </Button>
+ </Show>
+ <ViewSidebar.Item
+ class={cn(
+ 'min-w-0 flex-1 justify-start px-2 font-normal bg-transparent not-disabled:hover:bg-transparent not-disabled:hover:bg-none not-disabled:active:bg-none',
+ props.selectedId === node.id && 'text-ink'
+ )}
+ title={node.name}
+ aria-current={
+ props.selectedId === node.id ? 'page' : undefined
+ }
+ onClick={() => props.onSelect(node.id)}
+ >
+ <FolderIcon class="size-4 shrink-0" />
+ <span class="truncate">{node.name}</span>
+ </ViewSidebar.Item>
+ </div>
+ <Show when={open() && node.children.length > 0}>
+ <div class="ml-3 border-l border-edge pl-3">
+ <FolderTree {...props} nodes={node.children} />
+ </div>
+ </Show>
+ </li>
+ );
+ }}
+ </For>
+ </ul>
+ );
+}
diff --git a/apps/web/src/features/drive-view/context/drive-source.ts b/apps/web/src/features/drive-view/context/drive-source.ts
new file mode 100644
index 0000000000..9747e562b3
--- /dev/null
+++ b/apps/web/src/features/drive-view/context/drive-source.ts
@@ -0,0 +1,7 @@
+import type { DriveState } from '../core/types';
+
+export type DriveSelection = Pick<DriveState, 'location' | 'scope' | 'sort'>;
+
+export type DriveResults = {
+ apply: (selection: DriveSelection, clearSearch: boolean) => void;
+};
diff --git a/apps/web/src/features/drive-view/core/folder-tree.test.ts b/apps/web/src/features/drive-view/core/folder-tree.test.ts
new file mode 100644
index 0000000000..4890648ec1
--- /dev/null
+++ b/apps/web/src/features/drive-view/core/folder-tree.test.ts
@@ -0,0 +1,39 @@
+import { describe, expect, it } from 'vitest';
+import {
+ buildFolderTree,
+ filterFolderTree,
+ folderAncestors,
+} from './folder-tree';
+
+const folders = [
+ { id: 'root', name: 'Design' },
+ { id: 'child', name: 'Wireframes', parentId: 'root' },
+ { id: 'nested', name: 'Drive', parentId: 'child' },
+ { id: 'orphan', name: 'Assets', parentId: 'inaccessible' },
+];
+
+describe('Drive folder navigation', () => {
+ it('builds nested folders and keeps folders whose parents are inaccessible', () => {
+ const tree = buildFolderTree(folders);
+ expect(tree.map((node) => node.id)).toEqual(['orphan', 'root']);
+ expect(tree[1].children[0].children[0].id).toBe('nested');
+ });
+ it('searches descendants without losing their ancestors', () => {
+ const matches = filterFolderTree(buildFolderTree(folders), ' dRiVe ');
+ expect(matches.map((node) => node.id)).toEqual(['root']);
+ expect(matches[0].children[0].children[0].id).toBe('nested');
+ expect(filterFolderTree(buildFolderTree(folders), 'absent')).toEqual([]);
+ });
+ it('orders breadcrumb ancestors and tolerates broken/cyclic hierarchies', () => {
+ expect(
+ folderAncestors(folders, 'nested').map((folder) => folder.id)
+ ).toEqual(['root', 'child', 'nested']);
+ const cyclic = [
+ { id: 'a', name: 'A', parentId: 'b' },
+ { id: 'b', name: 'B', parentId: 'a' },
+ ];
+ expect(buildFolderTree(cyclic)).toHaveLength(2);
+ expect(folderAncestors(cyclic, 'a')).toHaveLength(2);
+ expect(folderAncestors(folders, 'missing')).toEqual([]);
+ });
+});
diff --git a/apps/web/src/features/drive-view/core/folder-tree.ts b/apps/web/src/features/drive-view/core/folder-tree.ts
new file mode 100644
index 0000000000..65656755dc
--- /dev/null
+++ b/apps/web/src/features/drive-view/core/folder-tree.ts
@@ -0,0 +1,72 @@
+import type { DriveFolder, DriveFolderNode } from './types';
+
+/** Missing parents become roots; inaccessible ancestors must not hide folders. */
+export function buildFolderTree(
+ folders: readonly DriveFolder[]
+): DriveFolderNode[] {
+ const nodes = new Map(
+ folders.map((folder) => [
+ folder.id,
+ { ...folder, children: [] as DriveFolderNode[] },
+ ])
+ );
+ const roots: DriveFolderNode[] = [];
+ for (const node of nodes.values()) {
+ const ancestors = new Set([node.id]);
+ let parentId = node.parentId;
+ let cycle = false;
+ while (parentId && nodes.has(parentId)) {
+ if (ancestors.has(parentId)) {
+ cycle = true;
+ break;
+ }
+ ancestors.add(parentId);
+ parentId = nodes.get(parentId)?.parentId;
+ }
+ const parent =
+ node.parentId && !cycle ? nodes.get(node.parentId) : undefined;
+ if (parent) parent.children.push(node);
+ else roots.push(node);
+ }
+ const sort = (items: DriveFolderNode[]) => {
+ items.sort((a, b) =>
+ a.name.localeCompare(b.name, undefined, {
+ numeric: true,
+ sensitivity: 'base',
+ })
+ );
+ items.forEach((node) => sort(node.children));
+ };
+ sort(roots);
+ return roots;
+}
+
+/** Keep ancestors of matching descendants, including when their branch is closed. */
+export function filterFolderTree(
+ nodes: readonly DriveFolderNode[],
+ search: string
+): DriveFolderNode[] {
+ const term = search.trim().toLocaleLowerCase();
+ if (!term) return [...nodes];
+ return nodes.flatMap((node) => {
+ if (node.name.toLocaleLowerCase().includes(term)) return [node];
+ const children = filterFolderTree(node.children, term);
+ return children.length ? [{ ...node, children }] : [];
+ });
+}
+
+export function folderAncestors(
+ folders: readonly DriveFolder[],
+ id: string
+): DriveFolder[] {
+ const byId = new Map(folders.map((folder) => [folder.id, folder]));
+ const result: DriveFolder[] = [];
+ const seen = new Set<string>();
+ let current = byId.get(id);
+ while (current && !seen.has(current.id)) {
+ seen.add(current.id);
+ result.unshift(current);
+ current = current.parentId ? byId.get(current.parentId) : undefined;
+ }
+ return result;
+}
diff --git a/apps/web/src/features/drive-view/core/types.ts b/apps/web/src/features/drive-view/core/types.ts
new file mode 100644
index 0000000000..42cb535809
--- /dev/null
+++ b/apps/web/src/features/drive-view/core/types.ts
@@ -0,0 +1,30 @@
+export type DriveTab = 'owned' | 'recent' | 'shared';
+export type DriveScope = 'default' | 'all' | 'attachments';
+export type DriveSort = 'updated_at' | 'created_at' | 'viewed_at';
+
+export type DriveLocation =
+ | { kind: 'tab'; tab: DriveTab }
+ | { kind: 'folder'; id: string | null };
+
+export type DriveFolder = {
+ id: string;
+ name: string;
+ parentId?: string | null;
+};
+
+export type DriveFolderNode = DriveFolder & { children: DriveFolderNode[] };
+
+export type DriveState = {
+ location: DriveLocation;
+ scope: DriveScope;
+ sort: DriveSort;
+ expandedFolderIds: string[];
+ favoritesOpen: boolean;
+ rootOpen: boolean;
+};
+
+export const DRIVE_TABS = [
+ { id: 'owned', label: 'My Files' },
+ { id: 'recent', label: 'Recent' },
+ { id: 'shared', label: 'Shared with me' },
+] satisfies { id: DriveTab; label: string }[];
diff --git a/apps/web/src/features/drive-view/drive-view.tsx b/apps/web/src/features/drive-view/drive-view.tsx
new file mode 100644
index 0000000000..0862008610
--- /dev/null
+++ b/apps/web/src/features/drive-view/drive-view.tsx
@@ -0,0 +1,338 @@
+import {
+ useViewControlHotkeys,
+ useViewTabHotkeys,
+ ViewSidebar,
+} from '@app/components/view-shell';
+import {
+ CREATABLE_BLOCKS,
+ runCreateAction,
+ useCreatableEnabled,
+} from '@app/features/command/Launcher';
+import { FavoriteIcon } from '@app/features/favorites/FavoriteIcon';
+import type { Query } from '@app/features/next-soup/filters/filter-store';
+import { queryStateFrom } from '@app/features/next-soup/filters/filter-store';
+import type { SetPredicatesInput } from '@app/features/next-soup/filters/filter-store/predicates-store';
+import { mergeQuery } from '@app/features/next-soup/filters/filter-store/query-store';
+import { soupItemMatchesProjectMembership } from '@app/features/next-soup/filters/query-filters';
+import { SoupViewList } from '@app/features/next-soup/soup-view/soup-view';
+import { useSoupView } from '@app/features/next-soup/soup-view/soup-view-context';
+import {
+ favoriteSplitContent,
+ useFavoriteDisplayName,
+} from '@app/util/favorites';
+import { useHandleFileUpload } from '@app/util/handleFileUpload';
+import { useEntryState } from '@components/app/split-layout/entry-state';
+import { useSplitLayout } from '@components/app/split-layout/layout';
+import { useSplitPanelOrThrow } from '@components/app/split-layout/layoutUtils';
+import { useUserId } from '@core/context/user';
+import {
+ handleFolderSelect,
+ openFilePicker,
+ openFolderPicker,
+} from '@core/util/upload';
+import EmptyStateFolderGraphic from '@design/empty-state-folder.svg';
+import ArrowLeftIcon from '@phosphor/arrow-left.svg';
+import CaretDownIcon from '@phosphor/caret-down.svg';
+import FolderIcon from '@phosphor/folder.svg';
+import PlusIcon from '@phosphor/plus.svg';
+import SpinnerIcon from '@phosphor/spinner.svg';
+import UploadIcon from '@phosphor/upload-simple.svg';
+import { useFavoritesData } from '@queries/favorites/favorites';
+import { useProjectsQuery } from '@queries/storage/projects';
+import type { Favorite } from '@service-storage/generated/schemas/favorite';
+import { Dropdown, EmptyStatePanel } from '@ui';
+import { createMemo, For, Show, Suspense } from 'solid-js';
+import { Dynamic } from 'solid-js/web';
+import { DRIVE_TABS, type DriveState, type DriveTab } from './core/types';
+import { createDriveNavigation } from './primitives/drive-navigation';
+import { driveQuery } from './queries/drive-query';
+import { createDriveResults } from './queries/drive-results';
+import { DriveLayout } from './views/drive-layout';
+
+export type DriveViewProps = {
+ initialFilters?: Query;
+ initialClientFilters?: SetPredicatesInput<string>;
+};
+
+function DriveFavorite(props: {
+ favorite: Favorite;
+ onOpen: (favorite: Favorite) => void;
+}) {
+ const name = useFavoriteDisplayName(props.favorite);
+ return (
+ <ViewSidebar.Item
+ class="font-normal"
+ title={name()}
+ onClick={() => props.onOpen(props.favorite)}
+ >
+ <FavoriteIcon favorite={props.favorite} class="size-4 shrink-0" />
+ <span class="truncate">{name()}</span>
+ </ViewSidebar.Item>
+ );
+}
+
+/** App composition: shared queries, split navigation, and upload/create capabilities. */
+export function DriveView(props: DriveViewProps) {
+ const panel = useSplitPanelOrThrow();
+ const layout = useSplitLayout();
+ const userId = useUserId();
+ const view = useSoupView();
+ const projects = useProjectsQuery();
+ const folders = () =>
+ projects.isSuccess
+ ? projects.data.filter((folder) => !folder.deletedAt)
+ : [];
+ const favoritesData = useFavoritesData();
+ const favorites = createMemo(() =>
+ (favoritesData()?.favorites ?? [])
+ .filter(
+ (favorite) =>
+ favorite.entityType === 'project' ||
+ (favorite.entityType === 'document' &&
+ favorite.documentSubType !== 'task')
+ )
+ .sort((a, b) => a.sortOrder - b.sortOrder)
+ );
+ const [state, setState] = useEntryState<DriveState>('drive.view', {
+ default: {
+ location: { kind: 'tab', tab: 'owned' },
+ scope: 'default',
+ sort: 'updated_at',
+ expandedFolderIds: [],
+ favoritesOpen: true,
+ rootOpen: true,
+ },
+ });
+ const projectId = () => {
+ const location = state().location;
+ return location.kind === 'folder' ? (location.id ?? undefined) : undefined;
+ };
+ const isRecent = () => {
+ const location = state().location;
+ return location.kind === 'tab' && location.tab === 'recent';
+ };
+ const upload = useHandleFileUpload({
+ get projectId() {
+ return projectId();
+ },
+ });
+ const isCreatableEnabled = useCreatableEnabled();
+ const createOptions = () =>
+ CREATABLE_BLOCKS.filter(
+ (block) =>
+ ['md', 'snippet', 'canvas', 'code', 'project'].includes(
+ block.blockName
+ ) && isCreatableEnabled(block.blockName)
+ );
+
+ const { navigate, setScope } = createDriveNavigation({
+ state,
+ setState,
+ folders,
+ results: createDriveResults(view, userId),
+ onNavigate: () => panel.handle.resetPreview(),
+ });
+ const selectTab = (tab: DriveTab) => navigate({ kind: 'tab', tab });
+ const selectFolder = (id: string | null) => navigate({ kind: 'folder', id });
+
+ const initial = driveQuery(state(), userId());
+ view.initialize({
+ initialQuery: props.initialFilters
+ ? mergeQuery(queryStateFrom(initial.filters), props.initialFilters)
+ : initial.filters,
+ initialClientFilters: props.initialClientFilters ?? initial.clientFilters,
+ initialSearchText: view.searchText(),
+ preferInitialFilters: true,
+ sortMethod: () => (isRecent() ? 'touched_by_me' : undefined),
+ persistFilters: false,
+ itemMembershipFilter: (item) => {
+ const id = projectId();
+ return !id || soupItemMatchesProjectMembership(item, id);
+ },
+ });
+ view.soup.grouping.setActiveGroupId(undefined);
+ view.soup.sort.setAll([state().sort]);
+ panel.handle.setDisplayName('Drive');
+ let searchInput: HTMLInputElement | undefined;
+ useViewControlHotkeys({
+ scopeId: panel.splitHotkeyScope,
+ enabled: panel.isPanelActive,
+ search: {
+ description: 'Search Drive',
+ run: () => {
+ searchInput?.focus();
+ searchInput?.select();
+ return true;
+ },
+ },
+ });
+ useViewTabHotkeys({
+ scopeId: panel.splitHotkeyScope,
+ enabled: panel.isPanelActive,
+ ids: () => DRIVE_TABS.map((tab) => tab.id),
+ activeId: () => {
+ const location = state().location;
+ return location.kind === 'tab' ? location.tab : 'owned';
+ },
+ setActiveId: selectTab,
+ });
+
+ const CreateMenu = () => (
+ <Dropdown placement="bottom-start">
+ <Dropdown.Trigger
+ variant="ghost"
+ depth={2}
+ class="h-10 w-full shrink-0 justify-start gap-3 rounded-xl bg-ink/5 px-3"
+ aria-label="New file or folder"
+ >
+ <PlusIcon class="size-4 shrink-0" />
+ <span>New</span>
+ <CaretDownIcon class="ml-auto size-3 shrink-0" />
+ </Dropdown.Trigger>
+ <Dropdown.Content class="min-w-48">
+ <Dropdown.Group>
+ <For each={createOptions()}>
+ {(option) => (
+ <Dropdown.Item
+ onSelect={() =>
+ runCreateAction(option.blockName, {
+ projectId: projectId(),
+ source: 'drive',
+ })
+ }
+ >
+ <span
+ aria-hidden="true"
+ class="flex size-4 shrink-0 items-center justify-center [&_svg]:size-4"
+ >
+ <Dynamic component={option.icon} />
+ </span>
+ <span>{option.label}</span>
+ </Dropdown.Item>
+ )}
+ </For>
+ </Dropdown.Group>
+ <Dropdown.Group>
+ <Dropdown.Item
+ onSelect={() =>
+ openFilePicker({ multiple: true }, async (files) => {
+ await upload(files, false);
+ })
+ }
+ >
+ <UploadIcon aria-hidden="true" class="size-4 shrink-0" />
+ <span>Upload files</span>
+ </Dropdown.Item>
+ <Dropdown.Item
+ onSelect={() =>
+ openFolderPicker({}, async (files) => {
+ await handleFolderSelect(files, async (entries) => {
+ await upload(entries, false);
+ });
+ })
+ }
+ >
+ <FolderIcon aria-hidden="true" class="size-4 shrink-0" />
+ <span>Upload folder</span>
+ </Dropdown.Item>
+ </Dropdown.Group>
+ </Dropdown.Content>
+ </Dropdown>
+ );
+
+ const Favorites = () => (
+ <ViewSidebar.Nav aria-label="Favorite files and folders">
+ <For each={favorites()}>
+ {(favorite) => (
+ <DriveFavorite
+ favorite={favorite}
+ onOpen={(item) => {
+ if (item.entityType === 'project') selectFolder(item.entityId);
+ else
+ layout.openWithSplit(favoriteSplitContent(item), {
+ referredFrom: 'sidebar',
+ });
+ }}
+ />
+ )}
+ </For>
+ <Show when={favorites().length === 0}>
+ <p class="px-3 py-2 text-sm text-ink-extra-muted">No favorites yet</p>
+ </Show>
+ </ViewSidebar.Nav>
+ );
+
+ return (
+ <DriveLayout
+ state={state()}
+ folders={folders()}
+ foldersLoading={projects.isPending}
+ foldersError={projects.isError}
+ onRetryFolders={() => void projects.refetch()}
+ search={view.searchText()}
+ onSearch={view.setSearchText}
+ searchRef={(element) => {
+ searchInput = element;
+ }}
+ onTab={selectTab}
+ onFolder={selectFolder}
+ onScope={setScope}
+ onSort={(sort) => {
+ setState((current) => ({ ...current, sort }));
+ view.soup.sort.setAll([sort]);
+ }}
+ onToggleFolder={(id) =>
+ setState((current) => ({
+ ...current,
+ expandedFolderIds: current.expandedFolderIds.includes(id)
+ ? current.expandedFolderIds.filter((value) => value !== id)
+ : [...current.expandedFolderIds, id],
+ }))
+ }
+ onFavoritesOpen={(favoritesOpen) =>
+ setState((current) => ({ ...current, favoritesOpen }))
+ }
+ onRootOpen={(rootOpen) =>
+ setState((current) => ({ ...current, rootOpen }))
+ }
+ createMenu={CreateMenu}
+ favorites={Favorites}
+ >
+ <Suspense
+ fallback={
+ <div class="grid size-full place-items-center text-ink-muted">
+ <SpinnerIcon
+ aria-label="Loading files"
+ class="size-5 animate-spin"
+ />
+ </div>
+ }
+ >
+ <SoupViewList
+ emptyState={
+ projectId() && state().scope === 'default'
+ ? () => (
+ <EmptyStatePanel
+ centered
+ graphic={EmptyStateFolderGraphic}
+ title="This folder is empty"
+ description="Create something new or drop files here to add them to this folder."
+ primaryAction={{
+ label: 'Back to Drive',
+ icon: ArrowLeftIcon,
+ onClick: () => selectFolder(null),
+ }}
+ />
+ )
+ : undefined
+ }
+ onOpenProject={selectFolder}
+ uploadProjectId={projectId()}
+ disableTabHotkeys
+ navigationKey={JSON.stringify([state().location, state().scope])}
+ timestamp={isRecent() ? (entity) => entity.touchedAt : undefined}
+ />
+ </Suspense>
+ </DriveLayout>
+ );
+}
diff --git a/apps/web/src/features/drive-view/primitives/drive-navigation.test.ts b/apps/web/src/features/drive-view/primitives/drive-navigation.test.ts
new file mode 100644
index 0000000000..e91fdec00d
--- /dev/null
+++ b/apps/web/src/features/drive-view/primitives/drive-navigation.test.ts
@@ -0,0 +1,49 @@
+import { createRoot, createSignal } from 'solid-js';
+import { describe, expect, it, vi } from 'vitest';
+import type { DriveState } from '../core/types';
+import { createDriveNavigation } from './drive-navigation';
+
+describe('Drive navigation state', () => {
+ it('opens ancestors, clears refinements on navigation, and keeps search when filtering', () =>
+ createRoot((dispose) => {
+ const [state, setState] = createSignal<DriveState>({
+ location: { kind: 'tab', tab: 'shared' },
+ scope: 'attachments',
+ sort: 'created_at',
+ expandedFolderIds: ['unrelated'],
+ favoritesOpen: false,
+ rootOpen: false,
+ });
+ const apply = vi.fn();
+ const onNavigate = vi.fn();
+ const navigation = createDriveNavigation({
+ state,
+ setState,
+ results: { apply },
+ onNavigate,
+ folders: () => [
+ { id: 'parent', name: 'Parent' },
+ { id: 'child', name: 'Child', parentId: 'parent' },
+ ],
+ });
+ navigation.navigate({ kind: 'folder', id: 'child' });
+ expect(state().expandedFolderIds).toEqual([
+ 'unrelated',
+ 'parent',
+ 'child',
+ ]);
+ expect(state()).toMatchObject({
+ scope: 'default',
+ rootOpen: true,
+ favoritesOpen: false,
+ sort: 'created_at',
+ });
+ expect(apply).toHaveBeenLastCalledWith(state(), true);
+ expect(onNavigate).toHaveBeenCalledOnce();
+ navigation.navigate({ kind: 'tab', tab: 'recent' });
+ expect(state().location).toEqual({ kind: 'tab', tab: 'recent' });
+ navigation.setScope('attachments');
+ expect(apply).toHaveBeenLastCalledWith(state(), false);
+ dispose();
+ }));
+});
diff --git a/apps/web/src/features/drive-view/primitives/drive-navigation.ts b/apps/web/src/features/drive-view/primitives/drive-navigation.ts
new file mode 100644
index 0000000000..e7e4f069d7
--- /dev/null
+++ b/apps/web/src/features/drive-view/primitives/drive-navigation.ts
@@ -0,0 +1,48 @@
+import { type Accessor, batch, type Setter } from 'solid-js';
+import type { DriveResults } from '../context/drive-source';
+import { folderAncestors } from '../core/folder-tree';
+import type {
+ DriveFolder,
+ DriveLocation,
+ DriveScope,
+ DriveState,
+} from '../core/types';
+
+export function createDriveNavigation(options: {
+ state: Accessor<DriveState>;
+ setState: Setter<DriveState>;
+ folders: Accessor<DriveFolder[]>;
+ results: DriveResults;
+ onNavigate: () => void;
+}) {
+ const navigate = (location: DriveLocation) => {
+ const ancestors =
+ location.kind === 'folder' && location.id
+ ? folderAncestors(options.folders(), location.id).map(
+ (folder) => folder.id
+ )
+ : [];
+ const current = options.state();
+ const next: DriveState = {
+ ...current,
+ location,
+ scope: 'default',
+ rootOpen: true,
+ expandedFolderIds: [
+ ...new Set([...current.expandedFolderIds, ...ancestors]),
+ ],
+ };
+ batch(() => {
+ options.setState(next);
+ options.results.apply(next, true);
+ options.onNavigate();
+ });
+ };
+ const setScope = (scope: DriveScope) =>
+ batch(() => {
+ const next = { ...options.state(), scope };
+ options.setState(next);
+ options.results.apply(next, false);
+ });
+ return { navigate, setScope };
+}
diff --git a/apps/web/src/features/drive-view/queries/drive-query.test.ts b/apps/web/src/features/drive-view/queries/drive-query.test.ts
new file mode 100644
index 0000000000..a55cf40345
--- /dev/null
+++ b/apps/web/src/features/drive-view/queries/drive-query.test.ts
@@ -0,0 +1,72 @@
+import { describe, expect, it, vi } from 'vitest';
+
+vi.mock('@core/constant/featureFlags', () => ({
+ enableCalendarUi: {},
+ enableReminders: {},
+ enableSnippets: {},
+ enableSupportedSoupForeignEntities: {},
+ isCalendarSearchUiEnabled: () => false,
+ isFeatureEnabled: () => false,
+}));
+
+import {
+ compileToAst,
+ queryStateFrom,
+} from '@app/features/next-soup/filters/filter-store';
+import type { DriveSelection } from '../context/drive-source';
+import { driveQuery } from './drive-query';
+
+const selection: DriveSelection = {
+ location: { kind: 'tab', tab: 'owned' },
+ scope: 'default',
+ sort: 'updated_at',
+};
+
+describe('Drive query scopes', () => {
+ it('keeps owned/shared scopes and excludes tasks and disabled snippets', () => {
+ const owned = driveQuery(selection, 'me');
+ expect(owned.filters.include?.documentOwnerId).toEqual(['me']);
+ expect(owned.filters.exclude?.subType).toEqual(['task', 'snippet']);
+ const shared = driveQuery(
+ { ...selection, location: { kind: 'tab', tab: 'shared' } },
+ 'me'
+ );
+ expect(shared.filters.exclude?.documentOwnerId).toEqual(['me']);
+ expect(shared.clientFilters.and).toContain('shared-entity');
+ });
+ it('allows all files and attachments without retaining the owned restriction', () => {
+ const all = driveQuery({ ...selection, scope: 'all' }, 'me');
+ expect(all.filters.include?.documentOwnerId).toBeUndefined();
+ const attachments = driveQuery(
+ { ...selection, scope: 'attachments' },
+ 'me'
+ );
+ expect(attachments.filters.include?.isEmailAttachment).toBe(true);
+ expect(attachments.filters.include?.documentOwnerId).toBeUndefined();
+ });
+ it('scopes every supported folder entity type to the selected folder', () => {
+ const folder = driveQuery(
+ { ...selection, location: { kind: 'folder', id: 'folder' } },
+ 'me'
+ );
+ expect(folder.filters.include).toMatchObject({
+ projectId: ['folder'],
+ chatProjectId: ['folder'],
+ folderId: ['folder'],
+ emailProjectId: ['folder'],
+ });
+ expect(folder.filters.emailView).toBe('all');
+ expect(folder.clientFilters).toEqual({});
+ });
+ it('keeps Recent compatible with the touched feed and restricts display to files', () => {
+ const recent = driveQuery(
+ { ...selection, location: { kind: 'tab', tab: 'recent' } },
+ 'me'
+ );
+ const ast = compileToAst(queryStateFrom(recent.filters));
+ expect(ast.chanf).toBeUndefined();
+ expect(ast.ef).toBeUndefined();
+ expect(recent.clientFilters.and).toEqual(['document-or-file']);
+ expect(recent.filters.exclude?.subType).toContain('task');
+ });
+});
diff --git a/apps/web/src/features/drive-view/queries/drive-query.ts b/apps/web/src/features/drive-view/queries/drive-query.ts
new file mode 100644
index 0000000000..d138e4e754
--- /dev/null
+++ b/apps/web/src/features/drive-view/queries/drive-query.ts
@@ -0,0 +1,71 @@
+import {
+ defineQueryFilters,
+ type Query,
+} from '@app/features/next-soup/filters/filter-store';
+import { getViewPreset } from '@app/features/next-soup/sidebar/soup-filter-presets';
+import type { DriveSelection } from '../context/drive-source';
+
+export function driveQuery(state: DriveSelection, userId: string | undefined) {
+ const context = { userId, isTeamAdmin: false };
+ const location = state.location;
+ if (location.kind === 'folder') {
+ if (!location.id) return getViewPreset('documents', 'folders', context)!;
+ return {
+ filters: defineQueryFilters({
+ include: {
+ projectId: [location.id],
+ chatProjectId: [location.id],
+ folderId: [location.id],
+ emailProjectId: [location.id],
+ },
+ emailView: 'all',
+ }),
+ clientFilters: {},
+ };
+ }
+ if (location.tab === 'recent') {
+ const recent = getViewPreset('recent', undefined, context)!;
+ const files = getViewPreset('documents', 'all', context)!;
+ return {
+ filters: {
+ ...recent.filters,
+ exclude: {
+ ...recent.filters.exclude,
+ subType: files.filters.exclude?.subType,
+ },
+ include: {
+ ...recent.filters.include,
+ isEmailAttachment:
+ state.scope === 'all' ? undefined : state.scope === 'attachments',
+ },
+ } satisfies Query,
+ clientFilters: { and: ['document-or-file'] },
+ };
+ }
+ const tab =
+ location.tab === 'owned' && state.scope !== 'default'
+ ? state.scope
+ : location.tab;
+ const preset =
+ getViewPreset('documents', tab, context) ??
+ getViewPreset('documents', 'all', context)!;
+ if (state.scope === 'attachments') {
+ return {
+ ...preset,
+ filters: {
+ ...preset.filters,
+ include: { ...preset.filters.include, isEmailAttachment: true },
+ },
+ };
+ }
+ if (state.scope === 'all') {
+ return {
+ ...preset,
+ filters: {
+ ...preset.filters,
+ include: { ...preset.filters.include, isEmailAttachment: undefined },
+ },
+ };
+ }
+ return preset;
+}
diff --git a/apps/web/src/features/drive-view/queries/drive-results.ts b/apps/web/src/features/drive-view/queries/drive-results.ts
new file mode 100644
index 0000000000..287a3318ef
--- /dev/null
+++ b/apps/web/src/features/drive-view/queries/drive-results.ts
@@ -0,0 +1,27 @@
+import type { useSoupView } from '@app/features/next-soup/soup-view/soup-view-context';
+import type { Accessor } from 'solid-js';
+import type { DriveResults } from '../context/drive-source';
+import { driveQuery } from './drive-query';
+
+export function createDriveResults(
+ view: ReturnType<typeof useSoupView>,
+ userId: Accessor<string | undefined>
+): DriveResults {
+ return {
+ apply(selection, clearSearch) {
+ const preset = driveQuery(selection, userId());
+ view.setActiveTab(
+ selection.location.kind === 'tab' && selection.location.tab !== 'recent'
+ ? selection.location.tab
+ : 'all'
+ );
+ view.queryFilters.replace(preset.filters);
+ view.soup.predicates.set(preset.clientFilters);
+ view.soup.grouping.setActiveGroupId(undefined);
+ view.soup.sort.setAll([selection.sort]);
+ view.soup.selection.clear();
+ view.soup.focus.clear();
+ if (clearSearch) view.setSearchText('');
+ },
+ };
+}
diff --git a/apps/web/src/features/drive-view/views/drive-layout.tsx b/apps/web/src/features/drive-view/views/drive-layout.tsx
new file mode 100644
index 0000000000..485c940b04
--- /dev/null
+++ b/apps/web/src/features/drive-view/views/drive-layout.tsx
@@ -0,0 +1,375 @@
+import {
+ CollapsibleSection,
+ ListFilterDropdown,
+ ListSortDropdown,
+ SearchBar,
+ ViewShell,
+ ViewSidebar,
+} from '@app/components/view-shell';
+import { SplitPanel } from '@components/app/split-panel';
+import CaretDownIcon from '@phosphor/caret-down.svg';
+import CaretRightIcon from '@phosphor/caret-right.svg';
+import FolderIcon from '@phosphor/folder.svg';
+import SearchIcon from '@phosphor/magnifying-glass.svg';
+import { Button, cn, Dropdown } from '@ui';
+import { createMemo, createSignal, For, type JSX, Show } from 'solid-js';
+import { DriveNavigation } from '../components/drive-navigation';
+import { FolderTree } from '../components/folder-tree';
+import {
+ buildFolderTree,
+ filterFolderTree,
+ folderAncestors,
+} from '../core/folder-tree';
+import {
+ DRIVE_TABS,
+ type DriveFolder,
+ type DriveScope,
+ type DriveSort,
+ type DriveState,
+ type DriveTab,
+} from '../core/types';
+
+export function DriveLayout(props: {
+ state: DriveState;
+ folders: DriveFolder[];
+ foldersLoading: boolean;
+ foldersError: boolean;
+ onRetryFolders: () => void;
+ search: string;
+ onSearch: (value: string) => void;
+ searchRef: (element: HTMLInputElement) => void;
+ onTab: (tab: DriveTab) => void;
+ onFolder: (id: string | null) => void;
+ onScope: (scope: DriveScope) => void;
+ onSort: (sort: DriveSort) => void;
+ onToggleFolder: (id: string) => void;
+ onFavoritesOpen: (open: boolean) => void;
+ onRootOpen: (open: boolean) => void;
+ createMenu: () => JSX.Element;
+ favorites: () => JSX.Element;
+ children: JSX.Element;
+}) {
+ const [folderSearch, setFolderSearch] = createSignal('');
+ const [searchingFolders, setSearchingFolders] = createSignal(false);
+ const [navigationOpen, setNavigationOpen] = createSignal(false);
+ const tree = createMemo(() => buildFolderTree(props.folders));
+ const filteredTree = createMemo(() =>
+ filterFolderTree(tree(), folderSearch())
+ );
+ const selectedFolder = () =>
+ props.state.location.kind === 'folder'
+ ? props.state.location.id
+ : undefined;
+ const breadcrumbs = createMemo(() => {
+ const id = selectedFolder();
+ return id ? folderAncestors(props.folders, id) : [];
+ });
+ const title = () =>
+ props.state.location.kind === 'folder'
+ ? (breadcrumbs().at(-1)?.name ?? 'Drive')
+ : (DRIVE_TABS.find(
+ (tab) =>
+ props.state.location.kind === 'tab' &&
+ tab.id === props.state.location.tab
+ )?.label ?? 'My Files');
+
+ const SidebarContent = () => (
+ <>
+ <DriveNavigation
+ location={props.state.location}
+ onNavigate={(tab) => {
+ props.onTab(tab);
+ setNavigationOpen(false);
+ }}
+ />
+ <CollapsibleSection.Root
+ open={props.state.favoritesOpen}
+ onOpenChange={props.onFavoritesOpen}
+ >
+ <CollapsibleSection.Trigger class="text-xs">
+ <CollapsibleSection.Indicator class="order-first ml-0" />
+ Favorites
+ </CollapsibleSection.Trigger>
+ <CollapsibleSection.Content>
+ <props.favorites />
+ </CollapsibleSection.Content>
+ </CollapsibleSection.Root>
+ <section aria-label="Folders" class="min-w-0">
+ <div class="mb-3 flex h-7 items-center justify-between px-3 text-xs text-ink-muted">
+ <span>Folders</span>
+ <Button
+ variant="ghost"
+ size="sm"
+ square
+ class="size-7 rounded-lg"
+ aria-label="Search folders"
+ onClick={() => {
+ setSearchingFolders((value) => !value);
+ setFolderSearch('');
+ }}
+ >
+ <SearchIcon class="size-4" />
+ </Button>
+ </div>
+ <Show when={searchingFolders()}>
+ <SearchBar
+ label="Search folders"
+ placeholder="Search folders"
+ value={folderSearch()}
+ onValueChange={setFolderSearch}
+ class="mb-2"
+ />
+ </Show>
+ <div
+ class={cn(
+ 'flex min-w-0 items-center rounded-xl',
+ selectedFolder() === null ? 'bg-active' : 'hover:bg-hover'
+ )}
+ >
+ <Button
+ variant="ghost"
+ size="sm"
+ square
+ class="size-6 shrink-0 rounded-lg not-disabled:hover:bg-transparent not-disabled:hover:bg-none not-disabled:active:bg-none"
+ aria-label={
+ props.state.rootOpen
+ ? 'Collapse Drive folders'
+ : 'Expand Drive folders'
+ }
+ aria-expanded={props.state.rootOpen}
+ onClick={() => props.onRootOpen(!props.state.rootOpen)}
+ >
+ <CaretRightIcon
+ class={cn(
+ 'size-3 transition-transform',
+ props.state.rootOpen && 'rotate-90'
+ )}
+ />
+ </Button>
+ <ViewSidebar.Item
+ class={cn(
+ 'min-w-0 flex-1 px-2 font-normal bg-transparent not-disabled:hover:bg-transparent not-disabled:hover:bg-none not-disabled:active:bg-none',
+ selectedFolder() === null && 'text-ink'
+ )}
+ aria-current={selectedFolder() === null ? 'page' : undefined}
+ onClick={() => {
+ props.onFolder(null);
+ setNavigationOpen(false);
+ }}
+ >
+ <FolderIcon class="size-4 shrink-0" />
+ <span>Drive</span>
+ </ViewSidebar.Item>
+ </div>
+ <Show when={props.state.rootOpen || folderSearch().trim()}>
+ <div class="ml-3 border-l border-edge pl-3">
+ <Show
+ when={!props.foldersLoading}
+ fallback={
+ <p role="status" class="px-3 py-2 text-sm text-ink-extra-muted">
+ Loading folders…
+ </p>
+ }
+ >
+ <Show
+ when={!props.foldersError}
+ fallback={
+ <div class="p-3 text-sm text-ink-muted">
+ Folders couldn’t be loaded.
+ <Button variant="ghost" onClick={props.onRetryFolders}>
+ Try again
+ </Button>
+ </div>
+ }
+ >
+ <FolderTree
+ nodes={filteredTree()}
+ selectedId={selectedFolder()}
+ expandedIds={props.state.expandedFolderIds}
+ searching={!!folderSearch().trim()}
+ onToggle={props.onToggleFolder}
+ onSelect={(id) => {
+ props.onFolder(id);
+ setNavigationOpen(false);
+ }}
+ />
+ <Show when={filteredTree().length === 0}>
+ <p class="px-3 py-2 text-sm text-ink-extra-muted">
+ {folderSearch() ? 'No matching folders' : 'No folders yet'}
+ </p>
+ </Show>
+ </Show>
+ </Show>
+ </div>
+ </Show>
+ </section>
+ </>
+ );
+
+ return (
+ <SplitPanel.Root>
+ <SplitPanel.Body>
+ <ViewShell.Root
+ resizable
+ aside={{ preserveDuringResize: false }}
+ main={{ preferredWidth: 640 }}
+ >
+ <ViewShell.Aside>
+ <ViewSidebar.Root
+ aria-label="Drive navigation"
+ class="gap-4 bg-panel"
+ >
+ <ViewSidebar.Header>
+ <div class="flex min-w-0 items-center gap-1">
+ <SplitPanel.CloseButton />
+ <ViewSidebar.Title>Drive</ViewSidebar.Title>
+ </div>
+ <SplitPanel.ControlGroup>
+ <SplitPanel.BackButton />
+ <SplitPanel.ForwardButton />
+ </SplitPanel.ControlGroup>
+ </ViewSidebar.Header>
+ <ViewSidebar.Content class="flex flex-col gap-6">
+ <props.createMenu />
+ <SidebarContent />
+ </ViewSidebar.Content>
+ </ViewSidebar.Root>
+ </ViewShell.Aside>
+ <ViewShell.Main>
+ <ViewShell.TopBar class="touch:flex">
+ <Show
+ when={props.state.location.kind === 'folder'}
+ fallback={title()}
+ >
+ <span
+ role="navigation"
+ aria-label="Folder breadcrumbs"
+ class="inline-flex max-w-full items-center gap-1 overflow-x-auto align-middle"
+ >
+ <Button
+ variant="ghost"
+ size="sm"
+ class="text-sm font-semibold tracking-[-0.03em] text-ink"
+ onClick={() => props.onFolder(null)}
+ >
+ Drive
+ </Button>
+ <For each={breadcrumbs()}>
+ {(folder) => (
+ <>
+ <span
+ aria-hidden="true"
+ class="shrink-0 text-ink-extra-muted"
+ >
+ /
+ </span>
+ <Button
+ variant="ghost"
+ size="sm"
+ class="max-w-48 shrink-0 truncate rounded-md px-1.5 text-sm font-semibold tracking-[-0.03em] text-ink"
+ title={folder.name}
+ onClick={() => props.onFolder(folder.id)}
+ >
+ {folder.name}
+ </Button>
+ </>
+ )}
+ </For>
+ </span>
+ </Show>
+ </ViewShell.TopBar>
+ <ViewShell.Header>
+ <div class="flex min-w-0 flex-col gap-3">
+ <div class="hidden min-w-0 items-center gap-2 @max-[720px]/view-shell:flex">
+ <SplitPanel.ControlGroup>
+ <SplitPanel.CloseButton />
+ <SplitPanel.BackButton />
+ <SplitPanel.ForwardButton />
+ </SplitPanel.ControlGroup>
+ <Dropdown
+ open={navigationOpen()}
+ onOpenChange={setNavigationOpen}
+ placement="bottom-start"
+ >
+ <Dropdown.Trigger
+ variant="ghost"
+ class="min-w-0 gap-1 rounded-lg text-lg font-semibold"
+ aria-label="Select Drive view"
+ >
+ <span class="truncate">{title()}</span>
+ <CaretDownIcon class="size-3 shrink-0" />
+ </Dropdown.Trigger>
+ <Dropdown.Content class="max-h-[70vh] w-72 overflow-auto rounded-2xl p-3">
+ <div class="flex flex-col gap-5">
+ <SidebarContent />
+ </div>
+ </Dropdown.Content>
+ </Dropdown>
+ <div class="ml-auto shrink-0">
+ <props.createMenu />
+ </div>
+ </div>
+ <div class="flex min-w-0 items-center justify-between gap-3">
+ <SearchBar
+ ref={props.searchRef}
+ label="Search Drive"
+ placeholder={
+ selectedFolder() ? 'Search this folder' : 'Search files'
+ }
+ value={props.search}
+ onValueChange={props.onSearch}
+ hotkey="cmd+f"
+ class="max-w-md flex-1"
+ />
+ <div class="flex shrink-0 items-center gap-2">
+ <Show
+ when={
+ !(
+ props.state.location.kind === 'tab' &&
+ props.state.location.tab === 'recent'
+ )
+ }
+ >
+ <ListSortDropdown
+ label="Sort files"
+ value={props.state.sort}
+ onChange={props.onSort}
+ options={[
+ { id: 'updated_at', label: 'Last modified' },
+ { id: 'created_at', label: 'Created' },
+ { id: 'viewed_at', label: 'Last viewed' },
+ ]}
+ />
+ </Show>
+ <Show when={props.state.location.kind === 'tab'}>
+ <ListFilterDropdown
+ label="Filter files"
+ groups={[
+ {
+ id: 'scope',
+ label: 'Files',
+ selectionMode: 'single',
+ defaultOptionId: 'default',
+ options: [
+ { id: 'default', label: 'Default' },
+ { id: 'all', label: 'All files' },
+ { id: 'attachments', label: 'Email attachments' },
+ ],
+ },
+ ]}
+ isSelected={(_, id) => props.state.scope === id}
+ onSelectionChange={(_, id) => props.onScope(id)}
+ onClear={() => props.onScope('default')}
+ />
+ </Show>
+ </div>
+ </div>
+ </div>
+ </ViewShell.Header>
+ <ViewShell.Content>{props.children}</ViewShell.Content>
+ </ViewShell.Main>
+ </ViewShell.Root>
+ </SplitPanel.Body>
+ </SplitPanel.Root>
+ );
+}
diff --git a/apps/web/src/features/next-soup/soup-view/soup-view-context.tsx b/apps/web/src/features/next-soup/soup-view/soup-view-context.tsx
index a128312073..20c3a259f3 100644
--- a/apps/web/src/features/next-soup/soup-view/soup-view-context.tsx
+++ b/apps/web/src/features/next-soup/soup-view/soup-view-context.tsx
@@ -137,6 +137,10 @@ type DataSource<T> = {
};
type SoupViewInitializeOptions = {
+ /** Composed views can keep their own state without overwriting legacy tab preferences. */
+ persistFilters?: boolean;
+ /** A composed view may own its ordering independently of legacy tabs. */
+ sortMethod?: Accessor<NonNullable<SoupParams['sort_method']> | undefined>;
initialQuery?: Query;
initialClientFilters?: SetPredicatesInput<string>;
initialSearchText?: string;
@@ -322,10 +326,14 @@ export const SoupViewContextProvider: FlowComponent<
disableLocalSearch: props.disableLocalSearch,
additionalEntities: props.additionalEntities,
itemMembershipFilter: props.itemMembershipFilter,
+ sortMethod: props.sortMethod,
+ persistFilters: props.persistFilters,
});
const queryClient = useQueryClient();
- const [filterPersistenceEnabled] = useSoupFilterPersistence();
+ const [persistFilterPreference] = useSoupFilterPersistence();
+ const filterPersistenceEnabled = () =>
+ config().persistFilters !== false && persistFilterPreference();
const panel = useSplitPanelOrThrow();
@@ -694,7 +702,7 @@ export const SoupViewContextProvider: FlowComponent<
});
const presetSortMethod = () => {
- const method = activePreset()?.sortMethod;
+ const method = config().sortMethod?.() ?? activePreset()?.sortMethod;
return method === 'notified_at' && !notifiedSortFF().enabled
? 'updated_at'
: method;
@@ -732,7 +740,9 @@ export const SoupViewContextProvider: FlowComponent<
const clientSort = createMemo((): SortConfig<SoupEntity>[] =>
presetSortMethod() === 'notified_at'
? [SORT_CONFIGS.notified_at]
- : soup.sort.active()
+ : config().sortMethod?.() === 'touched_by_me'
+ ? []
+ : soup.sort.active()
);
// Active deal-stage set (team-customized when present). Drives the
diff --git a/apps/web/src/features/next-soup/soup-view/soup-view-file-dropzone.tsx b/apps/web/src/features/next-soup/soup-view/soup-view-file-dropzone.tsx
index 0fc933436d..9b30669455 100644
--- a/apps/web/src/features/next-soup/soup-view/soup-view-file-dropzone.tsx
+++ b/apps/web/src/features/next-soup/soup-view/soup-view-file-dropzone.tsx
@@ -6,11 +6,17 @@ import { createSignal, type FlowComponent, Show } from 'solid-js';
false && fileFolderDrop;
-export const SoupViewFileDropzone: FlowComponent = (props) => {
+export const SoupViewFileDropzone: FlowComponent<{ projectId?: string }> = (
+ props
+) => {
const [isDragging, setIsDragging] = createSignal(false);
const [isValidDrag, setIsValidDrag] = createSignal(true);
- const handleFileUpload = useHandleFileUpload();
+ const handleFileUpload = useHandleFileUpload({
+ get projectId() {
+ return props.projectId;
+ },
+ });
return (
<div
diff --git a/apps/web/src/features/next-soup/soup-view/soup-view.tsx b/apps/web/src/features/next-soup/soup-view/soup-view.tsx
index 67024f75c5..0df2248d1a 100644
--- a/apps/web/src/features/next-soup/soup-view/soup-view.tsx
+++ b/apps/web/src/features/next-soup/soup-view/soup-view.tsx
@@ -89,6 +89,7 @@ import {
import { registerHotkey, useHotkeyDOMScope } from '@core/hotkey/hotkeys';
import { TOKENS } from '@core/hotkey/tokens';
import { isTouchDevice } from '@core/mobile/isTouchDevice';
+import type { DateValue } from '@core/util/date';
import { openExternalUrl } from '@core/util/url';
import { useIsKeyPressActive } from '@core/util/useIsKeyPressActive';
import {
@@ -790,6 +791,13 @@ export const SoupView = (props: SoupViewProps) => {
};
interface SoupViewListProps {
+ emptyState?: () => JSX.Element;
+ timestamp?: (entity: EntityData) => DateValue | null | undefined;
+ navigationKey?: string;
+ /** Composed folder browsers keep ordinary folder activation in their pane. */
+ onOpenProject?: (id: string) => void;
+ uploadProjectId?: string;
+ disableTabHotkeys?: boolean;
customScrollbarHidden?: boolean;
scopeId?: string;
}
@@ -803,6 +811,12 @@ export const SoupViewList = (props: SoupViewListProps) => (
<SoupViewListContent
customScrollbarHidden={props.customScrollbarHidden}
scopeId={props.scopeId}
+ onOpenProject={props.onOpenProject}
+ uploadProjectId={props.uploadProjectId}
+ disableTabHotkeys={props.disableTabHotkeys}
+ timestamp={props.timestamp}
+ navigationKey={props.navigationKey}
+ emptyState={props.emptyState}
/>
</SoupRowMetadataProvider>
);
@@ -988,6 +1002,8 @@ const SoupViewListContent = (props: SoupViewListProps) => {
activeTab,
applyTabPreset,
fetchNextGroupPage,
+ onOpenProject: props.onOpenProject,
+ disableTabHotkeys: props.disableTabHotkeys,
});
// Create markDone action for swipe/click handlers
@@ -1026,6 +1042,18 @@ const SoupViewListContent = (props: SoupViewListProps) => {
type === 'entity' ? args.entity : args.projectEntity
) as EntityData;
+ if (
+ entity.type === 'project' &&
+ props.onOpenProject &&
+ !event.metaKey &&
+ !event.ctrlKey &&
+ !event.shiftKey &&
+ !event.altKey
+ ) {
+ props.onOpenProject(entity.id);
+ return;
+ }
+
markReminderSeenOnOpen(entity, notificationSource);
// FIXME: this never gets called because we have overrides
@@ -1295,6 +1323,16 @@ const SoupViewListContent = (props: SoupViewListProps) => {
registerFocusEffects(!panel.handle.isControllerSplit());
};
+ createEffect(
+ on(
+ () => props.navigationKey,
+ () => {
+ virtualizerHandle()?.scrollTo(0);
+ },
+ { defer: true }
+ )
+ );
+
const registerVirtualizerHandler = (
handle: VirtualizerHandle | undefined
) => {
@@ -1321,7 +1359,7 @@ const SoupViewListContent = (props: SoupViewListProps) => {
data-soup-view
data-soup-view-id={panel.handle.id}
>
- <SoupViewFileDropzone>
+ <SoupViewFileDropzone projectId={props.uploadProjectId}>
<div class="@container/u-list size-full unified-list-root flex flex-col relative no-select-children">
<Show
when={
@@ -1377,13 +1415,20 @@ const SoupViewListContent = (props: SoupViewListProps) => {
ref={setEmptyStateRef}
class="flex-1 min-h-0 flex flex-col touch:pb-(--mobile-content-inset-bottom)"
>
- <EmptyState
- listView={currentView()}
- search={!!searchText()}
- hasRefinementsFromBase={hasActiveRefinements()}
- hasHiddenItems={hasHiddenItems()}
- onClearFilters={resetToTabDefaults}
- />
+ <Show
+ when={!searchText() && props.emptyState}
+ fallback={
+ <EmptyState
+ listView={currentView()}
+ search={!!searchText()}
+ hasRefinementsFromBase={hasActiveRefinements()}
+ hasHiddenItems={hasHiddenItems()}
+ onClearFilters={resetToTabDefaults}
+ />
+ }
+ >
+ {(emptyState) => emptyState()()}
+ </Show>
</div>
</Match>
<Match when={rows().length}>
@@ -1434,6 +1479,8 @@ const SoupViewListContent = (props: SoupViewListProps) => {
>
{(row, i) => {
const timestamp = () => {
+ if (props.timestamp)
+ return props.timestamp(row.original) ?? undefined;
const sort_ = clientSort();
// The notified order shows when you were told,
// ahead of the row's own recency stamp.
diff --git a/apps/web/src/features/next-soup/soup-view/use-soup-view-hotkeys.ts b/apps/web/src/features/next-soup/soup-view/use-soup-view-hotkeys.ts
index dc1a81c0e2..694a2e9a9d 100644
--- a/apps/web/src/features/next-soup/soup-view/use-soup-view-hotkeys.ts
+++ b/apps/web/src/features/next-soup/soup-view/use-soup-view-hotkeys.ts
@@ -31,6 +31,8 @@ import {
} from './soup-view-tabs';
type UseSoupViewHotkeysOptions = {
+ onOpenProject?: (id: string) => void;
+ disableTabHotkeys?: boolean;
scopeId: string;
soup: SoupState;
splitHandle: SplitHandle;
@@ -180,6 +182,11 @@ export const useSoupViewHotkeys = (options: UseSoupViewHotkeysOptions) => {
const entity = soup.focus.item();
if (!entity) return false;
+ if (entity.type === 'project' && options.onOpenProject) {
+ options.onOpenProject(entity.id);
+ return true;
+ }
+
const contentHitData = isSearchEntity(entity)
? entity.search.contentHitData
: undefined;
@@ -363,6 +370,7 @@ export const useSoupViewHotkeys = (options: UseSoupViewHotkeysOptions) => {
const visibleViewTabs = useVisibleViewTabs();
const getTabKeys = () => {
+ if (options.disableTabHotkeys) return [];
const view = currentView();
if (!view || !isTabbedView(view)) return [];
return visibleViewTabs(view).map((t) => t.value);
diff --git a/apps/web/src/lib/core/util/create.ts b/apps/web/src/lib/core/util/create.ts
index 0b285c8c7a..32f5646238 100644
--- a/apps/web/src/lib/core/util/create.ts
+++ b/apps/web/src/lib/core/util/create.ts
@@ -299,8 +299,10 @@ export async function createCodeFileFromText({
language,
title,
source,
+ projectId,
}: {
code: string;
+ projectId?: string;
title?: string;
extension?: CodeFileExtension;
language?: string;
@@ -344,6 +346,7 @@ export async function createCodeFileFromText({
const mimeType = 'text/plain';
const maybeCode = await storageServiceClient.createDocument({
+ projectId,
documentName: title ?? 'New Code File',
fileType: finalExtension,
sha: sha,
diff --git a/apps/web/src/lib/utils/handleFileUpload.ts b/apps/web/src/lib/utils/handleFileUpload.ts
index 088c1789d5..9bd77b7875 100644
--- a/apps/web/src/lib/utils/handleFileUpload.ts
+++ b/apps/web/src/lib/utils/handleFileUpload.ts
@@ -5,16 +5,12 @@ import { type UploadInput, uploadFiles } from '@core/util/upload';
import { refetchHistory } from '@queries/history/history';
import { refetchSoupEntity } from '@queries/soup/cache';
-export function useHandleFileUpload({
- projectId,
-}: {
- projectId?: string;
-} = {}) {
+export function useHandleFileUpload(options: { projectId?: string } = {}) {
const { replaceOrInsertSplit, openWithSplit } = useSplitLayout();
return async (files: UploadInput[], withOpen = true) => {
const results = await uploadFiles(files, 'dss', {
- projectId,
+ projectId: options.projectId,
});
const notFailedUploads = results.filter((result) => !result.failed);
diff --git a/docs/AGENT_GUIDE/surfaces.md b/docs/AGENT_GUIDE/surfaces.md
index ea50060430..082868c59b 100644
--- a/docs/AGENT_GUIDE/surfaces.md
+++ b/docs/AGENT_GUIDE/surfaces.md
@@ -236,6 +236,25 @@ copy, and move-to-folder actions are not offered on agent-session search rows.
Tabs `Owned` / `Shared` / `Attachments` / `Folders` / `All`; `New` menu; rows show title,
tags, updated time. Clicking a row opens the doc.
+With `enable-new-app-views` enabled, Files opens **Drive** using the same
+shell as Tasks. The sidebar contains `New file or folder`, `My Files`, `Recent`,
+`Shared with me`, collapsible Favorites, and a searchable folder hierarchy.
+The `Drive` folder row opens the folder overview. Click a folder name to browse
+its contents in the main pane; its separate expand/collapse button reveals child
+folders without navigating. Folder breadcrumbs in the top bar use `/` separators
+and navigate to ancestors. Empty folders show `This folder is empty` and a
+`Back to Drive` action that returns to the folder overview. Folder
+search retains matching descendants' ancestors and reveals their branches.
+
+`Search Drive` searches the current tab or folder. `Filter files` includes all-files
+and email-attachment scopes; `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
+selection and context menus; ordinary folder clicks and Enter browse inside Drive,
+while modified clicks retain existing split navigation. On narrow layouts, use
+`Select Drive view` for tabs, favorites, and folders. Navigation state and expanded
+folders are restored when returning from an opened file.
+
## Calendar — `/app/calendar/view`
Calendars default to Day on phones and Week on desktop. The selected view is
diff --git a/flake.nix b/flake.nix
index 24aa0fd121..ea8251502f 100644
--- a/flake.nix
+++ b/flake.nix
@@ -12,4 +12,4 @@
};
outputs = inputs: inputs.flake-parts.lib.mkFlake { inherit inputs; } (inputs.import-tree ./nix);
-}
+}
\ No newline at end of file
diff --git a/rules/ast-grep/ts-feature-components-presentational.yml b/rules/ast-grep/ts-feature-components-presentational.yml
index ce5f8bd23a..ed9049b98d 100644
--- a/rules/ast-grep/ts-feature-components-presentational.yml
+++ b/rules/ast-grep/ts-feature-components-presentational.yml
@@ -13,6 +13,7 @@ note: |-
untyped wire JSON for property-changed rows.
files:
- apps/web/src/features/activity/components/**
+ - apps/web/src/features/drive-view/components/**
- apps/web/src/features/email-message/components/**
- apps/web/src/features/email-thread/components/**
- apps/web/src/features/email-compose/components/**
diff --git a/rules/ast-grep/ts-feature-core-pure.yml b/rules/ast-grep/ts-feature-core-pure.yml
index f2656b9144..ebf792749e 100644
--- a/rules/ast-grep/ts-feature-core-pure.yml
+++ b/rules/ast-grep/ts-feature-core-pure.yml
@@ -15,6 +15,7 @@ note: |-
The shared @core/util/base64 codec is also pure and may be reused by email.
files:
- apps/web/src/features/activity/core/**
+ - apps/web/src/features/drive-view/core/**
- apps/web/src/features/email-message/core/**
- apps/web/src/features/email-thread/core/**
- apps/web/src/features/email-compose/core/**
diff --git a/rules/ast-grep/ts-feature-data-no-ui.yml b/rules/ast-grep/ts-feature-data-no-ui.yml
index 68f8e2f3b6..5a65a2b28d 100644
--- a/rules/ast-grep/ts-feature-data-no-ui.yml
+++ b/rules/ast-grep/ts-feature-data-no-ui.yml
@@ -12,7 +12,9 @@ note: |-
rendering code.
files:
- apps/web/src/features/activity/queries/**
+ - apps/web/src/features/drive-view/queries/**
- apps/web/src/features/activity/primitives/**
+ - apps/web/src/features/drive-view/primitives/**
- apps/web/src/features/email-message/queries/**
- apps/web/src/features/email-message/primitives/**
- apps/web/src/features/email-thread/queries/**
diff --git a/rules/ast-grep/ts-feature-layers-use-context.yml b/rules/ast-grep/ts-feature-layers-use-context.yml
index 786e378ce7..f445f0992c 100644
--- a/rules/ast-grep/ts-feature-layers-use-context.yml
+++ b/rules/ast-grep/ts-feature-layers-use-context.yml
@@ -15,9 +15,13 @@ note: |-
`files` in each ts-/tsx-feature-* rule.
files:
- apps/web/src/features/activity/components/**
+ - apps/web/src/features/drive-view/components/**
- apps/web/src/features/activity/queries/**
+ - apps/web/src/features/drive-view/queries/**
- apps/web/src/features/activity/primitives/**
+ - apps/web/src/features/drive-view/primitives/**
- apps/web/src/features/activity/views/**
+ - apps/web/src/features/drive-view/views/**
- apps/web/src/features/email-message/components/**
- apps/web/src/features/email-message/queries/**
- apps/web/src/features/email-message/primitives/**
diff --git a/rules/ast-grep/tsx-feature-components-presentational.yml b/rules/ast-grep/tsx-feature-components-presentational.yml
index 22fe899cee..3a97bdefaa 100644
--- a/rules/ast-grep/tsx-feature-components-presentational.yml
+++ b/rules/ast-grep/tsx-feature-components-presentational.yml
@@ -13,6 +13,7 @@ note: |-
untyped wire JSON for property-changed rows.
files:
- apps/web/src/features/activity/components/**
+ - apps/web/src/features/drive-view/components/**
- apps/web/src/features/email-message/components/**
- apps/web/src/features/email-thread/components/**
- apps/web/src/features/email-compose/components/**
diff --git a/rules/ast-grep/tsx-feature-core-pure.yml b/rules/ast-grep/tsx-feature-core-pure.yml
index 94bfd15f94..01d610dc0a 100644
--- a/rules/ast-grep/tsx-feature-core-pure.yml
+++ b/rules/ast-grep/tsx-feature-core-pure.yml
@@ -15,6 +15,7 @@ note: |-
The shared @core/util/base64 codec is also pure and may be reused by email.
files:
- apps/web/src/features/activity/core/**
+ - apps/web/src/features/drive-view/core/**
- apps/web/src/features/email-message/core/**
- apps/web/src/features/email-thread/core/**
- apps/web/src/features/email-compose/core/**
diff --git a/rules/ast-grep/tsx-feature-data-no-ui.yml b/rules/ast-grep/tsx-feature-data-no-ui.yml
index 1d981058ec..a45911b589 100644
--- a/rules/ast-grep/tsx-feature-data-no-ui.yml
+++ b/rules/ast-grep/tsx-feature-data-no-ui.yml
@@ -12,7 +12,9 @@ note: |-
rendering code.
files:
- apps/web/src/features/activity/queries/**
+ - apps/web/src/features/drive-view/queries/**
- apps/web/src/features/activity/primitives/**
+ - apps/web/src/features/drive-view/primitives/**
- apps/web/src/features/email-message/queries/**
- apps/web/src/features/email-message/primitives/**
- apps/web/src/features/email-thread/queries/**
diff --git a/rules/ast-grep/tsx-feature-layers-use-context.yml b/rules/ast-grep/tsx-feature-layers-use-context.yml
index e8bc05ab9f..d6ec50bee8 100644
--- a/rules/ast-grep/tsx-feature-layers-use-context.yml
+++ b/rules/ast-grep/tsx-feature-layers-use-context.yml
@@ -15,9 +15,13 @@ note: |-
`files` in each ts-/tsx-feature-* rule.
files:
- apps/web/src/features/activity/components/**
+ - apps/web/src/features/drive-view/components/**
- apps/web/src/features/activity/queries/**
+ - apps/web/src/features/drive-view/queries/**
- apps/web/src/features/activity/primitives/**
+ - apps/web/src/features/drive-view/primitives/**
- apps/web/src/features/activity/views/**
+ - apps/web/src/features/drive-view/views/**
- apps/web/src/features/email-message/components/**
- apps/web/src/features/email-message/queries/**
- apps/web/src/features/email-message/primitives/**