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(projects): clear linked discussion highlights on click (#8617)

gbirman9faed35fa4dc
diff --git a/apps/web/src/features/projects/project-collaboration.test.tsx b/apps/web/src/features/projects/project-collaboration.test.tsx
index d5e4b2cea7..11da8d08c9 100644
--- a/apps/web/src/features/projects/project-collaboration.test.tsx
+++ b/apps/web/src/features/projects/project-collaboration.test.tsx
@@ -1,6 +1,6 @@
import type { MessageData } from '@core/messages/types';
import type { MessageListItem, MessageParent } from '@service-storage/messages';
-import { cleanup, render } from '@solidjs/testing-library';
+import { cleanup, fireEvent, render } from '@solidjs/testing-library';
import { type Accessor, createSignal, type ParentProps } from 'solid-js';
import { afterEach, describe, expect, it, vi } from 'vitest';
import { ProjectDiscussion } from './project-collaboration';
@@ -46,8 +46,13 @@ vi.mock('@core/messages/MessageThread', () => ({
MessageThread: (props: {
data: MessageListItem;
buildLink?: (message: MessageData) => string;
+ targetId?: string | null;
+ onClearTarget?: () => void;
}) => (
- <article>
+ <article
+ data-target={props.targetId ?? undefined}
+ onClick={props.onClearTarget}
+ >
<a href={props.buildLink?.(props.data)}>{props.data.content}</a>
</article>
),
@@ -80,7 +85,7 @@ function message(id: string, content: string): MessageListItem {
};
}
-function setup(targetId?: string) {
+function setup(initialTargetId?: string) {
mocks.link.mockImplementation(
(_parent: Accessor<MessageParent>, target: Accessor<string | null>) => ({
messageId: target,
@@ -103,13 +108,15 @@ function setup(targetId?: string) {
},
});
const [canWrite, setCanWrite] = createSignal(true);
+ const [targetId, setTargetId] = createSignal(initialTargetId);
return {
setCanWrite,
+ setTargetId,
...render(() => (
<ProjectDiscussion
projectId={projectId}
canWrite={canWrite()}
- targetId={targetId}
+ targetId={targetId()}
/>
)),
};
@@ -161,4 +168,36 @@ describe('project discussion uses the task conversation', () => {
`/app/component/initiative-view~${projectId}~overview~${oldId}`
);
});
+
+ it('dismisses a linked comment highlight without changing the loaded timeline', () => {
+ const view = setup(oldId);
+ const comment = view.getByText('Old comment').closest('article')!;
+ expect(comment.dataset.target).toBe(oldId);
+
+ fireEvent.click(comment);
+ expect(comment.dataset.target).toBeUndefined();
+ const [, target] = mocks.link.mock.calls[0];
+ const [, around] = mocks.timeline.mock.calls[0];
+ expect(target()).toBe(oldId);
+ expect(around()).toBe(oldId);
+ expect(view.getAllByRole('article')).toHaveLength(2);
+
+ // An unrelated host update must not restore the highlight.
+ view.setCanWrite(false);
+ expect(comment.dataset.target).toBeUndefined();
+
+ // Following another link, then returning, starts a new highlight.
+ view.setTargetId(newId);
+ const next = view.getByText('New comment').closest('article')!;
+ expect(next.dataset.target).toBe(newId);
+ fireEvent.click(next);
+ expect(next.dataset.target).toBeUndefined();
+ view.setTargetId(oldId);
+ expect(comment.dataset.target).toBe(oldId);
+
+ fireEvent.click(comment);
+ view.setTargetId(undefined);
+ view.setTargetId(oldId);
+ expect(comment.dataset.target).toBe(oldId);
+ });
});
diff --git a/apps/web/src/features/projects/project-collaboration.tsx b/apps/web/src/features/projects/project-collaboration.tsx
index 881f902503..71c9ccc6fb 100644
--- a/apps/web/src/features/projects/project-collaboration.tsx
+++ b/apps/web/src/features/projects/project-collaboration.tsx
@@ -1,5 +1,6 @@
import { EntityConversation } from '@core/messages/EntityConversation';
import { buildSimpleEntityUrl } from '@core/util/url';
+import { createMemo, createSignal } from 'solid-js';
import { projectRouteId } from './core/route';
/** Projects use the same unanchored discussion and composer as task detail. */
@@ -8,11 +9,18 @@ export function ProjectDiscussion(props: {
canWrite: boolean;
targetId?: string;
}) {
+ const targetId = createMemo(() => props.targetId);
+ const targetRequest = createMemo(() => ({ id: targetId() }));
+ const [clearedTarget, setClearedTarget] =
+ createSignal<ReturnType<typeof targetRequest>>();
+
return (
<EntityConversation
parent={{ type: 'initiative', id: props.projectId }}
canWrite={props.canWrite}
targetId={props.targetId}
+ targetCleared={clearedTarget() === targetRequest()}
+ onClearTarget={() => setClearedTarget(targetRequest())}
buildLink={(message) =>
buildSimpleEntityUrl({
type: 'component',
diff --git a/docs/agent-guide/tasks.md b/docs/agent-guide/tasks.md
index 0d001f1c85..5c1423ce76 100644
--- a/docs/agent-guide/tasks.md
+++ b/docs/agent-guide/tasks.md
@@ -763,6 +763,9 @@ at the top. Comments, replies, and reactions stay attached to the project identi
Notification links open Overview at the relevant discussion. Existing `activity`
URLs also open Overview and preserve the target discussion. Project history is
not included in this discussion section.
+Click or tap the linked comment to clear its highlight; the loaded discussion
+and expanded replies stay in place. Following another comment link highlights
+its target again.
## Bulk delete