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(tasks): give the touch task sheet its own layout (#9147)
Peter Chinman0a40b14b5632
diff --git a/.agents/rules/web/mobile.md b/.agents/rules/web/mobile.mdindex 43775596cd..6295e00e0d 100644--- a/.agents/rules/web/mobile.md+++ b/.agents/rules/web/mobile.md@@ -25,6 +25,11 @@ read their code, and follow that pattern rather than inventing a new one.control and show its touch replacement with the same one, or tablets getneither. Native checks (`isPlatform` in `@core/util/platform`) are fornative bridges and platform-specific visual effects, not layout.+- When a surface needs a different phone or touch layout, compose a separate+ mobile view from shared parts (and a shared state primitive) instead of+ branching on `isMobile()` / `isTouchDevice()` throughout one component;+ extract the parts first if needed. The task composer+ (`features/task-composer/views`) is the reference.- Gate hover and press styles with `not-touch:`; iOS leaves hover stuck.- No action lives only behind hover. `HoverCard` renders nothing on touch,so give it a tap path that opens a sheet, as `UserCardTrigger` does.diff --git a/apps/web/src/components/app/split-layout/componentRegistry.tsx b/apps/web/src/components/app/split-layout/componentRegistry.tsxindex fd2c9b1149..d16ab0085e 100644--- a/apps/web/src/components/app/split-layout/componentRegistry.tsx+++ b/apps/web/src/components/app/split-layout/componentRegistry.tsx@@ -134,7 +134,7 @@ const ComposeSkill = lazyNamed('ComposeSkill');const ComposeTask = lazyNamed(- () => import('@block-md/component/ComposeTask'),+ () => import('@app/features/task-composer/compose-task'),'ComposeTask');const ComposeDocument = lazyNamed(diff --git a/apps/web/src/components/app/split-layout/tests/activity-registration.test.tsx b/apps/web/src/components/app/split-layout/tests/activity-registration.test.tsxindex 337a9eee54..c45c8ec57b 100644--- a/apps/web/src/components/app/split-layout/tests/activity-registration.test.tsx+++ b/apps/web/src/components/app/split-layout/tests/activity-registration.test.tsx@@ -155,7 +155,7 @@ vi.mock('@app/signal/splitLayout', () => {vi.mock('@block-calendar/components/EventComposerSplit', () => ({}));vi.mock('@block-channel/component/Compose', () => ({}));vi.mock('@block-md/component/ComposeSkill', () => ({}));-vi.mock('@block-md/component/ComposeTask', () => ({+vi.mock('@app/features/task-composer/compose-task', () => ({ComposeTask: (props: {composerContext?: {key: string;diff --git a/apps/web/src/features/block-md/component/MarkdownPopup.tsx b/apps/web/src/features/block-md/component/MarkdownPopup.tsxindex 93c3bcd61d..e8c8369632 100644--- a/apps/web/src/features/block-md/component/MarkdownPopup.tsx+++ b/apps/web/src/features/block-md/component/MarkdownPopup.tsx@@ -92,6 +92,7 @@ import {useContext,} from 'solid-js';import { Dynamic } from 'solid-js/web';+import type { ComposeTaskSuccess } from '../../task-composer/core/types';import { URL_PARAMS } from '../constants';import { useMarkdownDocument } from '../context/markdown-document-context';import {@@ -103,7 +104,6 @@ import {$insertAtSavedPoint,type SavedPoint,} from '../util/insertAtSavedPoint';-import type { ComposeTaskSuccess } from './ComposeTask';import { FormatTools } from './FormatTools';import { TouchSelectionToolbar } from './TouchSelectionToolbar';diff --git a/apps/web/src/features/block-md/views/compose-document.tsx b/apps/web/src/features/block-md/views/compose-document.tsxindex f15c42f442..a0dc2c1768 100644--- a/apps/web/src/features/block-md/views/compose-document.tsx+++ b/apps/web/src/features/block-md/views/compose-document.tsx@@ -14,7 +14,7 @@ import { Button, EntityComposer } from '@ui';import { createSignal, onMount, Show, Suspense } from 'solid-js';import { DocumentFields } from '../../document-composer/components/document-fields';import { createDocumentEditor } from '../../document-composer/primitives/create-document-editor';-import type { ComposeTaskSuccess } from '../component/ComposeTask';+import type { ComposeTaskSuccess } from '../../task-composer/core/types';import { createDocumentWithTags } from '../queries/create-document-with-tags';import { createDocumentComposerTags } from '../util/documentComposerProperties';diff --git a/apps/web/src/features/projects/project-detail.tsx b/apps/web/src/features/projects/project-detail.tsxindex 1e255736b2..506b1ca56d 100644--- a/apps/web/src/features/projects/project-detail.tsx+++ b/apps/web/src/features/projects/project-detail.tsx@@ -4,6 +4,7 @@ import {makeCopyEntityIdAction,makeCopyLinkAction,} from '@app/features/next-soup/actions';+import type { ComposeTaskProps } from '@app/features/task-composer/core/types';import { useNavigate } from '@app/lib/split-router';import {projectDetailRoute,@@ -11,7 +12,6 @@ import {tasksSplitRoute,} from '@app/routes/routes';import { globalSplitManager } from '@app/signal/splitLayout';-import type { ComposeTaskProps } from '@block-md/component/ComposeTask';import { useSplitLayout } from '@components/app/split-layout/layout';import {useSplitDisplayName,diff --git a/apps/web/src/features/task-composer/compose-task.tsx b/apps/web/src/features/task-composer/compose-task.tsxnew file mode 100644index 0000000000..3528292e29--- /dev/null+++ b/apps/web/src/features/task-composer/compose-task.tsx@@ -0,0 +1,72 @@+import { useSplitLayout } from '@components/app/split-layout/layout';+import { useSplitPanelOrThrow } from '@components/app/split-layout/layoutUtils';+import { useMacroMentionLinkResolver } from '@components/app/split-layout/split-router/mention-links';+import { useUserId } from '@core/context/user';+import { isTouchDevice } from '@core/mobile/isTouchDevice';+import { Show } from 'solid-js';+import type { ComposeTaskProps } from './core/types';+import {+ createTaskComposer,+ type TaskComposerHost,+} from './primitives/task-composer';+import { DesktopTaskComposer } from './views/desktop-task-composer';+import { MobileTaskComposer } from './views/mobile-task-composer';++function createSplitTaskComposerHost(): TaskComposerHost {+ const splitPanel = useSplitPanelOrThrow();+ const { popoverSplit, openWithSplit } = useSplitLayout();+ const taskContent = (task: {+ id: string;+ optimisticSnapshot?: Uint8Array;+ }) => {+ const snapshotParams = task.optimisticSnapshot+ ? {+ params: { optimisticSnapshot: task.optimisticSnapshot },+ preserveParams: true as const,+ }+ : {};+ return { type: 'task' as const, id: task.id, ...snapshotParams };+ };+ return {+ userId: useUserId(),+ resolveAppLink: useMacroMentionLinkResolver(),+ isPopover: () => splitPanel.handle.isPopover(),+ setDisplayName: (name) => splitPanel.handle.setDisplayName(name),+ close: () => splitPanel.handle.close(),+ openComposer: (params) =>+ popoverSplit({ type: 'component', id: 'task-compose', params }),+ openTask: (task, options) =>+ openWithSplit(taskContent(task), {+ referredFrom: options.referredFrom,+ preferNewSplit: options.newSplit,+ }),+ openPendingTask: () => {+ const { split } = openWithSplit(+ { type: 'component', id: 'loading' },+ { referredFrom: 'launcher', preferNewSplit: true }+ );+ return {+ show: (task) =>+ split?.replace({+ next: taskContent(task),+ mergeHistory: true,+ referredFrom: 'launcher',+ }),+ cancel: () => split?.goBack(),+ };+ },+ };+}++/** Touch devices show a popover split in a bottom sheet, with its own layout. */+export function ComposeTask(props: ComposeTaskProps) {+ const composer = createTaskComposer(props, createSplitTaskComposerHost());+ return (+ <Show+ when={isTouchDevice() && composer.isPopover()}+ fallback={<DesktopTaskComposer composer={composer} />}+ >+ <MobileTaskComposer composer={composer} />+ </Show>+ );+}diff --git a/apps/web/src/features/task-composer/core/types.ts b/apps/web/src/features/task-composer/core/types.tsnew file mode 100644index 0000000000..9873f47e39--- /dev/null+++ b/apps/web/src/features/task-composer/core/types.ts@@ -0,0 +1,50 @@+import type { createTaskWithProperties } from '@block-md/util/taskComposerProperties';+import type { TaskComposerContext } from './context';++export type ComposeTaskSuccess = {+ documentId: string;+ title: string;+ content: string;+};++export interface ComposeTaskProps {+ /** Replaces how the task is created, e.g. to also add it to a project. */+ createTask?: typeof createTaskWithProperties;+ onCreateTask?: (title: string, content: string) => void;+ onClose?: () => void;+ /** Identity of a locally retained, unconfirmed submission. */+ recoveredDraftId?: string;+ initialTitle?: string;+ initialContent?: string;+ placeholder?: string;+ initialAssigneeIds?: string[];+ /** Start in this project, e.g. when composing from the project's page. */+ initialProjectId?: string;+ composerContext?: TaskComposerContext;+ /** Prefill the visible Due Date control when creating from a timeline. */+ initialDueDate?: Date;+ /**+ * When provided, replaces the default success behavior (auto-copy link ++ * toast) so the caller can handle the created task however it needs.+ */+ onSuccess?: (result: ComposeTaskSuccess) => void;+ /**+ * Fires when the user submits and the dialog closes but the create-task+ * network call is still in flight. The originating editor can use this to+ * drop in an await placeholder which onSuccess later replaces.+ */+ onCreateStart?: (init: { title: string; content: string }) => void;+ /**+ * Fires if the create-task API call fails after the dialog has been closed.+ * Pairs with onCreateStart for placeholder cleanup.+ */+ onCreateFailure?: () => void;+ /**+ * Offers a toggle that links the created task back where it was composed+ * from; `insert` runs after creation while the toggle is on.+ */+ linkInSource?: {+ label: string;+ insert: (result: ComposeTaskSuccess) => void;+ };+}diff --git a/apps/web/src/features/block-md/component/ComposeTask.tsx b/apps/web/src/features/task-composer/primitives/task-composer.tssimilarity index 51%rename from apps/web/src/features/block-md/component/ComposeTask.tsxrename to apps/web/src/features/task-composer/primitives/task-composer.tsindex 7b13315ba8..24457e5a8b 100644--- a/apps/web/src/features/block-md/component/ComposeTask.tsx+++ b/apps/web/src/features/task-composer/primitives/task-composer.ts@@ -1,147 +1,91 @@import {- ComposeTaskTitleEditor,- TaskTitleAccessory,-} from '../../task-composer/components/title-editor';--export {- ComposeTaskTitleEditor,- TaskTitleAccessory,-} from '../../task-composer/components/title-editor';--import { useSplitLayout } from '@components/app/split-layout/layout';-import { useSplitPanelOrThrow } from '@components/app/split-layout/layoutUtils';-import { useMacroMentionLinkResolver } from '@components/app/split-layout/split-router/mention-links';+ createTaskComposerProperties,+ createTaskWithProperties,+ DEFAULT_TASK_COMPOSER_PROPERTY_IDS,+ defaultTaskPropertyValues,+ taskComposerProjectValue,+} from '@block-md/util/taskComposerProperties';+import {+ clearTaskComposerDraft,+ createTaskComposerLinkInSource,+ createTaskComposerSharing,+ loadTaskComposerDraft,+ saveTaskComposerDraft,+ taskComposerContextStorage,+} from '@block-md/util/taskComposerStorage';+import {+ clearTaskSubmission,+ createTaskSubmissionList,+ submitTaskDraft,+ taskSubmissionDraftStorage,+ taskSubmissionKey,+} from '@block-md/util/taskComposerSubmissions';import { COMPOSER_STORAGE_CLEARED } from '@core/auth/clear-composer-storage';import { buildConfig } from '@core/component/LexicalMarkdown/builder/MarkdownConfigBuilder';-import { MarkdownShell } from '@core/component/LexicalMarkdown/builder/MarkdownShell';import { addMediaFromFile } from '@core/component/LexicalMarkdown/plugins/media';+import type { MentionLinkResolver } from '@core/component/LexicalMarkdown/plugins/text-paste/textPastePlugin';import { initializeEditorEmpty } from '@core/component/LexicalMarkdown/utils';import type { PortalScope } from '@core/component/ScopedPortal';import { toast } from '@core/component/Toast/Toast';-import { useUserId } from '@core/context/user';import { registerHotkey, useHotkeyDOMScope } from '@core/hotkey/hotkeys';-import { isTouchDevice } from '@core/mobile/isTouchDevice';import { fireAndForget } from '@core/util/fireAndForget';-import { onElementConnect } from '@core/util/onElementConnect';import { buildSimpleEntityUrl } from '@core/util/url';import ArrowSquareOutIcon from '@icon/system/regular/arrow-square-out.svg';-import ArrowsOutIcon from '@icon/system/regular/arrows-out.svg';-import PaperclipIcon from '@icon/system/regular/paperclip.svg';import SplitIcon from '@icon/system/regular/square-half.svg';-import XIcon from '@icon/system/regular/x.svg';import { Telemetry } from '@macro-inc/observability';-import { Modals } from '@property/component/modal';import { SYSTEM_PROPERTY_IDS } from '@property/constants';-import { PropertiesProvider } from '@property/context/PropertiesContext';-import { InlineTagsPill } from '@property/tags';import type { PropertyApiValues } from '@property/types';import { queryReadyGate } from '@queries/gate';import { useUpsertToHistoryMutation } from '@queries/history/history';import { useUserTeamsQuery } from '@queries/team/teams';import { debounce } from '@solid-primitives/scheduled';import { useQueryClient } from '@tanstack/solid-query';-import { Button, cn, EntityComposer, Scroll, ToggleSwitch, Tooltip } from '@ui';import type { LexicalEditor } from 'lexical';import {+ type Accessor,createEffect,createSignal,- For,onCleanup,onMount,- Show,- Suspense,} from 'solid-js';import { reconcile, unwrap } from 'solid-js/store';import { tabbable } from 'tabbable';-import type { TaskComposerContext } from '../../task-composer/core/context';-import {- createTaskComposerProperties,- createTaskWithProperties,- DEFAULT_TASK_COMPOSER_PROPERTY_IDS,- defaultTaskPropertyValues,- taskComposerProjectValue,-} from '../util/taskComposerProperties';-import {- clearTaskComposerDraft,- createTaskComposerLinkInSource,- createTaskComposerSharing,- loadTaskComposerDraft,- saveTaskComposerDraft,- taskComposerContextStorage,-} from '../util/taskComposerStorage';-import {- clearTaskSubmission,- createTaskSubmissionList,- submitTaskDraft,- taskSubmissionDraftStorage,- taskSubmissionKey,-} from '../util/taskComposerSubmissions';-import { EditorSystemMessage } from './EditorSystemMessage';-import { InlinePropertyValue } from './InlinePropertyValue';-import { RecoverTaskDrafts } from './RecoverTaskDrafts';-import { TaskComposerPropertyEditor } from './TaskComposerPropertyEditor';-import { SimilarTasksSection } from './TaskDuplicateList';+import type { ComposeTaskProps, ComposeTaskSuccess } from '../core/types';type ComposerTagLayoutMode = 'bottom' | 'title';-/**- * Toast preview component for successful task creation.- * @param props- * @returns- */--export type ComposeTaskSuccess = {- documentId: string;- title: string;- content: string;+/** A task to open, with the snapshot that renders it before it syncs. */+type OpenableTask = { id: string; optimisticSnapshot?: Uint8Array };++/** App capabilities the composer uses; `compose-task.tsx` supplies them. */+export type TaskComposerHost = {+ userId: Accessor<string | undefined>;+ resolveAppLink: MentionLinkResolver | undefined;+ /** Whether the composer floats over the layout rather than filling a split. */+ isPopover: Accessor<boolean>;+ setDisplayName(name: string): void;+ close(): void;+ /** Opens another composer on a recovered submission. */+ openComposer(+ params: Pick<ComposeTaskProps, 'composerContext' | 'recoveredDraftId'>+ ): void;+ openTask(+ task: OpenableTask,+ options: { newSplit: boolean; referredFrom: 'launcher' | null }+ ): void;+ /** Holds a new split for a task that is still being created. */+ openPendingTask(): { show(task: OpenableTask): void; cancel(): void };};-export interface ComposeTaskProps {- /** Replaces how the task is created, e.g. to also add it to a project. */- createTask?: typeof createTaskWithProperties;- onCreateTask?: (title: string, content: string) => void;- onClose?: () => void;- /** Identity of a locally retained, unconfirmed submission. */- recoveredDraftId?: string;- initialTitle?: string;- initialContent?: string;- placeholder?: string;- initialAssigneeIds?: string[];- /** Start in this project, e.g. when composing from the project's page. */- initialProjectId?: string;- composerContext?: TaskComposerContext;- /** Prefill the visible Due Date control when creating from a timeline. */- initialDueDate?: Date;- /**- * When provided, replaces the default success behavior (auto-copy link +- * toast) so the caller can handle the created task however it needs.- */- onSuccess?: (result: ComposeTaskSuccess) => void;- /**- * Fires when the user submits and the dialog closes but the create-task- * network call is still in flight. The originating editor can use this to- * drop in an await placeholder which onSuccess later replaces.- */- onCreateStart?: (init: { title: string; content: string }) => void;- /**- * Fires if the create-task API call fails after the dialog has been closed.- * Pairs with onCreateStart for placeholder cleanup.- */- onCreateFailure?: () => void;- /**- * Offers a toggle that links the created task back where it was composed- * from; `insert` runs after creation while the toggle is on.- */- linkInSource?: {- label: string;- insert: (result: ComposeTaskSuccess) => void;- };-}--export function ComposeTask(props: ComposeTaskProps) {- const splitPanel = useSplitPanelOrThrow();- const { popoverSplit, openWithSplit } = useSplitLayout();- const currentUserId = useUserId();+/**+ * Draft, property, and submission state for one task composer, shared by the+ * desktop and mobile views through the `TaskComposer` parts.+ */+export function createTaskComposer(+ props: ComposeTaskProps,+ host: TaskComposerHost+) {+ const currentUserId = host.userId;const queryClient = useQueryClient();const draftOwner = currentUserId() ?? '';const submissions = createTaskSubmissionList(@@ -261,12 +205,8 @@ export function ComposeTask(props: ComposeTaskProps) {const [tagLayoutMode, setTagLayoutMode] =createSignal<ComposerTagLayoutMode>('bottom');let titleEditorRoot: HTMLDivElement | undefined;- let attachInputRef: HTMLInputElement | undefined;- const handleAttachFiles = async (event: Event) => {- const input = event.currentTarget as HTMLInputElement;- const files = Array.from(input.files ?? []);- input.value = '';+ const attachFiles = async (files: File[]) => {const editor = bodyEditor();if (!editor || files.length === 0) return;for (const file of files) {@@ -343,7 +283,7 @@ export function ComposeTask(props: ComposeTaskProps) {saveTaskComposerDraft(draftSnapshot(), draftStorage);}});- const clearDraft = () => {+ const discardSavedDraft = () => {debouncedSave.clear();clearTaskComposerDraft(draftStorage);};@@ -407,32 +347,21 @@ export function ComposeTask(props: ComposeTaskProps) {toast.failure('Failed to copy link to clipboard');}- const snapshotParams = optimisticSnapshot- ? { params: { optimisticSnapshot }, preserveParams: true as const }- : {};-+ const task = { id: documentId, optimisticSnapshot };toast.success('Task created', {subtext: linkCopied ? 'Link copied' : undefined,actions: [{label: 'Open',icon: ArrowSquareOutIcon,- onClick: () => {- openWithSplit(- { type: 'task', id: documentId, ...snapshotParams },- { referredFrom: null }- );- },+ onClick: () =>+ host.openTask(task, { newSplit: false, referredFrom: null }),},{label: 'Open (New Split)',icon: SplitIcon,- onClick: () => {- openWithSplit(- { type: 'task', id: documentId, ...snapshotParams },- { referredFrom: null, preferNewSplit: true }- );- },+ onClick: () =>+ host.openTask(task, { newSplit: true, referredFrom: null }),},],});@@ -440,17 +369,13 @@ export function ComposeTask(props: ComposeTaskProps) {const recoverDraft = (id: string) => {if (currentUserId() !== draftOwner) return;- popoverSplit({- type: 'component',- id: 'task-compose',- params: {- composerContext: props.composerContext,- recoveredDraftId: id,- },+ host.openComposer({+ composerContext: props.composerContext,+ recoveredDraftId: id,});};- const createTask = async (inSplit: boolean) => {+ const submit = async (inSplit: boolean) => {if (!draftSessionActive ||isCreating() ||@@ -477,7 +402,7 @@ export function ComposeTask(props: ComposeTaskProps) {const definitions = createDefinitions();const snapshot = draftSnapshot();const shareWithTeam = sharesWithTeam();- let split: ReturnType<typeof openWithSplit>['split'];+ let pendingSplit: ReturnType<typeof host.openPendingTask> | undefined;let started = false;let createdTask: Awaited<ReturnType<typeof createTaskWithProperties>> =null;@@ -508,7 +433,7 @@ export function ComposeTask(props: ComposeTaskProps) {showFailureToast: false,onCreated: confirm,onMutate: () => {- clearDraft();+ discardSavedDraft();if (keepOpen) {submittedInput = false;skipNextDraftSave = true;@@ -519,13 +444,10 @@ export function ComposeTask(props: ComposeTaskProps) {if (editor) initializeEditorEmpty(editor);requestAnimationFrame(() => titleEditorRoot?.focus());} else {- splitPanel.handle.close();+ host.close();props.onClose?.();if (inSplit) {- split = openWithSplit(- { type: 'component', id: 'loading' },- { referredFrom: 'launcher', preferNewSplit: true }- ).split;+ pendingSplit = host.openPendingTask();} else {props.onCreateStart?.({title: taskTitle,@@ -553,7 +475,7 @@ export function ComposeTask(props: ComposeTaskProps) {return;}if (!inSplit && !keepOpen) props.onCreateFailure?.();- split?.goBack();+ pendingSplit?.cancel();if (currentUserId() === draftOwner) {toast.failure('Task creation was not confirmed', {subtext:@@ -568,23 +490,11 @@ export function ComposeTask(props: ComposeTaskProps) {if (currentUserId() !== draftOwner) return;const { documentId, initialSnapshot } = createdTask;if (inSplit) {- const snapshotParams = initialSnapshot- ? {- params: { optimisticSnapshot: initialSnapshot },- preserveParams: true as const,- }- : {};- if (split) {- split.replace({- next: { type: 'task', id: documentId, ...snapshotParams },- mergeHistory: true,- referredFrom: 'launcher',- });+ const task = { id: documentId, optimisticSnapshot: initialSnapshot };+ if (pendingSplit) {+ pendingSplit.show(task);} else {- openWithSplit(- { type: 'task', id: documentId, ...snapshotParams },- { referredFrom: 'launcher', preferNewSplit: true }- );+ host.openTask(task, { newSplit: true, referredFrom: 'launcher' });}} else if (props.onSuccess) {props.onSuccess({ documentId, title: taskTitle, content: taskContent });@@ -597,28 +507,25 @@ export function ComposeTask(props: ComposeTaskProps) {linkCreatedTask({ documentId, title: taskTitle, content: taskContent });props.onCreateTask?.(taskTitle, taskContent);};- const handleCreateTask = () => createTask(false);- const handleContinueInSplit = () => createTask(true);+ const createTask = () => submit(false);+ const continueInSplit = () => submit(true);- const handleClose = () => {- splitPanel.handle.close();+ const close = () => {+ host.close();props.onClose?.();};- const handleOpenSimilarTask = (taskId: string) => {+ const openSimilarTask = (taskId: string) => {// Closing snapshots the draft (incl. these results); open the existing task// in a new split so the composer's work isn't lost.- splitPanel.handle.close();+ host.close();props.onClose?.();- openWithSplit(- { type: 'task', id: taskId },- { referredFrom: null, preferNewSplit: true }- );+ host.openTask({ id: taskId }, { newSplit: true, referredFrom: null });};- const handleClearDraft = () => {+ const clearDraft = () => {if (recovered) clearTaskSubmission(draftOwner, recovered.id);- clearDraft();+ discardSavedDraft();skipNextDraftSave = true;setTitle('');setContent('');@@ -663,7 +570,7 @@ export function ComposeTask(props: ComposeTaskProps) {};onMount(() => {- splitPanel.handle.setDisplayName('New task');+ host.setDisplayName('New task');const container = containerRef();if (container) {attachHotkeys(container);@@ -679,16 +586,14 @@ export function ComposeTask(props: ComposeTaskProps) {scopeId: composeHotkeyScope,description: 'Create task',keyDownHandler: () => {- handleCreateTask().catch((error) =>- Telemetry.error(error, { surface: 'compose-task' })- );+ fireAndForget(createTask(), 'compose-task');return true;},runWithInputFocused: true,});const editorConfig = buildConfig('markdown')- .withAppLinkResolver(useMacroMentionLinkResolver())+ .withAppLinkResolver(host.resolveAppLink).withMentions().withTags({applyTargetLabel: 'Task',@@ -717,307 +622,57 @@ export function ComposeTask(props: ComposeTaskProps) {return true;});- const editor = editorConfig.buildHandle().lexical;- setBodyEditor(editor);- const portalScope = (): PortalScope =>- splitPanel.handle.isPopover() ? 'local' : 'block';-- // In the phone sheet the keyboard leaves too little room for the whole- // composer, so the footer pins to the bottom of the sheet's scroll. It only- // takes a background while pinned over content; at rest it would show as a- // band against the glass sheet.- const pinsFooter = () => isTouchDevice() && splitPanel.handle.isPopover();- const [footerPinned, setFooterPinned] = createSignal(false);- const observeFooter = (footer: HTMLElement) => {- if (!pinsFooter()) return;- onElementConnect(footer, () => {- const observer = new IntersectionObserver(- ([entry]) => setFooterPinned(!!entry && entry.intersectionRatio < 1),- {- root: footer.closest('[data-drawer-scroll-body]'),- // At rest the footer ends 16px above the viewport's bottom edge;- // pinned, it reaches the edge.- rootMargin: '0px 0px -15px 0px',- threshold: 1,- }- );- observer.observe(footer);- onCleanup(() => observer.disconnect());- });- };+ setBodyEditor(editorConfig.buildHandle().lexical);+ const portalScope = (): PortalScope => (host.isPopover() ? 'local' : 'block');- return (- <EntityComposer.Root tabIndex={-1} ref={setContainerRef}>- <EntityComposer.Header>- <div class="flex-1 flex items-center">- <Show when={splitPanel?.handle.isPopover()}>- <Button- onMouseDown={handleContinueInSplit}- disabled={isCreating()}- tabIndex={-1}- tooltip="Continue editing in split"- variant="ghost"- size="icon-md"- >- <ArrowsOutIcon class="size-4 shrink-0 pointer-events-none" />- </Button>- </Show>- </div>- <Show when={hasDraftChanges()}>- <Button- onMouseDown={handleClearDraft}- disabled={isCreating()}- tabIndex={-1}- tooltip="Clear Draft"- size="xs"- variant="secondary"- >- Clear Draft- </Button>- </Show>- <Show when={splitPanel?.handle.isPopover()}>- <Button- onMouseDown={handleClose}- tabIndex={-1}- tooltip="Close"- variant="ghost"- size="icon-md"- >- <XIcon class="size-4 shrink-0 pointer-events-none" />- </Button>- </Show>- </EntityComposer.Header>- <RecoverTaskDrafts- userId={draftOwner}- drafts={submissions().filter((draft) => draft.id !== recovered?.id)}- onOpen={recoverDraft}- />- <Show when={recovered}>- <div class="border-b border-edge-muted p-3 text-sm">- Recovered on this device. Task creation requires a connection. Check- Tasks before retrying to avoid creating a duplicate.- </div>- </Show>- <EntityComposer.Main>- <EntityComposer.Title>- <Show when={tagLayoutMode() === 'title'}>- <TaskTitleAccessory>- <InlineTagsPill- docTags={composerTags}- variant="secondary"- size="xs"- showPlaceholder- class="shrink-0"- onActiveChange={handleTitleTagPickerActive}- />- </TaskTitleAccessory>- </Show>- <ComposeTaskTitleEditor- value={title}- onChange={setTitle}- disabled={isCreating}- bodyEditor={bodyEditor}- containerRef={containerRef}- onUserInput={() => {- if (errorMessage()) {- setErrorMessage('');- }- }}- onTagSelected={(tag) => {- setTagLayoutMode('title');- fireAndForget(- composerTags.applyTag(tag.scope, tag.optionId),- 'compose-task'- );- }}- onDeleteTagsAtStart={deleteTitleTagsAtStart}- portalScope={portalScope()}- ref={(el) => {- titleEditorRoot = el;- }}- />- </EntityComposer.Title>-- <EntityComposer.Body class="mb-0">- <Scroll>- <MarkdownShell- config={editorConfig}- initialState={initialState.editorState}- initialValue={- initialState.editorState- ? undefined- : initialState.content || undefined- }- placeholder={props.placeholder ?? 'Add description...'}- portalScope={portalScope()}- />- </Scroll>- </EntityComposer.Body>-- <div class="shrink-0 flex items-center py-2">- <input- ref={(el) => {- attachInputRef = el;- }}- type="file"- class="hidden"- multiple- accept="image/*,video/*"- onChange={handleAttachFiles}- />- <Button- onMouseDown={() => attachInputRef?.click()}- tabIndex={-1}- tooltip="Attach image or video"- variant="ghost"- size="icon-md"- >- <PaperclipIcon class="size-4 touch:size-6 shrink-0 pointer-events-none" />- </Button>- </div>-- <Suspense fallback={<div class="h-7" />}>- <PropertiesProvider- entityType="TASK"- canEdit={true}- properties={properties}- onRefresh={() => {}}- onPropertyAdded={() => {}}- onPropertyDeleted={() => {}}- saveHandler={saveHandler}- >- <EntityComposer.Properties- on:keydown={(e) => {- const target = e.target as HTMLElement;- const container = e.currentTarget;- const tabbables = tabbable(container);- const isFirst = tabbables.indexOf(target) === 0;- const isLast =- tabbables.indexOf(target) === tabbables.length - 1;-- // Shift+Tab or ArrowUp on first property -> focus editor- if (- isFirst &&- ((e.key === 'Tab' && e.shiftKey) || e.key === 'ArrowUp')- ) {- const editor = bodyEditor();- if (editor) {- e.preventDefault();- e.stopPropagation();- editor.focus(undefined, { defaultSelection: 'rootEnd' });- }- }-- // Tab or ArrowDown on last property -> let tabbable handle or wrap- if (- isLast &&- ((e.key === 'Tab' && !e.shiftKey) || e.key === 'ArrowDown')- ) {- // Allow default Tab behavior to continue to next focusable- // element outside this container- }- }}- >- <For each={properties()}>- {(property) => (- <InlinePropertyValue- property={property}- emptyLabel={property.displayName}- />- )}- </For>- <Show when={tagLayoutMode() === 'bottom'}>- <InlineTagsPill- docTags={composerTags}- variant="secondary"- size="xs"- showPlaceholder- />- </Show>- <TaskComposerPropertyEditor- name={title()}- definitions={availableProperties()}- properties={properties()}- onAdd={addProperty}- onSave={(id, value) => setPropertyValues(id, value)}- />- </EntityComposer.Properties>- <Modals />- </PropertiesProvider>- </Suspense>- </EntityComposer.Main>-- <Show when={errorMessage()}>- <div class="w-full border-b border-edge-muted" />- <div class="p-2">- <EditorSystemMessage variant="error">- {errorMessage()}- </EditorSystemMessage>- </div>- </Show>-- {/* The team switch, Create More and Create Task need about 400px; a- phone is narrower, so the actions wrap to their own row. */}- <EntityComposer.Footer- ref={observeFooter}- class={cn(- 'flex-wrap items-center',- // -bottom-4 offsets the scroll body's bottom padding, which sticky- // positioning insets from.- pinsFooter() &&- 'sticky -bottom-4 z-1 -mx-4 -mt-3 -mb-4 px-4 pt-3 pb-4',- footerPinned() && 'bg-menu'- )}- >- <Show when={team()}>- {(team) => (- <Tooltip label={sharingHint()} tabIndex={0}>- <ToggleSwitch- class="shrink-0 ml-0.5"- checked={shareWithTeam()}- onChange={setShareWithTeam}- disabled={isCreating()}- label={`Share with ${team().name}`}- labelClass="text-xs text-ink-muted font-normal whitespace-nowrap"- />- </Tooltip>- )}- </Show>- <div class="ml-auto flex items-center gap-3">- <Show when={props.linkInSource}>- {(linkInSource) => (- <ToggleSwitch- labelClass="text-xs text-ink-muted font-normal whitespace-nowrap"- onChange={setLinkInSourceEnabled}- checked={linkInSourceEnabled()}- label={linkInSource().label}- />- )}- </Show>- <ToggleSwitch- labelClass="text-xs text-ink-muted font-normal whitespace-nowrap"- onChange={setCreateMore}- disabled={!!recovered || isCreating()}- checked={createMore()}- label="Create More"- />- <EntityComposer.Submit- variant="primary"- size="sm"- onClick={handleCreateTask}- disabled={title().trim().length === 0 || isCreating()}- hasContent={title().trim().length > 0}- >- Create Task- </EntityComposer.Submit>- </div>- </EntityComposer.Footer>-- <SimilarTasksSection- title={title}- content={content}- onOpenTask={handleOpenSimilarTask}- />- </EntityComposer.Root>- );+ return {+ props,+ draftOwner,+ submissions,+ recovered,+ initialState,+ title,+ setTitle,+ content,+ bodyEditor,+ containerRef,+ setContainerRef,+ setTitleEditorRoot: (el: HTMLDivElement) => {+ titleEditorRoot = el;+ },+ editorConfig,+ portalScope,+ isPopover: host.isPopover,+ isCreating,+ errorMessage,+ setErrorMessage,+ hasDraftChanges,+ createMore,+ setCreateMore,+ team,+ shareWithTeam,+ setShareWithTeam,+ sharingHint,+ linkInSourceEnabled,+ setLinkInSourceEnabled,+ tagLayoutMode,+ setTagLayoutMode,+ handleTitleTagPickerActive,+ deleteTitleTagsAtStart,+ properties,+ setPropertyValues,+ availableProperties,+ addProperty,+ saveHandler,+ composerTags,+ attachFiles,+ recoverDraft,+ createTask,+ continueInSplit,+ close,+ openSimilarTask,+ clearDraft,+ };}++export type TaskComposerController = ReturnType<typeof createTaskComposer>;diff --git a/apps/web/src/features/task-composer/views/desktop-task-composer.tsx b/apps/web/src/features/task-composer/views/desktop-task-composer.tsxnew file mode 100644index 0000000000..6c00404613--- /dev/null+++ b/apps/web/src/features/task-composer/views/desktop-task-composer.tsx@@ -0,0 +1,41 @@+import { EntityComposer } from '@ui';+import type { TaskComposerController } from '../primitives/task-composer';+import { TaskComposer } from './task-composer-parts';++/** The task composer in a split or the desktop dialog. */+export function DesktopTaskComposer(props: {+ composer: TaskComposerController;+}) {+ return (+ <TaskComposer.Root composer={props.composer}>+ <EntityComposer.Header>+ <div class="flex-1 flex items-center">+ <TaskComposer.ContinueInSplit />+ </div>+ <TaskComposer.ClearDraft />+ <TaskComposer.Close />+ </EntityComposer.Header>+ <TaskComposer.Recovery />+ <EntityComposer.Main>+ <TaskComposer.Title />+ <TaskComposer.Body />+ <div class="shrink-0 flex items-center py-2">+ <TaskComposer.Attach />+ </div>+ <TaskComposer.Properties />+ </EntityComposer.Main>+ <TaskComposer.ErrorMessage />+ {/* The team switch, Create More and Create Task need about 400px; a+ narrow split wraps the actions to their own row. */}+ <EntityComposer.Footer class="flex-wrap items-center">+ <TaskComposer.ShareToggle />+ <div class="ml-auto flex items-center gap-3">+ <TaskComposer.LinkInSourceToggle />+ <TaskComposer.CreateMoreToggle />+ <TaskComposer.Submit />+ </div>+ </EntityComposer.Footer>+ <TaskComposer.SimilarTasks />+ </TaskComposer.Root>+ );+}diff --git a/apps/web/src/features/task-composer/views/mobile-task-composer.tsx b/apps/web/src/features/task-composer/views/mobile-task-composer.tsxnew file mode 100644index 0000000000..a01bbcafba--- /dev/null+++ b/apps/web/src/features/task-composer/views/mobile-task-composer.tsx@@ -0,0 +1,73 @@+import { onElementConnect } from '@core/util/onElementConnect';+import { cn, EntityComposer } from '@ui';+import { createSignal, onCleanup } from 'solid-js';+import type { TaskComposerController } from '../primitives/task-composer';+import { TaskComposer } from './task-composer-parts';++/** The task composer in the touch bottom sheet. */+export function MobileTaskComposer(props: {+ composer: TaskComposerController;+}) {+ // The keyboard leaves too little room for the whole composer, so the header+ // pins to the top of the sheet's scroll to keep Create Task in reach. It+ // only takes a background while pinned over content; at rest it would show+ // as a band against the glass sheet.+ const [headerPinned, setHeaderPinned] = createSignal(false);+ const observeHeader = (header: HTMLElement) => {+ onElementConnect(header, () => {+ const observer = new IntersectionObserver(+ ([entry]) => setHeaderPinned(!!entry && entry.intersectionRatio < 1),+ {+ root: header.closest('[data-drawer-scroll-body]'),+ // Pinned at -1px, the header's top pixel leaves the scroll viewport.+ threshold: 1,+ }+ );+ observer.observe(header);+ onCleanup(() => observer.disconnect());+ });+ };++ return (+ <TaskComposer.Root composer={props.composer}>+ <EntityComposer.Header+ ref={observeHeader}+ class={cn(+ // -mt-4 and pt-4 offset the composer's padding so the header rests+ // where it would have been.+ 'sticky -top-px z-1 -mx-4 -mt-4 -mb-3 px-4 pt-4 pb-3',+ headerPinned() && 'bg-menu'+ )}+ >+ <div class="flex-1 flex items-center">+ <TaskComposer.ContinueInSplit />+ </div>+ {/* Far enough from Create Task that a tap meant for one cannot land+ on the other. */}+ <div class="flex items-center gap-8">+ <TaskComposer.Clear />+ <TaskComposer.Submit />+ </div>+ </EntityComposer.Header>+ <TaskComposer.Recovery />+ {/* The sheet sizes the composer to its content, so nothing needs+ clipping, and the property row can scroll to the sheet's edges. */}+ <EntityComposer.Main class="overflow-visible">+ <TaskComposer.Title />+ <TaskComposer.Body />+ <div class="shrink-0 flex items-center py-2">+ <TaskComposer.Attach />+ </div>+ <div class="-mx-4 shrink-0 overflow-x-auto overscroll-x-contain scrollbar-hidden">+ <TaskComposer.Properties class="w-max flex-nowrap px-4" />+ </div>+ </EntityComposer.Main>+ <TaskComposer.ErrorMessage />+ {/* Hidden when there is neither a team nor a source to link back to. */}+ <EntityComposer.Footer class="items-center empty:hidden">+ <TaskComposer.ShareToggle />+ <TaskComposer.LinkInSourceToggle />+ </EntityComposer.Footer>+ </TaskComposer.Root>+ );+}diff --git a/apps/web/src/features/task-composer/views/task-composer-parts.tsx b/apps/web/src/features/task-composer/views/task-composer-parts.tsxnew file mode 100644index 0000000000..b9350d1df2--- /dev/null+++ b/apps/web/src/features/task-composer/views/task-composer-parts.tsx@@ -0,0 +1,412 @@+import { EditorSystemMessage } from '@block-md/component/EditorSystemMessage';+import { InlinePropertyValue } from '@block-md/component/InlinePropertyValue';+import { RecoverTaskDrafts } from '@block-md/component/RecoverTaskDrafts';+import { TaskComposerPropertyEditor } from '@block-md/component/TaskComposerPropertyEditor';+import { SimilarTasksSection } from '@block-md/component/TaskDuplicateList';+import { MarkdownShell } from '@core/component/LexicalMarkdown/builder/MarkdownShell';+import { fireAndForget } from '@core/util/fireAndForget';+import ArrowsOutIcon from '@icon/system/regular/arrows-out.svg';+import PaperclipIcon from '@icon/system/regular/paperclip.svg';+import XIcon from '@icon/system/regular/x.svg';+import { Modals } from '@property/component/modal';+import { PropertiesProvider } from '@property/context/PropertiesContext';+import { InlineTagsPill } from '@property/tags';+import { Button, EntityComposer, Scroll, ToggleSwitch, Tooltip } from '@ui';+import {+ createContext,+ For,+ type JSX,+ Show,+ Suspense,+ useContext,+} from 'solid-js';+import { tabbable } from 'tabbable';+import {+ ComposeTaskTitleEditor,+ TaskTitleAccessory,+} from '../components/title-editor';+import type { TaskComposerController } from '../primitives/task-composer';++const TaskComposerPartsContext = createContext<TaskComposerController>();++function useTaskComposer() {+ const composer = useContext(TaskComposerPartsContext);+ if (!composer) {+ throw new Error('TaskComposer parts must be rendered inside Root');+ }+ return composer;+}++function Root(props: {+ composer: TaskComposerController;+ children: JSX.Element;+}) {+ return (+ <TaskComposerPartsContext.Provider value={props.composer}>+ <EntityComposer.Root tabIndex={-1} ref={props.composer.setContainerRef}>+ {props.children}+ </EntityComposer.Root>+ </TaskComposerPartsContext.Provider>+ );+}++function ContinueInSplit() {+ const composer = useTaskComposer();+ return (+ <Show when={composer.isPopover()}>+ <Button+ onMouseDown={composer.continueInSplit}+ disabled={composer.isCreating()}+ tabIndex={-1}+ tooltip="Continue editing in split"+ variant="ghost"+ size="icon-md"+ >+ <ArrowsOutIcon class="size-4 shrink-0 pointer-events-none" />+ </Button>+ </Show>+ );+}++function ClearDraft() {+ const composer = useTaskComposer();+ return (+ <Show when={composer.hasDraftChanges()}>+ <Button+ onMouseDown={composer.clearDraft}+ disabled={composer.isCreating()}+ tabIndex={-1}+ tooltip="Clear Draft"+ size="xs"+ variant="secondary"+ >+ Clear Draft+ </Button>+ </Show>+ );+}++/** `ClearDraft` as a text-only action, for the touch sheet's header. */+function Clear() {+ const composer = useTaskComposer();+ return (+ <Show when={composer.hasDraftChanges()}>+ <Button+ variant="ghost"+ size="sm"+ disabled={composer.isCreating()}+ onClick={composer.clearDraft}+ >+ Clear+ </Button>+ </Show>+ );+}++function Close() {+ const composer = useTaskComposer();+ return (+ <Show when={composer.isPopover()}>+ <Button+ onMouseDown={composer.close}+ tabIndex={-1}+ tooltip="Close"+ variant="ghost"+ size="icon-md"+ >+ <XIcon class="size-4 shrink-0 pointer-events-none" />+ </Button>+ </Show>+ );+}++/** Other unconfirmed submissions, and a notice when this draft is one. */+function Recovery() {+ const composer = useTaskComposer();+ return (+ <>+ <RecoverTaskDrafts+ userId={composer.draftOwner}+ drafts={composer+ .submissions()+ .filter((draft) => draft.id !== composer.recovered?.id)}+ onOpen={composer.recoverDraft}+ />+ <Show when={composer.recovered}>+ <div class="border-b border-edge-muted p-3 text-sm">+ Recovered on this device. Task creation requires a connection. Check+ Tasks before retrying to avoid creating a duplicate.+ </div>+ </Show>+ </>+ );+}++function Title() {+ const composer = useTaskComposer();+ return (+ <EntityComposer.Title>+ <Show when={composer.tagLayoutMode() === 'title'}>+ <TaskTitleAccessory>+ <InlineTagsPill+ docTags={composer.composerTags}+ variant="secondary"+ size="xs"+ showPlaceholder+ class="shrink-0"+ onActiveChange={composer.handleTitleTagPickerActive}+ />+ </TaskTitleAccessory>+ </Show>+ <ComposeTaskTitleEditor+ value={composer.title}+ onChange={composer.setTitle}+ disabled={composer.isCreating}+ bodyEditor={composer.bodyEditor}+ containerRef={composer.containerRef}+ onUserInput={() => {+ if (composer.errorMessage()) {+ composer.setErrorMessage('');+ }+ }}+ onTagSelected={(tag) => {+ composer.setTagLayoutMode('title');+ fireAndForget(+ composer.composerTags.applyTag(tag.scope, tag.optionId),+ 'compose-task'+ );+ }}+ onDeleteTagsAtStart={composer.deleteTitleTagsAtStart}+ portalScope={composer.portalScope()}+ ref={composer.setTitleEditorRoot}+ />+ </EntityComposer.Title>+ );+}++function Body() {+ const composer = useTaskComposer();+ return (+ <EntityComposer.Body class="mb-0">+ <Scroll>+ <MarkdownShell+ config={composer.editorConfig}+ initialState={composer.initialState.editorState}+ initialValue={+ composer.initialState.editorState+ ? undefined+ : composer.initialState.content || undefined+ }+ placeholder={composer.props.placeholder ?? 'Add description...'}+ portalScope={composer.portalScope()}+ />+ </Scroll>+ </EntityComposer.Body>+ );+}++function Attach() {+ const composer = useTaskComposer();+ let input: HTMLInputElement | undefined;+ const attachSelectedFiles = async (event: Event) => {+ const target = event.currentTarget as HTMLInputElement;+ const files = Array.from(target.files ?? []);+ target.value = '';+ await composer.attachFiles(files);+ };+ return (+ <>+ <input+ ref={(el) => {+ input = el;+ }}+ type="file"+ class="hidden"+ multiple+ accept="image/*,video/*"+ onChange={attachSelectedFiles}+ />+ <Button+ onMouseDown={() => input?.click()}+ tabIndex={-1}+ tooltip="Attach image or video"+ variant="ghost"+ size="icon-md"+ >+ <PaperclipIcon class="size-4 touch:size-6 shrink-0 pointer-events-none" />+ </Button>+ </>+ );+}++/** The property pills, tags, and Add property; `class` places the row. */+function Properties(props: { class?: string }) {+ const composer = useTaskComposer();+ return (+ <Suspense fallback={<div class="h-7" />}>+ <PropertiesProvider+ entityType="TASK"+ canEdit={true}+ properties={composer.properties}+ onRefresh={() => {}}+ onPropertyAdded={() => {}}+ onPropertyDeleted={() => {}}+ saveHandler={composer.saveHandler}+ >+ <EntityComposer.Properties+ class={props.class}+ on:keydown={(e) => {+ // Shift+Tab or ArrowUp on the first property returns to the description.+ if (!(e.key === 'ArrowUp' || (e.key === 'Tab' && e.shiftKey))) {+ return;+ }+ const target = e.target as HTMLElement;+ if (tabbable(e.currentTarget).indexOf(target) !== 0) return;+ const editor = composer.bodyEditor();+ if (!editor) return;+ e.preventDefault();+ e.stopPropagation();+ editor.focus(undefined, { defaultSelection: 'rootEnd' });+ }}+ >+ <For each={composer.properties()}>+ {(property) => (+ <InlinePropertyValue+ property={property}+ emptyLabel={property.displayName}+ />+ )}+ </For>+ <Show when={composer.tagLayoutMode() === 'bottom'}>+ <InlineTagsPill+ docTags={composer.composerTags}+ variant="secondary"+ size="xs"+ showPlaceholder+ />+ </Show>+ <TaskComposerPropertyEditor+ name={composer.title()}+ definitions={composer.availableProperties()}+ properties={composer.properties()}+ onAdd={composer.addProperty}+ onSave={(id, value) => composer.setPropertyValues(id, value)}+ />+ </EntityComposer.Properties>+ <Modals />+ </PropertiesProvider>+ </Suspense>+ );+}++function ErrorMessage() {+ const composer = useTaskComposer();+ return (+ <Show when={composer.errorMessage()}>+ <div class="w-full border-b border-edge-muted" />+ <div class="p-2">+ <EditorSystemMessage variant="error">+ {composer.errorMessage()}+ </EditorSystemMessage>+ </div>+ </Show>+ );+}++function ShareToggle() {+ const composer = useTaskComposer();+ return (+ <Show when={composer.team()}>+ {(team) => (+ <Tooltip label={composer.sharingHint()} tabIndex={0}>+ <ToggleSwitch+ class="shrink-0 ml-0.5"+ checked={composer.shareWithTeam()}+ onChange={composer.setShareWithTeam}+ disabled={composer.isCreating()}+ label={`Share with ${team().name}`}+ labelClass="text-xs text-ink-muted font-normal whitespace-nowrap"+ />+ </Tooltip>+ )}+ </Show>+ );+}++function LinkInSourceToggle() {+ const composer = useTaskComposer();+ return (+ <Show when={composer.props.linkInSource}>+ {(linkInSource) => (+ <ToggleSwitch+ labelClass="text-xs text-ink-muted font-normal whitespace-nowrap"+ onChange={composer.setLinkInSourceEnabled}+ checked={composer.linkInSourceEnabled()}+ label={linkInSource().label}+ />+ )}+ </Show>+ );+}++function CreateMoreToggle() {+ const composer = useTaskComposer();+ return (+ <ToggleSwitch+ labelClass="text-xs text-ink-muted font-normal whitespace-nowrap"+ onChange={composer.setCreateMore}+ disabled={!!composer.recovered || composer.isCreating()}+ checked={composer.createMore()}+ label="Create More"+ />+ );+}++function Submit() {+ const composer = useTaskComposer();+ return (+ <EntityComposer.Submit+ variant="primary"+ size="sm"+ onClick={composer.createTask}+ disabled={composer.title().trim().length === 0 || composer.isCreating()}+ hasContent={composer.title().trim().length > 0}+ >+ Create Task+ </EntityComposer.Submit>+ );+}++function SimilarTasks() {+ const composer = useTaskComposer();+ return (+ <SimilarTasksSection+ title={composer.title}+ content={composer.content}+ onOpenTask={composer.openSimilarTask}+ />+ );+}++/**+ * Parts of the task composer. A view creates the controller with+ * `createTaskComposer`, hands it to `Root`, and lays out the parts it shows.+ */+export const TaskComposer = {+ Root,+ ContinueInSplit,+ ClearDraft,+ Clear,+ Close,+ Recovery,+ Title,+ Body,+ Attach,+ Properties,+ ErrorMessage,+ ShareToggle,+ LinkInSourceToggle,+ CreateMoreToggle,+ Submit,+ SimilarTasks,+};diff --git a/apps/web/src/lib/core/component/LexicalMarkdown/plugins/actions/actions.ts b/apps/web/src/lib/core/component/LexicalMarkdown/plugins/actions/actions.tsindex e3c939f7b3..5c769e1876 100644--- a/apps/web/src/lib/core/component/LexicalMarkdown/plugins/actions/actions.ts+++ b/apps/web/src/lib/core/component/LexicalMarkdown/plugins/actions/actions.ts@@ -1,5 +1,5 @@+import type { ComposeTaskSuccess } from '@app/features/task-composer/core/types';import { globalSplitManager } from '@app/signal/splitLayout';-import type { ComposeTaskSuccess } from '@block-md/component/ComposeTask';import { toast } from '@core/component/Toast/Toast';import { enableDatabases, isFeatureEnabled } from '@core/constant/featureFlags';import { trackMention } from '@core/signal/mention';diff --git a/docs/agent-guide/tasks.md b/docs/agent-guide/tasks.mdindex af6ee69d77..878c08f8a1 100644--- a/docs/agent-guide/tasks.md+++ b/docs/agent-guide/tasks.md@@ -596,21 +596,25 @@ Use existing PRs and do not modify hosted data.On touch devices, task creation opens in a bottom sheet with a drag handle andscrollable, keyboard-aware content. Its glass pane has broad screen-scaledcorners, an 8px outer inset, and a blurred backdrop, matching the create and-filter sheets. Its footer wraps when a phone is too narrow for one row: the-`Share with <team name>` switch keeps the left corner and `Create More` and-`Create Task` move to a right-aligned row below it. When the keyboard leaves-too little room for the whole composer, the footer pins to the bottom of the-sheet (with a solid background only while pinned over content), so-`Create Task` stays visible above the keyboard. `Create Task` shows no+filter sheets. Its header has `Continue editing in split` on the left and+`Create Task` on the right, with a text-only `Clear` 32px to its left once the+draft has changes, and no close button. When the+keyboard leaves too little room for the whole composer, the header pins to the+top of the sheet (with a solid background only while pinned over content), so+`Create Task` stays in reach. The properties sit on a single line that scrolls+horizontally, with the `Share with <team name>` switch below them. The sheet+has no `Create More` switch and no similar-tasks list. `Create Task` shows nokeyboard shortcut on touch. While the keyboard is up, the tag picker opensabove its trigger so its search results stay above the keyboard. Desktop uses-the centered composer dialog.+the centered composer dialog. Both layouts are views in+`apps/web/src/features/task-composer/views` composing the shared+`TaskComposer` parts.1. Click the `Task` button (or `Create` → `Task T`, or keyboard `c` then `t`).2. A dialog opens with the title contenteditable focused (placeholder `New task`), plus`Add description...`, and property buttons: `Not Started` (status), `Priority`, assigneechip (defaults to you), `Due Date`, `Project` (when Projects is enabled; the standard- property dropdown, listing projects), `Change or select tags`, a `Create More` switch,+ property dropdown, listing projects), `Change or select tags`, a desktop-only `Create More` switch,and `Create Task Ctrl ↵` (`Create Task` alone on touch). `Attach image or video`(paperclip) sits just under thedescription, above the property buttons. If the chosen project can't be@@ -654,7 +658,7 @@ Task creation requires a connection. Before any create request, the composersaves a separate copy of the title, description/editor state, properties, andsharing choice on this device. Pending submissions do not expire and survive anapp restart. Reopen the same task composer context and choose **Recover: <title>**-to continue an unconfirmed draft; **Clear Draft** discards that recovered copy.+to continue an unconfirmed draft; **Clear Draft** (**Clear** on touch) discards that recovered copy.Explicit logout removes these account-scoped copies. Recovery does not submitanything automatically: check Tasks before retrying because a lost response maymean the task already exists. A submission still in flight cannot be recovered