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

推荐订阅源

大猫的无限游戏
大猫的无限游戏
aimingoo的专栏
aimingoo的专栏
I
InfoQ
B
Blog RSS Feed
D
DataBreaches.Net
S
SegmentFault 最新的问题
P
Proofpoint News Feed
A
About on SuperTechFans
WordPress大学
WordPress大学
Hugging Face - Blog
Hugging Face - Blog
博客园 - 司徒正美
小众软件
小众软件
博客园 - Franky
有赞技术团队
有赞技术团队
D
Docker
T
Tailwind CSS Blog
雷峰网
雷峰网
让小产品的独立变现更简单 - ezindie.com
让小产品的独立变现更简单 - ezindie.com
Blog — PlanetScale
Blog — PlanetScale
酷 壳 – CoolShell
酷 壳 – CoolShell
B
Blog
V
Visual Studio Blog
宝玉的分享
宝玉的分享
爱范儿
爱范儿

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(channels): delay progress drafts until work is visibl...
steipete · 2026-05-04 · via Recent Commits to openclaw:main

@@ -1,6 +1,8 @@

11

import { EmbeddedBlockChunker } from "openclaw/plugin-sdk/agent-runtime";

22

import {

3+

createChannelProgressDraftGate,

34

formatChannelProgressDraftText,

5+

isChannelProgressDraftWorkToolName,

46

resolveChannelProgressDraftMaxLines,

57

resolveChannelStreamingBlockEnabled,

68

resolveChannelStreamingPreviewToolProgress,

@@ -70,7 +72,6 @@ export function createDiscordDraftPreviewController(params: {

7072

let hasStreamedMessage = false;

7173

let finalizedViaPreviewMessage = false;

7274

let finalDeliveryHandled = false;

73-

let progressDraftStarted = false;

7475

const previewToolProgressEnabled =

7576

Boolean(draftStream) && resolveChannelStreamingPreviewToolProgress(params.discordConfig);

7677

const suppressDefaultToolProgressMessages =

@@ -83,6 +84,32 @@ export function createDiscordDraftPreviewController(params: {

8384

let previewToolProgressLines: string[] = [];

8485

const progressSeed = `${params.accountId}:${params.deliverChannelId}`;

858687+

const renderProgressDraft = async (options?: { flush?: boolean }) => {

88+

if (!draftStream || discordStreamMode !== "progress") {

89+

return;

90+

}

91+

const previewText = formatChannelProgressDraftText({

92+

entry: params.discordConfig,

93+

lines: previewToolProgressLines,

94+

seed: progressSeed,

95+

});

96+

if (!previewText || previewText === lastPartialText) {

97+

return;

98+

}

99+

lastPartialText = previewText;

100+

draftText = previewText;

101+

hasStreamedMessage = true;

102+

draftChunker?.reset();

103+

draftStream.update(previewText);

104+

if (options?.flush) {

105+

await draftStream.flush();

106+

}

107+

};

108+109+

const progressDraftGate = createChannelProgressDraftGate({

110+

onStart: () => renderProgressDraft({ flush: true }),

111+

});

112+86113

const resetProgressState = () => {

87114

lastPartialText = "";

88115

draftText = "";

@@ -106,6 +133,9 @@ export function createDiscordDraftPreviewController(params: {

106133

get isProgressMode() {

107134

return discordStreamMode === "progress";

108135

},

136+

get hasProgressDraftStarted() {

137+

return progressDraftGate.hasStarted;

138+

},

109139

get finalizedViaPreviewMessage() {

110140

return finalizedViaPreviewMessage;

111141

},

@@ -120,50 +150,55 @@ export function createDiscordDraftPreviewController(params: {

120150

if (!draftStream || discordStreamMode !== "progress") {

121151

return;

122152

}

123-

if (progressDraftStarted) {

124-

return;

125-

}

126-

const previewText = formatChannelProgressDraftText({

127-

entry: params.discordConfig,

128-

lines: [],

129-

seed: progressSeed,

130-

});

131-

if (!previewText || previewText === lastPartialText) {

153+

await progressDraftGate.startNow();

154+

},

155+

async pushToolProgress(line?: string, options?: { toolName?: string }) {

156+

if (!draftStream) {

132157

return;

133158

}

134-

progressDraftStarted = true;

135-

lastPartialText = previewText;

136-

draftText = previewText;

137-

hasStreamedMessage = true;

138-

draftChunker?.reset();

139-

draftStream.update(previewText);

140-

await draftStream.flush();

141-

},

142-

pushToolProgress(line?: string) {

143-

if (!draftStream || !previewToolProgressEnabled || previewToolProgressSuppressed) {

159+

if (

160+

options?.toolName !== undefined &&

161+

!isChannelProgressDraftWorkToolName(options.toolName)

162+

) {

144163

return;

145164

}

146165

const normalized = line?.replace(/\s+/g, " ").trim();

147-

if (!normalized) {

166+

if (discordStreamMode !== "progress") {

167+

if (!previewToolProgressEnabled || previewToolProgressSuppressed || !normalized) {

168+

return;

169+

}

170+

const previous = previewToolProgressLines.at(-1);

171+

if (previous === normalized) {

172+

return;

173+

}

174+

previewToolProgressLines = [...previewToolProgressLines, normalized].slice(

175+

-resolveChannelProgressDraftMaxLines(params.discordConfig),

176+

);

177+

const previewText = formatChannelProgressDraftText({

178+

entry: params.discordConfig,

179+

lines: previewToolProgressLines,

180+

seed: progressSeed,

181+

});

182+

lastPartialText = previewText;

183+

draftText = previewText;

184+

hasStreamedMessage = true;

185+

draftChunker?.reset();

186+

draftStream.update(previewText);

148187

return;

149188

}

150-

const previous = previewToolProgressLines.at(-1);

151-

if (previous === normalized) {

152-

return;

189+

if (previewToolProgressEnabled && !previewToolProgressSuppressed && normalized) {

190+

const previous = previewToolProgressLines.at(-1);

191+

if (previous !== normalized) {

192+

previewToolProgressLines = [...previewToolProgressLines, normalized].slice(

193+

-resolveChannelProgressDraftMaxLines(params.discordConfig),

194+

);

195+

}

196+

}

197+

const alreadyStarted = progressDraftGate.hasStarted;

198+

await progressDraftGate.noteWork();

199+

if (alreadyStarted && progressDraftGate.hasStarted) {

200+

await renderProgressDraft();

153201

}

154-

previewToolProgressLines = [...previewToolProgressLines, normalized].slice(

155-

-resolveChannelProgressDraftMaxLines(params.discordConfig),

156-

);

157-

const previewText = formatChannelProgressDraftText({

158-

entry: params.discordConfig,

159-

lines: previewToolProgressLines,

160-

seed: progressSeed,

161-

});

162-

lastPartialText = previewText;

163-

draftText = previewText;

164-

hasStreamedMessage = true;

165-

draftChunker?.reset();

166-

draftStream.update(previewText);

167202

},

168203

resolvePreviewFinalText(text?: string) {

169204

if (typeof text !== "string") {

@@ -281,6 +316,7 @@ export function createDiscordDraftPreviewController(params: {

281316

},

282317

async cleanup() {

283318

try {

319+

progressDraftGate.cancel();

284320

if (!finalDeliveryHandled) {

285321

await draftStream?.discardPending();

286322

}