mirror of
https://github.com/hansjone/dsh-im-ops.git
synced 2026-10-09 00:33:20 +08:00
fix(qq): stop flashing the status frame during tool runs
The shared Harness client emits a '正在整理结果…' status update after every tool/result. Pushing each one into the QQ stream message made multi-tool turns repeatedly flash that notice instead of showing real progress. Skip status frames in the QQ onUpdate handler so the stream keeps the last meaningful frame (tool name or generated text), which matches the official dsh-qqbot behaviour of not pushing tool-noise.
This commit is contained in:
parent
81884173df
commit
6b176d9053
3 changed files with 40 additions and 2 deletions
File diff suppressed because one or more lines are too long
|
|
@ -619,11 +619,13 @@ export class QqHarnessBridge {
|
|||
signal: this.#signal,
|
||||
control: { owner: this, key },
|
||||
onUpdate: stream ? async (update) => {
|
||||
// status 帧(如工具结束后的“正在整理结果…”)不推送:
|
||||
// 保持上一帧(工具名或已生成文本),避免中间过程反复闪提示。
|
||||
const progress = update.type === 'text'
|
||||
? update.text
|
||||
: update.type === 'tool'
|
||||
? `正在使用${update.name}…`
|
||||
: update.text;
|
||||
: null;
|
||||
if (progress) await stream.update(progress);
|
||||
} : undefined,
|
||||
onInteraction: (interaction) => this.#handleInteraction(interaction, {
|
||||
|
|
|
|||
|
|
@ -458,6 +458,42 @@ test('QQ private messages stream Harness snapshots and finalize once', async ()
|
|||
assert.equal(bridge.status.messagesReplied, 1);
|
||||
});
|
||||
|
||||
test('QQ progress stream keeps the last frame when a tool finishes', async () => {
|
||||
const frames = [];
|
||||
const bridge = new QqHarnessBridge({
|
||||
bot: {
|
||||
sendText: async () => {},
|
||||
openStream: () => ({
|
||||
update: async (text) => frames.push(text),
|
||||
complete: async () => frames.push('DONE'),
|
||||
cancel() {},
|
||||
}),
|
||||
},
|
||||
ownerUserOpenid: 'owner-openid',
|
||||
harness: {
|
||||
sessionExists: async () => true,
|
||||
ask: async (_session, _text, { onUpdate }) => {
|
||||
await onUpdate({ type: 'tool', name: 'bash' });
|
||||
// 工具结束后 Harness 客户端会下发 status 帧“正在整理结果…”。
|
||||
await onUpdate({ type: 'status', text: '正在整理结果…' });
|
||||
await onUpdate({ type: 'tool', name: 'read' });
|
||||
await onUpdate({ type: 'status', text: '正在整理结果…' });
|
||||
return '最终回答';
|
||||
},
|
||||
},
|
||||
state: {
|
||||
hasSeen: () => false,
|
||||
markSeen: async () => {},
|
||||
sessionFor: () => 'session-status',
|
||||
setSession: async () => {},
|
||||
clearSession: async () => {},
|
||||
},
|
||||
});
|
||||
|
||||
await bridge.accept(message({ messageId: 'msg-status-frame' }));
|
||||
assert.deepEqual(frames, ['正在使用bash…', '正在使用read…', '最终回答', 'DONE']);
|
||||
});
|
||||
|
||||
test('QQ delivers final group answers as markdown messages', async () => {
|
||||
const sentText = [];
|
||||
const markdownCalls = [];
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue