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.

chg(md): flag on discussion thread for all md subtypes (#4247)

Seamus37171bfbf4b4
diff --git a/js/app/packages/block-md/comments/documentDiscussionSource.ts b/js/app/packages/block-md/comments/documentDiscussionSource.ts
index 02a68d40ae..33fe0a1657 100644
--- a/js/app/packages/block-md/comments/documentDiscussionSource.ts
+++ b/js/app/packages/block-md/comments/documentDiscussionSource.ts
@@ -1,4 +1,4 @@
-import { useBlockId } from '@core/block';
+import { useBlockAliasedName, useBlockId } from '@core/block';
import type {
DiscussionComment,
DiscussionSource,
@@ -54,13 +54,14 @@ function toViewThread(ct: CommentThread): DiscussionThread {
/**
* [`DiscussionSource`] backed by the document annotations system — the
- * `DISCUSSION:`-marked threads on a task document. Quarantines the numeric
+ * `DISCUSSION:`-marked threads on a markdown document. Quarantines the numeric
* id ↔ string adaptation and the document-specific request shapes so the
* shared discussion UI stays backend-agnostic. Must be called within a
* block/component owner (it wires the existing block resources).
*/
export function createDocumentDiscussionSource(): DiscussionSource {
const blockId = useBlockId();
+ const blockAliasedName = useBlockAliasedName();
// Comment affordances gate on can-comment (main switched tasks off can-edit).
const canComment = useCanComment();
const userId = useUserId();
@@ -102,7 +103,7 @@ export function createDocumentDiscussionSource(): DiscussionSource {
},
buildCommentLink(comment) {
return buildSimpleEntityUrl(
- { type: 'task', id: blockId },
+ { type: blockAliasedName, id: blockId },
{ [URL_PARAMS.commentId]: comment.id }
);
},
diff --git a/js/app/packages/block-md/component/TaskDiscussion.tsx b/js/app/packages/block-md/component/DocumentDiscussion.tsx
similarity index 72%
rename from js/app/packages/block-md/component/TaskDiscussion.tsx
rename to js/app/packages/block-md/component/DocumentDiscussion.tsx
index d33e3ef0a4..d23dab494c 100644
--- a/js/app/packages/block-md/component/TaskDiscussion.tsx
+++ b/js/app/packages/block-md/component/DocumentDiscussion.tsx
@@ -1,8 +1,8 @@
import { Discussion, DiscussionProvider } from '@core/comments/discussion';
import { createDocumentDiscussionSource } from '../comments/documentDiscussionSource';
-/** Task discussion: the document annotations source feeding the shared UI. */
-export function TaskDiscussion() {
+/** Document discussion: the document annotations source feeding the shared UI. */
+export function DocumentDiscussion() {
const source = createDocumentDiscussionSource();
return (
<DiscussionProvider source={source}>
diff --git a/js/app/packages/block-md/component/MarkdownEditor.tsx b/js/app/packages/block-md/component/MarkdownEditor.tsx
index 495f482d01..9f76761252 100644
--- a/js/app/packages/block-md/component/MarkdownEditor.tsx
+++ b/js/app/packages/block-md/component/MarkdownEditor.tsx
@@ -130,7 +130,6 @@ import { IS_MAC } from '@core/constant/isMac';
import { useUserId } from '@core/context/user';
import { fileFolderDrop } from '@core/directive/fileFolderDrop';
import { isNativeMobilePlatform } from '@core/mobile/isNativeMobilePlatform';
-import { blockElementSignal } from '@core/signal/blockElement';
import {
blockFileSignal,
blockHandleSignal,
@@ -192,12 +191,8 @@ import { MarkdownPopup } from './MarkdownPopup';
false && fileFolderDrop;
-// There is an invisible div below the editor that clicks to set editor focus
-// and add a new line. This constant is the minimum height of that element (in pixels)
-// once the editor has at least one full page of content.
-const EDITOR_PADDING_BOTTOM = 200;
-// For tasks, the click target is a small fixed pad so the activity section stays visible.
-const TASK_EDITOR_PADDING_BOTTOM = 48;
+// Keep the bottom click target compact so document discussion stays visible.
+const EDITOR_CLICK_TARGET_HEIGHT = 80;
function getBlankMarkdownPlaceholder(canEdit: boolean) {
if (!canEdit) return 'This document is blank...';
@@ -231,7 +226,6 @@ export function MarkdownEditor(props: {
const md = mdStore.get;
const canEdit = useCanEdit();
const canComment = useCanComment();
- const [blockElement] = blockElementSignal;
const [findAndReplaceStore, setFindAndReplaceStore] = FindAndReplaceStore;
const docSource = blockSourceSignal.get;
@@ -667,25 +661,16 @@ export function MarkdownEditor(props: {
})
);
- const isTask = blockName === 'task';
+ const [editorHasNoContent, setEditorHasNoContent] = createSignal(false);
const observeClickTargetHeight = () => {
- if (isTask) {
- setClickTargetHeight(TASK_EDITOR_PADDING_BOTTOM);
- return;
- }
- const blockEl = blockElement();
- const rootEl = editor.getRootElement();
- if (!blockEl || !rootEl) {
- setClickTargetHeight(EDITOR_PADDING_BOTTOM);
- return;
- }
- const blockBottom = blockEl.getBoundingClientRect().bottom;
- const targetHeight =
- blockBottom - rootEl.getBoundingClientRect().bottom - 40;
- setClickTargetHeight(Math.max(targetHeight, EDITOR_PADDING_BOTTOM));
+ setClickTargetHeight(EDITOR_CLICK_TARGET_HEIGHT);
};
+ createEffect(() => {
+ observeClickTargetHeight();
+ });
+
autoRegister(
registerInternalLayoutShiftListener(editor, observeClickTargetHeight)
);
@@ -766,8 +751,6 @@ export function MarkdownEditor(props: {
}
);
- const [editorHasNoContent, setEditorHasNoContent] = createSignal(false);
-
const isBlankMarkdown = createMemo(() => {
return editorHasNoContent() && !generateMenuOpen();
});
@@ -979,11 +962,10 @@ export function MarkdownEditor(props: {
});
}}
contentEditable={isContentEditable()}
- class="ph-no-capture w-full max-w-full"
+ class="ph-no-capture w-full max-w-full min-h-52"
classList={{
'select-auto': !canEdit(),
'md-no-comments': !ENABLE_MARKDOWN_COMMENTS,
- 'min-h-52': isTask,
}}
/>
@@ -1004,6 +986,7 @@ export function MarkdownEditor(props: {
<FocusClickTarget
editor={editor}
editorFocus={editorFocus}
+ class="bg-[pink]/20"
style={{ height: `${clickTargetHeight()}px` }}
/>
<Show when={!editorReady()}>
diff --git a/js/app/packages/block-md/component/Notebook.tsx b/js/app/packages/block-md/component/Notebook.tsx
index 00dc16784f..1ad774b371 100644
--- a/js/app/packages/block-md/component/Notebook.tsx
+++ b/js/app/packages/block-md/component/Notebook.tsx
@@ -6,14 +6,13 @@ import {
} from '@block-md/comments/commentStore';
import { useGoToTempRedirect } from '@block-md/signal/location';
import { mdStore } from '@block-md/signal/markdownBlockData';
-import { useBlockAliasedName, useBlockId } from '@core/block';
+import { useBlockId } from '@core/block';
import type { LoroManager } from '@core/collab/manager';
import { editorFocusSignal } from '@core/component/LexicalMarkdown/utils';
import { ParamsProvider } from '@core/component/ParamsProvider';
import {
DEV_MODE_ENV,
ENABLE_MARKDOWN_COMMENTS,
- ENABLE_RAIL_CHAT_TASK_COMMENTS,
LOCAL_ONLY,
} from '@core/constant/featureFlags';
import { useIsMacroTeam } from '@core/context/team';
@@ -32,14 +31,13 @@ import {
createSignal,
onCleanup,
onMount,
- Show,
untrack,
} from 'solid-js';
+import { DocumentDiscussion } from './DocumentDiscussion';
import { InlineTaskGithubPullRequests } from './InlineTaskGithubPullRequests';
import { InlineTaskProperties } from './InlineTaskProperties';
import { InstructionsEditor } from './InstructionsEditor';
import { MarkdownEditor } from './MarkdownEditor';
-import { TaskDiscussion } from './TaskDiscussion';
import { TaskDuplicateMatchPill } from './TaskDuplicateMatches';
import { TitleEditor } from './TitleEditor';
import {
@@ -87,7 +85,6 @@ export function Notebook(props: { loroManager: LoroManager }) {
const setWideEnoughForComments = commentWidthSignal.set;
const documentName = useBlockDocumentName();
const scopeId = blockHotkeyScopeSignal.get;
- const isTask = useBlockAliasedName() === 'task';
const md = mdStore.get;
const { navigatedFromJK } = useNavigatedFromJK();
@@ -296,9 +293,7 @@ export function Notebook(props: { loroManager: LoroManager }) {
setShowLexicalStateDebugger(false)
}
/>
- <Show when={ENABLE_RAIL_CHAT_TASK_COMMENTS && isTask}>
- <TaskDiscussion />
- </Show>
+ <DocumentDiscussion />
</ParamsProvider>
</div>
<div
diff --git a/js/app/packages/core/constant/featureFlags.ts b/js/app/packages/core/constant/featureFlags.ts
index 3a9a1978e6..6f6133ff44 100644
--- a/js/app/packages/core/constant/featureFlags.ts
+++ b/js/app/packages/core/constant/featureFlags.ts
@@ -327,11 +327,6 @@ export const ENABLE_APP_STORE_QR_CODE = resolveFeatureFlag(
true
);
-export const ENABLE_RAIL_CHAT_TASK_COMMENTS = resolveFeatureFlag(
- 'RAIL_CHAT_TASK_COMMENTS',
- true
-);
-
export const ENABLE_PR_DISCUSSION_INPUT = resolveFeatureFlag(
'ENABLE_PR_DISCUSSION_INPUT',
false