Skip to content

Local-first AI coding agent desktop: Electron + Rust host core + pi Agent Harness + user-installable plugins

fix(chat): derive thinking label from the latest turn activity

zszz3d753e260e936
diff --git a/apps/desktop/src/features/chat/transcript/TurnProcess.tsx b/apps/desktop/src/features/chat/transcript/TurnProcess.tsx
index 2b1dd78c4..9e49146d1 100644
--- a/apps/desktop/src/features/chat/transcript/TurnProcess.tsx
+++ b/apps/desktop/src/features/chat/transcript/TurnProcess.tsx
@@ -4,6 +4,7 @@ import type { AssistantTurnPart } from "../../../lib/assistant-turns";
import { formatToolDuration } from "../../../lib/tool-display";
import { TranscriptSearchContext } from "../../../lib/transcript-search-context";
import {
+ isThinkingActive,
resolveThinkingDisplayMode,
turnProcessTiming,
visibleProcessSteps,
@@ -59,10 +60,12 @@ export function TurnProcess({
item.message.isError),
),
);
- const thinkingOnly = parts.every(
- (part) =>
- part.kind === "activity" && part.items.every((item) => item.kind === "thinking"),
- );
+ const latestPart = timingParts.at(-1);
+ const latestActivity =
+ latestPart?.kind === "activity" ? latestPart.items.at(-1) : undefined;
+ const thinkingNow =
+ latestActivity?.kind === "thinking" &&
+ isThinkingActive(latestActivity.message, isActive);
const disclosure = useAutomaticDisclosure(
isActive && (failed || mode === "detailed"),
reveal,
@@ -103,7 +106,7 @@ export function TurnProcess({
<span className={`tool-activity-label${isActive ? " running" : ""}`}>
{t(
isActive
- ? thinkingOnly
+ ? thinkingNow
? "chat.thinkingFor"
: "chat.processingFor"
: "chat.processedFor",
diff --git a/docs/spec/04-ux/08-component-spec.md b/docs/spec/04-ux/08-component-spec.md
index c1264120d..e51f653d4 100644
--- a/docs/spec/04-ux/08-component-spec.md
+++ b/docs/spec/04-ux/08-component-spec.md
@@ -798,7 +798,9 @@ unchanged.
Completed process areas start collapsed; detailed mode opens the active process.
Manual choices and search reveals own the disclosure until unmount. Failed tools
open an unclaimed active process and keep their invocation-level error presentation.
-The header shows elapsed time and the visible process step count. Delegation
+The header shows elapsed time and the visible process step count. Its thinking
+label applies only while the latest activity is streaming reasoning without answer
+text; streamed answers use the processing label. Delegation
cards and individual tool details remain available inside the process.
`thinkingDisplayMode` defaults to `detailed`. In `compact`, reasoning text and
diff --git a/scripts/e2e/turn-process.tsx b/scripts/e2e/turn-process.tsx
index 2d1407176..ecab2d9cb 100644
--- a/scripts/e2e/turn-process.tsx
+++ b/scripts/e2e/turn-process.tsx
@@ -163,6 +163,44 @@ export async function turnProcessProbe() {
"search reveals folded progress",
);
+ const liveThought = message("live-thought", "assistant", "", {
+ thinking: "Reasoning before the answer",
+ status: "streaming",
+ });
+ const processLabel = () =>
+ container.querySelector(".tool-activity-label")?.textContent;
+ render([liveThought], true, null, "thinking-transition");
+ check(
+ processLabel()?.startsWith(i18n.t("chat.thinkingFor", { time: "" })),
+ "active reasoning uses the thinking label",
+ );
+ render(
+ [{ ...liveThought, content: "Answer has started" }],
+ true,
+ null,
+ "thinking-transition",
+ );
+ check(
+ processLabel()?.startsWith(i18n.t("chat.processingFor", { time: "" })) &&
+ visible(container.querySelector('[data-message-id="live-thought"]')),
+ "answer streaming ends the thinking label even when reasoning is retained",
+ );
+ render(
+ [
+ liveThought,
+ message("separate-answer", "assistant", "Answer text", {
+ status: "streaming",
+ }),
+ ],
+ true,
+ null,
+ "thinking-transition",
+ );
+ check(
+ processLabel()?.startsWith(i18n.t("chat.processingFor", { time: "" })),
+ "a later answer takes precedence over an earlier streaming thought",
+ );
+
const streaming = message("stream", "assistant", "Live text", {
status: "streaming",
});