fix(messages): normalize escaped markdown newlines
This commit is contained in:
1 parent
6ce7e63c71
commit
31aac7c0de
9 files changed
+78
-7
No files matched your search
@@ -1,6 +1,7 @@
|
||||
import { randomUUID } from "node:crypto";
|
||||
import type { DatabaseSync } from "node:sqlite";
|
||||
import type { CommentRecord } from "@shared/types";
|
||||
import { normalizeMarkdownText } from "@shared/markdown-text";
|
||||
import type { ReadAll } from "./helpers";
|
||||
import { nowIso } from "./helpers";
|
||||
|
||||
@@ -19,12 +20,13 @@ export function buildActivityMethods(
|
||||
const taskRow = getDb().prepare("select company_id from tasks where id = ?").get(input.taskId) as { company_id: string } | undefined;
|
||||
if (!taskRow) throw new Error("Task not found.");
|
||||
if (taskRow.company_id !== input.companyId) throw new Error("Task does not belong to this company.");
|
||||
const body = normalizeMarkdownText(input.body);
|
||||
const id = randomUUID();
|
||||
const ts = nowIso();
|
||||
getDb().prepare(
|
||||
"insert into task_comments (id, company_id, task_id, author_agent_id, author_name, body, created_at) values (?, ?, ?, ?, ?, ?, ?)",
|
||||
).run(id, input.companyId, input.taskId, input.authorAgentId, input.authorName, input.body, ts);
|
||||
return { id, companyId: input.companyId, taskId: input.taskId, authorAgentId: input.authorAgentId, authorName: input.authorName, body: input.body, createdAt: ts };
|
||||
).run(id, input.companyId, input.taskId, input.authorAgentId, input.authorName, body, ts);
|
||||
return { id, companyId: input.companyId, taskId: input.taskId, authorAgentId: input.authorAgentId, authorName: input.authorName, body, createdAt: ts };
|
||||
},
|
||||
|
||||
listComments(taskId: string): CommentRecord[] {
|
||||
|
||||
@@ -2,6 +2,7 @@ import { randomUUID } from "node:crypto";
|
||||
import type { DatabaseSync, SQLInputValue } from "node:sqlite";
|
||||
import log from "electron-log/main.js";
|
||||
import type { AgentMessageRecord, AgentRecord } from "@shared/types";
|
||||
import { normalizeMarkdownText } from "@shared/markdown-text";
|
||||
import {
|
||||
BOARD_READER_ID,
|
||||
type ReadAll,
|
||||
@@ -66,6 +67,7 @@ export function buildMessageMethods(
|
||||
}
|
||||
const senderKind = input.senderKind
|
||||
?? (input.fromAgentId === BOARD_READER_ID ? "human" : "agent");
|
||||
const body = normalizeMarkdownText(input.body);
|
||||
const id = randomUUID();
|
||||
const createdAt = nowIso();
|
||||
// Single transaction: the row and its mention fan-out must land
|
||||
@@ -86,7 +88,7 @@ export function buildMessageMethods(
|
||||
channel,
|
||||
input.channelTargetId ?? null,
|
||||
input.subject,
|
||||
input.body,
|
||||
body,
|
||||
input.priority ?? "normal",
|
||||
input.parentMessageId ?? null,
|
||||
input.attachmentsJson ?? "[]",
|
||||
|
||||
Reference in new issue
Block a user