+ );
+}
+
+/** The provider and model of the run behind an assistant message, by their names in the picker. */
+export function useRunModelSender(
+ environmentId: EnvironmentId,
+ runs: ReadonlyArray,
+ runId: RunId | null,
+): MessageSender {
+ const run = runId === null ? undefined : runs.find((candidate) => candidate.id === runId);
+ const settings = useAtomValue(serverEnvironment.settingsValueAtom(environmentId));
+ const providersAtom = serverEnvironment.providersValueAtom(environmentId);
+ const entryOf = (providers: Parameters[0] | null) => {
+ if (run === undefined) return undefined;
+ const derived = deriveProviderInstanceEntries(providers ?? []);
+ const entries = settings ? brandProviderInstanceEntries(derived, settings) : derived;
+ return entries.find((candidate) => candidate.instanceId === run.modelSelection.instanceId);
+ };
+ // Select strings: provider status pushes replace the list even when names are unchanged.
+ const provider = useAtomValue(providersAtom, (providers) => {
+ if (run === undefined) return null;
+ return entryOf(providers)?.displayName ?? run.modelSelection.instanceId;
+ });
+ const model = useAtomValue(providersAtom, (providers) => {
+ if (run === undefined) return null;
+ const entry = entryOf(providers);
+ const known = entry?.models.find((candidate) => candidate.slug === run.modelSelection.model);
+ return known === undefined
+ ? run.modelSelection.model
+ : getTriggerDisplayModelName(known, entry?.driverKind);
+ });
+ return { kind: "model", provider, model };
+}
diff --git a/apps/web/src/components/chat/MessagesTimeline.logic.test.ts b/apps/web/src/components/chat/MessagesTimeline.logic.test.ts
index 1cd8066dbcd32..8d05c43e39d43 100644
--- a/apps/web/src/components/chat/MessagesTimeline.logic.test.ts
+++ b/apps/web/src/components/chat/MessagesTimeline.logic.test.ts
@@ -25,10 +25,11 @@ import {
} from "../../test-fixtures";
import type { TurnDiffSummary } from "../../types";
import { describe, expect, it } from "vite-plus/test";
-import { MessageId, RunId } from "@t3tools/contracts";
+import { AuthSessionId, MessageId, RunId } from "@t3tools/contracts";
import {
computeStableMessagesTimelineRows,
deriveMessagesTimelineRows,
+ filterTimelineRowsBySender,
timelineTurnFoldRunIdsByEntryId,
liveAnswerPreview,
deriveMessagesTimelineRowsWithState,
@@ -5158,3 +5159,67 @@ describe("isTimelineMinimapTurnVisible", () => {
expect(isTimelineMinimapTurnVisible(10, 500, null, null)).toBe(false);
});
});
+
+describe("message senders in the timeline", () => {
+ const runId = RunId.make("sender-run");
+ const time = (second: number) => new Date(Date.UTC(2026, 0, 1, 0, 0, second)).toISOString();
+ const sentBy = (founder: "kameron" | "jeff") => ({
+ sessionId: AuthSessionId.make(`session:${founder}`),
+ device: `${founder} laptop`,
+ deviceType: "desktop" as const,
+ founder,
+ });
+ const message = (
+ id: string,
+ second: number,
+ role: "user" | "assistant",
+ extra: Partial["message"] = undefined,
+ ): TimelineEntry => ({
+ kind: "message",
+ id,
+ createdAt: time(second),
+ message: {
+ id: MessageId.make(id),
+ role,
+ text: id,
+ runId,
+ createdAt: time(second),
+ updatedAt: time(second),
+ streaming: false,
+ ...extra,
+ },
+ });
+ const rows = deriveMessagesTimelineRows({
+ timelineEntries: [
+ message("kameron-1", 0, "user", { sentBy: sentBy("kameron") } as never),
+ message("kameron-2", 1, "user", { sentBy: sentBy("kameron") } as never),
+ message("jeff-1", 2, "user", { sentBy: sentBy("jeff") } as never),
+ message("reply", 3, "assistant"),
+ ],
+ latestRun: { runId, status: "completed", startedAt: time(0), completedAt: time(30) },
+ isWorking: false,
+ expandedRunIds: new Set(),
+ turnDiffSummaries: [],
+ supportsConversationRollback: false,
+ });
+
+ it("groups consecutive messages only under one sender", () => {
+ const byId = new Map(rows.map((row) => [row.id, row]));
+ expect(byId.get("kameron-1")).toMatchObject({ groupedWithNext: true });
+ expect(byId.get("kameron-2")).toMatchObject({
+ groupedWithPrevious: true,
+ groupedWithNext: false,
+ });
+ // Jeff's message starts a new group, so it shows his name.
+ expect(byId.get("jeff-1")).not.toHaveProperty("groupedWithPrevious", true);
+ });
+
+ it("keeps only the chosen sender's messages", () => {
+ expect(filterTimelineRowsBySender(rows, null)).toBe(rows);
+ expect(filterTimelineRowsBySender(rows, "jeff").map((row) => row.id)).toEqual(["jeff-1"]);
+ expect(filterTimelineRowsBySender(rows, "model").map((row) => row.id)).toEqual(["reply"]);
+ const kameron = filterTimelineRowsBySender(rows, "kameron");
+ expect(kameron.map((row) => row.id)).toEqual(["kameron-1", "kameron-2"]);
+ expect(kameron[1]).toMatchObject({ groupedWithPrevious: false });
+ });
+});
diff --git a/apps/web/src/components/chat/MessagesTimeline.logic.ts b/apps/web/src/components/chat/MessagesTimeline.logic.ts
index 5c4f99d76dc44..c4869c99cea24 100644
--- a/apps/web/src/components/chat/MessagesTimeline.logic.ts
+++ b/apps/web/src/components/chat/MessagesTimeline.logic.ts
@@ -13,6 +13,12 @@ import {
IDLE_COMPACTION_TITLES,
} from "@t3tools/client-runtime/user-message";
import type { HandoffTimelineRun } from "@t3tools/client-runtime/handoff";
+import {
+ messageSenderMatches,
+ resolveMessageSender,
+ sameMessageSender,
+} from "@t3tools/client-runtime/message-sender";
+import type { OrchestrationMessageSenderFilter } from "@t3tools/contracts";
import { renderCodexDirectivesForCopy } from "@t3tools/shared/codexMarkdownDirectives";
import {
commandDisplayText,
@@ -2361,8 +2367,15 @@ export function deriveMessagesTimelineRows(input: {
}
if (!timelineRowIsOwnUserMessage(row)) return row;
const previous = result[index - 1];
- const groupedWithNext = timelineRowIsOwnUserMessage(result[index + 1]);
- const groupedWithPrevious = timelineRowIsOwnUserMessage(previous);
+ const next = result[index + 1];
+ // Messages group only under one sender, so each change of sender gets its name.
+ const sender = resolveMessageSender(row.message);
+ const groupedWithNext =
+ timelineRowIsOwnUserMessage(next) &&
+ sameMessageSender(sender, resolveMessageSender(next.message));
+ const groupedWithPrevious =
+ timelineRowIsOwnUserMessage(previous) &&
+ sameMessageSender(sender, resolveMessageSender(previous.message));
const continuesSteer =
groupedWithPrevious && messageIsSteer(row.message) && messageIsSteer(previous.message);
if (!groupedWithNext && !groupedWithPrevious) return row;
@@ -2370,6 +2383,25 @@ export function deriveMessagesTimelineRows(input: {
});
}
+/**
+ * The timeline with only `sender`'s messages, for find's "From" filter. Tool calls, plans and
+ * other rows say nothing about who sent them, so they drop out too.
+ */
+export function filterTimelineRowsBySender(
+ rows: MessagesTimelineRow[],
+ sender: OrchestrationMessageSenderFilter | null,
+): MessagesTimelineRow[] {
+ if (sender === null) return rows;
+ return rows.flatMap((row) => {
+ if (row.kind !== "message") return [];
+ if (!messageSenderMatches(resolveMessageSender(row.message), sender)) return [];
+ // Neighbours are gone, so each kept message stands alone.
+ return row.groupedWithNext || row.groupedWithPrevious
+ ? [{ ...row, groupedWithNext: false, groupedWithPrevious: false, continuesSteer: false }]
+ : [row];
+ });
+}
+
function timelineRowIsOwnUserMessage(
row: MessagesTimelineRow | undefined,
): row is Extract {
diff --git a/apps/web/src/components/chat/MessagesTimeline.tsx b/apps/web/src/components/chat/MessagesTimeline.tsx
index b9653da6b315b..e381e295d7e1c 100644
--- a/apps/web/src/components/chat/MessagesTimeline.tsx
+++ b/apps/web/src/components/chat/MessagesTimeline.tsx
@@ -7,7 +7,7 @@ import { MarkdownFindContext } from "./markdownFindContext";
import { useChatCanvas } from "./ChatCanvasContext";
import { WorkLogBlock } from "./WorkLog";
import { TimelinePendingApprovalRow } from "./TimelinePendingApprovalRow";
-import type { WorktreeSetupSnapshot } from "@t3tools/contracts";
+import type { OrchestrationMessageSenderFilter, WorktreeSetupSnapshot } from "@t3tools/contracts";
import { deriveTimelineMinimapItems } from "./timelineMinimapItems";
import {
type AssistantCitation,
@@ -139,7 +139,12 @@ import {
} from "./timelineViewport";
import { useThreadFindPositionReader } from "./useThreadFindPositionReader";
import { ThreadActivityAnnouncer } from "./ThreadActivityAnnouncer";
-import { useStableHandoffRuns, useIncrementalTimelineRows, useStableRows } from "./useTimelineRows";
+import {
+ useSenderFilteredRows,
+ useStableHandoffRuns,
+ useIncrementalTimelineRows,
+ useStableRows,
+} from "./useTimelineRows";
import { useClientSettings } from "../../hooks/useSettings";
function timelineListStateFor(identity: string): {
@@ -326,6 +331,7 @@ interface MessagesTimelineProps {
findQuery?: string;
activeFindMatch?: ThreadFindMatch | null;
findNavigationId?: number;
+ findSender?: OrchestrationMessageSenderFilter | null;
}
export function MessagesTimeline(props: MessagesTimelineProps) {
@@ -372,6 +378,7 @@ const ConversationTimeline = memo(function ConversationTimeline({
findQuery = "",
activeFindMatch = null,
findNavigationId = 0,
+ findSender = null,
latestRun,
announcedRun = null,
detailBehindShell = false,
@@ -754,7 +761,8 @@ const ConversationTimeline = memo(function ConversationTimeline({
toolCallVisibility,
revealedMessageId,
});
- const rows = useStableRows(rawRows, listIdentityKey);
+ const stableRows = useStableRows(rawRows, listIdentityKey);
+ const rows = useSenderFilteredRows(stableRows, findSender);
const matchedApprovalRequestIds = new Set();
for (const row of pendingApprovalRequestIds.size > 0 ? rows : []) {
const entries =
diff --git a/apps/web/src/components/chat/ThreadFindBar.tsx b/apps/web/src/components/chat/ThreadFindBar.tsx
index 5ef0485ff4f50..3e13cd32a2be9 100644
--- a/apps/web/src/components/chat/ThreadFindBar.tsx
+++ b/apps/web/src/components/chat/ThreadFindBar.tsx
@@ -9,6 +9,10 @@ import {
type ThreadFindAnnouncement,
} from "./threadFind";
import { THREAD_DETAILS_CARD_GAP } from "./threadDetailsCardLayout";
+import type { OrchestrationMessageSenderFilter } from "@t3tools/contracts";
+import { MESSAGE_SENDER_FILTER_LABELS } from "@t3tools/client-runtime/message-sender";
+
+const SENDER_FILTERS = Object.keys(MESSAGE_SENDER_FILTER_LABELS) as OrchestrationMessageSenderFilter[];
interface ThreadFindBarProps {
readonly open: boolean;
@@ -24,6 +28,9 @@ interface ThreadFindBarProps {
readonly settled: boolean;
readonly focusRequestId: number;
readonly onQueryChange: (query: string) => void;
+ /** Only messages from this sender stay in the timeline while find is open. */
+ readonly sender?: OrchestrationMessageSenderFilter | null;
+ readonly onSenderChange?: (sender: OrchestrationMessageSenderFilter | null) => void;
readonly onNext: () => void;
readonly onPrevious: () => void;
readonly onClose: () => void;
@@ -94,6 +101,7 @@ export function ThreadFindBar(props: ThreadFindBarProps) {
ref={inputRef}
type="search"
size="sm"
+ className="min-w-24"
value={props.query}
aria-label="Find in thread"
placeholder="Find in thread"
@@ -104,6 +112,28 @@ export function ThreadFindBar(props: ThreadFindBarProps) {
onKeyDown={handleKeyDown}
/>
+ {props.onSenderChange ? (
+
+ ) : null}
{announcement.text}
diff --git a/apps/web/src/components/chat/TimelineAssistantRows.tsx b/apps/web/src/components/chat/TimelineAssistantRows.tsx
index b62f6f8e4b10f..f3b978b91d5aa 100644
--- a/apps/web/src/components/chat/TimelineAssistantRows.tsx
+++ b/apps/web/src/components/chat/TimelineAssistantRows.tsx
@@ -32,6 +32,8 @@ import { readThreadTurnItems } from "../../state/entities";
import { useV2ItemSupport } from "../../state/v2ItemSupport";
import { TimelineRowCtx, TimelineRowActivityCtx, type TimelineRow } from "./timelineRowContext";
import { MESSAGE_HEADING_LEVEL, MessageAuthorHeading } from "./TimelineRowParts";
+import { messageSenderLabel } from "@t3tools/client-runtime/message-sender";
+import { MessageSenderLine, useRunModelSender } from "./MessageSenderLine";
import { useAtomValue } from "@effect/atom-react";
import { AsyncResult, Atom } from "effect/reactivity";
import { vcsEnvironment } from "../../state/vcs";
@@ -48,11 +50,12 @@ export function AssistantTimelineRow({ row }: { row: Extract
- T3 Code
+ {messageSenderLabel(sender)}
) : null}
+ {/* Who replied stays visible: the provider and model of the run that wrote it. */}
+ {row.showAssistantMeta && !row.message.streaming && sender.kind === "model" && sender.provider !== null ? (
+
+
+
+ ) : null}
{row.showAssistantMeta ? (
!isImageAttachment(attachment) && !isFileAttachment(attachment),
);
const userMessage = resolveUserMessagePresentation(row.message);
+ const sender = resolveMessageSender(row.message);
+ // Name a person's message where the sender changes; agents, guests and T3 Code name themselves.
+ // A message still on its way has no server stamp yet (no createdBy); it is the user's own.
+ const unsent = row.message.createdBy === undefined && row.message.sentBy === undefined;
+ const showSender = sender.kind === "person" && !row.groupedWithPrevious && !unsent;
+ const personHeading = sender.kind === "person" && !unsent ? messageSenderLabel(sender) : "You";
// Messages from other agents fold to one line so the user's own messages stay easy to find.
const folded = userMessage.attribution === "agent";
const [expanded, setExpanded] = useState(false);
@@ -856,6 +864,11 @@ function UserTimelineRow({ row }: { row: Extract
) : null}
+ {showSender ? (
+
+
+
+ ) : null}
{/* The row's heading already names the guest for screen readers. */}
{userMessage.guestName !== undefined ? (
@@ -873,7 +886,7 @@ function UserTimelineRow({ row }: { row: Extract
{/* The heading leads the media so screen readers reach it before the images. */}
- You
+ {personHeading}
{mediaBlock}
+ {onSetFounder && clientSession.client.deviceType !== "bot" ? (
+ // Messages sent from this client show this person's name. The server refuses a client
+ // naming itself, so the current one is set from another trusted client.
+
+ ) : null}
{!clientSession.current ? (