Skip to content

Commit 0ec4974

Browse files
committed
fix(web): background work line sits right under the message
A finished message reserves an invisible hover row for copy, fork and time, which left 48px between the message and the background work line. While the line shows, those actions move below it, like they do after trailing work.
1 parent 0dd2985 commit 0ec4974

3 files changed

Lines changed: 56 additions & 11 deletions

File tree

‎apps/web/src/components/ChatView.tsx‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3244,6 +3244,7 @@ export default function ChatView(props: ChatViewProps) {
32443244
{...(onOpenWorktreeSetupTerminal ? { onOpenWorktreeSetupTerminal } : {})}
32453245
isPreparingWorktree={isPreparingWorktree}
32463246
footer={timelineFooter}
3247+
footerContinuesMessage={backgroundWorkNow !== null}
32473248
listRef={legendListRef}
32483249
runs={serverProjection?.runs ?? []}
32493250
latestRun={activeActivityRun}

‎apps/web/src/components/chat/MessagesTimeline.logic.ts‎

Lines changed: 19 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1192,6 +1192,21 @@ function deriveTurnFolds(input: {
11921192
return foldsByAnchorEntryId;
11931193
}
11941194

1195+
export function assistantMetaRow(
1196+
row: Extract<MessagesTimelineRow, { kind: "message" }>,
1197+
createdAt: string,
1198+
): Extract<MessagesTimelineRow, { kind: "assistant-meta" }> {
1199+
return {
1200+
kind: "assistant-meta",
1201+
id: `assistant-meta:${row.message.id}`,
1202+
...(row.projectedItem === undefined ? {} : { projectedItem: row.projectedItem }),
1203+
createdAt,
1204+
message: row.message,
1205+
showAssistantCopyButton: row.showAssistantCopyButton,
1206+
assistantCopyStreaming: row.assistantCopyStreaming,
1207+
};
1208+
}
1209+
11951210
function attachTrailingToolGroupsToAssistant(
11961211
rows: ReadonlyArray<MessagesTimelineRow>,
11971212
): MessagesTimelineRow[] {
@@ -1259,15 +1274,10 @@ function attachTrailingToolGroupsToAssistant(
12591274
}
12601275

12611276
messageRowsWithoutMeta.add(row.id);
1262-
metaRowsAfterIndex.set(lastTrailingWorkIndex, {
1263-
kind: "assistant-meta",
1264-
id: `assistant-meta:${row.message.id}`,
1265-
...(row.projectedItem === undefined ? {} : { projectedItem: row.projectedItem }),
1266-
createdAt: rows[lastTrailingWorkIndex]?.createdAt ?? row.message.updatedAt,
1267-
message: row.message,
1268-
showAssistantCopyButton: row.showAssistantCopyButton,
1269-
assistantCopyStreaming: row.assistantCopyStreaming,
1270-
});
1277+
metaRowsAfterIndex.set(
1278+
lastTrailingWorkIndex,
1279+
assistantMetaRow(row, rows[lastTrailingWorkIndex]?.createdAt ?? row.message.updatedAt),
1280+
);
12711281
}
12721282

12731283
const result: MessagesTimelineRow[] = [];

‎apps/web/src/components/chat/MessagesTimeline.tsx‎

Lines changed: 36 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,7 @@ import { useAssistantCitationTarget } from "./useAssistantCitationTarget";
7171
import { worktreeSetupAgentStarted } from "@t3tools/client-runtime/worktree-setup";
7272
import { resolveCitationPhase, type CitedHistory } from "./citationProcedure";
7373
import {
74+
assistantMetaRow,
7475
resolveTimelineIsAtEnd,
7576
resolveTimelineMinimapHasPersistentGutter,
7677
resolveTimelineMinimapCurrentIndex,
@@ -232,6 +233,8 @@ interface MessagesTimelineProps {
232233
/** Which request is waiting, so a second one of the same kind is announced too. */
233234
awaitingRequestId?: string | null;
234235
footer?: ReactNode;
236+
/** The footer continues the last message, so that message's actions follow it. */
237+
footerContinuesMessage?: boolean;
235238

236239
listRef: React.RefObject<LegendListRef | null>;
237240
timelineEntries: ReadonlyArray<TimelineEntry>;
@@ -330,6 +333,7 @@ const ConversationTimeline = memo(function ConversationTimeline({
330333
activeTurnStartedAt = null,
331334
worktreeSetup = null,
332335
footer = null,
336+
footerContinuesMessage = false,
333337
onCancelWorktreeSetup,
334338
retryableWorkspacePreparationRunIds = EMPTY_RUN_IDS,
335339
onRetryWorkspacePreparation,
@@ -683,6 +687,20 @@ const ConversationTimeline = memo(function ConversationTimeline({
683687
worktreeSetup,
684688
});
685689
const rows = useStableRows(rawRows, listIdentityKey);
690+
const lastRow = rows.at(-1);
691+
// A message reserves an invisible hover row for its actions, which would hold the footer away.
692+
const messageBeforeFooter =
693+
footerContinuesMessage &&
694+
lastRow?.kind === "message" &&
695+
lastRow.message.role === "assistant" &&
696+
lastRow.showAssistantMeta
697+
? lastRow
698+
: null;
699+
const messageBeforeFooterRow = messageBeforeFooter && {
700+
...messageBeforeFooter,
701+
showAssistantMeta: false,
702+
showAssistantCopyButton: false,
703+
};
686704
const unmatchedPendingApprovals = new Map(pendingApprovalsByRequestId);
687705
if (unmatchedPendingApprovals.size > 0) {
688706
for (const row of rows) {
@@ -1225,19 +1243,35 @@ const ConversationTimeline = memo(function ConversationTimeline({
12251243
data-timeline-root="true"
12261244
>
12271245
<AudioPreviewUnmountContext value={onAudioUnmount}>
1228-
<TimelineRowContent row={item} />
1246+
<TimelineRowContent
1247+
row={item.id === messageBeforeFooterRow?.id ? messageBeforeFooterRow : item}
1248+
/>
12291249
</AudioPreviewUnmountContext>
12301250
</div>
12311251
</div>
12321252
</TimelineRowCtx>
12331253
);
1234-
const listExtraData = { identity: listIdentityKey, rowCount: rows.length, sharedState };
1254+
const listExtraData = {
1255+
identity: listIdentityKey,
1256+
rowCount: rows.length,
1257+
sharedState,
1258+
messageBeforeFooterRow,
1259+
};
12351260
const timelineListFooter = (
12361261
<TimelineListFooter
12371262
composerInset={anchoredEndSpace ? 0 : contentInsetEndAdjustment}
12381263
onGrow={onFooterGrow}
12391264
>
12401265
{footer}
1266+
{messageBeforeFooter ? (
1267+
<TimelineRowCtx value={sharedState}>
1268+
<div className="chat-content-lane">
1269+
<AssistantMetaTimelineRow
1270+
row={assistantMetaRow(messageBeforeFooter, messageBeforeFooter.message.updatedAt)}
1271+
/>
1272+
</div>
1273+
</TimelineRowCtx>
1274+
) : null}
12411275
{unmatchedPendingApprovals.size > 0 ? (
12421276
<TimelineRowCtx value={sharedState}>
12431277
<div className="messages-timeline-row-frame">

0 commit comments

Comments
 (0)