fix(web): 提前轮询自动标题
This commit is contained in:
parent
8ab548a1cd
commit
df2b636ee5
|
|
@ -66,3 +66,12 @@ test("composer uses one Codex-style action button for stop and queued send", ()
|
|||
assert.match(chat, /void dispatchNextQueuedMessage\(ctx\.taskId\)/);
|
||||
assert.match(chat, /removeQueuedMessage\([\s\S]*streamSse\(r\.events_url, run\)/);
|
||||
});
|
||||
|
||||
test("automatic title polling starts before a long-running response finishes", () => {
|
||||
const chat = readFileSync(new URL("../web/static/js/chat.js", import.meta.url), "utf8");
|
||||
const sendMessage = chat.indexOf("async function sendMessage(");
|
||||
const poll = chat.indexOf("void pollAutoTitle(taskId)", sendMessage);
|
||||
const stream = chat.indexOf("streamSse(r.events_url, run)", sendMessage);
|
||||
assert.ok(poll > sendMessage, "sendMessage should start title polling");
|
||||
assert.ok(poll < stream, "title polling should start before waiting on the SSE run");
|
||||
});
|
||||
|
|
|
|||
|
|
@ -3105,6 +3105,11 @@ async function sendMessage(overrideText) {
|
|||
state.streaming = true;
|
||||
syncTaskRowRunIndicator(taskId);
|
||||
if (state.taskId === taskId) setActionMode("streaming");
|
||||
// 标题生成与主 run 并行,页面也应立即开始观察结果。若等 SSE 收尾才轮询,
|
||||
// 长思考会让已经写入 DB 的标题在 UI 中继续显示数分钟“新对话”。
|
||||
if (run.autoTitleEligible && state.taskMeta?.auto_title_pending) {
|
||||
void pollAutoTitle(taskId);
|
||||
}
|
||||
streamSse(r.events_url, run);
|
||||
} catch (e) {
|
||||
if (e.status === 401) { logout(); return; }
|
||||
|
|
|
|||
Loading…
Reference in New Issue