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.

refactor(projects): edit a task's Project with the standard property UI (#7450)

teo9aedd35b2ed1
diff --git a/apps/web/src/features/block-md/component/ComposeTask.tsx b/apps/web/src/features/block-md/component/ComposeTask.tsx
index 8847095e76..27c007f22a 100644
--- a/apps/web/src/features/block-md/component/ComposeTask.tsx
+++ b/apps/web/src/features/block-md/component/ComposeTask.tsx
@@ -35,6 +35,7 @@ import PaperclipIcon from '@phosphor/paperclip.svg';
import SplitIcon from '@phosphor/square-half.svg';
import XIcon from '@phosphor/x.svg';
import { Modals } from '@property/component/modal';
+import { SYSTEM_PROPERTY_IDS } from '@property/constants';
import { PropertiesProvider } from '@property/context/PropertiesContext';
import { InlineTagsPill } from '@property/tags';
import type { PropertyApiValues } from '@property/types';
@@ -72,6 +73,7 @@ import {
createTaskComposerProperties,
createTaskWithProperties,
defaultTaskPropertyValues,
+ taskComposerProjectValue,
} from '../util/taskComposerProperties';
import {
clearTaskComposerDraft,
@@ -342,6 +344,8 @@ export interface ComposeTaskProps {
initialContent?: string;
placeholder?: string;
initialAssigneeIds?: string[];
+ /** Start in this project, e.g. when composing from the project's page. */
+ initialProjectId?: string;
/**
* When provided, replaces the default success behavior (auto-copy link +
* toast) so the caller can handle the created task however it needs.
@@ -376,6 +380,19 @@ export function ComposeTask(props: ComposeTaskProps) {
return defaultTaskPropertyValues(ids);
};
+ // A project the composer opens in applies on top of a restored draft too.
+ const withInitialProject = (
+ values: Record<string, PropertyApiValues>
+ ): Record<string, PropertyApiValues> =>
+ props.initialProjectId
+ ? {
+ ...values,
+ [SYSTEM_PROPERTY_IDS.PROJECT]: taskComposerProjectValue(
+ props.initialProjectId
+ ),
+ }
+ : values;
+
// draft init logic
const initializeFromDraft = () => {
if (
@@ -389,7 +406,7 @@ export function ComposeTask(props: ComposeTaskProps) {
title: draft.title,
content: draft.content,
editorState: draft.editorState,
- propertyValues: draft.propertyValues,
+ propertyValues: withInitialProject(draft.propertyValues),
isDraftLoaded: true,
};
}
@@ -398,7 +415,7 @@ export function ComposeTask(props: ComposeTaskProps) {
title: props.initialTitle ?? '',
content: props.initialContent ?? '',
editorState: undefined,
- propertyValues: getDefaultPropertyValues(),
+ propertyValues: withInitialProject(getDefaultPropertyValues()),
isDraftLoaded: false,
};
};
@@ -764,7 +781,9 @@ export function ComposeTask(props: ComposeTaskProps) {
clearTaskComposerDraft();
setTitle('');
setContent('');
- setPropertyValues(reconcile(getDefaultPropertyValues()));
+ setPropertyValues(
+ reconcile(withInitialProject(getDefaultPropertyValues()))
+ );
setTagLayoutMode('bottom');
setIsDraftLoaded(false);
const ed = bodyEditor();
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 f7658dd875..b407d09996 100644
--- a/apps/web/src/features/block-md/component/InlineTaskProperties.test.tsx
+++ b/apps/web/src/features/block-md/component/InlineTaskProperties.test.tsx
@@ -27,9 +27,24 @@ const mocks = vi.hoisted(() => ({
properties: () => [] as Property[],
add: vi.fn(),
open: vi.fn<typeof openPropertyEditor>(),
+ kind: 'document' as 'document' | 'task',
+ projectsEnabled: false,
}));
-vi.mock('@app/features/projects/task-project-property', () => ({
- TaskProjectProperty: () => null,
+vi.mock('@app/lib/analytics/posthog', () => ({
+ useFeatureFlag: () => () => ({ enabled: mocks.projectsEnabled }),
+}));
+vi.mock('@entity/extractors-property', () => ({
+ buildTaskProjectDefaultProperty: () => ({
+ propertyId: 'pending:project',
+ propertyDefinitionId: '00000001-0000-0000-0000-000000000014',
+ displayName: 'Project',
+ valueType: 'ENTITY',
+ value: null,
+ isMultiSelect: false,
+ owner: { scope: 'system' },
+ createdAt: '1970-01-01',
+ updatedAt: '1970-01-01',
+ }),
}));
vi.mock('@property/editor/state/propertyEditor', () => ({
openPropertyEditor: mocks.open,
@@ -59,7 +74,7 @@ vi.mock('./MarkdownNameProvider', () => ({
vi.mock('../context/markdown-document-context', () => ({
useMarkdownDocument: () => ({
documentId: () => 'doc',
- kind: () => 'document',
+ kind: () => mocks.kind,
permissions: { canEdit: () => true },
state: { editor: { md: { editor: mocks.editor } } },
}),
@@ -79,6 +94,8 @@ vi.mock('./InlinePropertyValue', () => ({
afterEach(() => {
cleanup();
vi.clearAllMocks();
+ mocks.kind = 'document';
+ mocks.projectsEnabled = false;
});
const property: Property = {
@@ -149,3 +166,18 @@ it('repins an existing property without assigning it a second time', async () =>
);
expect(mocks.add).not.toHaveBeenCalled();
});
+
+it("shows a task's Project with the other task properties, through the same pill", async () => {
+ mocks.kind = 'task';
+ mocks.projectsEnabled = true;
+ setup();
+ // A task without a project still gets the standard pill, from a placeholder.
+ await waitFor(() =>
+ expect(screen.getByRole('button', { name: 'Unpin Project' })).toBeTruthy()
+ );
+
+ cleanup();
+ mocks.projectsEnabled = false;
+ setup();
+ expect(screen.queryByRole('button', { name: 'Unpin Project' })).toBeNull();
+});
diff --git a/apps/web/src/features/block-md/component/InlineTaskProperties.tsx b/apps/web/src/features/block-md/component/InlineTaskProperties.tsx
index 60d3823194..c8bd3692c7 100644
--- a/apps/web/src/features/block-md/component/InlineTaskProperties.tsx
+++ b/apps/web/src/features/block-md/component/InlineTaskProperties.tsx
@@ -1,5 +1,7 @@
-import { TaskProjectProperty } from '@app/features/projects/task-project-property';
+import { useFeatureFlag } from '@app/lib/analytics/posthog';
import { ProgressChip } from '@core/component/LexicalMarkdown/component/status/Progress';
+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';
@@ -39,6 +41,7 @@ export function InlineTaskProperties() {
const { properties, refetch, addProperty, removeProperty } =
useEntityProperties(blockId, entityType, false);
const pins = createPinnedProperties(() => state.editor.md.editor);
+ const projects = useFeatureFlag(enableProjects);
const tagSets = useTagsQuery();
const tagDefinitionIds = () =>
new Set(
@@ -84,9 +87,18 @@ export function InlineTaskProperties() {
SYSTEM_PROPERTY_IDS.PRIORITY,
SYSTEM_PROPERTY_IDS.ASSIGNEES,
];
- return ids
+ 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 shouldShowRow = createMemo(
() =>
@@ -147,9 +159,6 @@ export function InlineTaskProperties() {
<Show when={documentKind === 'document' && canEdit()}>
<AddPropertyButton class="gap-1.5 bg-surface-2" />
</Show>
- <Show when={documentKind === 'task'}>
- <TaskProjectProperty taskId={blockId} canEdit={canEdit()} />
- </Show>
<Show when={documentKind === 'task' && state.editor.md.progressStats}>
{(progressStats) => (
<Show when={progressStats().total > 0}>
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 9c1de2dc5b..f87d7792b9 100644
--- a/apps/web/src/features/block-md/component/sidepanel/MarkdownSidePanelSections.tsx
+++ b/apps/web/src/features/block-md/component/sidepanel/MarkdownSidePanelSections.tsx
@@ -1,11 +1,10 @@
import { EntityActivitySectionConditional } from '@app/features/activity/views/entity-activity-section';
import { AskMacroButton } from '@app/features/chat/ChatWithAgentButton';
-import { TaskProjectProperty } from '@app/features/projects/task-project-property';
import {
EntityPropertiesSection,
EntityTagsSection,
} from '@app/features/property/side-panel/properties';
-import { ShowFeatureFlag } from '@app/lib/analytics/posthog';
+import { useFeatureFlag } from '@app/lib/analytics/posthog';
import { useGlobalNotificationSource } from '@components/app/GlobalAppState';
import {
GithubPullRequestDetailsRows,
@@ -27,6 +26,7 @@ import type { Entity } from '@core/types';
import type { DateValue } from '@core/util/date';
import { openExternalUrl } from '@core/util/url';
import { useSplitNavigationHandler } from '@core/util/useSplitNavigationHandler';
+import { buildTaskProjectDefaultProperty } from '@entity/extractors-property';
import { useNotificationsForEntity } from '@notifications';
import {
getDefaultPinnedProperties,
@@ -98,18 +98,6 @@ export function MarkdownSidePanelSections() {
defaultOpen
order={25}
>
- <Show when={isTask()}>
- <ShowFeatureFlag flag={enableProjects}>
- <SidePanel.Grid>
- <SidePanel.Row label="Project">
- <TaskProjectProperty
- taskId={documentId()}
- canEdit={canEdit()}
- />
- </SidePanel.Row>
- </SidePanel.Grid>
- </ShowFeatureFlag>
- </Show>
<PropertiesSectionContent
documentId={documentId()}
isTask={isTask()}
@@ -214,6 +202,7 @@ function PropertiesSectionContent(props: {
const entityType: PropertiesEntityType = props.isTask ? 'TASK' : 'DOCUMENT';
const pins = createPinnedProperties(() => mdData.editor);
+ const projects = useFeatureFlag(enableProjects);
return (
<EntityPropertiesSection
@@ -228,6 +217,12 @@ function PropertiesSectionContent(props: {
pinnedPropertyDefinitionOrder={PINNED_ORDER}
onPropertyUnpinned={pins.unpin}
showTags={false}
+ // A task joins a project through its Project property, edited like the others.
+ defaultProperties={() =>
+ props.isTask && projects().enabled
+ ? [buildTaskProjectDefaultProperty()]
+ : []
+ }
/>
);
}
@@ -239,6 +234,7 @@ const PINNED_ORDER: readonly string[] = [
SYSTEM_PROPERTY_IDS.STATUS,
SYSTEM_PROPERTY_IDS.PRIORITY,
SYSTEM_PROPERTY_IDS.ASSIGNEES,
+ SYSTEM_PROPERTY_IDS.PROJECT,
];
// ─────────────────────────────────────────────────────────────────────────────
diff --git a/apps/web/src/features/block-md/util/taskComposerProperties.test.ts b/apps/web/src/features/block-md/util/taskComposerProperties.test.ts
new file mode 100644
index 0000000000..b97b13fdca
--- /dev/null
+++ b/apps/web/src/features/block-md/util/taskComposerProperties.test.ts
@@ -0,0 +1,97 @@
+import { SYSTEM_PROPERTY_IDS } from '@property/constants';
+import { afterEach, expect, it, vi } from 'vitest';
+
+const mock = vi.hoisted(() => ({
+ create: vi.fn(),
+ properties: vi.fn(),
+ failure: vi.fn(),
+}));
+vi.mock('@core/util/create', () => ({
+ createTaskWithInitialSnapshot: mock.create,
+}));
+vi.mock('@queries/properties/entity', () => ({
+ fetchEntityProperties: mock.properties,
+}));
+vi.mock('@core/component/Toast/Toast', () => ({
+ toast: { failure: mock.failure },
+}));
+vi.mock('@app/lib/analytics/posthog', () => ({
+ useFeatureFlag: () => () => ({ enabled: true }),
+}));
+vi.mock('@property/tags', () => ({ useLocalDocTags: vi.fn() }));
+vi.mock('@queries/properties/definitions', () => ({}));
+vi.mock('@queries/properties/tags', () => ({}));
+
+import {
+ createTaskWithProperties,
+ taskComposerProjectValue,
+} from './taskComposerProperties';
+
+afterEach(() => vi.clearAllMocks());
+
+/** The created task's properties as the server reports them. */
+function serverProject(projectId: string | undefined) {
+ mock.properties.mockResolvedValue(
+ projectId
+ ? [
+ {
+ propertyId: 'row',
+ propertyDefinitionId: SYSTEM_PROPERTY_IDS.PROJECT,
+ displayName: 'Project',
+ valueType: 'ENTITY',
+ value: [{ entity_id: projectId, entity_type: 'INITIATIVE' }],
+ isMultiSelect: false,
+ owner: { scope: 'system' },
+ createdAt: '1970-01-01',
+ updatedAt: '1970-01-01',
+ },
+ ]
+ : []
+ );
+}
+
+const create = (projectId?: string) =>
+ createTaskWithProperties(
+ 'Ship it',
+ '',
+ projectId
+ ? [[SYSTEM_PROPERTY_IDS.PROJECT, taskComposerProjectValue(projectId)]]
+ : [],
+ new Map(),
+ vi.fn()
+ );
+
+it('creates the task with its Project in the one create call', async () => {
+ mock.create.mockResolvedValue({ documentId: 'task' });
+ serverProject('project');
+ expect(await create('project')).toEqual({ documentId: 'task' });
+ expect(mock.create).toHaveBeenCalledWith(
+ expect.objectContaining({
+ propertyValues: [
+ {
+ propertyId: SYSTEM_PROPERTY_IDS.PROJECT,
+ value: {
+ type: 'entity_reference',
+ reference: { entity_id: 'project', entity_type: 'INITIATIVE' },
+ },
+ },
+ ],
+ })
+ );
+ expect(mock.failure).not.toHaveBeenCalled();
+});
+
+it('says so when the created task did not join its project', async () => {
+ mock.create.mockResolvedValue({ documentId: 'task' });
+ serverProject(undefined);
+ expect(await create('project')).toEqual({ documentId: 'task' });
+ expect(mock.failure).toHaveBeenCalledWith(
+ expect.stringContaining('could not be added to the project')
+ );
+});
+
+it('skips the check without a project', async () => {
+ mock.create.mockResolvedValue({ documentId: 'task' });
+ await create();
+ expect(mock.properties).not.toHaveBeenCalled();
+});
diff --git a/apps/web/src/features/block-md/util/taskComposerProperties.ts b/apps/web/src/features/block-md/util/taskComposerProperties.ts
index 3ad19a33cb..47cb529aa2 100644
--- a/apps/web/src/features/block-md/util/taskComposerProperties.ts
+++ b/apps/web/src/features/block-md/util/taskComposerProperties.ts
@@ -1,4 +1,6 @@
+import { useFeatureFlag } from '@app/lib/analytics/posthog';
import { toast } from '@core/component/Toast/Toast';
+import { enableProjects } from '@core/constant/featureFlags';
import { createTaskWithInitialSnapshot } from '@core/util/create';
import { filterMap } from '@core/util/list';
import {
@@ -14,20 +16,33 @@ import type {
PropertyOption,
} from '@property/types';
import { useListPropertiesQuery } from '@queries/properties/definitions';
+import { fetchEntityProperties } from '@queries/properties/entity';
import { useTagsQuery } from '@queries/properties/tags';
import type { PropertyDefinition } from '@service-properties/generated/schemas/propertyDefinition';
import type { PropertyDefinitionDetailResponse } from '@service-properties/generated/schemas/propertyDefinitionDetailResponse';
import { createStore, reconcile, type Store, unwrap } from 'solid-js/store';
-/** Props shown in the composer (Linear-style left-to-right order). */
+/**
+ * Props shown in the composer (Linear-style left-to-right order). Project
+ * shows only while Projects is enabled.
+ */
const COMPOSER_PROPERTIES = [
SYSTEM_PROPERTY_IDS.STATUS,
SYSTEM_PROPERTY_IDS.PRIORITY,
SYSTEM_PROPERTY_IDS.ASSIGNEES,
SYSTEM_PROPERTY_IDS.DUE_DATE,
+ SYSTEM_PROPERTY_IDS.PROJECT,
];
const COMPOSER_PROPERTY_SET = new Set<string>(COMPOSER_PROPERTIES);
+/** The Project value naming `projectId`. */
+export function taskComposerProjectValue(projectId: string): PropertyApiValues {
+ return {
+ valueType: 'ENTITY',
+ refs: [{ entity_id: projectId, entity_type: 'INITIATIVE' }],
+ };
+}
+
/** The default property values a fresh task composer starts from. */
export function defaultTaskPropertyValues(
assigneeIds: string[]
@@ -104,9 +119,59 @@ export async function createTaskWithProperties(
itemType: 'document',
});
+ // Creation keeps the task when a property is rejected, so confirm a chosen
+ // project took and say when it didn't.
+ const projectId = chosenProjectId(properties);
+ if (
+ projectId &&
+ (await taskIsInProject(createdTask.documentId, projectId)) === false
+ ) {
+ toast.failure(
+ 'Task created, but could not be added to the project. Use Add to project from the task menu to try again.'
+ );
+ }
+
return createdTask;
}
+/** The project the composer's Project value names, if any. */
+function chosenProjectId(
+ properties: Array<[string, PropertyApiValues]>
+): string | undefined {
+ const project = properties.find(
+ ([id]) => id === SYSTEM_PROPERTY_IDS.PROJECT
+ )?.[1];
+ if (project?.valueType !== 'ENTITY') return undefined;
+ return project.refs?.find(
+ (reference) => reference.entity_type === 'INITIATIVE'
+ )?.entity_id;
+}
+
+/**
+ * Whether the server has `taskId` in `projectId`, from its Project property;
+ * undefined when the properties can't be read.
+ */
+async function taskIsInProject(
+ taskId: string,
+ projectId: string
+): Promise<boolean | undefined> {
+ const properties = await fetchEntityProperties('TASK', taskId).catch(
+ () => undefined
+ );
+ if (!properties) return undefined;
+ const project = properties.find(
+ (property) => property.propertyDefinitionId === SYSTEM_PROPERTY_IDS.PROJECT
+ );
+ if (project?.valueType !== 'ENTITY') return false;
+ return (
+ project.value?.some(
+ (reference) =>
+ reference.entity_type === 'INITIATIVE' &&
+ reference.entity_id === projectId
+ ) ?? false
+ );
+}
+
/**
* Helper to get display value of local property
* @param definition The prop definition
@@ -195,8 +260,11 @@ export function createTaskComposerProperties(args: {
);
};
+ const projects = useFeatureFlag(enableProjects);
+
const properties = (): Property[] => {
return filterMap(COMPOSER_PROPERTIES, (id) => {
+ if (id === SYSTEM_PROPERTY_IDS.PROJECT && !projects().enabled) return;
const definition = definitions().get(id);
if (!definition) return;
return {
diff --git a/apps/web/src/features/entity/composed/list-entity/narrow-layout.tsx b/apps/web/src/features/entity/composed/list-entity/narrow-layout.tsx
index 48be7044fc..0008e7a7de 100644
--- a/apps/web/src/features/entity/composed/list-entity/narrow-layout.tsx
+++ b/apps/web/src/features/entity/composed/list-entity/narrow-layout.tsx
@@ -116,6 +116,7 @@ export function NarrowLayout(props: LayoutProps) {
entity={props.entity}
maxUserStackUsers={0}
showCaret={false}
+ includeProject={props.showProject}
/>
}
>
diff --git a/apps/web/src/features/entity/composed/list-entity/shared.tsx b/apps/web/src/features/entity/composed/list-entity/shared.tsx
index 1c6a601960..806a444086 100644
--- a/apps/web/src/features/entity/composed/list-entity/shared.tsx
+++ b/apps/web/src/features/entity/composed/list-entity/shared.tsx
@@ -85,6 +85,8 @@ export interface LayoutProps {
entity: ProjectEntity,
e: PointerEvent | MouseEvent
) => void;
+ /** Show a task's Project with its other properties (Projects enabled). */
+ showProject?: boolean;
}
export type NarrowLayoutVariant = 'standard' | 'condensed' | 'single-line';
diff --git a/apps/web/src/features/entity/extractors-property/entity-key-properties.tsx b/apps/web/src/features/entity/extractors-property/entity-key-properties.tsx
index 27cf075e19..90bbe9191b 100644
--- a/apps/web/src/features/entity/extractors-property/entity-key-properties.tsx
+++ b/apps/web/src/features/entity/extractors-property/entity-key-properties.tsx
@@ -30,6 +30,7 @@ import {
import {
getSortedKeyProperties,
soupPropertyToProperty,
+ withTaskProject,
} from './property-helpers';
function getEntityType(entity: EntityData): EntityType {
@@ -81,6 +82,8 @@ interface EntityKeyPropertiesProps {
maxUserStackUsers?: number;
/** Whether to show the edit affordance caret. */
showCaret?: boolean;
+ /** Append a task's Project, set or not (Projects enabled). */
+ includeProject?: boolean;
}
/**
@@ -94,16 +97,18 @@ export function EntityKeyProperties(props: EntityKeyPropertiesProps) {
const keyProperties = createMemo((): PropertyT[] => {
const soupProperties = props.entity.properties ?? [];
- return getSortedKeyProperties(
- soupProperties.flatMap((soupProperty) => {
- try {
- return [soupPropertyToProperty(soupProperty)];
- } catch (error) {
- console.warn('Skipping property with unsupported type', error);
- return [];
- }
- })
- );
+ const properties = soupProperties.flatMap((soupProperty) => {
+ try {
+ return [soupPropertyToProperty(soupProperty)];
+ } catch (error) {
+ console.warn('Skipping property with unsupported type', error);
+ return [];
+ }
+ });
+ const key = getSortedKeyProperties(properties);
+ return props.includeProject && entityType() === EntityType.TASK
+ ? withTaskProject(key, properties)
+ : key;
});
const saveMutation = useBulkSaveEntityPropertiesMutation();
diff --git a/apps/web/src/features/entity/extractors-property/index.ts b/apps/web/src/features/entity/extractors-property/index.ts
index 2e143e46e5..be7af12356 100644
--- a/apps/web/src/features/entity/extractors-property/index.ts
+++ b/apps/web/src/features/entity/extractors-property/index.ts
@@ -2,5 +2,6 @@ export { EntityKeyProperties } from './entity-key-properties';
export {
buildCompanyDefaultProperties,
+ buildTaskProjectDefaultProperty,
soupPropertyToProperty,
} from './property-helpers';
diff --git a/apps/web/src/features/entity/extractors-property/property-helpers.test.ts b/apps/web/src/features/entity/extractors-property/property-helpers.test.ts
index 30fba63c12..3ccb10fbce 100644
--- a/apps/web/src/features/entity/extractors-property/property-helpers.test.ts
+++ b/apps/web/src/features/entity/extractors-property/property-helpers.test.ts
@@ -1,9 +1,14 @@
// @vitest-environment jsdom
import { PROPERTY_OPTION_IDS, SYSTEM_PROPERTY_IDS } from '@property/constants';
+import type { Property } from '@property/types';
import { formatPropertyValue } from '@property/utils/formatting';
import type { SoupProperty } from '@service-storage/generated/schemas/soupProperty';
import { describe, expect, it } from 'vitest';
-import { soupPropertyToProperty } from './property-helpers';
+import {
+ buildTaskProjectDefaultProperty,
+ soupPropertyToProperty,
+ withTaskProject,
+} from './property-helpers';
const EPOCH_ZERO = new Date(0).toISOString();
@@ -38,3 +43,46 @@ describe('soupPropertyToProperty stage labels', () => {
expect(formatPropertyValue(property, optionId)).toBe(label);
});
});
+
+describe('withTaskProject', () => {
+ const status = {
+ propertyId: 'status-row',
+ propertyDefinitionId: SYSTEM_PROPERTY_IDS.STATUS,
+ displayName: 'Status',
+ valueType: 'SELECT_STRING',
+ value: null,
+ isMultiSelect: false,
+ owner: { scope: 'system' },
+ createdAt: '1970-01-01',
+ updatedAt: '1970-01-01',
+ } as Property;
+ const project = {
+ propertyId: 'project-row',
+ propertyDefinitionId: SYSTEM_PROPERTY_IDS.PROJECT,
+ displayName: 'Project',
+ valueType: 'ENTITY',
+ value: [{ entity_id: 'launch', entity_type: 'INITIATIVE' }],
+ isMultiSelect: false,
+ owner: { scope: 'system' },
+ createdAt: '1970-01-01',
+ updatedAt: '1970-01-01',
+ } as Property;
+
+ it("appends the task's Project after its key properties", () => {
+ expect(withTaskProject([status], [status, project])).toEqual([
+ status,
+ project,
+ ]);
+ });
+
+ it('appends the standard Project placeholder when the task has none', () => {
+ const [, placeholder] = withTaskProject([status], [status]);
+ expect(placeholder).toMatchObject({
+ propertyDefinitionId: SYSTEM_PROPERTY_IDS.PROJECT,
+ displayName: 'Project',
+ valueType: 'ENTITY',
+ specificEntityType: 'INITIATIVE',
+ });
+ expect(placeholder).toEqual(buildTaskProjectDefaultProperty());
+ });
+});
diff --git a/apps/web/src/features/entity/extractors-property/property-helpers.ts b/apps/web/src/features/entity/extractors-property/property-helpers.ts
index 54f2b1b985..6750425055 100644
--- a/apps/web/src/features/entity/extractors-property/property-helpers.ts
+++ b/apps/web/src/features/entity/extractors-property/property-helpers.ts
@@ -336,6 +336,46 @@ export function buildCompanyDefaultProperties(): Property[] {
);
}
+/**
+ * Placeholder for a task's Project property, which a task only carries once it
+ * joins a project. Lets the standard property row and editor show and set it;
+ * setting a value upserts the real row.
+ */
+export function buildTaskProjectDefaultProperty(): Property {
+ return soupPropertyToProperty({
+ id: `pending:${SYSTEM_PROPERTY_IDS.PROJECT}`,
+ definition: {
+ id: SYSTEM_PROPERTY_IDS.PROJECT,
+ display_name: 'Project',
+ data_type: 'ENTITY',
+ is_metadata: false,
+ is_multi_select: false,
+ is_system: true,
+ owner: { scope: 'system' },
+ specific_entity_type: 'INITIATIVE',
+ created_at: EPOCH_ZERO.toISOString(),
+ updated_at: EPOCH_ZERO.toISOString(),
+ },
+ });
+}
+
+/**
+ * A task's key properties followed by its Project, or the Project placeholder
+ * when the task isn't in a project.
+ */
+export function withTaskProject(
+ keyProperties: Property[],
+ properties: Property[]
+): Property[] {
+ return [
+ ...keyProperties,
+ properties.find(
+ (property) =>
+ property.propertyDefinitionId === SYSTEM_PROPERTY_IDS.PROJECT
+ ) ?? buildTaskProjectDefaultProperty(),
+ ];
+}
+
/**
* Sort properties by the defined sort order (status, priority, assignees first)
*/
diff --git a/apps/web/src/features/projects/project-detail.tsx b/apps/web/src/features/projects/project-detail.tsx
index fa1a9a25e8..78ef64e2d6 100644
--- a/apps/web/src/features/projects/project-detail.tsx
+++ b/apps/web/src/features/projects/project-detail.tsx
@@ -121,6 +121,7 @@ function ProjectDetailHost(props: ProjectDetailProps) {
createTask: (
...args: Parameters<NonNullable<ComposeTaskProps['createTask']>>
) => commands.createTask(projectId, ...args),
+ initialProjectId: projectId,
onSuccess: () => section('tasks'),
},
});
diff --git a/apps/web/src/features/projects/project-property.tsx b/apps/web/src/features/projects/project-property.tsx
index 2bb8aeb2b7..ea9a27ea99 100644
--- a/apps/web/src/features/projects/project-property.tsx
+++ b/apps/web/src/features/projects/project-property.tsx
@@ -1,12 +1,7 @@
-import { useUserId } from '@core/context/user';
-import CaretDownIcon from '@phosphor/caret-down.svg';
-import CircleDashedEmpty from '@phosphor/circle-dashed.svg';
-import StackIcon from '@phosphor/stack.svg';
import { Property } from '@property';
-import { Dropdown, HoverCard, Layer } from '@ui';
-import { createSignal, Show } from 'solid-js';
+import { Dropdown } from '@ui';
+import { Show } from 'solid-js';
import { Projects } from './projects';
-import { useTaskProjectReference } from './queries/project-identity';
import { ProjectPicker } from './views/project-picker';
type AnchorRect = { x: number; y: number; width?: number; height?: number };
@@ -49,86 +44,3 @@ export function ProjectPickerPopover(props: {
</Dropdown>
);
}
-
-/** Task list cell for a task's Project property, matching the other property cells. */
-export function ProjectPropertyCell(props: {
- taskId: string;
- projectId?: string;
-}) {
- const [anchor, setAnchor] = createSignal<HTMLElement>();
- const reference = useTaskProjectReference(() => props.projectId, useUserId());
- const project = () => {
- const current = reference();
- return current?.state === 'visible' ? current : undefined;
- };
- const emptyLabel = () =>
- reference()?.state === 'unavailable' ? 'Unavailable project' : 'Project';
- return (
- <>
- <HoverCard
- content={
- <div class="flex flex-row gap-2 items-center">
- <div class="flex items-center gap-2 text-ink-muted">
- <StackIcon class="size-3.5 text-ink-muted" />
- <span class="text-xs">Project</span>
- </div>
- <div class="inline-flex min-w-0 items-center gap-1.5 px-2 py-0.5 text-xs leading-5 text-ink-muted w-fit rounded-sm">
- <span class="truncate max-w-37.5">
- {project()?.name ?? `No project set`}
- </span>
- </div>
- </div>
- }
- disabled={anchor() !== undefined}
- contentClass="rounded-xl p-1.5 px-3 glass bg-menu-glass"
- // The trigger is a flex item; min-w-0 lets long names truncate in the column.
- triggerClass="w-full min-w-0"
- >
- <Layer depth={2}>
- <button
- type="button"
- class="list-property-cell cursor-default inline-flex w-full max-w-full min-w-0 items-center gap-1 overflow-hidden rounded-full px-2 py-1.5 text-left leading-tight hover:bg-surface/50 @max-[840px]/u-list:px-1"
- onClick={(event) => {
- event.stopPropagation();
- setAnchor(event.currentTarget);
- }}
- >
- <Show
- when={project()}
- fallback={
- <>
- <CircleDashedEmpty class="size-3 shrink-0 opacity-50 @max-[840px]/u-list:size-4" />
- <span class="min-w-0 flex-1 truncate opacity-50 @max-[840px]/u-list:hidden">
- {emptyLabel()}
- </span>
- </>
- }
- >
- {(project) => (
- <>
- <StackIcon class="size-3 shrink-0 @max-[840px]/u-list:size-4" />
- <span class="min-w-0 max-w-full flex-1 truncate @max-[840px]/u-list:hidden">
- {project().name}
- </span>
- </>
- )}
- </Show>
- <CaretDownIcon class="size-3 shrink-0 @max-[840px]/u-list:hidden" />
- </button>
- </Layer>
- </HoverCard>
- <ProjectPickerPopover
- taskIds={[props.taskId]}
- open={anchor() !== undefined}
- onOpenChange={(open) => {
- if (open) return;
- const trigger = anchor();
- setAnchor(undefined);
- // No Kobalte trigger to return focus to, so hand it back ourselves.
- setTimeout(() => trigger?.isConnected && trigger.focus(), 0);
- }}
- getAnchorRect={() => anchor()?.getBoundingClientRect()}
- />
- </>
- );
-}
diff --git a/apps/web/src/features/projects/queries/project-identity.ts b/apps/web/src/features/projects/queries/project-identity.ts
index a9b69e4fd9..2109fcbd5b 100644
--- a/apps/web/src/features/projects/queries/project-identity.ts
+++ b/apps/web/src/features/projects/queries/project-identity.ts
@@ -6,7 +6,6 @@ import {
} from '@service-storage/initiative';
import { type QueryClient, useQuery } from '@tanstack/solid-query';
import type { Accessor } from 'solid-js';
-import type { TaskProjectReference } from '../core/project';
import { projectKeys } from './keys';
import { toProjectDetail } from './project-model';
import { projectProperties } from './project-properties';
@@ -60,22 +59,3 @@ export function useProjectIdentityQuery(
() => queryClient
);
}
-
-/**
- * A task's project, named only after an authorized project read; a project
- * the viewer cannot read stays unavailable. Undefined while loading.
- */
-export function useTaskProjectReference(
- projectId: Accessor<string | undefined>,
- userId: Accessor<string | undefined>
-): Accessor<TaskProjectReference | undefined> {
- const project = useProjectIdentityQuery(() => projectId() ?? '', userId);
- return () => {
- if (!projectId()) return { state: 'none' };
- if (project.isError) return { state: 'unavailable' };
- if (project.isPending) return undefined;
- return project.data
- ? { state: 'visible', id: project.data.id, name: project.data.name }
- : { state: 'unavailable' };
- };
-}
diff --git a/apps/web/src/features/projects/queries/project-sources.test.ts b/apps/web/src/features/projects/queries/project-sources.test.ts
index 2167901d2b..daad936841 100644
--- a/apps/web/src/features/projects/queries/project-sources.test.ts
+++ b/apps/web/src/features/projects/queries/project-sources.test.ts
@@ -1,4 +1,5 @@
import { SYSTEM_PROPERTY_IDS } from '@property/identifiers';
+import type { PropertyApiValues } from '@property/types';
import { QueryClient } from '@tanstack/solid-query';
import { createRoot } from 'solid-js';
import { afterEach, expect, it, vi } from 'vitest';
@@ -7,14 +8,6 @@ import { TASK_PROJECT_PROPERTY } from './task-project';
const mock = vi.hoisted(() => ({
createTask: vi.fn(),
saveProperty: vi.fn(),
- taskProperties: vi.fn(),
- toastFailure: vi.fn(),
-}));
-vi.mock('@service-properties/client', () => ({
- propertiesServiceClient: { getEntityProperties: mock.taskProperties },
-}));
-vi.mock('@core/component/Toast/Toast', () => ({
- toast: { failure: mock.toastFailure },
}));
vi.mock('@block-md/util/taskComposerProperties', () => ({
createTaskWithProperties: mock.createTask,
@@ -51,68 +44,50 @@ function commands() {
});
}
-/** The created task's properties as the server reports them. */
-function serverProject(projectId: string | undefined) {
- mock.taskProperties.mockResolvedValue({
- isErr: () => false,
- value: {
- properties: projectId
- ? [
- {
- property: {
- id: 'row',
- created_at: '2026-10-03T00:00:00Z',
- updated_at: '2026-10-03T00:00:00Z',
- },
- definition: {
- id: SYSTEM_PROPERTY_IDS.PROJECT,
- owner: { scope: 'system' },
- display_name: 'Project',
- data_type: 'ENTITY',
- is_multi_select: false,
- specific_entity_type: 'INITIATIVE',
- is_system: true,
- created_at: '2026-10-03T00:00:00Z',
- updated_at: '2026-10-03T00:00:00Z',
- },
- value: {
- type: 'EntityReference',
- value: [{ entity_id: projectId, entity_type: 'INITIATIVE' }],
- },
- },
- ]
- : [],
- },
- });
-}
-
-it('creates a project task in one call with its Project property', async () => {
+it("keeps the composer's Project and adds the project only when it's missing", async () => {
mock.createTask.mockResolvedValue({ documentId: 'task' });
- serverProject('project');
const { commands: project, dispose } = commands();
const history = vi.fn();
+ const status: [string, PropertyApiValues] = [
+ 'status',
+ { valueType: 'SELECT_STRING', values: ['done'] },
+ ];
+ const other: [string, PropertyApiValues] = [
+ SYSTEM_PROPERTY_IDS.PROJECT,
+ {
+ valueType: 'ENTITY',
+ refs: [{ entity_id: 'other', entity_type: 'INITIATIVE' }],
+ },
+ ];
+ await project.createTask(
+ 'project',
+ 'Moved',
+ '',
+ [status, other],
+ new Map(),
+ history
+ );
+ expect(mock.createTask).toHaveBeenLastCalledWith(
+ 'Moved',
+ '',
+ [status, other],
+ new Map(),
+ history
+ );
+
await project.createTask(
'project',
'Ship it',
'',
- [
- ['status', { valueType: 'SELECT_STRING', values: ['done'] }],
- [
- SYSTEM_PROPERTY_IDS.PROJECT,
- {
- valueType: 'ENTITY',
- refs: [{ entity_id: 'other', entity_type: 'INITIATIVE' }],
- },
- ],
- ],
+ [status],
new Map(),
history
);
- expect(mock.createTask).toHaveBeenCalledWith(
+ expect(mock.createTask).toHaveBeenLastCalledWith(
'Ship it',
'',
[
- ['status', { valueType: 'SELECT_STRING', values: ['done'] }],
+ status,
[
SYSTEM_PROPERTY_IDS.PROJECT,
{
@@ -124,29 +99,6 @@ it('creates a project task in one call with its Project property', async () => {
new Map(),
history
);
- expect(mock.toastFailure).not.toHaveBeenCalled();
- dispose();
-});
-
-it('says so when a created task could not join the project', async () => {
- mock.createTask.mockResolvedValue({ documentId: 'task' });
- serverProject(undefined);
- const { commands: project, dispose } = commands();
- const created = await project.createTask(
- 'project',
- 'Ship it',
- '',
- [],
- new Map(),
- vi.fn()
- );
- expect(created).toEqual({ documentId: 'task' });
- expect(mock.taskProperties).toHaveBeenCalledWith(
- expect.objectContaining({ entity_type: 'DOCUMENT', entity_id: 'task' })
- );
- expect(mock.toastFailure).toHaveBeenCalledWith(
- expect.stringContaining('could not be added to the project')
- );
dispose();
});
diff --git a/apps/web/src/features/projects/queries/project-sources.ts b/apps/web/src/features/projects/queries/project-sources.ts
index b322ff2a32..6106cd0442 100644
--- a/apps/web/src/features/projects/queries/project-sources.ts
+++ b/apps/web/src/features/projects/queries/project-sources.ts
@@ -1,5 +1,4 @@
import { createTaskWithProperties } from '@block-md/util/taskComposerProperties';
-import { toast } from '@core/component/Toast/Toast';
import { thrownResultErrorHasCode, throwOnErr } from '@core/util/result';
import { SYSTEM_PROPERTY_IDS } from '@property/identifiers';
import { useListPropertiesQuery } from '@queries/properties/definitions';
@@ -21,11 +20,7 @@ import { projectKeys } from './keys';
import { projectDetailQueryOptions } from './project-identity';
import { projectDefinitionProperties } from './project-properties';
import { createProjectSoupSource } from './project-soup';
-import {
- TASK_PROJECT_PROPERTY,
- taskIsInProject,
- taskProjectValue,
-} from './task-project';
+import { TASK_PROJECT_PROPERTY, taskProjectValue } from './task-project';
type ProjectCommands = ReturnType<ProjectsContext['createCommands']>;
@@ -108,33 +103,25 @@ export function createProjectSources(
},
createCommands() {
// A task joins a project through its Project property, set at creation.
- // Creation keeps the task when a property is rejected, so confirm the
- // join and say when it didn't happen.
- const createTask: ProjectCommands['createTask'] = async (
+ // The composer starts in the project, so keep a changed or cleared value.
+ const createTask: ProjectCommands['createTask'] = (
projectId,
title,
content,
properties,
...rest
- ) => {
- const created = await createTaskWithProperties(
+ ) =>
+ createTaskWithProperties(
title,
content,
- [
- ...properties.filter(([id]) => id !== SYSTEM_PROPERTY_IDS.PROJECT),
- [SYSTEM_PROPERTY_IDS.PROJECT, taskProjectValue(projectId)],
- ],
+ properties.some(([id]) => id === SYSTEM_PROPERTY_IDS.PROJECT)
+ ? properties
+ : [
+ ...properties,
+ [SYSTEM_PROPERTY_IDS.PROJECT, taskProjectValue(projectId)],
+ ],
...rest
);
- if (
- created &&
- (await taskIsInProject(created.documentId, projectId)) === false
- )
- toast.failure(
- 'Task created, but could not be added to the project. Use Add to project from the task menu to try again.'
- );
- return created;
- };
const create = createProjectMutation(client, cache, userId);
const update = useMutation(
() => ({
diff --git a/apps/web/src/features/projects/queries/task-project.test.ts b/apps/web/src/features/projects/queries/task-project.test.ts
index e0e67a12f5..c7c4425aec 100644
--- a/apps/web/src/features/projects/queries/task-project.test.ts
+++ b/apps/web/src/features/projects/queries/task-project.test.ts
@@ -1,7 +1,5 @@
-import { SYSTEM_PROPERTY_IDS } from '@property/identifiers';
-import type { Property } from '@property/types';
import { describe, expect, it } from 'vitest';
-import { taskProjectId, taskProjectValue } from './task-project';
+import { taskProjectValue } from './task-project';
describe('task Project property', () => {
it('builds the value naming a project, or clearing it', () => {
@@ -11,17 +9,4 @@ describe('task Project property', () => {
});
expect(taskProjectValue()).toEqual({ valueType: 'ENTITY', refs: null });
});
-
- it("reads the project a task's properties name", () => {
- const project = {
- propertyDefinitionId: SYSTEM_PROPERTY_IDS.PROJECT,
- valueType: 'ENTITY',
- value: [{ entity_id: 'initiative', entity_type: 'INITIATIVE' }],
- } as Property;
- expect(taskProjectId([project])).toBe('initiative');
- expect(taskProjectId([{ ...project, value: null } as Property])).toBe(
- undefined
- );
- expect(taskProjectId([])).toBe(undefined);
- });
});
diff --git a/apps/web/src/features/projects/queries/task-project.ts b/apps/web/src/features/projects/queries/task-project.ts
index a5785bddd6..27cf024982 100644
--- a/apps/web/src/features/projects/queries/task-project.ts
+++ b/apps/web/src/features/projects/queries/task-project.ts
@@ -1,11 +1,8 @@
-import { entityPropertyFromApi } from '@property/api/converters';
import { SYSTEM_PROPERTY_IDS } from '@property/identifiers';
import type {
- Property,
PropertyApiValues,
PropertyDefinitionDomain,
} from '@property/types';
-import { propertiesServiceClient } from '@service-properties/client';
/** A task's project is its Project system property: one project reference. */
export const TASK_PROJECT_PROPERTY: PropertyDefinitionDomain = {
@@ -28,40 +25,3 @@ export const taskProjectValue = (projectId?: string): PropertyApiValues => ({
? [{ entity_id: projectId, entity_type: 'INITIATIVE' }]
: null,
});
-
-/** The project a task's properties name, if any. */
-export function taskProjectId(
- properties: readonly Property[]
-): string | undefined {
- const property = properties.find(
- (property) => property.propertyDefinitionId === SYSTEM_PROPERTY_IDS.PROJECT
- );
- if (property?.valueType !== 'ENTITY') return undefined;
- return property.value?.find(
- (reference) => reference.entity_type === 'INITIATIVE'
- )?.entity_id;
-}
-
-/**
- * Whether the server has `taskId` in `projectId`, from its Project property;
- * undefined when the properties can't be read.
- */
-export async function taskIsInProject(
- taskId: string,
- projectId: string
-): Promise<boolean | undefined> {
- const result = await propertiesServiceClient.getEntityProperties({
- entity_type: 'DOCUMENT',
- entity_id: taskId,
- query: {},
- });
- if (result.isErr()) return undefined;
- const properties = result.value.properties.flatMap((property) => {
- try {
- return [entityPropertyFromApi(property)];
- } catch {
- return [];
- }
- });
- return taskProjectId(properties) === projectId;
-}
diff --git a/apps/web/src/features/projects/task-project-property.tsx b/apps/web/src/features/projects/task-project-property.tsx
deleted file mode 100644
index 5bccfa8a98..0000000000
--- a/apps/web/src/features/projects/task-project-property.tsx
+++ /dev/null
@@ -1,14 +0,0 @@
-import { useUserId } from '@core/context/user';
-import { Projects } from './projects';
-import { TaskProjectProperty as TaskProjectPropertyContent } from './views/task-project-property';
-
-export function TaskProjectProperty(props: {
- taskId: string;
- canEdit: boolean;
-}) {
- return (
- <Projects>
- <TaskProjectPropertyContent {...props} userId={useUserId()} />
- </Projects>
- );
-}
diff --git a/apps/web/src/features/projects/views/task-project-property.tsx b/apps/web/src/features/projects/views/task-project-property.tsx
deleted file mode 100644
index 3f0190569b..0000000000
--- a/apps/web/src/features/projects/views/task-project-property.tsx
+++ /dev/null
@@ -1,61 +0,0 @@
-import CaretDownIcon from '@phosphor/caret-down.svg';
-import StackIcon from '@phosphor/stack.svg';
-import { useEntityPropertiesQuery } from '@queries/properties/entity';
-import { Button, Tooltip } from '@ui';
-import { type Accessor, createSignal, Show } from 'solid-js';
-import { useTaskProjectReference } from '../queries/project-identity';
-import { taskProjectId } from '../queries/task-project';
-import { ProjectAssignment } from './project-assignment';
-
-/** The task's Project property, rendered alongside its other properties. */
-export function TaskProjectProperty(props: {
- taskId: string;
- canEdit: boolean;
- userId: Accessor<string | undefined>;
-}) {
- const properties = useEntityPropertiesQuery(
- () => 'TASK',
- () => props.taskId,
- false
- );
- const reference = useTaskProjectReference(
- () => taskProjectId(properties.data ?? []),
- props.userId
- );
- const [open, setOpen] = createSignal(false);
- const label = () => {
- const project = reference();
- if (properties.error) return 'Could not load project';
- if (properties.isLoading || !project) return 'Loading project…';
- if (project.state === 'visible') return project.name;
- if (project.state === 'unavailable') return 'Unavailable project';
- return 'No project';
- };
-
- return (
- <>
- <Tooltip label={`Project: ${label()}`}>
- <Button
- size="sm"
- variant="ghost"
- class="max-w-full gap-1.5 rounded-full border border-edge bg-surface-2 px-2 py-1 text-xs font-normal"
- aria-label={`Project: ${label()}`}
- disabled={!props.canEdit}
- onClick={() => setOpen(true)}
- >
- <StackIcon class="size-3 shrink-0" />
- <span class="max-w-48 truncate">{label()}</span>
- <Show when={props.canEdit}>
- <CaretDownIcon class="size-3 shrink-0" />
- </Show>
- </Button>
- </Tooltip>
- <Show when={open() && props.canEdit}>
- <ProjectAssignment
- taskIds={[props.taskId]}
- onClose={() => setOpen(false)}
- />
- </Show>
- </>
- );
-}
diff --git a/apps/web/src/features/property/hooks/usePropertySelection.ts b/apps/web/src/features/property/hooks/usePropertySelection.ts
index a5114f0366..7eec48363d 100644
--- a/apps/web/src/features/property/hooks/usePropertySelection.ts
+++ b/apps/web/src/features/property/hooks/usePropertySelection.ts
@@ -27,7 +27,7 @@ export function usePropertySelection(
// Tag definitions are managed through the dedicated Tags UI, never the
// generic property pickers.
property.valueType !== 'TAG' &&
- // A task's project is set from its own Project row and pickers.
+ // A task always lists Project, and nothing else can carry it.
property.id !== SYSTEM_PROPERTY_IDS.PROJECT
);
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 0e9d888c70..1aeeb620a5 100644
--- a/apps/web/src/features/property/side-panel/properties/EntityPropertiesSection.tsx
+++ b/apps/web/src/features/property/side-panel/properties/EntityPropertiesSection.tsx
@@ -13,7 +13,6 @@ import { Property as PropertyNS, useProperty } from '@property';
import { AddPropertyButton } from '@property/component/AddPropertyButton';
import { Modals } from '@property/component/modal';
import { PropertyValueIcon } from '@property/component/propertyValue/PropertyValueIcon';
-import { SYSTEM_PROPERTY_IDS } from '@property/constants';
import {
PropertiesProvider,
type PropertySaveHandler,
@@ -176,10 +175,6 @@ export function EntityPropertiesSection(props: EntityPropertiesSectionProps) {
if (tagDefinitionIds().has(property.propertyDefinitionId)) {
return false;
}
- // A task's project has its own row beside the properties.
- if (property.propertyDefinitionId === SYSTEM_PROPERTY_IDS.PROJECT) {
- return false;
- }
if (props.propertyFilter && !props.propertyFilter(property)) {
return false;
}
diff --git a/apps/web/src/features/tasks-view/components/task-list/TaskGridLayout.tsx b/apps/web/src/features/tasks-view/components/task-list/TaskGridLayout.tsx
index ce36cc4a1e..92ac4cf697 100644
--- a/apps/web/src/features/tasks-view/components/task-list/TaskGridLayout.tsx
+++ b/apps/web/src/features/tasks-view/components/task-list/TaskGridLayout.tsx
@@ -25,9 +25,10 @@ import { useBulkSaveEntityPropertiesMutation } from '@queries/properties/entity'
import { EntityType } from '@service-properties/generated/schemas/entityType';
import type { SoupProperty } from '@service-storage/generated/schemas/soupProperty';
import { cn } from '@ui/utils/classname';
-import { createMemo, For, type JSX, Show, Suspense } from 'solid-js';
+import { createMemo, For, Show, Suspense } from 'solid-js';
import {
TASK_GRID_COLUMNS,
+ TASK_PROJECT_COLUMN,
type TaskGridColumn,
taskGridTemplate,
} from './task-grid-template';
@@ -59,7 +60,6 @@ function buildStubProperty(col: TaskGridColumn): Property {
type TaskGridLayoutProps = Omit<LayoutProps, 'entity'> & {
entity: TaskEntityWithProperties;
- projectSlot?: JSX.Element;
};
export function TaskGridLayout(props: TaskGridLayoutProps) {
@@ -118,7 +118,7 @@ export function TaskGridLayout(props: TaskGridLayoutProps) {
)}
style={taskGridTemplate({
indicator: !props.hideCheckbox,
- project: props.projectSlot !== undefined,
+ project: props.showProject === true,
})}
>
<Show when={!props.hideCheckbox}>
@@ -197,12 +197,18 @@ export function TaskGridLayout(props: TaskGridLayoutProps) {
)}
</For>
- <Show when={props.projectSlot !== undefined}>
+ <Show when={props.showProject}>
<Entity.Slot
- placement="initiative"
+ placement={TASK_PROJECT_COLUMN.id}
class="flex items-center min-w-0 text-xs ph-no-capture @container/slot @max-[840px]/u-list:justify-center"
>
- {props.projectSlot}
+ <ListPropertyValue
+ entityId={props.entity.id}
+ property={
+ propertyMap().get(TASK_PROJECT_COLUMN.defId) ??
+ buildStubProperty(TASK_PROJECT_COLUMN)
+ }
+ />
</Entity.Slot>
</Show>
diff --git a/apps/web/src/features/tasks-view/components/task-list/TaskList.tsx b/apps/web/src/features/tasks-view/components/task-list/TaskList.tsx
index b2d87a1bc3..7d3c6aab8a 100644
--- a/apps/web/src/features/tasks-view/components/task-list/TaskList.tsx
+++ b/apps/web/src/features/tasks-view/components/task-list/TaskList.tsx
@@ -25,7 +25,6 @@ import { isTouchDevice } from '@core/mobile/isTouchDevice';
import {
type EntityData,
EntitySelectionToolbar,
- getTaskReferencedEntityIds,
getTaskStatusOptionId,
ListLayoutProvider,
type TaskEntityWithProperties,
@@ -64,7 +63,6 @@ import { TaskListEntity } from './TaskListEntity';
import { TaskListHeader } from './TaskListHeader';
import { taskGridColumnCount } from './task-grid-template';
import './task-list.css';
-import { ProjectPropertyCell } from '@app/features/projects/project-property';
import { ProjectAssignmentDialog } from '@app/features/projects/projects';
function ResponsiveTaskListHeader() {
@@ -516,19 +514,7 @@ export function TaskList(props: TaskListProps) {
}}
>
<TaskListEntity
- projectSlot={
- projectsEnabled() ? (
- <ProjectPropertyCell
- taskId={entityRow().entity.id}
- projectId={
- getTaskReferencedEntityIds(
- entityRow().entity,
- SYSTEM_PROPERTY_IDS.PROJECT
- )[0]
- }
- />
- ) : undefined
- }
+ showProject={projectsEnabled()}
rowId={entityRow().id}
entity={entityRow().entity}
highlighted={list.focus.key() === entityRow().id}
diff --git a/apps/web/src/features/tasks-view/components/task-list/TaskListEntity.tsx b/apps/web/src/features/tasks-view/components/task-list/TaskListEntity.tsx
index ad851fc503..f06535992e 100644
--- a/apps/web/src/features/tasks-view/components/task-list/TaskListEntity.tsx
+++ b/apps/web/src/features/tasks-view/components/task-list/TaskListEntity.tsx
@@ -37,7 +37,6 @@ import {
import { mergeRefs } from '@solid-primitives/refs';
import { cn } from '@ui/utils/classname';
import {
- children,
createEffect,
createSignal,
type JSX,
@@ -52,7 +51,8 @@ type TaskListEntityProps = Omit<BaseListEntityProps, 'entity'> & {
entity: TaskEntityWithProperties;
rowId?: string;
showUnrollNotifications?: boolean;
- projectSlot?: JSX.Element;
+ /** Show the Project column (Projects enabled). */
+ showProject?: boolean;
};
function MaybeEntityRow(props: {
@@ -115,9 +115,6 @@ export function TaskListEntity(props: TaskListEntityProps) {
const showContentHits = () => showHitSnippet();
- // Resolved once: both layouts render it and the grid checks it exists.
- const projectSlot = children(() => props.projectSlot);
-
const layoutProps = () => ({
entity: props.entity,
checked: props.checked,
@@ -131,7 +128,7 @@ export function TaskListEntity(props: TaskListEntityProps) {
setSnippetContainerRef,
chars: chars(),
onProjectClick: props.onProjectClick,
- projectSlot: projectSlot(),
+ showProject: props.showProject,
});
const draggable = createEntityDraggable({
@@ -186,9 +183,6 @@ export function TaskListEntity(props: TaskListEntityProps) {
config={props.entityRowConfig}
>
<NarrowLayout {...layoutProps()} />
- <Show when={projectSlot()}>
- <div class="ml-8 pb-1 text-xs">{projectSlot()}</div>
- </Show>
</MaybeEntityRow>
</Match>
</Switch>
diff --git a/apps/web/src/features/tasks-view/components/task-list/task-grid-template.ts b/apps/web/src/features/tasks-view/components/task-list/task-grid-template.ts
index ecd1a12a0e..26d1bae3bd 100644
--- a/apps/web/src/features/tasks-view/components/task-list/task-grid-template.ts
+++ b/apps/web/src/features/tasks-view/components/task-list/task-grid-template.ts
@@ -34,10 +34,23 @@ export const TASK_GRID_COLUMNS = [
},
] as const;
+/** The task's project, shown only while Projects is enabled. */
+export const TASK_PROJECT_COLUMN = {
+ id: 'initiative',
+ label: 'Project',
+ defId: SYSTEM_PROPERTY_IDS.PROJECT,
+ dataType: DataType.ENTITY,
+ isMultiSelect: false,
+ specificEntityType: EntityType.INITIATIVE,
+ width: 'var(--task-col-initiative, 8rem)',
+} as const;
+
/** Width for the "Created By" column - only shown on wide containers */
const CREATED_BY_COLUMN_WIDTH = 'var(--task-col-created-by, 7rem)';
-export type TaskGridColumn = (typeof TASK_GRID_COLUMNS)[number];
+export type TaskGridColumn =
+ | (typeof TASK_GRID_COLUMNS)[number]
+ | typeof TASK_PROJECT_COLUMN;
/**
* Wide-container grid (includes Created By). The project column exists only
@@ -51,9 +64,7 @@ export function taskGridTemplate(options: {
...(options.indicator ? [{ id: 'indicator', width: '1rem' }] : []),
{ id: 'content', width: 'minmax(0, 100%)' },
...TASK_GRID_COLUMNS,
- ...(options.project
- ? [{ id: 'initiative', width: 'var(--task-col-initiative, 8rem)' }]
- : []),
+ ...(options.project ? [TASK_PROJECT_COLUMN] : []),
{ id: 'createdBy', width: CREATED_BY_COLUMN_WIDTH },
{ id: 'timestamp', width: 'var(--task-col-timestamp, 5rem)' },
];
diff --git a/apps/web/src/lib/queries/properties/entity.ts b/apps/web/src/lib/queries/properties/entity.ts
index 3b662ca5cf..ada20ce904 100644
--- a/apps/web/src/lib/queries/properties/entity.ts
+++ b/apps/web/src/lib/queries/properties/entity.ts
@@ -94,6 +94,45 @@ async function setRestEntityProperty(args: {
}
}
+/**
+ * An entity's properties from the properties service, metadata included, so
+ * consumers with different `includeMetadata` values share one cache entry and
+ * one request.
+ */
+async function fetchRestEntityProperties(
+ entityType: EntityType,
+ entityId: string
+): Promise<Property[]> {
+ const data = await throwOnErr(
+ async () =>
+ await propertiesServiceClient.getEntityProperties({
+ entity_type: toPropertyTargetEntityType(entityType),
+ entity_id: entityId,
+ query: { include_metadata: true },
+ })
+ );
+ return data.properties.flatMap((property) => {
+ try {
+ return [entityPropertyFromApi(property)];
+ } catch (error) {
+ console.warn('Skipping property with unsupported type', error);
+ return [];
+ }
+ });
+}
+
+/** Read an entity's current properties through the shared entity query. */
+export function fetchEntityProperties(
+ entityType: EntityType,
+ entityId: string
+): Promise<Property[]> {
+ return queryClient.fetchQuery({
+ queryKey: propertiesKeys.entity({ entityType, entityId }).queryKey,
+ queryFn: () => fetchRestEntityProperties(entityType, entityId),
+ staleTime: 0,
+ });
+}
+
export function useEntityPropertiesQuery(
entityType: Accessor<EntityType>,
entityId: Accessor<string>,
@@ -124,26 +163,7 @@ export function useEntityPropertiesQuery(
entityId: id,
}).queryKey,
enabled: !usesGraphql() && id.length > 0,
- queryFn: async () => {
- // Always fetch with metadata so consumers with different
- // `includeMetadata` values share one cache entry and one request.
- const data = await throwOnErr(
- async () =>
- await propertiesServiceClient.getEntityProperties({
- entity_type: toPropertyTargetEntityType(type),
- entity_id: id,
- query: { include_metadata: true },
- })
- );
- return data.properties.flatMap((property) => {
- try {
- return [entityPropertyFromApi(property)];
- } catch (error) {
- console.warn('Skipping property with unsupported type', error);
- return [];
- }
- });
- },
+ queryFn: () => fetchRestEntityProperties(type, id),
select: (properties: Property[]) =>
includeMetadata
? properties
diff --git a/docs/AGENT_GUIDE/tasks.md b/docs/AGENT_GUIDE/tasks.md
index be8b08d326..2104f65210 100644
--- a/docs/AGENT_GUIDE/tasks.md
+++ b/docs/AGENT_GUIDE/tasks.md
@@ -125,8 +125,10 @@ filter sheets. Desktop uses the centered composer dialog.
1. Click the `Task` button (or `Create` → `Task T`, or keyboard `c` then `t`).
2. A dialog opens with the title contenteditable focused (placeholder `New task`), plus
`Add description...`, and property buttons: `Not Started` (status), `Priority`, assignee
- chip (defaults to you), `Due Date`, `Change or select tags`, `Attach image or video`,
- a `Create More` switch, and `Create Task Ctrl ↵`.
+ chip (defaults to you), `Due Date`, `Project` (when Projects is enabled; the standard
+ property dropdown, listing projects), `Change or select tags`, `Attach image or video`,
+ a `Create More` switch, and `Create Task Ctrl ↵`. If the chosen project can't be
+ set, the task is still created and a toast says it wasn't added to the project.
The `Shared with Team` row defaults to on and remembers your choice in local
storage across composer openings and page reloads. Its hint explains whether
the task will be visible to your whole team or only to you and the people you
@@ -268,8 +270,9 @@ tasks whose Project property names the project.
The project's Tasks tab starts with the task search, controls, and unified list;
the project title and property pills appear only on Overview. Use
-`New task` to create a task in the project: the create request carries the
-Project property, so there is no separate assignment step. The new row appears
+`New task` to create a task in the project: the composer opens with its Project
+set to this project (change or clear it like any property), and the create
+request carries it, so there is no separate assignment step. The new row appears
once the task is created. Verify this with GraphQL Soup both enabled and
disabled. The section tabs
use the same control as Channels. Editors can choose `Add existing tasks` beside
@@ -278,17 +281,19 @@ already in this project are excluded. Adding a task moves it from its previous
project; the dialog explains this before saving. A partial failure keeps only
failed tasks selected for retry, and a request failure preserves the selection.
-The regular Tasks list includes a Project column; clicking its cell opens the
-project picker. Right-click a task and choose `Add to project…` to choose or clear
+The regular Tasks list includes a Project column. Its cell is a regular property
+cell: clicking it opens the same entity dropdown as the other property columns,
+listing projects. Narrow lists show Project as a compact pill after the row's
+Status, Priority and Assignees pills. Right-click a task and choose `Add to project…` to choose or clear
its project. On mobile the same action is in the long-press menu. For a selection,
choose `Actions → Add to project…`; there is no separate assignment button in the
selection toolbar. A context action on a selected row applies to the selection.
-Inside an open task, use the Project pill below the title, the Project row in
-the Properties side panel, or `Add to project…` in the title's actions menu.
-The property shows `No project` until assigned and stays read-only without edit
-access. Choose `No project` in the assignment dialog to remove the association.
-The Project property does not appear in the generic Properties list or the
-`Add property` picker; these project controls set it.
+Inside an open task, Project is a regular property: a pill beside Status,
+Priority and Assignees below the title, and a row in the Properties side panel.
+Both open the standard property dropdown, which searches projects; clear the
+value there to remove the task from its project. `Add to project…` in the
+title's actions menu does the same. Tasks show Project even before it's set,
+and the `Add property` picker doesn't list it.
Discussion at the bottom of Overview uses the new discussions system. Comments
appear from oldest to newest, with the comment input below them. The Discussion