iflow-feishu 1.0.9 → 1.1.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json
CHANGED
package/src/core/card-builder.js
CHANGED
|
@@ -55,9 +55,9 @@ class CardBuilder {
|
|
|
55
55
|
|
|
56
56
|
let titleContent = '';
|
|
57
57
|
if (modelName) titleContent += `<font color='blue'>${modelName}</font>`;
|
|
58
|
-
//
|
|
59
|
-
|
|
60
|
-
|
|
58
|
+
// 显示剩余上下文
|
|
59
|
+
const displayPercent = contentLeftPercent !== null ? contentLeftPercent : 100;
|
|
60
|
+
titleContent += (titleContent ? ' | ' : '') + `<font color='grey'>${displayPercent}% left</font>`;
|
|
61
61
|
if (thinkingStatus) titleContent += (titleContent ? ' <font color=\'grey\'>|</font> ' : '') + thinkingStatus;
|
|
62
62
|
|
|
63
63
|
if (titleContent) {
|
|
@@ -84,9 +84,9 @@ class CardBuilder {
|
|
|
84
84
|
|
|
85
85
|
let titleContent = '';
|
|
86
86
|
if (modelName) titleContent += `<font color='blue'>${modelName}</font>`;
|
|
87
|
-
//
|
|
88
|
-
|
|
89
|
-
|
|
87
|
+
// 显示剩余上下文
|
|
88
|
+
const displayPercent = contentLeftPercent !== null ? contentLeftPercent : 100;
|
|
89
|
+
titleContent += (titleContent ? ' | ' : '') + `<font color='grey'>${displayPercent}% left</font>`;
|
|
90
90
|
const statusColor = isGenerating ? 'orange' : 'green';
|
|
91
91
|
titleContent += (titleContent ? ' <font color=\'grey\'>|</font> ' : '') + `<font color='${statusColor}'>${responseTitle}</font>`;
|
|
92
92
|
|
package/src/core/service.js
CHANGED
|
@@ -287,7 +287,6 @@ class FeishuService {
|
|
|
287
287
|
|
|
288
288
|
// 提取响应
|
|
289
289
|
const extracted = this.streamHandler.extractResponse(stdoutSoFar, chatId, modelName);
|
|
290
|
-
// 内容变化会自动触发卡片更新,无需显式调用 update()
|
|
291
290
|
updater.setReasoning(extracted.reasoning);
|
|
292
291
|
updater.setContent(extracted.content || '');
|
|
293
292
|
|
|
@@ -295,6 +294,8 @@ class FeishuService {
|
|
|
295
294
|
const currentLength = (stdoutSoFar || '').length;
|
|
296
295
|
const percent = this.messageProcessor.calculateContentLeftPercent(chatId, currentLength, modelName);
|
|
297
296
|
updater.setPercent(percent);
|
|
297
|
+
|
|
298
|
+
updater.update();
|
|
298
299
|
},
|
|
299
300
|
{ mode: 'default', thinking: false }
|
|
300
301
|
);
|
|
@@ -155,7 +155,6 @@ class StreamHandler {
|
|
|
155
155
|
|
|
156
156
|
/**
|
|
157
157
|
* 创建卡片更新器
|
|
158
|
-
* 优化:只在内容变化时才调用API,计时变化不单独触发更新
|
|
159
158
|
*/
|
|
160
159
|
createCardUpdater(cardId, startTime, modelName, initialPercent) {
|
|
161
160
|
let lastUpdate = 0;
|
|
@@ -168,9 +167,6 @@ class StreamHandler {
|
|
|
168
167
|
let isCompleted = false;
|
|
169
168
|
let thinkingStartTime = null;
|
|
170
169
|
let thinkingEndTime = null;
|
|
171
|
-
let lastReasoning = '';
|
|
172
|
-
let lastContent = '';
|
|
173
|
-
let pendingUpdate = false;
|
|
174
170
|
|
|
175
171
|
const update = async (force = false) => {
|
|
176
172
|
if (!cardId || isCompleted) return;
|
|
@@ -179,9 +175,6 @@ class StreamHandler {
|
|
|
179
175
|
if (!force && now - lastUpdate < CARD_UPDATE_INTERVAL) return;
|
|
180
176
|
|
|
181
177
|
lastUpdate = now;
|
|
182
|
-
lastReasoning = currentReasoning;
|
|
183
|
-
lastContent = currentContent;
|
|
184
|
-
pendingUpdate = false;
|
|
185
178
|
|
|
186
179
|
const elapsed = isStreamEnded && streamEndTime
|
|
187
180
|
? streamEndTime - startTime
|
|
@@ -205,30 +198,10 @@ class StreamHandler {
|
|
|
205
198
|
}
|
|
206
199
|
};
|
|
207
200
|
|
|
208
|
-
// 检查内容是否有变化
|
|
209
|
-
const hasContentChanged = () => {
|
|
210
|
-
return currentReasoning !== lastReasoning || currentContent !== lastContent;
|
|
211
|
-
};
|
|
212
|
-
|
|
213
|
-
// 内容变化时触发更新
|
|
214
|
-
const triggerUpdate = () => {
|
|
215
|
-
if (hasContentChanged() && !pendingUpdate) {
|
|
216
|
-
pendingUpdate = true;
|
|
217
|
-
update();
|
|
218
|
-
}
|
|
219
|
-
};
|
|
220
|
-
|
|
221
201
|
return {
|
|
222
202
|
update,
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
currentReasoning = r;
|
|
226
|
-
triggerUpdate();
|
|
227
|
-
},
|
|
228
|
-
setContent: (c) => {
|
|
229
|
-
currentContent = c;
|
|
230
|
-
triggerUpdate();
|
|
231
|
-
},
|
|
203
|
+
setReasoning: (r) => { currentReasoning = r; },
|
|
204
|
+
setContent: (c) => { currentContent = c; },
|
|
232
205
|
setPercent: (p) => { currentPercent = p; },
|
|
233
206
|
setThinking: (isThinking) => { isInThinking = isThinking; },
|
|
234
207
|
setThinkingStart: (t) => { thinkingStartTime = t; },
|
|
@@ -245,12 +218,12 @@ class StreamHandler {
|
|
|
245
218
|
|
|
246
219
|
/**
|
|
247
220
|
* 创建定时器
|
|
248
|
-
* 优化:定时器不再主动更新,只在完成时强制更新一次显示最终耗时
|
|
249
221
|
*/
|
|
250
222
|
createTimer(updater) {
|
|
251
223
|
return setInterval(() => {
|
|
252
|
-
|
|
253
|
-
|
|
224
|
+
if (!updater.isCompleted()) {
|
|
225
|
+
updater.update();
|
|
226
|
+
}
|
|
254
227
|
}, TIMER_UPDATE_INTERVAL);
|
|
255
228
|
}
|
|
256
229
|
}
|