Auto-reply: format and lint fixes

This commit is contained in:
Peter Steinberger
2025-12-03 00:30:05 +00:00
parent b6c45485bc
commit ecac4dd72a
4 changed files with 7 additions and 4 deletions

View File

@@ -29,7 +29,8 @@ describe("chunkText", () => {
});
it("otherwise breaks at the last whitespace under the limit", () => {
const text = "This is a message that should break nicely near a word boundary.";
const text =
"This is a message that should break nicely near a word boundary.";
const chunks = chunkText(text, 30);
expect(chunks[0].length).toBeLessThanOrEqual(30);
expect(chunks[1].length).toBeLessThanOrEqual(30);

View File

@@ -38,7 +38,10 @@ export function chunkText(text: string, limit: number): string[] {
// If we broke on whitespace/newline, skip that separator; for hard breaks keep it.
const brokeOnSeparator =
breakIdx < remaining.length && /\s/.test(remaining[breakIdx]);
const nextStart = Math.min(remaining.length, breakIdx + (brokeOnSeparator ? 1 : 0));
const nextStart = Math.min(
remaining.length,
breakIdx + (brokeOnSeparator ? 1 : 0),
);
remaining = remaining.slice(nextStart).trimStart();
}

View File

@@ -46,4 +46,3 @@ describe("autoReplyIfConfigured chunking", () => {
);
});
});

View File

@@ -16,8 +16,8 @@ import { runCommandWithTimeout } from "../process/exec.js";
import { defaultRuntime, type RuntimeEnv } from "../runtime.js";
import type { TwilioRequester } from "../twilio/types.js";
import { sendTypingIndicator } from "../twilio/typing.js";
import { runCommandReply } from "./command-reply.js";
import { chunkText } from "./chunk.js";
import { runCommandReply } from "./command-reply.js";
import {
applyTemplate,
type MsgContext,