Auto-reply: format and lint fixes
This commit is contained in:
@@ -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);
|
||||
|
||||
@@ -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();
|
||||
}
|
||||
|
||||
|
||||
@@ -46,4 +46,3 @@ describe("autoReplyIfConfigured chunking", () => {
|
||||
);
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
@@ -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,
|
||||
|
||||
Reference in New Issue
Block a user