From e996afbdb2e9a549c2cb63b9c306eee2b9941f74 Mon Sep 17 00:00:00 2001 From: Aarav Date: Mon, 10 Aug 2026 18:20:50 -0600 Subject: [PATCH] =?UTF-8?q?Revert=20"fix:=20upload=20chat-message=20markup?= =?UTF-8?q?=20as=20MarkupBlobRef=20instead=20of=20raw=20HTML=20=E2=80=A6"?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This reverts commit 0a16ceb12fa86dc13780f59815006f7c753e699f. --- packages/cli/src/resources/activity.ts | 13 +--- packages/cli/src/resources/approvals.ts | 16 +---- packages/cli/src/resources/channel.ts | 90 ++----------------------- packages/cli/src/resources/comment.ts | 31 +-------- 4 files changed, 11 insertions(+), 139 deletions(-) diff --git a/packages/cli/src/resources/activity.ts b/packages/cli/src/resources/activity.ts index 4607be7..56382bd 100644 --- a/packages/cli/src/resources/activity.ts +++ b/packages/cli/src/resources/activity.ts @@ -18,7 +18,6 @@ import { } from '../output/format.js' import { withSpinner } from '../output/progress.js' import { CliError, ExitCode } from '../output/errors.js' -import { uploadMarkup, generateId } from './_helpers.js' type ActivityMessage = Doc & { message?: string @@ -372,12 +371,7 @@ export async function addReply(opts: ReplyOpts): Promise { const client = await connectCli({ url: opts.url, workspace: opts.workspace }) try { const { id, doc } = await fetchActivity(client, opts.target) - // HULY-20: upload the markup first so `message` stores a MarkupBlobRef - // (prosemirror-JSON-backed), not raw HTML. The id is generated up-front - // so the markup blob's collabId and the reply doc share the same id. - const newReplyId = generateId() - const messageRef = await uploadMarkup(client, ACTIVITY_CLASS, newReplyId, 'message', opts.body, 'markup') - const data: Record = { message: messageRef } + const data: Record = { message: opts.body } const rid = await withSpinner( 'Replying…', () => @@ -388,7 +382,6 @@ export async function addReply(opts: ReplyOpts): Promise { ACTIVITY_CLASS, 'replies', data as any, - newReplyId, ), opts, ) @@ -415,13 +408,11 @@ export async function updateReply( // attachedTo pointing at the parent). `message` lives on the reply // doc itself — updateDoc, NOT updateCollection against the parent's // 'replies' tuple (which doesn't exist). - // HULY-20: upload markup first so the update lands a MarkupBlobRef. - const messageRef = await uploadMarkup(client, ACTIVITY_CLASS, id, 'message', opts.body, 'markup') await client.updateDoc( ACTIVITY_CLASS, doc.space as unknown as Ref, id as Ref, - { message: messageRef, modifiedOn: Date.now() } as any, + { message: opts.body, modifiedOn: Date.now() } as any, ) updated('updated reply', refString(id)) } finally { diff --git a/packages/cli/src/resources/approvals.ts b/packages/cli/src/resources/approvals.ts index 547ca68..4988add 100644 --- a/packages/cli/src/resources/approvals.ts +++ b/packages/cli/src/resources/approvals.ts @@ -18,7 +18,6 @@ import { } from '../output/format.js' import { withSpinner } from '../output/progress.js' import { CliError, ExitCode } from '../output/errors.js' -import { uploadMarkup, generateId } from './_helpers.js' const REQUEST_STATUSES = ['Active', 'Completed', 'Rejected', 'Cancelled'] as const type RequestStatus = (typeof REQUEST_STATUSES)[number] @@ -298,19 +297,7 @@ export async function commentOnApproval(opts: CommentOpts): Promise { const client = await connectCli({ url: opts.url, workspace: opts.workspace }) try { const { id, doc } = await fetchRequest(client, opts.ref!) - // HULY-20: upload markup so `message` stores a MarkupBlobRef, not raw - // HTML. Generate id up-front so the markup blob's collabId matches - // the ChatMessage doc's id. No --dry-run flag on this surface today. - const newCommentId = generateId() - const messageRef = await uploadMarkup( - client, - 'chunter:class:ChatMessage' as Ref>, - newCommentId, - 'message', - opts.body, - 'markup', - ) - const data: Record = { message: messageRef } + const data: Record = { message: opts.body } if (opts.decision) data.decision = opts.decision const cid = await withSpinner( 'Commenting…', @@ -322,7 +309,6 @@ export async function commentOnApproval(opts: CommentOpts): Promise { REQUEST_CLASS, 'comments', data as any, - newCommentId, ), opts, ) diff --git a/packages/cli/src/resources/channel.ts b/packages/cli/src/resources/channel.ts index cee9346..7061201 100644 --- a/packages/cli/src/resources/channel.ts +++ b/packages/cli/src/resources/channel.ts @@ -6,7 +6,6 @@ import { normalizeSocialKey } from '../auth/social.js' import { shouldJson, json, table, COLUMNS, C, success, updated, bulkRemoved } from '../output/format.js' import { withSpinner } from '../output/progress.js' import { CliError, ExitCode } from '../output/errors.js' -import { uploadMarkup, generateId } from './_helpers.js' type Channel = Doc & { name: string @@ -547,21 +546,8 @@ export async function sendChannelMessage( const client = await connectCli({ url: opts.url, workspace: opts.workspace }) try { const channel = await resolveChannel(client, ref) - // HULY-20: pre-upload the markup so `message` stores a MarkupBlobRef, - // not raw HTML. Generate the id up-front so the markup blob's collabId - // matches the ChatMessage doc's id (the platform keys the blob by - // `${class}:${id}:${attribute}`). - const newMessageId = generateId() - // Defer the actual upload until after the dry-run guard below — same - // pattern as the HULY-8 updateIssue fix. Dry-run must not write to - // MinIO. The dry-run preview shows `message: ''` (the placeholder) + - // a `wouldUploadMarkup` note so users see what would happen. - let messageRef = '' - if (!opts.dryRun) { - messageRef = await uploadMarkup(client, CHAT_MESSAGE_CLASS, newMessageId, 'message', body, 'markup') - } const data: Record = { - message: messageRef, + message: body, } if (opts.dryRun) { console.log('would send channel message:') @@ -574,12 +560,6 @@ export async function sendChannelMessage( attachedToClass: CHANNEL_CLASS, collection: 'messages', data, - wouldUploadMarkup: { - objectClass: CHAT_MESSAGE_CLASS, - objectId: newMessageId, - objectAttr: 'message', - bodyBytes: body.length, - }, }, null, 2, @@ -595,7 +575,6 @@ export async function sendChannelMessage( CHANNEL_CLASS, 'messages', data as any, - newMessageId, ), ) if (shouldJson({ json: opts.json, ci: opts.ci })) { @@ -631,23 +610,8 @@ export async function updateChannelMessage( if (msg.attachedTo !== channel._id) { throw new CliError(ExitCode.NotFound, 'message does not belong to this channel') } - // HULY-20: upload the markup so the update lands a MarkupBlobRef in - // `message`, not raw HTML. The existing messageId is reused so the - // markup blob's collabId stays consistent across updates. Deferred - // until after the dry-run guard below (same pattern as HULY-8). - let messageRef = '' - if (!opts.dryRun) { - messageRef = await uploadMarkup( - client, - CHAT_MESSAGE_CLASS, - messageId as Ref, - 'message', - body, - 'markup', - ) - } const data: Record = { - message: messageRef, + message: body, editedOn: Date.now(), } if (opts.dryRun) { @@ -773,24 +737,8 @@ export async function addThreadReply( try { const parent = await client.findOne(CHAT_MESSAGE_CLASS, { _id: targetId as Ref }) if (!parent) throw new CliError(ExitCode.NotFound, `target message ${targetId} not found`) - // HULY-20: upload markup first so `message` stores a MarkupBlobRef. - // The reply lives in chunter:class:ThreadMessage (subclass of - // ChatMessage), and the markup blob is keyed by that subclass id. - // Deferred until after the dry-run guard (same pattern as HULY-8). - const newReplyId = generateId() - let messageRef = '' - if (!opts.dryRun) { - messageRef = await uploadMarkup( - client, - 'chunter:class:ThreadMessage' as Ref>, - newReplyId, - 'message', - body, - 'markup', - ) - } const data: Record = { - message: messageRef, + message: body, } if (opts.dryRun) { console.log('would add thread reply:') @@ -811,7 +759,6 @@ export async function addThreadReply( CHAT_MESSAGE_CLASS, 'replies', data as any, - newReplyId, ), ) if (shouldJson({ json: opts.json, ci: opts.ci })) { @@ -844,20 +791,7 @@ export async function updateThreadReply( _id: replyId as Ref, }) if (!reply) throw new CliError(ExitCode.NotFound, `thread reply ${replyId} not found`) - // HULY-20: upload markup so the update lands a MarkupBlobRef. Deferred - // until after the dry-run guard (same pattern as HULY-8). - let messageRef = '' - if (!opts.dryRun) { - messageRef = await uploadMarkup( - client, - 'chunter:class:ThreadMessage' as Ref>, - replyId as Ref, - 'message', - body, - 'markup', - ) - } - const data: Record = { message: messageRef, editedOn: Date.now() } + const data: Record = { message: body, editedOn: Date.now() } if (opts.dryRun) { console.log(`would update thread reply ${replyId}:`) console.log( @@ -1105,14 +1039,7 @@ export async function sendDmMessage( }) const dm = await client.findOne(DM_CLASS, { _id: dmId as Ref }) if (!dm) throw new CliError(ExitCode.NotFound, `DM ${dmRef} not found`) - // HULY-20: upload markup so `message` stores a MarkupBlobRef, not raw - // HTML. Deferred until after the dry-run guard (same pattern as HULY-8). - const newMessageId = generateId() - let messageRef = '' - if (!opts.dryRun) { - messageRef = await uploadMarkup(client, CHAT_MESSAGE_CLASS, newMessageId, 'message', body, 'markup') - } - const data: Record = { message: messageRef } + const data: Record = { message: body } if (opts.dryRun) { console.log('would send DM:') console.log( @@ -1124,12 +1051,6 @@ export async function sendDmMessage( attachedToClass: DM_CLASS, collection: 'messages', data, - wouldUploadMarkup: { - objectClass: CHAT_MESSAGE_CLASS, - objectId: newMessageId, - objectAttr: 'message', - bodyBytes: body.length, - }, }, null, 2, @@ -1145,7 +1066,6 @@ export async function sendDmMessage( DM_CLASS, 'messages', data as any, - newMessageId, ), ) if (shouldJson({ json: opts.json, ci: opts.ci })) { diff --git a/packages/cli/src/resources/comment.ts b/packages/cli/src/resources/comment.ts index d70f88b..858f184 100644 --- a/packages/cli/src/resources/comment.ts +++ b/packages/cli/src/resources/comment.ts @@ -6,7 +6,6 @@ import { shouldJson, json, table, COLUMNS, success, updated, bulkRemoved } from import { withSpinner } from '../output/progress.js' import { CliError, ExitCode } from '../output/errors.js' import { readEnv } from '../auth/env.js' -import { uploadMarkup, generateId } from './_helpers.js' type ChatMessage = Doc & { message: string @@ -86,19 +85,6 @@ export async function addComment(opts: { }) const issue = await client.findOne(CLASS.Issue as Ref>, { _id: issueId }) if (!issue) throw new CliError(ExitCode.NotFound, `issue ${opts.issue} not found`) - // HULY-20: pre-upload the markup so the `message` field stores a - // MarkupBlobRef (pointing to a prosemirror-JSON blob in MinIO) instead of - // a raw HTML string. Generating the id up-front lets us use the same - // id for both the markup blob's collabId and the ChatMessage doc. - const newMessageId = generateId() - const messageRef = await uploadMarkup( - client, - CLASS.ChatMessage as Ref>, - newMessageId, - 'message', - body, - 'markup', - ) const id = await withSpinner( 'Adding comment…', () => @@ -108,14 +94,13 @@ export async function addComment(opts: { issueId, CLASS.Issue, 'comments', - { message: messageRef } as any, - newMessageId, + { message: body } as any, ), opts, ) invalidateIndex(client, CLASS.ChatMessage) if (shouldJson({ json: opts.json, ci: opts.ci })) { - json({ _id: id, attachedTo: issueId, message: messageRef }) + json({ _id: id, attachedTo: issueId, message: body }) } else { success('added comment', `on ${opts.issue}`, id) } @@ -145,16 +130,6 @@ export async function updateComment( }) const comment = await client.findOne(CLASS.ChatMessage as Ref>, { _id: commentId }) if (!comment) throw new CliError(ExitCode.NotFound, `comment ${ref} not found`) - // HULY-20: same fix as addComment — upload the markup first so the - // update lands a MarkupBlobRef in `message`, not raw HTML. - const messageRef = await uploadMarkup( - client, - CLASS.ChatMessage as Ref>, - commentId, - 'message', - body, - 'markup', - ) await withSpinner( 'Updating comment…', () => @@ -162,7 +137,7 @@ export async function updateComment( CLASS.ChatMessage as Ref>, (comment as Doc).space as Ref, commentId as Ref, - { message: messageRef, editedOn: Date.now() } as any, + { message: body, editedOn: Date.now() } as any, ), opts, )