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(properties): iterate on collections and side-panel layout (#9138)

dev-rbe681120fe069
diff --git a/.agents/rules/web/ui.md b/.agents/rules/web/ui.md
index b0621135a3..3c70a26182 100644
--- a/.agents/rules/web/ui.md
+++ b/.agents/rules/web/ui.md
@@ -28,7 +28,8 @@ Components, styling, and interaction conventions.
component utilities and layer/inversion rules keep their own responsibilities.
Do not append separate border, Button, glass, or avatar theme blocks elsewhere.
- **FE-26** Prefer composition over configurability; keep reusable components
- small and free of queries/complex state.
+ small and free of queries/complex state. Prefer children or JSX slots over
+ render props when the parent provides no data to the child.
- **FE-27** Don't add `cursor-pointer` to clickable elements. Enforced by
ast-grep `tsx-no-cursor-pointer`, warning.
- **FE-28** Dialogs rely on Kobalte's default autofocus: make the intended
diff --git a/apps/web/src/components/app/side-panel/EntityMetadata.tsx b/apps/web/src/components/app/side-panel/EntityMetadata.tsx
index ff1fff8ad3..14c5a08192 100644
--- a/apps/web/src/components/app/side-panel/EntityMetadata.tsx
+++ b/apps/web/src/components/app/side-panel/EntityMetadata.tsx
@@ -2,7 +2,18 @@ import { type DateValue, formatDate } from '@core/util/date';
import { OwnerLabel } from '@entity/owner/owner-display';
import { type ParentProps, Show } from 'solid-js';
-/** Quiet metadata copy shared by every block information footer. */
+export function EntityMetadataRow(props: ParentProps<{ label: string }>) {
+ return (
+ <div class="flex min-w-0 items-center gap-3">
+ <span class="w-(--sidepanel-label-width) shrink-0 whitespace-nowrap">
+ {props.label}
+ </span>
+ <div class="min-w-0 flex-1 wrap-break-word">{props.children}</div>
+ </div>
+ );
+}
+
+/** Quiet metadata copy shared by every block information panel. */
export function EntityMetadata(
props: ParentProps<{
ownerId?: string | null;
@@ -11,22 +22,26 @@ export function EntityMetadata(
}>
) {
return (
- <div class="flex flex-col gap-1">
+ <div class="flex flex-col gap-2">
<Show when={props.ownerId}>
{(owner) => (
- <div class="flex min-w-0 items-center gap-1">
- Owned by <OwnerLabel ownerId={owner()} textOnly suppressClick />
- </div>
+ <EntityMetadataRow label="Owner">
+ <OwnerLabel ownerId={owner()} textOnly suppressClick />
+ </EntityMetadataRow>
)}
</Show>
<Show when={props.createdAt}>
{(created) => (
- <div>Created {formatDate(created(), { showTime: true })}</div>
+ <EntityMetadataRow label="Created">
+ {formatDate(created(), { showTime: true })}
+ </EntityMetadataRow>
)}
</Show>
<Show when={props.updatedAt}>
{(updated) => (
- <div>Last updated {formatDate(updated(), { showTime: true })}</div>
+ <EntityMetadataRow label="Last updated">
+ {formatDate(updated(), { showTime: true })}
+ </EntityMetadataRow>
)}
</Show>
{props.children}
diff --git a/apps/web/src/components/app/side-panel/FileSidePanelSections.tsx b/apps/web/src/components/app/side-panel/FileSidePanelSections.tsx
index e194cf3bd4..8865de8b6d 100644
--- a/apps/web/src/components/app/side-panel/FileSidePanelSections.tsx
+++ b/apps/web/src/components/app/side-panel/FileSidePanelSections.tsx
@@ -3,7 +3,6 @@ import {
EntityTagsSection,
} from '@app/features/property/side-panel/properties';
import { useBlockId } from '@core/block';
-import { EntityIcon } from '@core/component/EntityIcon';
import { openDocument } from '@core/component/LexicalMarkdown/component/core/BlockLink';
import { useCanEdit } from '@core/signal/permissions';
import { useBlockDocumentName } from '@core/util/currentBlockDocumentName';
@@ -13,8 +12,8 @@ import { OwnerLabel } from '@entity/owner/owner-display';
import { useDocumentMetadataQuery } from '@queries/storage/document-metadata';
import { createCallback } from '@solid-primitives/rootless';
import { createMemo, Show } from 'solid-js';
-import { EntityMetadata } from './EntityMetadata';
-import { SidePanel } from './SidePanel';
+import { EntityMetadata, EntityMetadataRow } from './EntityMetadata';
+import { SidePanel, type SidePanelSectionLayout } from './SidePanel';
export function FileSidePanelSections() {
return (
@@ -80,9 +79,10 @@ export function FilePropertiesSection(props: { order?: number }) {
title="Properties"
defaultOpen
order={props.order}
- >
- <PropertiesSectionContent />
- </SidePanel.Section>
+ render={(renderSection) => (
+ <PropertiesSectionContent renderSection={renderSection} />
+ )}
+ />
);
}
@@ -98,15 +98,17 @@ export function DocumentFilePropertiesSection(props: {
title="Properties"
defaultOpen
order={props.order}
- >
- <EntityPropertiesSection
- entityId={props.documentId}
- entityType="DOCUMENT"
- canEdit={props.canEdit}
- documentName={props.documentName}
- showTags={false}
- />
- </SidePanel.Section>
+ render={(renderSection) => (
+ <EntityPropertiesSection
+ entityId={props.documentId}
+ entityType="DOCUMENT"
+ canEdit={props.canEdit}
+ documentName={props.documentName}
+ showTags={false}
+ renderSection={renderSection}
+ />
+ )}
+ />
);
}
@@ -124,7 +126,9 @@ export function FileTagsSection(props: { order?: number }) {
);
}
-function PropertiesSectionContent() {
+function PropertiesSectionContent(props: {
+ renderSection: SidePanelSectionLayout;
+}) {
const blockId = useBlockId();
const canEdit = useCanEdit();
const documentName = useBlockDocumentName();
@@ -136,6 +140,7 @@ function PropertiesSectionContent() {
canEdit={canEdit()}
documentName={documentName()}
showTags={false}
+ renderSection={props.renderSection}
/>
);
}
@@ -163,10 +168,9 @@ function DetailsSectionContent(props: { documentId: string }) {
})()}
>
{(folder) => (
- <div class="flex items-center gap-1">
- Folder
+ <EntityMetadataRow label="Folder">
<FolderLink projectId={folder().id} projectName={folder().name} />
- </div>
+ </EntityMetadataRow>
)}
</Show>
</EntityMetadata>
@@ -187,9 +191,6 @@ export function FolderLink(props: { projectId: string; projectName: string }) {
' pointer-events-auto text-link hover:text-link-hover hover:bg-hover'
}
>
- <span class="relative size-3 shrink-0">
- <EntityIcon targetType="project" size="fill" />
- </span>
<span class="truncate underline decoration-current/20 decoration-[max(1px,0.1em)] underline-offset-2">
{props.projectName}
</span>
diff --git a/apps/web/src/components/app/side-panel/SidePanel.tsx b/apps/web/src/components/app/side-panel/SidePanel.tsx
index 42b3fdf249..90b8fc6e70 100644
--- a/apps/web/src/components/app/side-panel/SidePanel.tsx
+++ b/apps/web/src/components/app/side-panel/SidePanel.tsx
@@ -1,3 +1,4 @@
+import { CollapsibleSection } from '@app/components/view-shell/CollapsibleSection';
import { ListSkeleton } from '@app/components/view-shell/ListSkeleton';
import { usePreference } from '@app/preferences/use-preference';
import { useMaybeBlockAliasedName } from '@core/block';
@@ -7,7 +8,6 @@ import { TOKENS } from '@core/hotkey/tokens';
import { isMobile } from '@core/mobile/isMobile';
import { isTouchDevice } from '@core/mobile/isTouchDevice';
import ArrowLeft from '@icon/system/regular/arrow-left.svg';
-import CaretRight from '@icon/system/regular/caret-right.svg';
import CircleDashedEmpty from '@icon/system/regular/circle-dashed.svg';
import InfoIcon from '@icon/system/regular/info.svg';
import SidePanelIcon from '@icon/system/regular/sidebar-simple.svg';
@@ -571,8 +571,8 @@ function SidePanelOutlet(props: {
when={props.floating}
fallback={
<Scroll class="flex flex-col min-h-0">
+ <Metadata />
<Sections />
- <Footers />
</Scroll>
}
>
@@ -582,13 +582,13 @@ function SidePanelOutlet(props: {
props.scrollable !== false && 'overflow-y-auto overscroll-contain'
)}
>
+ <Metadata />
<Sections />
- <Footers />
</div>
</Show>
);
- function Footers() {
+ function Metadata() {
return (
<For each={sortedSections().filter((section) => section.footer)}>
{(section) => section.component(props.floating ?? false)}
@@ -597,7 +597,7 @@ function SidePanelOutlet(props: {
}
}
-/** Unheaded metadata always follows the panel's interactive sections. */
+/** Unheaded metadata appears before the panel's interactive sections. */
function Footer(props: ParentProps) {
const ctx = useContext(SidePanelContext);
if (!ctx)
@@ -609,12 +609,12 @@ function Footer(props: ParentProps) {
defaultOpen: false,
footer: true,
component: () => (
- <footer
- aria-label="Metadata"
- class="border-t border-edge-muted px-3 py-3 text-xs leading-relaxed text-ink-extra-muted"
+ <section
+ aria-label="Details"
+ class="border-b border-edge-muted p-3 text-xs leading-relaxed text-ink-muted"
>
<Suspense fallback={<Loading />}>{props.children}</Suspense>
- </footer>
+ </section>
),
});
onCleanup(() => ctx.unregister('metadata-footer'));
@@ -622,6 +622,11 @@ function Footer(props: ParentProps) {
return null;
}
+/** Native section composition; defer body content until the accordion opens. */
+export type SidePanelSectionLayout = (
+ content: () => JSX.Element,
+ actions?: JSX.Element
+) => JSX.Element;
/**
* A collapsible section that registers itself with the nearest SidePanel.Root.
*
@@ -629,6 +634,7 @@ function Footer(props: ParentProps) {
* inside the side panel's Accordion. Children evaluate lazily when the
* panel renders the section, so they only mount when the panel is visible.
*
+ * Use `render` when a provider must own both header actions and body content.
* Must be a descendant of `<SidePanel.Root>`. A standalone Layout creates one.
*/
function Section(
@@ -639,11 +645,12 @@ function Section(
/** Render order — lower numbers appear first. */
order?: number;
/**
- * Optional controls rendered at the right edge of the header row,
- * outside the collapse trigger — clicking them doesn't toggle the
- * section.
+ * Optional controls rendered at the right edge while the section is open,
+ * outside the collapse trigger. Keep them visible without hover.
*/
actions?: JSX.Element;
+ /** Compose header and body beneath a shared provider without a portal. */
+ render?: (layout: SidePanelSectionLayout) => JSX.Element;
}>
) {
const ctx = useContext(SidePanelContext);
@@ -660,7 +667,10 @@ function Section(
component: (floating) => (
<Accordion.Item
value={props.id}
- class={cn(floating && 'border-b border-edge-muted last:border-b-0')}
+ class={cn(
+ 'group/sidebar-section',
+ floating && 'border-b border-edge-muted last:border-b-0'
+ )}
>
<Show
when={floating}
@@ -684,26 +694,36 @@ function Section(
return null;
function SectionContent() {
- return (
- <>
- <Accordion.Header class="group flex items-center">
- <Accordion.Trigger class="px-2 py-3 flex flex-1 min-w-0 items-center justify-between gap-2 text-xs text-ink-muted hover:underline">
- <span>{props.title}</span>
- <CaretRight class="size-3 shrink-0 transition-transform duration-90 group-data-expanded:rotate-90" />
- </Accordion.Trigger>
- <Show when={props.actions}>
- <div class="shrink-0 pr-2">{props.actions}</div>
- </Show>
- </Accordion.Header>
- <Accordion.Content class="group/content overflow-hidden data-expanded:animate-accordion-down data-closed:animate-accordion-up">
- <Suspense fallback={<Loading />}>
- <div class="px-2 pb-2 text-sm opacity-0 group-data-expanded/content:opacity-100 transition-opacity duration-150 ease-out">
- {props.children}
- </div>
- </Suspense>
- </Accordion.Content>
- </>
- );
+ const renderSection: SidePanelSectionLayout = (content, actions) => {
+ const resolvedActions = children(() =>
+ actions === undefined ? props.actions : actions
+ );
+ return (
+ <>
+ <Accordion.Header class="flex min-w-0 items-center gap-1">
+ <Accordion.Trigger class="flex min-w-0 flex-1 items-center gap-1 rounded-lg p-3 text-left text-xs font-medium leading-5 text-ink-muted outline-none transition-colors group-hover/sidebar-section:text-ink focus-visible:outline-2 focus-visible:outline-accent">
+ <span class="min-w-0 truncate">{props.title}</span>
+ <CollapsibleSection.Indicator class="touch:opacity-100 group-focus-within/sidebar-section:opacity-100" />
+ </Accordion.Trigger>
+ <Show when={resolvedActions.toArray().length > 0}>
+ <div class="hidden shrink-0 items-center pr-3 group-data-expanded/sidebar-section:flex">
+ {resolvedActions()}
+ </div>
+ </Show>
+ </Accordion.Header>
+ <Accordion.Content class="group/content overflow-hidden data-expanded:animate-accordion-down data-closed:animate-accordion-up">
+ <Suspense fallback={<Loading />}>
+ <div class="px-3 pb-3 text-sm opacity-0 group-data-expanded/content:opacity-100 transition-opacity duration-150 ease-out">
+ {content()}
+ </div>
+ </Suspense>
+ </Accordion.Content>
+ </>
+ );
+ };
+
+ if (props.render) return props.render(renderSection);
+ return renderSection(() => props.children);
}
}
diff --git a/apps/web/src/features/block-call/component/sidepanel/CallSidePanelSections.tsx b/apps/web/src/features/block-call/component/sidepanel/CallSidePanelSections.tsx
index 94b8c21081..7af3cfc2e0 100644
--- a/apps/web/src/features/block-call/component/sidepanel/CallSidePanelSections.tsx
+++ b/apps/web/src/features/block-call/component/sidepanel/CallSidePanelSections.tsx
@@ -2,7 +2,11 @@ import { EntityActivitySectionConditional } from '@app/features/activity/views/e
import { EntityPropertiesSection } from '@app/features/property/side-panel/properties';
import { useCallContextOptional } from '@channel/Call/CallContext';
import { SidePanel } from '@components/app/side-panel';
-import { EntityMetadata } from '@components/app/side-panel/EntityMetadata';
+import {
+ EntityMetadata,
+ EntityMetadataRow,
+} from '@components/app/side-panel/EntityMetadata';
+import type { SidePanelSectionLayout } from '@components/app/side-panel/SidePanel';
import { References } from '@core/component/References';
import { useUserId } from '@core/context/user';
import { type DateValue, formatDate } from '@core/util/date';
@@ -34,11 +38,13 @@ export function CallSidePanelSections(props: CallSidePanelSectionsProps) {
title="Properties"
defaultOpen
order={15}
- >
- <Suspense fallback={<SidePanel.Loading />}>
- <PropertiesSectionContent record={props.record} />
- </Suspense>
- </SidePanel.Section>
+ render={(renderSection) => (
+ <PropertiesSectionContent
+ record={props.record}
+ renderSection={renderSection}
+ />
+ )}
+ />
<Show when={props.record.channelId != null}>
<SidePanel.Section id="sharing" title="Sharing" order={20}>
<SharingSectionContent record={props.record} />
@@ -65,21 +71,36 @@ function DetailsSectionContent(props: { record: CallRecord }) {
<EntityMetadata ownerId={record().createdBy}>
<Show when={startedAt()}>
{(value) => (
- <div>Started {formatDate(value(), { showTime: true })}</div>
+ <EntityMetadataRow label="Started">
+ {formatDate(value(), { showTime: true })}
+ </EntityMetadataRow>
)}
</Show>
<Show when={endedAt()}>
- {(value) => <div>Ended {formatDate(value(), { showTime: true })}</div>}
+ {(value) => (
+ <EntityMetadataRow label="Ended">
+ {formatDate(value(), { showTime: true })}
+ </EntityMetadataRow>
+ )}
</Show>
<Show when={durationMs()}>
- {(ms) => <div>{formatCallDuration(ms())}</div>}
+ {(ms) => (
+ <EntityMetadataRow label="Duration">
+ {formatCallDuration(ms())}
+ </EntityMetadataRow>
+ )}
</Show>
- <div>{record().isActive ? 'In progress' : 'Ended'}</div>
+ <EntityMetadataRow label="Status">
+ {record().isActive ? 'In progress' : 'Ended'}
+ </EntityMetadataRow>
</EntityMetadata>
);
}
-function PropertiesSectionContent(props: { record: CallRecord }) {
+function PropertiesSectionContent(props: {
+ record: CallRecord;
+ renderSection: SidePanelSectionLayout;
+}) {
// Tag/property writes are authorized server-side via the call's owning
// channel (edit access), mirroring the sharing control above, so the editor
// is always mounted and the backend rejects unauthorized mutations.
@@ -91,6 +112,7 @@ function PropertiesSectionContent(props: { record: CallRecord }) {
documentName={
props.record.customName ?? props.record.channelName ?? undefined
}
+ renderSection={props.renderSection}
/>
);
}
diff --git a/apps/web/src/features/block-chat/component/sidepanel/ChatSidePanelSections.tsx b/apps/web/src/features/block-chat/component/sidepanel/ChatSidePanelSections.tsx
index 62e7a3e8a3..dc83e6fff8 100644
--- a/apps/web/src/features/block-chat/component/sidepanel/ChatSidePanelSections.tsx
+++ b/apps/web/src/features/block-chat/component/sidepanel/ChatSidePanelSections.tsx
@@ -4,7 +4,11 @@ import {
EntityTagsSection,
} from '@app/features/property/side-panel/properties';
import { FolderLink, SidePanel } from '@components/app/side-panel';
-import { EntityMetadata } from '@components/app/side-panel/EntityMetadata';
+import {
+ EntityMetadata,
+ EntityMetadataRow,
+} from '@components/app/side-panel/EntityMetadata';
+import type { SidePanelSectionLayout } from '@components/app/side-panel/SidePanel';
import { useBlockId } from '@core/block';
import { useCanEdit } from '@core/signal/permissions';
import { useChatDataQuery } from '@queries/cognition/chat-data';
@@ -33,11 +37,14 @@ export function ChatSidePanelSections() {
title="Properties"
defaultOpen
order={30}
- >
- <Suspense fallback={<SidePanel.Loading />}>
- <ChatPropertiesContent chatId={chatId} canEdit={canEdit()} />
- </Suspense>
- </SidePanel.Section>
+ render={(renderSection) => (
+ <ChatPropertiesContent
+ chatId={chatId}
+ canEdit={canEdit()}
+ renderSection={renderSection}
+ />
+ )}
+ />
<EntityActivitySectionConditional
entityId={chatId}
entityType="CHAT"
@@ -68,17 +75,20 @@ function ChatDetailsContent(props: { chatId: string }) {
})()}
>
{(folder) => (
- <div class="flex items-center gap-1">
- Folder
+ <EntityMetadataRow label="Folder">
<FolderLink projectId={folder().id} projectName={folder().name} />
- </div>
+ </EntityMetadataRow>
)}
</Show>
</EntityMetadata>
);
}
-function ChatPropertiesContent(props: { chatId: string; canEdit: boolean }) {
+function ChatPropertiesContent(props: {
+ chatId: string;
+ canEdit: boolean;
+ renderSection: SidePanelSectionLayout;
+}) {
const query = useChatDataQuery(() => props.chatId);
return (
@@ -88,6 +98,7 @@ function ChatPropertiesContent(props: { chatId: string; canEdit: boolean }) {
canEdit={props.canEdit}
documentName={query.data?.name}
showTags={false}
+ renderSection={props.renderSection}
/>
);
}
diff --git a/apps/web/src/features/block-email/component/sidepanel/EmailSidePanelSections.tsx b/apps/web/src/features/block-email/component/sidepanel/EmailSidePanelSections.tsx
index 3d93d85fd7..ee161a059e 100644
--- a/apps/web/src/features/block-email/component/sidepanel/EmailSidePanelSections.tsx
+++ b/apps/web/src/features/block-email/component/sidepanel/EmailSidePanelSections.tsx
@@ -33,8 +33,7 @@ export function EmailSidePanelSections(props: EmailSidePanelSectionsProps) {
title="Properties"
defaultOpen
order={30}
- >
- <Suspense fallback={<SidePanel.Loading />}>
+ render={(renderSection) => (
<EntityPropertiesSection
entityId={props.threadId}
entityType="THREAD"
@@ -42,9 +41,10 @@ export function EmailSidePanelSections(props: EmailSidePanelSectionsProps) {
documentName={props.title}
propertyFilter={(property) => property.isMetadata !== true}
showTags={false}
+ renderSection={renderSection}
/>
- </Suspense>
- </SidePanel.Section>
+ )}
+ />
<EntityActivitySectionConditional
entityId={props.threadId}
entityType="THREAD"
diff --git a/apps/web/src/features/block-md/component/InlineTaskProperties.tsx b/apps/web/src/features/block-md/component/InlineTaskProperties.tsx
index bddffa0234..c3c0aa0f6d 100644
--- a/apps/web/src/features/block-md/component/InlineTaskProperties.tsx
+++ b/apps/web/src/features/block-md/component/InlineTaskProperties.tsx
@@ -1,6 +1,7 @@
import { useFeatureFlag } from '@app/lib/analytics/posthog';
import { ProgressChip } from '@core/component/LexicalMarkdown/component/status/Progress';
import { enableProjects } from '@core/constant/featureFlags';
+import { fireAndForget } from '@core/util/fireAndForget';
import { buildTaskProjectDefaultProperty } from '@entity/extractors-property';
import { AddPropertyButton } from '@property/component/AddPropertyButton';
import { Modals } from '@property/component/modal';
@@ -84,7 +85,7 @@ export function InlineTaskProperties() {
if (definitionIds?.length) {
setPendingPins((pending) => new Set([...pending, ...definitionIds]));
}
- refetch();
+ fireAndForget(refetch(), 'inline-task-property-added-refresh');
};
const clearPendingPin = (definitionId: string) => {
setPendingPins((pending) => {
diff --git a/apps/web/src/features/block-md/component/sidepanel/MarkdownSidePanelSections.tsx b/apps/web/src/features/block-md/component/sidepanel/MarkdownSidePanelSections.tsx
index 45122c6225..9f5d2287e3 100644
--- a/apps/web/src/features/block-md/component/sidepanel/MarkdownSidePanelSections.tsx
+++ b/apps/web/src/features/block-md/component/sidepanel/MarkdownSidePanelSections.tsx
@@ -11,9 +11,12 @@ import {
GithubPullRequestDetailsRows,
SidePanel,
} from '@components/app/side-panel';
-import { EntityMetadata } from '@components/app/side-panel/EntityMetadata';
+import {
+ EntityMetadata,
+ EntityMetadataRow,
+} from '@components/app/side-panel/EntityMetadata';
+import type { SidePanelSectionLayout } from '@components/app/side-panel/SidePanel';
import { useSplitLayout } from '@components/app/split-layout/layout';
-import { EntityIcon } from '@core/component/EntityIcon';
import { openDocument } from '@core/component/LexicalMarkdown/component/core/BlockLink';
import { Wordcount } from '@core/component/LexicalMarkdown/component/status/Wordcount';
import { Notifications } from '@core/component/Notifications';
@@ -49,7 +52,7 @@ import { useMarkdownName } from '../MarkdownNameProvider';
import { TaskDuplicateMatchesSidePanelSection } from '../TaskDuplicateMatches';
import { MarkdownReferencesSection } from './MarkdownReferencesSection';
-/** Registers markdown header actions, panel sections, and metadata footer. */
+/** Registers markdown header actions, panel sections, and shared metadata. */
export function MarkdownSidePanelSections() {
const { documentId, kind, permissions } = useMarkdownDocument();
const canEdit = permissions.canEdit;
@@ -83,10 +86,10 @@ export function MarkdownSidePanelSections() {
</div>
</SidePanel.HeaderActions>
<SidePanel.Footer>
+ <DetailsSectionContent documentId={documentId()} />
<Show when={!isTask()}>
<StatsSectionContent />
</Show>
- <DetailsSectionContent documentId={documentId()} />
</SidePanel.Footer>
<EntityTagsSection
entityId={documentId()}
@@ -99,14 +102,16 @@ export function MarkdownSidePanelSections() {
title="Properties"
defaultOpen
order={25}
- >
- <PropertiesSectionContent
- documentId={documentId()}
- isTask={isTask()}
- canEdit={canEdit()}
- documentName={displayName() ?? ''}
- />
- </SidePanel.Section>
+ render={(renderSection) => (
+ <PropertiesSectionContent
+ documentId={documentId()}
+ isTask={isTask()}
+ canEdit={canEdit()}
+ documentName={displayName() ?? ''}
+ renderSection={renderSection}
+ />
+ )}
+ />
<EntityActivitySectionConditional
entityId={documentId()}
entityType={propertiesEntityType()}
@@ -158,10 +163,9 @@ function DetailsGrid(props: {
>
<Show when={props.folder()}>
{(folder) => (
- <div class="flex items-center gap-1">
- Folder
+ <EntityMetadataRow label="Folder">
<FolderLink projectId={folder().id} projectName={folder().name} />
- </div>
+ </EntityMetadataRow>
)}
</Show>
</EntityMetadata>
@@ -178,9 +182,6 @@ function FolderLink(props: { projectId: string; projectName: string }) {
{...navHandlers}
class="pointer-events-auto min-w-0 truncate py-0.5 rounded-xs text-link hover:text-link-hover hover:bg-hover focus:bg-active"
>
- <span class="relative top-[0.125em] size-[1em] inline-flex mx-1">
- <EntityIcon targetType="project" size="fill" />
- </span>
<span class="underline decoration-current/20 decoration-[max(1px,0.1em)] underline-offset-2">
{props.projectName}
</span>
@@ -197,6 +198,7 @@ function PropertiesSectionContent(props: {
isTask: boolean;
canEdit: boolean;
documentName: string;
+ renderSection: SidePanelSectionLayout;
}) {
const { state } = useMarkdownDocument();
const mdData = state.editor.md;
@@ -234,6 +236,7 @@ function PropertiesSectionContent(props: {
onPropertyPinned={mdData.editor ? pins.pin : undefined}
onPropertyUnpinned={pins.unpin}
showTags={false}
+ renderSection={props.renderSection}
// A task joins a project through its Project property, edited like the others.
defaultProperties={() =>
props.isTask && projects().enabled
@@ -266,8 +269,13 @@ function StatsSectionContent() {
<Show when={md.wordcountStats}>
{(stats) => (
<Wordcount.Root stats={stats()}>
- <div class="mb-1">
- <Wordcount.Words /> words · <Wordcount.Characters /> characters
+ <div class="mt-2 flex flex-col gap-2">
+ <EntityMetadataRow label="Words">
+ <Wordcount.Words />
+ </EntityMetadataRow>
+ <EntityMetadataRow label="Characters">
+ <Wordcount.Characters />
+ </EntityMetadataRow>
</div>
</Wordcount.Root>
)}
diff --git a/apps/web/src/features/block-pr/component/sidepanel/PrSidePanelSections.tsx b/apps/web/src/features/block-pr/component/sidepanel/PrSidePanelSections.tsx
index 07b1238e16..f80b1872fe 100644
--- a/apps/web/src/features/block-pr/component/sidepanel/PrSidePanelSections.tsx
+++ b/apps/web/src/features/block-pr/component/sidepanel/PrSidePanelSections.tsx
@@ -2,6 +2,7 @@ import {
GithubPullRequestChecksContent,
SidePanel,
} from '@components/app/side-panel';
+import { EntityMetadataRow } from '@components/app/side-panel/EntityMetadata';
import type { GithubPullRequestWithDetails } from '@queries/storage/github-pull-requests';
import { Show } from 'solid-js';
import { PrAgentSessionsSection } from './PrAgentSessionsSection';
@@ -18,27 +19,37 @@ export function PrSidePanelSections(props: {
{(pr) => (
<div class="flex flex-col gap-1">
<Show when={pr().authorLogin}>
- {(author) => <div>Authored by {author()}</div>}
+ {(author) => (
+ <EntityMetadataRow label="Author">
+ {author()}
+ </EntityMetadataRow>
+ )}
</Show>
- <div>
+ <EntityMetadataRow label="Repository">
{pr().owner}/{pr().repo}
- </div>
+ </EntityMetadataRow>
<Show when={pr().status}>
- {(status) => <div class="capitalize">{status()}</div>}
+ {(status) => (
+ <EntityMetadataRow label="Status">
+ <span class="capitalize">{status()}</span>
+ </EntityMetadataRow>
+ )}
</Show>
<Show when={pr().additions != null || pr().deletions != null}>
- <div>
+ <EntityMetadataRow label="Changes">
+{pr().additions ?? 0} / −{pr().deletions ?? 0}
- </div>
+ </EntityMetadataRow>
</Show>
- <a
- href={pr().url}
- target="_blank"
- rel="noreferrer"
- class="truncate hover:underline"
- >
- {pr().displayName}
- </a>
+ <EntityMetadataRow label="Pull request">
+ <a
+ href={pr().url}
+ target="_blank"
+ rel="noreferrer"
+ class="block truncate hover:underline"
+ >
+ {pr().displayName}
+ </a>
+ </EntityMetadataRow>
</div>
)}
</Show>
diff --git a/apps/web/src/features/block-project/component/sidepanel/ProjectSidePanelSections.tsx b/apps/web/src/features/block-project/component/sidepanel/ProjectSidePanelSections.tsx
index 30d9b7de6d..2f1424e68d 100644
--- a/apps/web/src/features/block-project/component/sidepanel/ProjectSidePanelSections.tsx
+++ b/apps/web/src/features/block-project/component/sidepanel/ProjectSidePanelSections.tsx
@@ -34,8 +34,7 @@ export function ProjectSidePanelSections() {
title="Properties"
defaultOpen
order={30}
- >
- <Suspense fallback={<SidePanel.Loading />}>
+ render={(renderSection) => (
<EntityPropertiesSection
entityId={projectId}
entityType="PROJECT"
@@ -43,9 +42,10 @@ export function ProjectSidePanelSections() {
documentName={projectName()}
propertyFilter={(property) => property.isMetadata !== true}
showTags={false}
+ renderSection={renderSection}
/>
- </Suspense>
- </SidePanel.Section>
+ )}
+ />
<EntityActivitySectionConditional
entityId={projectId}
entityType="PROJECT"
diff --git a/apps/web/src/features/crm/views/company-detail.tsx b/apps/web/src/features/crm/views/company-detail.tsx
index acf83fe9fd..82e5f0451f 100644
--- a/apps/web/src/features/crm/views/company-detail.tsx
+++ b/apps/web/src/features/crm/views/company-detail.tsx
@@ -145,9 +145,13 @@ export function Company(props: {
title="Properties"
order={15}
defaultOpen
- >
- <CompanyPropertiesSection companyId={props.companyId} />
- </SidePanel.Section>
+ render={(renderSection) => (
+ <CompanyPropertiesSection
+ companyId={props.companyId}
+ renderSection={renderSection}
+ />
+ )}
+ />
<Show when={listsEnabled()}>
<Suspense>
<CompanyListsSection companyId={props.companyId} />
diff --git a/apps/web/src/features/crm/views/company-properties-section.tsx b/apps/web/src/features/crm/views/company-properties-section.tsx
index 9c155be702..82ff6f9c5b 100644
--- a/apps/web/src/features/crm/views/company-properties-section.tsx
+++ b/apps/web/src/features/crm/views/company-properties-section.tsx
@@ -1,4 +1,5 @@
import { EntityPropertiesSection } from '@app/features/property/side-panel/properties/EntityPropertiesSection';
+import type { SidePanelSectionLayout } from '@components/app/side-panel/SidePanel';
import { buildCompanyDefaultProperties } from '@entity/extractors-property';
import { SYSTEM_PROPERTY_IDS } from '@property/constants';
import { useCrmPermissions, useDealStages } from './use-crm';
@@ -14,7 +15,10 @@ import { useCrmPermissions, useDealStages } from './use-crm';
* customized stages, the panel edits the team Stage definition and the
* fetched system Stage row is hidden.
*/
-export function CompanyPropertiesSection(props: { companyId: string }) {
+export function CompanyPropertiesSection(props: {
+ companyId: string;
+ renderSection: SidePanelSectionLayout;
+}) {
const { canEditCrm } = useCrmPermissions();
const dealStages = useDealStages();
@@ -39,6 +43,7 @@ export function CompanyPropertiesSection(props: { companyId: string }) {
entityId={props.companyId}
entityType="COMPANY"
canEdit={canEditCrm()}
+ renderSection={props.renderSection}
defaultProperties={defaultProperties}
pinnedPropertyDefinitionOrder={pinnedOrder()}
hidePropertyDefinitionIds={
diff --git a/apps/web/src/features/projects/views/project-workspace.tsx b/apps/web/src/features/projects/views/project-workspace.tsx
index 856a3b954c..9861671848 100644
--- a/apps/web/src/features/projects/views/project-workspace.tsx
+++ b/apps/web/src/features/projects/views/project-workspace.tsx
@@ -68,23 +68,25 @@ export function ProjectWorkspace(props: {
title="Properties"
defaultOpen
order={1}
- >
- <Show when={props.project.id} keyed>
- {(projectId) => (
- <EntityPropertiesSection
- entityId={projectId}
- entityType="INITIATIVE"
- canEdit={canEdit()}
- documentName={props.project.name}
- showTags={false}
- defaultProperties={() => [...definitions.properties()]}
- requiredPropertyDefinitionIds={PROJECT_PROPERTY_ORDER}
- pinnedPropertyDefinitionOrder={PROJECT_PROPERTY_ORDER}
- onPropertiesChanged={props.source.refresh}
- />
- )}
- </Show>
- </SidePanel.Section>
+ render={(renderSection) => (
+ <Show when={props.project.id} keyed>
+ {(projectId) => (
+ <EntityPropertiesSection
+ entityId={projectId}
+ entityType="INITIATIVE"
+ canEdit={canEdit()}
+ documentName={props.project.name}
+ showTags={false}
+ defaultProperties={() => [...definitions.properties()]}
+ requiredPropertyDefinitionIds={PROJECT_PROPERTY_ORDER}
+ pinnedPropertyDefinitionOrder={PROJECT_PROPERTY_ORDER}
+ onPropertiesChanged={props.source.refresh}
+ renderSection={renderSection}
+ />
+ )}
+ </Show>
+ )}
+ />
<div class="flex size-full min-h-0 min-w-0 flex-col overflow-hidden">
<Show when={error()}>
{(message) => (
diff --git a/apps/web/src/features/property/README.md b/apps/web/src/features/property/README.md
index 01a569cf0b..bb63c20078 100644
--- a/apps/web/src/features/property/README.md
+++ b/apps/web/src/features/property/README.md
@@ -8,3 +8,69 @@ in any layout, replacing the duplicated `PropertyValue` / `CondensedPropertyValu
/ `InlinePropertyValue` / `ListPropertyValue` trees.
Debug page: `/props-debug` (LOCAL_ONLY).
+
+## Side-panel collections
+
+Property rows use a 4px vertical gap, including inline Tags and the boundary
+between regular fields and collection fields.
+Keep 16px between populated property lists and the bottom Add property action,
+with spacing on the list so empty lists leave no gap above the action.
+Keep property names on one line. Collection headers use available space up to
+their actions, truncating only the remaining overflow; value rows retain the
+shared label column.
+
+`side-panel/properties/EntityCollectionProperty.tsx` renders non-user, multi-entity
+properties. Empty collections show only the property header, with no placeholder
+or reserved content area. Their labeled ghost Add button aligns with the shared
+value-selector column unless a longer name needs more room. Populated collections use an icon-only ghost Add button
+at the right, immediately before the pin action. Both use extra-muted ink until
+hovered or keyboard-focused. During compatible app-item drags, the property name
+uses accent ink and a tray-arrow drop icon while the row stays compact.
+Hovering a populated property highlights its existing item list as the dropzone,
+without adding a separate box or shifting items. Empty properties reveal a
+full-width dashed dropzone. Both use 300ms transitions with reduced-motion support.
+This first pass uses direct hover, not pointer proximity. During app-item drags,
+collection Add buttons are hidden with their layout space preserved. Incompatible
+or unavailable collections show no rejection feedback. One target covers the
+name, values, and dropzone, with bounds refreshed as it resizes.
+Drops append a reference using the same entity-type conversion as the picker,
+ignore duplicate references and the owning entity's type-and-ID pair, and retain
+existing values. Picker saves, drops, chip removal, and row removal share a pending
+state until refresh completes. New references appear immediately as pending
+chips with an inline spinner until saving and refresh finish. Removed references
+disappear immediately; a failed save restores them from the last confirmed values.
+Confirmed edits remain visible if refresh fails, and reconcile when the query
+reflects them. Subsequent edits use these confirmed values rather than stale query
+data. Other values remain visible. Failed saves clear pending additions through
+the existing error flow. Pending chips cannot be opened or removed. Collection rows
+retain their definition identity through query updates so loading state survives
+refreshed property objects. Dropped items use the drag label while preview metadata loads.
+Read-only, metadata, loading, saving, and open-editor states reject drops.
+Add and value edits stay disabled until the initial collection finishes loading.
+The accessible loading-status region stays mounted outside the collapsing drop
+feedback. Native file uploads are not supported here; the Add action remains
+available for keyboard and touch.
+Saved-item remove controls overlay the chip's right edge on hover or keyboard
+focus and remain visible on touch. They reserve no layout space or change chip
+width. Chip backgrounds use `bg-surface` at `Layer depth={3}`.
+
+Collection drop handling and save callbacks stay in the property callers.
+
+The empty dedicated Tags section shows one compact, tag-icon Add tags outline button,
+without a separate message, card, title, or description. The existing tag picker
+handles the action; read-only sections show “No tags added yet” instead.
+Inline Tags property rows retain their compact treatment.
+
+## Side-panel row actions
+
+Compose `PropertyRowActions.Root`, `.Pin`, and `.Remove` through children so
+callers own action order. Multi-value layouts and collections accept JSX children,
+not action render callbacks. Each collection row owns one saving signal shared
+with its collection editor and row actions.
+
+## Side-panel header actions
+
+Pass `renderSection` from `SidePanel.Section` to `EntityPropertiesSection` to
+compose its icon-only Add property action directly in the header. The existing
+property provider owns the header action and picker; no action portal is used.
+Read-only sections and `showAddProperty={false}` omit the action.
diff --git a/apps/web/src/features/property/component/CollectionEmptyState.tsx b/apps/web/src/features/property/component/CollectionEmptyState.tsx
new file mode 100644
index 0000000000..47ebaa057f
--- /dev/null
+++ b/apps/web/src/features/property/component/CollectionEmptyState.tsx
@@ -0,0 +1,28 @@
+import { cn } from '@ui/utils/classname';
+import { type ComponentProps, type JSX, splitProps } from 'solid-js';
+
+export type CollectionEmptyStateProps = Omit<
+ ComponentProps<'div'>,
+ 'children'
+> & {
+ message: JSX.Element;
+ action?: JSX.Element;
+};
+
+export function CollectionEmptyState(props: CollectionEmptyStateProps) {
+ const [local, rest] = splitProps(props, ['message', 'action', 'class']);
+
+ return (
+ <div
+ data-slot="collection-empty-state"
+ class={cn(
+ 'flex w-full min-w-0 flex-col items-start gap-2 text-left',
+ local.class
+ )}
+ {...rest}
+ >
+ <span class="text-xs text-ink-extra-muted">{local.message}</span>
+ {local.action}
+ </div>
+ );
+}
diff --git a/apps/web/src/features/property/hooks/useEntityProperties.ts b/apps/web/src/features/property/hooks/useEntityProperties.ts
index 8be70c16f7..225215a0a4 100644
--- a/apps/web/src/features/property/hooks/useEntityProperties.ts
+++ b/apps/web/src/features/property/hooks/useEntityProperties.ts
@@ -14,6 +14,7 @@ import { ERROR_MESSAGES } from '../utils/errorHandling';
*
* This hook focuses purely on data management and returns structured results.
* UI feedback (toasts, notifications) is handled by mutations.
+ * Refetch returns its completion promise; ignored refresh failures remain reported.
*
* @param entityId - The ID of the entity to fetch properties for
* @param entityType - The type of entity (e.g., 'document', 'channel', 'project')
@@ -27,7 +28,7 @@ export function useEntityProperties(
properties: Accessor<Property[]>;
isLoading: Accessor<boolean>;
error: Accessor<string | null>;
- refetch: () => void;
+ refetch: () => Promise<unknown>;
addProperty: (propertyDefinitionId: string) => Promise<void>;
removeProperty: (propertyId: string) => Promise<void>;
} {
@@ -44,7 +45,11 @@ export function useEntityProperties(
properties: () => query.data ?? [],
isLoading: () => query.isLoading,
error: () => (query.error ? ERROR_MESSAGES.PROPERTY_FETCH : null),
- refetch: () => fireAndForget(query.refetch(), 'entity-properties'),
+ refetch: () => {
+ const refresh = query.refetch();
+ fireAndForget(refresh, 'entity-properties');
+ return refresh;
+ },
addProperty: (propertyDefinitionId: string) =>
addMutation.mutateAsync({ entityId, entityType, propertyDefinitionId }),
removeProperty: (propertyId: string) =>
diff --git a/apps/web/src/features/property/side-panel/properties/EntityCollectionProperty.tsx b/apps/web/src/features/property/side-panel/properties/EntityCollectionProperty.tsx
new file mode 100644
index 0000000000..09611044c1
--- /dev/null
+++ b/apps/web/src/features/property/side-panel/properties/EntityCollectionProperty.tsx
@@ -0,0 +1,509 @@
+import { t } from '@app/lib/i18n';
+import type { BlockAlias, BlockName } from '@core/block';
+import { PopupPreview } from '@core/component/DocumentPreview';
+import { HoverCard } from '@core/component/HoverCard';
+import { openDocument } from '@core/component/LexicalMarkdown/component/core/BlockLink';
+import { itemToBlockName } from '@core/constant/allBlocks';
+import { fireAndForget } from '@core/util/fireAndForget';
+import { useSplitNavigationHandler } from '@core/util/useSplitNavigationHandler';
+import Plus from '@icon/system/regular/plus.svg';
+import SpinnerIcon from '@icon/system/regular/spinner.svg';
+import DropIcon from '@icon/system/regular/tray-arrow-down.svg';
+import DeleteIcon from '@icon/system/regular/x.svg';
+import { Property as PropertyNS, useProperty } from '@property';
+import { usePropertiesContext } from '@property/context/PropertiesContext';
+import { usePropertyEntityDisplay } from '@property/hooks';
+import type { Property, PropertyApiValues } from '@property/types';
+import { getEntityValues } from '@property/utils';
+import { isAccessiblePreviewItem, useItemPreview } from '@queries/preview';
+import type { EntityReference } from '@service-properties/generated/schemas/entityReference';
+import type { EntityType } from '@service-properties/generated/schemas/entityType';
+import { Button, Layer } from '@ui';
+import { cn } from '@ui/utils/classname';
+import {
+ batch,
+ createEffect,
+ createMemo,
+ createSignal,
+ For,
+ type JSX,
+ Show,
+ type Signal,
+} from 'solid-js';
+import { createEntityCollectionDropTarget } from './entity-collection-drop';
+
+type PendingEntityReference = EntityReference & { displayName?: string };
+
+function sameEntityReference(left: EntityReference, right: EntityReference) {
+ return (
+ left.entity_id === right.entity_id &&
+ left.entity_type === right.entity_type &&
+ (left.specific_message_id ?? null) === (right.specific_message_id ?? null)
+ );
+}
+
+export function EntityCollectionProperty(props: {
+ entityId: string;
+ loading?: boolean;
+ onRefresh: () => Promise<unknown>;
+ property: Property;
+ onSave: (property: Property, values: PropertyApiValues) => Promise<void>;
+ saving: Signal<boolean>;
+ children: JSX.Element;
+}) {
+ const ctx = usePropertiesContext();
+ const [isSaving, setIsSaving] = props.saving;
+ const [confirmedReferences, setConfirmedReferences] =
+ createSignal<EntityReference[]>();
+ const displayedProperty = createMemo(() => {
+ const property = props.property;
+ const confirmed = confirmedReferences();
+ if (property.valueType !== 'ENTITY' || !confirmed) return property;
+ return { ...property, value: confirmed };
+ });
+
+ // Retire confirmed edits only after refresh, not during another optimistic save.
+ createEffect(() => {
+ if (isSaving()) return;
+ const confirmed = confirmedReferences();
+ if (!confirmed) return;
+ const current = getEntityValues(props.property);
+ if (current.length !== confirmed.length) return;
+ const unmatched = [...current];
+ for (const reference of confirmed) {
+ const index = unmatched.findIndex((value) =>
+ sameEntityReference(value, reference)
+ );
+ if (index < 0) return;
+ unmatched.splice(index, 1);
+ }
+ setConfirmedReferences(undefined);
+ });
+
+ const [pendingReferences, setPendingReferences] = createSignal<
+ PendingEntityReference[]
+ >([]);
+ const [pendingRemovals, setPendingRemovals] = createSignal<EntityReference[]>(
+ []
+ );
+ const saveProperty = async (
+ property: Property,
+ values: PropertyApiValues,
+ displayName?: string
+ ) => {
+ if (!ctx.canEdit || property.isMetadata || props.loading || isSaving())
+ return;
+ const currentRefs = getEntityValues(property);
+ const nextRefs = values.valueType === 'ENTITY' ? (values.refs ?? []) : [];
+ batch(() => {
+ setPendingReferences(
+ nextRefs
+ .filter(
+ (reference) =>
+ !currentRefs.some((current) =>
+ sameEntityReference(current, reference)
+ )
+ )
+ .map((reference) => ({ ...reference, displayName }))
+ );
+ setPendingRemovals(
+ currentRefs.filter(
+ (reference) =>
+ !nextRefs.some((next) => sameEntityReference(next, reference))
+ )
+ );
+ setIsSaving(true);
+ });
+ try {
+ await props.onSave(property, values);
+ setConfirmedReferences(nextRefs);
+ await props.onRefresh();
+ } finally {
+ batch(() => {
+ setPendingReferences([]);
+ setPendingRemovals([]);
+ setIsSaving(false);
+ });
+ }
+ };
+
+ return (
+ <PropertyNS.Root
+ property={displayedProperty()}
+ canEdit={ctx.canEdit}
+ onSave={saveProperty}
+ >
+ <EntityCollectionPropertyBody
+ entityId={props.entityId}
+ loading={props.loading}
+ pendingReferences={pendingReferences()}
+ pendingRemovals={pendingRemovals()}
+ onSave={saveProperty}
+ property={displayedProperty()}
+ saving={props.saving}
+ >
+ {props.children}
+ </EntityCollectionPropertyBody>
+ <PropertyNS.PopoverEditor
+ entitySelfFilter={{
+ entityType: ctx.entityType,
+ blockId: props.entityId,
+ }}
+ />
+ </PropertyNS.Root>
+ );
+}
+
+function EntityCollectionPropertyBody(props: {
+ entityId: string;
+ loading?: boolean;
+ pendingReferences: PendingEntityReference[];
+ pendingRemovals: EntityReference[];
+ onSave: (
+ property: Property,
+ values: PropertyApiValues,
+ displayName?: string
+ ) => Promise<void>;
+ property: Property;
+ saving: Signal<boolean>;
+ children: JSX.Element;
+}) {
+ const ctx = usePropertiesContext();
+ const propertyCtx = useProperty();
+ const entities = () => getEntityValues(props.property);
+ const pendingReference = (reference: EntityReference) =>
+ props.pendingReferences.find((pending) =>
+ sameEntityReference(pending, reference)
+ );
+ const isPending = (reference: EntityReference) =>
+ Boolean(pendingReference(reference));
+ const isPendingRemoval = (reference: EntityReference) =>
+ props.pendingRemovals.some((removed) =>
+ sameEntityReference(removed, reference)
+ );
+ const displayedEntities = () => [
+ ...entities().filter(
+ (reference) => !isPending(reference) && !isPendingRemoval(reference)
+ ),
+ ...props.pendingReferences,
+ ];
+ const hasItems = () => displayedEntities().length > 0;
+ const isReadOnly = () => !ctx.canEdit || props.property.isMetadata;
+ const [isSaving] = props.saving;
+ const dropTarget = createEntityCollectionDropTarget({
+ property: () => props.property,
+ selfId: () => props.entityId,
+ selfType: () => ctx.entityType,
+ disabled: () =>
+ Boolean(
+ isReadOnly() || props.loading || isSaving() || propertyCtx.editorOpen()
+ ),
+ onDrop: (reference, name) =>
+ saveReferences([...entities(), reference], name),
+ });
+ const isDraggingOver = () => dropTarget?.isOver() ?? false;
+ const canDrop = () => dropTarget?.canDrop() ?? false;
+ const isDragging = () => dropTarget?.isDragging() ?? false;
+ const showDropZone = () => isDraggingOver();
+ const handleAdd: JSX.EventHandler<HTMLButtonElement, MouseEvent> = (
+ event
+ ) => {
+ event.stopPropagation();
+ if (isReadOnly() || props.loading || isSaving()) return;
+ propertyCtx.openEditor(event.currentTarget);
+ };
+
+ const saveReferences = (refs: EntityReference[], displayName?: string) =>
+ props.onSave(
+ props.property,
+ {
+ valueType: 'ENTITY',
+ refs: refs.length > 0 ? refs : null,
+ },
+ displayName
+ );
+
+ const handleRemoveEntity = (reference: EntityReference) =>
+ saveReferences(
+ entities().filter((entity) => !sameEntityReference(entity, reference))
+ );
+
+ return (
+ <div
+ ref={(element) => dropTarget?.ref(element)}
+ role="group"
+ aria-label={props.property.displayName}
+ class={cn(
+ 'group/property-row grid min-h-7 min-w-0 items-center gap-x-3',
+ hasItems()
+ ? 'grid-cols-[minmax(0,1fr)_auto]'
+ : 'grid-cols-[minmax(var(--sidepanel-label-width,auto),max-content)_minmax(max-content,1fr)]'
+ )}
+ >
+ <span
+ class={cn(
+ 'flex min-w-0 items-center gap-1.5 transition-colors duration-150 motion-reduce:transition-none',
+ canDrop() ? 'text-accent' : 'text-ink-muted'
+ )}
+ title={props.property.displayName}
+ >
+ <span class="min-w-0 truncate">{props.property.displayName}</span>
+ <Show when={canDrop()}>
+ <DropIcon
+ class="size-3.5 shrink-0"
+ aria-hidden="true"
+ data-icon-motion="none"
+ />
+ </Show>
+ </span>
+ <div class="flex min-w-0 items-center">
+ <Show when={!isReadOnly()}>
+ <Button
+ type="button"
+ variant="ghost"
+ size={hasItems() ? 'icon-xs' : 'xs'}
+ class={cn(
+ 'text-ink-extra-muted not-data-disabled:focus-visible:text-ink',
+ hasItems() && 'ml-auto',
+ isDragging() && 'invisible'
+ )}
+ aria-label={`Add ${props.property.displayName}`}
+ tooltip={
+ hasItems() ? `Add ${props.property.displayName}` : undefined
+ }
+ disabled={props.loading || isSaving() || isDragging()}
+ onClick={handleAdd}
+ >
+ <Plus class="size-4" />
+ <Show when={!hasItems()}>{t('common.add')}</Show>
+ </Button>
+ </Show>
+ <div class={cn('flex shrink-0 items-center', !hasItems() && 'ml-auto')}>
+ {props.children}
+ </div>
+ </div>
+ <div class="col-span-2 min-w-0">
+ <div
+ class={cn(
+ 'flex flex-wrap gap-1.5 rounded-lg transition-colors duration-300 motion-reduce:transition-none',
+ hasItems() && 'mt-1 outline-1 outline-dashed outline-offset-2',
+ hasItems() && showDropZone()
+ ? 'bg-accent/10 outline-accent'
+ : 'outline-transparent'
+ )}
+ aria-busy={isSaving()}
+ >
+ <For each={displayedEntities()}>
+ {(entityRef) => (
+ <NonUserEntityChip
+ property={props.property}
+ entityId={entityRef.entity_id}
+ entityType={entityRef.entity_type}
+ specificMessageId={entityRef.specific_message_id}
+ pending={isPending(entityRef)}
+ pendingLabel={pendingReference(entityRef)?.displayName}
+ canEdit={!isReadOnly() && !props.loading && !isSaving()}
+ onRemove={() =>
+ fireAndForget(
+ handleRemoveEntity(entityRef),
+ 'property-collection-remove'
+ )
+ }
+ onEdit={(anchor) => {
+ if (isReadOnly() || props.loading || isSaving()) return;
+ propertyCtx.openEditor(anchor);
+ }}
+ />
+ )}
+ </For>
+ </div>
+ <span
+ class="sr-only"
+ role="status"
+ aria-live="polite"
+ aria-atomic="true"
+ >
+ {props.pendingReferences.length > 0 ? t('common.addingItem') : ''}
+ </span>
+ <Show when={!hasItems()}>
+ <div
+ aria-hidden={!showDropZone()}
+ class={cn(
+ 'grid transition-all duration-300 ease-out motion-reduce:transition-none',
+ showDropZone()
+ ? 'grid-rows-[1fr] opacity-100'
+ : 'grid-rows-[0fr] opacity-0'
+ )}
+ >
+ <div class="min-h-0 overflow-hidden">
+ <div class="mt-1 flex h-12 items-center justify-center gap-2 rounded-lg border border-dashed border-accent bg-accent/10 text-xs text-accent">
+ <DropIcon
+ class="size-4 shrink-0"
+ aria-hidden="true"
+ data-icon-motion="none"
+ />
+ <span>{t('common.dropToAdd')}</span>
+ </div>
+ </div>
+ </div>
+ </Show>
+ </div>
+ </div>
+ );
+}
+
+export function NonUserEntityChip(props: {
+ property: Property;
+ entityId: string;
+ entityType: EntityType;
+ specificMessageId?: string | null;
+ pending?: boolean;
+ canEdit?: boolean;
+ pendingLabel?: string;
+ onRemove?: () => void;
+ onEdit?: (anchor?: HTMLElement) => void;
+}) {
+ let containerRef: HTMLDivElement | undefined;
+ const { name, icon } = usePropertyEntityDisplay(
+ () => props.entityId,
+ () => props.entityType,
+ {
+ specificMessageId: () => props.specificMessageId,
+ }
+ );
+ const previewBlockType = () =>
+ getDocumentPreviewFallbackBlockType(props.entityType);
+ const isDocumentPreviewEntity = () =>
+ props.entityType === 'DOCUMENT' || props.entityType === 'TASK';
+
+ const openEditor = (event: MouseEvent) => {
+ if (!props.canEdit || !props.onEdit) return;
+ event.stopPropagation();
+ props.onEdit(containerRef);
+ };
+
+ return (
+ <Layer depth={3}>
+ <div
+ ref={containerRef}
+ class="group/collection-item relative inline-flex min-w-0 max-w-full border h-7 items-stretch border-edge-muted rounded-md bg-surface text-ink overflow-clip"
+ aria-busy={props.pending || undefined}
+ >
+ <Show
+ when={!props.pending}
+ fallback={
+ <span class="flex min-w-0 items-center gap-1.5 px-2 text-ink-muted">
+ <span class="shrink-0 flex items-center">{icon()}</span>
+ <span class="min-w-0 truncate">
+ {props.pendingLabel ?? name()}
+ </span>
+ <SpinnerIcon
+ class="size-3.5 shrink-0 animate-spin motion-reduce:animate-none"
+ aria-hidden="true"
+ />
+ </span>
+ }
+ >
+ <Show
+ when={isDocumentPreviewEntity()}
+ fallback={
+ <button
+ type="button"
+ class="flex min-w-0 max-w-full items-center gap-1.5 px-2 text-left"
+ onClick={openEditor}
+ disabled={!props.canEdit}
+ >
+ <span class="shrink-0 flex items-center">{icon()}</span>
+ <span class="min-w-0 truncate">{name()}</span>
+ </button>
+ }
+ >
+ <DocumentEntityChipButton
+ entityId={props.entityId}
+ fallbackBlockType={previewBlockType()}
+ icon={icon()}
+ name={name()}
+ />
+ </Show>
+ <Show when={props.canEdit && props.onRemove}>
+ <div class="absolute inset-y-0 right-0 flex border-l border-edge-muted bg-surface pointer-events-none opacity-0 not-touch:group-hover/collection-item:pointer-events-auto not-touch:group-hover/collection-item:opacity-100 group-focus-within/collection-item:pointer-events-auto group-focus-within/collection-item:opacity-100 touch:pointer-events-auto touch:opacity-100">
+ <Button
+ variant="ghost"
+ type="button"
+ size="icon-sm"
+ class="flex w-6 p-1 h-full shrink-0 rounded-none text-ink-muted not-disabled:hover:text-failure-ink"
+ onClick={(event) => {
+ event.stopPropagation();
+ props.onRemove?.();
+ }}
+ aria-label={`Remove ${name()}`}
+ >
+ <DeleteIcon class="size-3.5 touch:size-6 shrink-0 pointer-events-none" />
+ </Button>
+ </div>
+ </Show>
+ </Show>
+ </div>
+ </Layer>
+ );
+}
+
+function DocumentEntityChipButton(props: {
+ entityId: string;
+ fallbackBlockType: BlockName | BlockAlias | undefined;
+ icon: JSX.Element;
+ name: string;
+}) {
+ const [item] = useItemPreview(() => ({
+ id: props.entityId,
+ type: 'document',
+ }));
+ const blockType = () => {
+ const preview = item();
+ if (isAccessiblePreviewItem(preview)) {
+ return itemToBlockName(preview);
+ }
+ return props.fallbackBlockType;
+ };
+ const navHandlers = useSplitNavigationHandler<HTMLButtonElement>((event) => {
+ const targetBlockType = blockType();
+ if (!targetBlockType) return;
+ event.stopPropagation();
+ openDocument(targetBlockType, props.entityId, {}, event.shiftKey);
+ });
+
+ return (
+ <button
+ type="button"
+ class="flex min-w-0 max-w-full items-center gap-1.5 px-2 text-left"
+ {...navHandlers}
+ >
+ <span class="shrink-0 flex items-center">{props.icon}</span>
+ <HoverCard
+ trigger={<span class="truncate">{props.name}</span>}
+ content={
+ <PopupPreview
+ mouseEnter={() => {}}
+ mouseLeave={() => {}}
+ documentInfo={{
+ id: props.entityId,
+ name: props.name,
+ type: blockType() ?? 'unknown',
+ params: {},
+ isOpenable: true,
+ }}
+ />
+ }
+ triggerClass="min-w-0 truncate"
+ />
+ </button>
+ );
+}
+
+function getDocumentPreviewFallbackBlockType(
+ entityType: EntityType
+): BlockName | BlockAlias | undefined {
+ if (entityType === 'TASK') return 'task';
+ if (entityType === 'DOCUMENT') return undefined;
+ return undefined;
+}
diff --git a/apps/web/src/features/property/side-panel/properties/EntityPropertiesSection.test.tsx b/apps/web/src/features/property/side-panel/properties/EntityPropertiesSection.test.tsx
index 6a62278494..d888752cb4 100644
--- a/apps/web/src/features/property/side-panel/properties/EntityPropertiesSection.test.tsx
+++ b/apps/web/src/features/property/side-panel/properties/EntityPropertiesSection.test.tsx
@@ -86,6 +86,9 @@ vi.mock('@queries/properties/entity', () => ({
vi.mock('@queries/properties/tags', () => ({
useTagsQuery: () => ({ isSuccess: true, data: [] }),
}));
+vi.mock('./entity-collection-drop', () => ({
+ createEntityCollectionDropTarget: () => undefined,
+}));
vi.mock('@ui', async () => ({
...(await import('@ui/utils/classname')),
Button: (props: JSX.ButtonHTMLAttributes<HTMLButtonElement>) => (
diff --git a/apps/web/src/features/property/side-panel/properties/EntityPropertiesSection.tsx b/apps/web/src/features/property/side-panel/properties/EntityPropertiesSection.tsx
index 162e74acf0..6415277a9b 100644
--- a/apps/web/src/features/property/side-panel/properties/EntityPropertiesSection.tsx
+++ b/apps/web/src/features/property/side-panel/properties/EntityPropertiesSection.tsx
@@ -1,16 +1,10 @@
-import { SidePanel } from '@components/app/side-panel/SidePanel';
-import { useIsAuthenticated } from '@core/auth';
-import type { BlockAlias, BlockName } from '@core/block';
-import { PopupPreview } from '@core/component/DocumentPreview';
-import { HoverCard } from '@core/component/HoverCard';
-import { openDocument } from '@core/component/LexicalMarkdown/component/core/BlockLink';
-import { itemToBlockName } from '@core/constant/allBlocks';
-import { useSplitNavigationHandler } from '@core/util/useSplitNavigationHandler';
+import { t } from '@app/lib/i18n';
+import {
+ SidePanel,
+ type SidePanelSectionLayout,
+} from '@components/app/side-panel/SidePanel';
+import { fireAndForget } from '@core/util/fireAndForget';
import Plus from '@icon/system/regular/plus.svg';
-import PushPinIcon from '@icon/system/regular/push-pin.svg';
-import PushPinSlashIcon from '@icon/system/regular/push-pin-slash.svg';
-import TrashIcon from '@icon/system/regular/trash.svg';
-import DeleteIcon from '@icon/system/regular/x.svg';
import { Property as PropertyNS, useProperty } from '@property';
import { AddPropertyButton } from '@property/component/AddPropertyButton';
import { Modals } from '@property/component/modal';
@@ -30,7 +24,6 @@ import type {
PropertyDefinitionDomain,
} from '@property/types';
import { getEntityValues, hasValue } from '@property/utils';
-import { isAccessiblePreviewItem, useItemPreview } from '@queries/preview';
import { useBulkSaveEntityPropertiesMutation } from '@queries/properties/entity';
import { useTagsQuery } from '@queries/properties/tags';
import type { EntityType } from '@service-properties/generated/schemas/entityType';
@@ -44,10 +37,14 @@ import {
type JSX,
Match,
Show,
- Suspense,
Switch,
} from 'solid-js';
import { match } from 'ts-pattern';
+import {
+ EntityCollectionProperty,
+ NonUserEntityChip,
+} from './EntityCollectionProperty';
+import { isPendingProperty, PropertyRowActions } from './PropertyRowActions';
export interface EntityPropertiesSectionProps {
entityId: string;
@@ -59,6 +56,7 @@ export interface EntityPropertiesSectionProps {
propertyFilter?: (property: Property) => boolean;
getEmptyLabel?: (property: Property) => JSX.Element | undefined;
showAddProperty?: boolean;
+ renderSection?: SidePanelSectionLayout;
showTags?: boolean;
defaultPinnedPropertyIds?: () => readonly string[];
/** Keep required fields attached without hiding other entity properties. */
@@ -88,41 +86,10 @@ export interface EntityPropertiesSectionProps {
hidePropertyDefinitionIds?: string[];
}
-export interface EntityTagsSectionProps {
- entityId: string;
- entityType: EntityType;
- canEdit: boolean;
- order?: number;
-}
-
-export function EntityTagsSection(props: EntityTagsSectionProps) {
- const tagsQuery = useTagsQuery();
- const isAuthenticated = useIsAuthenticated();
-
- return (
- <Show when={isTaggableEntityType(props.entityType)}>
- <SidePanel.Section id="tags" title="Tags" defaultOpen order={props.order}>
- <Show
- when={isAuthenticated() !== false && !tagsQuery.isError}
- fallback={
- <span class="text-xs text-ink-extra-muted">Tags unavailable</span>
- }
- >
- <Suspense fallback={<SidePanel.Loading />}>
- <div class="text-xs">
- <TagsRow
- entityId={props.entityId}
- entityType={props.entityType}
- canEdit={props.canEdit}
- triggerVariant="pill"
- />
- </div>
- </Suspense>
- </Show>
- </SidePanel.Section>
- </Show>
- );
-}
+export {
+ EntityTagsSection,
+ type EntityTagsSectionProps,
+} from './EntityTagsSection';
export function EntityPropertiesSection(props: EntityPropertiesSectionProps) {
const { properties, isLoading, error, refetch, addProperty, removeProperty } =
@@ -248,7 +215,7 @@ export function EntityPropertiesSection(props: EntityPropertiesSectionProps) {
return next;
});
}
- refetch();
+ fireAndForget(refetch(), 'property-added-refresh');
};
const removePendingProperty = (property: Property) => {
@@ -266,7 +233,7 @@ export function EntityPropertiesSection(props: EntityPropertiesSectionProps) {
next.delete(definitionId);
return next;
});
- refetch();
+ fireAndForget(refetch(), 'property-add-failed-refresh');
};
createEffect(() => {
@@ -289,7 +256,10 @@ export function EntityPropertiesSection(props: EntityPropertiesSectionProps) {
});
const saveMutation = useBulkSaveEntityPropertiesMutation();
- const saveOne = async (property: Property, apiValues: PropertyApiValues) => {
+ const savePropertyValues = async (
+ property: Property,
+ apiValues: PropertyApiValues
+ ) => {
await saveMutation.mutateAsync({
properties: [
{
@@ -300,6 +270,13 @@ export function EntityPropertiesSection(props: EntityPropertiesSectionProps) {
},
],
});
+ };
+ const saveOne = async (property: Property, apiValues: PropertyApiValues) => {
+ await savePropertyValues(property, apiValues);
+ await props.onPropertiesChanged?.();
+ };
+ const refreshCollection = async () => {
+ await refetch();
await props.onPropertiesChanged?.();
};
@@ -309,126 +286,200 @@ export function EntityPropertiesSection(props: EntityPropertiesSectionProps) {
saveOne(property, { valueType: 'DATE', value: date }),
};
- return (
+ const canShowProperties = () => !error() || properties().length > 0;
+ const renderContent = () => (
<Show
- when={!error()}
+ when={canShowProperties()}
fallback={
<div class="text-failure-ink text-center py-4 text-xs">{error()}</div>
}
>
- <div class="text-xs">
- <PropertiesProvider
- entityId={props.entityId}
- entityType={props.entityType}
- canEdit={props.canEdit}
- documentName={props.documentName}
- properties={filteredProperties}
- onRefresh={refetch}
- onPropertyAdded={handlePropertyAdded}
- onPropertyAddFailed={handlePropertyAddFailed}
- onPropertyDeleted={refetch}
- onPropertyUnpinned={
- props.onPropertyUnpinned ? unpinProperty : undefined
+ <div class="flex flex-col gap-1 text-xs">
+ <Show when={isLoading()}>
+ <SidePanel.Loading />
+ </Show>
+
+ <Show
+ when={
+ props.showTags !== false && isTaggableEntityType(props.entityType)
}
- pinnedPropertyIds={titlePinnedIds}
- addProperty={addEntityProperty}
- removeProperty={removeEntityProperty}
- saveHandler={saveHandler}
>
- <Show when={isLoading()}>
- <SidePanel.Loading />
- </Show>
+ <div class="flex items-center gap-3">
+ <span class="w-(--sidepanel-label-width) shrink-0 text-ink-muted">
+ Tags
+ </span>
+ <TagsRow
+ entityId={props.entityId}
+ entityType={props.entityType}
+ canEdit={props.canEdit}
+ />
+ </div>
+ </Show>
- <Show
- when={
- props.showTags !== false && isTaggableEntityType(props.entityType)
- }
+ <Show when={gridProperties().length > 0}>
+ <SidePanel.Grid
+ class={cn(
+ 'auto-rows-[minmax(1.75rem,auto)] gap-y-1',
+ collectionProperties().length === 0 &&
+ props.canEdit &&
+ props.showAddProperty !== false &&
+ 'mb-3'
+ )}
>
- <div class="mb-2 flex items-center gap-3">
- <span class="text-ink-muted">Tags</span>
- <TagsRow
- entityId={props.entityId}
- entityType={props.entityType}
- canEdit={props.canEdit}
- />
- </div>
- </Show>
-
- <Show when={gridProperties().length > 0}>
- <SidePanel.Grid class="auto-rows-[minmax(1.75rem,auto)]">
- <For each={gridProperties()}>
- {(property) => (
- <SidePanelPropertyRow
- entityId={props.entityId}
- getEmptyLabel={props.getEmptyLabel}
- property={property}
- canRemoveFromEntity={
- !defaultPinnedDefinitionIds().has(
- property.propertyDefinitionId
- ) &&
- !(
- isPendingProperty(property) &&
- props
- .defaultProperties?.()
- .some(
- (placeholder) =>
- placeholder.propertyDefinitionId ===
- property.propertyDefinitionId
- )
- )
- }
- canPinPendingProperty={props
- .defaultTitlePropertyDefinitionIds?.()
- .includes(property.propertyDefinitionId)}
- onRemovePendingProperty={removePendingProperty}
- onPropertyPinned={
- props.onPropertyPinned ? pinProperty : undefined
- }
- />
- )}
- </For>
- </SidePanel.Grid>
- </Show>
-
- <Show when={collectionProperties().length > 0}>
- <div class="flex flex-col gap-2 pb-2">
- <For each={collectionProperties()}>
- {(property) => (
- <EntityCollectionProperty
- entityId={props.entityId}
- property={property}
- canRemoveFromEntity={
- !defaultPinnedDefinitionIds().has(
- property.propertyDefinitionId
- )
- }
- onRemovePendingProperty={removePendingProperty}
- onPropertyPinned={
- props.onPropertyPinned ? pinProperty : undefined
- }
- />
- )}
- </For>
- </div>
- </Show>
+ <For each={gridProperties()}>
+ {(property) => (
+ <SidePanelPropertyRow
+ entityId={props.entityId}
+ getEmptyLabel={props.getEmptyLabel}
+ property={property}
+ canRemoveFromEntity={
+ !defaultPinnedDefinitionIds().has(
+ property.propertyDefinitionId
+ ) &&
+ !(
+ isPendingProperty(property) &&
+ props
+ .defaultProperties?.()
+ .some(
+ (placeholder) =>
+ placeholder.propertyDefinitionId ===
+ property.propertyDefinitionId
+ )
+ )
+ }
+ canPinPendingProperty={props
+ .defaultTitlePropertyDefinitionIds?.()
+ .includes(property.propertyDefinitionId)}
+ onRemovePendingProperty={removePendingProperty}
+ onPropertyPinned={
+ props.onPropertyPinned ? pinProperty : undefined
+ }
+ />
+ )}
+ </For>
+ </SidePanel.Grid>
+ </Show>
- <Show when={props.canEdit && props.showAddProperty !== false}>
- <div
- class={cn(
- 'flex items-center',
- filteredProperties().length > 0 && 'mt-2'
+ <Show when={collectionProperties().length > 0}>
+ <div
+ class={cn(
+ 'flex flex-col gap-1',
+ props.canEdit && props.showAddProperty !== false && 'mb-3'
+ )}
+ >
+ <For
+ each={collectionProperties().map(
+ (property) => property.propertyDefinitionId
)}
>
- <AddPropertyButton size="xs" class="m-px gap-1.5" />
- </div>
- </Show>
- <Modals />
- </PropertiesProvider>
+ {(definitionId) => {
+ const saving = createSignal(false);
+ return (
+ <Show
+ when={collectionProperties().find(
+ (property) =>
+ property.propertyDefinitionId === definitionId
+ )}
+ >
+ {(property) => (
+ <EntityCollectionProperty
+ entityId={props.entityId}
+ loading={isLoading()}
+ onSave={savePropertyValues}
+ onRefresh={refreshCollection}
+ property={property()}
+ saving={saving}
+ >
+ <PropertyRowActions.Root
+ saving={saving}
+ onRefresh={refetch}
+ canRemoveFromEntity={
+ !defaultPinnedDefinitionIds().has(
+ property().propertyDefinitionId
+ )
+ }
+ property={property()}
+ onRemovePendingProperty={removePendingProperty}
+ onPropertyPinned={
+ props.onPropertyPinned ? pinProperty : undefined
+ }
+ >
+ <PropertyRowActions.Pin />
+ <PropertyRowActions.Remove />
+ </PropertyRowActions.Root>
+ </EntityCollectionProperty>
+ )}
+ </Show>
+ );
+ }}
+ </For>
+ </div>
+ </Show>
+
+ <Show when={props.canEdit && props.showAddProperty !== false}>
+ <div class="flex items-center">
+ <AddPropertyButton size="xs" class="m-px gap-1.5" />
+ </div>
+ </Show>
</div>
</Show>
);
+
+ return (
+ <PropertiesProvider
+ entityId={props.entityId}
+ entityType={props.entityType}
+ canEdit={props.canEdit}
+ documentName={props.documentName}
+ properties={filteredProperties}
+ onRefresh={refetch}
+ onPropertyAdded={handlePropertyAdded}
+ onPropertyAddFailed={handlePropertyAddFailed}
+ onPropertyDeleted={refetch}
+ onPropertyUnpinned={props.onPropertyUnpinned ? unpinProperty : undefined}
+ pinnedPropertyIds={titlePinnedIds}
+ addProperty={addEntityProperty}
+ removeProperty={removeEntityProperty}
+ saveHandler={saveHandler}
+ >
+ {props.renderSection
+ ? props.renderSection(
+ renderContent,
+ <Show
+ when={
+ canShowProperties() &&
+ props.canEdit &&
+ props.showAddProperty !== false
+ }
+ >
+ <AddPropertyHeaderAction />
+ </Show>
+ )
+ : renderContent()}
+ <Modals />
+ </PropertiesProvider>
+ );
}
+function AddPropertyHeaderAction() {
+ const ctx = usePropertiesContext();
+ return (
+ <Button
+ type="button"
+ variant="ghost"
+ size="icon-xs"
+ class="text-ink-extra-muted"
+ aria-label={t('common.addProperty')}
+ title={t('common.addProperty')}
+ onClick={(event) => {
+ event.stopPropagation();
+ ctx.openPropertySelector();
+ }}
+ >
+ <Plus class="size-4" />
+ </Button>
+ );
+}
function propertyFromPendingDefinition(
definition: PropertyDefinitionDomain
): Property | undefined {
@@ -531,21 +582,11 @@ function SidePanelPropertyRow(props: {
const hasInlineAddAction = () =>
isMultiValueRow() &&
!(t() === 'ENTITY' && props.property.specificEntityType === 'USER');
- const renderActions = () => (
- <PropertyRowActions
- canRemoveFromEntity={props.canRemoveFromEntity}
- pinFirst={hasInlineAddAction()}
- canPinPendingProperty={props.canPinPendingProperty}
- property={props.property}
- onRemovePendingProperty={props.onRemovePendingProperty}
- onPropertyPinned={props.onPropertyPinned}
- />
- );
return (
<div class="contents group/property-row">
<span
- class={cn('text-ink-muted truncate', {
+ class={cn('min-w-0 truncate text-ink-muted', {
'self-start pt-[0.3125rem]': isMultilineRow(),
'self-center': !isMultilineRow(),
})}
@@ -579,10 +620,18 @@ function SidePanelPropertyRow(props: {
<InputValue />
</Match>
<Match when={isMultiValueRow()}>
- <MultiValue
- property={props.property}
- renderActions={renderActions}
- />
+ <MultiValue property={props.property}>
+ <PropertyRowActions.Root
+ canRemoveFromEntity={props.canRemoveFromEntity}
+ canPinPendingProperty={props.canPinPendingProperty}
+ property={props.property}
+ onRemovePendingProperty={props.onRemovePendingProperty}
+ onPropertyPinned={props.onPropertyPinned}
+ >
+ <PropertyRowActions.Pin />
+ <PropertyRowActions.Remove />
+ </PropertyRowActions.Root>
+ </MultiValue>
</Match>
</Switch>
<PropertyNS.PopoverEditor
@@ -592,138 +641,24 @@ function SidePanelPropertyRow(props: {
}}
/>
</PropertyNS.Root>
- <Show when={!hasInlineAddAction()}>{renderActions()}</Show>
+ <Show when={!hasInlineAddAction()}>
+ <PropertyRowActions.Root
+ canRemoveFromEntity={props.canRemoveFromEntity}
+ canPinPendingProperty={props.canPinPendingProperty}
+ property={props.property}
+ onRemovePendingProperty={props.onRemovePendingProperty}
+ onPropertyPinned={props.onPropertyPinned}
+ >
+ <PropertyRowActions.Remove />
+ <PropertyRowActions.Pin />
+ </PropertyRowActions.Root>
+ </Show>
</div>
</div>
</div>
);
}
-function isPendingProperty(property: Property): boolean {
- return property.propertyId.startsWith('pending:');
-}
-
-function PropertyRowActions(props: {
- canRemoveFromEntity: boolean;
- canPinPendingProperty?: boolean;
- onRemovePendingProperty: (property: Property) => void;
- onPropertyPinned?: (propertyId: string) => void;
- pinFirst?: boolean;
- property: Property;
-}) {
- const ctx = usePropertiesContext();
- const [isSaving, setIsSaving] = createSignal(false);
-
- const canRemove = () =>
- props.canRemoveFromEntity &&
- ctx.canEdit &&
- !props.property.isMetadata &&
- (isPendingProperty(props.property) || Boolean(ctx.removeProperty));
- const canPin = () =>
- ctx.canEdit &&
- !props.property.isMetadata &&
- (!isPendingProperty(props.property) ||
- props.canPinPendingProperty === true) &&
- Boolean(
- props.onPropertyPinned && ctx.onPropertyUnpinned && ctx.pinnedPropertyIds
- );
- const isPinned = () =>
- ctx.pinnedPropertyIds?.().includes(props.property.propertyId) ?? false;
- const pinLabel = () => (isPinned() ? 'Unpin from title' : 'Pin below title');
- const hasActions = () => canRemove() || canPin();
- const actionVisibility =
- 'pointer-events-none opacity-0 group-hover/property-row:pointer-events-auto group-hover/property-row:opacity-100 group-focus-within/property-row:pointer-events-auto group-focus-within/property-row:opacity-100 focus-within:pointer-events-auto focus-within:opacity-100 touch:pointer-events-auto touch:opacity-100';
-
- const stopRowInteraction = (event: MouseEvent) => {
- event.preventDefault();
- event.stopPropagation();
- };
-
- const togglePin = (event: MouseEvent) => {
- stopRowInteraction(event);
- if (!canPin() || isSaving()) return;
- if (isPinned()) {
- ctx.onPropertyUnpinned?.(
- props.property.propertyId,
- props.property.propertyDefinitionId
- );
- } else {
- props.onPropertyPinned?.(props.property.propertyId);
- }
- };
-
- const removeFromEntity = async (event: MouseEvent) => {
- stopRowInteraction(event);
- if (!canRemove() || isSaving()) return;
-
- if (isPendingProperty(props.property)) {
- props.onRemovePendingProperty(props.property);
- return;
- }
-
- const remove = ctx.removeProperty;
- if (!remove) return;
-
- setIsSaving(true);
- try {
- await remove(props.property.propertyId);
- ctx.onPropertyUnpinned?.(
- props.property.propertyId,
- props.property.propertyDefinitionId
- );
- ctx.onRefresh();
- } finally {
- setIsSaving(false);
- }
- };
-
- const renderRemoveAction = () => (
- <Show when={canRemove()}>
- <Button
- variant="danger-ghost"
- size="icon-xs"
- data-property-row-action
- tooltip="Remove from entity"
- aria-label="Remove from entity"
- disabled={isSaving()}
- class={cn('transition', actionVisibility)}
- onClick={removeFromEntity}
- >
- <TrashIcon class="size-4" />
- </Button>
- </Show>
- );
-
- return (
- <Show when={hasActions()}>
- <div
- class="flex shrink-0 items-center gap-0.5"
- onMouseDown={stopRowInteraction}
- >
- <Show when={!props.pinFirst}>{renderRemoveAction()}</Show>
- <Show when={canPin()}>
- <Button
- variant="ghost"
- size="icon-xs"
- data-property-row-action
- title={pinLabel()}
- aria-label={pinLabel()}
- aria-pressed={isPinned()}
- disabled={isSaving()}
- class="text-ink-extra-muted aria-pressed:bg-button-tertiary-bg aria-pressed:not-data-disabled:hover:bg-button-tertiary-hover"
- onClick={togglePin}
- >
- <Show when={isPinned()} fallback={<PushPinIcon class="size-4" />}>
- <PushPinSlashIcon class="size-4 text-accent" />
- </Show>
- </Button>
- </Show>
- <Show when={props.pinFirst}>{renderRemoveAction()}</Show>
- </div>
- </Show>
- );
-}
-
function SinglePill(props: {
getEmptyLabel?: (property: Property) => JSX.Element | undefined;
property: Property;
@@ -799,10 +734,7 @@ function UserStackPill(props: { property: Property }) {
);
}
-function MultiValue(props: {
- property: Property;
- renderActions: () => JSX.Element;
-}) {
+function MultiValue(props: { property: Property; children: JSX.Element }) {
const ctx = usePropertiesContext();
const propertyCtx = useProperty();
const isReadOnly = () => !ctx.canEdit || props.property.isMetadata;
@@ -819,10 +751,9 @@ function MultiValue(props: {
<Show
when={!isEntity()}
fallback={
- <NonUserEntityValue
- property={props.property}
- renderActions={props.renderActions}
- />
+ <NonUserEntityValue property={props.property}>
+ {props.children}
+ </NonUserEntityValue>
}
>
<div class="flex flex-wrap items-center gap-1.5">
@@ -856,7 +787,7 @@ function MultiValue(props: {
<Plus class="size-4" />
</Button>
</Show>
- {props.renderActions()}
+ {props.children}
</div>
</div>
</Show>
@@ -867,7 +798,7 @@ function MultiValue(props: {
function NonUserEntityValue(props: {
property: Property;
- renderActions: () => JSX.Element;
+ children: JSX.Element;
}) {
const ctx = usePropertiesContext();
const propertyCtx = useProperty();
@@ -930,261 +861,12 @@ function NonUserEntityValue(props: {
</Button>
</Show>
</Show>
- {props.renderActions()}
+ {props.children}
</div>
</div>
);
}
-function EntityCollectionProperty(props: {
- canRemoveFromEntity: boolean;
- entityId: string;
- onRemovePendingProperty: (property: Property) => void;
- onPropertyPinned?: (propertyId: string) => void;
- property: Property;
-}) {
- const ctx = usePropertiesContext();
-
- return (
- <PropertyNS.Root
- property={props.property}
- canEdit={ctx.canEdit}
- onSave={ctx.saveHandler.saveProperty}
- onRefresh={ctx.onRefresh}
- >
- <EntityCollectionPropertyBody
- canRemoveFromEntity={props.canRemoveFromEntity}
- property={props.property}
- onRemovePendingProperty={props.onRemovePendingProperty}
- onPropertyPinned={props.onPropertyPinned}
- />
- <PropertyNS.PopoverEditor
- entitySelfFilter={{
- entityType: ctx.entityType,
- blockId: props.entityId,
- }}
- />
- </PropertyNS.Root>
- );
-}
-
-function EntityCollectionPropertyBody(props: {
- canRemoveFromEntity: boolean;
- onRemovePendingProperty: (property: Property) => void;
- onPropertyPinned?: (propertyId: string) => void;
- property: Property;
-}) {
- const ctx = usePropertiesContext();
- const propertyCtx = useProperty();
- const entities = () => getEntityValues(props.property);
- const isReadOnly = () => !ctx.canEdit || props.property.isMetadata;
-
- const handleRemoveEntity = async (entityId: string) => {
- const remaining = entities().filter(
- (entity) => entity.entity_id !== entityId
- );
- await ctx.saveHandler.saveProperty(props.property, {
- valueType: 'ENTITY',
- refs: remaining.length > 0 ? remaining : null,
- });
- ctx.onRefresh();
- };
-
- return (
- <div class="group/property-row min-w-0 py-2">
- <div class="flex items-center justify-between gap-2">
- <span
- class="min-w-0 truncate text-ink-muted"
- title={props.property.displayName}
- >
- {props.property.displayName}
- </span>
- <div class="ml-auto flex shrink-0 items-center">
- <Show when={!isReadOnly()}>
- <Button
- type="button"
- variant="ghost"
- size="icon-xs"
- class="text-ink-extra-muted"
- aria-label={`Add ${props.property.displayName}`}
- onClick={(event) => {
- event.stopPropagation();
- propertyCtx.openEditor(event.currentTarget);
- }}
- >
- <Plus class="size-4" />
- </Button>
- </Show>
- <PropertyRowActions
- canRemoveFromEntity={props.canRemoveFromEntity}
- pinFirst
- property={props.property}
- onRemovePendingProperty={props.onRemovePendingProperty}
- onPropertyPinned={props.onPropertyPinned}
- />
- </div>
- </div>
- <div class="mt-2 flex flex-wrap gap-1.5">
- <For
- each={entities()}
- fallback={<span class="text-ink-extra-muted">Empty</span>}
- >
- {(entityRef) => (
- <NonUserEntityChip
- property={props.property}
- entityId={entityRef.entity_id}
- entityType={entityRef.entity_type}
- specificMessageId={entityRef.specific_message_id}
- canEdit={!isReadOnly()}
- onRemove={() => handleRemoveEntity(entityRef.entity_id)}
- onEdit={(anchor) => {
- if (isReadOnly()) return;
- propertyCtx.openEditor(anchor);
- }}
- />
- )}
- </For>
- </div>
- </div>
- );
-}
-
-function NonUserEntityChip(props: {
- property: Property;
- entityId: string;
- entityType: EntityType;
- specificMessageId?: string | null;
- canEdit?: boolean;
- onRemove?: () => void;
- onEdit?: (anchor?: HTMLElement) => void;
-}) {
- let containerRef: HTMLDivElement | undefined;
- const { name, icon } = usePropertyEntityDisplay(
- () => props.entityId,
- () => props.entityType,
- {
- specificMessageId: () => props.specificMessageId,
- }
- );
- const previewBlockType = () =>
- getDocumentPreviewFallbackBlockType(props.entityType);
- const isDocumentPreviewEntity = () =>
- props.entityType === 'DOCUMENT' || props.entityType === 'TASK';
-
- const openEditor = (event: MouseEvent) => {
- if (!props.canEdit || !props.onEdit) return;
- event.stopPropagation();
- props.onEdit(containerRef);
- };
-
- return (
- <Layer depth={2}>
- <div
- ref={containerRef}
- class="inline-flex min-w-0 max-w-full border h-7 items-stretch border-edge-muted rounded-md bg-surface text-ink overflow-clip"
- >
- <Show
- when={isDocumentPreviewEntity()}
- fallback={
- <button
- type="button"
- class="flex min-w-0 max-w-full items-center gap-1.5 px-2 text-left"
- onClick={openEditor}
- disabled={!props.canEdit}
- >
- <span class="shrink-0 flex items-center">{icon()}</span>
- <span class="min-w-0 truncate">{name()}</span>
- </button>
- }
- >
- <DocumentEntityChipButton
- entityId={props.entityId}
- fallbackBlockType={previewBlockType()}
- icon={icon()}
- name={name()}
- />
- </Show>
- <Show when={props.canEdit && props.onRemove}>
- <div class="border-l border-edge-muted" />
- <Button
- variant="ghost"
- type="button"
- size="icon-sm"
- class="flex w-6 p-1 h-full shrink-0 rounded-none text-ink-muted not-disabled:hover:text-failure-ink"
- onClick={(event) => {
- event.stopPropagation();
- props.onRemove?.();
- }}
- aria-label={`Remove ${name()}`}
- >
- <DeleteIcon class="size-3.5 touch:size-6 shrink-0 pointer-events-none" />
- </Button>
- </Show>
- </div>
- </Layer>
- );
-}
-
-function DocumentEntityChipButton(props: {
- entityId: string;
- fallbackBlockType: BlockName | BlockAlias | undefined;
- icon: JSX.Element;
- name: string;
-}) {
- const [item] = useItemPreview(() => ({
- id: props.entityId,
- type: 'document',
- }));
- const blockType = () => {
- const preview = item();
- if (isAccessiblePreviewItem(preview)) {
- return itemToBlockName(preview);
- }
- return props.fallbackBlockType;
- };
- const navHandlers = useSplitNavigationHandler<HTMLButtonElement>((event) => {
- const targetBlockType = blockType();
- if (!targetBlockType) return;
- event.stopPropagation();
- openDocument(targetBlockType, props.entityId, {}, event.shiftKey);
- });
-
- return (
- <button
- type="button"
- class="flex min-w-0 max-w-full items-center gap-1.5 px-2 text-left"
- {...navHandlers}
- >
- <span class="shrink-0 flex items-center">{props.icon}</span>
- <HoverCard
- trigger={<span class="truncate">{props.name}</span>}
- content={
- <PopupPreview
- mouseEnter={() => {}}
- mouseLeave={() => {}}
- documentInfo={{
- id: props.entityId,
- name: props.name,
- type: blockType() ?? 'unknown',
- params: {},
- isOpenable: true,
- }}
- />
- }
- triggerClass="min-w-0 truncate"
- />
- </button>
- );
-}
-
-function getDocumentPreviewFallbackBlockType(
- entityType: EntityType
-): BlockName | BlockAlias | undefined {
- if (entityType === 'TASK') return 'task';
- if (entityType === 'DOCUMENT') return undefined;
- return undefined;
-}
-
function InputValue() {
return (
<div class="min-w-0 max-w-full overflow-hidden">
diff --git a/apps/web/src/features/property/side-panel/properties/EntityTagsSection.tsx b/apps/web/src/features/property/side-panel/properties/EntityTagsSection.tsx
new file mode 100644
index 0000000000..b5aee4b359
--- /dev/null
+++ b/apps/web/src/features/property/side-panel/properties/EntityTagsSection.tsx
@@ -0,0 +1,68 @@
+import { t } from '@app/lib/i18n';
+import { SidePanel } from '@components/app/side-panel/SidePanel';
+import { useIsAuthenticated } from '@core/auth';
+import Plus from '@icon/system/regular/plus.svg';
+import { isTaggableEntityType, TagsRow } from '@property/tags';
+import { TagPicker } from '@property/tags/TagPicker';
+import { useDocTags } from '@property/tags/useDocTags';
+import { useTagsQuery } from '@queries/properties/tags';
+import type { EntityType } from '@service-properties/generated/schemas/entityType';
+import { buttonClasses } from '@ui';
+import { Show, Suspense } from 'solid-js';
+
+export interface EntityTagsSectionProps {
+ entityId: string;
+ entityType: EntityType;
+ canEdit: boolean;
+ order?: number;
+}
+
+export function EntityTagsSection(props: EntityTagsSectionProps) {
+ const tagsQuery = useTagsQuery();
+ const isAuthenticated = useIsAuthenticated();
+ const isAvailable = () => isAuthenticated() !== false && !tagsQuery.isError;
+
+ return (
+ <Show when={isTaggableEntityType(props.entityType)}>
+ <SidePanel.Section
+ id="tags"
+ title="Tags"
+ defaultOpen
+ order={props.order}
+ actions={
+ <Show when={props.canEdit && isAvailable()}>
+ <TagPicker
+ createDocTags={() => useDocTags(props.entityId, props.entityType)}
+ triggerClass={buttonClasses({
+ variant: 'ghost',
+ size: 'icon-xs',
+ class: 'text-ink-extra-muted',
+ })}
+ triggerLabel={t('common.addTags')}
+ >
+ <Plus class="size-4" />
+ </TagPicker>
+ </Show>
+ }
+ >
+ <Show
+ when={isAvailable()}
+ fallback={
+ <span class="text-xs text-ink-extra-muted">Tags unavailable</span>
+ }
+ >
+ <Suspense fallback={<SidePanel.Loading />}>
+ <div class="text-xs">
+ <TagsRow
+ entityId={props.entityId}
+ entityType={props.entityType}
+ canEdit={props.canEdit}
+ triggerVariant="pill"
+ />
+ </div>
+ </Suspense>
+ </Show>
+ </SidePanel.Section>
+ </Show>
+ );
+}
diff --git a/apps/web/src/features/property/side-panel/properties/PropertyRowActions.tsx b/apps/web/src/features/property/side-panel/properties/PropertyRowActions.tsx
new file mode 100644
index 0000000000..abfde88428
--- /dev/null
+++ b/apps/web/src/features/property/side-panel/properties/PropertyRowActions.tsx
@@ -0,0 +1,191 @@
+import PushPinIcon from '@icon/system/regular/push-pin.svg';
+import PushPinSlashIcon from '@icon/system/regular/push-pin-slash.svg';
+import TrashIcon from '@icon/system/regular/trash.svg';
+import { usePropertiesContext } from '@property/context/PropertiesContext';
+import type { Property } from '@property/types';
+import { Button } from '@ui';
+import {
+ type Accessor,
+ createContext,
+ createSignal,
+ type JSX,
+ Show,
+ type Signal,
+ useContext,
+} from 'solid-js';
+
+type PropertyRowActionsContextValue = {
+ canPin: Accessor<boolean>;
+ canRemove: Accessor<boolean>;
+ isPinned: Accessor<boolean>;
+ isSaving: Accessor<boolean>;
+ pinLabel: Accessor<string>;
+ togglePin: (event: MouseEvent) => void;
+ removeFromEntity: (event: MouseEvent) => Promise<void>;
+};
+
+const PropertyRowActionsContext =
+ createContext<PropertyRowActionsContextValue>();
+
+export function isPendingProperty(property: Property): boolean {
+ return property.propertyId.startsWith('pending:');
+}
+
+function usePropertyRowActions() {
+ const context = useContext(PropertyRowActionsContext);
+ if (!context) {
+ throw new Error('Property row actions require PropertyRowActions.Root');
+ }
+ return context;
+}
+
+function PropertyRowActionsRoot(props: {
+ canRemoveFromEntity: boolean;
+ canPinPendingProperty?: boolean;
+ onRemovePendingProperty: (property: Property) => void;
+ onPropertyPinned?: (propertyId: string) => void;
+ property: Property;
+ saving?: Signal<boolean>;
+ onRefresh?: () => Promise<unknown>;
+ children: JSX.Element;
+}) {
+ const ctx = usePropertiesContext();
+ const [isSaving, setIsSaving] = props.saving ?? createSignal(false);
+
+ const canRemove = () =>
+ props.canRemoveFromEntity &&
+ ctx.canEdit &&
+ !props.property.isMetadata &&
+ (isPendingProperty(props.property) || Boolean(ctx.removeProperty));
+ const canPin = () =>
+ ctx.canEdit &&
+ !props.property.isMetadata &&
+ (!isPendingProperty(props.property) ||
+ props.canPinPendingProperty === true) &&
+ Boolean(
+ props.onPropertyPinned && ctx.onPropertyUnpinned && ctx.pinnedPropertyIds
+ );
+ const isPinned = () =>
+ ctx.pinnedPropertyIds?.().includes(props.property.propertyId) ?? false;
+ const pinLabel = () => (isPinned() ? 'Unpin from title' : 'Pin below title');
+
+ const stopRowInteraction = (event: MouseEvent) => {
+ event.preventDefault();
+ event.stopPropagation();
+ };
+
+ const togglePin = (event: MouseEvent) => {
+ stopRowInteraction(event);
+ if (!canPin() || isSaving()) return;
+ if (isPinned()) {
+ ctx.onPropertyUnpinned?.(
+ props.property.propertyId,
+ props.property.propertyDefinitionId
+ );
+ } else {
+ props.onPropertyPinned?.(props.property.propertyId);
+ }
+ };
+
+ const removeFromEntity = async (event: MouseEvent) => {
+ stopRowInteraction(event);
+ if (!canRemove() || isSaving()) return;
+
+ if (isPendingProperty(props.property)) {
+ props.onRemovePendingProperty(props.property);
+ return;
+ }
+
+ const remove = ctx.removeProperty;
+ if (!remove) return;
+
+ setIsSaving(true);
+ try {
+ await remove(props.property.propertyId);
+ ctx.onPropertyUnpinned?.(
+ props.property.propertyId,
+ props.property.propertyDefinitionId
+ );
+ await (props.onRefresh ?? ctx.onRefresh)();
+ } finally {
+ setIsSaving(false);
+ }
+ };
+
+ return (
+ <PropertyRowActionsContext.Provider
+ value={{
+ canPin,
+ canRemove,
+ isPinned,
+ isSaving,
+ pinLabel,
+ togglePin,
+ removeFromEntity,
+ }}
+ >
+ <Show when={canRemove() || canPin()}>
+ <div
+ class="flex shrink-0 items-center gap-0.5"
+ onMouseDown={stopRowInteraction}
+ >
+ {props.children}
+ </div>
+ </Show>
+ </PropertyRowActionsContext.Provider>
+ );
+}
+
+function PropertyPinAction() {
+ const actions = usePropertyRowActions();
+
+ return (
+ <Show when={actions.canPin()}>
+ <Button
+ variant="ghost"
+ size="icon-xs"
+ data-property-row-action
+ title={actions.pinLabel()}
+ aria-label={actions.pinLabel()}
+ aria-pressed={actions.isPinned()}
+ disabled={actions.isSaving()}
+ class="text-ink-extra-muted aria-pressed:bg-button-tertiary-bg aria-pressed:not-data-disabled:hover:bg-button-tertiary-hover"
+ onClick={actions.togglePin}
+ >
+ <Show
+ when={actions.isPinned()}
+ fallback={<PushPinIcon class="size-4" />}
+ >
+ <PushPinSlashIcon class="size-4 text-accent" />
+ </Show>
+ </Button>
+ </Show>
+ );
+}
+
+function PropertyRemoveAction() {
+ const actions = usePropertyRowActions();
+
+ return (
+ <Show when={actions.canRemove()}>
+ <Button
+ variant="danger-ghost"
+ size="icon-xs"
+ data-property-row-action
+ tooltip="Remove from entity"
+ aria-label="Remove from entity"
+ disabled={actions.isSaving()}
+ class="transition pointer-events-none opacity-0 group-hover/property-row:pointer-events-auto group-hover/property-row:opacity-100 group-focus-within/property-row:pointer-events-auto group-focus-within/property-row:opacity-100 focus-within:pointer-events-auto focus-within:opacity-100 touch:pointer-events-auto touch:opacity-100"
+ onClick={actions.removeFromEntity}
+ >
+ <TrashIcon class="size-4" />
+ </Button>
+ </Show>
+ );
+}
+
+export const PropertyRowActions = {
+ Root: PropertyRowActionsRoot,
+ Pin: PropertyPinAction,
+ Remove: PropertyRemoveAction,
+};
diff --git a/apps/web/src/features/property/side-panel/properties/entity-collection-drop.ts b/apps/web/src/features/property/side-panel/properties/entity-collection-drop.ts
new file mode 100644
index 0000000000..0985a22d28
--- /dev/null
+++ b/apps/web/src/features/property/side-panel/properties/entity-collection-drop.ts
@@ -0,0 +1,97 @@
+import { fireAndForget } from '@core/util/fireAndForget';
+import { isEntityDragData } from '@entity/types/drag';
+import type { EntityReference } from '@service-properties/generated/schemas/entityReference';
+import type { EntityType } from '@service-properties/generated/schemas/entityType';
+import { createDroppable, useDragDropContext } from '@thisbeyond/solid-dnd';
+import { type Accessor, createUniqueId, onCleanup } from 'solid-js';
+import { getEntityType } from '../../editors/selectors/entityUtils';
+import type { Property } from '../../types';
+
+/** Apply the entity picker's type restrictions to an app-item drag. */
+export function getCollectionDropReference(
+ property: Property,
+ data: unknown,
+ selfId: string,
+ selfType: EntityType
+): EntityReference | undefined {
+ if (
+ property.valueType !== 'ENTITY' ||
+ !property.isMultiSelect ||
+ property.isMetadata ||
+ !isEntityDragData(data)
+ ) {
+ return;
+ }
+
+ const entityType = getEntityType({ kind: 'entity', id: data.id, data });
+ if (!entityType) return;
+ if (data.id === selfId && entityType === selfType) return;
+ if (
+ property.specificEntityType &&
+ property.specificEntityType !== entityType
+ ) {
+ return;
+ }
+ if (property.value?.some((reference) => reference.entity_id === data.id)) {
+ return;
+ }
+
+ return { entity_id: data.id, entity_type: entityType };
+}
+
+/** One target covers the property label, values, and expanded drag feedback. */
+export function createEntityCollectionDropTarget(options: {
+ property: Accessor<Property>;
+ selfId: Accessor<string>;
+ selfType: Accessor<EntityType>;
+ disabled: Accessor<boolean>;
+ onDrop: (reference: EntityReference, name: string) => Promise<void>;
+}) {
+ const context = useDragDropContext();
+ if (!context) return;
+
+ const [state, actions] = context;
+ const id = `property-collection:${createUniqueId()}`;
+ const referenceFor = (data: unknown) =>
+ getCollectionDropReference(
+ options.property(),
+ data,
+ options.selfId(),
+ options.selfType()
+ );
+ const isDragging = () => isEntityDragData(state.active.draggable?.data);
+ const canDrop = () =>
+ !options.disabled() && Boolean(referenceFor(state.active.draggable?.data));
+ const droppable = createDroppable(id, {
+ type: 'property-collection',
+ isDropTargetDisabled: () => !canDrop(),
+ });
+ // Expanded dropzones move other targets, so refresh collision bounds as they resize.
+ const resizeObserver = new ResizeObserver(() => {
+ if (!isDragging()) return;
+ actions.recomputeLayouts();
+ actions.detectCollisions();
+ });
+ onCleanup(() => resizeObserver.disconnect());
+
+ actions.onDragEnd(({ draggable, droppable: target }) => {
+ if (target?.id !== id || options.disabled()) return;
+ if (!isEntityDragData(draggable.data)) return;
+ const reference = referenceFor(draggable.data);
+ if (!reference) return;
+ fireAndForget(
+ options.onDrop(reference, draggable.data.name),
+ 'property-collection-drop'
+ );
+ });
+
+ return {
+ ref: (element: HTMLElement) => {
+ droppable.ref(element);
+ resizeObserver.observe(element);
+ },
+ isDragging,
+ canDrop,
+ isOver: () => state.active.droppable?.id === id && canDrop(),
+ };
+}
diff --git a/apps/web/src/features/property/tags/TagsRow.tsx b/apps/web/src/features/property/tags/TagsRow.tsx
index 5322543c11..755d25accc 100644
--- a/apps/web/src/features/property/tags/TagsRow.tsx
+++ b/apps/web/src/features/property/tags/TagsRow.tsx
@@ -6,11 +6,12 @@ import { fireAndForget } from '@core/util/fireAndForget';
import FunnelIcon from '@icon/system/regular/funnel-simple.svg';
import PencilIcon from '@icon/system/regular/pencil-simple.svg';
import PlusIcon from '@icon/system/regular/plus.svg';
+import TagIcon from '@icon/system/regular/tag-simple.svg';
import XIcon from '@icon/system/regular/x.svg';
import { ContextMenu } from '@kobalte/core/context-menu';
import type { EntityType } from '@service-properties/generated/schemas/entityType';
-import { Badge, badgeTriggerClasses, buttonClasses, Layer } from '@ui';
-import { createSignal, For, Match, Show, Switch } from 'solid-js';
+import { Badge, buttonClasses, Layer } from '@ui';
+import { createSignal, For, Show } from 'solid-js';
import { TagDot } from './TagDot';
import {
type EditableTag,
@@ -138,53 +139,61 @@ export function TagsRow(props: {
return (
<div class="flex flex-wrap items-center gap-1.5">
- <For each={docTags.appliedTags()}>
- {(tag) => (
- <TagChip
- tag={tag}
- docTags={docTags}
- canEdit={props.canEdit}
- onEdit={openEdit}
- />
- )}
- </For>
<Show
- when={props.canEdit}
+ when={triggerVariant() === 'pill' && !hasTags()}
fallback={
- <Show when={docTags.appliedTags().length === 0}>
- <span class="text-ink-extra-muted">No tags</span>
- </Show>
+ <>
+ <For each={docTags.appliedTags()}>
+ {(tag) => (
+ <TagChip
+ tag={tag}
+ docTags={docTags}
+ canEdit={props.canEdit}
+ onEdit={openEdit}
+ />
+ )}
+ </For>
+ <Show
+ when={props.canEdit}
+ fallback={
+ <Show when={!hasTags()}>
+ <span class="text-ink-extra-muted">No tags</span>
+ </Show>
+ }
+ >
+ <TagPicker
+ docTags={docTags}
+ triggerClass={buttonClasses({
+ variant: 'secondary',
+ size: 'icon-xs',
+ class: 'm-px',
+ })}
+ triggerLabel={t('common.addTags')}
+ >
+ <PlusIcon class="size-3" />
+ </TagPicker>
+ </Show>
+ </>
}
>
- <Switch>
- <Match when={triggerVariant() === 'pill' && !hasTags()}>
- <TagPicker
- docTags={docTags}
- triggerClass={badgeTriggerClasses({
- variant: 'outline',
- size: 'xs',
- class: 'm-px gap-1.5',
- })}
- triggerLabel="Add tags"
- >
- <PlusIcon class="size-3" />
- <span>Add tags</span>
- </TagPicker>
- </Match>
- <Match when={true}>
- <TagPicker
- docTags={docTags}
- triggerClass={buttonClasses({
- variant: 'secondary',
- size: 'icon-xs',
- class: 'm-px',
- })}
- triggerLabel="Add tags"
- >
- <PlusIcon class="size-3" />
- </TagPicker>
- </Match>
- </Switch>
+ <Show
+ when={props.canEdit}
+ fallback={
+ <span class="text-xs text-ink-muted">{t('common.emptyTags')}</span>
+ }
+ >
+ <TagPicker
+ docTags={docTags}
+ triggerClass={buttonClasses({
+ variant: 'outline',
+ size: 'xs',
+ })}
+ triggerLabel={t('common.addTags')}
+ >
+ <TagIcon class="size-4" />
+ {t('common.addTags')}
+ </TagPicker>
+ </Show>
</Show>
<TagEditorDialog
open={editorMode() !== null}
diff --git a/apps/web/src/lib/i18n/locales/en/common.ts b/apps/web/src/lib/i18n/locales/en/common.ts
index 14ad93b657..39e95e4d10 100644
--- a/apps/web/src/lib/i18n/locales/en/common.ts
+++ b/apps/web/src/lib/i18n/locales/en/common.ts
@@ -1,4 +1,12 @@
export default {
+ add: 'Add',
+ addProperty: 'Add property',
+ addTags: 'Add tags',
+ emptyCollection: 'No items added yet',
+ emptyTags: 'No tags added yet',
+ dropToAdd: 'Drop to add',
+ addingItem: 'Adding item…',
+ cannotAddDraggedItem: 'Can’t add this item',
addPhotos: 'Add photos',
addFiles: 'Add files',
photosFromDevice: 'Images from your device',
diff --git a/docs/agent-guide/ui-conventions.md b/docs/agent-guide/ui-conventions.md
index 03f302b854..b0e1670bdf 100644
--- a/docs/agent-guide/ui-conventions.md
+++ b/docs/agent-guide/ui-conventions.md
@@ -157,6 +157,58 @@ action; it uses the theme accent. Use neutral for solid monochrome emphasis and
secondary for softer neutral actions. Loading actions use `loading`. Mobile
confirmation drawers use the same action hierarchy.
+## Property collections
+
+Use a 4px vertical gap between all property rows, including inline Tags and
+transitions between regular fields and collection fields.
+Separate populated property lists from the bottom Add property action by 16px,
+using list bottom spacing rather than an action margin so empty lists leave no gap.
+Keep property names on one line. Let collection headers use available space up
+to their actions before truncating; value rows retain the shared label column.
+
+Empty multi-entity collections show only their property header, without a
+placeholder or reserved content area. Align their labeled ghost Add button with
+the shared value-selector column, allowing longer names to borrow available
+space. Populated collections use an icon-only ghost
+Add button at the right, immediately before the pin action. Keep Add actions
+extra-muted until hovered or keyboard-focused.
+While dragging a compatible app item, tint the property name and show a small
+tray-arrow drop icon without expanding the row. Hovering a populated property highlights
+its existing item list as the dashed dropzone, without a separate box or layout
+shift. Empty properties reveal a full-width dashed dropzone below the field label.
+Use 300ms transitions with reduced-motion support; this first pass does not use
+pointer proximity. Hide collection Add buttons during app-item drags while
+preserving their layout space. Incompatible or unavailable collections retain
+their height and show no rejection feedback. Dropping adds a reference without
+moving the original item.
+Existing references stay in place. Duplicate references, the owning entity's
+matching type-and-ID pair, unsupported item types, and types outside the property's
+restriction are ignored. Read-only, metadata, loading, saving, and open-editor
+states reject drops. Picker saves, drops, chip removal, and row removal share a
+busy state through save and refresh, preventing stale references from replacing
+newly selected values.
+New references appear immediately in the collection as pending chips with an
+inline spinner through saving and refresh. Use the dragged item's label while
+its preview metadata loads. Failed saves clear pending chips through the existing
+error flow. Pending chips cannot be opened or removed. A persistently
+mounted status region announces additions, including picker saves. Removed
+references disappear immediately and are restored from the last confirmed values
+if saving fails. A failed refresh does not undo a successful save: keep confirmed
+edits visible until the query reflects them, and base subsequent edits on those
+values. Other values remain visible; further edits and drops stay locked during
+that operation. Add and value edits also remain disabled while the initial
+collection loads.
+
+The empty dedicated Tags section uses a compact, tag-icon Add tags outline button,
+without a separate message, card, title, or description. Keep the button
+permission-gated and connected to the existing tag picker; read-only sections
+show “No tags added yet” instead.
+Inline Tags property rows remain compact.
+
+The **Add** action remains the keyboard/touch alternative. This target does not
+upload files dragged from the computer. A persisted drop changes property data;
+use only disposable items and properties when that mutation is authorized.
+
## List-item sharing
Right-click a shareable list row and choose **Share**. The sharing dialog must
@@ -186,10 +238,20 @@ information panels. Markdown/tasks include Ask Macro and document/task dispatch;
includes Ask Macro and Create task; PDF and calls include Ask Macro. Native
projects put Delete in the `Project actions` menu after the project title.
-Standard metadata is quiet, non-collapsible text at the bottom of each panel,
-separated by a muted divider. Owner and available timestamps share one format;
-Markdown adds word/character counts. There is no standard Details or Stats
+Standard metadata appears at the top of each panel, before the interactive
+sections and separated by a muted divider. Each row places its label without an
+icon in a left column sized by `--sidepanel-label-width`, followed by a nearby
+left-aligned value. Metadata, property grids, and inline Tags share this column
+and 12px label-to-value gap; metadata rows retain their 8px vertical gaps.
+Word and character counts appear last. There is no standard Details or Stats
disclosure. Agent runtime information remains in its dedicated Session section.
+Section headers and bodies use 12px horizontal insets, with 12px bottom padding
+on the body. Collapsible headers place the shared view-sidebar caret immediately
+after the section name, with matching hover and focus treatment rather than an
+underline. Editable Properties and Tags headers have a right-aligned, icon-only
+Add action, visible whenever the section is expanded, that opens the existing
+picker. Compose actions natively with the section and their owning state;
+do not mount them through a portal. Keep read-only sections free of Add actions.
Block information panels float over the right side of the block without changing
the content width or its centered position. A single rounded bubble fits its