Skip to content

armgit / macro

Public Imported from GitHub
0

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

feat(tasks): link task sources in the composer (#9481)

dev-rb63a434fd80aa
diff --git a/.agents/rules/web/ui-primitives.md b/.agents/rules/web/ui-primitives.md
index 0faa784ea4..db997ee24e 100644
--- a/.agents/rules/web/ui-primitives.md
+++ b/.agents/rules/web/ui-primitives.md
@@ -51,6 +51,7 @@ Applies to `apps/web/src/components/ui`, including ports from shadcn-solid.
- Keep ordinary children in the Button's flex row so trailing carets, truncation,
and custom spacing work. Only loading actions need the reserved-content layer.
Preserve native disabled behavior and activation guards for polymorphic controls.
+- Pass only styling fields to Button style helpers; spreading props with `children` evaluates Solid getters and can detach memoized content.
- Compose groups explicitly with `ButtonGroup.Button`; standalone Buttons do not
inherit group styling. Segments inherit size and variant unless overridden,
remain flat, and own their hover/pressed/disabled states. The frame owns its
diff --git a/apps/web/AGENTS.md b/apps/web/AGENTS.md
index 977366dde3..657cae607e 100644
--- a/apps/web/AGENTS.md
+++ b/apps/web/AGENTS.md
@@ -612,6 +612,9 @@ resolved session ID; keep the existing `AgentSessionProvider` subscription to
the create response confirms success; never clear newer composer input from a
late callback or automatically retry an uncertain create. Keep recovery copies
through restarts and remove them on explicit logout. See the Tasks walkthrough.
+- Prefill task Source through the originating action's composer preset under
+ `enable-task-source-property`; keep the shared composer flag-agnostic and retain
+ exact message IDs through property edits. See the Tasks walkthrough.
- Shared server-state queries and mutations live in `src/lib/queries`; keep
feature-specific query orchestration with its owning feature.
- Keep CRM contacts explicitly included in the auxiliary GraphQL backfill;
diff --git a/apps/web/src/components/ui/components/Button.test.tsx b/apps/web/src/components/ui/components/Button.test.tsx
index 3cd5b4b1c3..9ccf04f40d 100644
--- a/apps/web/src/components/ui/components/Button.test.tsx
+++ b/apps/web/src/components/ui/components/Button.test.tsx
@@ -1,3 +1,4 @@
+import { createLazyMemo } from '@solid-primitives/memo';
import { cleanup, fireEvent, render, screen } from '@solidjs/testing-library';
import { createSignal } from 'solid-js';
import { afterEach, describe, expect, it, vi } from 'vitest';
@@ -32,6 +33,40 @@ describe('Button', () => {
expect(onClick).toHaveBeenCalledTimes(2);
});
+ it.each([undefined, false])(
+ 'keeps memoized content mounted through style and control changes with loading=%s',
+ (initialLoading) => {
+ const [variant, setVariant] = createSignal<'secondary' | 'primary'>(
+ 'secondary'
+ );
+ const [loading, setLoading] = createSignal<boolean | undefined>(
+ initialLoading
+ );
+ const [tooltip, setTooltip] = createSignal<string>();
+ render(() => {
+ const content = createLazyMemo(() => <span>Linked item</span>);
+ return (
+ <Button variant={variant()} loading={loading()} tooltip={tooltip()}>
+ <span>{content()}</span>
+ </Button>
+ );
+ });
+ expect(screen.getByRole('button', { name: 'Linked item' })).toBeTruthy();
+
+ setVariant('primary');
+ expect(screen.getByRole('button', { name: 'Linked item' })).toBeTruthy();
+
+ setLoading(true);
+ setLoading(false);
+ expect(screen.getByRole('button', { name: 'Linked item' })).toBeTruthy();
+
+ setTooltip('Open linked item');
+ expect(screen.getByRole('button', { name: 'Linked item' })).toBeTruthy();
+ setTooltip(undefined);
+ expect(screen.getByRole('button', { name: 'Linked item' })).toBeTruthy();
+ }
+ );
+
it('inherits group settings only through explicit segments', () => {
render(() => (
<ButtonGroup variant="secondary" size="sm">
diff --git a/apps/web/src/components/ui/components/Button.tsx b/apps/web/src/components/ui/components/Button.tsx
index eae83aaefc..d2b65e4b52 100644
--- a/apps/web/src/components/ui/components/Button.tsx
+++ b/apps/web/src/components/ui/components/Button.tsx
@@ -249,7 +249,9 @@ export function Button<T extends ValidComponent = 'button'>(
{...tabIndexProps()}
aria-busy={local.loading || buttonProps['aria-busy'] || undefined}
class={buttonClasses({
- ...local,
+ appearance: local.appearance,
+ finish: local.finish,
+ fullWidth: local.fullWidth,
variant: variant(),
size: size(),
class: local.class,
diff --git a/apps/web/src/features/block-email/EmailThreadHostView.tsx b/apps/web/src/features/block-email/EmailThreadHostView.tsx
index e2c29664a2..045cf9e8da 100644
--- a/apps/web/src/features/block-email/EmailThreadHostView.tsx
+++ b/apps/web/src/features/block-email/EmailThreadHostView.tsx
@@ -9,6 +9,7 @@ import {
EmailThread,
type EmailThreadProps,
} from '@app/features/email-thread/email-thread';
+import { taskSourceComposerContext } from '@app/features/task-composer/source-context';
import { HeaderActionGroup } from '@components/app/HeaderActionGroup';
import { SidePanel } from '@components/app/side-panel';
import { useSplitLayout } from '@components/app/split-layout/layout';
@@ -51,6 +52,10 @@ export function EmailThreadHostView(props: EmailThreadHostViewProps) {
type: 'component',
id: 'task-compose',
params: {
+ composerContext: taskSourceComposerContext({
+ entity_type: 'THREAD',
+ entity_id: props.threadId(),
+ }),
initialContent: buildMentionMarkdownString({
type: 'document',
documentId: props.threadId(),
diff --git a/apps/web/src/features/block-md/component/MarkdownPopup.tsx b/apps/web/src/features/block-md/component/MarkdownPopup.tsx
index fd489b78ff..9cc61810c4 100644
--- a/apps/web/src/features/block-md/component/MarkdownPopup.tsx
+++ b/apps/web/src/features/block-md/component/MarkdownPopup.tsx
@@ -1,3 +1,4 @@
+import { taskSourceComposerContext } from '@app/features/task-composer/source-context';
import { useFeatureFlag } from '@app/lib/analytics/posthog';
import { useFlow } from '@app/observability/flow';
import { globalSplitManager } from '@app/signal/splitLayout';
@@ -516,6 +517,10 @@ export function MarkdownPopup(props: {
type: 'component',
id: 'task-compose',
params: {
+ composerContext: taskSourceComposerContext({
+ entity_type: 'DOCUMENT',
+ entity_id: blockId,
+ }),
initialTitle: text.length > 70 ? `${text.slice(0, 70)}...` : text,
initialContent: buildMentionMarkdownString({
type: 'document',
diff --git a/apps/web/src/features/block-md/util/taskComposerProperties.test.ts b/apps/web/src/features/block-md/util/taskComposerProperties.test.ts
index 6b28e8c685..b5b45cce61 100644
--- a/apps/web/src/features/block-md/util/taskComposerProperties.test.ts
+++ b/apps/web/src/features/block-md/util/taskComposerProperties.test.ts
@@ -338,3 +338,106 @@ it('lets the composer own failed-create feedback without silencing other callers
expect(await create()).toBeNull();
expect(mock.failure).toHaveBeenCalledExactlyOnceWith('Failed to create Task');
});
+
+it('keeps a message source through composer edits and the task create payload', async () => {
+ mock.create.mockResolvedValue({ documentId: 'task' });
+ mock.listProperties.mockReturnValue({
+ isSuccess: true,
+ data: [definition(SYSTEM_PROPERTY_IDS.SOURCE, { data_type: 'ENTITY' })],
+ });
+ const { composer, dispose } = createRoot((dispose) => ({
+ composer: createTaskComposerProperties({
+ initialValues: {
+ [SYSTEM_PROPERTY_IDS.SOURCE]: {
+ valueType: 'ENTITY',
+ refs: [
+ {
+ entity_type: 'CHANNEL',
+ entity_id: 'channel',
+ specific_message_id: 'reply',
+ },
+ ],
+ },
+ },
+ initialVisiblePropertyIds: [SYSTEM_PROPERTY_IDS.SOURCE],
+ }),
+ dispose,
+ }));
+ try {
+ const source = composer.properties()[0];
+ await composer.saveHandler.saveProperty(source, {
+ valueType: 'ENTITY',
+ refs: [
+ {
+ entity_type: 'CHANNEL',
+ entity_id: 'channel',
+ specific_message_id: 'reply',
+ },
+ ],
+ });
+ await createTaskWithProperties(
+ 'Task',
+ '',
+ Object.entries(composer.propertyValues),
+ composer.createDefinitions(),
+ vi.fn()
+ );
+ expect(mock.create).toHaveBeenLastCalledWith(
+ expect.objectContaining({
+ propertyValues: [
+ {
+ propertyId: SYSTEM_PROPERTY_IDS.SOURCE,
+ value: {
+ type: 'entity_reference',
+ reference: {
+ entity_type: 'CHANNEL',
+ entity_id: 'channel',
+ specific_message_id: 'reply',
+ },
+ },
+ },
+ ],
+ })
+ );
+ await composer.saveHandler.saveProperty(source, {
+ valueType: 'ENTITY',
+ refs: [{ entity_type: 'DOCUMENT', entity_id: 'request' }],
+ });
+ await createTaskWithProperties(
+ 'Task',
+ '',
+ Object.entries(composer.propertyValues),
+ composer.createDefinitions(),
+ vi.fn()
+ );
+ expect(mock.create).toHaveBeenLastCalledWith(
+ expect.objectContaining({
+ propertyValues: [
+ {
+ propertyId: SYSTEM_PROPERTY_IDS.SOURCE,
+ value: {
+ type: 'entity_reference',
+ reference: { entity_type: 'DOCUMENT', entity_id: 'request' },
+ },
+ },
+ ],
+ })
+ );
+ await composer.saveHandler.saveProperty(source, {
+ valueType: 'ENTITY',
+ refs: null,
+ });
+ await createTaskWithProperties(
+ 'Task',
+ '',
+ Object.entries(composer.propertyValues),
+ composer.createDefinitions(),
+ vi.fn()
+ );
+ expect(mock.create).toHaveBeenLastCalledWith(
+ expect.objectContaining({ propertyValues: undefined })
+ );
+ } finally {
+ dispose();
+ }
+});
diff --git a/apps/web/src/features/block-md/util/taskComposerProperties.ts b/apps/web/src/features/block-md/util/taskComposerProperties.ts
index 0e9fe0be9b..c750db9425 100644
--- a/apps/web/src/features/block-md/util/taskComposerProperties.ts
+++ b/apps/web/src/features/block-md/util/taskComposerProperties.ts
@@ -1,3 +1,4 @@
+import { DEFAULT_TASK_COMPOSER_PROPERTY_IDS } from '@app/features/task-composer/property-defaults';
import { useFeatureFlag } from '@app/lib/analytics/posthog';
import { toast } from '@core/component/Toast/Toast';
import { enableProjects } from '@core/constant/featureFlags';
@@ -26,17 +27,8 @@ import type { Accessor } from 'solid-js';
import { createSignal } from 'solid-js';
import { createStore, reconcile, type Store, unwrap } from 'solid-js/store';
-/**
- * Props shown in the composer (Linear-style left-to-right order). Project
- * shows only while Projects is enabled.
- */
-export const DEFAULT_TASK_COMPOSER_PROPERTY_IDS = [
- SYSTEM_PROPERTY_IDS.STATUS,
- SYSTEM_PROPERTY_IDS.PRIORITY,
- SYSTEM_PROPERTY_IDS.ASSIGNEES,
- SYSTEM_PROPERTY_IDS.DUE_DATE,
- SYSTEM_PROPERTY_IDS.PROJECT,
-];
+export { DEFAULT_TASK_COMPOSER_PROPERTY_IDS } from '@app/features/task-composer/property-defaults';
+
const COMPOSER_PROPERTY_SET = new Set<string>(
DEFAULT_TASK_COMPOSER_PROPERTY_IDS
);
diff --git a/apps/web/src/features/channel/Channel/Channel.tsx b/apps/web/src/features/channel/Channel/Channel.tsx
index 1976f43e4b..0d1ea3bcef 100644
--- a/apps/web/src/features/channel/Channel/Channel.tsx
+++ b/apps/web/src/features/channel/Channel/Channel.tsx
@@ -5,6 +5,7 @@ import {
import { AgentConversationsProvider } from '@app/features/agent-conversations/agent-conversations-provider';
import { AgentDmComposer } from '@app/features/agent-dms/agent-dm-composer';
import { openChatWithInput } from '@app/features/chat/ChatWithAgentButton';
+import { taskSourceComposerContext } from '@app/features/task-composer/source-context';
import { usePending } from '@app/observability/flow';
import { startUiOperation } from '@app/observability/ui-operation';
import { createActivityTracker } from '@channel/activity-tracker';
@@ -499,6 +500,11 @@ export function Channel(props: ChannelProps) {
type: 'component',
id: 'task-compose',
params: {
+ composerContext: taskSourceComposerContext({
+ entity_type: 'CHANNEL',
+ entity_id: props.channelId,
+ specific_message_id: ctx.message.id,
+ }),
initialTitle: title,
initialContent: buildChannelMessageMention(ctx.message),
initialAssigneeIds:
diff --git a/apps/web/src/features/property/README.md b/apps/web/src/features/property/README.md
index d8b8ae9d25..d8a36686bd 100644
--- a/apps/web/src/features/property/README.md
+++ b/apps/web/src/features/property/README.md
@@ -51,6 +51,16 @@ Editable list cells use the shared ghost `Property.Pill` styling. Project hover
cards use a cube header with the assigned value below it; empty Project hover
cards retain the one-line empty message.
+The single-item Source property uses `SourceLinkPill` in composers, inline pills,
+and the side panel: its item opens through the shared mention-link navigation,
+including `specific_message_id`; its caret opens the host's existing picker.
+Inline Source pills use the link glyph instead of a `Source:` prefix, followed by
+the item's icon and title; side panels retain the separate property label.
+Let the linked item's renderer fill its icon slot with `iconSize: 'fill'`; a
+fixed-size child in a smaller wrapper shifts the icon below the label.
+Empty Source values use the same link glyph; unsupported references retain the
+ordinary property editor.
+
`EntityRowTags.collapse` connects to the host's shared priority-overflow controller.
Show at most three individual chips by default and keep the rest in overflow.
Measure actual title, tag, and control widths; collapse more trailing chips when
diff --git a/apps/web/src/features/property/component/PropertyValuePill.tsx b/apps/web/src/features/property/component/PropertyValuePill.tsx
index f580a57308..27d7a26b2c 100644
--- a/apps/web/src/features/property/component/PropertyValuePill.tsx
+++ b/apps/web/src/features/property/component/PropertyValuePill.tsx
@@ -1,9 +1,11 @@
import { cn } from '@ui';
import { type ComponentProps, type JSX, Match, Show, Switch } from 'solid-js';
import { Dynamic } from 'solid-js/web';
+import { SYSTEM_PROPERTY_IDS } from '../identifiers';
import { Property } from '../property';
import { getEntityValues, hasValue } from '../utils';
import { ProjectLinkPill } from './ProjectLinkPill';
+import { SourceLinkPill } from './SourceLinkPill';
type PropertyValuePillProps = Pick<
ComponentProps<typeof Property.Root>,
@@ -48,7 +50,14 @@ export function PropertyValuePill(props: PropertyValuePillProps) {
variant={props.variant ?? 'outline'}
size={props.size}
>
- <Show when={props.showLabel && hasValue(property())}>
+ <Show
+ when={
+ props.showLabel &&
+ property().propertyDefinitionId !==
+ SYSTEM_PROPERTY_IDS.SOURCE &&
+ hasValue(property())
+ }
+ >
<span class="shrink-0 text-ink-muted">
{property().displayName}:
</span>
@@ -99,14 +108,29 @@ export function PropertyValuePill(props: PropertyValuePillProps) {
actions={props.hoverActions}
trailingAction={props.hoverTrailingAction}
>
- <Show when={props.opensProject} fallback={pill()}>
- <ProjectLinkPill
- property={property()}
- class={props.class}
- iconClass={props.iconClass}
- fallback={pill()}
- />
- </Show>
+ <Switch fallback={pill()}>
+ <Match
+ when={
+ property().propertyDefinitionId ===
+ SYSTEM_PROPERTY_IDS.SOURCE
+ }
+ >
+ <SourceLinkPill
+ property={property()}
+ class={props.class}
+ iconClass={props.iconClass}
+ fallback={pill()}
+ />
+ </Match>
+ <Match when={props.opensProject}>
+ <ProjectLinkPill
+ property={property()}
+ class={props.class}
+ iconClass={props.iconClass}
+ fallback={pill()}
+ />
+ </Match>
+ </Switch>
</Property.Tooltip>
<Dynamic
component={props.editor ?? Property.PopoverEditor}
diff --git a/apps/web/src/features/property/component/SourceLinkPill.tsx b/apps/web/src/features/property/component/SourceLinkPill.tsx
new file mode 100644
index 0000000000..4b207cf8b9
--- /dev/null
+++ b/apps/web/src/features/property/component/SourceLinkPill.tsx
@@ -0,0 +1,93 @@
+import { t } from '@app/lib/i18n';
+import { openDocument } from '@core/component/LexicalMarkdown/component/core/BlockLink';
+import CaretDownIcon from '@icon/system/regular/caret-down.svg';
+import SourceIcon from '@icon/system/regular/link.svg';
+import { createCallback } from '@solid-primitives/rootless';
+import { ButtonGroup, cn } from '@ui';
+import { type JSX, Show } from 'solid-js';
+import { useProperty } from '../core/context';
+import { usePropertyEntityDisplay } from '../hooks/usePropertyEntityDisplay';
+import type { Property } from '../types';
+import { getEntityValues } from '../utils/typeGuards';
+
+/** The item opens through the mention-link path; the caret edits the reference. */
+export function SourceLinkPill(props: {
+ property: Property;
+ fallback: JSX.Element;
+ class?: string;
+ iconClass?: string;
+ variant?: 'secondary' | 'ghost';
+ showSourceIcon?: boolean;
+}) {
+ const ctx = useProperty();
+ const reference = () => getEntityValues(props.property)[0];
+ const display = usePropertyEntityDisplay(
+ () => reference()?.entity_id ?? '',
+ () => reference()?.entity_type,
+ {
+ iconSize: 'fill',
+ specificMessageId: () => reference()?.specific_message_id,
+ loadingName: () => ctx.pickedEntityName(reference()?.entity_id ?? ''),
+ }
+ );
+ const open = createCallback((event: MouseEvent) => {
+ event.stopPropagation();
+ const source = reference();
+ const type = display.blockOrFileType();
+ if (!source || !type) return;
+ openDocument(type, source.entity_id, display.linkParams(), event.shiftKey);
+ });
+
+ return (
+ <Show
+ when={reference() && display.blockOrFileType()}
+ fallback={props.fallback}
+ >
+ <ButtonGroup
+ variant={props.variant ?? 'secondary'}
+ finish={props.variant === 'ghost' ? undefined : 'raised'}
+ size="xs"
+ class={cn('min-w-0 max-w-full border-0', props.class)}
+ >
+ <ButtonGroup.Button
+ data-property-row-action
+ aria-label={t('entityActions.openSourceNamed', {
+ name: display.name(),
+ })}
+ class="min-w-0 shrink justify-start"
+ onClick={open}
+ >
+ <Show when={props.showSourceIcon !== false}>
+ <SourceIcon
+ class={cn('size-3 shrink-0 text-ink-muted', props.iconClass)}
+ />
+ </Show>
+ <span
+ aria-hidden="true"
+ class={cn(
+ 'inline-flex size-3 shrink-0 items-center justify-center',
+ props.iconClass
+ )}
+ >
+ {display.icon()}
+ </span>
+ <span class="min-w-0 max-w-60 truncate">{display.name()}</span>
+ </ButtonGroup.Button>
+ <Show when={ctx.canEdit()}>
+ <ButtonGroup.Divider />
+ <ButtonGroup.Button
+ size="icon-xs"
+ aria-label={t('entityActions.changeSource')}
+ aria-expanded={ctx.editorOpen()}
+ onClick={(event) => {
+ event.stopPropagation();
+ ctx.openEditor(event.currentTarget);
+ }}
+ >
+ <CaretDownIcon class="size-3 shrink-0" />
+ </ButtonGroup.Button>
+ </Show>
+ </ButtonGroup>
+ </Show>
+ );
+}
diff --git a/apps/web/src/features/property/extractors/PropertyEmpty.tsx b/apps/web/src/features/property/extractors/PropertyEmpty.tsx
index bd99d3b7e7..5743499a29 100644
--- a/apps/web/src/features/property/extractors/PropertyEmpty.tsx
+++ b/apps/web/src/features/property/extractors/PropertyEmpty.tsx
@@ -1,6 +1,7 @@
import NoDueDateIcon from '@icon/system/regular/calendar-slash.svg';
import CircleDashedEmpty from '@icon/system/regular/circle-dashed.svg';
import ProjectIcon from '@icon/system/regular/cube-dashed.svg';
+import SourceIcon from '@icon/system/regular/link.svg';
import PersonIcon from '@icon/system/regular/user-circle-dashed.svg';
import PriorityNoneIcon from '@icon/wide-priority-none.svg';
import { cn } from '@ui';
@@ -26,6 +27,9 @@ export function PropertyEmptyIcon(props: {
/>
}
>
+ <Match when={props.propertyDefinitionId === SYSTEM_PROPERTY_IDS.SOURCE}>
+ <SourceIcon class={cn('size-full', props.muted && 'opacity-50')} />
+ </Match>
<Match
when={props.propertyDefinitionId === SYSTEM_PROPERTY_IDS.DUE_DATE}
>
diff --git a/apps/web/src/features/property/extractors/PropertyIcon.tsx b/apps/web/src/features/property/extractors/PropertyIcon.tsx
index 9da5763000..e826fbb77f 100644
--- a/apps/web/src/features/property/extractors/PropertyIcon.tsx
+++ b/apps/web/src/features/property/extractors/PropertyIcon.tsx
@@ -1,9 +1,11 @@
import { UserIcon } from '@core/component/UserIcon';
import ProjectIcon from '@icon/system/regular/cube.svg';
+import SourceIcon from '@icon/system/regular/link.svg';
import CalendarIcon from '@phosphor/calendar-blank.svg';
import { PropertyValueIcon } from '@property/component/propertyValue/PropertyValueIcon';
import { cn } from '@ui';
import { type JSX, Show } from 'solid-js';
+import { SYSTEM_PROPERTY_IDS } from '../identifiers';
import type { Property } from '../types';
import { getEntityValues, getSelectValues } from '../utils';
@@ -16,6 +18,7 @@ type Props = {
* Renders the icon associated with a property's value:
* - SELECT_*: option icon for the first value (status/priority icons).
* - ENTITY+USER: avatar for the first user.
+ * - Source: link icon.
* - ENTITY+INITIATIVE: project icon when the property has a value.
* - DATE: calendar icon.
* - everything else: null (extractor stays uninvolved).
@@ -23,6 +26,9 @@ type Props = {
* Uses compact defaults; callers can override sizing and spacing.
*/
export function PropertyIcon(props: Props): JSX.Element {
+ if (props.property.propertyDefinitionId === SYSTEM_PROPERTY_IDS.SOURCE) {
+ return <SourceIcon class={cn('size-3 shrink-0', props.class)} />;
+ }
if (props.property.valueType === 'DATE') {
return <CalendarIcon class={cn('size-3 shrink-0', props.class)} />;
}
diff --git a/apps/web/src/features/property/hooks/usePropertyEntityDisplay.test.tsx b/apps/web/src/features/property/hooks/usePropertyEntityDisplay.test.tsx
index 015c025870..2ebe4720e4 100644
--- a/apps/web/src/features/property/hooks/usePropertyEntityDisplay.test.tsx
+++ b/apps/web/src/features/property/hooks/usePropertyEntityDisplay.test.tsx
@@ -344,3 +344,22 @@ describe('usePropertyEntityDisplay CRM references', () => {
}
);
});
+
+it('retains exact message navigation when the source changes within one channel', () => {
+ const [messageId, setMessageId] = createSignal<string | undefined>('reply');
+ const display = createRoot((dispose) => {
+ disposals.push(dispose);
+ return usePropertyEntityDisplay(
+ () => 'channel',
+ () => 'CHANNEL',
+ {
+ specificMessageId: messageId,
+ }
+ );
+ });
+ expect(display.linkParams()).toEqual({ channel_message_id: 'reply' });
+ setMessageId('other-reply');
+ expect(display.linkParams()).toEqual({ channel_message_id: 'other-reply' });
+ setMessageId(undefined);
+ expect(display.linkParams()).toBeUndefined();
+});
diff --git a/apps/web/src/features/property/hooks/usePropertyEntityDisplay.tsx b/apps/web/src/features/property/hooks/usePropertyEntityDisplay.tsx
index c18138b67c..2eac6d4fdc 100644
--- a/apps/web/src/features/property/hooks/usePropertyEntityDisplay.tsx
+++ b/apps/web/src/features/property/hooks/usePropertyEntityDisplay.tsx
@@ -1,6 +1,9 @@
import { useFeatureFlag } from '@app/lib/analytics/posthog';
import { URL_PARAMS as CHANNEL_PARAMS } from '@block-channel/constants';
-import { EntityIcon as CoreEntityIcon } from '@core/component/EntityIcon';
+import {
+ EntityIcon as CoreEntityIcon,
+ type EntityIconProps,
+} from '@core/component/EntityIcon';
import { UserIcon } from '@core/component/UserIcon';
import { fileTypeToBlockName } from '@core/constant/allBlocks';
import { enableProjects } from '@core/constant/featureFlags';
@@ -68,6 +71,8 @@ export function usePropertyEntityDisplay(
options?: {
/** Custom fallback icon for unknown entity types (null to show nothing) */
fallbackIcon?: JSX.Element | null;
+ /** Size passed to the entity icon renderer; defaults to xs. */
+ iconSize?: EntityIconProps['size'];
/** Specific message ID for THREAD/CHANNEL/CHAT entities */
specificMessageId?: Accessor<string | null | undefined>;
/** Name to show while the entity's own read loads, such as a picker's label. */
@@ -168,29 +173,59 @@ export function usePropertyEntityDisplay(
.with('USER', () => (
<UserIcon id={entityId()} size="sm" photoUrl={user.photoUrl()} />
))
- .with('CHANNEL', () => <CoreEntityIcon targetType="channel" size="xs" />)
- .with('TASK', () => <CoreEntityIcon targetType="task" size="xs" />)
+ .with('CHANNEL', () => (
+ <CoreEntityIcon targetType="channel" size={options?.iconSize ?? 'xs'} />
+ ))
+ .with('TASK', () => (
+ <CoreEntityIcon targetType="task" size={options?.iconSize ?? 'xs'} />
+ ))
.with('DOCUMENT', () => {
const item = preview();
if (!item || !isAccessiblePreviewItem(item)) {
- return <CoreEntityIcon targetType="unknown" size="xs" />;
+ return (
+ <CoreEntityIcon
+ targetType="unknown"
+ size={options?.iconSize ?? 'xs'}
+ />
+ );
}
const { subType, fileType } = item;
const blockName = fileTypeToBlockName(subType?.type ?? fileType, true);
- return <CoreEntityIcon targetType={blockName} size="xs" />;
+ return (
+ <CoreEntityIcon
+ targetType={blockName}
+ size={options?.iconSize ?? 'xs'}
+ />
+ );
})
- .with('PROJECT', () => <CoreEntityIcon targetType="project" size="xs" />)
- .with('CHAT', () => <CoreEntityIcon targetType="chat" size="xs" />)
+ .with('PROJECT', () => (
+ <CoreEntityIcon targetType="project" size={options?.iconSize ?? 'xs'} />
+ ))
+ .with('CHAT', () => (
+ <CoreEntityIcon targetType="chat" size={options?.iconSize ?? 'xs'} />
+ ))
.with('COMPANY', () => (
- <CoreEntityIcon targetType="crm_company" size="xs" />
+ <CoreEntityIcon
+ targetType="crm_company"
+ size={options?.iconSize ?? 'xs'}
+ />
+ ))
+ .with('CONTACT', () => (
+ <CoreEntityIcon targetType="contact" size={options?.iconSize ?? 'xs'} />
+ ))
+ .with('THREAD', () => (
+ <CoreEntityIcon targetType="email" size={options?.iconSize ?? 'xs'} />
))
- .with('CONTACT', () => <CoreEntityIcon targetType="contact" size="xs" />)
- .with('THREAD', () => <CoreEntityIcon targetType="email" size="xs" />)
.otherwise(() => {
if (options && 'fallbackIcon' in options) {
return options.fallbackIcon;
}
- return <CoreEntityIcon targetType="unknown" size="xs" />;
+ return (
+ <CoreEntityIcon
+ targetType="unknown"
+ size={options?.iconSize ?? 'xs'}
+ />
+ );
})
);
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 5a9d80c4f3..7c6c4881f5 100644
--- a/apps/web/src/features/property/side-panel/properties/EntityPropertiesSection.tsx
+++ b/apps/web/src/features/property/side-panel/properties/EntityPropertiesSection.tsx
@@ -10,6 +10,7 @@ import { AddPropertyButton } from '@property/component/AddPropertyButton';
import { Modals } from '@property/component/modal';
import { ProjectLinkPill } from '@property/component/ProjectLinkPill';
import { PropertyValueIcon } from '@property/component/propertyValue/PropertyValueIcon';
+import { SourceLinkPill } from '@property/component/SourceLinkPill';
import {
PropertiesProvider,
type PropertySaveHandler,
@@ -764,14 +765,29 @@ function SinglePill(props: {
return (
<PropertyNS.Tooltip property={props.property}>
- <Show when={props.opensProject} fallback={pill()}>
- <ProjectLinkPill
- property={props.property}
- variant="ghost"
- iconClass="touch:size-4"
- fallback={pill()}
- />
- </Show>
+ <Switch fallback={pill()}>
+ <Match
+ when={
+ props.property.propertyDefinitionId === SYSTEM_PROPERTY_IDS.SOURCE
+ }
+ >
+ <SourceLinkPill
+ property={props.property}
+ showSourceIcon={false}
+ variant="ghost"
+ iconClass="touch:size-4"
+ fallback={pill()}
+ />
+ </Match>
+ <Match when={props.opensProject}>
+ <ProjectLinkPill
+ property={props.property}
+ variant="ghost"
+ iconClass="touch:size-4"
+ fallback={pill()}
+ />
+ </Match>
+ </Switch>
</PropertyNS.Tooltip>
);
}
diff --git a/apps/web/src/features/task-composer/property-defaults.ts b/apps/web/src/features/task-composer/property-defaults.ts
new file mode 100644
index 0000000000..06129b3694
--- /dev/null
+++ b/apps/web/src/features/task-composer/property-defaults.ts
@@ -0,0 +1,10 @@
+import { SYSTEM_PROPERTY_IDS } from '@property/identifiers';
+
+/** Default composer order; hosts append contextual properties to this list. */
+export const DEFAULT_TASK_COMPOSER_PROPERTY_IDS = [
+ SYSTEM_PROPERTY_IDS.STATUS,
+ SYSTEM_PROPERTY_IDS.PRIORITY,
+ SYSTEM_PROPERTY_IDS.ASSIGNEES,
+ SYSTEM_PROPERTY_IDS.DUE_DATE,
+ SYSTEM_PROPERTY_IDS.PROJECT,
+];
diff --git a/apps/web/src/features/task-composer/source-context.ts b/apps/web/src/features/task-composer/source-context.ts
new file mode 100644
index 0000000000..538b2ebd25
--- /dev/null
+++ b/apps/web/src/features/task-composer/source-context.ts
@@ -0,0 +1,29 @@
+import {
+ enableTaskSourceProperty,
+ isFeatureEnabled,
+} from '@core/constant/featureFlags';
+import { SYSTEM_PROPERTY_IDS } from '@property/identifiers';
+import type { EntityReference } from '@service-properties/generated/schemas/entityReference';
+import type { TaskComposerContext } from './core/context';
+import { DEFAULT_TASK_COMPOSER_PROPERTY_IDS } from './property-defaults';
+
+/** Capture the source at the originating action, not after the composer mounts. */
+export function taskSourceComposerContext(
+ source: EntityReference
+): TaskComposerContext | undefined {
+ if (!isFeatureEnabled(enableTaskSourceProperty)) return;
+
+ return {
+ key: `source:${source.entity_type}:${source.entity_id}:${source.specific_message_id ?? ''}`,
+ visiblePropertyIds: [
+ ...DEFAULT_TASK_COMPOSER_PROPERTY_IDS,
+ SYSTEM_PROPERTY_IDS.SOURCE,
+ ],
+ initialPropertyValues: {
+ [SYSTEM_PROPERTY_IDS.SOURCE]: {
+ valueType: 'ENTITY',
+ refs: [{ ...source }],
+ },
+ },
+ };
+}
diff --git a/apps/web/src/lib/core/constant/featureFlags.ts b/apps/web/src/lib/core/constant/featureFlags.ts
index 08bcec2fa9..7961685f1c 100644
--- a/apps/web/src/lib/core/constant/featureFlags.ts
+++ b/apps/web/src/lib/core/constant/featureFlags.ts
@@ -546,6 +546,13 @@ export const enableProjects = defineFlag({
default: onInDev,
});
+/** Prefill the editable Source property from contextual task actions. */
+export const enableTaskSourceProperty = defineFlag({
+ key: 'enable-task-source-property',
+ env: 'ENABLE_TASK_SOURCE_PROPERTY',
+ default: onInDev,
+});
+
// Email snooze: the "Remind me" action, its 'h' shortcut, and the shared
// time-selection command menu.
// Every surface routes through `makeCreateReminderAction().canExecute`, so this
diff --git a/apps/web/src/lib/i18n/locales/en/entity-actions.ts b/apps/web/src/lib/i18n/locales/en/entity-actions.ts
index 763a9132f8..d657e057cb 100644
--- a/apps/web/src/lib/i18n/locales/en/entity-actions.ts
+++ b/apps/web/src/lib/i18n/locales/en/entity-actions.ts
@@ -44,6 +44,8 @@ export default {
addToProject: 'Add to project…',
openProjectNamed: 'Open project {{name}}',
changeProject: 'Change project',
+ openSourceNamed: 'Open source {{name}}',
+ changeSource: 'Change source',
moveToFolder: 'Move to folder',
removeFromFolder: 'Remove from folder',
duplicate: 'Duplicate',
diff --git a/docs/agent-guide/tasks.md b/docs/agent-guide/tasks.md
index 1dd639a9cf..14204e876a 100644
--- a/docs/agent-guide/tasks.md
+++ b/docs/agent-guide/tasks.md
@@ -890,6 +890,32 @@ To bring tasks over from Linear, Jira, Asana, and other apps, use the **Import
tasks** card at the bottom of the Tasks sidebar; see
[Import from connected apps](setup-cards.md#import-from-connected-apps).
+### Source experiment
+
+With `enable-task-source-property` enabled, **Create task** from an email thread,
+a channel message, or a document selection opens the composer with **Source**
+already populated and visible. Source is the existing single-item entity property,
+not description text or an external URL field. Channel sources retain the exact
+message ID, including replies. Existing description mentions remain unchanged.
+The local override is `VITE_ENABLE_TASK_SOURCE_PROPERTY=true`; development builds
+enable the experiment by default, while production defers to PostHog.
+
+Open the linked item from Source, or use its picker to replace or clear the value.
+A task opened without a source preset can add **Source** through **Add property**
+and select an existing Macro item, such as a document or task. Source uses the same
+mobile picker sheet as other entity properties. Arbitrary external URLs and
+multiple sources are outside the experiment.
+
+Verify email and channel task buttons before entering any composer text: Source
+must already show the link glyph and originating item's icon and title, without
+a `Source:` prefix. Confirm both glyphs stay vertically centered with the title
+on desktop and touch. Create the task and reopen it to confirm Source persists.
+For a channel reply, follow Source and confirm the exact reply
+opens; open and dismiss the picker without changing the value, then repeat.
+Replace Source with a document, clear Source, and recover an unconfirmed draft to
+check the selected value survives. Repeat on touch with the stacked picker sheet.
+Disable the flag and confirm the original task-button behavior remains unchanged.
+
## Projects
Projects are enabled by default in development. Production rollout is gated by