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(projects): add description to project composer; Enter in title moves to it (#7758)

teo47e9af49d6cf
diff --git a/apps/web/src/features/projects/components/project-description-composer.tsx b/apps/web/src/features/projects/components/project-description-composer.tsx
new file mode 100644
index 0000000000..794943fd3e
--- /dev/null
+++ b/apps/web/src/features/projects/components/project-description-composer.tsx
@@ -0,0 +1,58 @@
+import { useSplitPanel } from '@components/app/split-layout/layoutUtils';
+import { useMacroMentionLinkResolver } from '@components/app/split-layout/split-router/mention-links';
+import { buildConfig } from '@core/component/LexicalMarkdown/builder/MarkdownConfigBuilder';
+import { MarkdownShell } from '@core/component/LexicalMarkdown/builder/MarkdownShell';
+import type { EditorControls } from '@core/component/LexicalMarkdown/builder/types';
+import { Scroll } from '@ui';
+
+/** The Markdown body of the project composer, edited like a new task's. */
+export function ProjectDescriptionComposer(props: {
+ initialValue: string;
+ disabled: boolean;
+ onChange(markdown: string): void;
+ onSubmit(): void;
+ /** Keyboard focus left the start of the description, or Escape was pressed. */
+ onLeaveStart(): void;
+ ref(controls: EditorControls): void;
+}) {
+ const panel = useSplitPanel();
+ const config = buildConfig('markdown')
+ .withAppLinkResolver(useMacroMentionLinkResolver())
+ .withMentions()
+ .withEmojis()
+ .withCode()
+ .withSelectionData()
+ .withFloatingFormatMenu()
+ .withHistory()
+ .onChange(props.onChange)
+ .onEnter((event) => {
+ if (!(event.metaKey || event.ctrlKey) || event.isComposing) return false;
+ props.onSubmit();
+ return true;
+ })
+ .onFocusLeave({
+ onStart: (event) => {
+ event.preventDefault();
+ props.onLeaveStart();
+ },
+ onEnd: () => {},
+ })
+ .onEscape(() => {
+ props.onLeaveStart();
+ return true;
+ });
+ const handle = config.buildHandle();
+ props.ref(handle.controls);
+
+ return (
+ <Scroll>
+ <MarkdownShell
+ config={config}
+ initialValue={props.initialValue || undefined}
+ disabled={props.disabled}
+ placeholder="Add description..."
+ portalScope={panel?.handle.isPopover() ? 'local' : 'block'}
+ />
+ </Scroll>
+ );
+}
diff --git a/apps/web/src/features/projects/context/projects-context.tsx b/apps/web/src/features/projects/context/projects-context.tsx
index a6a39b350e..f5b3444d70 100644
--- a/apps/web/src/features/projects/context/projects-context.tsx
+++ b/apps/web/src/features/projects/context/projects-context.tsx
@@ -35,6 +35,8 @@ export type ProjectPropertyDraft = {
export type ProjectCreationInput = {
name: string;
+ /** Markdown that seeds the description surface. */
+ description: string;
shareWithTeam: boolean;
properties: readonly ProjectPropertyDraft[];
};
diff --git a/apps/web/src/features/projects/primitives/create-project.test.ts b/apps/web/src/features/projects/primitives/create-project.test.ts
index ec68410c5b..b78710aee4 100644
--- a/apps/web/src/features/projects/primitives/create-project.test.ts
+++ b/apps/web/src/features/projects/primitives/create-project.test.ts
@@ -54,6 +54,7 @@ describe('project creation', () => {
const service = commands();
const composer = createProjectComposer(service);
composer.setName(' Release ');
+ composer.setDescription('Goals');
composer.saveDraft(dueDate, dueValue);
const submission = composer.submit();
expect(composer.pending()).toBe(true);
@@ -61,6 +62,7 @@ describe('project creation', () => {
expect(service.create).toHaveBeenCalledOnce();
expect(service.create).toHaveBeenCalledWith({
name: 'Release',
+ description: 'Goals',
shareWithTeam: true,
properties: [{ property: dueDate, value: dueValue }],
});
@@ -83,6 +85,7 @@ describe('project creation', () => {
it("reopens a failure with its draft and the server's reason", () => {
const draft = {
name: 'Release',
+ description: '',
shareWithTeam: true,
properties: [{ property: dueDate, value: dueValue }],
};
diff --git a/apps/web/src/features/projects/primitives/create-project.ts b/apps/web/src/features/projects/primitives/create-project.ts
index 007bf8d539..affc1f031f 100644
--- a/apps/web/src/features/projects/primitives/create-project.ts
+++ b/apps/web/src/features/projects/primitives/create-project.ts
@@ -34,6 +34,9 @@ export function createProjectComposer(
initial?: ProjectComposerDraft
) {
const [name, setName] = createSignal(initial?.name ?? '');
+ const [description, setDescription] = createSignal(
+ initial?.description ?? ''
+ );
const [shareWithTeam, setShareWithTeam] = createSignal(
initial?.shareWithTeam ?? true
);
@@ -50,6 +53,7 @@ export function createProjectComposer(
const [error, setError] = createSignal(initial?.error);
const snapshot = (): ProjectComposerDraft => ({
name: name(),
+ description: description(),
shareWithTeam: shareWithTeam(),
properties: [...drafts().values()],
error: error(),
@@ -57,6 +61,8 @@ export function createProjectComposer(
return {
name,
setName,
+ description,
+ setDescription,
shareWithTeam,
setShareWithTeam,
drafts,
@@ -66,6 +72,7 @@ export function createProjectComposer(
clear() {
if (pending()) return;
setName('');
+ setDescription('');
setShareWithTeam(true);
setDrafts(new Map());
setError(undefined);
diff --git a/apps/web/src/features/projects/project-view.test.tsx b/apps/web/src/features/projects/project-view.test.tsx
index f4c0cb18e7..4f52a2608e 100644
--- a/apps/web/src/features/projects/project-view.test.tsx
+++ b/apps/web/src/features/projects/project-view.test.tsx
@@ -73,7 +73,12 @@ afterEach(() => {
fixtures.touch = false;
});
const projectId = '01992d2f-8444-7000-8000-000000000001';
-const draft = { name: 'Launch', shareWithTeam: true, properties: [] };
+const draft = {
+ name: 'Launch',
+ description: '',
+ shareWithTeam: true,
+ properties: [],
+};
const project = { id: projectId } as ProjectDetail;
function submit(popover: boolean) {
fixtures.popover = popover;
diff --git a/apps/web/src/features/projects/queries/create-project.test.ts b/apps/web/src/features/projects/queries/create-project.test.ts
index e690634eef..ca0e589c97 100644
--- a/apps/web/src/features/projects/queries/create-project.test.ts
+++ b/apps/web/src/features/projects/queries/create-project.test.ts
@@ -56,6 +56,7 @@ it('sends drafted values with the create and leaves unset ones to the server', (
expect(
createInitiativeInput({
name: 'Launch',
+ description: ' Ship it ',
shareWithTeam: false,
properties: [
{
@@ -74,6 +75,7 @@ it('sends drafted values with the create and leaves unset ones to the server', (
})
).toEqual({
name: 'Launch',
+ description: 'Ship it',
shareWithTeam: false,
propertyValues: [
{
@@ -108,6 +110,7 @@ it('resolves as soon as the server answers, seeding the detail and refreshing li
const project = await mutation.mutateAsync({
name: 'Launch',
+ description: ' ',
shareWithTeam: true,
properties: [],
});
@@ -145,6 +148,7 @@ it('rejects without refreshing when the server refuses the create', async () =>
await expect(
mutation.mutateAsync({
name: 'Launch',
+ description: '',
shareWithTeam: true,
properties: [],
})
diff --git a/apps/web/src/features/projects/queries/create-project.ts b/apps/web/src/features/projects/queries/create-project.ts
index b9b35b6595..bd7c04e6a8 100644
--- a/apps/web/src/features/projects/queries/create-project.ts
+++ b/apps/web/src/features/projects/queries/create-project.ts
@@ -16,6 +16,7 @@ export function createInitiativeInput(
): CreateInitiativeInput {
return {
name: input.name,
+ description: input.description.trim() || undefined,
shareWithTeam: input.shareWithTeam,
propertyValues: input.properties.flatMap(({ property, value }) => {
const graphqlValue = toGraphqlSetPropertyValue(
diff --git a/apps/web/src/features/projects/views/create-project.test.tsx b/apps/web/src/features/projects/views/create-project.test.tsx
index 47bd91a09d..c8df95ef90 100644
--- a/apps/web/src/features/projects/views/create-project.test.tsx
+++ b/apps/web/src/features/projects/views/create-project.test.tsx
@@ -1,5 +1,6 @@
import { Dialog } from '@app/components/ui/components/Dialog';
import { focusPopoverInput } from '@components/app/split-layout/utils/focusPopoverInput';
+import type { EditorControls } from '@core/component/LexicalMarkdown/builder/types';
import type { Property } from '@property/types';
import { cleanup, fireEvent, render, screen } from '@solidjs/testing-library';
import { type ComponentProps, type ParentProps, Show } from 'solid-js';
@@ -47,6 +48,39 @@ vi.mock('@property/component/PropertyValuePill', () => ({
</button>
),
}));
+// Lexical is exercised in the browser; this stands in for its editor contract.
+vi.mock('../components/project-description-composer', () => ({
+ ProjectDescriptionComposer: (
+ props: ComponentProps<
+ typeof import('../components/project-description-composer').ProjectDescriptionComposer
+ >
+ ) => {
+ let element: HTMLTextAreaElement | undefined;
+ props.ref({
+ getLexical: () => ({ update: () => {}, focus: () => element?.focus() }),
+ clear: () => {
+ if (element) element.value = '';
+ props.onChange('');
+ },
+ } as unknown as EditorControls);
+ return (
+ <textarea
+ ref={element}
+ aria-label="Project description"
+ value={props.initialValue}
+ disabled={props.disabled}
+ onInput={(event) => props.onChange(event.currentTarget.value)}
+ onKeyDown={(event) => {
+ event.stopPropagation();
+ if (event.key === 'Enter' && (event.metaKey || event.ctrlKey)) {
+ props.onSubmit();
+ }
+ if (event.key === 'Escape') props.onLeaveStart();
+ }}
+ />
+ );
+ },
+}));
beforeEach(() => vi.stubGlobal('scrollTo', vi.fn()));
afterEach(() => {
cleanup();
@@ -156,12 +190,19 @@ it('hands its draft and one create with the drafted values to the host the momen
true
);
fireEvent.input(title, { target: { value: ' Launch ' } });
+ fireEvent.input(
+ screen.getByRole('textbox', { name: 'Project description' }),
+ {
+ target: { value: 'Ship **it**' },
+ }
+ );
fireEvent.click(screen.getByRole('button', { name: 'Set due date' }));
fireEvent.click(screen.getByRole('checkbox', { name: 'Share with my team' }));
fireEvent.click(screen.getByRole('button', { name: /Create Project/ }));
expect(service.create).toHaveBeenCalledOnce();
expect(service.create).toHaveBeenCalledWith({
name: 'Launch',
+ description: 'Ship **it**',
shareWithTeam: false,
properties: [{ property: dueDate, value: dueValue }],
});
@@ -170,6 +211,7 @@ it('hands its draft and one create with the drafted values to the host the momen
const [submission] = onSubmit.mock.calls[0];
expect(submission.draft).toEqual({
name: ' Launch ',
+ description: 'Ship **it**',
shareWithTeam: false,
properties: [{ property: dueDate, value: dueValue }],
});
@@ -182,6 +224,7 @@ it('shows a reopened creation failure and resubmits the same draft', () => {
const service = commands();
const { onSubmit } = setup(service, {
name: 'Launch',
+ description: 'Goals',
shareWithTeam: true,
properties: [{ property: dueDate, value: dueValue }],
error: 'offline',
@@ -189,10 +232,14 @@ it('shows a reopened creation failure and resubmits the same draft', () => {
expect(screen.getByRole('alert')).toHaveProperty('textContent', 'offline');
const title = screen.getByRole('textbox', { name: 'Project name' });
expect(title).toHaveProperty('value', 'Launch');
+ expect(
+ screen.getByRole('textbox', { name: 'Project description' })
+ ).toHaveProperty('value', 'Goals');
fireEvent.keyDown(title, { key: 'Enter', ctrlKey: true });
expect(onSubmit).toHaveBeenCalledOnce();
expect(service.create).toHaveBeenCalledWith({
name: 'Launch',
+ description: 'Goals',
shareWithTeam: true,
properties: [{ property: dueDate, value: dueValue }],
});
@@ -230,12 +277,50 @@ it('blocks empty and duplicate keyboard submits, and clears intentionally', () =
);
expect(fresh.onContinueInSplit).toHaveBeenCalledWith({
name: '',
+ description: '',
shareWithTeam: true,
properties: [],
error: undefined,
});
});
+it('moves from the name to the description on Enter, and creates from the description', () => {
+ const { service, onSubmit } = setup();
+ const title = screen.getByRole('textbox', { name: 'Project name' });
+ const description = screen.getByRole('textbox', {
+ name: 'Project description',
+ });
+ fireEvent.input(title, { target: { value: 'Launch' } });
+ const enter = new KeyboardEvent('keydown', {
+ key: 'Enter',
+ bubbles: true,
+ cancelable: true,
+ });
+ title.dispatchEvent(enter);
+ expect(enter.defaultPrevented).toBe(true);
+ expect(document.activeElement).toBe(description);
+ expect(service.create).not.toHaveBeenCalled();
+
+ fireEvent.keyDown(description, { key: 'Escape' });
+ expect(document.activeElement).toBe(title);
+ fireEvent.keyDown(title, { key: 'ArrowDown' });
+ expect(document.activeElement).toBe(description);
+
+ fireEvent.input(description, { target: { value: 'Goals' } });
+ fireEvent.click(screen.getByRole('button', { name: 'Clear Draft' }));
+ expect(description).toHaveProperty('value', '');
+ fireEvent.input(title, { target: { value: 'Launch' } });
+ fireEvent.input(description, { target: { value: 'Goals' } });
+ fireEvent.keyDown(description, { key: 'Enter', metaKey: true });
+ expect(onSubmit).toHaveBeenCalledOnce();
+ expect(service.create).toHaveBeenCalledWith({
+ name: 'Launch',
+ description: 'Goals',
+ shareWithTeam: true,
+ properties: [],
+ });
+});
+
it('keeps the project name focused after the popover applies initial focus', async () => {
setup(commands(), undefined, true);
await screen.findByRole('dialog');
diff --git a/apps/web/src/features/projects/views/create-project.tsx b/apps/web/src/features/projects/views/create-project.tsx
index 0cdc63b860..817a9f7c63 100644
--- a/apps/web/src/features/projects/views/create-project.tsx
+++ b/apps/web/src/features/projects/views/create-project.tsx
@@ -1,8 +1,11 @@
+import type { EditorControls } from '@core/component/LexicalMarkdown/builder/types';
import ArrowsOutIcon from '@phosphor/arrows-out.svg';
import XIcon from '@phosphor/x.svg';
import { PropertyValuePill } from '@property/component/PropertyValuePill';
import { Button, Checkbox, EntityComposer } from '@ui';
+import { $getRoot } from 'lexical';
import { For, onMount, Show } from 'solid-js';
+import { ProjectDescriptionComposer } from '../components/project-description-composer';
import { useProjectsContext } from '../context/projects-context';
import {
createProjectComposer,
@@ -25,7 +28,14 @@ export function CreateProject(props: {
props.initialDraft
);
let titleInput: HTMLInputElement | undefined;
+ let description: EditorControls | undefined;
onMount(() => titleInput?.focus());
+ const focusDescriptionStart = () => {
+ const editor = description?.getLexical();
+ if (!editor) return;
+ editor.update(() => $getRoot().getFirstChild()?.selectStart());
+ editor.focus();
+ };
const submit = () => {
const submission = composer.submit();
if (submission) props.onSubmit(submission);
@@ -67,7 +77,13 @@ export function CreateProject(props: {
</Button>
</Show>
</div>
- <Show when={composer.name() || composer.drafts().size > 0}>
+ <Show
+ when={
+ composer.name() ||
+ composer.description().trim() ||
+ composer.drafts().size > 0
+ }
+ >
<Button
tabIndex={-1}
size="sm"
@@ -77,6 +93,7 @@ export function CreateProject(props: {
disabled={composer.pending()}
onClick={() => {
composer.clear();
+ description?.clear();
titleInput?.focus();
}}
>
@@ -106,8 +123,34 @@ export function CreateProject(props: {
required
disabled={composer.pending()}
onInput={(event) => composer.setName(event.currentTarget.value)}
+ onKeyDown={(event) => {
+ if (
+ event.isComposing ||
+ event.metaKey ||
+ event.ctrlKey ||
+ event.shiftKey ||
+ event.altKey ||
+ (event.key !== 'Enter' && event.key !== 'ArrowDown')
+ ) {
+ return;
+ }
+ event.preventDefault();
+ focusDescriptionStart();
+ }}
/>
</EntityComposer.Title>
+ <EntityComposer.Body>
+ <ProjectDescriptionComposer
+ initialValue={composer.description()}
+ disabled={composer.pending()}
+ onChange={composer.setDescription}
+ onSubmit={submit}
+ onLeaveStart={() => titleInput?.focus()}
+ ref={(controls) => {
+ description = controls;
+ }}
+ />
+ </EntityComposer.Body>
<div>
<EntityComposer.Properties>
<For each={definitions.properties()}>
diff --git a/docs/AGENT_GUIDE/tasks.md b/docs/AGENT_GUIDE/tasks.md
index d660c17c3a..db44658cf1 100644
--- a/docs/AGENT_GUIDE/tasks.md
+++ b/docs/AGENT_GUIDE/tasks.md
@@ -367,16 +367,20 @@ hosted data.
`New project` and the global Create menu's `Project` action (C, then P) open
the same native composer host and layout as task creation,
-with a project name and the shared property pills for Status, Priority,
-Assignees, and Due date. Team sharing is enabled by default.
+with a project name, a Markdown description (`Add description...`), and the
+shared property pills for Status, Priority, Assignees, and Due date. Team
+sharing is enabled by default. As in the task composer, Enter or ArrowDown in
+the name moves to the description instead of creating the project; Escape, or
+ArrowUp/Shift+Tab at the start of the description, returns to the name. The
+description seeds the project's Overview description.
Project Status offers `Not Started`, `In Progress`, and `Completed` in the
composer, list, and detail/side-panel pickers. The Status filter uses the same
three choices. Task statuses are unchanged. Existing project values from the
previous status catalog remain visible until an editor changes them.
Submit with
-`Create Project` or Cmd/Ctrl+Enter. `Continue editing in split` preserves the
-name, properties, and sharing choice; `Clear Draft` resets an uncreated draft.
+`Create Project` or Cmd/Ctrl+Enter from the name or description. `Continue
+editing in split` preserves the name, description, properties, and sharing choice; `Clear Draft` resets an uncreated draft.
Leaving a property unset keeps its normal server default.
Submitting closes the composer at once; a full composer returns its split to
Projects, and Back skips the submitted composer. One request creates the project