From 43545a486438821c576634b697bcbfc853cfa823 Mon Sep 17 00:00:00 2001 From: Josh Palmer Date: Fri, 9 Jan 2026 00:15:41 +0100 Subject: [PATCH] =?UTF-8?q?=F0=9F=A4=96=20codex:=20preserve=20spacing=20af?= =?UTF-8?q?ter=20inline=20directives=20(issue-telegram-inline-spacing)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/auto-reply/model.test.ts | 6 ++++++ src/auto-reply/model.ts | 2 +- src/auto-reply/reply/directives.ts | 3 ++- src/auto-reply/reply/queue.ts | 2 +- 4 files changed, 10 insertions(+), 3 deletions(-) diff --git a/src/auto-reply/model.test.ts b/src/auto-reply/model.test.ts index 6737349aa..626a60d36 100644 --- a/src/auto-reply/model.test.ts +++ b/src/auto-reply/model.test.ts @@ -107,6 +107,12 @@ describe("extractModelDirective", () => { }); describe("edge cases", () => { + it("preserves spacing when /model is followed by a path segment", () => { + const result = extractModelDirective("thats not /model gpt-5/tmp/hello"); + expect(result.hasDirective).toBe(true); + expect(result.cleaned).toBe("thats not /hello"); + }); + it("handles alias with special regex characters", () => { const result = extractModelDirective("/test.alias", { aliases: ["test.alias"], diff --git a/src/auto-reply/model.ts b/src/auto-reply/model.ts index 814e258e7..163381376 100644 --- a/src/auto-reply/model.ts +++ b/src/auto-reply/model.ts @@ -42,7 +42,7 @@ export function extractModelDirective( } const cleaned = match - ? body.replace(match[0], "").replace(/\s+/g, " ").trim() + ? body.replace(match[0], " ").replace(/\s+/g, " ").trim() : body.trim(); return { diff --git a/src/auto-reply/reply/directives.ts b/src/auto-reply/reply/directives.ts index b0ddb1a43..d04180411 100644 --- a/src/auto-reply/reply/directives.ts +++ b/src/auto-reply/reply/directives.ts @@ -56,6 +56,7 @@ const extractLevelDirective = ( const level = normalize(rawLevel); const cleaned = body .slice(0, match.start) + .concat(" ") .concat(body.slice(match.end)) .replace(/\s+/g, " ") .trim(); @@ -76,7 +77,7 @@ const extractSimpleDirective = ( new RegExp(`(?:^|\\s)\\/(?:${namePattern})(?=$|\\s|:)(?:\\s*:\\s*)?`, "i"), ); const cleaned = match - ? body.replace(match[0], "").replace(/\s+/g, " ").trim() + ? body.replace(match[0], " ").replace(/\s+/g, " ").trim() : body.trim(); return { cleaned, diff --git a/src/auto-reply/reply/queue.ts b/src/auto-reply/reply/queue.ts index 86ae083a8..a7cf97e66 100644 --- a/src/auto-reply/reply/queue.ts +++ b/src/auto-reply/reply/queue.ts @@ -272,7 +272,7 @@ export function extractQueueDirective(body?: string): { const args = body.slice(argsStart); const parsed = parseQueueDirectiveArgs(args); const cleanedRaw = - body.slice(0, start) + body.slice(argsStart + parsed.consumed); + body.slice(0, start) + " " + body.slice(argsStart + parsed.consumed); const cleaned = cleanedRaw.replace(/\s+/g, " ").trim(); return { cleaned,