|
1 | 1 | import { worktreeSetupAgentStarted } from "@t3tools/client-runtime/worktree-setup"; |
| 2 | +import { resolveUserMessagePresentation } from "@t3tools/client-runtime/user-message"; |
2 | 3 | import { isLiveSubagentTurnItem } from "@t3tools/client-runtime/state/subagentRuntime"; |
3 | 4 | import * as DateTime from "effect/DateTime"; |
4 | 5 | import * as Equal from "effect/Equal"; |
@@ -594,6 +595,10 @@ type MessagesTimelineRowContent = |
594 | 595 | assistantCopyStreaming: boolean; |
595 | 596 | assistantTurnDiffSummary?: TurnDiffSummary | undefined; |
596 | 597 | revertTurnCount?: number | undefined; |
| 598 | + /** Another of your messages follows directly, so the two sit closer together. */ |
| 599 | + groupedWithNext?: boolean; |
| 600 | + /** Set when the message above is a steer too, so the label shows once. */ |
| 601 | + continuesSteer?: boolean; |
597 | 602 | } |
598 | 603 | | { |
599 | 604 | kind: "assistant-meta"; |
@@ -2134,13 +2139,36 @@ export function deriveMessagesTimelineRows(input: { |
2134 | 2139 | const result = attachTrailingToolGroupsToAssistant( |
2135 | 2140 | attachCreatedThreadSummaries(nextRows, timelineEntries, collapsedFoldMemberIds), |
2136 | 2141 | ); |
2137 | | - return result.map((row, index) => |
2138 | | - timelineRowIsWorkLog(row) && timelineRowIsWorkLog(result[index + 1]) |
2139 | | - ? { ...row, continuesWorkLog: true } |
2140 | | - : row, |
| 2142 | + return result.map((row, index) => { |
| 2143 | + if (timelineRowIsWorkLog(row) && timelineRowIsWorkLog(result[index + 1])) { |
| 2144 | + return { ...row, continuesWorkLog: true }; |
| 2145 | + } |
| 2146 | + if (!timelineRowIsOwnUserMessage(row)) return row; |
| 2147 | + const previous = result[index - 1]; |
| 2148 | + const groupedWithNext = timelineRowIsOwnUserMessage(result[index + 1]); |
| 2149 | + const continuesSteer = |
| 2150 | + timelineRowIsOwnUserMessage(previous) && |
| 2151 | + messageIsSteer(row.message) && |
| 2152 | + messageIsSteer(previous.message); |
| 2153 | + if (!groupedWithNext && !continuesSteer) return row; |
| 2154 | + return { ...row, groupedWithNext, continuesSteer }; |
| 2155 | + }); |
| 2156 | +} |
| 2157 | + |
| 2158 | +function timelineRowIsOwnUserMessage( |
| 2159 | + row: MessagesTimelineRow | undefined, |
| 2160 | +): row is Extract<MessagesTimelineRow, { kind: "message" }> { |
| 2161 | + return ( |
| 2162 | + row?.kind === "message" && |
| 2163 | + row.message.role === "user" && |
| 2164 | + resolveUserMessagePresentation(row.message).attribution === null |
2141 | 2165 | ); |
2142 | 2166 | } |
2143 | 2167 |
|
| 2168 | +function messageIsSteer(message: ChatMessage): boolean { |
| 2169 | + return message.inputIntent === "steer" || message.inputIntent === "promoted_queued_to_steer"; |
| 2170 | +} |
| 2171 | + |
2144 | 2172 | function timelineRowIsWorkLog(row: MessagesTimelineRow | undefined): boolean { |
2145 | 2173 | return ( |
2146 | 2174 | row !== undefined && |
@@ -2478,7 +2506,9 @@ function isRowUnchanged(a: MessagesTimelineRow, b: MessagesTimelineRow): boolean |
2478 | 2506 | a.showAssistantCopyButton === bm.showAssistantCopyButton && |
2479 | 2507 | a.assistantCopyStreaming === bm.assistantCopyStreaming && |
2480 | 2508 | a.assistantTurnDiffSummary === bm.assistantTurnDiffSummary && |
2481 | | - a.revertTurnCount === bm.revertTurnCount |
| 2509 | + a.revertTurnCount === bm.revertTurnCount && |
| 2510 | + a.groupedWithNext === bm.groupedWithNext && |
| 2511 | + a.continuesSteer === bm.continuesSteer |
2482 | 2512 | ); |
2483 | 2513 | } |
2484 | 2514 | } |
|
0 commit comments