Skip to content
Closed
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
52 changes: 52 additions & 0 deletions apps/web/src/components/ChatView.logic.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
import { EventId, TurnId, type OrchestrationThreadActivity } from "@t3tools/contracts";
import { describe, expect, it } from "vitest";

import { deriveVisibleThreadWorkLogEntries } from "./ChatView.logic";

function makeActivity(overrides: {
id?: string;
createdAt?: string;
kind?: string;
summary?: string;
tone?: OrchestrationThreadActivity["tone"];
payload?: Record<string, unknown>;
turnId?: string;
sequence?: number;
}): OrchestrationThreadActivity {
return {
id: EventId.makeUnsafe(overrides.id ?? crypto.randomUUID()),
createdAt: overrides.createdAt ?? "2026-02-23T00:00:00.000Z",
kind: overrides.kind ?? "tool.started",
summary: overrides.summary ?? "Tool call",
tone: overrides.tone ?? "tool",
payload: overrides.payload ?? {},
turnId: overrides.turnId ? TurnId.makeUnsafe(overrides.turnId) : null,
...(overrides.sequence !== undefined ? { sequence: overrides.sequence } : {}),
};
}

describe("deriveVisibleThreadWorkLogEntries", () => {
it("keeps completed tool calls from previous turns visible in the thread timeline", () => {
const activities: OrchestrationThreadActivity[] = [
makeActivity({
id: "tool-1",
createdAt: "2026-02-23T00:00:01.000Z",
turnId: "turn-1",
kind: "tool.completed",
summary: "First tool call",
}),
makeActivity({
id: "tool-2",
createdAt: "2026-02-23T00:00:03.000Z",
turnId: "turn-2",
kind: "tool.completed",
summary: "Second tool call",
}),
];

expect(deriveVisibleThreadWorkLogEntries(activities).map((entry) => entry.id)).toEqual([
"tool-1",
"tool-2",
]);
});
});
14 changes: 13 additions & 1 deletion apps/web/src/components/ChatView.logic.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,15 @@
import { ProjectId, type ProviderKind, type ThreadId } from "@t3tools/contracts";
import {
ProjectId,
type OrchestrationThreadActivity,
type ProviderKind,
type ThreadId,
} from "@t3tools/contracts";
import { type ChatMessage, type Thread } from "../types";
import { randomUUID } from "~/lib/utils";
import { getAppModelOptions } from "../appSettings";
import { type ComposerImageAttachment, type DraftThreadState } from "../composerDraftStore";
import { Schema } from "effect";
import { deriveWorkLogEntries, type WorkLogEntry } from "../session-logic";

export const LAST_INVOKED_SCRIPT_BY_PROJECT_KEY = "t3code:last-invoked-script-by-project";
const WORKTREE_BRANCH_PREFIX = "t3code";
Expand Down Expand Up @@ -123,3 +129,9 @@ export function getCustomModelOptionsByProvider(settings: {
codex: getAppModelOptions("codex", settings.customCodexModels),
};
}

export function deriveVisibleThreadWorkLogEntries(
activities: ReadonlyArray<OrchestrationThreadActivity>,
): WorkLogEntry[] {
return deriveWorkLogEntries(activities, undefined);
}
6 changes: 3 additions & 3 deletions apps/web/src/components/ChatView.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,6 @@ import {
deriveActiveWorkStartedAt,
deriveActivePlanState,
findLatestProposedPlan,
deriveWorkLogEntries,
hasToolActivityForTurn,
isLatestTurnSettled,
formatElapsed,
Expand Down Expand Up @@ -149,6 +148,7 @@ import {
buildTemporaryWorktreeBranchName,
cloneComposerImageForRetry,
collectUserMessageBlobPreviewUrls,
deriveVisibleThreadWorkLogEntries,
getCustomModelOptionsByProvider,
LAST_INVOKED_SCRIPT_BY_PROJECT_KEY,
LastInvokedScriptByProjectSchema,
Expand Down Expand Up @@ -578,8 +578,8 @@ export default function ChatView({ threadId }: ChatViewProps) {
);
const threadActivities = activeThread?.activities ?? EMPTY_ACTIVITIES;
const workLogEntries = useMemo(
() => deriveWorkLogEntries(threadActivities, activeLatestTurn?.turnId ?? undefined),
[activeLatestTurn?.turnId, threadActivities],
() => deriveVisibleThreadWorkLogEntries(threadActivities),
[threadActivities],
);
const latestTurnHasToolActivity = useMemo(
() => hasToolActivityForTurn(threadActivities, activeLatestTurn?.turnId),
Expand Down