feat(ai): run agent sessions as background tasks

This commit is contained in:
Abeautifulsnow authored and GitHub committed 2026-08-26 14:09:08 +08:00
1 parent b37a1f8538
commit eeeb4e5011
34 files changed
+3440 -184

No files matched your search

+6 -4
View File
@@ -61,15 +61,17 @@ test("assistant messages keep metadata aligned with the bubble and wrap long tex
test("AI request failures use localized backend diagnostics", () => {
// The lookup is guarded (matching the `finally` block right below it) so that if
// clearMessages()/selectConversation() already replaced messages.value while this
// clearMessages()/selectConversation() already replaced the transcript while this
// request was still in flight, writing the failure text doesn't throw and silently
// swallow the real error. See issue #5941.
assert.match(source, /const msg = messages\.value\[assistantIdx\];\s*\n\s*if \(msg\) msg\.content = `\$\{t\("ai\.requestFailed"\)\}\\n\\n\$\{translateBackendError\(t, message\)\}`;/);
// swallow the real error. See issue #5941. (`runMessages` is the send pipeline's
// array — `messages.value` for a visible conversation, the run's own array for a
// detached/background run.)
assert.match(source, /const msg = runMessages\[assistantIdx\];\s*\n\s*if \(msg\) msg\.content = `\$\{t\("ai\.requestFailed"\)\}\\n\\n\$\{translateBackendError\(t, message\)\}`;/);
});
test("AI analysis export keeps the connection that produced each assistant response", () => {
assert.match(source, /sourceConnectionName\?: string/);
assert.match(source, /messages\.value\.push\(\{ role: "assistant", content: "", sourceConnectionName: connection\.name \}\)/);
assert.match(source, /runMessages\.push\(\{ role: "assistant", content: "", sourceConnectionName: connection\.name \}\)/);
assert.match(source, /connectionName: msg\.sourceConnectionName \?\? props\.connection\?\.name/);
assert.match(source, /sourceConnectionName: m\.role === "assistant" \? conv\.connectionName : undefined/);
});