惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

J
Java Code Geeks
G
Google Developers Blog
Blog — PlanetScale
Blog — PlanetScale
U
Unit 42
A
About on SuperTechFans
Vercel News
Vercel News
B
Blog
Martin Fowler
Martin Fowler
MyScale Blog
MyScale Blog
Cyber Security Advisories - MS-ISAC
Cyber Security Advisories - MS-ISAC
腾讯CDC
D
Docker
V
Visual Studio Blog
博客园 - 叶小钗
The Cloudflare Blog
Jina AI
Jina AI
B
Blog RSS Feed
钛媒体:引领未来商业与生活新知
钛媒体:引领未来商业与生活新知
WordPress大学
WordPress大学
T
Tailwind CSS Blog
MongoDB | Blog
MongoDB | Blog
D
DataBreaches.Net
月光博客
月光博客
大猫的无限游戏
大猫的无限游戏

Recent Commits to openclaw:main

test: merge chat side-result checks · openclaw/openclaw@ddd2c2a test: merge cron history checks · openclaw/openclaw@f7eb746 test: merge responsive navigation shell checks · openclaw/openclaw@c2e4b47 docs(changelog): add codex oauth fixes · openclaw/openclaw@628e6cd test: merge navigation routing cases · openclaw/openclaw@5d8cecb Tests: mock channel registry bundled fallback · openclaw/openclaw@2b08233 Secrets: avoid broad web search discovery for single plugin config · openclaw/openclaw@a464f59 test: merge config view browser checks · openclaw/openclaw@20cf511 fix(status): align oauth health with runtime · openclaw/openclaw@eed7116 feat: add macOS screen snapshots for monitor preview (#67954) thanks … · openclaw/openclaw@f377db1 fix: report shared auth scopes in hello-ok (#67810) thanks @BunsDev · openclaw/openclaw@0b6c39b Auto-reply: avoid eager bundled route fallback · openclaw/openclaw@3ea1bf4 Tests: narrow session binding contract setup · openclaw/openclaw@54e4e16 fix(macOS): enable undo/redo in webchat composer text input (#34962) · openclaw/openclaw@00951dc Tests: speed up channel setup promotion · openclaw/openclaw@82b529a Docs: refresh agent instructions · openclaw/openclaw@5775fe2 fix(auth): serialize OAuth refresh across agents to fix #26322 (#67876) · openclaw/openclaw@8e79080 test: allow ollama public surface boundary test · openclaw/openclaw@7d4f1a6 Docs: add test performance guardrails · openclaw/openclaw@89706d3 Tests: restore context-engine usage proof · openclaw/openclaw@e4c4f95 Tests: slim context engine runtime coverage · openclaw/openclaw@74c198f ci: retry failed custom checkouts · openclaw/openclaw@0ee5baf test: trim duplicate provider auth onboarding cases · openclaw/openclaw@1ffc02e matrix: fix sessions_spawn --thread subagent session spawning (#67643) · openclaw/openclaw@1ce2596 test: reduce auth choice fixture churn · openclaw/openclaw@857b9cd test: mock health status config boundaries · openclaw/openclaw@9d5ab4a test: mock onboard config io boundary · openclaw/openclaw@299694d test: mock legacy state plugin boundaries · openclaw/openclaw@2713089 test: mock channel install boundaries · openclaw/openclaw@b945248 test: mock doctor preview channel boundaries · openclaw/openclaw@b1a3ad4
test(telegram): cover draft preview overflow · openclaw/o...
obviyus · 2026-05-28 · via Recent Commits to openclaw:main

@@ -399,7 +399,42 @@ describe("createTelegramDraftStream", () => {

399399

});

400400

});

401401402-

