Skip to content
Merged
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
20 changes: 10 additions & 10 deletions apps/app/src/views/ToolsView.plugin-detail.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -686,18 +686,18 @@ describe("BB Official plugin detail routing", () => {

const { wrapper: QueryClientWrapper } = createQueryClientTestHarness();
render(
<MemoryRouter initialEntries={["/extensions/plugins/github"]}>
<MemoryRouter initialEntries={["/settings/plugins/github"]}>
<Routes>
<Route path="/extensions/plugins/*" element={<RoutedToolsView />} />
<Route path="/settings/plugins/*" element={<RoutedPluginsView />} />
</Routes>
</MemoryRouter>,
{ wrapper: QueryClientWrapper },
);

await waitFor(() => {
expect(
document.querySelector("[data-plugin-summary]")?.textContent,
).toBe("Description from the installed catalog.");
expect(document.querySelector("[data-plugin-summary]")?.textContent).toBe(
"Description from the installed catalog.",
);
});
});

Expand Down Expand Up @@ -760,18 +760,18 @@ describe("BB Official plugin detail routing", () => {

const { wrapper: QueryClientWrapper } = createQueryClientTestHarness();
render(
<MemoryRouter initialEntries={["/extensions/plugins/github"]}>
<MemoryRouter initialEntries={["/settings/plugins/github"]}>
<Routes>
<Route path="/extensions/plugins/*" element={<RoutedToolsView />} />
<Route path="/settings/plugins/*" element={<RoutedPluginsView />} />
</Routes>
</MemoryRouter>,
{ wrapper: QueryClientWrapper },
);

await waitFor(() => {
expect(
document.querySelector("[data-plugin-summary]")?.textContent,
).toBe("Description from installed metadata.");
expect(document.querySelector("[data-plugin-summary]")?.textContent).toBe(
"Description from installed metadata.",
);
});
});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2053,7 +2053,10 @@ describe("turn details for an item that finishes in a later turn", () => {
unfinishedLatest.timelinePage.olderCursor!,
).response;
const beforeThought = unfinishedOlder.rows.find(
(row) => row.kind === "system" && row.title.startsWith("Thought for"),
(row) =>
row.kind === "system" &&
row.systemKind === "operation" &&
row.operationKind === "reasoning",
);
expect(beforeThought).toMatchObject({ detail: "Checking" });

Expand All @@ -2077,7 +2080,10 @@ describe("turn details for an item that finishes in a later turn", () => {
expect(latest.rows.some((row) => row.kind === "system")).toBe(false);
const after = collectTurnDetailsAndChildren(db, thread).get(turnId);
const thoughts = after?.details.filter(
(row) => row.kind === "system" && row.title.startsWith("Thought for"),
(row) =>
row.kind === "system" &&
row.systemKind === "operation" &&
row.operationKind === "reasoning",
);
expect(thoughts).toEqual([
expect.objectContaining({
Expand Down
8 changes: 5 additions & 3 deletions packages/thread-view/src/reasoning-lifecycle-projection.ts
Original file line number Diff line number Diff line change
Expand Up @@ -219,6 +219,7 @@ function finalizeReasoningLifecycleByKey(
return null;
}

const durationMs = args.meta.createdAt - lifecycle.startedAt;
const message: EventProjectionOperationMessage = {
kind: "operation",
id: messageId(
Expand All @@ -237,9 +238,10 @@ function finalizeReasoningLifecycleByKey(
? { parentToolCallId: lifecycle.parentToolCallId }
: {}),
opType: "reasoning",
title: `Thought for ${durationToCompactString(
args.meta.createdAt - lifecycle.startedAt,
)}`,
title:
durationMs > 0
? `Thought for ${durationToCompactString(durationMs)}`
: "Thought",
detail: normalizeReasoningDetail(detail),
status: args.status,
};
Expand Down
56 changes: 56 additions & 0 deletions packages/thread-view/test/reasoning-zero-duration.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
import { describe, expect, it } from "vitest";
import {
createTimelineEventFactory,
renderTimelineFixture,
} from "./timeline-test-harness.js";

describe("completed reasoning duration", () => {
it.each([
{ completedAt: 4_000, title: "Thought" },
{ completedAt: 3_000, title: "Thought" },
{ completedAt: 4_500, title: "Thought for 500ms" },
])(
"renders $title when completion is $completedAt",
({ completedAt, title }) => {
const event = createTimelineEventFactory({ threadId: "thread-1" });
const persistedAt = 4_000;
const timeline = renderTimelineFixture({
events: [
event.turnStarted({ createdAt: 0 }),
event.reasoningStarted({
createdAt: persistedAt,
itemId: "reasoning-1",
}),
event.reasoningDelta({
createdAt: persistedAt,
delta: "Checking the projection.",
itemId: "reasoning-1",
}),
event.reasoningCompleted({
createdAt: completedAt,
itemId: "reasoning-1",
text: "Checked the projection.",
}),
event.turnCompleted({ createdAt: 5_000 }),
],
projectionOptions: {
threadStatus: "idle",
turnMessageDetail: "summary",
},
});

const reasoning = timeline.messages.find(
(message) =>
message.kind === "operation" &&
message.detail === "Checked the projection.",
);
expect(reasoning).toMatchObject({
completedAt,
startedAt: persistedAt,
title,
});
expect(timeline.text).toContain(`── ${title}\n`);
expect(timeline.text).not.toContain("Thought for 0ms");
},
);
});
Loading