mirror of
https://github.com/HKUDS/nanobot.git
synced 2026-06-13 22:34:06 +00:00
fix(webui): keep tool activity in one thought block
This commit is contained in:
parent
fd61203be4
commit
a371907809
@ -132,7 +132,12 @@ function pushActivityUnits(units: TurnUnit[], activityMessages: UIMessage[], vis
|
||||
for (const message of activityMessages) {
|
||||
const bucket = isFileEditActivityMessage(message) ? "file" : "other";
|
||||
const segmentId = message.activitySegmentId;
|
||||
const segmentChanged = !!runSegmentId && !!segmentId && runSegmentId !== segmentId;
|
||||
const segmentChanged =
|
||||
bucket === "file"
|
||||
&& runBucket === "file"
|
||||
&& !!runSegmentId
|
||||
&& !!segmentId
|
||||
&& runSegmentId !== segmentId;
|
||||
if ((runBucket && bucket !== runBucket) || segmentChanged) {
|
||||
flushRun();
|
||||
}
|
||||
|
||||
@ -102,7 +102,7 @@ describe("ThreadMessages", () => {
|
||||
expect(units[2].type === "activity" ? units[2].messages.map((m) => m.id) : []).toEqual(["r2"]);
|
||||
});
|
||||
|
||||
it("splits ordinary tool activity when segment ids changed", () => {
|
||||
it("keeps ordinary tool activity in one Thought block across segment ids", () => {
|
||||
const messages: UIMessage[] = [
|
||||
{
|
||||
id: "r1",
|
||||
@ -142,12 +142,10 @@ describe("ThreadMessages", () => {
|
||||
|
||||
const units = buildDisplayUnits(messages);
|
||||
|
||||
expect(units).toHaveLength(2);
|
||||
expect(units).toHaveLength(1);
|
||||
expect(units[0].type === "activity" ? units[0].messages.map((m) => m.id) : []).toEqual([
|
||||
"r1",
|
||||
"t1",
|
||||
]);
|
||||
expect(units[1].type === "activity" ? units[1].messages.map((m) => m.id) : []).toEqual([
|
||||
"r2",
|
||||
"t2",
|
||||
]);
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user