Skip to content

armgit / macro

Public Imported from GitHub
0

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

fix(email): match row subjects, tag view titles, and copied thread links (#8785)

teof3ad7286c4f0
diff --git a/apps/web/src/features/email-view/components/EmailDetailView.tsx b/apps/web/src/features/email-view/components/EmailDetailView.tsx
index c36cabc977..c5b9292c96 100644
--- a/apps/web/src/features/email-view/components/EmailDetailView.tsx
+++ b/apps/web/src/features/email-view/components/EmailDetailView.tsx
@@ -136,7 +136,8 @@ export function EmailDetailView(props: {
displaySubject(
representativeThreadMessage(thread.messages)?.subject
)) ||
- props.thread.fallbackName ||
+ (props.thread.fallbackName &&
+ displaySubject(props.thread.fallbackName)) ||
'Email'
);
};
diff --git a/apps/web/src/features/email-view/components/EmailHeader.tsx b/apps/web/src/features/email-view/components/EmailHeader.tsx
index 61aee26315..e9ad52bb2a 100644
--- a/apps/web/src/features/email-view/components/EmailHeader.tsx
+++ b/apps/web/src/features/email-view/components/EmailHeader.tsx
@@ -27,13 +27,14 @@ export type EmailHeaderProps = {
};
export function EmailViewBreadcrumbItem() {
- const { state } = useEmailView();
+ const { state, tagViewTitle } = useEmailView();
const inboxSelected = () =>
!isTouchDevice() && (state.tab === 'important' || state.tab === 'noise');
const tabTitle = () =>
- inboxSelected()
+ tagViewTitle() ??
+ (inboxSelected()
? 'Inbox'
- : (EMAIL_TABS.find((tab) => tab.id === state.tab)?.label ?? 'Email');
+ : (EMAIL_TABS.find((tab) => tab.id === state.tab)?.label ?? 'Email'));
return (
<ViewBreadcrumbs.Item
@@ -62,16 +63,17 @@ export function EmailViewBreadcrumbItem() {
export function EmailHeader(props: EmailHeaderProps) {
const panel = useSplitPanelOrThrow();
const { openWithSplit } = useSplitLayout();
- const { state, setState, setTab } = useEmailView();
+ const { state, setState, setTab, tagViewTitle } = useEmailView();
const [filterOpen, setFilterOpen] = createSignal(false);
let focusSearch: (() => void) | undefined;
const searchTarget = tourTarget(EMAIL_TOUR.search);
const inboxSelected = () =>
state.tab === 'important' || state.tab === 'noise';
const selectedTabLabel = () =>
- inboxSelected()
+ tagViewTitle() ??
+ (inboxSelected()
? 'Inbox'
- : (EMAIL_TABS.find((tab) => tab.id === state.tab)?.label ?? 'Email');
+ : (EMAIL_TABS.find((tab) => tab.id === state.tab)?.label ?? 'Email'));
const runSearch = () => {
focusSearch?.();
diff --git a/apps/web/src/features/email-view/email-view-context.test.tsx b/apps/web/src/features/email-view/email-view-context.test.tsx
index c9ce28917c..bd0749c576 100644
--- a/apps/web/src/features/email-view/email-view-context.test.tsx
+++ b/apps/web/src/features/email-view/email-view-context.test.tsx
@@ -1,3 +1,4 @@
+import type { TagSetResponse } from '@service-properties/generated/schemas/tagSetResponse';
import { cleanup, render } from '@solidjs/testing-library';
import { createStore } from 'solid-js/store';
import { afterEach, describe, expect, it, vi } from 'vitest';
@@ -13,6 +14,7 @@ const mocks = vi.hoisted(() => ({
useEmailLinksQuery: vi.fn(),
reminders: (): boolean => true,
tab: (): string => 'important',
+ tagSets: (): TagSetResponse[] => [],
}));
vi.mock('@app/lib/analytics/posthog', () => ({
@@ -66,7 +68,7 @@ vi.mock('@components/app/split-layout/layoutUtils', () => ({
vi.mock('@core/context/user', () => ({ useUserId: () => () => 'user' }));
vi.mock('@core/mobile/isTouchDevice', () => ({ isTouchDevice: () => false }));
vi.mock('@property/tags/tag-sets-context', () => ({
- useTagSets: () => () => [],
+ useTagSets: () => () => mocks.tagSets(),
useTagSetsReady: () => () => true,
}));
vi.mock('@queries/email/link', () => ({
@@ -91,6 +93,7 @@ afterEach(() => {
vi.clearAllMocks();
mocks.reminders = () => true;
mocks.tab = () => 'important';
+ mocks.tagSets = () => [];
});
function mount() {
@@ -177,6 +180,38 @@ it('clears persisted text search when entering and leaving Email Reminders', ()
expect(view.state.search).toBe('');
});
+describe('tag view title', () => {
+ const qaTag = '019a1f40-2c7e-7d10-9a4b-6f2b0c1d2e40';
+ const userTags = (): TagSetResponse[] => [
+ {
+ scope: 'user',
+ options: [
+ {
+ id: qaTag,
+ displayOrder: 0,
+ propertyDefinitionId: 'user-tags',
+ value: { type: 'string', value: 'QA test tag' },
+ },
+ ],
+ },
+ ];
+
+ it('names the view after the tag chosen in the sidebar', () => {
+ mocks.tagSets = userTags;
+ const { view } = mount();
+ view.showTags([qaTag]);
+ expect(view.tagViewTitle()).toBe('QA test tag');
+ });
+
+ it('keeps the tab name when a tag only filters a tab', () => {
+ mocks.tagSets = userTags;
+ const { view } = mount();
+ view.filterByTag(qaTag);
+ expect(view.state.tab).toBe('important');
+ expect(view.tagViewTitle()).toBeUndefined();
+ });
+});
+
it('normalizes restored and route-driven Reminders when the rollout is disabled', () => {
const [flag, setFlag] = createStore({ enabled: true });
mocks.reminders = () => flag.enabled;
diff --git a/apps/web/src/features/email-view/email-view-context.tsx b/apps/web/src/features/email-view/email-view-context.tsx
index 7b75bebd08..370e16e8cd 100644
--- a/apps/web/src/features/email-view/email-view-context.tsx
+++ b/apps/web/src/features/email-view/email-view-context.tsx
@@ -27,6 +27,7 @@ import { createAssertedContextProvider } from '@core/context/createContext';
import { useUserId } from '@core/context/user';
import { isTouchDevice } from '@core/mobile/isTouchDevice';
import { fireAndForget } from '@core/util/fireAndForget';
+import { listTagOptions } from '@property/tags/list-tag-options';
import { useTagSets, useTagSetsReady } from '@property/tags/tag-sets-context';
import { useEmailLinksQuery } from '@queries/email/link';
import type { ContextProviderProps } from '@solid-primitives/context';
@@ -96,6 +97,8 @@ export type EmailViewContext = {
* "filter by tag" button on entity rows.
*/
filterByTag: (optionId: string) => void;
+ /** The selected tags' names on All, where they alone scope the list. */
+ tagViewTitle: Accessor<string | undefined>;
source: EmailDataSource;
list: EmailListController;
registerListActivationHandler: (
@@ -422,6 +425,15 @@ export const [EmailViewProvider, useEmailView] = createAssertedContextProvider<
);
};
+ const tagViewTitle = () => {
+ const tagIds = state.facets.tags ?? [];
+ if (state.tab !== 'all' || tagIds.length === 0) return undefined;
+ const labels = listTagOptions(tagSets())
+ .filter((tag) => tagIds.includes(tag.id))
+ .map((tag) => tag.label);
+ return labels.length > 0 ? labels.join(', ') : undefined;
+ };
+
const [readingPane, setReadingPane] = usePreference(
'macro:pref:email:reading-pane',
{ default: false }
@@ -444,6 +456,7 @@ export const [EmailViewProvider, useEmailView] = createAssertedContextProvider<
setFacets,
showTags,
filterByTag,
+ tagViewTitle,
source,
list,
registerListActivationHandler,
diff --git a/apps/web/src/features/entity/extractors-notification/notification-copy-link.test.ts b/apps/web/src/features/entity/extractors-notification/notification-copy-link.test.ts
index d9cebf75ce..941e48d786 100644
--- a/apps/web/src/features/entity/extractors-notification/notification-copy-link.test.ts
+++ b/apps/web/src/features/entity/extractors-notification/notification-copy-link.test.ts
@@ -1,5 +1,5 @@
const mocks = vi.hoisted(() => ({
- writeText: vi.fn(),
+ writeText: vi.fn<(text: string) => Promise<void>>(),
success: vi.fn(),
remindersEnabled: true,
}));
@@ -7,6 +7,19 @@ const mocks = vi.hoisted(() => ({
vi.mock('@app/features/calendar-view/copy-event-mention', () => ({
copyCalendarEventMentionTarget: vi.fn(),
}));
+vi.mock('@components/app/split-layout/componentRegistry', () => ({
+ resolveComponent: vi.fn(() => ({ type: 'mock-component' })),
+}));
+vi.mock('@service-storage/websocket', () => ({
+ storageWS: { reconnectIfDisconnected: vi.fn() },
+ createWebSocketJob: vi.fn(),
+}));
+vi.mock('@service-connection/websocket', () => ({
+ ws: { addEventListener: vi.fn(), send: vi.fn() },
+ state: () => 'closed',
+ createConnectionBlockWebsocketEffect: vi.fn(),
+ createConnectionWebsocketEffect: vi.fn(),
+}));
vi.mock('@core/component/Toast/Toast', () => ({
toast: { success: mocks.success },
}));
@@ -22,17 +35,51 @@ vi.mock('@notifications', () => ({
getChannelNotificationParams: () => ({}),
}));
+import {
+ createRoutesManifest,
+ decodePane,
+ type SplitRoutes,
+} from '@app/lib/split-router';
+import { paneRoute } from '@app/routes/app-route';
+import {
+ appRoute,
+ emailSplitRoute,
+ emailThreadRoute,
+ legacyContentRoute,
+ notFoundRoute,
+} from '@app/routes/routes';
import type { UnifiedNotification } from '@notifications';
import { beforeEach, expect, it, vi } from 'vitest';
import { copyNotificationLink } from './notification-copy-link';
+const routes = createRoutesManifest({
+ definitions: [
+ {
+ ...appRoute,
+ children: [
+ { ...emailSplitRoute, children: [emailThreadRoute] },
+ legacyContentRoute,
+ notFoundRoute,
+ ],
+ },
+ ],
+ defaultRoute: () => paneRoute({ id: emailSplitRoute.id, params: {} }),
+} satisfies SplitRoutes);
+
+const openedRoute = (link: string) => {
+ const [root, ...segments] = new URL(link).pathname.split('/').filter(Boolean);
+ expect(root).toBe('app');
+ const leaf = decodePane(routes, segments)?.matches.at(-1);
+ return leaf && { id: leaf.id, params: leaf.params };
+};
+
beforeEach(() => {
mocks.remindersEnabled = true;
vi.clearAllMocks();
vi.stubGlobal('navigator', { clipboard: { writeText: mocks.writeText } });
});
-it('copies the original email URL', async () => {
+it('copies a link that opens the reminded email thread', async () => {
const notification = {
entity_id: 'thread-1',
entity_type: 'email_thread',
@@ -47,9 +94,11 @@ it('copies the original email URL', async () => {
await copyNotificationLink(notification);
- expect(mocks.writeText).toHaveBeenCalledExactlyOnceWith(
- 'https://macro.com/app/email/thread-1'
- );
+ expect(mocks.writeText).toHaveBeenCalledOnce();
+ expect(openedRoute(mocks.writeText.mock.calls[0]![0])).toEqual({
+ id: emailThreadRoute.id,
+ params: { threadId: 'thread-1' },
+ });
expect(mocks.success).toHaveBeenCalledWith('Link copied to clipboard');
});
diff --git a/apps/web/src/features/entity/extractors/entity-title.tsx b/apps/web/src/features/entity/extractors/entity-title.tsx
index f77d5586cd..a4150b06c2 100644
--- a/apps/web/src/features/entity/extractors/entity-title.tsx
+++ b/apps/web/src/features/entity/extractors/entity-title.tsx
@@ -1,3 +1,4 @@
+import { displaySubject } from '@app/features/email-compose/core/subject-text';
import { StaticMarkdown } from '@core/component/LexicalMarkdown/component/core/StaticMarkdown';
import { unifiedListMarkdownTheme } from '@core/component/LexicalMarkdown/theme';
import { blockNameToDefaultFile } from '@core/constant/allBlocks';
@@ -19,7 +20,7 @@ function extractRawTitle(entity: EntityData): JSX.Element {
.with({ type: 'channel' }, (e) => e.name)
.with({ type: 'channel_message' }, (e) => e.channelName)
.with({ type: 'channel_thread' }, (e) => e.name)
- .with({ type: 'email' }, (e) => e.name || '(No Subject)')
+ .with({ type: 'email' }, (e) => displaySubject(e.name))
.with({ type: 'agent_session' }, (e) => e.name || 'Agent session')
.with({ type: 'chat' }, (e) => e.name)
.with({ type: 'call' }, (e) => e.name || blockNameToDefaultFile('call'))
diff --git a/apps/web/src/features/entity/tests/entity-title.test.tsx b/apps/web/src/features/entity/tests/entity-title.test.tsx
index 875a7bd836..d11cb54442 100644
--- a/apps/web/src/features/entity/tests/entity-title.test.tsx
+++ b/apps/web/src/features/entity/tests/entity-title.test.tsx
@@ -2,7 +2,7 @@ import { cleanup, render } from '@solidjs/testing-library';
import { createSignal } from 'solid-js';
import { afterEach, describe, expect, it, vi } from 'vitest';
import { EntityTitle } from '../extractors/entity-title';
-import type { FormEntity } from '../types/entity';
+import type { EmailEntity, FormEntity } from '../types/entity';
vi.mock(
'@core/component/LexicalMarkdown/component/core/StaticMarkdown',
@@ -66,3 +66,20 @@ describe('form entity titles', () => {
expect(getByText('Untitled form')).toBeTruthy();
});
});
+
+describe('email thread titles', () => {
+ it('drops the reply prefix the thread header drops', () => {
+ const thread: EmailEntity = {
+ type: 'email',
+ id: '019a1f40-2c7e-7d10-9a4b-6f2b0c1d2e3f',
+ name: 'Re: hello from my outlook to your outlook',
+ ownerId: 'macro|[email protected]',
+ isRead: true,
+ isDraft: false,
+ isImportant: true,
+ done: false,
+ };
+ const { container } = render(() => <EntityTitle entity={thread} />);
+ expect(container.textContent).toBe('hello from my outlook to your outlook');
+ });
+});
diff --git a/apps/web/src/features/next-soup/actions/make-copy-link-action.test.ts b/apps/web/src/features/next-soup/actions/make-copy-link-action.test.ts
new file mode 100644
index 0000000000..18558b7dd3
--- /dev/null
+++ b/apps/web/src/features/next-soup/actions/make-copy-link-action.test.ts
@@ -0,0 +1,106 @@
+import {
+ createRoutesManifest,
+ decodePane,
+ type SplitRoutes,
+} from '@app/lib/split-router';
+import { paneRoute } from '@app/routes/app-route';
+import {
+ appRoute,
+ emailSplitRoute,
+ emailThreadRoute,
+ legacyContentRoute,
+ notFoundRoute,
+} from '@app/routes/routes';
+import { createMacroMentionLinkResolver } from '@components/app/split-layout/split-router/mention-links';
+import type { EmailEntity } from '@entity';
+import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest';
+import { makeCopyLinkAction } from './make-copy-link-action';
+
+vi.mock('@components/app/split-layout/componentRegistry', () => ({
+ resolveComponent: vi.fn(() => ({ type: 'mock-component' })),
+}));
+vi.mock('@service-storage/websocket', () => ({
+ storageWS: { reconnectIfDisconnected: vi.fn() },
+ createWebSocketJob: vi.fn(),
+}));
+vi.mock('@service-connection/websocket', () => ({
+ ws: { addEventListener: vi.fn(), send: vi.fn() },
+ state: () => 'closed',
+ createConnectionBlockWebsocketEffect: vi.fn(),
+ createConnectionWebsocketEffect: vi.fn(),
+}));
+vi.mock('@core/component/Toast/Toast', () => ({
+ toast: { success: vi.fn(), failure: vi.fn() },
+}));
+
+const routes = createRoutesManifest({
+ definitions: [
+ {
+ ...appRoute,
+ children: [
+ { ...emailSplitRoute, children: [emailThreadRoute] },
+ legacyContentRoute,
+ notFoundRoute,
+ ],
+ },
+ ],
+ defaultRoute: () => paneRoute({ id: emailSplitRoute.id, params: {} }),
+} satisfies SplitRoutes);
+const resolveMention = createMacroMentionLinkResolver(routes);
+
+const threadId = '019a1f40-2c7e-7d10-9a4b-6f2b0c1d2e3f';
+const thread: EmailEntity = {
+ type: 'email',
+ id: threadId,
+ name: 'hello from my outlook to your outlook',
+ ownerId: 'macro|[email protected]',
+ isRead: true,
+ isDraft: false,
+ isImportant: true,
+ done: false,
+};
+
+const writeText = vi.fn<(text: string) => Promise<void>>();
+
+beforeEach(() => {
+ writeText.mockReset().mockResolvedValue(undefined);
+ vi.stubGlobal('navigator', { ...navigator, clipboard: { writeText } });
+});
+
+afterEach(() => {
+ vi.unstubAllGlobals();
+});
+
+const copiedLink = () => {
+ expect(writeText).toHaveBeenCalledOnce();
+ return writeText.mock.calls[0]![0];
+};
+
+const expectOpensThread = (link: string) => {
+ const url = new URL(link);
+ expect(url.origin).toBe(window.location.origin);
+ const segments = url.pathname.split('/').filter(Boolean);
+ expect(segments[0]).toBe('app');
+ const leaf = decodePane(routes, segments.slice(1))?.matches.at(-1);
+ expect(leaf && { id: leaf.id, params: leaf.params }).toEqual({
+ id: emailThreadRoute.id,
+ params: { threadId },
+ });
+ expect(resolveMention(link)).toEqual({
+ id: threadId,
+ block: 'email',
+ params: {},
+ });
+};
+
+describe('copy link for an email thread', () => {
+ it('copies a link the router opens as the thread', async () => {
+ await makeCopyLinkAction().execute([thread]);
+ expectOpensThread(copiedLink());
+ });
+
+ it('copies the same link from the thread menu without a list entity', async () => {
+ await makeCopyLinkAction().executeByBlock(threadId, 'email');
+ expectOpensThread(copiedLink());
+ });
+});
diff --git a/apps/web/src/lib/core/util/url.ts b/apps/web/src/lib/core/util/url.ts
index 7ae63326f3..1bc75b508b 100644
--- a/apps/web/src/lib/core/util/url.ts
+++ b/apps/web/src/lib/core/util/url.ts
@@ -68,11 +68,18 @@ export function transformShortIdInUrlPathname(pathname: string) {
return newPathname;
}
+/** Canonical route segments that differ from the entity type. Email threads
+ * open in Mail; /app/email is the legacy block URL. */
+const ROUTE_SEGMENTS = new Map([
+ ['routine', 'routines'],
+ ['email', 'mail'],
+]);
+
export function buildSimpleEntityUrl(
entity: { type: string; id: string },
params?: Record<string, string>
): string {
- const type = entity.type === 'routine' ? 'routines' : entity.type;
+ const type = ROUTE_SEGMENTS.get(entity.type) ?? entity.type;
const urlString = `${getWebOrigin()}/app/${type}/${entity.id}`;
const url = new URL(urlString);
if (params) {
diff --git a/docs/agent-guide/email.md b/docs/agent-guide/email.md
index 443d6113af..26ae7c541f 100644
--- a/docs/agent-guide/email.md
+++ b/docs/agent-guide/email.md
@@ -25,6 +25,9 @@ detail view. See [Email reminders](reminders.md#delivery-and-undo).
Email's Tags sidebar uses the [nested tag tree](tasks.md#nested-sidebar-tags).
Carets and folder-only parents expand branches; actual tags select their exact ID
and switch the mailbox to All. Parent selection does not include descendant tags.
+While tags scope All, the header and breadcrumb show the tag names instead of
+`All`. A narrow pane keeps its short `Email` or `Inbox` breadcrumb label. A tag
+filter on any other tab keeps that tab's title.
Unlike Calls, it lists only personal tags; team-shared tags are hidden,
and its `New tag` action creates a personal tag with no Team sharing option.
@@ -361,7 +364,9 @@ keyboard back to the list without closing the thread. Narrow email rows here
stack senders and date, subject, and one preview line beside a slim unread-dot
gutter (no per-type icon); unread rows are bold, hovering swaps the date for the
row actions, and hovering the gutter shows the select checkbox. Phones keep
-their own touch email rows, with the sender's picture on the left.
+their own touch email rows, with the sender's picture on the left. Every email
+row titles the thread as its header does: repeated leading `Re:` prefixes are
+dropped, and a blank subject reads `[No subject]`.
Without room for both (narrow split, collapsed window) the pane folds away and
a thread replaces the list as usual; the thread remounts, but a reply draft
survives. The divider can be dragged; the list width is remembered. Verify that
@@ -399,7 +404,10 @@ preserve working menu actions and header controls. Repeatedly navigate forward
and backward, including after returning to the list: the subject and email body
should remain visible without reloading.
Shift-click opens a standalone split at `/app/email/<thread-id>`, which remains
-the destination for direct links and legacy surfaces. Click a message header to
+the destination for direct links and legacy surfaces. **Copy Link** on a
+thread copies `/app/mail/<thread-id>` from a row, the title menu, the Share
+dialog, or a reminder notification. The link opens the thread in Mail and
+pastes as an email mention. Click a message header to
expand or collapse it; `Show N hidden messages` reveals the collapsed middle of
a longer conversation. A standalone link with
`?email_message_id=<message-id>` loads older pages as needed, expands the target,