Skip to content

armgit / macro

Public Imported from GitHub
0

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

fix(web): property panel pinning (#8079)

dev-rb44db4572b03c
diff --git a/apps/web/src/features/block-md/component/InlinePropertyValue.test.tsx b/apps/web/src/features/block-md/component/InlinePropertyValue.test.tsx
index b9f6582450..3fbb45f86b 100644
--- a/apps/web/src/features/block-md/component/InlinePropertyValue.test.tsx
+++ b/apps/web/src/features/block-md/component/InlinePropertyValue.test.tsx
@@ -32,7 +32,7 @@ const property: Property = {
createdAt: '2026-01-01',
updatedAt: '2026-01-01',
};
-function setup(canEdit = true) {
+function setup(canEdit = true, canRemove = true) {
const remove = vi.fn<() => Promise<void>>().mockResolvedValue(undefined);
const unpin = vi.fn();
const refresh = vi.fn();
@@ -49,7 +49,12 @@ function setup(canEdit = true) {
removeProperty={remove}
saveHandler={{ saveProperty: vi.fn(), saveDate: vi.fn() }}
>
- <InlinePropertyValue property={property} entityId="doc" canManage />
+ <InlinePropertyValue
+ property={property}
+ entityId="doc"
+ canManage
+ canRemove={canRemove}
+ />
</PropertiesProvider>
));
return { remove, unpin, refresh };
@@ -57,7 +62,7 @@ function setup(canEdit = true) {
it('unpins without removing the saved property', async () => {
const { remove, unpin } = setup();
await fireEvent.click(screen.getByRole('button', { name: 'Unpin' }));
- expect(unpin).toHaveBeenCalledWith('assignment');
+ expect(unpin).toHaveBeenCalledWith('assignment', 'definition');
expect(remove).not.toHaveBeenCalled();
});
it('removes the property assignment and its pin after a successful save', async () => {
@@ -65,7 +70,9 @@ it('removes the property assignment and its pin after a successful save', async
await fireEvent.click(
screen.getByRole('button', { name: 'Delete from item' })
);
- await waitFor(() => expect(unpin).toHaveBeenCalledWith('assignment'));
+ await waitFor(() =>
+ expect(unpin).toHaveBeenCalledWith('assignment', 'definition')
+ );
expect(remove).toHaveBeenCalledWith('assignment');
expect(refresh).toHaveBeenCalledOnce();
});
@@ -89,3 +96,9 @@ it('hides management actions for read-only documents', () => {
setup(false);
expect(screen.queryByRole('button')).toBeNull();
});
+
+it('allows unpinning protected task properties without exposing deletion', () => {
+ setup(true, false);
+ expect(screen.getByRole('button', { name: 'Unpin' })).toBeTruthy();
+ expect(screen.queryByRole('button', { name: 'Delete from item' })).toBeNull();
+});
diff --git a/apps/web/src/features/block-md/component/InlinePropertyValue.tsx b/apps/web/src/features/block-md/component/InlinePropertyValue.tsx
index 9050448d2c..fe2ee93c98 100644
--- a/apps/web/src/features/block-md/component/InlinePropertyValue.tsx
+++ b/apps/web/src/features/block-md/component/InlinePropertyValue.tsx
@@ -15,6 +15,7 @@ type InlinePropertyValueProps = {
emptyLabel?: JSX.Element;
class?: string;
canManage?: boolean;
+ canRemove?: boolean;
};
/**
@@ -69,7 +70,10 @@ export const InlinePropertyValue: Component<InlinePropertyValueProps> = (
<Show
when={props.canManage && ctx.canEdit && !props.property.isMetadata}
>
- <InlinePropertyActions property={props.property} />
+ <InlinePropertyActions
+ property={props.property}
+ canRemove={props.canRemove}
+ />
</Show>
}
entitySelfFilter={{ entityType: ctx.entityType, blockId: props.entityId }}
@@ -77,7 +81,10 @@ export const InlinePropertyValue: Component<InlinePropertyValueProps> = (
);
};
-function InlinePropertyActions(props: { property: PropertyT }) {
+function InlinePropertyActions(props: {
+ property: PropertyT;
+ canRemove?: boolean;
+}) {
const ctx = usePropertiesContext();
const [removing, setRemoving] = createSignal(false);
const remove = async () => {
@@ -85,7 +92,10 @@ function InlinePropertyActions(props: { property: PropertyT }) {
setRemoving(true);
try {
await ctx.removeProperty(props.property.propertyId);
- ctx.onPropertyUnpinned?.(props.property.propertyId);
+ ctx.onPropertyUnpinned?.(
+ props.property.propertyId,
+ props.property.propertyDefinitionId
+ );
ctx.onPropertyDeleted();
} catch {
// The shared removal mutation reports the failure and keeps the property.
@@ -99,20 +109,27 @@ function InlinePropertyActions(props: { property: PropertyT }) {
type="button"
class="flex w-full min-w-0 items-center gap-2 whitespace-nowrap rounded-md px-2 py-1.5 text-left hover:bg-hover disabled:opacity-50"
disabled={removing()}
- onClick={() => ctx.onPropertyUnpinned?.(props.property.propertyId)}
+ onClick={() =>
+ ctx.onPropertyUnpinned?.(
+ props.property.propertyId,
+ props.property.propertyDefinitionId
+ )
+ }
>
<PushPinSlashIcon class="size-3.5 shrink-0 text-ink-muted" />
Unpin
</button>
- <button
- type="button"
- class="flex w-full min-w-0 items-center gap-2 whitespace-nowrap rounded-md px-2 py-1.5 text-left text-failure-ink hover:bg-hover disabled:opacity-50"
- disabled={removing()}
- onClick={remove}
- >
- <TrashIcon class="size-3.5 shrink-0" />
- {removing() ? 'Deleting…' : 'Delete from item'}
- </button>
+ <Show when={props.canRemove !== false}>
+ <button
+ type="button"
+ class="flex w-full min-w-0 items-center gap-2 whitespace-nowrap rounded-md px-2 py-1.5 text-left text-failure-ink hover:bg-hover disabled:opacity-50"
+ disabled={removing()}
+ onClick={remove}
+ >
+ <TrashIcon class="size-3.5 shrink-0" />
+ {removing() ? 'Deleting…' : 'Delete from item'}
+ </button>
+ </Show>
</div>
);
}
diff --git a/apps/web/src/features/block-md/component/InlineTaskProperties.test.tsx b/apps/web/src/features/block-md/component/InlineTaskProperties.test.tsx
index b3feaa9282..decfc53fd1 100644
--- a/apps/web/src/features/block-md/component/InlineTaskProperties.test.tsx
+++ b/apps/web/src/features/block-md/component/InlineTaskProperties.test.tsx
@@ -1,7 +1,10 @@
import {
$getPinnedProperties,
+ $getStoredPinnedProperties,
+ ADD_PINNED_PROPERTY_COMMAND,
pinnedPropertiesPlugin,
} from '@core/component/LexicalMarkdown/plugins/pinned-properties/pinnedPropertiesPlugin';
+import { SYSTEM_PROPERTY_IDS } from '@property/constants';
import {
PropertiesProvider,
usePropertiesContext,
@@ -25,10 +28,13 @@ import {
$getRoot,
createEditor,
type LexicalEditor,
+ type SerializedEditorState,
} from 'lexical';
-import { createSignal } from 'solid-js';
+import { createRoot, createSignal, type Setter } from 'solid-js';
import { createStore } from 'solid-js/store';
import { afterEach, beforeEach, expect, it, vi } from 'vitest';
+import { createPinnedProperties } from '../primitives/create-pinned-properties';
+import type { MarkdownDocumentKind } from '../types';
import { InlineTaskProperties } from './InlineTaskProperties';
import { TaskComposerPropertyEditor } from './TaskComposerPropertyEditor';
@@ -37,7 +43,8 @@ const mocks = vi.hoisted(() => ({
properties: () => [] as Property[],
add: vi.fn(),
open: vi.fn<typeof openPropertyEditor>(),
- kind: 'document' as 'document' | 'task',
+ kind: 'document' as MarkdownDocumentKind,
+ setProperties: undefined as Setter<Property[]> | undefined,
projectsEnabled: false,
}));
const entityWrite = vi.fn();
@@ -153,6 +160,7 @@ vi.mock('./InlinePropertyValue', () => ({
},
}));
afterEach(() => {
+ for (const dispose of disposers.splice(0)) dispose();
cleanup();
vi.clearAllMocks();
vi.restoreAllMocks();
@@ -160,6 +168,8 @@ afterEach(() => {
mocks.projectsEnabled = false;
});
+const disposers: (() => void)[] = [];
+
const property: Property = {
propertyId: 'assignment',
propertyDefinitionId: 'definition',
@@ -184,7 +194,7 @@ const draftDefinition: PropertyDefinitionDomain = {
updatedAt: '2026-01-01',
};
-function setup(initial: Property[] = []) {
+function setup(initial: Property[] = [], saved?: SerializedEditorState) {
const editor = createEditor({
onError: (error) => {
throw error;
@@ -194,10 +204,12 @@ function setup(initial: Property[] = []) {
discrete: true,
});
pinnedPropertiesPlugin()(editor);
+ if (saved) editor.setEditorState(editor.parseEditorState(saved));
mocks.editor = editor;
render(() => {
const [properties, setProperties] = createSignal(initial);
mocks.properties = properties;
+ mocks.setProperties = setProperties;
mocks.add.mockImplementation(async () => setProperties([property]));
return <InlineTaskProperties />;
});
@@ -256,6 +268,228 @@ it("shows a task's Project with the other task properties, through the same pill
expect(screen.queryByRole('button', { name: 'Unpin Project' })).toBeNull();
});
+const taskDefinitions = [
+ SYSTEM_PROPERTY_IDS.STATUS,
+ SYSTEM_PROPERTY_IDS.PRIORITY,
+ SYSTEM_PROPERTY_IDS.ASSIGNEES,
+];
+const taskProperties: Property[] = taskDefinitions.map(
+ (definitionId, index) => ({
+ ...property,
+ propertyId: `task-${index}`,
+ propertyDefinitionId: definitionId,
+ displayName: ['Status', 'Priority', 'Assignees'][index],
+ })
+);
+
+function setupPins(
+ editor: LexicalEditor,
+ defaults: readonly string[] = taskDefinitions
+) {
+ return createRoot((dispose) => {
+ disposers.push(dispose);
+ return createPinnedProperties(
+ () => editor,
+ () => defaults
+ );
+ });
+}
+
+it.each(['task', 'snippet', 'skill'] as const)(
+ 'renders saved pins below a %s title and unpins without losing the value',
+ async (kind) => {
+ mocks.kind = kind;
+ const editor = setup([property]);
+ editor.dispatchCommand(ADD_PINNED_PROPERTY_COMMAND, property.propertyId);
+ await waitFor(() =>
+ expect(
+ screen.getByRole('button', { name: 'Unpin Review notes' })
+ ).toBeTruthy()
+ );
+ await fireEvent.click(
+ screen.getByRole('button', { name: 'Unpin Review notes' })
+ );
+ await waitFor(() =>
+ expect(
+ screen.queryByRole('button', { name: 'Unpin Review notes' })
+ ).toBeNull()
+ );
+ expect(mocks.properties()[0].value).toBe('Keep this value');
+ expect(editor.getEditorState().read($getStoredPinnedProperties)).toEqual(
+ []
+ );
+ }
+);
+
+it('preserves implicit task defaults when pinning the first additional property', async () => {
+ mocks.kind = 'task';
+ const properties = [...taskProperties, property];
+ const editor = setup(properties);
+ const pins = setupPins(editor);
+ expect(
+ editor.getEditorState().read($getStoredPinnedProperties)
+ ).toBeUndefined();
+ pins.pin(property.propertyId, properties);
+ await waitFor(() =>
+ expect(
+ screen.getByRole('button', { name: 'Unpin Review notes' })
+ ).toBeTruthy()
+ );
+ expect(editor.getEditorState().read($getPinnedProperties)).toEqual([
+ ...taskProperties.map((item) => item.propertyId),
+ property.propertyId,
+ ]);
+ for (const item of taskProperties) {
+ expect(
+ screen.getByRole('button', { name: `Unpin ${item.displayName}` })
+ ).toBeTruthy();
+ }
+});
+
+it('keeps consecutive pin changes before the editor commits', async () => {
+ mocks.kind = 'task';
+ const properties = [...taskProperties, property];
+ const editor = setup(properties);
+ const pins = setupPins(editor);
+
+ pins.pin(property.propertyId, properties);
+ pins.unpin(taskProperties[0].propertyId, properties);
+
+ await waitFor(() =>
+ expect(editor.getEditorState().read($getStoredPinnedProperties)).toEqual([
+ taskProperties[1].propertyId,
+ taskProperties[2].propertyId,
+ property.propertyId,
+ ])
+ );
+ expect(screen.queryByRole('button', { name: 'Unpin Status' })).toBeNull();
+ expect(
+ screen.getByRole('button', { name: 'Unpin Review notes' })
+ ).toBeTruthy();
+});
+
+it('unpins an implicit task default without dropping the other defaults', async () => {
+ mocks.kind = 'task';
+ const editor = setup(taskProperties);
+ await fireEvent.click(screen.getByRole('button', { name: 'Unpin Status' }));
+ await waitFor(() =>
+ expect(screen.queryByRole('button', { name: 'Unpin Status' })).toBeNull()
+ );
+ expect(editor.getEditorState().read($getPinnedProperties)).toEqual([
+ taskProperties[1].propertyId,
+ taskProperties[2].propertyId,
+ ]);
+ expect(mocks.properties()).toEqual(taskProperties);
+});
+
+it('keeps all task title pins cleared after serialization and reopening', async () => {
+ mocks.kind = 'task';
+ const editor = setup(taskProperties);
+ for (const item of taskProperties) {
+ await fireEvent.click(
+ screen.getByRole('button', { name: `Unpin ${item.displayName}` })
+ );
+ await waitFor(() =>
+ expect(
+ screen.queryByRole('button', { name: `Unpin ${item.displayName}` })
+ ).toBeNull()
+ );
+ }
+ expect(editor.getEditorState().read($getStoredPinnedProperties)).toEqual([]);
+ const saved = editor.getEditorState().toJSON();
+ cleanup();
+ const reopened = setup(taskProperties, saved);
+ expect(reopened.getEditorState().read($getStoredPinnedProperties)).toEqual(
+ []
+ );
+ expect(screen.queryByRole('button', { name: /^Unpin / })).toBeNull();
+ expect(mocks.properties()).toEqual(taskProperties);
+});
+
+it('resolves a default Project placeholder after assignment and preserves its value on unpin', async () => {
+ mocks.kind = 'task';
+ mocks.projectsEnabled = true;
+ const pendingProject: Property = {
+ ...property,
+ propertyId: `pending:${SYSTEM_PROPERTY_IDS.PROJECT}`,
+ propertyDefinitionId: SYSTEM_PROPERTY_IDS.PROJECT,
+ displayName: 'Project',
+ value: null,
+ };
+ const editor = setup([...taskProperties, property]);
+ const pins = setupPins(editor, [
+ ...taskDefinitions,
+ SYSTEM_PROPERTY_IDS.PROJECT,
+ ]);
+ pins.pin(property.propertyId, [...taskProperties, pendingProject, property]);
+ await waitFor(() =>
+ expect(editor.getEditorState().read($getPinnedProperties)).toContain(
+ pendingProject.propertyId
+ )
+ );
+ const assignedProject: Property = {
+ ...pendingProject,
+ propertyId: 'project-assignment',
+ value: 'Assigned project',
+ };
+ mocks.setProperties?.([...taskProperties, assignedProject, property]);
+ await waitFor(() =>
+ expect(
+ screen.getAllByRole('button', { name: 'Unpin Project' })
+ ).toHaveLength(1)
+ );
+ await fireEvent.click(screen.getByRole('button', { name: 'Unpin Project' }));
+ await waitFor(() =>
+ expect(screen.queryByRole('button', { name: 'Unpin Project' })).toBeNull()
+ );
+ const savedIds = editor.getEditorState().read($getPinnedProperties);
+ expect(savedIds).not.toContain(pendingProject.propertyId);
+ expect(savedIds).not.toContain(assignedProject.propertyId);
+ expect(savedIds).toContain(property.propertyId);
+ expect(
+ mocks
+ .properties()
+ .find((item) => item.propertyId === assignedProject.propertyId)?.value
+ ).toBe('Assigned project');
+});
+
+it('clears a placeholder-backed Project pin when its assignment disappears before removal finishes', async () => {
+ mocks.kind = 'task';
+ mocks.projectsEnabled = true;
+ const pendingProject: Property = {
+ ...property,
+ propertyId: `pending:${SYSTEM_PROPERTY_IDS.PROJECT}`,
+ propertyDefinitionId: SYSTEM_PROPERTY_IDS.PROJECT,
+ displayName: 'Project',
+ value: null,
+ };
+ const properties = [...taskProperties, pendingProject, property];
+ const editor = setup(properties);
+ const pins = setupPins(editor, [
+ ...taskDefinitions,
+ SYSTEM_PROPERTY_IDS.PROJECT,
+ ]);
+ pins.pin(property.propertyId, properties);
+ await waitFor(() =>
+ expect(editor.getEditorState().read($getPinnedProperties)).toContain(
+ pendingProject.propertyId
+ )
+ );
+ pins.unpin(
+ 'removed-project-assignment',
+ properties,
+ SYSTEM_PROPERTY_IDS.PROJECT
+ );
+ await waitFor(() =>
+ expect(editor.getEditorState().read($getPinnedProperties)).not.toContain(
+ pendingProject.propertyId
+ )
+ );
+ expect(editor.getEditorState().read($getPinnedProperties)).toContain(
+ property.propertyId
+ );
+});
+
it('selects a shared property and edits its draft value without an entity write', async () => {
const onAdd = vi.fn(async () => {});
const [values, setValues] = createStore<Record<string, PropertyApiValues>>(
diff --git a/apps/web/src/features/block-md/component/InlineTaskProperties.tsx b/apps/web/src/features/block-md/component/InlineTaskProperties.tsx
index c8bd3692c7..90c7142036 100644
--- a/apps/web/src/features/block-md/component/InlineTaskProperties.tsx
+++ b/apps/web/src/features/block-md/component/InlineTaskProperties.tsx
@@ -4,11 +4,16 @@ import { enableProjects } from '@core/constant/featureFlags';
import { buildTaskProjectDefaultProperty } from '@entity/extractors-property';
import { AddPropertyButton } from '@property/component/AddPropertyButton';
import { Modals } from '@property/component/modal';
-import { SYSTEM_PROPERTY_IDS } from '@property/constants';
+import {
+ getBuiltinPropertyIds,
+ getDefaultPinnedProperties,
+ SYSTEM_PROPERTY_IDS,
+} from '@property/constants';
import {
PropertiesProvider,
type PropertySaveHandler,
} from '@property/context/PropertiesContext';
+import { resolvePinnedPropertyIds } from '@property/core/pinned-property-ids';
import { useEntityProperties } from '@property/hooks';
import { InlineFetchedEntityTagsPill } from '@property/tags';
import type { Property, PropertyApiValues } from '@property/types';
@@ -40,8 +45,35 @@ export function InlineTaskProperties() {
const { properties, refetch, addProperty, removeProperty } =
useEntityProperties(blockId, entityType, false);
- const pins = createPinnedProperties(() => state.editor.md.editor);
const projects = useFeatureFlag(enableProjects);
+ const defaultDefinitionIds = () =>
+ documentKind === 'task'
+ ? [
+ ...getDefaultPinnedProperties('task'),
+ ...(projects().enabled ? [SYSTEM_PROPERTY_IDS.PROJECT] : []),
+ ]
+ : [];
+ const pins = createPinnedProperties(
+ () => state.editor.md.editor,
+ defaultDefinitionIds
+ );
+ const titleProperties = () => {
+ const fetched = properties();
+ return documentKind === 'task' &&
+ projects().enabled &&
+ !fetched.some(
+ (property) =>
+ property.propertyDefinitionId === SYSTEM_PROPERTY_IDS.PROJECT
+ )
+ ? [...fetched, buildTaskProjectDefaultProperty()]
+ : fetched;
+ };
+ const titlePinnedIds = () =>
+ resolvePinnedPropertyIds(
+ titleProperties(),
+ pins.ids(),
+ defaultDefinitionIds()
+ );
const tagSets = useTagsQuery();
const tagDefinitionIds = () =>
new Set(
@@ -67,38 +99,37 @@ export function InlineTaskProperties() {
if (pendingPins().size === 0 || !state.editor.md.editor) return;
for (const property of properties()) {
if (!pendingPins().has(property.propertyDefinitionId)) continue;
- pins.pin(property.propertyId);
+ pins.pin(property.propertyId, titleProperties());
clearPendingPin(property.propertyDefinitionId);
}
});
const inlineProperties = createMemo(() => {
- const props = properties();
- if (documentKind === 'document') {
- return props.filter(
- (property) =>
- pins.ids().includes(property.propertyId) &&
- !property.isMetadata &&
- !tagDefinitionIds().has(property.propertyDefinitionId)
- );
- }
- const ids = [
- SYSTEM_PROPERTY_IDS.STATUS,
- SYSTEM_PROPERTY_IDS.PRIORITY,
- SYSTEM_PROPERTY_IDS.ASSIGNEES,
- ];
- const task = ids
- .map((id) => props.find((p) => p.propertyDefinitionId === id))
- .filter((p): p is Property => p !== undefined);
- if (!projects().enabled) return task;
- // A task carries Project only once it joins one; the placeholder lets the
- // same pill and editor set it.
- return [
- ...task,
- props.find(
- (p) => p.propertyDefinitionId === SYSTEM_PROPERTY_IDS.PROJECT
- ) ?? buildTaskProjectDefaultProperty(),
+ const selected = titlePinnedIds();
+ const visible = titleProperties().filter(
+ (property) =>
+ selected.includes(property.propertyId) &&
+ !property.isMetadata &&
+ !tagDefinitionIds().has(property.propertyDefinitionId) &&
+ !(
+ documentKind === 'task' &&
+ !projects().enabled &&
+ property.propertyDefinitionId === SYSTEM_PROPERTY_IDS.PROJECT
+ )
+ );
+ if (documentKind !== 'task') return visible;
+ const order = [
+ ...getDefaultPinnedProperties('task'),
+ SYSTEM_PROPERTY_IDS.PROJECT,
];
+ return [...visible].sort((left, right) => {
+ const leftIndex = order.indexOf(left.propertyDefinitionId);
+ const rightIndex = order.indexOf(right.propertyDefinitionId);
+ return (
+ (leftIndex < 0 ? order.length : leftIndex) -
+ (rightIndex < 0 ? order.length : rightIndex)
+ );
+ });
});
const shouldShowRow = createMemo(
() =>
@@ -131,9 +162,11 @@ export function InlineTaskProperties() {
properties={properties}
addProperty={addProperty}
removeProperty={removeProperty}
- pinnedPropertyIds={pins.ids}
- onPropertyPinned={pins.pin}
- onPropertyUnpinned={pins.unpin}
+ pinnedPropertyIds={titlePinnedIds}
+ onPropertyPinned={(id) => pins.pin(id, titleProperties())}
+ onPropertyUnpinned={(id, definitionId) =>
+ pins.unpin(id, titleProperties(), definitionId)
+ }
onRefresh={refetch}
onPropertyAdded={propertyAdded}
onPropertyAddFailed={clearPendingPin}
@@ -152,7 +185,17 @@ export function InlineTaskProperties() {
property={property}
entityId={blockId}
class="bg-surface-2 border border-edge"
- canManage={documentKind === 'document'}
+ canManage={
+ !property.propertyId.startsWith('pending:') ||
+ defaultDefinitionIds().includes(property.propertyDefinitionId)
+ }
+ canRemove={
+ !property.propertyId.startsWith('pending:') &&
+ (documentKind !== 'task' ||
+ !getBuiltinPropertyIds('task').includes(
+ property.propertyDefinitionId
+ ))
+ }
/>
)}
</For>
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 d41052c9c9..5d32df60f3 100644
--- a/apps/web/src/features/block-md/component/sidepanel/MarkdownSidePanelSections.tsx
+++ b/apps/web/src/features/block-md/component/sidepanel/MarkdownSidePanelSections.tsx
@@ -30,6 +30,7 @@ import { useSplitNavigationHandler } from '@core/util/useSplitNavigationHandler'
import { buildTaskProjectDefaultProperty } from '@entity/extractors-property';
import { useNotificationsForEntity } from '@notifications';
import {
+ getBuiltinPropertyIds,
getDefaultPinnedProperties,
SYSTEM_PROPERTY_IDS,
} from '@property/constants';
@@ -203,8 +204,18 @@ function PropertiesSectionContent(props: {
const entityType: PropertiesEntityType = props.isTask ? 'TASK' : 'DOCUMENT';
- const pins = createPinnedProperties(() => mdData.editor);
const projects = useFeatureFlag(enableProjects);
+ const defaultTitlePropertyDefinitionIds = () =>
+ props.isTask
+ ? [
+ ...getDefaultPinnedProperties('task'),
+ ...(projects().enabled ? [SYSTEM_PROPERTY_IDS.PROJECT] : []),
+ ]
+ : [];
+ const pins = createPinnedProperties(
+ () => mdData.editor,
+ defaultTitlePropertyDefinitionIds
+ );
return (
<EntityPropertiesSection
@@ -215,8 +226,13 @@ function PropertiesSectionContent(props: {
defaultPinnedPropertyIds={() =>
props.isTask ? getDefaultPinnedProperties('task') : []
}
+ requiredPropertyDefinitionIds={
+ props.isTask ? getBuiltinPropertyIds('task') : undefined
+ }
pinnedPropertyIds={pins.ids}
+ defaultTitlePropertyDefinitionIds={defaultTitlePropertyDefinitionIds}
pinnedPropertyDefinitionOrder={PINNED_ORDER}
+ onPropertyPinned={mdData.editor ? pins.pin : undefined}
onPropertyUnpinned={pins.unpin}
showTags={false}
// A task joins a project through its Project property, edited like the others.
diff --git a/apps/web/src/features/block-md/primitives/create-pinned-properties.ts b/apps/web/src/features/block-md/primitives/create-pinned-properties.ts
index 96fb367628..7e94482354 100644
--- a/apps/web/src/features/block-md/primitives/create-pinned-properties.ts
+++ b/apps/web/src/features/block-md/primitives/create-pinned-properties.ts
@@ -1,31 +1,83 @@
import {
- $getPinnedProperties,
+ $getStoredPinnedProperties,
ADD_PINNED_PROPERTY_COMMAND,
REMOVE_PINNED_PROPERTY_COMMAND,
} from '@core/component/LexicalMarkdown/plugins/pinned-properties/pinnedPropertiesPlugin';
+import { resolvePinnedPropertyIds } from '@property/core/pinned-property-ids';
+import type { Property } from '@property/types';
import type { LexicalEditor } from 'lexical';
import { type Accessor, createEffect, createSignal, onCleanup } from 'solid-js';
/** Observe and update the pins persisted in the collaborative document. */
export function createPinnedProperties(
- editor: Accessor<LexicalEditor | undefined>
+ editor: Accessor<LexicalEditor | undefined>,
+ defaultDefinitionIds: Accessor<readonly string[]> = () => []
) {
- const [ids, setIds] = createSignal<string[]>([]);
+ const [ids, setIds] = createSignal<string[] | undefined>();
createEffect(() => {
const current = editor();
- if (!current) return;
- current.getEditorState().read(() => setIds($getPinnedProperties()));
+ if (!current) {
+ setIds(undefined);
+ return;
+ }
+ current.getEditorState().read(() => setIds($getStoredPinnedProperties()));
onCleanup(
current.registerUpdateListener(({ editorState }) => {
- editorState.read(() => setIds($getPinnedProperties()));
+ editorState.read(() => setIds($getStoredPinnedProperties()));
})
);
});
+ const update = (
+ id: string,
+ properties: readonly Property[],
+ pin: boolean,
+ propertyDefinitionId?: string
+ ) => {
+ const current = editor();
+ if (!current) return;
+ const defaults = defaultDefinitionIds();
+ const definitionId =
+ propertyDefinitionId ??
+ properties.find((property) => property.propertyId === id)
+ ?.propertyDefinitionId;
+ current.update(() => {
+ const storedIds = $getStoredPinnedProperties();
+ const selected = resolvePinnedPropertyIds(
+ properties,
+ storedIds,
+ defaults
+ );
+ // Materialize defaults and resolve placeholder IDs using the existing commands.
+ for (const propertyId of selected) {
+ if (!storedIds?.includes(propertyId)) {
+ current.dispatchCommand(ADD_PINNED_PROPERTY_COMMAND, propertyId);
+ }
+ }
+ for (const propertyId of storedIds ?? []) {
+ if (!selected.includes(propertyId)) {
+ current.dispatchCommand(REMOVE_PINNED_PROPERTY_COMMAND, propertyId);
+ }
+ }
+ current.dispatchCommand(
+ pin ? ADD_PINNED_PROPERTY_COMMAND : REMOVE_PINNED_PROPERTY_COMMAND,
+ id
+ );
+ if (!pin && definitionId) {
+ current.dispatchCommand(
+ REMOVE_PINNED_PROPERTY_COMMAND,
+ `pending:${definitionId}`
+ );
+ }
+ });
+ };
return {
ids,
- pin: (id: string) =>
- editor()?.dispatchCommand(ADD_PINNED_PROPERTY_COMMAND, id),
- unpin: (id: string) =>
- editor()?.dispatchCommand(REMOVE_PINNED_PROPERTY_COMMAND, id),
+ pin: (id: string, properties: readonly Property[] = []) =>
+ update(id, properties, true),
+ unpin: (
+ id: string,
+ properties: readonly Property[] = [],
+ definitionId?: string
+ ) => update(id, properties, false, definitionId),
};
}
diff --git a/apps/web/src/features/property/context/PropertiesContext.tsx b/apps/web/src/features/property/context/PropertiesContext.tsx
index 5ce5debde1..2fd66e805e 100644
--- a/apps/web/src/features/property/context/PropertiesContext.tsx
+++ b/apps/web/src/features/property/context/PropertiesContext.tsx
@@ -37,7 +37,10 @@ interface PropertiesContextValue {
onPropertyAddFailed?: (definitionId: string) => void;
onPropertyDeleted: () => void;
onPropertyPinned?: (propertyId: string) => void;
- onPropertyUnpinned?: (propertyId: string) => void;
+ onPropertyUnpinned?: (
+ propertyId: string,
+ propertyDefinitionId?: string
+ ) => void;
pinnedPropertyIds?: () => string[];
addProperty?: (propertyDefinitionId: string) => Promise<void>;
removeProperty?: (propertyId: string) => Promise<void>;
@@ -74,7 +77,10 @@ interface PropertiesProviderProps extends ParentProps {
onPropertyAddFailed?: (definitionId: string) => void;
onPropertyDeleted: () => void;
onPropertyPinned?: (propertyId: string) => void;
- onPropertyUnpinned?: (propertyId: string) => void;
+ onPropertyUnpinned?: (
+ propertyId: string,
+ propertyDefinitionId?: string
+ ) => void;
pinnedPropertyIds?: () => string[];
addProperty?: (propertyDefinitionId: string) => Promise<void>;
removeProperty?: (propertyId: string) => Promise<void>;
diff --git a/apps/web/src/features/property/core/pinned-property-ids.ts b/apps/web/src/features/property/core/pinned-property-ids.ts
new file mode 100644
index 0000000000..e2fde2b7f9
--- /dev/null
+++ b/apps/web/src/features/property/core/pinned-property-ids.ts
@@ -0,0 +1,29 @@
+import type { Property } from '../types';
+
+/** Resolve implicit defaults and placeholder pins using already-loaded properties. */
+export function resolvePinnedPropertyIds(
+ properties: readonly Pick<Property, 'propertyId' | 'propertyDefinitionId'>[],
+ storedIds: readonly string[] | undefined,
+ defaultDefinitionIds: readonly string[] = []
+): string[] {
+ const selected =
+ storedIds ??
+ defaultDefinitionIds.flatMap((definitionId) => {
+ const property = properties.find(
+ (property) => property.propertyDefinitionId === definitionId
+ );
+ return property ? [property.propertyId] : [];
+ });
+ const resolved = selected.map((id) => {
+ if (!id.startsWith('pending:')) return id;
+ const definitionId = id.slice('pending:'.length);
+ return (
+ properties.find(
+ (property) =>
+ property.propertyDefinitionId === definitionId &&
+ !property.propertyId.startsWith('pending:')
+ )?.propertyId ?? id
+ );
+ });
+ return resolved.filter((id, index) => resolved.indexOf(id) === index);
+}
diff --git a/apps/web/src/features/property/editors/hooks/useInlineEditor.ts b/apps/web/src/features/property/editors/hooks/useInlineEditor.ts
index 3cf2d4481f..76b17660f5 100644
--- a/apps/web/src/features/property/editors/hooks/useInlineEditor.ts
+++ b/apps/web/src/features/property/editors/hooks/useInlineEditor.ts
@@ -45,7 +45,8 @@ export function useInlineEditor(): {
};
const save = async () => {
- if (isSaving()) return;
+ // Removing a canceled input can still fire blur.
+ if (!isEditing() || isSaving()) return;
const property = ctx.property();
const trimmedValue = inputValue().trim();
const currentRawValue = getCurrentRawValue();
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 425379935e..8a8aeab1c3 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
@@ -211,6 +211,7 @@ it('keeps unpinned assignments visible in the panel when title pins change', ()
it('adds side-panel properties without exposing an automatic pin callback', () => {
const pins: string[] = [];
+ const pin = vi.fn((id: string) => pins.push(id));
const [properties, setProperties] = createSignal<Property[]>([]);
mocks.getProperties = properties;
render(() => (
@@ -220,6 +221,8 @@ it('adds side-panel properties without exposing an automatic pin callback', () =
canEdit
showTags={false}
pinnedPropertyIds={() => pins}
+ onPropertyPinned={pin}
+ onPropertyUnpinned={vi.fn()}
/>
));
mocks.context.onPropertyAdded(['Custom']);
@@ -227,6 +230,7 @@ it('adds side-panel properties without exposing an automatic pin callback', () =
mocks.context.onPropertyAdded(['Custom']);
expect(screen.getByText('"saved value"')).toBeTruthy();
expect(mocks.context.onPropertyPinned).toBeUndefined();
+ expect(pin).not.toHaveBeenCalled();
expect(pins).toEqual([]);
});
@@ -251,3 +255,212 @@ it('preserves an existing property without reattaching or pinning it', async ()
expect(mocks.context.onPropertyPinned).toBeUndefined();
expect(screen.getByText('"Acme"')).toBeTruthy();
});
+
+it('pins and unpins an assigned property without changing its value or panel visibility', async () => {
+ mocks.properties = [field('Custom', 'saved value')];
+ const [pins, setPins] = createSignal<string[]>([]);
+ const pin = vi.fn((id: string) => setPins([id]));
+ const unpin = vi.fn(() => setPins([]));
+ const [canEdit, setCanEdit] = createSignal(true);
+ render(() => (
+ <EntityPropertiesSection
+ entityId="document"
+ entityType="DOCUMENT"
+ canEdit={canEdit()}
+ showTags={false}
+ pinnedPropertyIds={pins}
+ onPropertyPinned={pin}
+ onPropertyUnpinned={unpin}
+ />
+ ));
+
+ await fireEvent.click(
+ screen.getByRole('button', { name: 'Pin below title' })
+ );
+ expect(pin).toHaveBeenCalledWith('instance-Custom', mocks.properties);
+ expect(
+ screen
+ .getByRole('button', { name: 'Unpin from title' })
+ .getAttribute('aria-pressed')
+ ).toBe('true');
+ await fireEvent.click(
+ screen.getByRole('button', { name: 'Unpin from title' })
+ );
+ expect(unpin).toHaveBeenCalledWith(
+ 'instance-Custom',
+ mocks.properties,
+ 'Custom'
+ );
+ expect(screen.getByText('"saved value"')).toBeTruthy();
+ expect(mocks.remove).not.toHaveBeenCalled();
+ expect(mocks.save).not.toHaveBeenCalled();
+ expect(mocks.context.onPropertyPinned).toBeUndefined();
+
+ setCanEdit(false);
+ expect(screen.queryByRole('button', { name: 'Pin below title' })).toBeNull();
+});
+
+it('does not offer pinning for placeholders, metadata, or hosts without title pin support', () => {
+ mocks.properties = [
+ { ...field('Pending'), propertyId: 'pending:Pending' },
+ { ...field('Metadata'), isMetadata: true },
+ ];
+ render(() => (
+ <EntityPropertiesSection
+ entityId="document"
+ entityType="DOCUMENT"
+ canEdit
+ includeMetadata
+ showTags={false}
+ pinnedPropertyIds={() => []}
+ onPropertyPinned={vi.fn()}
+ onPropertyUnpinned={vi.fn()}
+ />
+ ));
+ expect(screen.queryByRole('button', { name: 'Pin below title' })).toBeNull();
+
+ cleanup();
+ mocks.properties = [field('Custom')];
+ render(() => (
+ <EntityPropertiesSection
+ entityId="chat"
+ entityType="CHAT"
+ canEdit
+ showTags={false}
+ />
+ ));
+ expect(screen.queryByRole('button', { name: 'Pin below title' })).toBeNull();
+ expect(
+ screen.getByRole('button', { name: 'Remove from entity' })
+ ).toBeTruthy();
+});
+
+it('locks pin actions during removal and unpins only after removal succeeds', async () => {
+ mocks.properties = [field('Custom', 'saved value')];
+ let finishRemoval!: () => void;
+ mocks.remove.mockImplementationOnce(
+ () =>
+ new Promise<void>((resolve) => {
+ finishRemoval = resolve;
+ })
+ );
+ const unpin = vi.fn();
+ render(() => (
+ <EntityPropertiesSection
+ entityId="document"
+ entityType="DOCUMENT"
+ canEdit
+ showTags={false}
+ pinnedPropertyIds={() => ['instance-Custom']}
+ onPropertyPinned={vi.fn()}
+ onPropertyUnpinned={unpin}
+ />
+ ));
+
+ await fireEvent.click(
+ screen.getByRole('button', { name: 'Remove from entity' })
+ );
+ expect(
+ screen
+ .getByRole('button', { name: 'Unpin from title' })
+ .hasAttribute('disabled')
+ ).toBe(true);
+ expect(unpin).not.toHaveBeenCalled();
+ finishRemoval();
+ await vi.waitFor(() =>
+ expect(unpin).toHaveBeenCalledWith(
+ 'instance-Custom',
+ mocks.properties,
+ 'Custom'
+ )
+ );
+});
+
+it('shows implicit task defaults as pinned while preserving deletion guards and explicit empty pins', async () => {
+ mocks.properties = [
+ field('Status', 'Active'),
+ field('Priority', 'High'),
+ field('Custom', 'saved'),
+ ];
+ const defaults = ['Status', 'Priority'];
+ const defaultIds = ['instance-Status', 'instance-Priority'];
+ const [pins, setPins] = createSignal<string[] | undefined>();
+ const pin = vi.fn((id: string) => setPins([...(pins() ?? defaultIds), id]));
+ const unpin = vi.fn((id: string) =>
+ setPins((pins() ?? defaultIds).filter((current) => current !== id))
+ );
+ render(() => (
+ <EntityPropertiesSection
+ entityId="task"
+ entityType="TASK"
+ canEdit
+ showTags={false}
+ defaultPinnedPropertyIds={() => defaults}
+ defaultTitlePropertyDefinitionIds={() => defaults}
+ pinnedPropertyIds={pins}
+ onPropertyPinned={pin}
+ onPropertyUnpinned={unpin}
+ />
+ ));
+ expect(
+ screen.getAllByRole('button', { name: 'Unpin from title' })
+ ).toHaveLength(2);
+ expect(
+ screen.getAllByRole('button', { name: 'Remove from entity' })
+ ).toHaveLength(1);
+ await fireEvent.click(
+ screen.getAllByRole('button', { name: 'Unpin from title' })[0]
+ );
+ expect(unpin).toHaveBeenCalledWith(
+ 'instance-Status',
+ mocks.properties,
+ 'Status'
+ );
+ expect(pins()).toEqual(['instance-Priority']);
+ expect(
+ screen.getAllByRole('button', { name: 'Unpin from title' })
+ ).toHaveLength(1);
+ setPins([]);
+ expect(screen.queryByRole('button', { name: 'Unpin from title' })).toBeNull();
+ expect(
+ screen.getAllByRole('button', { name: 'Pin below title' })
+ ).toHaveLength(3);
+ expect(screen.getByText('"Active"')).toBeTruthy();
+ expect(screen.getByText('"High"')).toBeTruthy();
+ expect(mocks.remove).not.toHaveBeenCalled();
+});
+
+it('pins and unpins a virtual default without creating or deleting an assignment', async () => {
+ const placeholder = { ...field('Project'), propertyId: 'pending:Project' };
+ const [pins, setPins] = createSignal<string[] | undefined>();
+ const pin = vi.fn((id: string) => setPins([id]));
+ const unpin = vi.fn(() => setPins([]));
+ render(() => (
+ <EntityPropertiesSection
+ entityId="task"
+ entityType="TASK"
+ canEdit
+ showTags={false}
+ defaultProperties={() => [placeholder]}
+ defaultTitlePropertyDefinitionIds={() => ['Project']}
+ pinnedPropertyIds={pins}
+ onPropertyPinned={pin}
+ onPropertyUnpinned={unpin}
+ />
+ ));
+ expect(
+ screen.queryByRole('button', { name: 'Remove from entity' })
+ ).toBeNull();
+ await fireEvent.click(
+ screen.getByRole('button', { name: 'Unpin from title' })
+ );
+ expect(pins()).toEqual([]);
+ await fireEvent.click(
+ screen.getByRole('button', { name: 'Pin below title' })
+ );
+ expect(pins()).toEqual(['pending:Project']);
+ expect(pin).toHaveBeenCalledWith('pending:Project', [placeholder]);
+ expect(mocks.add).not.toHaveBeenCalled();
+ expect(mocks.remove).not.toHaveBeenCalled();
+ expect(mocks.save).not.toHaveBeenCalled();
+});
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 c225bab90b..63efd96fbb 100644
--- a/apps/web/src/features/property/side-panel/properties/EntityPropertiesSection.tsx
+++ b/apps/web/src/features/property/side-panel/properties/EntityPropertiesSection.tsx
@@ -7,6 +7,8 @@ import { openDocument } from '@core/component/LexicalMarkdown/component/core/Blo
import { itemToBlockName } from '@core/constant/allBlocks';
import { useSplitNavigationHandler } from '@core/util/useSplitNavigationHandler';
import Plus from '@phosphor/plus.svg';
+import PushPinIcon from '@phosphor/push-pin.svg';
+import PushPinSlashIcon from '@phosphor/push-pin-slash.svg';
import TrashIcon from '@phosphor/trash.svg';
import DeleteIcon from '@phosphor/x.svg';
import { Property as PropertyNS, useProperty } from '@property';
@@ -18,6 +20,7 @@ import {
type PropertySaveHandler,
usePropertiesContext,
} from '@property/context/PropertiesContext';
+import { resolvePinnedPropertyIds } from '@property/core/pinned-property-ids';
import { useAllProperties } from '@property/editor/hooks/useAllProperties';
import { useEntityProperties, usePropertyEntityDisplay } from '@property/hooks';
import { isTaggableEntityType, TagsRow } from '@property/tags';
@@ -60,9 +63,17 @@ export interface EntityPropertiesSectionProps {
defaultPinnedPropertyIds?: () => readonly string[];
/** Keep required fields attached without hiding other entity properties. */
requiredPropertyDefinitionIds?: readonly string[];
- pinnedPropertyIds?: () => string[];
+ pinnedPropertyIds?: () => string[] | undefined;
+ /** Implicit title pins for hosts whose saved pin list is still absent. */
+ defaultTitlePropertyDefinitionIds?: () => readonly string[];
pinnedPropertyDefinitionOrder?: readonly string[];
- onPropertyUnpinned?: (propertyId: string) => void;
+ /** Explicit title-row pin action; adding a property does not pin it. */
+ onPropertyPinned?: (propertyId: string, properties: Property[]) => void;
+ onPropertyUnpinned?: (
+ propertyId: string,
+ properties: Property[],
+ propertyDefinitionId?: string
+ ) => void;
/**
* Placeholder properties shown (and editable) even when the entity has no
* value row for them yet — e.g. builtin CRM company defaults. Fetched
@@ -201,6 +212,17 @@ export function EntityPropertiesSection(props: EntityPropertiesSectionProps) {
])
);
+ const titlePinnedIds = () =>
+ resolvePinnedPropertyIds(
+ mergedProperties(),
+ props.pinnedPropertyIds?.(),
+ props.defaultTitlePropertyDefinitionIds?.()
+ );
+ const pinProperty = (id: string) =>
+ props.onPropertyPinned?.(id, mergedProperties());
+ const unpinProperty = (id: string, definitionId?: string) =>
+ props.onPropertyUnpinned?.(id, mergedProperties(), definitionId);
+
const addEntityProperty = async (definitionId: string) => {
// The entity can carry a definition it never pinned (set at creation or
// through the API); attaching it again would clear the value.
@@ -305,8 +327,10 @@ export function EntityPropertiesSection(props: EntityPropertiesSectionProps) {
onPropertyAdded={handlePropertyAdded}
onPropertyAddFailed={handlePropertyAddFailed}
onPropertyDeleted={refetch}
- onPropertyUnpinned={props.onPropertyUnpinned}
- pinnedPropertyIds={props.pinnedPropertyIds}
+ onPropertyUnpinned={
+ props.onPropertyUnpinned ? unpinProperty : undefined
+ }
+ pinnedPropertyIds={titlePinnedIds}
addProperty={addEntityProperty}
removeProperty={removeEntityProperty}
saveHandler={saveHandler}
@@ -341,9 +365,25 @@ export function EntityPropertiesSection(props: EntityPropertiesSectionProps) {
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>
@@ -363,6 +403,9 @@ export function EntityPropertiesSection(props: EntityPropertiesSectionProps) {
)
}
onRemovePendingProperty={removePendingProperty}
+ onPropertyPinned={
+ props.onPropertyPinned ? pinProperty : undefined
+ }
/>
)}
</For>
@@ -463,9 +506,11 @@ function isNonUserMultiEntityProperty(property: Property): boolean {
function SidePanelPropertyRow(props: {
canRemoveFromEntity: boolean;
+ canPinPendingProperty?: boolean;
entityId: string;
getEmptyLabel?: (property: Property) => JSX.Element | undefined;
onRemovePendingProperty: (property: Property) => void;
+ onPropertyPinned?: (propertyId: string) => void;
property: Property;
}) {
const ctx = usePropertiesContext();
@@ -496,9 +541,9 @@ function SidePanelPropertyRow(props: {
'self-center': !isMultilineRow(),
})}
>
- <div class="group/property-row relative min-w-0 max-w-full overflow-hidden">
+ <div class="group/property-row flex min-w-0 max-w-full items-center gap-1 overflow-hidden">
<PropertyNS.Root
- class="min-w-0 max-w-full overflow-hidden"
+ class="min-w-0 max-w-full flex-1 overflow-hidden"
property={props.property}
canEdit={ctx.canEdit}
onSave={ctx.saveHandler.saveProperty}
@@ -527,10 +572,11 @@ function SidePanelPropertyRow(props: {
/>
</PropertyNS.Root>
<PropertyRowActions
- class="absolute right-0 top-1/2 z-1 -translate-y-1/2"
canRemoveFromEntity={props.canRemoveFromEntity}
+ canPinPendingProperty={props.canPinPendingProperty}
property={props.property}
onRemovePendingProperty={props.onRemovePendingProperty}
+ onPropertyPinned={props.onPropertyPinned}
/>
</div>
</div>
@@ -543,9 +589,10 @@ function isPendingProperty(property: Property): boolean {
}
function PropertyRowActions(props: {
- class?: string;
canRemoveFromEntity: boolean;
+ canPinPendingProperty?: boolean;
onRemovePendingProperty: (property: Property) => void;
+ onPropertyPinned?: (propertyId: string) => void;
property: Property;
}) {
const ctx = usePropertiesContext();
@@ -556,13 +603,37 @@ function PropertyRowActions(props: {
ctx.canEdit &&
!props.property.isMetadata &&
(isPendingProperty(props.property) || Boolean(ctx.removeProperty));
- const hasActions = () => canRemove();
+ 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 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;
@@ -578,7 +649,10 @@ function PropertyRowActions(props: {
setIsSaving(true);
try {
await remove(props.property.propertyId);
- ctx.onPropertyUnpinned?.(props.property.propertyId);
+ ctx.onPropertyUnpinned?.(
+ props.property.propertyId,
+ props.property.propertyDefinitionId
+ );
ctx.onRefresh();
} finally {
setIsSaving(false);
@@ -590,19 +664,37 @@ function PropertyRowActions(props: {
<div
class={cn(
'flex shrink-0 items-center gap-0.5',
- 'pointer-events-none opacity-0 transition-opacity',
- 'group-hover/property-row:opacity-100 group-focus-within/property-row:opacity-100 focus-within:opacity-100',
- props.class
+ 'transition-opacity',
+ canPin() && isPinned()
+ ? 'pointer-events-auto opacity-100'
+ : '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'
)}
onMouseDown={stopRowInteraction}
>
+ <Show when={canPin()}>
+ <button
+ type="button"
+ title={pinLabel()}
+ aria-label={pinLabel()}
+ aria-pressed={isPinned()}
+ disabled={isSaving()}
+ class="flex size-5 items-center justify-center rounded-full text-ink-muted hover:bg-hover hover:text-ink focus-visible:outline-2 focus-visible:outline-accent disabled:pointer-events-none disabled:opacity-50"
+ onClick={togglePin}
+ >
+ <Show when={isPinned()} fallback={<PushPinIcon class="size-3" />}>
+ <PushPinSlashIcon class="size-3" />
+ </Show>
+ </button>
+ </Show>
<Show when={canRemove()}>
<button
type="button"
title="Remove from entity"
aria-label="Remove from entity"
disabled={isSaving()}
- class="pointer-events-auto flex size-5 items-center justify-center rounded-full text-ink-muted outline-none ring-0 shadow-none hover:bg-hover hover:text-failure-ink focus:outline-none focus-visible:outline-none focus-visible:ring-0 disabled:pointer-events-none disabled:opacity-50"
+ class="flex size-5 items-center justify-center rounded-full text-ink-muted outline-none ring-0 shadow-none hover:bg-hover hover:text-failure-ink focus:outline-none focus-visible:outline-none focus-visible:ring-0 disabled:pointer-events-none disabled:opacity-50"
onClick={removeFromEntity}
>
<TrashIcon class="size-3" />
@@ -804,6 +896,7 @@ function EntityCollectionProperty(props: {
canRemoveFromEntity: boolean;
entityId: string;
onRemovePendingProperty: (property: Property) => void;
+ onPropertyPinned?: (propertyId: string) => void;
property: Property;
}) {
const ctx = usePropertiesContext();
@@ -819,6 +912,7 @@ function EntityCollectionProperty(props: {
canRemoveFromEntity={props.canRemoveFromEntity}
property={props.property}
onRemovePendingProperty={props.onRemovePendingProperty}
+ onPropertyPinned={props.onPropertyPinned}
/>
<PropertyNS.PopoverEditor
entitySelfFilter={{
@@ -833,6 +927,7 @@ function EntityCollectionProperty(props: {
function EntityCollectionPropertyBody(props: {
canRemoveFromEntity: boolean;
onRemovePendingProperty: (property: Property) => void;
+ onPropertyPinned?: (propertyId: string) => void;
property: Property;
}) {
const ctx = usePropertiesContext();
@@ -881,6 +976,7 @@ function EntityCollectionPropertyBody(props: {
canRemoveFromEntity={props.canRemoveFromEntity}
property={props.property}
onRemovePendingProperty={props.onRemovePendingProperty}
+ onPropertyPinned={props.onPropertyPinned}
/>
</div>
</div>
diff --git a/apps/web/src/lib/core/component/LexicalMarkdown/plugins/pinned-properties/pinnedPropertiesPlugin.ts b/apps/web/src/lib/core/component/LexicalMarkdown/plugins/pinned-properties/pinnedPropertiesPlugin.ts
index a3b34d9f1e..468ca03f46 100644
--- a/apps/web/src/lib/core/component/LexicalMarkdown/plugins/pinned-properties/pinnedPropertiesPlugin.ts
+++ b/apps/web/src/lib/core/component/LexicalMarkdown/plugins/pinned-properties/pinnedPropertiesPlugin.ts
@@ -35,6 +35,13 @@ export function $getPinnedProperties(): string[] {
return $getState(root, pinnedPropertyIdsState);
}
+/** Distinguish untouched default pins from an explicitly saved empty pin list. */
+export function $getStoredPinnedProperties(): string[] | undefined {
+ return Object.hasOwn($getRoot().exportJSON().$ ?? {}, 'pinnedPropertyIds')
+ ? $getPinnedProperties()
+ : undefined;
+}
+
/**
* Set property IDs on the root node
* Must be called within an editor.update() callback
diff --git a/docs/agent-guide/documents.md b/docs/agent-guide/documents.md
index 90e519298b..cfab6c534b 100644
--- a/docs/agent-guide/documents.md
+++ b/docs/agent-guide/documents.md
@@ -87,9 +87,22 @@ property selector for that document.
Adding or reselecting a property from the title row pins it there. Adding from
the side panel leaves it unpinned. The side panel shows all assigned properties,
including unpinned ones.
+In document, task, snippet, and skill side panels, hover or focus a property row
+to find
+**Pin below title** beside **Remove from entity**. These controls stay visible
+on touch devices. A pinned row shows **Unpin from title**; unpinning keeps both
+the saved value and the side-panel row.
+Pinning is unavailable for read-only documents, metadata, and properties still
+being assigned, except the task's default Project placeholder. Long values truncate
+or wrap within the value column without
+covering the pin or remove controls.
+Escape cancels an inline text or number draft without saving it.
Hover or focus an inline property pill to find **Unpin** (keeps its saved
-value) and **Delete from item** (removes the document's assignment, without
-deleting the shared property definition). Pins are saved with the document.
+value) and **Delete from item** where removal is allowed (removes the assignment,
+without deleting the shared property definition). Task builtins cannot be deleted
+from these pills. Pins are saved with the document, including an explicitly empty
+pin list. Tasks initially show Status, Priority, Assignees, and Project when enabled;
+changing pins keeps the other defaults unless they are explicitly unpinned.
Markdown code blocks have a **Copy Code** button in both editable and read-only
views. Successful copies briefly animate the icon to a solid green check-circle;
diff --git a/docs/agent-guide/tasks.md b/docs/agent-guide/tasks.md
index 21f49bbaf8..a1f29aa8b1 100644
--- a/docs/agent-guide/tasks.md
+++ b/docs/agent-guide/tasks.md
@@ -100,6 +100,15 @@ the originating tab breadcrumb, a task tab, or a tag to return to the list.
Shift-click a row or favorite to open it in a new split
instead. Keyboard list navigation only moves focus; press Enter to open the focused task.
+In the task's Properties side panel, hover or focus a row for **Pin below title**
+or **Unpin from title**. Pinning adds the property to the title row; unpinning keeps
+its saved value and the side-panel row. The title pill's hover menu also offers
+**Unpin**. Status, Priority, and Assignees are pinned by default, with Project when
+enabled. Unpinning a default preserves the other pins, and clearing all pins stays
+cleared after reopening. The empty Project placeholder can also be pinned or
+unpinned without creating an assignment; its pin follows the real assignment when
+one is saved. Builtin task properties cannot be deleted from the title or side panel.
+
Property edits should update the visible task before the save finishes. To verify,
delay the GraphQL mutation and change Status, an existing Priority, and an unset
Priority in the list and task detail. In a view grouped by that property, the task