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(drive-view): add entity detail views (#6513)

dev-rb98c902c1b9da
diff --git a/apps/web/src/components/app/split-layout/components/SplitHeader.tsx b/apps/web/src/components/app/split-layout/components/SplitHeader.tsx
index 71abb15352..e84f0b07cd 100644
--- a/apps/web/src/components/app/split-layout/components/SplitHeader.tsx
+++ b/apps/web/src/components/app/split-layout/components/SplitHeader.tsx
@@ -256,7 +256,7 @@ function SplitDriveReturnButton() {
<Show when={sourceList()?.id === LIST_VIEW_ID.documents}>
<ViewBreadcrumbs.ReturnButton
onClick={returnToDrive}
- title={`Back to ${sourceLabel()}`}
+ tooltip={sourceLabel()}
>
{sourceLabel()}
</ViewBreadcrumbs.ReturnButton>
diff --git a/apps/web/src/components/entity-detail/EntityDetail.tsx b/apps/web/src/components/entity-detail/EntityDetail.tsx
index 0e99cd61ca..54a45db2e7 100644
--- a/apps/web/src/components/entity-detail/EntityDetail.tsx
+++ b/apps/web/src/components/entity-detail/EntityDetail.tsx
@@ -1,11 +1,30 @@
+import { CodeDetail } from '@app/features/drive-view/views/CodeDetail';
+import { ImageDetail } from '@app/features/drive-view/views/ImageDetail';
+import { MarkdownDetail } from '@app/features/drive-view/views/MarkdownDetail';
+import { UnknownDetail } from '@app/features/drive-view/views/UnknownDetail';
+import { VideoDetail } from '@app/features/drive-view/views/VideoDetail';
+import type { MarkdownDocumentKind } from '@block-md/types';
import { useGlobalBlockOrchestrator } from '@components/app/GlobalAppState';
import { PreviewPanel } from '@components/app/PreviewPanel';
import { useSplitPanelOrThrow } from '@components/app/split-layout/layoutUtils';
-import { Match, Switch } from 'solid-js';
+import type { BlockAlias, BlockName } from '@core/block';
+import { fileTypeToBlockName } from '@core/constant/allBlocks';
+import type { AccessLevel } from '@service-storage/generated/schemas/accessLevel';
+import type { DocumentMetadata } from '@service-storage/generated/schemas/documentMetadata';
+import { type JSX, Match, Switch } from 'solid-js';
import type { EntityDetailTarget } from './EntityDetailNavigationStack';
+export type EntityDetailContext = {
+ documentMetadata: DocumentMetadata;
+ userAccessLevel: AccessLevel;
+ blockType: BlockName | BlockAlias;
+};
+
export type EntityDetailProps = {
target: EntityDetailTarget;
+ shareOpen?: boolean;
+ onShareOpenChange?: (open: boolean) => void;
+ children?: (context: EntityDetailContext) => JSX.Element;
};
function PreviewPanelEntityDetail(props: EntityDetailProps) {
@@ -21,9 +40,136 @@ function PreviewPanelEntityDetail(props: EntityDetailProps) {
);
}
+function markdownKind(kind: BlockName | BlockAlias): MarkdownDocumentKind {
+ if (kind === 'task' || kind === 'snippet' || kind === 'skill') return kind;
+ return 'document';
+}
+
+export function entityDetailBlockType(
+ target: EntityDetailTarget
+): BlockName | BlockAlias | undefined {
+ if (target.type !== 'document') return;
+
+ const subType = target.subType?.type;
+ const blockType = fileTypeToBlockName(
+ subType === 'task' || subType === 'snippet' || subType === 'skill'
+ ? subType
+ : target.fileType
+ );
+ if (
+ blockType === 'md' ||
+ blockType === 'task' ||
+ blockType === 'snippet' ||
+ blockType === 'skill' ||
+ blockType === 'code' ||
+ blockType === 'csv' ||
+ blockType === 'image' ||
+ blockType === 'video' ||
+ blockType === 'unknown'
+ ) {
+ return blockType;
+ }
+}
+
export function EntityDetail(props: EntityDetailProps) {
+ const documentTarget = () =>
+ props.target.type === 'document' ? props.target : undefined;
+ const blockType = () => entityDetailBlockType(props.target);
+ const renderChildren = (
+ documentMetadata: DocumentMetadata,
+ userAccessLevel: AccessLevel
+ ) =>
+ props.children?.({
+ documentMetadata,
+ userAccessLevel,
+ blockType: blockType()!,
+ });
+
return (
<Switch>
+ <Match
+ when={
+ blockType() === 'md' ||
+ blockType() === 'task' ||
+ blockType() === 'snippet' ||
+ blockType() === 'skill'
+ ? documentTarget()
+ : undefined
+ }
+ >
+ {(target) => (
+ <MarkdownDetail
+ documentId={target().id}
+ kind={markdownKind(blockType()!)}
+ fallbackName={target().fallbackName}
+ shareOpen={props.shareOpen}
+ onShareOpenChange={props.onShareOpenChange}
+ >
+ {(context) =>
+ renderChildren(
+ context.data.metadata,
+ context.data.userAccessLevel
+ )
+ }
+ </MarkdownDetail>
+ )}
+ </Match>
+ <Match when={blockType() === 'code' || blockType() === 'csv'}>
+ <CodeDetail
+ documentId={props.target.id}
+ shareOpen={props.shareOpen}
+ onShareOpenChange={props.onShareOpenChange}
+ >
+ {(context) =>
+ renderChildren(
+ context.data.documentMetadata,
+ context.data.userAccessLevel
+ )
+ }
+ </CodeDetail>
+ </Match>
+ <Match when={blockType() === 'image'}>
+ <ImageDetail
+ documentId={props.target.id}
+ shareOpen={props.shareOpen}
+ onShareOpenChange={props.onShareOpenChange}
+ >
+ {(context) =>
+ renderChildren(
+ context.data.documentMetadata,
+ context.data.userAccessLevel
+ )
+ }
+ </ImageDetail>
+ </Match>
+ <Match when={blockType() === 'video'}>
+ <VideoDetail
+ documentId={props.target.id}
+ shareOpen={props.shareOpen}
+ onShareOpenChange={props.onShareOpenChange}
+ >
+ {(context) =>
+ renderChildren(
+ context.data.documentMetadata,
+ context.data.userAccessLevel
+ )
+ }
+ </VideoDetail>
+ </Match>
+ <Match when={blockType() === 'unknown'}>
+ <UnknownDetail
+ documentId={props.target.id}
+ shareOpen={props.shareOpen}
+ onShareOpenChange={props.onShareOpenChange}
+ >
+ {(context) =>
+ renderChildren(
+ context.data.documentMetadata,
+ context.data.userAccessLevel
+ )
+ }
+ </UnknownDetail>
+ </Match>
<Match when={true}>
<PreviewPanelEntityDetail target={props.target} />
</Match>
diff --git a/apps/web/src/components/entity-detail/EntityDetailBreadcrumbItem.tsx b/apps/web/src/components/entity-detail/EntityDetailBreadcrumbItem.tsx
new file mode 100644
index 0000000000..80e231f1b0
--- /dev/null
+++ b/apps/web/src/components/entity-detail/EntityDetailBreadcrumbItem.tsx
@@ -0,0 +1,71 @@
+import { ViewBreadcrumbs } from '@app/components/view-shell';
+import {
+ EntityIcon,
+ type EntityIconSelector,
+} from '@core/component/EntityIcon';
+import { fileTypeToBlockName } from '@core/constant/allBlocks';
+import type {
+ EntityDetailNavigationStackEntry,
+ EntityDetailTarget,
+} from './EntityDetailNavigationStack';
+
+function breadcrumbIcon(target: EntityDetailTarget): EntityIconSelector {
+ if (target.type === 'document') {
+ return (target.subType?.type ??
+ target.fileType ??
+ 'unknown') as EntityIconSelector;
+ }
+ if (
+ target.type === 'channel' ||
+ target.type === 'channel_message' ||
+ target.type === 'channel_thread'
+ ) {
+ return 'channel';
+ }
+ return fileTypeToBlockName(target.type, true);
+}
+
+function breadcrumbName(target: EntityDetailTarget) {
+ if (target.fallbackName) return target.fallbackName;
+
+ if (target.type === 'document' && target.subType?.type === 'task') {
+ return 'New Task';
+ }
+ if (
+ target.type === 'channel' ||
+ target.type === 'channel_message' ||
+ target.type === 'channel_thread'
+ ) {
+ return 'Channel';
+ }
+ return 'Untitled';
+}
+
+export function EntityDetailBreadcrumbItem(props: {
+ entry: EntityDetailNavigationStackEntry;
+ order: number;
+}) {
+ return (
+ <ViewBreadcrumbs.Item
+ value={props.entry.value}
+ metadata={props.entry.data}
+ order={props.order}
+ >
+ {(item) => (
+ <ViewBreadcrumbs.Button
+ class="gap-1.5"
+ isActive={item.isActive()}
+ onClick={item.onSelect}
+ tooltip={breadcrumbName(props.entry.data)}
+ >
+ <EntityIcon
+ targetType={breadcrumbIcon(props.entry.data)}
+ size="xs"
+ class="shrink-0"
+ />
+ <span class="truncate">{breadcrumbName(props.entry.data)}</span>
+ </ViewBreadcrumbs.Button>
+ )}
+ </ViewBreadcrumbs.Item>
+ );
+}
diff --git a/apps/web/src/components/entity-detail/EntityDetailBreadcrumbSkeleton.tsx b/apps/web/src/components/entity-detail/EntityDetailBreadcrumbSkeleton.tsx
new file mode 100644
index 0000000000..022a2e183b
--- /dev/null
+++ b/apps/web/src/components/entity-detail/EntityDetailBreadcrumbSkeleton.tsx
@@ -0,0 +1,27 @@
+import { createSignal, onCleanup, onMount, Show } from 'solid-js';
+
+const BREADCRUMB_SKELETON_DELAY_MS = 150;
+
+export function EntityDetailBreadcrumbSkeleton() {
+ const [visible, setVisible] = createSignal(false);
+
+ onMount(() => {
+ const timeoutId = window.setTimeout(
+ () => setVisible(true),
+ BREADCRUMB_SKELETON_DELAY_MS
+ );
+ onCleanup(() => window.clearTimeout(timeoutId));
+ });
+
+ return (
+ <Show when={visible()}>
+ <div
+ aria-hidden="true"
+ class="flex h-7 min-w-0 items-center gap-1.5 px-1"
+ >
+ <span class="skeleton-shimmer size-4 shrink-0 rounded bg-skeleton" />
+ <span class="skeleton-shimmer h-3 w-24 rounded-full bg-skeleton" />
+ </div>
+ </Show>
+ );
+}
diff --git a/apps/web/src/components/view-shell/ViewBreadcrumbs.tsx b/apps/web/src/components/view-shell/ViewBreadcrumbs.tsx
index be5e7d018c..9b8e2c8a94 100644
--- a/apps/web/src/components/view-shell/ViewBreadcrumbs.tsx
+++ b/apps/web/src/components/view-shell/ViewBreadcrumbs.tsx
@@ -1,5 +1,5 @@
import CaretRightIcon from '@phosphor/caret-right.svg';
-import { cn } from '@ui';
+import { cn, Tooltip } from '@ui';
import {
type Accessor,
children,
@@ -105,6 +105,7 @@ export type ViewBreadcrumbsButtonProps = Omit<
'aria-current'
> & {
isActive?: boolean;
+ tooltip?: string;
};
function BreadcrumbButton(props: ViewBreadcrumbsButtonProps) {
@@ -112,10 +113,11 @@ function BreadcrumbButton(props: ViewBreadcrumbsButtonProps) {
'children',
'class',
'isActive',
+ 'tooltip',
'type',
]);
- return (
+ const button = () => (
<button
{...rest}
type={local.type ?? 'button'}
@@ -131,6 +133,16 @@ function BreadcrumbButton(props: ViewBreadcrumbsButtonProps) {
{local.children}
</button>
);
+
+ return (
+ <Show when={local.tooltip} fallback={button()}>
+ {(tooltip) => (
+ <Tooltip class="min-w-0" label={tooltip()}>
+ {button()}
+ </Tooltip>
+ )}
+ </Show>
+ );
}
export type ViewBreadcrumbsSeparatorProps = JSX.SvgSVGAttributes<SVGSVGElement>;
@@ -196,12 +208,23 @@ export type ViewBreadcrumbsOutletProps = Omit<
> & {
children?: JSX.Element;
fallback?: JSX.Element;
+ separator?: (state: ViewBreadcrumbsSeparatorState) => JSX.Element;
+};
+
+export type ViewBreadcrumbsSeparatorState = {
+ previous: ViewBreadcrumbsEntry<unknown>;
+ next?: ViewBreadcrumbsEntry<unknown>;
};
/** Renders mounted breadcrumb items in order. */
function Outlet(props: ViewBreadcrumbsOutletProps) {
const context = useViewBreadcrumbsContext();
- const [local, rest] = splitProps(props, ['children', 'class', 'fallback']);
+ const [local, rest] = splitProps(props, [
+ 'children',
+ 'class',
+ 'fallback',
+ 'separator',
+ ]);
const entries = createMemo(() =>
[...context.entries].sort(
(left, right) =>
@@ -212,6 +235,10 @@ function Outlet(props: ViewBreadcrumbsOutletProps) {
);
const hasActiveItem = () =>
entries().some((entry) => entry.value() === context.value());
+ const renderSeparator = (
+ previous: ViewBreadcrumbsEntry<unknown>,
+ next?: ViewBreadcrumbsEntry<unknown>
+ ) => local.separator?.({ previous, next }) ?? <Separator />;
return (
<nav
@@ -223,13 +250,18 @@ function Outlet(props: ViewBreadcrumbsOutletProps) {
{(entry, index) => (
<>
<Show when={index() > 0}>
- <Separator />
+ {renderSeparator(entries()[index() - 1]!, entry)}
</Show>
{entry.render()}
</>
)}
</For>
- <Show when={!hasActiveItem()}>{local.fallback}</Show>
+ <Show when={!hasActiveItem() && local.fallback != null}>
+ <Show when={entries().at(-1)}>
+ {(entry) => renderSeparator(entry())}
+ </Show>
+ {local.fallback}
+ </Show>
{local.children}
</nav>
);
diff --git a/apps/web/src/components/view-shell/index.ts b/apps/web/src/components/view-shell/index.ts
index a002ae2773..390c7b82a7 100644
--- a/apps/web/src/components/view-shell/index.ts
+++ b/apps/web/src/components/view-shell/index.ts
@@ -36,6 +36,7 @@ export {
type ViewBreadcrumbsOutletProps,
type ViewBreadcrumbsRootProps,
type ViewBreadcrumbsSeparatorProps,
+ type ViewBreadcrumbsSeparatorState,
} from './ViewBreadcrumbs';
export {
useViewShell,
diff --git a/apps/web/src/features/block-md/component/MarkdownDetailBreadcrumbItem.tsx b/apps/web/src/features/block-md/component/MarkdownDetailBreadcrumbItem.tsx
new file mode 100644
index 0000000000..1540cf1d9b
--- /dev/null
+++ b/apps/web/src/features/block-md/component/MarkdownDetailBreadcrumbItem.tsx
@@ -0,0 +1,101 @@
+import { ViewBreadcrumbs } from '@app/components/view-shell';
+import { useBlockEntityCommands } from '@app/features/next-soup/actions';
+import { SplitFileMenu } from '@components/app/split-layout/components/SplitFileMenu';
+import { useSplitPanelOrThrow } from '@components/app/split-layout/layoutUtils';
+import type { BlockAlias, BlockName } from '@core/block';
+import { EntityIcon } from '@core/component/EntityIcon';
+import { Permissions } from '@core/component/SharePermissions';
+import { buildEntityData } from '@entity';
+import { useMarkdownDocument } from '../context/markdown-document-context';
+import type { MarkdownDocumentKind } from '../types';
+import { useMarkdownName } from './MarkdownNameProvider';
+import { useMarkdownDocumentTools } from './useMarkdownDocumentTools';
+
+export function markdownDocumentBlockName(
+ kind: MarkdownDocumentKind
+): BlockName | BlockAlias {
+ return kind === 'document' ? 'md' : kind;
+}
+
+export function MarkdownDetailBreadcrumbItem(props: {
+ value: string;
+ metadata: unknown;
+ order: number;
+ documentId: string;
+ kind: MarkdownDocumentKind;
+ fallbackName?: string;
+ ownerId: string;
+ projectId?: string;
+ onClose: () => void;
+ onDuplicate: (id: string, name: string) => void;
+}) {
+ const panel = useSplitPanelOrThrow();
+ const { displayName } = useMarkdownName();
+ const { permissions, state } = useMarkdownDocument();
+ const { fileOperations, menuTools } = useMarkdownDocumentTools();
+ const blockName = () => markdownDocumentBlockName(props.kind);
+ const documentName = () =>
+ displayName() ??
+ props.fallbackName ??
+ (props.kind === 'task' ? 'New Task' : 'Untitled');
+ const focusDocument = () => state.editor.md.editor?.focus();
+
+ const menuPermissions = () => {
+ if (permissions.isOwner()) return Permissions.OWNER;
+ if (permissions.canEdit()) return Permissions.CAN_EDIT;
+ if (permissions.canComment()) return Permissions.CAN_COMMENT;
+ return Permissions.CAN_VIEW;
+ };
+
+ useBlockEntityCommands({
+ id: props.documentId,
+ scopeId: panel.splitHotkeyScope,
+ onDeleted: props.onClose,
+ resolveEntity: () =>
+ buildEntityData({
+ id: props.documentId,
+ name: documentName(),
+ blockName: blockName(),
+ ownerId: props.ownerId,
+ projectId: props.projectId,
+ }),
+ });
+
+ return (
+ <ViewBreadcrumbs.Item
+ value={props.value}
+ metadata={props.metadata}
+ order={props.order}
+ >
+ {(item) => (
+ <div class="flex min-w-0 items-center motion-safe:animate-[dialog-overlay-open_150ms_ease-out]">
+ <ViewBreadcrumbs.Button
+ class="gap-1.5"
+ isActive={item.isActive()}
+ onClick={() => {
+ item.onSelect();
+ focusDocument();
+ }}
+ tooltip={documentName()}
+ >
+ <EntityIcon targetType={blockName()} size="xs" class="shrink-0" />
+ <span class="truncate">{documentName()}</span>
+ </ViewBreadcrumbs.Button>
+ <div class="shrink-0">
+ <SplitFileMenu
+ id={props.documentId}
+ itemType="document"
+ name={documentName()}
+ ops={fileOperations}
+ tools={menuTools}
+ entityKind={blockName()}
+ permissions={menuPermissions()}
+ onDuplicate={(id) => props.onDuplicate(id, documentName())}
+ onDelete={props.onClose}
+ />
+ </div>
+ </div>
+ )}
+ </ViewBreadcrumbs.Item>
+ );
+}
diff --git a/apps/web/src/features/tasks-view/queries/task-document.ts b/apps/web/src/features/block-md/queries/markdown-document.ts
similarity index 77%
rename from apps/web/src/features/tasks-view/queries/task-document.ts
rename to apps/web/src/features/block-md/queries/markdown-document.ts
index 2c7297dc77..50120f957e 100644
--- a/apps/web/src/features/tasks-view/queries/task-document.ts
+++ b/apps/web/src/features/block-md/queries/markdown-document.ts
@@ -3,12 +3,16 @@ import {
waitForDocumentSyncServiceReady,
} from '@queries/storage/document-location';
import { fetchDocumentLoadBundle } from '@queries/storage/documentLoad/documentLoadBundle';
+import type { AccessLevel } from '@service-storage/generated/schemas/accessLevel';
import type { DocumentMetadata } from '@service-storage/generated/schemas/documentMetadata';
import { createSyncServiceSource } from '@service-sync/source';
import { match } from 'ts-pattern';
-export type TaskDocumentData = ReturnType<typeof createSyncServiceSource> & {
+export type MarkdownDocumentData = ReturnType<
+ typeof createSyncServiceSource
+> & {
metadata: DocumentMetadata;
+ userAccessLevel: AccessLevel;
permissions: {
canComment: boolean;
canEdit: boolean;
@@ -16,19 +20,19 @@ export type TaskDocumentData = ReturnType<typeof createSyncServiceSource> & {
};
};
-export async function loadTaskDocument(
+export async function loadMarkdownDocument(
documentId: string
-): Promise<TaskDocumentData> {
+): Promise<MarkdownDocumentData> {
const [bundleResult, locationResult] = await Promise.all([
fetchDocumentLoadBundle(documentId),
fetchDocumentLocation({ documentId }),
]);
if (bundleResult.isErr()) {
- throw new Error('Unable to load task metadata');
+ throw new Error('Unable to load document metadata');
}
if (locationResult.isErr()) {
- throw new Error('Unable to load task content');
+ throw new Error('Unable to load document content');
}
let location = locationResult.value;
@@ -39,7 +43,7 @@ export async function loadTaskDocument(
location = await waitForDocumentSyncServiceReady({ documentId });
}
if (location.type !== 'syncServiceContent') {
- throw new Error('Task content is not available in sync-service');
+ throw new Error('Document content is not available in sync-service');
}
const { documentMetadata, token, userAccessLevel } = bundleResult.value;
@@ -69,6 +73,7 @@ export async function loadTaskDocument(
return {
...createSyncServiceSource(documentId, token),
metadata: documentMetadata,
+ userAccessLevel,
permissions,
};
}
diff --git a/apps/web/src/features/drive-view/components/DriveBreadcrumbs.tsx b/apps/web/src/features/drive-view/components/DriveBreadcrumbs.tsx
new file mode 100644
index 0000000000..10fa286daa
--- /dev/null
+++ b/apps/web/src/features/drive-view/components/DriveBreadcrumbs.tsx
@@ -0,0 +1,73 @@
+import {
+ ViewBreadcrumbs,
+ type ViewBreadcrumbsOutletProps,
+ type ViewBreadcrumbsSeparatorState,
+} from '@app/components/view-shell';
+import { For } from 'solid-js';
+import type { DriveLocationBreadcrumb } from '../core/breadcrumbs';
+
+export function DriveLocationBreadcrumbItems(props: {
+ entries: DriveLocationBreadcrumb[];
+}) {
+ return (
+ <For each={props.entries}>
+ {(entry, index) => (
+ <ViewBreadcrumbs.Item
+ value={entry.value}
+ metadata={entry}
+ order={index()}
+ >
+ {(item) => (
+ <ViewBreadcrumbs.Button
+ class="max-w-48"
+ isActive={item.isActive()}
+ onClick={item.onSelect}
+ tooltip={entry.label}
+ >
+ <span class="truncate">{entry.label}</span>
+ </ViewBreadcrumbs.Button>
+ )}
+ </ViewBreadcrumbs.Item>
+ )}
+ </For>
+ );
+}
+
+function isDriveLocationBreadcrumb(
+ metadata: unknown
+): metadata is DriveLocationBreadcrumb {
+ return (
+ typeof metadata === 'object' &&
+ metadata !== null &&
+ 'type' in metadata &&
+ metadata.type === 'drive-location'
+ );
+}
+
+export function DriveBreadcrumbSeparator(state: ViewBreadcrumbsSeparatorState) {
+ const next = state.next?.metadata();
+ if (
+ isDriveLocationBreadcrumb(next) &&
+ next.location.kind === 'folder' &&
+ next.location.id !== null
+ ) {
+ return (
+ <span aria-hidden="true" class="shrink-0 text-ink-extra-muted">
+ /
+ </span>
+ );
+ }
+
+ return <ViewBreadcrumbs.Separator />;
+}
+
+export function DriveBreadcrumbsOutlet(
+ props: Omit<ViewBreadcrumbsOutletProps, 'separator'>
+) {
+ return (
+ <ViewBreadcrumbs.Outlet
+ {...props}
+ separator={(state) => <DriveBreadcrumbSeparator {...state} />}
+ />
+ );
+}
diff --git a/apps/web/src/features/drive-view/components/DriveDetailView.tsx b/apps/web/src/features/drive-view/components/DriveDetailView.tsx
new file mode 100644
index 0000000000..df5e5c9aca
--- /dev/null
+++ b/apps/web/src/features/drive-view/components/DriveDetailView.tsx
@@ -0,0 +1,240 @@
+import {
+ EntityDetail,
+ entityDetailBlockType,
+} from '@app/components/entity-detail/EntityDetail';
+import { EntityDetailBreadcrumbItem } from '@app/components/entity-detail/EntityDetailBreadcrumbItem';
+import { EntityDetailBreadcrumbSkeleton } from '@app/components/entity-detail/EntityDetailBreadcrumbSkeleton';
+import {
+ EntityDetailNavigationStack,
+ type EntityDetailNavigationStackEntry,
+ type EntityDetailTarget,
+ entityDetailTarget,
+ useEntityDetailNavigationStack,
+} from '@app/components/entity-detail/EntityDetailNavigationStack';
+import { ViewShell } from '@app/components/view-shell';
+import { MarkdownDetailBreadcrumbItem } from '@block-md/component/MarkdownDetailBreadcrumbItem';
+import type { MarkdownDocumentKind } from '@block-md/types';
+import { SidePanel } from '@components/app/side-panel';
+import { useSplitPanelOrThrow } from '@components/app/split-layout/layoutUtils';
+import { SplitPanel } from '@components/app/split-panel';
+import {
+ ShareDialogContext,
+ ShareTrigger,
+} from '@core/component/TopBar/ShareButton';
+import {
+ createSignal,
+ ErrorBoundary,
+ For,
+ Match,
+ Show,
+ Switch,
+} from 'solid-js';
+import {
+ MarkdownDetail,
+ MarkdownDetailBodyState,
+} from '../views/MarkdownDetail';
+import { DriveBreadcrumbsOutlet } from './DriveBreadcrumbs';
+import { FileDetailBreadcrumbItem } from './FileDetailBreadcrumbItem';
+
+function DriveDetailAncestorBreadcrumbs(props: { orderOffset: number }) {
+ const navigationStack = useEntityDetailNavigationStack();
+ const ancestors = () => navigationStack.entries.slice(0, -1);
+
+ return (
+ <For each={ancestors()}>
+ {(entry, index) => (
+ <EntityDetailBreadcrumbItem
+ entry={entry}
+ order={props.orderOffset + index()}
+ />
+ )}
+ </For>
+ );
+}
+
+type DocumentDetailTarget = Extract<EntityDetailTarget, { type: 'document' }>;
+
+function markdownKind(target: DocumentDetailTarget): MarkdownDocumentKind {
+ const kind = target.subType?.type;
+ if (kind === 'task' || kind === 'snippet' || kind === 'skill') return kind;
+ return 'document';
+}
+
+function DriveDetailTopBar() {
+ const navigationStack = useEntityDetailNavigationStack();
+ const panel = useSplitPanelOrThrow();
+ const activeDetail = () => {
+ const target = navigationStack.active()?.data;
+ const blockType = target ? entityDetailBlockType(target) : undefined;
+ return target?.type === 'document' && blockType
+ ? { target, blockType }
+ : undefined;
+ };
+
+ return (
+ <ViewShell.TopBar class="touch:flex">
+ <SplitPanel.CloseButton class="hidden shrink-0 @max-[720px]/view-shell:flex" />
+ <DriveBreadcrumbsOutlet
+ aria-label="File location"
+ fallback={<EntityDetailBreadcrumbSkeleton />}
+ />
+ <div class="ml-auto flex shrink-0 items-center gap-2">
+ <Show when={activeDetail()}>
+ {(detail) => (
+ <ShareTrigger
+ id={detail().target.id}
+ blockType={detail().blockType}
+ hotkeyScope={panel.splitHotkeyScope}
+ />
+ )}
+ </Show>
+ <SidePanel.Toggle />
+ </div>
+ </ViewShell.TopBar>
+ );
+}
+
+function StackEntityDetail(props: {
+ entry: EntityDetailNavigationStackEntry;
+ order: number;
+ shareOpen: boolean;
+ onShareOpenChange: (open: boolean) => void;
+}) {
+ const navigationStack = useEntityDetailNavigationStack();
+ const markdownTarget = () => {
+ const target = props.entry.data;
+ const blockType = entityDetailBlockType(target);
+ return target.type === 'document' &&
+ (blockType === 'md' ||
+ blockType === 'task' ||
+ blockType === 'snippet' ||
+ blockType === 'skill')
+ ? target
+ : undefined;
+ };
+
+ return (
+ <Switch>
+ <Match when={markdownTarget()}>
+ {(target) => {
+ const kind = () => markdownKind(target());
+ return (
+ <MarkdownDetail
+ documentId={target().id}
+ kind={kind()}
+ fallbackName={target().fallbackName}
+ shareOpen={props.shareOpen}
+ onShareOpenChange={props.onShareOpenChange}
+ >
+ {(context) => (
+ <MarkdownDetailBreadcrumbItem
+ value={props.entry.value}
+ metadata={props.entry.data}
+ order={props.order}
+ documentId={target().id}
+ kind={kind()}
+ fallbackName={target().fallbackName}
+ ownerId={context.data.metadata.owner}
+ projectId={context.data.metadata.projectId ?? undefined}
+ onClose={navigationStack.pop}
+ onDuplicate={(id, name) =>
+ navigationStack.navigate(
+ entityDetailTarget.document({
+ id,
+ fileType: 'md',
+ subType: target().subType,
+ fallbackName: name,
+ })
+ )
+ }
+ />
+ )}
+ </MarkdownDetail>
+ );
+ }}
+ </Match>
+ <Match when={true}>
+ <Show when={props.entry.data.type !== 'document'}>
+ <EntityDetailBreadcrumbItem entry={props.entry} order={props.order} />
+ </Show>
+ <EntityDetail
+ target={props.entry.data}
+ shareOpen={props.shareOpen}
+ onShareOpenChange={props.onShareOpenChange}
+ >
+ {(context) => (
+ <FileDetailBreadcrumbItem
+ value={props.entry.value}
+ metadata={props.entry.data}
+ order={props.order}
+ documentMetadata={context.documentMetadata}
+ userAccessLevel={context.userAccessLevel}
+ blockType={context.blockType}
+ fallbackName={props.entry.data.fallbackName}
+ onClose={navigationStack.pop}
+ onDuplicate={(id, name) => {
+ const target = props.entry.data;
+ if (target.type !== 'document') return;
+ navigationStack.navigate(
+ entityDetailTarget.document({
+ id,
+ fileType: target.fileType,
+ subType: target.subType,
+ fallbackName: name,
+ })
+ );
+ }}
+ />
+ )}
+ </EntityDetail>
+ </Match>
+ </Switch>
+ );
+}
+
+export function DriveDetailView(props: { breadcrumbOrderOffset: number }) {
+ const [shareOpen, setShareOpen] = createSignal(false);
+
+ return (
+ <ShareDialogContext.Provider
+ value={{
+ isOpen: shareOpen,
+ open: () => setShareOpen(true),
+ close: () => setShareOpen(false),
+ }}
+ >
+ <DriveDetailAncestorBreadcrumbs
+ orderOffset={props.breadcrumbOrderOffset}
+ />
+ <SidePanel.Root>
+ <div class="flex size-full min-h-0 min-w-0 flex-col overflow-hidden">
+ <DriveDetailTopBar />
+ <div class="relative min-h-0 min-w-0 flex-1">
+ <EntityDetailNavigationStack.Outlet>
+ {(entry, state) => (
+ <ErrorBoundary
+ fallback={(error, reset) => (
+ <MarkdownDetailBodyState
+ error={error}
+ actionLabel="Reset"
+ onAction={reset}
+ />
+ )}
+ >
+ <StackEntityDetail
+ entry={entry}
+ order={
+ props.breadcrumbOrderOffset + state.entries.length - 1
+ }
+ shareOpen={shareOpen()}
+ onShareOpenChange={setShareOpen}
+ />
+ </ErrorBoundary>
+ )}
+ </EntityDetailNavigationStack.Outlet>
+ </div>
+ </div>
+ </SidePanel.Root>
+ </ShareDialogContext.Provider>
+ );
+}
diff --git a/apps/web/src/features/drive-view/components/FileDetailBreadcrumbItem.tsx b/apps/web/src/features/drive-view/components/FileDetailBreadcrumbItem.tsx
new file mode 100644
index 0000000000..99a1be33fe
--- /dev/null
+++ b/apps/web/src/features/drive-view/components/FileDetailBreadcrumbItem.tsx
@@ -0,0 +1,87 @@
+import { ViewBreadcrumbs } from '@app/components/view-shell';
+import { useBlockEntityCommands } from '@app/features/next-soup/actions';
+import type { FileOperation } from '@components/app/split-layout/components/SplitFileMenu';
+import { SplitFileMenu } from '@components/app/split-layout/components/SplitFileMenu';
+import { useSplitPanelOrThrow } from '@components/app/split-layout/layoutUtils';
+import type { BlockAlias, BlockName } from '@core/block';
+import { EntityIcon } from '@core/component/EntityIcon';
+import { getPermissions } from '@core/component/SharePermissions';
+import { buildEntityData } from '@entity';
+import type { AccessLevel } from '@service-storage/generated/schemas/accessLevel';
+import type { DocumentMetadata } from '@service-storage/generated/schemas/documentMetadata';
+
+const fileOperations: FileOperation[] = [
+ { op: 'copy' },
+ { op: 'rename' },
+ { op: 'moveToProject' },
+ { op: 'delete' },
+];
+
+export function FileDetailBreadcrumbItem(props: {
+ value: string;
+ metadata: unknown;
+ order: number;
+ documentMetadata: DocumentMetadata;
+ userAccessLevel: AccessLevel;
+ blockType: BlockName | BlockAlias;
+ fallbackName?: string;
+ onClose: () => void;
+ onDuplicate: (id: string, name: string) => void;
+}) {
+ const panel = useSplitPanelOrThrow();
+ const documentId = () => props.documentMetadata.documentId;
+ const documentName = () =>
+ props.documentMetadata.documentName ?? props.fallbackName ?? 'Untitled';
+
+ useBlockEntityCommands({
+ id: documentId(),
+ scopeId: panel.splitHotkeyScope,
+ onDeleted: props.onClose,
+ resolveEntity: () =>
+ buildEntityData({
+ id: documentId(),
+ name: documentName(),
+ blockName: props.blockType,
+ ownerId: props.documentMetadata.owner,
+ projectId: props.documentMetadata.projectId ?? undefined,
+ }),
+ });
+
+ return (
+ <ViewBreadcrumbs.Item
+ value={props.value}
+ metadata={props.metadata}
+ order={props.order}
+ >
+ {(item) => (
+ <div class="flex min-w-0 items-center motion-safe:animate-[dialog-overlay-open_150ms_ease-out]">
+ <ViewBreadcrumbs.Button
+ class="gap-1.5"
+ isActive={item.isActive()}
+ onClick={item.onSelect}
+ tooltip={documentName()}
+ >
+ <EntityIcon
+ targetType={props.blockType}
+ size="xs"
+ class="shrink-0"
+ />
+ <span class="truncate">{documentName()}</span>
+ </ViewBreadcrumbs.Button>
+ <div class="shrink-0">
+ <SplitFileMenu
+ id={documentId()}
+ itemType="document"
+ name={documentName()}
+ ops={fileOperations}
+ entityKind={props.blockType}
+ permissions={getPermissions(props.userAccessLevel)}
+ onDuplicate={(id) => props.onDuplicate(id, documentName())}
+ onDelete={props.onClose}
+ />
+ </div>
+ </div>
+ )}
+ </ViewBreadcrumbs.Item>
+ );
+}
diff --git a/apps/web/src/features/drive-view/core/breadcrumbs.ts b/apps/web/src/features/drive-view/core/breadcrumbs.ts
new file mode 100644
index 0000000000..d56e4944fb
--- /dev/null
+++ b/apps/web/src/features/drive-view/core/breadcrumbs.ts
@@ -0,0 +1,49 @@
+import { folderAncestors } from './folder-tree';
+import { driveLocationLabel } from './location-label';
+import type { DriveFolder, DriveLocation } from './types';
+
+export const DRIVE_VIEW_BREADCRUMB = 'drive-view';
+
+export type DriveLocationBreadcrumb = {
+ type: 'drive-location';
+ value: string;
+ label: string;
+ location: DriveLocation;
+};
+
+function folderBreadcrumbValue(id: string) {
+ return `drive-folder:${id}`;
+}
+
+export function driveLocationBreadcrumbs(
+ location: DriveLocation,
+ folders: DriveFolder[]
+): DriveLocationBreadcrumb[] {
+ if (location.kind === 'tab') {
+ return [
+ {
+ type: 'drive-location',
+ value: DRIVE_VIEW_BREADCRUMB,
+ label: driveLocationLabel(location, folders),
+ location,
+ },
+ ];
+ }
+
+ return [
+ {
+ type: 'drive-location',
+ value: DRIVE_VIEW_BREADCRUMB,
+ label: 'Drive',
+ location: { kind: 'folder', id: null },
+ },
+ ...(location.id
+ ? folderAncestors(folders, location.id).map((folder) => ({
+ type: 'drive-location' as const,
+ value: folderBreadcrumbValue(folder.id),
+ label: folder.name,
+ location: { kind: 'folder' as const, id: folder.id },
+ }))
+ : []),
+ ];
+}
diff --git a/apps/web/src/features/drive-view/drive-view.tsx b/apps/web/src/features/drive-view/drive-view.tsx
index f9dc7cffc0..0975643cb2 100644
--- a/apps/web/src/features/drive-view/drive-view.tsx
+++ b/apps/web/src/features/drive-view/drive-view.tsx
@@ -1,7 +1,15 @@
+import { entityDetailBlockType } from '@app/components/entity-detail/EntityDetail';
+import {
+ EntityDetailNavigationStack,
+ type EntityDetailTarget,
+ entityDetailTarget,
+ useEntityDetailNavigationStack,
+} from '@app/components/entity-detail/EntityDetailNavigationStack';
import {
ListFilterDropdown,
useViewControlHotkeys,
useViewTabHotkeys,
+ ViewBreadcrumbs,
ViewSidebar,
} from '@app/components/view-shell';
import {
@@ -20,6 +28,7 @@ import { UnifiedFilterDropdown } from '@app/features/next-soup/soup-view/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 {
+ favoriteBlockName,
favoriteSplitContent,
useFavoriteDisplayName,
} from '@app/util/favorites';
@@ -47,6 +56,9 @@ import type { Favorite } from '@service-storage/generated/schemas/favorite';
import { Dropdown, EmptyStatePanel } from '@ui';
import { createMemo, For, onCleanup, Show, Suspense } from 'solid-js';
import { Dynamic } from 'solid-js/web';
+import { DriveLocationBreadcrumbItems } from './components/DriveBreadcrumbs';
+import { DriveDetailView } from './components/DriveDetailView';
+import { driveLocationBreadcrumbs } from './core/breadcrumbs';
import { driveLocationLabel } from './core/location-label';
import {
DRIVE_TABS,
@@ -64,16 +76,44 @@ export type DriveViewProps = {
initialClientFilters?: SetPredicatesInput<string>;
};
+function shouldOpenInline(event?: KeyboardEvent | MouseEvent) {
+ return !(
+ event?.shiftKey ||
+ event?.metaKey ||
+ event?.ctrlKey ||
+ event?.altKey
+ );
+}
+
+function favoriteDetailTarget(
+ favorite: Favorite,
+ fallbackName: string
+): EntityDetailTarget | undefined {
+ if (favorite.entityType !== 'document') return;
+
+ const blockName = favoriteBlockName(favorite);
+ const target = entityDetailTarget.document({
+ id: favorite.entityId,
+ fileType: favorite.fileType ?? undefined,
+ subType:
+ blockName === 'snippet' || blockName === 'skill'
+ ? { type: blockName }
+ : undefined,
+ fallbackName,
+ });
+ return entityDetailBlockType(target) ? target : undefined;
+}
+
function DriveFavorite(props: {
favorite: Favorite;
- onOpen: (favorite: Favorite, event: MouseEvent) => void;
+ onOpen: (favorite: Favorite, name: string, event: MouseEvent) => void;
}) {
const name = useFavoriteDisplayName(props.favorite);
return (
<ViewSidebar.Item
class="font-normal"
title={name()}
- onClick={(event) => props.onOpen(props.favorite, event)}
+ onClick={(event) => props.onOpen(props.favorite, name(), event)}
>
<FavoriteIcon favorite={props.favorite} class="size-4 shrink-0" />
<span class="truncate">{name()}</span>
@@ -81,10 +121,10 @@ function DriveFavorite(props: {
);
}
-/** App composition: shared queries, split navigation, and upload/create capabilities. */
-export function DriveView(props: DriveViewProps) {
+function DriveViewContent(props: DriveViewProps) {
const panel = useSplitPanelOrThrow();
const layout = useSplitLayout();
+ const navigationStack = useEntityDetailNavigationStack();
const userId = useUserId();
const view = useSoupView();
const projects = useProjectsQuery();
@@ -145,10 +185,16 @@ export function DriveView(props: DriveViewProps) {
setState,
folders,
results: createDriveResults(view, userId),
- onNavigate: () => panel.handle.resetPreview(),
+ onNavigate: () => {
+ navigationStack.clear();
+ panel.handle.resetPreview();
+ },
});
const selectTab = (tab: DriveTab) => navigate({ kind: 'tab', tab });
const selectFolder = (id: string | null) => navigate({ kind: 'folder', id });
+ const locationBreadcrumbs = createMemo(() =>
+ driveLocationBreadcrumbs(state().location, folders())
+ );
const initial = driveQuery(state(), userId());
view.initialize({
@@ -317,10 +363,14 @@ export function DriveView(props: DriveViewProps) {
{(favorite) => (
<DriveFavorite
favorite={favorite}
- onOpen={(item, event) => {
+ onOpen={(item, name, event) => {
+ const target = favoriteDetailTarget(item, name);
if (item.entityType === 'project' && !event.shiftKey)
selectFolder(item.entityId);
- else
+ else if (target && shouldOpenInline(event)) {
+ navigationStack.reset(target);
+ return;
+ } else
layout.openWithSplit(favoriteSplitContent(item), {
referredFrom: 'sidebar',
preferNewSplit: event.shiftKey,
@@ -336,76 +386,139 @@ export function DriveView(props: DriveViewProps) {
);
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}
- filterMenu={FilterMenu}
- 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],
- }))
+ <ViewBreadcrumbs.Root
+ value={
+ navigationStack.active()?.value ?? locationBreadcrumbs().at(-1)!.value
}
- onFavoritesOpen={(favoritesOpen) =>
- setState((current) => ({ ...current, favoritesOpen }))
- }
- onRootOpen={(rootOpen) =>
- setState((current) => ({ ...current, rootOpen }))
- }
- createMenu={CreateMenu}
- favorites={Favorites}
+ onChange={(value) => {
+ const breadcrumb = locationBreadcrumbs().find(
+ (entry) => entry.value === value
+ );
+ if (!breadcrumb) {
+ navigationStack.popTo(value);
+ return;
+ }
+
+ const current = state().location;
+ const location = breadcrumb.location;
+ const isCurrent =
+ (current.kind === 'tab' &&
+ location.kind === 'tab' &&
+ current.tab === location.tab) ||
+ (current.kind === 'folder' &&
+ location.kind === 'folder' &&
+ current.id === location.id);
+ if (isCurrent) {
+ navigationStack.clear();
+ return;
+ }
+ navigate(location);
+ }}
>
- <Suspense
- fallback={
- <div class="grid size-full place-items-center text-ink-muted">
- <SpinnerIcon
- aria-label="Loading files"
- class="size-5 animate-spin"
+ <DriveLocationBreadcrumbItems entries={locationBreadcrumbs()} />
+ <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}
+ filterMenu={FilterMenu}
+ 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}
+ detail={
+ navigationStack.active() ? (
+ <DriveDetailView
+ breadcrumbOrderOffset={locationBreadcrumbs().length}
/>
- </div>
+ ) : undefined
}
>
- <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
+ <Suspense
+ fallback={
+ <div class="grid size-full place-items-center text-ink-muted">
+ <SpinnerIcon
+ aria-label="Loading files"
+ class="size-5 animate-spin"
+ />
+ </div>
}
- onOpenProject={selectFolder}
- uploadProjectId={projectId()}
- disableTabHotkeys
- navigationKey={JSON.stringify([state().location, state().scope])}
- timestamp={isRecent() ? (entity) => entity.touchedAt : undefined}
- />
- </Suspense>
- </DriveLayout>
+ >
+ <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}
+ onOpenEntity={(entity, event) => {
+ if (entity.type !== 'document') return false;
+
+ const target = entityDetailTarget.document({
+ id: entity.id,
+ fileType: entity.fileType,
+ subType: entity.subType,
+ fallbackName: entity.name,
+ });
+ if (!entityDetailBlockType(target)) return false;
+ if (!shouldOpenInline(event)) return false;
+ navigationStack.reset(target);
+ return true;
+ }}
+ uploadProjectId={projectId()}
+ disableTabHotkeys
+ navigationKey={JSON.stringify([state().location, state().scope])}
+ timestamp={isRecent() ? (entity) => entity.touchedAt : undefined}
+ />
+ </Suspense>
+ </DriveLayout>
+ </ViewBreadcrumbs.Root>
+ );
+}
+
+/** App composition: shared queries, inline details, and upload/create capabilities. */
+export function DriveView(props: DriveViewProps) {
+ return (
+ <EntityDetailNavigationStack.Root
+ shouldNavigate={(_target, options) => shouldOpenInline(options?.event)}
+ >
+ <DriveViewContent {...props} />
+ </EntityDetailNavigationStack.Root>
);
}
diff --git a/apps/web/src/features/drive-view/views/CodeDetail.tsx b/apps/web/src/features/drive-view/views/CodeDetail.tsx
index 1f17b0d412..9a769c3a21 100644
--- a/apps/web/src/features/drive-view/views/CodeDetail.tsx
+++ b/apps/web/src/features/drive-view/views/CodeDetail.tsx
@@ -5,7 +5,7 @@ import {
import { CodeModeControl } from '@block-code/component/CodeModeControl';
import { isHtmlFileType } from '@block-code/util/fileMode';
import { Rerun } from '@solid-primitives/keyed';
-import { createSignal, Show } from 'solid-js';
+import { createSignal, type JSX, Show } from 'solid-js';
import {
FileDetailLayout,
FileDetailLoadGate,
@@ -17,6 +17,10 @@ import {
saveCodeDocument,
} from '../queries/code-document';
+export type CodeDetailContext = {
+ data: CodeDocumentData;
+};
+
function CodeDetailContent(props: {
documentId: string;
data: CodeDocumentData;
@@ -58,6 +62,7 @@ export function CodeDetailDocument(
props: FileDetailShareProps & {
documentId: string;
data: CodeDocumentData;
+ children?: (context: CodeDetailContext) => JSX.Element;
}
) {
const blockType = () =>
@@ -74,6 +79,7 @@ export function CodeDetailDocument(
shareOpen={props.shareOpen}
onShareOpenChange={props.onShareOpenChange}
>
+ {props.children?.({ data: props.data })}
<Rerun
on={() =>
`${props.documentId}:${props.data.documentMetadata.documentVersionId}`
@@ -88,7 +94,10 @@ export function CodeDetailDocument(
}
export function CodeDetail(
- props: FileDetailShareProps & { documentId: string }
+ props: FileDetailShareProps & {
+ documentId: string;
+ children?: (context: CodeDetailContext) => JSX.Element;
+ }
) {
return (
<FileDetailLoadGate
@@ -102,6 +111,7 @@ export function CodeDetail(
data={data}
shareOpen={props.shareOpen}
onShareOpenChange={props.onShareOpenChange}
+ children={props.children}
/>
)}
</FileDetailLoadGate>
diff --git a/apps/web/src/features/drive-view/views/ImageDetail.tsx b/apps/web/src/features/drive-view/views/ImageDetail.tsx
index b1fbf1c04e..928db7ce08 100644
--- a/apps/web/src/features/drive-view/views/ImageDetail.tsx
+++ b/apps/web/src/features/drive-view/views/ImageDetail.tsx
@@ -1,4 +1,5 @@
import { ImageContent } from '@block-image/component/ImageContent';
+import type { JSX } from 'solid-js';
import {
FileDetailLayout,
FileDetailLoadGate,
@@ -9,10 +10,15 @@ import {
loadImageDocument,
} from '../queries/image-document';
+export type ImageDetailContext = {
+ data: ImageDocumentData;
+};
+
export function ImageDetailDocument(
props: FileDetailShareProps & {
documentId: string;
data: ImageDocumentData;
+ children?: (context: ImageDetailContext) => JSX.Element;
}
) {
return (
@@ -24,6 +30,7 @@ export function ImageDetailDocument(
shareOpen={props.shareOpen}
onShareOpenChange={props.onShareOpenChange}
>
+ {props.children?.({ data: props.data })}
<ImageContent
file={props.data.file}
alt={props.data.documentMetadata.documentName || 'Image'}
@@ -33,7 +40,10 @@ export function ImageDetailDocument(
}
export function ImageDetail(
- props: FileDetailShareProps & { documentId: string }
+ props: FileDetailShareProps & {
+ documentId: string;
+ children?: (context: ImageDetailContext) => JSX.Element;
+ }
) {
return (
<FileDetailLoadGate
@@ -47,6 +57,7 @@ export function ImageDetail(
data={data}
shareOpen={props.shareOpen}
onShareOpenChange={props.onShareOpenChange}
+ children={props.children}
/>
)}
</FileDetailLoadGate>
diff --git a/apps/web/src/features/drive-view/views/MarkdownDetail.tsx b/apps/web/src/features/drive-view/views/MarkdownDetail.tsx
new file mode 100644
index 0000000000..ecb7fa7118
--- /dev/null
+++ b/apps/web/src/features/drive-view/views/MarkdownDetail.tsx
@@ -0,0 +1,182 @@
+import { FindAndReplace } from '@block-md/component/FindAndReplace';
+import {
+ MarkdownDocument,
+ MarkdownDocumentContent,
+} from '@block-md/component/MarkdownDocument';
+import { ModalsProvider } from '@block-md/component/ModalsProvider';
+import { MarkdownSidePanelSections } from '@block-md/component/sidepanel/MarkdownSidePanelSections';
+import { OldOverlay } from '@block-md/history/OldOverlay';
+import {
+ loadMarkdownDocument,
+ type MarkdownDocumentData,
+} from '@block-md/queries/markdown-document';
+import { loadMarkdownCachedSnapshot } from '@block-md/queries/markdown-document-operations';
+import type { MarkdownDocumentKind } from '@block-md/types';
+import { useGlobalNotificationSource } from '@components/app/GlobalAppState';
+import { SidePanel } from '@components/app/side-panel';
+import { useSplitPanelOrThrow } from '@components/app/split-layout/layoutUtils';
+import { ENABLE_MARKDOWN_SIDE_PANEL } from '@core/constant/featureFlags';
+import { DocumentDebouncedNotificationReadMarker } from '@notifications';
+import SpinnerIcon from '@phosphor/spinner.svg';
+import { Button } from '@ui';
+import {
+ createResource,
+ ErrorBoundary,
+ type JSX,
+ Match,
+ Show,
+ Suspense,
+ Switch,
+} from 'solid-js';
+
+export type MarkdownDetailContext = {
+ data: MarkdownDocumentData;
+};
+
+export type MarkdownDetailProps = {
+ documentId: string;
+ kind?: MarkdownDocumentKind;
+ fallbackName?: string;
+ shareOpen?: boolean;
+ onShareOpenChange?: (open: boolean) => void;
+ children?: (context: MarkdownDetailContext) => JSX.Element;
+};
+
+export function MarkdownDetailBodyState(props: {
+ entityLabel?: string;
+ error?: unknown;
+ actionLabel?: string;
+ onAction?: () => void;
+}) {
+ const entityLabel = () => props.entityLabel ?? 'document';
+
+ return (
+ <div class="grid size-full place-items-center text-ink-muted">
+ <Switch
+ fallback={
+ <SpinnerIcon
+ aria-label={`Loading ${entityLabel()}`}
+ class="size-5 animate-spin"
+ />
+ }
+ >
+ <Match when={props.error !== undefined}>
+ <div class="flex max-w-xl flex-col items-center gap-3 px-6 text-center">
+ <span>This {entityLabel()} couldn’t be displayed.</span>
+ <pre class="max-h-48 max-w-full overflow-auto whitespace-pre-wrap text-left text-failure text-xs">
+ {String(props.error)}
+ </pre>
+ <Button variant="outline" size="sm" onClick={props.onAction}>
+ {props.actionLabel ?? 'Reset'}
+ </Button>
+ </div>
+ </Match>
+ </Switch>
+ </div>
+ );
+}
+
+function MarkdownDetailContent(props: {
+ documentId: string;
+ kind: MarkdownDocumentKind;
+ fallbackName: string;
+ data: MarkdownDocumentData;
+ shareOpen?: boolean;
+ onShareOpenChange?: (open: boolean) => void;
+ children?: (context: MarkdownDetailContext) => JSX.Element;
+}) {
+ const panel = useSplitPanelOrThrow();
+ const notificationSource = useGlobalNotificationSource();
+
+ return (
+ <MarkdownDocument
+ documentId={props.documentId}
+ kind={props.kind}
+ documentSource={{ type: 'sync', source: props.data.source }}
+ permissions={props.data.permissions}
+ persistedName={props.data.metadata.documentName}
+ fallbackName={props.fallbackName}
+ >
+ <ModalsProvider
+ shareOpen={props.shareOpen}
+ onShareOpenChange={props.onShareOpenChange}
+ >
+ <OldOverlay />
+ {props.children?.({ data: props.data })}
+ <SidePanel.Layout headerToggle={false}>
+ <Show when={ENABLE_MARKDOWN_SIDE_PANEL}>
+ <MarkdownSidePanelSections />
+ </Show>
+ <div class="flex size-full min-h-0 min-w-0 flex-col overflow-hidden">
+ <div class="absolute top-1.5 right-4 z-action-menu flex justify-end">
+ <FindAndReplace hotkeyScope={panel.splitHotkeyScope} />
+ </div>
+ <DocumentDebouncedNotificationReadMarker
+ notificationSource={notificationSource}
+ documentId={props.documentId}
+ />
+ <MarkdownDocumentContent
+ hotkeyScope={panel.splitHotkeyScope}
+ doInitialSync={props.data.doInitialSync}
+ loadCachedSnapshot={() =>
+ loadMarkdownCachedSnapshot(props.documentId)
+ }
+ />
+ </div>
+ </SidePanel.Layout>
+ </ModalsProvider>
+ </MarkdownDocument>
+ );
+}
+
+/** Renders a markdown document without a block container or split header. */
+export function MarkdownDetail(props: MarkdownDetailProps) {
+ const [document, { refetch }] = createResource(
+ () => props.documentId,
+ loadMarkdownDocument
+ );
+ const entityLabel = () => (props.kind === 'task' ? 'task' : 'document');
+
+ return (
+ <Suspense
+ fallback={<MarkdownDetailBodyState entityLabel={entityLabel()} />}
+ >
+ <Switch>
+ <Match when={document.error}>
+ {(error) => (
+ <MarkdownDetailBodyState
+ entityLabel={entityLabel()}
+ error={error()}
+ actionLabel="Try again"
+ onAction={() => void refetch()}
+ />
+ )}
+ </Match>
+ <Match when={document()}>
+ {(data) => (
+ <ErrorBoundary
+ fallback={(error, reset) => (
+ <MarkdownDetailBodyState
+ entityLabel={entityLabel()}
+ error={error}
+ actionLabel="Reset"
+ onAction={reset}
+ />
+ )}
+ >
+ <MarkdownDetailContent
+ documentId={props.documentId}
+ kind={props.kind ?? 'document'}
+ fallbackName={props.fallbackName ?? 'Untitled'}
+ data={data()}
+ shareOpen={props.shareOpen}
+ onShareOpenChange={props.onShareOpenChange}
+ children={props.children}
+ />
+ </ErrorBoundary>
+ )}
+ </Match>
+ </Switch>
+ </Suspense>
+ );
+}
diff --git a/apps/web/src/features/drive-view/views/UnknownDetail.tsx b/apps/web/src/features/drive-view/views/UnknownDetail.tsx
index cf8056aad8..889088935f 100644
--- a/apps/web/src/features/drive-view/views/UnknownDetail.tsx
+++ b/apps/web/src/features/drive-view/views/UnknownDetail.tsx
@@ -2,7 +2,7 @@ import { UnknownContent } from '@block-unknown/component/UnknownContent';
import { toast } from '@core/component/Toast/Toast';
import { downloadFile } from '@filesystem/download';
import { formatDocumentName } from '@service-storage/util/filename';
-import { createSignal } from 'solid-js';
+import { createSignal, type JSX } from 'solid-js';
import {
FileDetailLayout,
FileDetailLoadGate,
@@ -14,10 +14,15 @@ import {
type UnknownDocumentData,
} from '../queries/unknown-document';
+export type UnknownDetailContext = {
+ data: UnknownDocumentData;
+};
+
export function UnknownDetailDocument(
props: FileDetailShareProps & {
documentId: string;
data: UnknownDocumentData;
+ children?: (context: UnknownDetailContext) => JSX.Element;
}
) {
const [localShareOpen, setLocalShareOpen] = createSignal(false);
@@ -56,6 +61,7 @@ export function UnknownDetailDocument(
shareOpen={shareOpen()}
onShareOpenChange={setShareOpen}
>
+ {props.children?.({ data: props.data })}
<UnknownContent
fileName={props.data.documentMetadata.documentName}
onShare={() => setShareOpen(true)}
@@ -66,7 +72,10 @@ export function UnknownDetailDocument(
}
export function UnknownDetail(
- props: FileDetailShareProps & { documentId: string }
+ props: FileDetailShareProps & {
+ documentId: string;
+ children?: (context: UnknownDetailContext) => JSX.Element;
+ }
) {
return (
<FileDetailLoadGate
@@ -80,6 +89,7 @@ export function UnknownDetail(
data={data}
shareOpen={props.shareOpen}
onShareOpenChange={props.onShareOpenChange}
+ children={props.children}
/>
)}
</FileDetailLoadGate>
diff --git a/apps/web/src/features/drive-view/views/VideoDetail.tsx b/apps/web/src/features/drive-view/views/VideoDetail.tsx
index b370cd150f..134240a162 100644
--- a/apps/web/src/features/drive-view/views/VideoDetail.tsx
+++ b/apps/web/src/features/drive-view/views/VideoDetail.tsx
@@ -1,4 +1,5 @@
import { VideoContent } from '@block-video/component/VideoContent';
+import type { JSX } from 'solid-js';
import {
FileDetailLayout,
FileDetailLoadGate,
@@ -9,10 +10,15 @@ import {
type VideoDocumentData,
} from '../queries/video-document';
+export type VideoDetailContext = {
+ data: VideoDocumentData;
+};
+
export function VideoDetailDocument(
props: FileDetailShareProps & {
documentId: string;
data: VideoDocumentData;
+ children?: (context: VideoDetailContext) => JSX.Element;
}
) {
return (
@@ -25,6 +31,7 @@ export function VideoDetailDocument(
shareOpen={props.shareOpen}
onShareOpenChange={props.onShareOpenChange}
>
+ {props.children?.({ data: props.data })}
<VideoContent
videoUrl={props.data.videoUrl}
fileType={props.data.documentMetadata.fileType}
@@ -35,7 +42,10 @@ export function VideoDetailDocument(
}
export function VideoDetail(
- props: FileDetailShareProps & { documentId: string }
+ props: FileDetailShareProps & {
+ documentId: string;
+ children?: (context: VideoDetailContext) => JSX.Element;
+ }
) {
return (
<FileDetailLoadGate
@@ -49,6 +59,7 @@ export function VideoDetail(
data={data}
shareOpen={props.shareOpen}
onShareOpenChange={props.onShareOpenChange}
+ children={props.children}
/>
)}
</FileDetailLoadGate>
diff --git a/apps/web/src/features/drive-view/views/drive-layout.tsx b/apps/web/src/features/drive-view/views/drive-layout.tsx
index d9880a0755..314d08f405 100644
--- a/apps/web/src/features/drive-view/views/drive-layout.tsx
+++ b/apps/web/src/features/drive-view/views/drive-layout.tsx
@@ -10,14 +10,11 @@ import CaretDownIcon from '@phosphor/caret-down.svg';
import FolderIcon from '@phosphor/folder.svg';
import SearchIcon from '@phosphor/magnifying-glass.svg';
import { Button, Dropdown } from '@ui';
-import { createMemo, createSignal, For, type JSX, Show } from 'solid-js';
+import { createMemo, createSignal, type JSX, Show } from 'solid-js';
+import { DriveBreadcrumbsOutlet } from '../components/DriveBreadcrumbs';
import { DriveNavigation } from '../components/drive-navigation';
import { FolderTree } from '../components/folder-tree';
-import {
- buildFolderTree,
- filterFolderTree,
- folderAncestors,
-} from '../core/folder-tree';
+import { buildFolderTree, filterFolderTree } from '../core/folder-tree';
import { driveLocationLabel } from '../core/location-label';
import type {
DriveFolder,
@@ -44,6 +41,7 @@ export function DriveLayout(props: {
onRootOpen: (open: boolean) => void;
createMenu: () => JSX.Element;
favorites: () => JSX.Element;
+ detail?: JSX.Element;
children: JSX.Element;
}) {
const [folderSearch, setFolderSearch] = createSignal('');
@@ -57,10 +55,6 @@ export function DriveLayout(props: {
props.state.location.kind === 'folder'
? props.state.location.id
: undefined;
- const breadcrumbs = createMemo(() => {
- const id = selectedFolder();
- return id ? folderAncestors(props.folders, id) : [];
- });
const title = () => driveLocationLabel(props.state.location, props.folders);
const SidebarContent = () => (
@@ -207,123 +201,94 @@ export function DriveLayout(props: {
</ViewSidebar.Root>
</ViewShell.Aside>
<ViewShell.Main>
- <ViewShell.TopBar class="touch:flex">
- <SplitPanel.CloseButton class="hidden shrink-0 @max-[720px]/view-shell:flex" />
- <h1 class="hidden min-w-0 truncate text-sm font-semibold tracking-[-0.03em] text-ink @max-[720px]/view-shell:block">
- Drive
- </h1>
- <Show
- when={props.state.location.kind === 'folder'}
- fallback={
- <h1 class="min-w-0 truncate text-sm font-semibold tracking-[-0.03em] text-ink @max-[720px]/view-shell:hidden">
- {title()}
- </h1>
- }
- >
- <span
- role="navigation"
- aria-label="Folder breadcrumbs"
- class="inline-flex max-w-full items-center gap-1 overflow-x-auto align-middle @max-[720px]/view-shell:hidden"
- >
- <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">
- <Dropdown
- open={navigationOpen()}
- onOpenChange={setNavigationOpen}
- placement="bottom-start"
- >
- <h1 class="min-w-0">
- <Dropdown.Trigger
- variant="ghost"
- size="sm"
- class="h-auto min-w-0 max-w-full gap-1 rounded-lg px-2 py-1 text-xl font-semibold tracking-[-0.03em] text-ink"
- aria-label={`Select Drive view: ${title()}`}
- >
- <span class="truncate">{title()}</span>
- <CaretDownIcon class="size-3.5 shrink-0 text-ink-muted" />
- </Dropdown.Trigger>
+ <Show
+ when={props.detail}
+ fallback={
+ <>
+ <ViewShell.TopBar class="touch:flex">
+ <SplitPanel.CloseButton class="hidden shrink-0 @max-[720px]/view-shell:flex" />
+ <h1 class="hidden min-w-0 truncate text-sm font-semibold tracking-[-0.03em] text-ink @max-[720px]/view-shell:block">
+ Drive
</h1>
- <Dropdown.Content class="max-h-[70vh] w-72 overflow-auto rounded-2xl">
- <Dropdown.Group class="gap-5 p-3">
- <SidebarContent />
- </Dropdown.Group>
- </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>
- <props.filterMenu />
- </div>
- </div>
- </div>
- </ViewShell.Header>
- <ViewShell.Content>{props.children}</ViewShell.Content>
+ <DriveBreadcrumbsOutlet
+ aria-label="Drive location"
+ class="@max-[720px]/view-shell:hidden"
+ />
+ </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">
+ <Dropdown
+ open={navigationOpen()}
+ onOpenChange={setNavigationOpen}
+ placement="bottom-start"
+ >
+ <h1 class="min-w-0">
+ <Dropdown.Trigger
+ variant="ghost"
+ size="sm"
+ class="h-auto min-w-0 max-w-full gap-1 rounded-lg px-2 py-1 text-xl font-semibold tracking-[-0.03em] text-ink"
+ aria-label={`Select Drive view: ${title()}`}
+ >
+ <span class="truncate">{title()}</span>
+ <CaretDownIcon class="size-3.5 shrink-0 text-ink-muted" />
+ </Dropdown.Trigger>
+ </h1>
+ <Dropdown.Content class="max-h-[70vh] w-72 overflow-auto rounded-2xl">
+ <Dropdown.Group class="gap-5 p-3">
+ <SidebarContent />
+ </Dropdown.Group>
+ </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>
+ <props.filterMenu />
+ </div>
+ </div>
+ </div>
+ </ViewShell.Header>
+ <ViewShell.Content>{props.children}</ViewShell.Content>
+ </>
+ }
+ >
+ {(detail) => detail()}
+ </Show>
</ViewShell.Main>
</ViewShell.Root>
</SplitPanel.Body>
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 180a46bb35..c0e10d04d5 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
@@ -804,13 +804,16 @@ export const SoupView = (props: SoupViewProps) => {
};
interface SoupViewListProps {
- /** Return true when the host handles ordinary activation in its own detail view. */
- onOpenEntity?: (entity: EntityData) => boolean;
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;
+ /** Returns true when a composed view handles ordinary entity activation. */
+ onOpenEntity?: (
+ entity: EntityData,
+ event?: KeyboardEvent | MouseEvent
+ ) => boolean;
uploadProjectId?: string;
disableTabHotkeys?: boolean;
customScrollbarHidden?: boolean;
@@ -1073,15 +1076,6 @@ const SoupViewListContent = (props: SoupViewListProps) => {
markReminderSeenOnOpen(entity, notificationSource);
- if (
- !event.metaKey &&
- !event.ctrlKey &&
- !event.shiftKey &&
- !event.altKey &&
- props.onOpenEntity?.(entity)
- )
- return;
-
// FIXME: this never gets called because we have overrides
if (event.metaKey || event.ctrlKey) {
// Channels the viewer hasn't joined can't be opened; the row's inline
@@ -1094,6 +1088,10 @@ const SoupViewListContent = (props: SoupViewListProps) => {
return;
}
+ if (type === 'entity' && props.onOpenEntity?.(entity, event)) {
+ return;
+ }
+
// Plain click while engaged as a Controller previews into the Viewer;
// opt+click opens in place of the whole Preview Pair (the Viewer closes and
// the content replaces this list); shift+click falls through to open a
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 933a8f4eb5..68d4fdedf0 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
@@ -32,8 +32,8 @@ import {
} from './soup-view-tabs';
type UseSoupViewHotkeysOptions = {
- onOpenEntity?: (entity: EntityData) => boolean;
onOpenProject?: (id: string) => void;
+ onOpenEntity?: (entity: EntityData, event?: KeyboardEvent) => boolean;
disableTabHotkeys?: boolean;
scopeId: string;
soup: SoupState;
@@ -157,7 +157,7 @@ export const useSoupViewHotkeys = (options: UseSoupViewHotkeysOptions) => {
scopeId,
description: 'Open',
hide: true,
- keyDownHandler: () => {
+ keyDownHandler: (event) => {
const focusedRow = soup.focus.row();
if (!focusedRow) return false;
@@ -188,8 +188,7 @@ export const useSoupViewHotkeys = (options: UseSoupViewHotkeysOptions) => {
options.onOpenProject(entity.id);
return true;
}
-
- if (options.onOpenEntity?.(entity)) return true;
+ if (options.onOpenEntity?.(entity, event)) return true;
const contentHitData = isSearchEntity(entity)
? entity.search.contentHitData
diff --git a/apps/web/src/features/tasks-view/components/TaskDetail.tsx b/apps/web/src/features/tasks-view/components/TaskDetail.tsx
index 82e218154e..3728e03319 100644
--- a/apps/web/src/features/tasks-view/components/TaskDetail.tsx
+++ b/apps/web/src/features/tasks-view/components/TaskDetail.tsx
@@ -1,37 +1,12 @@
-import { FindAndReplace } from '@block-md/component/FindAndReplace';
import {
- MarkdownDocument,
- MarkdownDocumentContent,
-} from '@block-md/component/MarkdownDocument';
-import { ModalsProvider } from '@block-md/component/ModalsProvider';
-import { MarkdownSidePanelSections } from '@block-md/component/sidepanel/MarkdownSidePanelSections';
-import { OldOverlay } from '@block-md/history/OldOverlay';
-import { loadMarkdownCachedSnapshot } from '@block-md/queries/markdown-document-operations';
-import { useGlobalNotificationSource } from '@components/app/GlobalAppState';
-import { SidePanel } from '@components/app/side-panel';
-import { useSplitPanelOrThrow } from '@components/app/split-layout/layoutUtils';
-import { ENABLE_MARKDOWN_SIDE_PANEL } from '@core/constant/featureFlags';
-import { DocumentDebouncedNotificationReadMarker } from '@notifications';
-import SpinnerIcon from '@phosphor/spinner.svg';
-import { Button } from '@ui';
-import {
- createResource,
- ErrorBoundary,
- type JSX,
- Match,
- Show,
- Suspense,
- Switch,
-} from 'solid-js';
-import {
- loadTaskDocument,
- type TaskDocumentData,
-} from '../queries/task-document';
+ MarkdownDetail,
+ MarkdownDetailBodyState,
+ type MarkdownDetailContext,
+} from '@app/features/drive-view/views/MarkdownDetail';
+import type { JSX } from 'solid-js';
import type { TaskDetailTarget } from '../types';
-export type TaskDetailContext = {
- data: TaskDocumentData;
-};
+export type TaskDetailContext = MarkdownDetailContext;
export type TaskDetailProps = {
task: TaskDetailTarget;
@@ -45,124 +20,19 @@ export function TaskDetailBodyState(props: {
actionLabel?: string;
onAction?: () => void;
}) {
- const errorText = () => String(props.error);
-
- return (
- <div class="grid size-full place-items-center text-ink-muted">
- <Switch
- fallback={
- <SpinnerIcon aria-label="Loading task" class="size-5 animate-spin" />
- }
- >
- <Match when={props.error !== undefined}>
- <div class="flex max-w-xl flex-col items-center gap-3 px-6 text-center">
- <span>This task couldn’t be displayed.</span>
- <pre class="max-h-48 max-w-full overflow-auto whitespace-pre-wrap text-left text-failure text-xs">
- {errorText()}
- </pre>
- <Button variant="outline" size="sm" onClick={props.onAction}>
- {props.actionLabel ?? 'Reset'}
- </Button>
- </div>
- </Match>
- </Switch>
- </div>
- );
-}
-
-function TaskDetailContent(props: {
- task: TaskDetailTarget;
- data: TaskDocumentData;
- shareOpen: boolean;
- onShareOpenChange: (open: boolean) => void;
- children?: (context: TaskDetailContext) => JSX.Element;
-}) {
- const panel = useSplitPanelOrThrow();
- const notificationSource = useGlobalNotificationSource();
- const fallbackName = () => props.task.fallbackName ?? 'New Task';
-
- return (
- <MarkdownDocument
- documentId={props.task.id}
- kind="task"
- documentSource={{ type: 'sync', source: props.data.source }}
- permissions={props.data.permissions}
- persistedName={props.data.metadata.documentName}
- fallbackName={fallbackName()}
- >
- <ModalsProvider
- shareOpen={props.shareOpen}
- onShareOpenChange={props.onShareOpenChange}
- >
- <OldOverlay />
- {props.children?.({ data: props.data })}
- <SidePanel.Layout headerToggle={false}>
- <Show when={ENABLE_MARKDOWN_SIDE_PANEL}>
- <MarkdownSidePanelSections />
- </Show>
- <div class="flex size-full min-h-0 min-w-0 flex-col overflow-hidden">
- <div class="absolute top-1.5 right-4 z-action-menu flex justify-end">
- <FindAndReplace hotkeyScope={panel.splitHotkeyScope} />
- </div>
- <DocumentDebouncedNotificationReadMarker
- notificationSource={notificationSource}
- documentId={props.task.id}
- />
- <MarkdownDocumentContent
- hotkeyScope={panel.splitHotkeyScope}
- doInitialSync={props.data.doInitialSync}
- loadCachedSnapshot={() =>
- loadMarkdownCachedSnapshot(props.task.id)
- }
- />
- </div>
- </SidePanel.Layout>
- </ModalsProvider>
- </MarkdownDocument>
- );
+ return <MarkdownDetailBodyState entityLabel="task" {...props} />;
}
/** Renders one task document without owning view navigation or breadcrumbs. */
export function TaskDetail(props: TaskDetailProps) {
- const [document, { refetch }] = createResource(
- () => props.task.id,
- loadTaskDocument
- );
-
return (
- <Suspense fallback={<TaskDetailBodyState />}>
- <Switch>
- <Match when={document.error}>
- {(error) => (
- <TaskDetailBodyState
- error={error()}
- actionLabel="Try again"
- onAction={() => void refetch()}
- />
- )}
- </Match>
- <Match when={document()}>
- {(data) => (
- <ErrorBoundary
- fallback={(error, reset) => (
- <TaskDetailBodyState
- error={error}
- actionLabel="Reset"
- onAction={reset}
- />
- )}
- >
- <TaskDetailContent
- task={props.task}
- data={data()}
- shareOpen={props.shareOpen}
- onShareOpenChange={props.onShareOpenChange}
- children={props.children}
- />
- </ErrorBoundary>
- )}
- </Match>
- </Switch>
- </Suspense>
+ <MarkdownDetail
+ documentId={props.task.id}
+ kind="task"
+ fallbackName={props.task.fallbackName ?? 'New Task'}
+ shareOpen={props.shareOpen}
+ onShareOpenChange={props.onShareOpenChange}
+ children={props.children}
+ />
);
}
diff --git a/apps/web/src/features/tasks-view/components/TasksDetailView.tsx b/apps/web/src/features/tasks-view/components/TasksDetailView.tsx
index 7710781ca6..de261e008a 100644
--- a/apps/web/src/features/tasks-view/components/TasksDetailView.tsx
+++ b/apps/web/src/features/tasks-view/components/TasksDetailView.tsx
@@ -1,40 +1,28 @@
import { EntityDetail } from '@app/components/entity-detail/EntityDetail';
+import { EntityDetailBreadcrumbItem } from '@app/components/entity-detail/EntityDetailBreadcrumbItem';
+import { EntityDetailBreadcrumbSkeleton } from '@app/components/entity-detail/EntityDetailBreadcrumbSkeleton';
import {
EntityDetailNavigationStack,
type EntityDetailNavigationStackEntry,
- type EntityDetailTarget,
useEntityDetailNavigationStack,
} from '@app/components/entity-detail/EntityDetailNavigationStack';
import { useListNavigationHotkeys } from '@app/components/entity-detail/use-list-navigation-hotkeys';
import { useListDetailNavigation } from '@app/components/list';
import { ViewBreadcrumbs } from '@app/components/view-shell';
-import { useBlockEntityCommands } from '@app/features/next-soup/actions';
-import { useMarkdownName } from '@block-md/component/MarkdownNameProvider';
-import { useMarkdownDocumentTools } from '@block-md/component/useMarkdownDocumentTools';
-import { useMarkdownDocument } from '@block-md/context/markdown-document-context';
+import { MarkdownDetailBreadcrumbItem } from '@block-md/component/MarkdownDetailBreadcrumbItem';
import { SidePanel } from '@components/app/side-panel';
-import { SplitFileMenu } from '@components/app/split-layout/components/SplitFileMenu';
import { useSplitPanelOrThrow } from '@components/app/split-layout/layoutUtils';
import { SplitPanel } from '@components/app/split-panel';
-import {
- EntityIcon,
- type EntityIconSelector,
-} from '@core/component/EntityIcon';
-import { Permissions } from '@core/component/SharePermissions';
import { toast } from '@core/component/Toast/Toast';
import {
ShareDialogContext,
ShareTrigger,
} from '@core/component/TopBar/ShareButton';
-import { fileTypeToBlockName } from '@core/constant/allBlocks';
-import { buildEntityData } from '@entity';
import {
createSignal,
ErrorBoundary,
For,
Match,
- onCleanup,
- onMount,
Show,
Switch,
} from 'solid-js';
@@ -43,7 +31,6 @@ import { useTasksView } from '../tasks-view-context';
import type { TaskDetailTarget } from '../types';
import { TaskDetail, TaskDetailBodyState } from './TaskDetail';
-const TASK_BREADCRUMB_SKELETON_DELAY_MS = 150;
type EntityDetailEntry = EntityDetailNavigationStackEntry;
function TaskViewBreadcrumbItem() {
@@ -61,7 +48,7 @@ function TaskViewBreadcrumbItem() {
<ViewBreadcrumbs.ReturnButton
isActive={item.isActive()}
onClick={item.onSelect}
- title={`Back to ${tabName()}`}
+ tooltip={tabName()}
>
<span class="truncate">{tabName()}</span>
</ViewBreadcrumbs.ReturnButton>
@@ -70,66 +57,6 @@ function TaskViewBreadcrumbItem() {
);
}
-function detailBreadcrumbIcon(target: EntityDetailTarget): EntityIconSelector {
- if (target.type === 'document') {
- return (target.subType?.type ??
- target.fileType ??
- 'unknown') as EntityIconSelector;
- }
- if (
- target.type === 'channel' ||
- target.type === 'channel_message' ||
- target.type === 'channel_thread'
- ) {
- return 'channel';
- }
- return fileTypeToBlockName(target.type, true);
-}
-
-function detailBreadcrumbName(target: EntityDetailTarget) {
- if (target.fallbackName) return target.fallbackName;
-
- if (target.type === 'document' && target.subType?.type === 'task') {
- return 'New Task';
- }
- if (
- target.type === 'channel' ||
- target.type === 'channel_message' ||
- target.type === 'channel_thread'
- ) {
- return 'Channel';
- }
- return 'Untitled';
-}
-
-function DetailBreadcrumbItem(props: {
- entry: EntityDetailEntry;
- order: number;
-}) {
- return (
- <ViewBreadcrumbs.Item
- value={props.entry.value}
- metadata={props.entry.data}
- order={props.order}
- >
- {(item) => (
- <ViewBreadcrumbs.Button
- class="gap-1.5"
- isActive={item.isActive()}
- onClick={item.onSelect}
- >
- <EntityIcon
- targetType={detailBreadcrumbIcon(props.entry.data)}
- size="xs"
- class="shrink-0"
- />
- <span class="truncate">{detailBreadcrumbName(props.entry.data)}</span>
- </ViewBreadcrumbs.Button>
- )}
- </ViewBreadcrumbs.Item>
- );
-}
-
function TaskDetailAncestorBreadcrumbs() {
const navigationStack = useEntityDetailNavigationStack();
const ancestors = () => navigationStack.entries.slice(0, -1);
@@ -137,111 +64,12 @@ function TaskDetailAncestorBreadcrumbs() {
return (
<For each={ancestors()}>
{(entry, index) => (
- <DetailBreadcrumbItem entry={entry} order={index() + 1} />
+ <EntityDetailBreadcrumbItem entry={entry} order={index() + 1} />
)}
</For>
);
}
-function TaskBreadcrumbItem(props: {
- entry: EntityDetailEntry;
- order: number;
- task: TaskDetailTarget;
- ownerId: string;
- projectId?: string;
-}) {
- const { closeTask, openTask } = useTasksView();
- const panel = useSplitPanelOrThrow();
- const { displayName } = useMarkdownName();
- const { permissions, state: documentState } = useMarkdownDocument();
- const { fileOperations, menuTools } = useMarkdownDocumentTools();
- const taskName = () => displayName() ?? props.task.fallbackName ?? 'New Task';
- const focusTask = () => documentState.editor.md.editor?.focus();
-
- const menuPermissions = () => {
- if (permissions.isOwner()) return Permissions.OWNER;
- if (permissions.canEdit()) return Permissions.CAN_EDIT;
- if (permissions.canComment()) return Permissions.CAN_COMMENT;
- return Permissions.CAN_VIEW;
- };
-
- useBlockEntityCommands({
- id: props.task.id,
- scopeId: panel.splitHotkeyScope,
- onDeleted: closeTask,
- resolveEntity: () =>
- buildEntityData({
- id: props.task.id,
- name: taskName(),
- blockName: 'task',
- ownerId: props.ownerId,
- projectId: props.projectId,
- }),
- });
-
- return (
- <ViewBreadcrumbs.Item
- value={props.entry.value}
- metadata={props.entry.data}
- order={props.order}
- >
- {(item) => (
- <div class="flex min-w-0 items-center motion-safe:animate-[dialog-overlay-open_150ms_ease-out]">
- <ViewBreadcrumbs.Button
- class="gap-1.5"
- isActive={item.isActive()}
- onClick={() => {
- item.onSelect();
- focusTask();
- }}
- >
- <EntityIcon targetType="task" size="xs" class="shrink-0" />
- <span class="truncate">{taskName()}</span>
- </ViewBreadcrumbs.Button>
- <div class="shrink-0">
- <SplitFileMenu
- id={props.task.id}
- itemType="document"
- name={taskName()}
- ops={fileOperations}
- tools={menuTools}
- entityKind="task"
- permissions={menuPermissions()}
- onDuplicate={(id) => openTask({ id, fallbackName: taskName() })}
- onDelete={closeTask}
- />
- </div>
- </div>
- )}
- </ViewBreadcrumbs.Item>
- );
-}
-
-function TaskBreadcrumbSkeleton() {
- const [visible, setVisible] = createSignal(false);
-
- onMount(() => {
- const timeoutId = window.setTimeout(
- () => setVisible(true),
- TASK_BREADCRUMB_SKELETON_DELAY_MS
- );
- onCleanup(() => window.clearTimeout(timeoutId));
- });
-
- return (
- <Show when={visible()}>
- <ViewBreadcrumbs.Separator />
- <div
- aria-hidden="true"
- class="flex h-7 min-w-0 items-center gap-1.5 px-1"
- >
- <span class="skeleton-shimmer size-4 shrink-0 rounded bg-skeleton" />
- <span class="skeleton-shimmer h-3 w-24 rounded-full bg-skeleton" />
- </div>
- </Show>
- );
-}
-
function TaskDetailTopBar(props: {
documentId: string;
showTaskActions: boolean;
@@ -253,7 +81,7 @@ function TaskDetailTopBar(props: {
<SplitPanel.CloseButton class="hidden shrink-0 @max-[720px]/view-shell:flex" />
<ViewBreadcrumbs.Outlet
aria-label="Task location"
- fallback={<TaskBreadcrumbSkeleton />}
+ fallback={<EntityDetailBreadcrumbSkeleton />}
/>
<div class="ml-auto flex shrink-0 items-center gap-2">
<Show when={props.showTaskActions}>
@@ -272,7 +100,7 @@ function TaskDetailTopBar(props: {
function StackEntityDetail(props: { entry: EntityDetailEntry; order: number }) {
return (
<>
- <DetailBreadcrumbItem entry={props.entry} order={props.order} />
+ <EntityDetailBreadcrumbItem entry={props.entry} order={props.order} />
<EntityDetail target={props.entry.data} />
</>
);
@@ -347,14 +175,21 @@ export function TasksDetailView(props: { task: TaskDetailTarget }) {
onShareOpenChange={setShareOpen}
>
{(context) => (
- <TaskBreadcrumbItem
- entry={entry}
+ <MarkdownDetailBreadcrumbItem
+ value={entry.value}
+ metadata={entry.data}
order={state.entries.length}
- task={props.task}
+ documentId={props.task.id}
+ kind="task"
+ fallbackName={props.task.fallbackName}
ownerId={context.data.metadata.owner}
projectId={
context.data.metadata.projectId ?? undefined
}
+ onClose={closeTask}
+ onDuplicate={(id, name) =>
+ openTask({ id, fallbackName: name })
+ }
/>
)}
</TaskDetail>
diff --git a/docs/AGENT_GUIDE/surfaces.md b/docs/AGENT_GUIDE/surfaces.md
index 75783682ea..b03a0adfbf 100644
--- a/docs/AGENT_GUIDE/surfaces.md
+++ b/docs/AGENT_GUIDE/surfaces.md
@@ -391,10 +391,13 @@ label's font weight matches the file title. The link
restores the originating Drive view.
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.
+folders without navigating. The top bar keeps the full folder and file detail
+path in one breadcrumb trail. Folder containment uses `/` separators, while the
+transition to a file detail and nested detail navigation use the default `>`
+separator. Choosing a folder breadcrumb returns to that folder and clears newer
+file details. 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. The **Filter** menu reuses the
legacy **Type**, searchable **Tags**, and **Created by** submenus alongside **Files**
@@ -404,9 +407,15 @@ is restricted to your own files. Recent offers only file-scope filtering.
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.
+while Markdown, code/CSV, image, video, and unrecognized file clicks and Enter
+replace the list with a breadcrumbed detail. Choose the current location
+breadcrumb to return to the list; choosing an ancestor file drops newer detail
+entries. Opening a list row or sidebar favorite starts a new detail path; only
+navigation originating inside a detail appends to that path. Modified clicks and
+file types without a dedicated detail, including PDF and canvas, 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`