diff --git a/apps/mobile/assets/context-chip-icons/users.png b/apps/mobile/assets/context-chip-icons/users.png new file mode 100644 index 0000000000000..e1ab07ef1b75d Binary files /dev/null and b/apps/mobile/assets/context-chip-icons/users.png differ diff --git a/apps/mobile/scripts/sync-context-chip-icons.mjs b/apps/mobile/scripts/sync-context-chip-icons.mjs index 7b86766708763..64a700e93659f 100644 --- a/apps/mobile/scripts/sync-context-chip-icons.mjs +++ b/apps/mobile/scripts/sync-context-chip-icons.mjs @@ -46,6 +46,7 @@ const lucideIcons = [ "mouse-pointer-click", "server", "terminal", + "users", ]; async function lucideSvg(name) { diff --git a/apps/mobile/src/components/ComposerEditor.tsx b/apps/mobile/src/components/ComposerEditor.tsx index bae452bad7c48..6926e5e64b579 100644 --- a/apps/mobile/src/components/ComposerEditor.tsx +++ b/apps/mobile/src/components/ComposerEditor.tsx @@ -3,6 +3,7 @@ import { ComposerContextId } from "@t3tools/contracts"; import { useAtomValue } from "@effect/atom-react"; import { AsyncResult } from "effect/reactivity"; import { settlePromise, squashAtomCommandFailure } from "@t3tools/client-runtime/state/runtime"; +import { groupMentionOccurrences } from "@t3tools/client-runtime/state/thread-group"; import { useEffect, useState } from "react"; import type { EnvironmentId } from "@t3tools/contracts"; import { encodeComposerContextFragment } from "@t3tools/shared/composerContextClipboard"; @@ -196,6 +197,10 @@ export function ComposerEditor({ onInertChipPress?.(); return; } + const member = groupMentionOccurrences(selection.source, props.group, { + seatedOnly: true, + })[0]; + if (member?.source === selection.source) return; const path = composerMentionPath(selection.source, draft.context); if (path && onOpenMention) { onOpenMention(path); diff --git a/apps/mobile/src/features/threads/ThreadComposer.tsx b/apps/mobile/src/features/threads/ThreadComposer.tsx index 087bb928e505d..7cb55282ffdac 100644 --- a/apps/mobile/src/features/threads/ThreadComposer.tsx +++ b/apps/mobile/src/features/threads/ThreadComposer.tsx @@ -1,4 +1,4 @@ -import { groupParticipants, isGroupActive } from "@t3tools/client-runtime/state/thread-group"; +import { isGroupActive } from "@t3tools/client-runtime/state/thread-group"; import { orchestrationEnvironment } from "../../state/orchestration"; import { ProjectKnowledgeEntry } from "../../components/ProjectKnowledgeEntry"; import { useSidebarWorkspaceTabs } from "../layout/workspace/useSystemWorkspaceTabBar"; @@ -1043,10 +1043,9 @@ export const ThreadComposer = function ThreadComposer(props: ThreadComposerProps // The save uses a draft snapshot; further typing would be discarded on success. readOnly={isSubmissionLocked} skills={composerMenu.skills} - groupHandles={(isGroupActive(props.selectedThread.group) - ? groupParticipants(props.selectedThread.group) - : [] - ).map((participant) => participant.handle.toLowerCase())} + group={ + isGroupActive(props.selectedThread.group) ? props.selectedThread.group : null + } selection={composerMenu.selection} onChangeText={(text) => { if (!isSubmissionLocked) props.onChangeDraftMessage(text); diff --git a/apps/mobile/src/features/threads/ThreadFeed.tsx b/apps/mobile/src/features/threads/ThreadFeed.tsx index e122437e666d6..0c31be42aa580 100644 --- a/apps/mobile/src/features/threads/ThreadFeed.tsx +++ b/apps/mobile/src/features/threads/ThreadFeed.tsx @@ -1,5 +1,7 @@ import { + groupMentionOccurrences, groupRowSpeaker, + sameThreadGroup, isQuietPass, quietPassLine, type ThreadGroup, @@ -1236,8 +1238,14 @@ function ArtifactTemplateCard(props: { ); } +function exactGroupMention(text: string, group: ThreadGroup | null | undefined) { + const mention = groupMentionOccurrences(text, group)[0]; + return mention !== undefined && mention.source === text ? mention : undefined; +} + const AssistantMarkdownContent = memo(function AssistantMarkdownContent(props: { readonly markdown: string; + readonly group?: ThreadGroup | null; readonly environmentId: EnvironmentId; readonly markdownStyles: MarkdownStyleSet; readonly linkHandlers: MarkdownLinkHandlers; @@ -1273,6 +1281,7 @@ const AssistantMarkdownContent = memo(function AssistantMarkdownContent(props: { renderImage={props.renderImage} skills={props.skills} models={models} + group={props.group} /> ); }); @@ -1280,6 +1289,7 @@ const AssistantMarkdownContent = memo(function AssistantMarkdownContent(props: { // Folds split first, so an artifact card inside a fold stays inside it. function AssistantMarkdownBlocks(props: { readonly markdown: string; + readonly group?: ThreadGroup | null; /** The reply's reference definitions, passed down by the enclosing fold. */ readonly definitions?: ReadonlyArray | undefined; readonly markdownStyles: MarkdownStyleSet; @@ -1335,6 +1345,7 @@ function AssistantMarkdownBlocks(props: { )} skills={props.skills} models={props.models} + group={props.group} textStyle={props.markdownStyles.nativeTextStyle} {...props.linkHandlers} renderImage={props.renderImage} @@ -1534,6 +1545,7 @@ function OpenSenderThreadButton(props: { /** Automation prompts are long, repeated runbooks; a folded bubble keeps them out of the way. */ function ThreadAutomationMessageRow(props: { readonly environmentId: EnvironmentId; + readonly group?: ThreadGroup | null; readonly text: string; readonly context?: OrchestrationMessageContext; readonly scheduledTaskId: ScheduledTaskId | undefined; @@ -1606,6 +1618,7 @@ function ThreadAutomationMessageRow(props: { FilePreviewSource, ) => { + const mention = exactGroupMention(href, group); + if (mention) { + if (mention.member !== "primary") { + openLinkedThread({ + environmentId: String(props.environmentId), + threadId: String(mention.member), + }); + } + return; + } markdownLinkRequest.current?.abort(); const request = new AbortController(); markdownLinkRequest.current = request; @@ -3276,6 +3308,19 @@ export const ThreadFeed = memo(function ThreadFeed(props: ThreadFeedProps) { onImagePress: (href, withGallery) => onMarkdownLinkPress(href, true, undefined, withGallery), resolveImageSource, fileContextMenu: (href) => { + const mention = exactGroupMention(href, group); + if (mention) { + return { + title: mention.label, + actions: + mention.member === "primary" + ? [{ id: "copy-mention", title: "Copy" }] + : [ + { id: "open-member", title: "Open work" }, + { id: "copy-mention", title: "Copy" }, + ], + }; + } const skill = enrichedSkillReference(href, props.skills); if (skill) { return { @@ -3305,6 +3350,16 @@ export const ThreadFeed = memo(function ThreadFeed(props: ThreadFeedProps) { return target ? fileChipMenu(target) : undefined; }, onFileContextMenuAction: (href, actionId, reply) => { + const mention = exactGroupMention(href, group); + if (mention) { + if (actionId === "open-member" && mention.member !== "primary") { + openLinkedThread({ + environmentId: String(props.environmentId), + threadId: String(mention.member), + }); + } else if (actionId === "copy-mention") copyTextWithHaptic(mention.source); + return; + } const skill = enrichedSkillReference(href, props.skills); if (skill) { const instructionsPath = enrichedSkillInstructionsPath(skill); @@ -3499,6 +3554,7 @@ export const ThreadFeed = memo(function ThreadFeed(props: ThreadFeedProps) { // Include turn completion so unchanged message rows reveal their footer and spacing // even when the final message update arrives before the turn settles. const listAppearanceData = { + group, disclosureLayout, reduceMotion, formatMessageTime, @@ -3914,7 +3970,7 @@ export const ThreadFeed = memo(function ThreadFeed(props: ThreadFeedProps) { /> ) : null} {renderFeedEntry(info, { - group: props.group, + group, runs: structure?.projection.runs ?? [], userMessageGrouping: info.item.userMessageGrouping, formatMessageTime, diff --git a/apps/mobile/src/features/threads/ThreadGroupBar.tsx b/apps/mobile/src/features/threads/ThreadGroupBar.tsx index 85f39267b2ebd..5db39e272cb33 100644 --- a/apps/mobile/src/features/threads/ThreadGroupBar.tsx +++ b/apps/mobile/src/features/threads/ThreadGroupBar.tsx @@ -5,7 +5,7 @@ import { isGroupActive } from "@t3tools/client-runtime/state/thread-group"; import { Pressable, ScrollView, View } from "react-native"; import { AppText as Text } from "../../components/ui/AppText"; -import { Button } from "../../components/ui/Button"; +import { SymbolView } from "../../components/ui/AppSymbol"; import { Menu } from "../../components/ui/Menu"; import { useEnvironmentServerConfig } from "../../state/entities"; import { orchestrationEnvironment } from "../../state/orchestration"; @@ -32,8 +32,7 @@ export function ThreadGroupBar({ thread }: { readonly thread: EnvironmentThreadS const remove = useAtomCommand(orchestrationEnvironment.removeFromGroup); const end = useAtomCommand(orchestrationEnvironment.endGroup); const openWork = useOpenLinkedThread(); - const active = isGroupActive(group); - if (!active && !inviteAvailable) return null; + if (!isGroupActive(group)) return null; return ( // The feed scrolls beneath the composer dock, so text here needs its own surface. @@ -41,81 +40,82 @@ export function ThreadGroupBar({ thread }: { readonly thread: EnvironmentThreadS - {active ? ( - <> - + ★ {group.primary.label} + + {group.seats + .filter((seat) => seat.status === "seated") + .map((seat) => ( + { + if (nativeEvent.event === "work") + openWork({ environmentId, threadId: seat.threadId }); + if (nativeEvent.event === "remove") + void remove({ + environmentId, + input: { threadId: thread.id, seatThreadId: seat.threadId }, + }).then((result) => + alertGroupCommandFailure(`Could not remove ${seat.label}`, result), + ); + }} > - ★ {group.primary.label} - - {group.seats - .filter((seat) => seat.status === "seated") - .map((seat) => ( - { - if (nativeEvent.event === "work") - openWork({ environmentId, threadId: seat.threadId }); - if (nativeEvent.event === "remove") - void remove({ - environmentId, - input: { threadId: thread.id, seatThreadId: seat.threadId }, - }).then((result) => - alertGroupCommandFailure(`Could not remove ${seat.label}`, result), - ); - }} - > - - {seat.label} - - - ))} - - ) : null} - {inviteAvailable ? ( - + ))} - {/* The way out stays on screen however many members the row scrolls past. */} - {active ? ( -