Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
43 changes: 43 additions & 0 deletions apps/mobile/src/lib/threadActivity.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -373,6 +373,49 @@ describe("buildThreadFeed", () => {
expect(nextRows.some((row) => row.type === "activity-group")).toBe(true);
});

it("keeps thinking activities in their own feed group between tool calls", () => {
const turnId = TurnId.make("turn-1");
const thread = makeThread({
id: ThreadId.make("feed-thinking"),
projectId: ProjectId.make("project-1"),
title: "Feed thinking",
messages: [],
activities: [
makeActivity({
id: EventId.make("tool-1"),
kind: "tool.completed",
summary: "Ran command",
tone: "tool",
createdAt: "2026-04-01T00:00:01.000Z",
turnId,
payload: { itemType: "command_execution", status: "completed" },
}),
makeActivity({
id: EventId.make("thinking-1"),
kind: "thinking",
summary: "Thinking",
tone: "info",
createdAt: "2026-04-01T00:00:02.000Z",
turnId,
payload: { detail: "Checking the checklist first." },
}),
makeActivity({
id: EventId.make("tool-2"),
kind: "tool.completed",
summary: "Ran command",
tone: "tool",
createdAt: "2026-04-01T00:00:03.000Z",
turnId,
payload: { itemType: "command_execution", status: "completed" },
}),
],
});

const feed = buildThreadFeed(thread);
expect(feed.map((row) => row.id)).toEqual(["tool-1", "thinking-1", "tool-2"]);
expect(feed[1]).toMatchObject({ type: "activity-group" });
});

it("regroups cached activities for message changes and pagination", () => {
const messages = [2, 4].map((second) => ({
id: MessageId.make(`message-${second}`),
Expand Down
14 changes: 11 additions & 3 deletions apps/mobile/src/lib/threadActivity.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,11 @@ import {
requestKindFromRequestType,
type PendingApproval,
} from "@t3tools/client-runtime/pending-requests";
import { UserInputAttachmentAnswerPayload, isToolLifecycleItemType } from "@t3tools/contracts";
import {
THINKING_ACTIVITY_KIND,
UserInputAttachmentAnswerPayload,
isToolLifecycleItemType,
} from "@t3tools/contracts";
import type {
OrchestrationLatestTurn,
OrchestrationThread,
Expand Down Expand Up @@ -1555,12 +1559,16 @@ function groupAdjacentActivities(entries: ReadonlyArray<RawThreadFeedEntry>): Th
}

const isCompaction = entry.activity.workEntry.sourceActivityKind === "context-compaction";
if (isCompaction || firstActivityEntry?.turnId !== entry.turnId) {
// Thinking rows stay visible outside collapsed tool groups (mirrors web):
// they break the run on both sides so a reasoning-narrated turn keeps its
// narrative without expanding dozens of tool calls.
const isThinking = entry.activity.workEntry.sourceActivityKind === THINKING_ACTIVITY_KIND;
if (isCompaction || isThinking || firstActivityEntry?.turnId !== entry.turnId) {
flushGroup();
}
firstActivityEntry ??= entry;
openGroupActivities.push(entry.activity);
if (isCompaction) {
if (isCompaction || isThinking) {
flushGroup();
}
}
Expand Down
Loading
Loading