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

推荐订阅源

freeCodeCamp Programming Tutorials: Python, JavaScript, Git & More
P
Proofpoint News Feed
宝玉的分享
宝玉的分享
人人都是产品经理
人人都是产品经理
博客园_首页
爱范儿
爱范儿
博客园 - 叶小钗
aimingoo的专栏
aimingoo的专栏
S
SegmentFault 最新的问题
MyScale Blog
MyScale Blog
阮一峰的网络日志
阮一峰的网络日志
IT之家
IT之家
Microsoft Security Blog
Microsoft Security Blog
Blog — PlanetScale
Blog — PlanetScale
博客园 - 【当耐特】
Y
Y Combinator Blog
量子位
博客园 - 三生石上(FineUI控件)
让小产品的独立变现更简单 - ezindie.com
让小产品的独立变现更简单 - ezindie.com
T
The Blog of Author Tim Ferriss
月光博客
月光博客
有赞技术团队
有赞技术团队
Apple Machine Learning Research
Apple Machine Learning Research
A
About on SuperTechFans

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
fix(auto-reply): clamp typing timers · openclaw/openclaw@...
steipete · 2026-05-31 · via Recent Commits to openclaw:main
Original file line numberDiff line numberDiff line change

@@ -1,4 +1,5 @@

11

import { describe, it, expect, vi, beforeEach, afterEach, type Mock } from "vitest";

2+

import { MAX_TIMER_TIMEOUT_MS } from "../../shared/number-coercion.js";

23

import { createTypingController } from "./typing.js";

34
45

describe("typing persistence bug fix", () => {

@@ -118,4 +119,22 @@ describe("typing persistence bug fix", () => {

118119

expect(inert.isActive()).toBe(false);

119120

expect(vi.getTimerCount()).toBe(0);

120121

});

122+
123+

it("clamps oversized typing interval and TTL timers", async () => {

124+

const setIntervalSpy = vi.spyOn(globalThis, "setInterval");

125+

const setTimeoutSpy = vi.spyOn(globalThis, "setTimeout");

126+

const boundedController = createTypingController({

127+

onReplyStart: onReplyStartSpy,

128+

onCleanup: onCleanupSpy,

129+

typingIntervalSeconds: Number.MAX_SAFE_INTEGER,

130+

typingTtlMs: Number.MAX_SAFE_INTEGER,

131+

log: vi.fn(),

132+

});

133+
134+

await boundedController.startTypingLoop();

135+
136+

expect(setIntervalSpy).toHaveBeenCalledWith(expect.any(Function), MAX_TIMER_TIMEOUT_MS);

137+

expect(setTimeoutSpy).toHaveBeenCalledWith(expect.any(Function), MAX_TIMER_TIMEOUT_MS);

138+

boundedController.cleanup();

139+

});

121140

});

Original file line numberDiff line numberDiff line change

@@ -1,8 +1,25 @@

1+

import {

2+

finiteSecondsToTimerSafeMilliseconds,

3+

resolveTimerTimeoutMs,

4+

} from "@openclaw/normalization-core/number-coercion";

15

import { normalizeOptionalString } from "@openclaw/normalization-core/string-coerce";

26

import { createTypingKeepaliveLoop } from "../../channels/typing-lifecycle.js";

37

import { createTypingStartGuard } from "../../channels/typing-start-guard.js";

48

import { isSilentReplyPrefixText, isSilentReplyText, SILENT_REPLY_TOKEN } from "../tokens.js";

59
10+

const DEFAULT_TYPING_INTERVAL_SECONDS = 6;

11+

const DEFAULT_TYPING_TTL_MS = 2 * 60_000;

12+
13+

function resolveTypingIntervalMs(seconds: number | undefined): number {

14+

if (Number.isFinite(seconds) && (seconds ?? 0) <= 0) {

15+

return 0;

16+

}

17+

return (

18+

finiteSecondsToTimerSafeMilliseconds(seconds ?? DEFAULT_TYPING_INTERVAL_SECONDS) ??

19+

DEFAULT_TYPING_INTERVAL_SECONDS * 1000

20+

);

21+

}

22+
623

export type TypingController = {

724

onReplyStart: () => Promise<void>;

825

startTypingLoop: () => Promise<void>;

@@ -22,14 +39,7 @@ export function createTypingController(params: {

2239

silentToken?: string;

2340

log?: (message: string) => void;

2441

}): TypingController {

25-

const {

26-

onReplyStart,

27-

onCleanup,

28-

typingIntervalSeconds = 6,

29-

typingTtlMs = 2 * 60_000,

30-

silentToken = SILENT_REPLY_TOKEN,

31-

log,

32-

} = params;

42+

const { onReplyStart, onCleanup, silentToken = SILENT_REPLY_TOKEN, log } = params;

3343

if (!onReplyStart && !onCleanup) {

3444

return {

3545

onReplyStart: async () => {},

@@ -52,7 +62,8 @@ export function createTypingController(params: {

5262

// Once we stop typing, we "seal" the controller so late events can't restart typing forever.

5363

let sealed = false;

5464

let typingTtlTimer: NodeJS.Timeout | undefined;

55-

const typingIntervalMs = typingIntervalSeconds * 1000;

65+

const typingIntervalMs = resolveTypingIntervalMs(params.typingIntervalSeconds);

66+

const typingTtlMs = resolveTimerTimeoutMs(params.typingTtlMs, DEFAULT_TYPING_TTL_MS, 0);

5667
5768

const formatTypingTtl = (ms: number) => {

5869

if (ms % 60_000 === 0) {