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
fix(lexical-service): announce agent sessions with a reply-target parent (#6625)
Wolf Mermelsteinb89b2a49e188
diff --git a/.github/workflows/web-app-check-main.yml b/.github/workflows/web-app-check-main.ymlindex 5ed045ad05..4d6f382043 100644--- a/.github/workflows/web-app-check-main.yml+++ b/.github/workflows/web-app-check-main.yml@@ -113,6 +113,9 @@ jobs:- name: Check Lexical Service Typesrun: bun run checkworking-directory: services/lexical-service+ - name: Test Lexical Service Endpoints+ run: bun test src+ working-directory: services/lexical-service- name: Teardown Nixif: always()uses: './.github/actions/teardown-nix'diff --git a/services/lexical-service/src/endpoints/extract-reply.test.ts b/services/lexical-service/src/endpoints/extract-reply.test.tsnew file mode 100644index 0000000000..78c10a88e1--- /dev/null+++ b/services/lexical-service/src/endpoints/extract-reply.test.ts@@ -0,0 +1,47 @@+import '../polyfills/prism';+import { describe, expect, it } from 'bun:test';+import { fromHono } from 'chanfana';+import { Hono } from 'hono';+import { ExtractReplyEndpoint } from './extract-reply';++const app = new Hono();+fromHono(app).post('/extract-reply', ExtractReplyEndpoint);+const request = (markdown: string) =>+ app.request('/extract-reply', {+ method: 'POST',+ headers: { 'Content-Type': 'application/json' },+ body: JSON.stringify({ markdown }),+ });+const target = {+ targetMessageId: 'message',+ targetThreadId: 'thread',+ displayText: 'hello',+ senderId: 'user',+};++describe('extract reply', () => {+ it('returns the parent of a leading reply target', async () => {+ const parent = { type: 'channel', id: 'channel' };+ const response = await request(+ `<m-reply-target>${JSON.stringify({ parent, ...target })}</m-reply-target>\n\nplease fix`+ );+ expect(response.status).toBe(200);+ expect(await response.json<unknown>()).toEqual({+ reply: { parent, ...target },+ });+ });+ it('reads a channelId-only reply target as a channel parent', async () => {+ const response = await request(+ `<m-reply-target>${JSON.stringify({ channelId: 'channel', ...target })}</m-reply-target>\n\nplease fix`+ );+ expect(response.status).toBe(200);+ expect(await response.json<unknown>()).toEqual({+ reply: { parent: { type: 'channel', id: 'channel' }, ...target },+ });+ });+ it('returns null for a blockquote', async () => {+ const response = await request('> quoted\n\nplease fix');+ expect(response.status).toBe(200);+ expect(await response.json<unknown>()).toEqual({ reply: null });+ });+});diff --git a/services/lexical-service/src/endpoints/extract-reply.ts b/services/lexical-service/src/endpoints/extract-reply.tsindex 2b3c243783..8ae081d365 100644--- a/services/lexical-service/src/endpoints/extract-reply.ts+++ b/services/lexical-service/src/endpoints/extract-reply.ts@@ -1,61 +1,64 @@-import { extractExplicitReply } from "@macro-inc/lexical-core/utils/explicit-reply";-import { OpenAPIRoute } from "chanfana";-import type { Context } from "hono";-import { z } from "zod";-import { handleEndpointError } from "../lib/error-handler";-import { standardErrorResponses } from "../lib/schemas";+import { extractExplicitReply } from '@macro-inc/lexical-core/utils/explicit-reply';+import { OpenAPIRoute } from 'chanfana';+import type { Context } from 'hono';+import { z } from 'zod';+import { handleEndpointError } from '../lib/error-handler';+import { standardErrorResponses } from '../lib/schemas';const extractReplyRequest = z.object({- markdown: z.string(),+ markdown: z.string(),});const replyTarget = z.object({- channelId: z.string(),- targetMessageId: z.string(),- targetThreadId: z.string(),- displayText: z.string(),- senderId: z.string(),+ parent: z.object({+ type: z.enum(['channel', 'document']),+ id: z.string(),+ }),+ targetMessageId: z.string(),+ targetThreadId: z.string(),+ displayText: z.string(),+ senderId: z.string(),});const extractReplyResponse = z.object({- reply: replyTarget.nullable(),+ reply: replyTarget.nullable(),});export class ExtractReplyEndpoint extends OpenAPIRoute {- schema = {- summary: "Extract an explicit reply target from Markdown",- description:- "Parses Macro Markdown and returns the leading ReplyTarget node when it is followed by authored content. Standard blockquotes do not count as replies.",- request: {- body: {- content: {- "application/json": {- schema: extractReplyRequest,- },- },- },- },- responses: {- 200: {- description: "Successfully evaluated the markdown",- content: {- "application/json": {- schema: extractReplyResponse,- },- },- },- ...standardErrorResponses,- },- };+ schema = {+ summary: 'Extract an explicit reply target from Markdown',+ description:+ 'Parses Macro Markdown and returns the leading ReplyTarget node when it is followed by authored content. Standard blockquotes do not count as replies.',+ request: {+ body: {+ content: {+ 'application/json': {+ schema: extractReplyRequest,+ },+ },+ },+ },+ responses: {+ 200: {+ description: 'Successfully evaluated the markdown',+ content: {+ 'application/json': {+ schema: extractReplyResponse,+ },+ },+ },+ ...standardErrorResponses,+ },+ };- async handle(c: Context) {- try {- const { body } = await this.getValidatedData<typeof this.schema>();- return c.json({- reply: extractExplicitReply(body.markdown),- });- } catch (error) {- return handleEndpointError(error, c);- }- }+ async handle(c: Context) {+ try {+ const { body } = await this.getValidatedData<typeof this.schema>();+ return c.json({+ reply: extractExplicitReply(body.markdown),+ });+ } catch (error) {+ return handleEndpointError(error, c);+ }+ }}diff --git a/tooling/xtask/crates/xtask_workflows/src/workflows/web_app_check_main.rs b/tooling/xtask/crates/xtask_workflows/src/workflows/web_app_check_main.rsindex 9a35135020..232c2136a8 100644--- a/tooling/xtask/crates/xtask_workflows/src/workflows/web_app_check_main.rs+++ b/tooling/xtask/crates/xtask_workflows/src/workflows/web_app_check_main.rs@@ -82,6 +82,7 @@ fn typescript() -> Job {.add_step(check_types()).add_step(check_collaboration_types()).add_step(check_lexical_service_types())+ .add_step(test_lexical_service()).add_step(steps::teardown_nix())}@@ -226,6 +227,12 @@ fn check_lexical_service_types() -> Step<Run> {.working_directory(xtask_paths::repo_dir!("services/lexical-service"))}+fn test_lexical_service() -> Step<Run> {+ Step::new("Test Lexical Service Endpoints")+ .run("bun test src")+ .working_directory(xtask_paths::repo_dir!("services/lexical-service"))+}+fn run_biome() -> Step<Run> {Step::new("Run Biome").run("biome ci --changed --no-errors-on-unmatched --error-on-warnings")diff --git a/tooling/xtask/crates/xtask_workflows/src/workflows/web_app_check_main/test.rs b/tooling/xtask/crates/xtask_workflows/src/workflows/web_app_check_main/test.rsindex cb303f31ad..b03b14175d 100644--- a/tooling/xtask/crates/xtask_workflows/src/workflows/web_app_check_main/test.rs+++ b/tooling/xtask/crates/xtask_workflows/src/workflows/web_app_check_main/test.rs@@ -21,3 +21,25 @@ fn nix_dev_shell_does_not_start_typecheck() {"web setup action still belongs in should_run: {should_run}");}++#[test]+fn typecheck_runs_lexical_service_check_and_tests() {+ let yaml = web_app_check_main().to_string().expect("workflow yaml");+ let typescript = yaml+ .split("name: Typecheck")+ .nth(1)+ .and_then(|rest| rest.split("name: Biome Check").next())+ .expect("Typecheck job");+ assert!(+ typescript.contains("bun run check"),+ "Typecheck must type-check lexical-service: {typescript}"+ );+ assert!(+ typescript.contains("bun test src"),+ "Typecheck must run lexical-service endpoint tests: {typescript}"+ );+ assert!(+ typescript.contains("services/lexical-service"),+ "lexical-service steps must run in the service directory: {typescript}"+ );+}