|
1 | 1 | import { |
| 2 | + groupMentionOccurrences, |
2 | 3 | groupRowSpeaker, |
| 4 | + sameThreadGroup, |
3 | 5 | isQuietPass, |
4 | 6 | quietPassLine, |
5 | 7 | type ThreadGroup, |
@@ -1236,8 +1238,14 @@ function ArtifactTemplateCard(props: { |
1236 | 1238 | ); |
1237 | 1239 | } |
1238 | 1240 |
|
| 1241 | +function exactGroupMention(text: string, group: ThreadGroup | null | undefined) { |
| 1242 | + const mention = groupMentionOccurrences(text, group)[0]; |
| 1243 | + return mention !== undefined && mention.source === text ? mention : undefined; |
| 1244 | +} |
| 1245 | + |
1239 | 1246 | const AssistantMarkdownContent = memo(function AssistantMarkdownContent(props: { |
1240 | 1247 | readonly markdown: string; |
| 1248 | + readonly group?: ThreadGroup | null; |
1241 | 1249 | readonly environmentId: EnvironmentId; |
1242 | 1250 | readonly markdownStyles: MarkdownStyleSet; |
1243 | 1251 | readonly linkHandlers: MarkdownLinkHandlers; |
@@ -1273,13 +1281,15 @@ const AssistantMarkdownContent = memo(function AssistantMarkdownContent(props: { |
1273 | 1281 | renderImage={props.renderImage} |
1274 | 1282 | skills={props.skills} |
1275 | 1283 | models={models} |
| 1284 | + group={props.group} |
1276 | 1285 | /> |
1277 | 1286 | ); |
1278 | 1287 | }); |
1279 | 1288 |
|
1280 | 1289 | // Folds split first, so an artifact card inside a fold stays inside it. |
1281 | 1290 | function AssistantMarkdownBlocks(props: { |
1282 | 1291 | readonly markdown: string; |
| 1292 | + readonly group?: ThreadGroup | null; |
1283 | 1293 | /** The reply's reference definitions, passed down by the enclosing fold. */ |
1284 | 1294 | readonly definitions?: ReadonlyArray<string> | undefined; |
1285 | 1295 | readonly markdownStyles: MarkdownStyleSet; |
@@ -1335,6 +1345,7 @@ function AssistantMarkdownBlocks(props: { |
1335 | 1345 | )} |
1336 | 1346 | skills={props.skills} |
1337 | 1347 | models={props.models} |
| 1348 | + group={props.group} |
1338 | 1349 | textStyle={props.markdownStyles.nativeTextStyle} |
1339 | 1350 | {...props.linkHandlers} |
1340 | 1351 | renderImage={props.renderImage} |
@@ -1534,6 +1545,7 @@ function OpenSenderThreadButton(props: { |
1534 | 1545 | /** Automation prompts are long, repeated runbooks; a folded bubble keeps them out of the way. */ |
1535 | 1546 | function ThreadAutomationMessageRow(props: { |
1536 | 1547 | readonly environmentId: EnvironmentId; |
| 1548 | + readonly group?: ThreadGroup | null; |
1537 | 1549 | readonly text: string; |
1538 | 1550 | readonly context?: OrchestrationMessageContext; |
1539 | 1551 | readonly scheduledTaskId: ScheduledTaskId | undefined; |
@@ -1606,6 +1618,7 @@ function ThreadAutomationMessageRow(props: { |
1606 | 1618 | <MarkdownImageAvailableWidthContext value={props.contentMaxWidth}> |
1607 | 1619 | <UserMessageContent |
1608 | 1620 | text={renderAssistantCitationsAsText(props.text)} |
| 1621 | + group={props.group} |
1609 | 1622 | environmentId={props.environmentId} |
1610 | 1623 | context={props.context} |
1611 | 1624 | markdownStyles={props.markdownStyles} |
@@ -1863,6 +1876,7 @@ function renderFeedEntry( |
1863 | 1876 | <MarkdownImageAvailableWidthContext value={props.markdownContentWidth}> |
1864 | 1877 | <AssistantMarkdownContent |
1865 | 1878 | markdown={entry.text} |
| 1879 | + group={props.group} |
1866 | 1880 | environmentId={props.environmentId} |
1867 | 1881 | markdownStyles={markdownStyles.assistant} |
1868 | 1882 | linkHandlers={props.markdownLinkHandlers} |
@@ -2065,6 +2079,7 @@ function renderFeedEntry( |
2065 | 2079 | return ( |
2066 | 2080 | <ThreadAutomationMessageRow |
2067 | 2081 | environmentId={props.environmentId} |
| 2082 | + group={props.group} |
2068 | 2083 | text={presentation.text} |
2069 | 2084 | context={message.context} |
2070 | 2085 | scheduledTaskId={presentation.scheduledTaskId} |
@@ -2306,6 +2321,7 @@ function renderFeedEntry( |
2306 | 2321 | > |
2307 | 2322 | <UserMessageContent |
2308 | 2323 | text={renderedText} |
| 2324 | + group={props.group} |
2309 | 2325 | sent={{ threadId: message.sourceThreadId, messageId: message.id }} |
2310 | 2326 | environmentId={props.environmentId} |
2311 | 2327 | context={message.context} |
@@ -2430,6 +2446,7 @@ function renderFeedEntry( |
2430 | 2446 | <MarkdownImageAvailableWidthContext value={props.markdownContentWidth}> |
2431 | 2447 | <AssistantMarkdownContent |
2432 | 2448 | markdown={renderedText} |
| 2449 | + group={props.group} |
2433 | 2450 | environmentId={props.environmentId} |
2434 | 2451 | markdownStyles={styles} |
2435 | 2452 | linkHandlers={props.markdownLinkHandlers} |
@@ -2553,6 +2570,7 @@ function TurnDiffStat(props: { |
2553 | 2570 |
|
2554 | 2571 | type UserMessageContentProps = { |
2555 | 2572 | readonly text: string; |
| 2573 | + readonly group?: ThreadGroup | null; |
2556 | 2574 | readonly sent?: { readonly threadId: ThreadId; readonly messageId: MessageId }; |
2557 | 2575 | readonly environmentId: EnvironmentId; |
2558 | 2576 | readonly context?: OrchestrationMessageContext; |
@@ -2693,6 +2711,7 @@ function UserMessageMarkdownContent(props: UserMessageContentProps) { |
2693 | 2711 | contextClipboardFragment={contextClipboardFragment} |
2694 | 2712 | skills={props.skills} |
2695 | 2713 | models={models} |
| 2714 | + group={props.group} |
2696 | 2715 | textStyle={props.markdownStyles.nativeTextStyle} |
2697 | 2716 | preserveSoftBreaks |
2698 | 2717 | {...props.linkHandlers} |
@@ -2726,6 +2745,7 @@ function UserMessageMarkdownContent(props: UserMessageContentProps) { |
2726 | 2745 | contextClipboardFragment={contextClipboardFragment} |
2727 | 2746 | skills={props.skills} |
2728 | 2747 | models={models} |
| 2748 | + group={props.group} |
2729 | 2749 | textStyle={props.markdownStyles.nativeTextStyle} |
2730 | 2750 | preserveSoftBreaks |
2731 | 2751 | {...props.linkHandlers} |
@@ -2886,6 +2906,8 @@ const THREAD_FEED_MAINTAIN_SCROLL_AT_END = { |
2886 | 2906 | } as const; |
2887 | 2907 |
|
2888 | 2908 | export const ThreadFeed = memo(function ThreadFeed(props: ThreadFeedProps) { |
| 2909 | + const [group, setGroup] = useState(props.group); |
| 2910 | + if (!sameThreadGroup(group, props.group)) setGroup(props.group); |
2889 | 2911 | const formatMessageTime = useMessageTimeFormatter(); |
2890 | 2912 | const { listRef, onIsAtEndChange, onHeaderMaterialVisibilityChange } = props; |
2891 | 2913 | const workflowOpening = useWorkflowOpening(props.detailRef); |
@@ -3164,6 +3186,16 @@ export const ThreadFeed = memo(function ThreadFeed(props: ThreadFeedProps) { |
3164 | 3186 | reply?: MarkdownLinkReply, |
3165 | 3187 | withGallery?: (source: FilePreviewSource) => FilePreviewSource, |
3166 | 3188 | ) => { |
| 3189 | + const mention = exactGroupMention(href, group); |
| 3190 | + if (mention) { |
| 3191 | + if (mention.member !== "primary") { |
| 3192 | + openLinkedThread({ |
| 3193 | + environmentId: String(props.environmentId), |
| 3194 | + threadId: String(mention.member), |
| 3195 | + }); |
| 3196 | + } |
| 3197 | + return; |
| 3198 | + } |
3167 | 3199 | markdownLinkRequest.current?.abort(); |
3168 | 3200 | const request = new AbortController(); |
3169 | 3201 | markdownLinkRequest.current = request; |
@@ -3276,6 +3308,19 @@ export const ThreadFeed = memo(function ThreadFeed(props: ThreadFeedProps) { |
3276 | 3308 | onImagePress: (href, withGallery) => onMarkdownLinkPress(href, true, undefined, withGallery), |
3277 | 3309 | resolveImageSource, |
3278 | 3310 | fileContextMenu: (href) => { |
| 3311 | + const mention = exactGroupMention(href, group); |
| 3312 | + if (mention) { |
| 3313 | + return { |
| 3314 | + title: mention.label, |
| 3315 | + actions: |
| 3316 | + mention.member === "primary" |
| 3317 | + ? [{ id: "copy-mention", title: "Copy" }] |
| 3318 | + : [ |
| 3319 | + { id: "open-member", title: "Open work" }, |
| 3320 | + { id: "copy-mention", title: "Copy" }, |
| 3321 | + ], |
| 3322 | + }; |
| 3323 | + } |
3279 | 3324 | const skill = enrichedSkillReference(href, props.skills); |
3280 | 3325 | if (skill) { |
3281 | 3326 | return { |
@@ -3305,6 +3350,16 @@ export const ThreadFeed = memo(function ThreadFeed(props: ThreadFeedProps) { |
3305 | 3350 | return target ? fileChipMenu(target) : undefined; |
3306 | 3351 | }, |
3307 | 3352 | onFileContextMenuAction: (href, actionId, reply) => { |
| 3353 | + const mention = exactGroupMention(href, group); |
| 3354 | + if (mention) { |
| 3355 | + if (actionId === "open-member" && mention.member !== "primary") { |
| 3356 | + openLinkedThread({ |
| 3357 | + environmentId: String(props.environmentId), |
| 3358 | + threadId: String(mention.member), |
| 3359 | + }); |
| 3360 | + } else if (actionId === "copy-mention") copyTextWithHaptic(mention.source); |
| 3361 | + return; |
| 3362 | + } |
3308 | 3363 | const skill = enrichedSkillReference(href, props.skills); |
3309 | 3364 | if (skill) { |
3310 | 3365 | const instructionsPath = enrichedSkillInstructionsPath(skill); |
@@ -3499,6 +3554,7 @@ export const ThreadFeed = memo(function ThreadFeed(props: ThreadFeedProps) { |
3499 | 3554 | // Include turn completion so unchanged message rows reveal their footer and spacing |
3500 | 3555 | // even when the final message update arrives before the turn settles. |
3501 | 3556 | const listAppearanceData = { |
| 3557 | + group, |
3502 | 3558 | disclosureLayout, |
3503 | 3559 | reduceMotion, |
3504 | 3560 | formatMessageTime, |
@@ -3914,7 +3970,7 @@ export const ThreadFeed = memo(function ThreadFeed(props: ThreadFeedProps) { |
3914 | 3970 | /> |
3915 | 3971 | ) : null} |
3916 | 3972 | {renderFeedEntry(info, { |
3917 | | - group: props.group, |
| 3973 | + group, |
3918 | 3974 | runs: structure?.projection.runs ?? [], |
3919 | 3975 | userMessageGrouping: info.item.userMessageGrouping, |
3920 | 3976 | formatMessageTime, |
|
0 commit comments