it("continues in a new message when rendered preview crosses maxChars", async () => {

402+

it("keeps non-final overflow in one editable preview", async () => {

403+

const api = createMockDraftApi();

404+

const onSupersededPreview = vi.fn();

405+

const stream = createDraftStream(api, { maxChars: 20, onSupersededPreview });

406+407+

stream.update("Hello world");

408+

await stream.flush();

409+

stream.update("Hello world foo bar baz qux");

410+

await stream.flush();

411+412+

expect(api.sendMessage).toHaveBeenCalledTimes(1);

413+

expect(api.sendMessage).toHaveBeenNthCalledWith(1, 123, "Hello world", undefined);

414+

expect(api.editMessageText).toHaveBeenCalledWith(123, 17, "Hello world foo bar");

415+

expect(onSupersededPreview).not.toHaveBeenCalled();

416+

expect(stream.lastDeliveredText?.()).toBe("Hello world foo bar");

417+

});

418+419+

it("does not retain non-final overflow preview pages", async () => {

420+

const api = createMockDraftApi();

421+

const onSupersededPreview = vi.fn();

422+

const stream = createDraftStream(api, {

423+

maxChars: 20,

424+

onSupersededPreview,

425+

});

426+427+

stream.update("Hello world");

428+

await stream.flush();

429+

stream.update("Hello world foo bar baz qux");

430+

await stream.flush();

431+432+

expect(api.sendMessage).toHaveBeenCalledTimes(1);

433+

expect(api.editMessageText).toHaveBeenCalledWith(123, 17, "Hello world foo bar");

434+

expect(onSupersededPreview).not.toHaveBeenCalled();

435+

});

436+437+

it("continues in a new message when a final rendered preview crosses maxChars", async () => {

403438

const api = createMockDraftApi();

404439

api.sendMessage

405440

.mockResolvedValueOnce({ message_id: 17 })

@@ -409,29 +444,53 @@ describe("createTelegramDraftStream", () => {

409444

stream.update("Hello world");

410445

await stream.flush();

411446

stream.update("Hello world foo bar baz qux");

412-

await stream.flush();

447+

await stream.stop();

413448414449

expect(api.sendMessage).toHaveBeenCalledTimes(2);

415450

expect(api.sendMessage).toHaveBeenNthCalledWith(1, 123, "Hello world", undefined);

416451

expect(api.sendMessage).toHaveBeenNthCalledWith(2, 123, "foo bar baz qux", undefined);

417452

});

418453419-

it("splits a first oversized rendered preview into chained messages", async () => {

454+

it("clamps a first oversized non-final preview", async () => {

455+

const api = createMockDraftApi();

456+

const stream = createDraftStream(api, { maxChars: 10 });

457+458+

stream.update("1234567890ABCDEFGHIJ");

459+

await stream.flush();

460+461+

expect(api.sendMessage).toHaveBeenCalledTimes(1);

462+

expect(api.sendMessage).toHaveBeenNthCalledWith(1, 123, "1234567890", undefined);

463+

expect(stream.lastDeliveredText?.()).toBe("1234567890");

464+

});

465+466+

it("finalizes overflow that was hidden by a clamped non-final preview", async () => {

420467

const api = createMockDraftApi();

421468

api.sendMessage

422469

.mockResolvedValueOnce({ message_id: 17 })

423470

.mockResolvedValueOnce({ message_id: 42 });

424-

const stream = createDraftStream(api, { maxChars: 10 });

471+

const onSupersededPreview = vi.fn();

472+

const stream = createDraftStream(api, {

473+

maxChars: 10,

474+

onSupersededPreview,

475+

});

425476426477

stream.update("1234567890ABCDEFGHIJ");

427478

await stream.flush();

479+

await stream.stop();

428480429481

expect(api.sendMessage).toHaveBeenCalledTimes(2);

430482

expect(api.sendMessage).toHaveBeenNthCalledWith(1, 123, "1234567890", undefined);

431483

expect(api.sendMessage).toHaveBeenNthCalledWith(2, 123, "ABCDEFGHIJ", undefined);

484+

expect(stream.lastDeliveredText?.()).toBe("1234567890ABCDEFGHIJ");

485+

expect(onSupersededPreview).toHaveBeenCalledWith(

486+

expect.objectContaining({

487+

messageId: 17,

488+

retain: true,

489+

}),

490+

);

432491

});

433492434-

it("retains overflow preview pages", async () => {

493+

it("retains final overflow preview pages", async () => {

435494

const api = createMockDraftApi();

436495

api.sendMessage

437496

.mockResolvedValueOnce({ message_id: 17 })

@@ -445,7 +504,7 @@ describe("createTelegramDraftStream", () => {

445504

stream.update("Hello world");

446505

await stream.flush();

447506

stream.update("Hello world foo bar baz qux");

448-

await stream.flush();

507+

await stream.stop();

449508450509

expect(onSupersededPreview).toHaveBeenCalledTimes(1);

451510

const [supersededPreview] = onSupersededPreview.mock.calls.at(0) ?? [];