Macro is a unified workspace for teams: email, chat, docs, tasks, agents, calls, and CRM — @-linked together with shared AI memory.
TypeScript agentaiai-agentsall-in-onecrmcrm-systememaillinearmcpmessagingnotesnotionofficerustslackslack-alternativestartupstartup-toolstypescriptworkspace
feat(web): activity section in the entity side panel (#5597)
teo1442dc3d45ae
diff --git a/apps/web/src/features/activity/EntityActivitySection.tsx b/apps/web/src/features/activity/EntityActivitySection.tsxnew file mode 100644index 0000000000..a65de9a12f--- /dev/null+++ b/apps/web/src/features/activity/EntityActivitySection.tsx@@ -0,0 +1,126 @@+import { SidePanel } from '@components/app/side-panel/SidePanel';+import { formatRelativeTimestamp } from '@entity/utils/timestamp';+import CaretRightIcon from '@phosphor/caret-right.svg';+import {+ type ActivityEvent,+ createEntityActivityQuery,+} from '@queries/activity/graphql/entity';+import type { EntityType } from '@service-properties/generated/schemas/entityType';+import { cn } from '@ui';+import { createSignal, For, Show, Suspense } from 'solid-js';+import { ActionPhrase } from './action-phrase';+import { ActorName } from './actor-name';+import { useEntityActivityFlag } from './use-entity-activity-flag';++/** Rows shown before the section collapses behind a "Show all" toggle. */+const COLLAPSED_ROW_LIMIT = 10;++export interface EntityActivitySectionProps {+ entityId: string;+ entityType: EntityType;+ order?: number;+}++/**+ * The side-panel Activity section, mounted only when the feature flag is on+ * so the activity query is never issued while the rollout is off.+ */+export function EntityActivitySectionConditional(+ props: EntityActivitySectionProps+) {+ const enabled = useEntityActivityFlag();+ return (+ <Show when={enabled()}>+ <EntityActivitySection {...props} />+ </Show>+ );+}++function EntityActivitySection(props: EntityActivitySectionProps) {+ const query = createEntityActivityQuery({+ entityType: () => props.entityType,+ entityId: () => props.entityId,+ enabled: () => true,+ });+ const events = () => query.result.data ?? [];++ // Collapsed to the newest rows, expandable like the History pane's+ // "Show activity" toggle, so a busy entity doesn't swallow the side panel.+ const [expanded, setExpanded] = createSignal(false);+ const visibleEvents = () =>+ expanded() ? events() : events().slice(0, COLLAPSED_ROW_LIMIT);+ const hasOverflow = () => events().length > COLLAPSED_ROW_LIMIT;++ return (+ <Show when={query.isEnabled()}>+ <SidePanel.Section id="activity" title="Activity" order={props.order}>+ {/* Two loading layers: the urql store never suspends, so the query's+ own fetch/error need explicit branches (or they'd render as a+ false "No activity yet"), while the Suspense boundary scopes+ resource reads inside the rows (display names, property+ definitions) to this section instead of an ancestor boundary. */}+ <Suspense fallback={<SidePanel.Loading />}>+ <Show when={!query.result.isLoading} fallback={<SidePanel.Loading />}>+ <Show+ when={!query.result.isError}+ fallback={<SidePanel.EmptyPill label="Activity is unavailable" />}+ >+ <Show+ when={events().length > 0}+ fallback={<SidePanel.EmptyPill label="No activity yet" />}+ >+ <div class="text-xs">+ <SidePanel.Card>+ <For each={visibleEvents()}>+ {(event) => <ActivityRow event={event} />}+ </For>+ </SidePanel.Card>+ <Show when={hasOverflow()}>+ <button+ type="button"+ aria-expanded={expanded()}+ class="mt-1 flex w-full items-center gap-1.5 rounded-md px-1 py-1 text-ink-muted text-xs hover:bg-hover hover:text-ink focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent/40"+ onClick={() => setExpanded((current) => !current)}+ >+ <CaretRightIcon+ class={cn(+ 'size-3 shrink-0 transition-transform duration-90',+ expanded() && 'rotate-90'+ )}+ />+ <span>+ {expanded()+ ? 'Show less'+ : `Show all (${events().length})`}+ </span>+ </button>+ </Show>+ </div>+ </Show>+ </Show>+ </Show>+ </Suspense>+ </SidePanel.Section>+ </Show>+ );+}++function ActivityRow(props: { event: ActivityEvent }) {+ return (+ <div class="flex min-h-7 min-w-0 items-center gap-2 px-2 py-1">+ <span class="flex min-w-0 flex-1 flex-wrap items-center gap-x-1 gap-y-0.5">+ <span class="font-medium text-ink">+ <ActorName actorId={props.event.actorId} />+ </span>+ <span class="min-w-0 text-ink-muted">+ <ActionPhrase event={props.event} />+ </span>+ </span>+ <span class="ml-auto shrink-0 text-ink-extra-muted">+ {formatRelativeTimestamp(new Date(props.event.occurredAt), {+ condensed: true,+ })}+ </span>+ </div>+ );+}diff --git a/apps/web/src/features/activity/action-glyph.tsx b/apps/web/src/features/activity/action-glyph.tsxnew file mode 100644index 0000000000..39282c810c--- /dev/null+++ b/apps/web/src/features/activity/action-glyph.tsx@@ -0,0 +1,39 @@+import ChatCircle from '@phosphor/chat-circle.svg';+import Eye from '@phosphor/eye.svg';+import PaperPlaneTilt from '@phosphor/paper-plane-tilt.svg';+import PencilSimple from '@phosphor/pencil-simple.svg';+import Phone from '@phosphor/phone.svg';+import Plus from '@phosphor/plus.svg';+import SlidersHorizontal from '@phosphor/sliders-horizontal.svg';+import Trash from '@phosphor/trash.svg';+import UserMinus from '@phosphor/user-minus.svg';+import UserPlus from '@phosphor/user-plus.svg';+import type { ActivityEvent } from '@queries/activity/graphql/entity';+import { Dynamic } from 'solid-js/web';++const GLYPHS = {+ GraphqlActivityCreated: Plus,+ GraphqlActivityEdited: PencilSimple,+ GraphqlActivityOpened: Eye,+ GraphqlActivityDeleted: Trash,+ GraphqlActivityMessaged: ChatCircle,+ GraphqlActivitySent: PaperPlaneTilt,+ GraphqlActivityPropertyChanged: SlidersHorizontal,+ GraphqlActivityParticipantAdded: UserPlus,+ GraphqlActivityParticipantRemoved: UserMinus,+ GraphqlActivityCallStarted: Phone,+ GraphqlActivityUnknownAction: PencilSimple,+} as const;++/** A small icon for the kind of action, for glyph-led activity rows. */+export function ActionGlyph(props: {+ action: ActivityEvent['action'];+ class?: string;+}) {+ return (+ <Dynamic+ component={GLYPHS[props.action.__typename]}+ class={props.class ?? 'size-3'}+ />+ );+}diff --git a/apps/web/src/features/activity/action-phrase.tsx b/apps/web/src/features/activity/action-phrase.tsxnew file mode 100644index 0000000000..4805872b30--- /dev/null+++ b/apps/web/src/features/activity/action-phrase.tsx@@ -0,0 +1,20 @@+import type { ActivityEvent } from '@queries/activity/graphql/entity';+import { Show } from 'solid-js';+import { actionAsPropertyChange, describeAction } from './describe-action';+import { PropertyChangeText } from './property-change';++/**+ * The verb half of an activity row: property changes render their resolved+ * transition ("changed Status from … to …"), everything else the plain verb+ * phrase.+ */+export function ActionPhrase(props: { event: ActivityEvent }) {+ return (+ <Show+ when={actionAsPropertyChange(props.event.action)}+ fallback={describeAction(props.event.action)}+ >+ {(change) => <PropertyChangeText action={change()} />}+ </Show>+ );+}diff --git a/apps/web/src/features/activity/actor-name.tsx b/apps/web/src/features/activity/actor-name.tsxnew file mode 100644index 0000000000..e2cdfb8a7b--- /dev/null+++ b/apps/web/src/features/activity/actor-name.tsx@@ -0,0 +1,32 @@+import { useUserId } from '@core/context/user';+import { tryMacroId, useDisplayName } from '@core/user';+import type { MacroId } from '@core/user/macroId';+import { Show } from 'solid-js';++/**+ * The actor of an activity row: "You" for the viewer, the display name+ * (local-part email fallback, never the full address) for other users, and+ * "Automation" for bot principals.+ */+export function ActorName(props: { actorId: string }) {+ const userId = useUserId();+ const macroId = () => tryMacroId(props.actorId);++ return (+ <Show when={macroId()} fallback={<>Automation</>}>+ {(id) => (+ <Show+ when={props.actorId === userId()}+ fallback={<RemoteName id={id()} />}+ >+ You+ </Show>+ )}+ </Show>+ );+}++function RemoteName(props: { id: MacroId }) {+ const [name] = useDisplayName(props.id, { emailFallback: 'local-part' });+ return <>{name()}</>;+}diff --git a/apps/web/src/features/activity/describe-action.test.ts b/apps/web/src/features/activity/describe-action.test.tsnew file mode 100644index 0000000000..b254b88f91--- /dev/null+++ b/apps/web/src/features/activity/describe-action.test.ts@@ -0,0 +1,84 @@+import { describe, expect, it } from 'vitest';+import { describeAction, describeActionForEntity } from './describe-action';++describe('describeAction', () => {+ it('describes every known action with a verb phrase', () => {+ expect(describeAction({ __typename: 'GraphqlActivityCreated' })).toBe(+ 'created this'+ );+ expect(describeAction({ __typename: 'GraphqlActivityEdited' })).toBe(+ 'made an edit'+ );+ expect(describeAction({ __typename: 'GraphqlActivityOpened' })).toBe(+ 'opened this'+ );+ expect(describeAction({ __typename: 'GraphqlActivityDeleted' })).toBe(+ 'deleted this'+ );+ expect(describeAction({ __typename: 'GraphqlActivityMessaged' })).toBe(+ 'sent a message'+ );+ expect(describeAction({ __typename: 'GraphqlActivitySent' })).toBe(+ 'sent an email'+ );+ expect(+ describeAction({+ __typename: 'GraphqlActivityPropertyChanged',+ property: 'prop-1',+ from: null,+ to: 'Done',+ })+ ).toBe('changed a property');+ expect(+ describeAction({+ __typename: 'GraphqlActivityParticipantAdded',+ participant: 'macro|[email protected]',+ })+ ).toBe('added a participant');+ expect(+ describeAction({+ __typename: 'GraphqlActivityParticipantRemoved',+ participant: 'macro|[email protected]',+ })+ ).toBe('removed a participant');+ expect(+ describeAction({+ __typename: 'GraphqlActivityCallStarted',+ callId: 'call-1',+ })+ ).toBe('started a call');+ });++ it('pairs entity-directed verbs with their natural connector', () => {+ expect(+ describeActionForEntity({ __typename: 'GraphqlActivityCreated' })+ ).toEqual({ verb: 'created' });+ expect(+ describeActionForEntity({ __typename: 'GraphqlActivityMessaged' })+ ).toEqual({ verb: 'sent a message', connector: 'in' });+ expect(+ describeActionForEntity({+ __typename: 'GraphqlActivityParticipantAdded',+ participant: 'macro|[email protected]',+ })+ ).toEqual({ verb: 'added a participant', connector: 'to' });+ expect(+ describeActionForEntity({+ __typename: 'GraphqlActivityPropertyChanged',+ property: 'prop-1',+ from: null,+ to: 'Done',+ })+ ).toEqual({ verb: 'changed a property', connector: 'on' });+ });++ it('humanizes the raw tag of an unknown action instead of hiding it', () => {+ expect(+ describeAction({+ __typename: 'GraphqlActivityUnknownAction',+ tag: 'transmogrified_thoroughly',+ payload: null,+ })+ ).toBe('transmogrified thoroughly');+ });+});diff --git a/apps/web/src/features/activity/describe-action.ts b/apps/web/src/features/activity/describe-action.tsnew file mode 100644index 0000000000..9d5ed5fb6b--- /dev/null+++ b/apps/web/src/features/activity/describe-action.ts@@ -0,0 +1,105 @@+import type { ActivityEvent } from '@queries/activity/graphql/entity';+import { match } from 'ts-pattern';++type ActivityAction = ActivityEvent['action'];++/**+ * Narrows an action to its property-change member, for rows that render+ * the richer "changed X from A to B" phrase instead of [`describeAction`].+ */+export function actionAsPropertyChange(+ action: ActivityAction+):+ | Extract<ActivityAction, { __typename: 'GraphqlActivityPropertyChanged' }>+ | undefined {+ return action.__typename === 'GraphqlActivityPropertyChanged'+ ? action+ : undefined;+}++/**+ * Short verb phrase for one activity action, phrased to follow an actor+ * name: "Sarah <created this>". Unknown actions (rows written by a newer+ * deployment) fall back to their humanized raw tag rather than hiding the+ * row.+ */+export function describeAction(action: ActivityAction): string {+ return match(action)+ .with({ __typename: 'GraphqlActivityCreated' }, () => 'created this')+ .with({ __typename: 'GraphqlActivityEdited' }, () => 'made an edit')+ .with({ __typename: 'GraphqlActivityOpened' }, () => 'opened this')+ .with({ __typename: 'GraphqlActivityDeleted' }, () => 'deleted this')+ .with({ __typename: 'GraphqlActivityMessaged' }, () => 'sent a message')+ .with({ __typename: 'GraphqlActivitySent' }, () => 'sent an email')+ .with(+ { __typename: 'GraphqlActivityPropertyChanged' },+ () => 'changed a property'+ )+ .with(+ { __typename: 'GraphqlActivityParticipantAdded' },+ () => 'added a participant'+ )+ .with(+ { __typename: 'GraphqlActivityParticipantRemoved' },+ () => 'removed a participant'+ )+ .with({ __typename: 'GraphqlActivityCallStarted' }, () => 'started a call')+ .with({ __typename: 'GraphqlActivityUnknownAction' }, (unknown) =>+ unknown.tag.replaceAll('_', ' ')+ )+ .exhaustive();+}++/**+ * The verb for a row that names its entity: "<actor> <verb> [connector]+ * <entity>". Direct-object actions carry no connector ("created *Doc*");+ * located actions carry the natural preposition ("sent a message *in*+ * #general", "changed Status *on* *Doc*").+ */+export function describeActionForEntity(action: ActivityAction): {+ verb: string;+ connector?: string;+} {+ return (+ match(action)+ .with({ __typename: 'GraphqlActivityCreated' }, () => ({+ verb: 'created',+ }))+ .with({ __typename: 'GraphqlActivityEdited' }, () => ({ verb: 'edited' }))+ .with({ __typename: 'GraphqlActivityOpened' }, () => ({ verb: 'opened' }))+ .with({ __typename: 'GraphqlActivityDeleted' }, () => ({+ verb: 'deleted',+ }))+ .with({ __typename: 'GraphqlActivityMessaged' }, () => ({+ verb: 'sent a message',+ connector: 'in',+ }))+ .with({ __typename: 'GraphqlActivitySent' }, () => ({+ verb: 'sent an email',+ connector: 'in',+ }))+ // The caller renders the full transition phrase; only the connector+ // is needed for property changes.+ .with({ __typename: 'GraphqlActivityPropertyChanged' }, () => ({+ verb: 'changed a property',+ connector: 'on',+ }))+ .with({ __typename: 'GraphqlActivityParticipantAdded' }, () => ({+ verb: 'added a participant',+ connector: 'to',+ }))+ .with({ __typename: 'GraphqlActivityParticipantRemoved' }, () => ({+ verb: 'removed a participant',+ connector: 'from',+ }))+ .with({ __typename: 'GraphqlActivityCallStarted' }, () => ({+ verb: 'started a call',+ connector: 'in',+ }))+ .with({ __typename: 'GraphqlActivityUnknownAction' }, (unknown) => ({+ verb: unknown.tag.replaceAll('_', ' '),+ connector: 'on',+ }))+ .exhaustive()+ );+}diff --git a/apps/web/src/features/activity/entity-mention.tsx b/apps/web/src/features/activity/entity-mention.tsxnew file mode 100644index 0000000000..f3f1baa041--- /dev/null+++ b/apps/web/src/features/activity/entity-mention.tsx@@ -0,0 +1,53 @@+import { StaticMarkdown } from '@core/component/LexicalMarkdown/component/core/StaticMarkdown';+import { unifiedListMarkdownTheme } from '@core/component/LexicalMarkdown/theme';+import { usePropertyEntityDisplay } from '@property/hooks';+import type { EntityType } from '@service-properties/generated/schemas/entityType';+import { Show } from 'solid-js';++/**+ * An activity row's entity reference rendered as a real document mention —+ * the same decorator the editor and notification rows use, with its hover+ * preview, access states, and click-to-open. Entity kinds without a block+ * mapping fall back to a plain icon + name chip.+ *+ * Must render under a `<StaticMarkdownContext>` ancestor.+ */+export function EntityMention(props: {+ entityId: string;+ entityType: EntityType;+}) {+ const display = usePropertyEntityDisplay(+ () => props.entityId,+ () => props.entityType+ );++ const mentionMarkdown = () => {+ const blockName = display.blockOrFileType();+ if (!blockName) return undefined;+ return `<m-document-mention>${JSON.stringify({+ documentId: props.entityId,+ documentName: display.name(),+ blockName,+ })}</m-document-mention>`;+ };++ return (+ <Show+ when={mentionMarkdown()}+ fallback={+ <span class="inline-flex min-w-0 items-center gap-1.5 text-ink">+ <span class="flex shrink-0 items-center">{display.icon()}</span>+ <span class="truncate">{display.name()}</span>+ </span>+ }+ >+ {(markdown) => (+ <StaticMarkdown+ markdown={markdown()}+ theme={unifiedListMarkdownTheme}+ singleLine+ />+ )}+ </Show>+ );+}diff --git a/apps/web/src/features/activity/property-change-label.ts b/apps/web/src/features/activity/property-change-label.tsnew file mode 100644index 0000000000..9383daa060--- /dev/null+++ b/apps/web/src/features/activity/property-change-label.ts@@ -0,0 +1,114 @@+import type { PropertyDefinitionDomain } from '@property/types';+import {+ formatBoolean,+ formatDate,+ formatNumber,+ formatOptionValue,+} from '@property/utils/formatting';++/** One resolved select option of a stored property value. */+export type SelectOptionEntry = {+ id: string;+ label: string;+ color: string | null;+};++/**+ * Resolves a stored SelectOption value into its options (label + tag color),+ * for rendering with the property system's option pills. Returns undefined+ * for non-select values or when no option resolves, so callers fall back to+ * the plain text label path.+ */+export function selectOptionEntries(+ raw: unknown,+ definition: PropertyDefinitionDomain | undefined+): SelectOptionEntry[] | undefined {+ const tagged = asTaggedValue(raw);+ if (+ !tagged ||+ tagged.type !== 'SelectOption' ||+ !Array.isArray(tagged.value)+ ) {+ return undefined;+ }+ const entries = tagged.value+ .filter((id): id is string => typeof id === 'string')+ .flatMap((id) => {+ const option = definition?.options?.find((o) => o.id === id);+ if (!option) return [];+ return [+ { id, label: formatOptionValue(option), color: option.color ?? null },+ ];+ });+ return entries.length > 0 ? entries : undefined;+}++/**+ * The stored property payload: models_properties' tagged PropertyValue+ * (`{"type": "SelectOption", "value": ["uuid"]}` …). Arrives as untyped+ * JSON, so parse defensively — an unrecognized shape renders no label+ * rather than garbage.+ */+function asTaggedValue(+ raw: unknown+): { type: string; value: unknown } | undefined {+ if (raw === null || typeof raw !== 'object') return undefined;+ const record = raw as Record<string, unknown>;+ if (typeof record.type !== 'string' || !('value' in record)) return undefined;+ return { type: record.type, value: record.value };+}++/**+ * Human label for one stored property value, resolved against the+ * property's definition (select-option ids → option names). Returns+ * undefined when the value can't be labeled, so callers can fall back to+ * generic wording instead of showing raw ids.+ */+export function propertyValueLabel(+ raw: unknown,+ definition: PropertyDefinitionDomain | undefined+): string | undefined {+ const tagged = asTaggedValue(raw);+ if (!tagged) return undefined;++ switch (tagged.type) {+ case 'String':+ return typeof tagged.value === 'string' ? tagged.value : undefined;+ case 'Number':+ return typeof tagged.value === 'number'+ ? formatNumber(tagged.value)+ : undefined;+ case 'Boolean':+ return typeof tagged.value === 'boolean'+ ? formatBoolean(tagged.value)+ : undefined;+ case 'Date':+ return typeof tagged.value === 'string'+ ? formatDate(tagged.value)+ : undefined;+ case 'SelectOption': {+ if (!Array.isArray(tagged.value)) return undefined;+ const labels = tagged.value+ .filter((id): id is string => typeof id === 'string')+ .map((id) => {+ const option = definition?.options?.find((o) => o.id === id);+ return option ? formatOptionValue(option) : undefined;+ })+ .filter((label): label is string => label !== undefined);+ return labels.length > 0 ? labels.join(', ') : undefined;+ }+ case 'Link':+ return Array.isArray(tagged.value)+ ? tagged.value.filter((v) => typeof v === 'string').join(', ') ||+ undefined+ : undefined;+ case 'EntityReference':+ return Array.isArray(tagged.value) && tagged.value.length > 0+ ? tagged.value.length === 1+ ? 'an item'+ : `${tagged.value.length} items`+ : undefined;+ default:+ return undefined;+ }+}diff --git a/apps/web/src/features/activity/property-change.test.ts b/apps/web/src/features/activity/property-change.test.tsnew file mode 100644index 0000000000..da54352d30--- /dev/null+++ b/apps/web/src/features/activity/property-change.test.ts@@ -0,0 +1,55 @@+import type { PropertyDefinitionDomain } from '@property/types';+import { describe, expect, it } from 'vitest';+import { propertyValueLabel } from './property-change-label';++const definition = {+ id: 'def-1',+ displayName: 'Status',+ options: [+ {+ id: 'opt-in-progress',+ value: { type: 'string', value: 'In Progress' },+ },+ { id: 'opt-done', value: { type: 'string', value: 'Completed' } },+ ],+} as unknown as PropertyDefinitionDomain;++describe('propertyValueLabel', () => {+ it('resolves select option ids to their option names', () => {+ expect(+ propertyValueLabel(+ { type: 'SelectOption', value: ['opt-done'] },+ definition+ )+ ).toBe('Completed');+ expect(+ propertyValueLabel(+ { type: 'SelectOption', value: ['opt-in-progress', 'opt-done'] },+ definition+ )+ ).toBe('In Progress, Completed');+ });++ it('labels scalar values without a definition', () => {+ expect(+ propertyValueLabel({ type: 'String', value: 'hello' }, undefined)+ ).toBe('hello');+ expect(+ propertyValueLabel({ type: 'Boolean', value: true }, undefined)+ ).toBe('True');+ expect(propertyValueLabel({ type: 'Number', value: 42 }, undefined)).toBe(+ '42'+ );+ });++ it('returns undefined for unknown shapes instead of raw ids', () => {+ expect(propertyValueLabel(null, definition)).toBeUndefined();+ expect(propertyValueLabel('garbage', definition)).toBeUndefined();+ expect(+ propertyValueLabel(+ { type: 'SelectOption', value: ['missing-option'] },+ definition+ )+ ).toBeUndefined();+ });+});diff --git a/apps/web/src/features/activity/property-change.tsx b/apps/web/src/features/activity/property-change.tsxnew file mode 100644index 0000000000..081ce00279--- /dev/null+++ b/apps/web/src/features/activity/property-change.tsx@@ -0,0 +1,97 @@+import { PropertyValueIcon } from '@property/component/propertyValue/PropertyValueIcon';+import { useAllProperties } from '@property/editor/hooks/useAllProperties';+import { TagDot } from '@property/tags/TagDot';+import type { PropertyDefinitionDomain } from '@property/types';+import type { ActivityEvent } from '@queries/activity/graphql/entity';+import { For, Show } from 'solid-js';+import {+ propertyValueLabel,+ selectOptionEntries,+} from './property-change-label';++type PropertyChangedAction = Extract<+ ActivityEvent['action'],+ { __typename: 'GraphqlActivityPropertyChanged' }+>;++/**+ * "changed Status: In Progress → Completed" — the property-changed verb+ * phrase with the definition name and value labels resolved. Select values+ * render as the property system's option pills (system option icons, tag+ * colors); scalars render as text. Falls back word by word: unknown+ * definition → "a property", unlabelable values → plain "changed"/"cleared"+ * wording. `from` is rendered only when the source event carried it (most+ * producers don't yet).+ */+export function PropertyChangeText(props: { action: PropertyChangedAction }) {+ const definitions = useAllProperties();+ const definition = () =>+ definitions().find((def) => def.id === props.action.property);+ const name = () => definition()?.displayName ?? 'a property';+ const cleared = () =>+ props.action.to === null || props.action.to === undefined;+ const hasFrom = () =>+ propertyValueLabel(props.action.from, definition()) !== undefined;+ const hasTo = () =>+ !cleared() &&+ propertyValueLabel(props.action.to, definition()) !== undefined;++ return (+ <span class="inline-flex min-w-0 flex-wrap items-center gap-x-1 gap-y-0.5">+ <span class="shrink-0">{cleared() ? 'cleared' : 'changed'}</span>+ <span class="shrink-0 font-medium text-ink">{name()}</span>+ <Show when={hasFrom()}>+ <span class="shrink-0">from</span>+ <PropertyValueDisplay+ raw={props.action.from}+ definition={definition()}+ />+ </Show>+ <Show when={hasTo()}>+ <span class="shrink-0">to</span>+ <PropertyValueDisplay raw={props.action.to} definition={definition()} />+ </Show>+ </span>+ );+}++/**+ * One stored property value: select options as the house option pills+ * (system option icon or tag color dot + label), everything else as text.+ */+function PropertyValueDisplay(props: {+ raw: unknown;+ definition: PropertyDefinitionDomain | undefined;+}) {+ const options = () => selectOptionEntries(props.raw, props.definition);++ return (+ <Show+ when={options()}+ fallback={+ <span class="min-w-0 truncate font-medium text-ink">+ {propertyValueLabel(props.raw, props.definition)}+ </span>+ }+ >+ {(entries) => (+ <span class="inline-flex min-w-0 flex-wrap items-center gap-1">+ <For each={entries()}>+ {(entry) => (+ <span class="inline-flex min-w-0 max-w-[20ch] items-center gap-1 rounded-full px-1.5 py-0.5 text-ink text-xs leading-tight ring ring-edge-muted/50 ring-inset">+ <PropertyValueIcon+ optionId={entry.id}+ class="size-3 shrink-0"+ />+ <Show when={entry.color}>+ {(color) => <TagDot color={color()} class="size-2" />}+ </Show>+ <span class="truncate">{entry.label}</span>+ </span>+ )}+ </For>+ </span>+ )}+ </Show>+ );+}diff --git a/apps/web/src/features/activity/use-entity-activity-flag.ts b/apps/web/src/features/activity/use-entity-activity-flag.tsnew file mode 100644index 0000000000..877e4bf6f9--- /dev/null+++ b/apps/web/src/features/activity/use-entity-activity-flag.ts@@ -0,0 +1,18 @@+import { useFeatureFlag } from '@app/lib/analytics/posthog';+import {+ ENABLE_ENTITY_ACTIVITY_SECTION_FLAG,+ ENABLE_ENTITY_ACTIVITY_SECTION_OVERRIDE,+} from '@core/constant/featureFlags';+import type { Accessor } from 'solid-js';++/**+ * Whether the entity side panel shows the Activity section. Gates the+ * section component itself, so the entity-activity GraphQL query is never+ * issued while off.+ */+export function useEntityActivityFlag(): Accessor<boolean> {+ const flag = useFeatureFlag(ENABLE_ENTITY_ACTIVITY_SECTION_FLAG, {+ enabledOverride: ENABLE_ENTITY_ACTIVITY_SECTION_OVERRIDE,+ });+ return () => flag().enabled;+}diff --git a/apps/web/src/features/block-call/component/sidepanel/CallSidePanelSections.tsx b/apps/web/src/features/block-call/component/sidepanel/CallSidePanelSections.tsxindex c54b5a1072..49a0251ee0 100644--- a/apps/web/src/features/block-call/component/sidepanel/CallSidePanelSections.tsx+++ b/apps/web/src/features/block-call/component/sidepanel/CallSidePanelSections.tsx@@ -1,3 +1,4 @@+import { EntityActivitySectionConditional } from '@app/features/activity/EntityActivitySection';import { EntityPropertiesSection } from '@app/features/property/side-panel/properties';import { useCallContextOptional } from '@channel/Call/CallContext';import { SidePanel } from '@components/app/side-panel';@@ -40,6 +41,11 @@ export function CallSidePanelSections(props: CallSidePanelSectionsProps) {<SidePanel.Section id="sharing" title="Sharing" order={20}><SharingSectionContent record={props.record} /></SidePanel.Section>+ <EntityActivitySectionConditional+ entityId={props.record().callId}+ entityType="CALL_RECORD"+ order={40}+ /><ReferencesSectionConditional callId={blockId} /></>);diff --git a/apps/web/src/features/block-chat/component/sidepanel/ChatSidePanelSections.tsx b/apps/web/src/features/block-chat/component/sidepanel/ChatSidePanelSections.tsxindex dc96dd18ea..1df4879f80 100644--- a/apps/web/src/features/block-chat/component/sidepanel/ChatSidePanelSections.tsx+++ b/apps/web/src/features/block-chat/component/sidepanel/ChatSidePanelSections.tsx@@ -1,3 +1,4 @@+import { EntityActivitySectionConditional } from '@app/features/activity/EntityActivitySection';import {EntityPropertiesSection,EntityTagsSection,@@ -41,6 +42,11 @@ export function ChatSidePanelSections() {<ChatPropertiesContent chatId={chatId} canEdit={canEdit()} /></Suspense></SidePanel.Section>+ <EntityActivitySectionConditional+ entityId={chatId}+ entityType="CHAT"+ order={40}+ /></>);}diff --git a/apps/web/src/features/block-email/component/sidepanel/EmailSidePanelSections.tsx b/apps/web/src/features/block-email/component/sidepanel/EmailSidePanelSections.tsxindex a9670f7186..655409ac65 100644--- a/apps/web/src/features/block-email/component/sidepanel/EmailSidePanelSections.tsx+++ b/apps/web/src/features/block-email/component/sidepanel/EmailSidePanelSections.tsx@@ -1,3 +1,4 @@+import { EntityActivitySectionConditional } from '@app/features/activity/EntityActivitySection';import {EntityPropertiesSection,EntityTagsSection,@@ -43,6 +44,11 @@ export function EmailSidePanelSections(props: EmailSidePanelSectionsProps) {/></Suspense></SidePanel.Section>+ <EntityActivitySectionConditional+ entityId={props.threadId}+ entityType="THREAD"+ order={40}+ /><ReferencesSectionConditional threadId={props.threadId} /></>);diff --git a/apps/web/src/features/block-md/component/sidepanel/MarkdownSidePanelSections.tsx b/apps/web/src/features/block-md/component/sidepanel/MarkdownSidePanelSections.tsxindex d7be879488..403b8d457f 100644--- a/apps/web/src/features/block-md/component/sidepanel/MarkdownSidePanelSections.tsx+++ b/apps/web/src/features/block-md/component/sidepanel/MarkdownSidePanelSections.tsx@@ -1,3 +1,4 @@+import { EntityActivitySectionConditional } from '@app/features/activity/EntityActivitySection';import {EntityPropertiesSection,EntityTagsSection,@@ -127,6 +128,11 @@ export function MarkdownSidePanelSections(<HistorySectionContent /></SidePanel.Section></Show>+ <EntityActivitySectionConditional+ entityId={blockId}+ entityType={propertiesEntityType()}+ order={40}+ /><GithubSectionConditional documentId={blockId} isTask={isTask()} /><NotificationsSectionConditional entity={entity()} /><ReferencesSectionConditional documentId={blockId} />diff --git a/apps/web/src/features/block-project/component/sidepanel/ProjectSidePanelSections.tsx b/apps/web/src/features/block-project/component/sidepanel/ProjectSidePanelSections.tsxindex e9771562a9..1fada9c0af 100644--- a/apps/web/src/features/block-project/component/sidepanel/ProjectSidePanelSections.tsx+++ b/apps/web/src/features/block-project/component/sidepanel/ProjectSidePanelSections.tsx@@ -1,3 +1,4 @@+import { EntityActivitySectionConditional } from '@app/features/activity/EntityActivitySection';import {EntityPropertiesSection,EntityTagsSection,@@ -52,6 +53,11 @@ export function ProjectSidePanelSections() {/></Suspense></SidePanel.Section>+ <EntityActivitySectionConditional+ entityId={projectId}+ entityType="PROJECT"+ order={40}+ /></>);}diff --git a/apps/web/src/lib/core/constant/featureFlags.ts b/apps/web/src/lib/core/constant/featureFlags.tsindex 31d7aabea2..ec4d29a994 100644--- a/apps/web/src/lib/core/constant/featureFlags.ts+++ b/apps/web/src/lib/core/constant/featureFlags.ts@@ -641,3 +641,14 @@ export const ENABLE_TAG_TEAM_SHARING_FLAG = 'enable-tag-team-sharing';export const ENABLE_TAG_TEAM_SHARING_OVERRIDE =getFeatureFlagOverride('ENABLE_TAG_TEAM_SHARING') ??(DEV_MODE_ENV ? true : undefined);++// The "Activity" section in the entity side panel: the entity's recent+// activity timeline from the GraphQL activity log (who did what, when).+// Purely additive — when off, the section never mounts and no activity+// query is issued. PostHog-gated with a dev-mode default; override with+// VITE_ENABLE_ENTITY_ACTIVITY_SECTION.+export const ENABLE_ENTITY_ACTIVITY_SECTION_FLAG =+ 'enable-entity-activity-section';+export const ENABLE_ENTITY_ACTIVITY_SECTION_OVERRIDE =+ getFeatureFlagOverride('ENABLE_ENTITY_ACTIVITY_SECTION') ??+ (DEV_MODE_ENV ? true : undefined);diff --git a/apps/web/src/lib/queries/activity/graphql/entity.ts b/apps/web/src/lib/queries/activity/graphql/entity.tsnew file mode 100644index 0000000000..5718d0611c--- /dev/null+++ b/apps/web/src/lib/queries/activity/graphql/entity.ts@@ -0,0 +1,67 @@+import { createUrqlQuery } from '@app/lib/urql-solid/create-urql-query';+import { buildEntityPropertiesInput } from '@queries/properties/graphql/entity';+import type { EntityType } from '@service-properties/generated/schemas/entityType';+import {+ type ActivityEventFieldsFragment,+ EntityActivityDocument,+ type EntityActivityQuery,+ type EntityActivityQueryVariables,+} from '@service-storage/graphql/generated/graphql';+import { getGraphqlSoupClient } from '@service-storage/graphql-soup';+import { type Accessor, createMemo } from 'solid-js';++/** One activity event as both activity queries return it. */+export type ActivityEvent = ActivityEventFieldsFragment;++/** Rows requested for a side-panel activity preview. */+export const ENTITY_ACTIVITY_PREVIEW_LIMIT = 20;++type EntityActivityQueryOptions = {+ entityType: Accessor<EntityType>;+ entityId: Accessor<string>;+ enabled: Accessor<boolean>;+ limit?: number;+};++/**+ * Live urql query for one Soup-backed entity's recent activity, newest+ * first. Reuses the exact-single-entity Soup input builder from the+ * properties query, so the same entity types are supported (everything but+ * `USER`) and the query pauses (`isEnabled` false) for the rest.+ */+export function createEntityActivityQuery(options: EntityActivityQueryOptions) {+ const input = createMemo(() => {+ const entityId = options.entityId();+ if (!options.enabled() || entityId.length === 0) return undefined;+ return buildEntityPropertiesInput(options.entityType(), entityId);+ });++ const result = createUrqlQuery<+ EntityActivityQuery,+ EntityActivityQueryVariables,+ ActivityEvent[]+ >(() => {+ const currentInput = input();+ const entityId = options.entityId();++ return {+ query: EntityActivityDocument,+ client: getGraphqlSoupClient(),+ variables: {+ input: currentInput!,+ limit: options.limit ?? ENTITY_ACTIVITY_PREVIEW_LIMIT,+ },+ enabled: currentInput !== undefined,+ requestPolicy: 'cache-and-network',+ keepPreviousData: false,+ select: (data) =>+ data.user.soup.items.find((item) => item.id === entityId)?.activity ??+ [],+ };+ });++ return {+ result,+ isEnabled: () => input() !== undefined,+ };+}diff --git a/apps/web/src/lib/service-clients/service-storage/graphql-soup.ts b/apps/web/src/lib/service-clients/service-storage/graphql-soup.tsindex a6d02add34..a2abe57751 100644--- a/apps/web/src/lib/service-clients/service-storage/graphql-soup.ts+++ b/apps/web/src/lib/service-clients/service-storage/graphql-soup.ts@@ -109,6 +109,10 @@ const graphqlSoupClient = createClient({url: `${dssHost}/items/soup/graphql`,exchanges: [fetchExchange],fetch: dssGraphqlFetch,+ // urql's default ("within-url-limit") sends small documents as GET, but+ // GET on the DSS GraphQL path serves the GraphiQL IDE — only POST+ // executes. Every pre-activity document was too large to trigger this.+ preferGetMethod: false,});/**@@ -180,6 +184,8 @@ export function getGraphqlSoupClient(): Client {websocketClient = graphqlWsClient;const client = createClient({url: `${dssHost}/items/soup/graphql`,+ // See graphqlSoupClient: GET serves GraphiQL on this path.+ preferGetMethod: false,exchanges: [normalizedCacheExchange(host, {entityResolvers: {