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): create tasks from kanban column headers (#8565)

dev-rb79c5475ec6b0
diff --git a/apps/web/src/features/projects/project-detail.tsx b/apps/web/src/features/projects/project-detail.tsx
index 8f10404894..d2e408c6fd 100644
--- a/apps/web/src/features/projects/project-detail.tsx
+++ b/apps/web/src/features/projects/project-detail.tsx
@@ -27,6 +27,7 @@ import { SYSTEM_PROPERTY_IDS } from '@property/identifiers';
import type { Property } from '@property/types';
import { Button } from '@ui';
import { createSignal, Match, Show, Suspense, Switch } from 'solid-js';
+import type { TaskCreateOptions } from '../tasks-view/types';
import { DeleteProjectsDialog } from './components/delete-projects-dialog';
import { ProjectMenuDropdown } from './components/project-row-menu';
import { ProjectContentSkeleton } from './components/project-skeletons';
@@ -218,7 +219,7 @@ function ProjectDetailHost(props: ProjectDetailProps) {
route: projectDetailRoute,
params: { projectId: props.route.id, section },
});
- const createTask = (dueDate?: Date) => {
+ const createTask = (options?: TaskCreateOptions) => {
const projectId = props.route.id;
layout.popoverSplit({
type: 'component',
@@ -228,7 +229,8 @@ function ProjectDetailHost(props: ProjectDetailProps) {
...args: Parameters<NonNullable<ComposeTaskProps['createTask']>>
) => commands.createTask(projectId, ...args),
initialProjectId: projectId,
- initialDueDate: dueDate,
+ initialDueDate: options?.dueDate,
+ composerContext: options?.composerContext,
onSuccess: () => section('tasks'),
},
});
diff --git a/apps/web/src/features/projects/views/project-tasks-list.tsx b/apps/web/src/features/projects/views/project-tasks-list.tsx
index d2c7d8b32a..39723389cc 100644
--- a/apps/web/src/features/projects/views/project-tasks-list.tsx
+++ b/apps/web/src/features/projects/views/project-tasks-list.tsx
@@ -15,7 +15,7 @@ import { createProjectTasksDataSource } from '../queries/project-tasks';
export type ProjectTasksProviderProps = ParentProps<{
projectId: string;
onOpenTask: NonNullable<TasksViewProviderProps['onOpenTask']>;
- onCreateTask?: (dueDate?: Date) => void;
+ onCreateTask?: TasksViewProviderProps['onCreateTask'];
}>;
export type ProjectTasksListProps = Omit<
diff --git a/apps/web/src/features/projects/views/project-workspace.tsx b/apps/web/src/features/projects/views/project-workspace.tsx
index 26ecf46f71..be8747b0ce 100644
--- a/apps/web/src/features/projects/views/project-workspace.tsx
+++ b/apps/web/src/features/projects/views/project-workspace.tsx
@@ -36,7 +36,7 @@ export function ProjectWorkspace(props: {
commands: ReturnType<ProjectsContext['createCommands']>;
section: ProjectSection;
onOpenTask: ProjectTasksListProps['onOpenTask'];
- onCreateTask(dueDate?: Date): void;
+ onCreateTask: NonNullable<ProjectTasksListProps['onCreateTask']>;
discussion: JSX.Element;
description: JSX.Element;
}) {
diff --git a/apps/web/src/features/tasks-view/task-composer.ts b/apps/web/src/features/tasks-view/task-composer.ts
new file mode 100644
index 0000000000..688608d2c3
--- /dev/null
+++ b/apps/web/src/features/tasks-view/task-composer.ts
@@ -0,0 +1,56 @@
+import { PROPERTY_OPTION_IDS } from '@property/identifiers';
+import type { PropertyApiValues } from '@property/types';
+import { match } from 'ts-pattern';
+import type { TaskComposerContext } from '../task-composer/core/context';
+import type { TaskBoardGrouping } from './core/task-board';
+import { taskBoardPropertyId } from './queries/task-board';
+
+/** Keep host presets while selecting the originating board column. */
+export function taskBoardComposerContext(options: {
+ grouping: TaskBoardGrouping;
+ columnId: string;
+ scopeKey?: string;
+ context?: TaskComposerContext;
+}): TaskComposerContext {
+ const { grouping, columnId, context } = options;
+ const propertyId = taskBoardPropertyId(grouping);
+ const value = match(grouping)
+ .returnType<PropertyApiValues>()
+ .with('status', () => ({
+ valueType: 'SELECT_STRING',
+ values: [columnId || PROPERTY_OPTION_IDS.STATUS.NOT_STARTED],
+ }))
+ .with('priority', () => ({
+ valueType: 'SELECT_STRING',
+ values: columnId ? [columnId] : null,
+ }))
+ .with('assignee', 'project', () => ({
+ valueType: 'ENTITY',
+ refs: columnId
+ ? [
+ {
+ entity_id: columnId,
+ entity_type: grouping === 'project' ? 'INITIATIVE' : 'USER',
+ },
+ ]
+ : null,
+ }))
+ .exhaustive();
+
+ return {
+ key: JSON.stringify([
+ 'tasks-board',
+ options.scopeKey,
+ context?.key,
+ grouping,
+ columnId,
+ ]),
+ visiblePropertyIds: context?.visiblePropertyIds
+ ? [...new Set([...context.visiblePropertyIds, propertyId])]
+ : undefined,
+ initialPropertyValues: {
+ ...context?.initialPropertyValues,
+ [propertyId]: value,
+ },
+ };
+}
diff --git a/apps/web/src/features/tasks-view/tasks-board.tsx b/apps/web/src/features/tasks-view/tasks-board.tsx
index ab3d6bfda8..6257a9d66b 100644
--- a/apps/web/src/features/tasks-view/tasks-board.tsx
+++ b/apps/web/src/features/tasks-view/tasks-board.tsx
@@ -1,4 +1,6 @@
+import { useCreateContext } from '@app/features/command/context/create-context';
import { openEntityInSplitFromUnifiedList } from '@app/features/next-soup/utils';
+import { useSplitLayout } from '@components/app/split-layout/layout';
import { useSplitPanelOrThrow } from '@components/app/split-layout/layoutUtils';
import { useUserId } from '@core/context/user';
import { fireAndForget } from '@core/util/fireAndForget';
@@ -6,13 +8,17 @@ import { usePropertyUserDisplay } from '@property/hooks/usePropertyUserDisplay';
import type { Accessor } from 'solid-js';
import { toTaskBoardGrouping } from './core/task-board';
import { createTaskBoardQueries } from './queries/task-board-queries';
+import { taskBoardComposerContext } from './task-composer';
import { useTasksView } from './tasks-view-context';
import { TaskBoardView } from './views/task-board-view';
/** Connects the task view to query adapters and app navigation. */
export function TasksBoard(props: { ref?: (element: HTMLDivElement) => void }) {
- const { state, source, openTask, projectsEnabled } = useTasksView();
+ const context = useTasksView();
+ const { state, source, openTask, projectsEnabled } = context;
const panel = useSplitPanelOrThrow();
+ const layout = useSplitLayout();
+ const createContext = useCreateContext();
const queries = createTaskBoardQueries({
rows: source.boardRows ?? source.items,
grouping: () => toTaskBoardGrouping(state.groupBy),
@@ -28,11 +34,32 @@ export function TasksBoard(props: { ref?: (element: HTMLDivElement) => void }) {
usePropertyUserDisplay(id).name,
};
+ const canCreate = () => !!context.createTask || !context.scopeKey;
+ const createTask = (columnId: string) => {
+ if (!canCreate()) return;
+ const composerContext = taskBoardComposerContext({
+ grouping: toTaskBoardGrouping(state.groupBy),
+ columnId,
+ scopeKey: context.scopeKey ?? panel.handle.id,
+ context: createContext.snapshot('task', panel.handle.id),
+ });
+ if (context.createTask) {
+ context.createTask({ composerContext });
+ return;
+ }
+ layout.popoverSplit({
+ type: 'component',
+ id: 'task-compose',
+ params: { composerContext },
+ });
+ };
+
return (
<div class="flex size-full min-h-0 min-w-0 flex-col overflow-hidden">
<TaskBoardView
ref={props.ref}
data={data}
+ onCreate={canCreate() ? createTask : undefined}
onOpen={(task, event) => {
const opened = openTask(
{ id: task.id, fallbackName: task.name },
diff --git a/apps/web/src/features/tasks-view/tasks-gantt.tsx b/apps/web/src/features/tasks-view/tasks-gantt.tsx
index 2fdbc41003..3162944489 100644
--- a/apps/web/src/features/tasks-view/tasks-gantt.tsx
+++ b/apps/web/src/features/tasks-view/tasks-gantt.tsx
@@ -19,6 +19,7 @@ import { TASK_SORT_DEFINITIONS } from './constants';
import { taskGanttDates } from './queries/task-gantt';
import { createTaskGanttQueries } from './queries/task-gantt-queries';
import { useTasksView } from './tasks-view-context';
+import type { TaskCreateOptions } from './types';
import { TaskGanttView } from './views/task-gantt-view';
/** Reuses the host's filtered task source and task-opening capability. */
@@ -27,11 +28,14 @@ export function TasksGantt(props: { ref?: (element: HTMLDivElement) => void }) {
const { source, state, setState, openTask } = context;
const panel = useSplitPanelOrThrow();
const layout = useSplitLayout();
- const createTask = (dueDate?: Date) =>
+ const createTask = (options?: TaskCreateOptions) =>
layout.popoverSplit({
type: 'component',
id: 'task-compose',
- params: { initialDueDate: dueDate },
+ params: {
+ initialDueDate: options?.dueDate,
+ composerContext: options?.composerContext,
+ },
});
const onCreate = () =>
context.createTask ?? (!context.scopeKey ? createTask : undefined);
@@ -156,7 +160,7 @@ export function TasksGantt(props: { ref?: (element: HTMLDivElement) => void }) {
: [...ids, id]
)
}
- onCreate={onCreate() && ((dates) => onCreate()?.(dates.end))}
+ onCreate={onCreate() && ((dates) => onCreate()?.({ dueDate: dates.end }))}
onOpen={onOpen}
renderEntity={renderEntity}
/>
diff --git a/apps/web/src/features/tasks-view/tasks-view-context.tsx b/apps/web/src/features/tasks-view/tasks-view-context.tsx
index 60ce1c3f7e..b3ad2cf6a3 100644
--- a/apps/web/src/features/tasks-view/tasks-view-context.tsx
+++ b/apps/web/src/features/tasks-view/tasks-view-context.tsx
@@ -62,6 +62,7 @@ import {
} from './queries/use-tasks-query';
import { tasksTabSearch, tasksTabSearchCodec } from './tasks-tab-search';
import type {
+ TaskCreateOptions,
TaskDetailTarget,
TaskSortId,
TasksTab,
@@ -85,7 +86,7 @@ export type TasksViewProviderProps = ContextProviderProps & {
) => boolean;
onCloseTask?: () => void;
/** Host-owned task creation, including scope and permissions for embedded views. */
- onCreateTask?: (dueDate?: Date) => void;
+ onCreateTask?: (options?: TaskCreateOptions) => void;
};
export type TasksListActivationMetadata = {
@@ -101,7 +102,7 @@ type TasksListController = ListController<
export type TasksViewContext = {
scopeKey?: string;
state: Store<TasksViewState>;
- createTask?: (dueDate?: Date) => void;
+ createTask?: TasksViewProviderProps['onCreateTask'];
projectsEnabled: Accessor<boolean>;
ganttEnabled: Accessor<boolean>;
setState: SetStoreFunction<TasksViewState>;
diff --git a/apps/web/src/features/tasks-view/types.ts b/apps/web/src/features/tasks-view/types.ts
index 54b8dadf82..4d55ad1120 100644
--- a/apps/web/src/features/tasks-view/types.ts
+++ b/apps/web/src/features/tasks-view/types.ts
@@ -1,4 +1,10 @@
import type { FacetSelection, SortSelection } from '@app/features/soup';
+import type { TaskComposerContext } from '../task-composer/core/context';
+
+export type TaskCreateOptions = {
+ dueDate?: Date;
+ composerContext?: TaskComposerContext;
+};
export type TaskTab = 'my-tasks' | 'created-by-me' | 'team-tasks' | 'projects';
export type TasksTab = TaskTab;
diff --git a/apps/web/src/features/tasks-view/views/task-board-view.tsx b/apps/web/src/features/tasks-view/views/task-board-view.tsx
index 21d9fb754f..e75cd61c15 100644
--- a/apps/web/src/features/tasks-view/views/task-board-view.tsx
+++ b/apps/web/src/features/tasks-view/views/task-board-view.tsx
@@ -1,5 +1,6 @@
import { toast } from '@core/component/Toast/Toast';
import { fireAndForget } from '@core/util/fireAndForget';
+import PlusIcon from '@phosphor/plus.svg';
import { SYSTEM_PROPERTY_IDS } from '@property/identifiers';
import { hasValue } from '@property/utils/typeGuards';
import { Button } from '@ui/components/Button';
@@ -30,6 +31,7 @@ const CARD_PROPERTY_IDS = [
export function TaskBoardView(props: {
data: TaskBoardData;
onOpen(task: TaskBoardTask, event: MouseEvent): void;
+ onCreate?: (columnId: string) => void;
ref?: (element: HTMLDivElement) => void;
}) {
const { state, source, projectsEnabled, setFacets } = useTasksView();
@@ -250,6 +252,18 @@ export function TaskBoardView(props: {
grouping={grouping()}
createAssigneeName={props.data.createAssigneeName}
/>
+ <Show when={props.onCreate}>
+ <div class="ml-auto flex shrink-0">
+ <Button
+ size="icon-sm"
+ variant="ghost"
+ label={`Add task to ${column().label}`}
+ onClick={() => props.onCreate?.(column().id)}
+ >
+ <PlusIcon />
+ </Button>
+ </div>
+ </Show>
</TaskBoard.Header>
<TaskBoard.DropOverlay>
Board sorted by {sortLabel()}
diff --git a/docs/agent-guide/tasks.md b/docs/agent-guide/tasks.md
index 1ed9c18c4d..0147efe315 100644
--- a/docs/agent-guide/tasks.md
+++ b/docs/agent-guide/tasks.md
@@ -244,6 +244,15 @@ Both layouts share one grouping, which restores with the Tasks navigation entry.
List-only None and Date groupings display Status columns in Board; switching
back to List retains those selections and collapsed groups until grouping changes.
+Each column header has an icon-only **Add task** plus button. It opens the task
+composer with that column's Status, Priority, Assignee, or Project preselected,
+while preserving the originating pane's other creation presets. **Unassigned**
+and **No priority** start with that property empty. **No project** starts empty
+outside project boards; project boards always retain the current project.
+**No status** starts with **Not started**, because new tasks require a status.
+Each pane or project scope and column keeps a separate composer draft. Project
+boards hide creation actions when the project is read-only.
+
Click a card's body or title to open the task. Move at least 10 pixels with the
mouse button held to start dragging to another column; holding still does not
start a drag. Property pills remain interactive and do not start a drag.