The best way to control Claude Code, Codex and more from any computer or phone
feat(mobile): select, cite, and comment on assistant text (#35306)
Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com> Co-authored-by: maria-rcks <maria@kuuro.net> Co-authored-by: Julius Marminge <julius0216@outlook.com> Co-authored-by: Julius Marminge <51714798+juliusmarminge@users.noreply.github.com>
Jake Leventhal committed
Nov 18, 2026 at 19:24 UTC
733bc8f1d06d9597cc846305779b29540e970279
35 files changed
+1308
-151
apps/mobile/src/components/AssistantCitationSheet.tsx
new
+131
@@ -0,0 +1,131 @@
1
+import { ASSISTANT_CITATION_MAX_COMMENT_LENGTH, type AssistantCitation } from "@t3tools/contracts";
2
+import { scopedThreadKey } from "@t3tools/client-runtime/environment";
3
+import { useState } from "react";
4
+import { T, useGT } from "gt-react-native";
5
+import { Platform, ScrollView, TextInput, View } from "react-native";
6
+import { useSafeAreaInsets } from "react-native-safe-area-context";
7
+import { useOpenLinkedThread } from "../features/threads/useOpenLinkedThread";
8
+import { requestThreadMessageJump } from "../features/threads/threadMessageJump";
9
+import { copyTextWithHaptic } from "../lib/copyTextWithHaptic";
10
+import { AppText as Text } from "./ui/AppText";
11
+import { ListActionRow } from "./ui/ListActionRow";
12
+import { ListSection } from "./ui/ListSection";
13
+import { Sheet } from "./ui/Sheet";
14
+
15
+const CONTEXT_CHARS = 80;
16
+
17
+function contextBefore(prefix: string) {
18
+ const flat = prefix.replace(/\s+/g, " ");
19
+ if (flat.length <= CONTEXT_CHARS) return flat.trimStart();
20
+ const cut = flat.slice(-CONTEXT_CHARS);
21
+ return `…${cut.slice(cut.indexOf(" ") + 1)}`;
22
+}
23
+
24
+function contextAfter(suffix: string) {
25
+ const flat = suffix.replace(/\s+/g, " ");
26
+ if (flat.length <= CONTEXT_CHARS) return flat.trimEnd();
27
+ const cut = flat.slice(0, CONTEXT_CHARS);
28
+ return `${cut.slice(0, cut.lastIndexOf(" "))}…`;
29
+}
30
+
31
+export function AssistantCitationSheet(props: {
32
+ readonly citation: AssistantCitation;
33
+ readonly onClose: () => void;
34
+ readonly onRemove?: () => void;
35
+ readonly onCommentChange?: (comment: string) => void;
36
+ readonly canChangeComment?: (comment: string) => boolean;
37
+}) {
38
+ const gt = useGT();
39
+ const openLinkedThread = useOpenLinkedThread();
40
+ const insets = useSafeAreaInsets();
41
+ const citation = props.citation;
42
+ const [comment, setComment] = useState(citation.comment ?? "");
43
+ const commentChanged = comment.trim() !== (citation.comment ?? "");
44
+ const commentTooLong = commentChanged && props.canChangeComment?.(comment) === false;
45
+ const close = () => {
46
+ if (commentTooLong) return;
47
+ if (props.onCommentChange && commentChanged) {
48
+ props.onCommentChange(comment);
49
+ }
50
+ props.onClose();
51
+ };
52
+ return (
53
+ <Sheet
54
+ title={gt("Quote", { $context: "noun, a quoted passage" })}
55
+ onClose={close}
56
+ dismissDisabled={commentTooLong}
57
+ >
58
+ <ScrollView
59
+ contentInsetAdjustmentBehavior={Platform.OS === "ios" ? "automatic" : "never"}
60
+ contentContainerStyle={{
61
+ paddingHorizontal: 20,
62
+ paddingTop: 12,
63
+ gap: 24,
64
+ paddingBottom: Math.max(20, insets.bottom),
65
+ }}
66
+ >
67
+ <View className="flex-row gap-3 rounded-2xl bg-grouped-card p-4">
68
+ <View className="w-1 rounded-full bg-primary" />
69
+ <Text selectable textRole="body" className="min-w-0 flex-1 text-foreground-muted">
70
+ {contextBefore(citation.prefix)}
71
+ <Text className="font-t3-medium text-foreground">{citation.text}</Text>
72
+ {contextAfter(citation.suffix)}
73
+ </Text>
74
+ </View>
75
+ {props.onCommentChange ? (
76
+ <ListSection title={gt("Comment", { $context: "noun" })}>
77
+ <TextInput
78
+ accessibilityLabel={gt("Comment on quote")}
79
+ placeholder={gt("Add an optional comment…")}
80
+ placeholderTextColorClassName="accent-foreground-muted"
81
+ multiline
82
+ maxLength={ASSISTANT_CITATION_MAX_COMMENT_LENGTH}
83
+ value={comment}
84
+ onChangeText={setComment}
85
+ className="min-h-24 px-4 py-3 text-base text-foreground"
86
+ style={{ textAlignVertical: "top" }}
87
+ />
88
+ {commentTooLong ? (
89
+ <Text textRole="body" className="px-4 pb-3 text-foreground-muted">
90
+ <T>
91
+ This comment makes the message too long to send. Shorten it to save and close.
92
+ </T>
93
+ </Text>
94
+ ) : null}
95
+ </ListSection>
96
+ ) : citation.comment ? (
97
+ <ListSection title={gt("Comment", { $context: "noun" })}>
98
+ <Text selectable textRole="body" className="px-4 py-3 text-foreground">
99
+ {citation.comment}
100
+ </Text>
101
+ </ListSection>
102
+ ) : null}
103
+ <ListSection>
104
+ <ListActionRow
105
+ icon="arrow.up.right"
106
+ label={gt("Go to message")}
107
+ onPress={() => {
108
+ if (commentTooLong) return;
109
+ close();
110
+ requestThreadMessageJump(scopedThreadKey(citation), citation.messageId);
111
+ openLinkedThread(citation);
112
+ }}
113
+ />
114
+ <ListActionRow
115
+ icon="doc.on.doc"
116
+ label={gt("Copy quote")}
117
+ onPress={() => copyTextWithHaptic(citation.text)}
118
+ />
119
+ {props.onRemove ? (
120
+ <ListActionRow
121
+ icon="trash"
122
+ label={gt("Remove from draft")}
123
+ tone="danger"
124
+ onPress={props.onRemove}
125
+ />
126
+ ) : null}
127
+ </ListSection>
128
+ </ScrollView>
129
+ </Sheet>
130
+ );
131
+}
apps/mobile/src/components/ComposerEditor.ios.test.tsx
+1
@@ -116,6 +116,7 @@ vi.mock("expo-file-system", () => ({
116
vi.mock("./ui/Dialog", () => ({ alert: vi.fn() }));
117
vi.mock("./ui/AppText", () => ({ AppText: ({ children }: { children?: ReactNode }) => children }));
118
vi.mock("./ComposerContextSheet", () => ({ ComposerContextSheet: () => null }));
119
+vi.mock("./AssistantCitationSheet", () => ({ AssistantCitationSheet: () => null }));
120
vi.mock("../features/threads/useOpenLinkedThread", () => ({ useOpenLinkedThread: () => vi.fn() }));
121
vi.mock("../state/peerLinks", () => ({ useLinkedEnvironments: () => [] }));
122
vi.mock("../state/model-mentions", () => ({ useModelMentions: () => [] }));
apps/mobile/src/components/ComposerEditor.tsx
+66
-13
@@ -9,6 +9,12 @@ import { useEffect, useState } from "react";
9
import type { EnvironmentId } from "@t3tools/contracts";
10
import { encodeComposerContextFragment } from "@t3tools/shared/composerContextClipboard";
11
import { collectComposerContextReferences } from "@t3tools/shared/composerContextReferences";
12
+import {
13
+ collectAssistantCitations,
14
+ serializeAssistantCitation,
15
+ withAssistantCitationComment,
16
+} from "@t3tools/shared/assistantCitations";
17
+import { AssistantCitationSheet } from "./AssistantCitationSheet";
18
import { ComposerEditor as NativeComposerEditor } from "../native/T3ComposerEditor";
19
import type { ComposerEditorProps as NativeComposerEditorProps } from "../native/T3ComposerEditor";
20
import {
@@ -36,6 +42,7 @@ import { useLinkedEnvironments } from "../state/peerLinks";
42
import { ComposerContextSheet } from "./ComposerContextSheet";
43
import { AppText as Text } from "./ui/AppText";
44
import {
45
+ assistantCitationDraftWithinLimit,
46
composerDocumentAttachment,
47
composerMentionPath,
48
type ComposerDocumentAttachment,
@@ -183,6 +190,9 @@ export function ComposerEditor({
190
const selectedReference = selected
191
? collectComposerContextReferences(selected.source)[0]
192
: undefined;
193
+ const selectedCitation = selected
194
+ ? collectAssistantCitations(selected.source)[0]?.citation
195
+ : undefined;
196
const selectedSkillName = selected?.source.match(/^\p{Sc}(.+)$/u)?.[1];
197
const selectedSkill = selectedSkillName
198
? props.skills?.find((skill) => skill.name === selectedSkillName)
@@ -190,6 +200,41 @@ export function ComposerEditor({
200
const record = draft.context?.records.find(
201
(entry) => entry.contextId === selectedReference?.contextId,
202
);
203
+ const removeSelected =
204
+ props.readOnly || props.editable === false
205
+ ? undefined
206
+ : () => {
207
+ if (!selected) return;
208
+ if (props.value.slice(selected.start, selected.end) === selected.source) {
209
+ changeText(props.value.slice(0, selected.start) + props.value.slice(selected.end));
210
+ props.onSelectionChange?.({ start: selected.start, end: selected.start });
211
+ }
212
+ setSelected(null);
213
+ };
214
+ const commentSelectedCitation =
215
+ props.readOnly || props.editable === false || !selected || !selectedCitation
216
+ ? undefined
217
+ : (comment: string) => {
218
+ if (props.value.slice(selected.start, selected.end) !== selected.source) return;
219
+ const next = serializeAssistantCitation(
220
+ withAssistantCitationComment(selectedCitation, comment),
221
+ );
222
+ const text =
223
+ props.value.slice(0, selected.start) + next + props.value.slice(selected.end);
224
+ if (!assistantCitationDraftWithinLimit(text)) {
225
+ Dialog.alert(
226
+ gt("Could not update quote"),
227
+ gt(
228
+ "This comment would make the message too long to send. Shorten the comment or draft.",
229
+ ),
230
+ );
231
+ return;
232
+ }
233
+ const cursor = selected.start + next.length;
234
+ if (draftKey)
235
+ rememberComposerDraftSelection(draftKey, text, { start: cursor, end: cursor });
236
+ changeText(text);
237
+ };
238
return (
239
<>
240
{/* Reset revision history with the recreated iOS view without aborting context imports. */}
@@ -242,6 +287,26 @@ export function ComposerEditor({
287
<T>Copying context…</T>
288
</Text>
289
) : null}
290
+ {selectedCitation ? (
291
+ <AssistantCitationSheet
292
+ citation={selectedCitation}
293
+ onClose={() => setSelected(null)}
294
+ onRemove={removeSelected}
295
+ onCommentChange={commentSelectedCitation}
296
+ canChangeComment={
297
+ selected && commentSelectedCitation
298
+ ? (comment) =>
299
+ assistantCitationDraftWithinLimit(
300
+ props.value.slice(0, selected.start) +
301
+ serializeAssistantCitation(
302
+ withAssistantCitationComment(selectedCitation, comment),
303
+ ) +
304
+ props.value.slice(selected.end),
305
+ )
306
+ : undefined
307
+ }
308
+ />
309
+ ) : null}
310
{selected && (selectedReference || selectedSkill) ? (
311
<ComposerContextSheet
312
label={
@@ -283,19 +348,7 @@ export function ComposerEditor({
348
records={draft.context?.records}
349
attachments={draft.attachments}
350
onClose={() => setSelected(null)}
286
- onRemove={
287
- props.readOnly || props.editable === false
288
- ? undefined
289
- : () => {
290
- if (props.value.slice(selected.start, selected.end) === selected.source) {
291
- changeText(
292
- props.value.slice(0, selected.start) + props.value.slice(selected.end),
293
- );
294
- props.onSelectionChange?.({ start: selected.start, end: selected.start });
295
- }
296
- setSelected(null);
297
- }
298
- }
351
+ onRemove={removeSelected}
352
/>
353
) : null}
354
</>
apps/mobile/src/features/threads/ThreadDetailScreen.tsx
+40
-1
@@ -130,7 +130,15 @@ import { useAppearancePreferences } from "../settings/appearance/AppearancePrefe
130
import { collectProviderUsageLimits } from "@t3tools/shared/usageLimits";
131
import type { ComposerEditorHandle } from "../../components/ComposerEditor";
132
import type { StatusTone } from "../../components/StatusPill";
133
-import { getComposerDraftSnapshot, setFreshSessionPending } from "../../state/use-composer-drafts";
133
+import {
134
+ captureComposerDraftInsertion,
135
+ getComposerDraftSnapshot,
136
+ setFreshSessionPending,
137
+ insertComposerDraftText,
138
+} from "../../state/use-composer-drafts";
139
+import { assistantCitationDraftWithinLimit } from "../../lib/composerContext";
140
+import { serializeAssistantCitation } from "@t3tools/shared/assistantCitations";
141
+import type { AssistantCitation } from "@t3tools/contracts";
142
import { RenderErrorBoundary, RenderFailureView } from "../../components/RenderErrorBoundary";
143
import {
144
ANDROID_READING_MAX_WIDTH,
@@ -211,6 +219,7 @@ import { resolveThreadFeedSubmissionAnchor } from "./thread-feed-scroll-position
219
import { useOpenLinkedThread } from "./useOpenLinkedThread";
220
import { useGlobalVoiceInput } from "../voice-input/VoiceInputProvider";
221
import type { OrchestrationV2ProviderSession } from "@t3tools/contracts";
222
+import { voiceInputBlocksSubmission } from "@t3tools/client-runtime/voice-input";
223
224
export interface ThreadDetailScreenProps {
225
readonly header?: React.ReactNode;
@@ -1351,6 +1360,35 @@ function ThreadDetailBody(
1360
composerEditorRef.current?.blur();
1361
};
1362
1363
+ const canCiteAssistantText =
1364
+ props.composerDraftKey !== null &&
1365
+ !isProviderSubagent &&
1366
+ !composerSlotHidden &&
1367
+ !props.isSavingQueuedEdit &&
1368
+ !props.draftMode?.interactionLocked &&
1369
+ !(
1370
+ voiceInputSession.ownerKey === props.composerDraftKey &&
1371
+ voiceInputBlocksSubmission(voiceInputSession.controller.currentState)
1372
+ );
1373
+ const handleCiteAssistantText = (citation: AssistantCitation) => {
1374
+ if (!canCiteAssistantText || props.composerDraftKey === null) return;
1375
+ const target = captureComposerDraftInsertion(props.composerDraftKey);
1376
+ const prefix = target.start > 0 && !/\s/.test(target.text[target.start - 1]!) ? " " : "";
1377
+ const value = `${prefix}${serializeAssistantCitation(citation)} `;
1378
+ const text = target.text.slice(0, target.start) + value + target.text.slice(target.end);
1379
+ if (!assistantCitationDraftWithinLimit(text)) {
1380
+ Dialog.alert(
1381
+ gt("Could not add quote"),
1382
+ gt(
1383
+ "This quote would make the message too long to send. Shorten the draft or select less text.",
1384
+ ),
1385
+ );
1386
+ return;
1387
+ }
1388
+ insertComposerDraftText(props.composerDraftKey, value, target);
1389
+ composerEditorRef.current?.focus();
1390
+ };
1391
+
1392
const handleUseArtifactTemplate = (template: CodexArtifactTemplate) => {
1393
const draftMessage =
1394
props.composerDraftKey === null ? "" : getComposerDraftSnapshot(props.composerDraftKey).text;
@@ -1493,6 +1531,7 @@ function ThreadDetailBody(
1531
onHeaderMaterialVisibilityChange={props.onHeaderMaterialVisibilityChange}
1532
onIsAtEndChange={setIsAtEnd}
1533
skills={selectedProviderSkills}
1534
+ onCiteAssistantText={canCiteAssistantText ? handleCiteAssistantText : undefined}
1535
onUseArtifactTemplate={handleUseArtifactTemplate}
1536
/>
1537
</ColumnWidth>
apps/mobile/src/features/threads/ThreadFeed.tsx
+114
-16
@@ -3,8 +3,13 @@ import { m } from "../../i18n/messages";
3
import { errorDisplayMessage } from "@t3tools/client-runtime/errors";
4
import { toServerClock } from "@t3tools/client-runtime/clock";
5
import { formatDuration } from "@t3tools/shared/orchestrationTimingCopy";
6
+import { Sheet } from "../../components/ui/Sheet";
7
+import { ListActionRow } from "../../components/ui/ListActionRow";
8
+import { ListSection } from "../../components/ui/ListSection";
9
+import { collectMobileAssistantTextSelectors } from "../../lib/assistantCitationSelection";
10
import { Button } from "../../components/ui/Button";
11
import * as Dialog from "../../components/ui/Dialog";
12
+import { ASSISTANT_CITATION_MAX_TEXT_LENGTH, type AssistantCitation } from "@t3tools/contracts";
13
import { useOpenPullRequest } from "../../native/useOpenPullRequest";
14
import { useWorkspaceSettledContentWidth } from "../layout/workspace-content-width";
15
import { useVisibleSecondClock } from "./use-visible-second-clock";
@@ -78,7 +83,6 @@ import {
83
type ScopedThreadRef,
84
} from "@t3tools/contracts";
85
import type { ToolCallVisibility } from "@t3tools/contracts/settings";
81
-import { renderAssistantCitationsAsText } from "@t3tools/shared/assistantCitations";
86
import { encodeComposerContextFragment } from "@t3tools/shared/composerContextClipboard";
87
import { hostedThreadLink, parseThreadLinkHref } from "@t3tools/shared/threadLinks";
88
import { PROMPT_LINK_MAX_PROMPT_LENGTH } from "@t3tools/shared/promptLinks";
@@ -140,6 +144,7 @@ import {
144
} from "react";
145
import {
146
Image,
147
+ ScrollView,
148
Platform,
149
type LayoutChangeEvent,
150
type NativeScrollEvent,
@@ -394,6 +399,7 @@ export interface ThreadFeedProps {
399
readonly onIsAtEndChange?: (isAtEnd: boolean) => void;
400
readonly skills?: ReadonlyArray<SelectableMarkdownSkill>;
401
readonly onUseArtifactTemplate?: (template: CodexArtifactTemplate) => void;
402
+ readonly onCiteAssistantText?: (citation: AssistantCitation) => void;
403
}
404
405
const USER_MESSAGE_COPY_MENU_ACTIONS = [
@@ -1308,6 +1314,8 @@ function ArtifactTemplateCard(props: {
1314
const AssistantMarkdownContent = memo(function AssistantMarkdownContent(props: {
1315
readonly markdown: string;
1316
readonly environmentId: EnvironmentId;
1317
+ readonly citationSource?: Pick<AssistantCitation, "threadId" | "messageId">;
1318
+ readonly onCiteAssistantText?: (citation: AssistantCitation) => void;
1319
readonly markdownStyles: MarkdownStyleSet;
1320
readonly linkHandlers: MarkdownLinkHandlers;
1321
readonly reply?: MarkdownLinkReply | undefined;
@@ -1315,8 +1323,25 @@ const AssistantMarkdownContent = memo(function AssistantMarkdownContent(props: {
1323
readonly renderImage: MarkdownImageRenderer;
1324
readonly skills?: ReadonlyArray<SelectableMarkdownSkill> | undefined;
1325
}) {
1318
- const models = useModelMentions(props.environmentId, props.markdown);
1326
+ const gt = useGT();
1327
const liveMarkdown = useLiveThreadLinkLabels(props.markdown, props.environmentId);
1328
+ const [quoteSelection, setQuoteSelection] = useState<{
1329
+ markdown: string;
1330
+ selectors: ReturnType<typeof collectMobileAssistantTextSelectors>;
1331
+ } | null>(null);
1332
+ if (quoteSelection !== null && quoteSelection.markdown !== liveMarkdown) setQuoteSelection(null);
1333
+ const quoteChoices = quoteSelection?.selectors ?? [];
1334
+ const cite = ({ selector }: (typeof quoteChoices)[number]) => {
1335
+ if (!props.citationSource || !props.onCiteAssistantText) return;
1336
+ setQuoteSelection(null);
1337
+ props.onCiteAssistantText({
1338
+ version: 1,
1339
+ environmentId: props.environmentId,
1340
+ ...props.citationSource,
1341
+ ...selector,
1342
+ });
1343
+ };
1344
+ const models = useModelMentions(props.environmentId, props.markdown);
1345
const threadIcons = useThreadChipIcons(props.environmentId, liveMarkdown);
1346
const withGallery = useFilePreviewGallery();
1347
const onImagePress = props.linkHandlers.onImagePress;
@@ -1331,21 +1356,75 @@ const AssistantMarkdownContent = memo(function AssistantMarkdownContent(props: {
1356
};
1357
1358
return (
1334
- <AssistantMarkdownBlocks
1335
- markdown={liveMarkdown}
1336
- markdownStyles={props.markdownStyles}
1337
- linkHandlers={linkHandlers}
1338
- onUseArtifactTemplate={props.onUseArtifactTemplate}
1339
- renderImage={props.renderImage}
1340
- skills={props.skills}
1341
- models={models}
1342
- />
1359
+ <>
1360
+ <AssistantMarkdownBlocks
1361
+ markdown={liveMarkdown}
1362
+ onCiteText={
1363
+ props.onCiteAssistantText && props.citationSource
1364
+ ? (text, path) => {
1365
+ if (!text.trim()) return;
1366
+ if (text.length > ASSISTANT_CITATION_MAX_TEXT_LENGTH) {
1367
+ Dialog.alert(
1368
+ gt("Quote is too long"),
1369
+ gt("Select up to {max} characters to cite.", {
1370
+ max: ASSISTANT_CITATION_MAX_TEXT_LENGTH.toLocaleString(),
1371
+ }),
1372
+ );
1373
+ return;
1374
+ }
1375
+ const selectors = collectMobileAssistantTextSelectors(liveMarkdown, path, text);
1376
+ if (selectors.length === 0) {
1377
+ Dialog.alert(
1378
+ gt("Unable to locate quote"),
1379
+ gt("Select more surrounding text to cite its source accurately."),
1380
+ );
1381
+ return;
1382
+ }
1383
+ if (selectors.length === 1) cite(selectors[0]!);
1384
+ else setQuoteSelection({ markdown: liveMarkdown, selectors });
1385
+ }
1386
+ : undefined
1387
+ }
1388
+ markdownStyles={props.markdownStyles}
1389
+ linkHandlers={linkHandlers}
1390
+ onUseArtifactTemplate={props.onUseArtifactTemplate}
1391
+ renderImage={props.renderImage}
1392
+ skills={props.skills}
1393
+ models={models}
1394
+ />
1395
+ {quoteChoices.length > 0 && props.onCiteAssistantText ? (
1396
+ <Sheet title={gt("Choose quote source")} onClose={() => setQuoteSelection(null)}>
1397
+ <ScrollView
1398
+ contentInsetAdjustmentBehavior="automatic"
1399
+ contentContainerStyle={{ padding: 20 }}
1400
+ >
1401
+ <ListSection
1402
+ title={gt("This text appears more than once. Choose the passage you selected.")}
1403
+ >
1404
+ {quoteChoices.map((choice) => (
1405
+ <ListActionRow
1406
+ key={choice.selector.start}
1407
+ label={gt("Occurrence {index} of {count}", {
1408
+ index: choice.index + 1,
1409
+ count: choice.count,
1410
+ })}
1411
+ description={`${choice.selector.prefix}${choice.selector.text}${choice.selector.suffix}`}
1412
+ onPress={() => cite(choice)}
1413
+ />
1414
+ ))}
1415
+ </ListSection>
1416
+ </ScrollView>
1417
+ </Sheet>
1418
+ ) : null}
1419
+ </>
1420
);
1421
});
1422
1423
// Folds split first, so an artifact card inside a fold stays inside it.
1424
function AssistantMarkdownBlocks(props: {
1425
readonly markdown: string;
1426
+ readonly citationPath?: string;
1427
+ readonly onCiteText?: (text: string, path: string) => void;
1428
/** The reply's reference definitions, passed down by the enclosing fold. */
1429
readonly definitions?: ReadonlyArray<string> | undefined;
1430
readonly markdownStyles: MarkdownStyleSet;
@@ -1370,7 +1449,7 @@ function AssistantMarkdownBlocks(props: {
1449
definitions: props.definitions ?? (whole ? [] : markdownReferenceDefinitions(props.markdown)),
1450
};
1451
}, [m, props.markdown, props.definitions]);
1373
- return blocks.map((block) => {
1452
+ return blocks.map((block, blockIndex) => {
1453
if (block.kind === "details") {
1454
return (
1455
<MarkdownDetailsFold
@@ -1378,11 +1457,16 @@ function AssistantMarkdownBlocks(props: {
1457
summary={block.summary}
1458
initiallyOpen={block.open}
1459
>
1381
- <AssistantMarkdownBlocks {...props} markdown={block.body} definitions={definitions} />
1460
+ <AssistantMarkdownBlocks
1461
+ {...props}
1462
+ markdown={block.body}
1463
+ definitions={definitions}
1464
+ citationPath={`${props.citationPath ?? ""}${blockIndex}/`}
1465
+ />
1466
</MarkdownDetailsFold>
1467
);
1468
}
1385
- return block.segments.map((segment) => {
1469
+ return block.segments.map((segment, segmentIndex) => {
1470
const offset = block.sourceOffset + segment.sourceOffset;
1471
if (segment.kind === "artifact-template") {
1472
return (
@@ -1403,6 +1487,15 @@ function AssistantMarkdownBlocks(props: {
1487
skills={props.skills}
1488
models={props.models}
1489
textStyle={props.markdownStyles.nativeTextStyle}
1490
+ onCiteText={
1491
+ props.onCiteText
1492
+ ? (text) =>
1493
+ props.onCiteText?.(
1494
+ text,
1495
+ `${props.citationPath ?? ""}${blockIndex}:${segmentIndex}`,
1496
+ )
1497
+ : undefined
1498
+ }
1499
{...props.linkHandlers}
1500
renderImage={props.renderImage}
1501
/>
@@ -1684,7 +1777,7 @@ function ThreadAutomationMessageRow(props: {
1777
<View className="px-3.5 pb-2.5">
1778
<MarkdownImageAvailableWidthContext value={props.contentMaxWidth}>
1779
<UserMessageContent
1687
- text={renderAssistantCitationsAsText(props.text)}
1780
+ text={props.text}
1781
environmentId={props.environmentId}
1782
context={props.context}
1783
markdownStyles={props.markdownStyles}
@@ -1871,6 +1964,7 @@ function renderFeedEntry(
1964
ThreadFeedProps,
1965
| "environmentId"
1966
| "onUseArtifactTemplate"
1967
+ | "onCiteAssistantText"
1968
| "skills"
1969
| "dispatchingMessageId"
1970
| "onEditPendingMessage"
@@ -2164,7 +2258,7 @@ function renderFeedEntry(
2258
const { message } = entry;
2259
const isUser = message.role === "user";
2260
const presentation = resolveUserMessagePresentation(message);
2167
- const renderedText = renderAssistantCitationsAsText(presentation.text);
2261
+ const renderedText = presentation.text;
2262
const styles = isUser ? markdownStyles.user : markdownStyles.assistant;
2263
const timestampLabel = props.formatMessageTime(isUser ? message.createdAt : message.updatedAt);
2264
const attachments = message.attachments ?? [];
@@ -2570,6 +2664,8 @@ function renderFeedEntry(
2664
<AssistantMarkdownContent
2665
markdown={renderedText}
2666
environmentId={props.environmentId}
2667
+ citationSource={{ threadId: props.threadId, messageId: message.id }}
2668
+ onCiteAssistantText={props.onCiteAssistantText}
2669
markdownStyles={styles}
2670
linkHandlers={props.markdownLinkHandlers}
2671
reply={message.projectedItem}
@@ -3646,6 +3742,7 @@ export const ThreadFeed = memo(function ThreadFeed(props: ThreadFeedProps) {
3742
setupDetailsOpen,
3743
disclosureLayout,
3744
reduceMotion,
3745
+ onCiteAssistantText: props.onCiteAssistantText,
3746
formatMessageTime,
3747
worktreeSetup: props.worktreeSetup,
3748
preparingWorktree: props.preparingWorktree,
@@ -4117,6 +4214,7 @@ export const ThreadFeed = memo(function ThreadFeed(props: ThreadFeedProps) {
4214
onOpenSetupDetails: openSetupDetails,
4215
onEditPendingMessage: props.onEditPendingMessage,
4216
onUseArtifactTemplate: props.onUseArtifactTemplate,
4217
+ onCiteAssistantText: props.onCiteAssistantText,
4218
threadId: props.threadId,
4219
copiedRowId,
4220
expandedWorkRows,
apps/mobile/src/i18n/translations/de.json
+22
-2
@@ -1237,6 +1237,14 @@
1237
"6df89a3609273ddf": "Zur Startseite",
1238
"ca91bde751481f6e": "Route nicht gefunden",
1239
"fa7ad42d8043440e": "Zur Startseite",
1240
+ "67e94b9fb8ee633b": "Quote",
1241
+ "90b2fa60b4cd0c15": "Kommentar",
1242
+ "60f8d5f18d14777e": "Comment on quote",
1243
+ "b9185b31f8d03aaa": "Add an optional comment…",
1244
+ "c59ddf9a3543013f": "Go to message",
1245
+ "58d429970e815c66": "Copy quote",
1246
+ "200acb0e96f98096": "Aus Entwurf entfernen",
1247
+ "cf063d4a1ffd5c6e": "This comment makes the message too long to send. Shorten it to save and close.",
1248
"9d1893839b7b4881": "Dev",
1249
"ae2263d9d6e71fd8": "Vorschau",
1250
"525f2b92a20a9707": "Beta",
@@ -1262,7 +1270,6 @@
1270
"fb28c2c6667398c7": "gemergt",
1271
"8c5799964db00630": "Seite",
1272
"bf14b3522e13a2c3": "URL",
1265
- "90b2fa60b4cd0c15": "Kommentar",
1273
"669b9d73d58ea020": "Auswahl",
1274
"6345ddd2e293ddd5": "Angeforderte Änderungen",
1275
"74e6003622876943": "Element",
@@ -1282,7 +1289,6 @@
1289
"eca94e6557931eae": "Versuch es erneut, wenn eine Verbindung besteht.",
1290
"be3fcbc1324d5f38": "{term, select, mr {Merge Request öffnen} cr {Änderungsanfrage öffnen} other {Pull Request öffnen}}",
1291
"19f953915a468edd": "Anhang öffnen",
1285
- "200acb0e96f98096": "Aus Entwurf entfernen",
1292
"13559139cab80bd6": [
1293
"Zeilen ",
1294
{
@@ -1306,6 +1312,8 @@
1312
"8fce5e0d1adf9939": "Ein Teil des Kontexts ist nicht verfügbar",
1313
"c80fb12238256d0d": "Diese Referenzen sind als nicht verfügbar markiert.",
1314
"d3fdcfa142649a36": "Versuch erneut zu kopieren.",
1315
+ "71369ce364d8ed08": "Could not update quote",
1316
+ "5f794b9980f91c26": "This comment would make the message too long to send. Shorten the comment or draft.",
1317
"b9cf50b7e7b1bc54": "Kontext wird kopiert…",
1318
"bda161176d64ec51": "Modell wählen",
1319
"54a5cee284438dd6": "Modell- und Reasoning-Einstellungen",
@@ -1465,6 +1473,7 @@
1473
"9f1b29c948772f0f": "Link öffnen",
1474
"258d16c1554b734c": "Link kopieren",
1475
"d7dc565616d13a5c": "Link teilen",
1476
+ "51244cd196696a00": "Cite",
1477
"6cdca065884f77f2": "Kopieren",
1478
"0165ef55eb6c8a99": "Als Markdown kopieren",
1479
"7c1923203049d602": "Code kopieren",
@@ -1482,6 +1491,8 @@
1491
"v": "v"
1492
}
1493
],
1494
+ "ede9a884a11b7972": "Assistant quote",
1495
+ "f563a55ee229090e": "Open quote",
1496
"7b30d976b8508ddf": "Nachricht senden",
1497
"40c503999bce960e": "Neue Aufgabe",
1498
"2225f6bda46f4cc6": "Tastatur ausblenden",
@@ -4330,6 +4341,8 @@
4341
"cebceafe7ddc7d5d": "Feedback zur Genehmigung",
4342
"0830bd81f19bb753": "Sende Feedback zur Genehmigung ohne Anhänge oder zusätzlichen Kontext.",
4343
"d15878f290283f53": "Nachricht konnte nicht bearbeitet werden",
4344
+ "dd426ccfb3da6826": "Could not add quote",
4345
+ "ba2b33c3082441c4": "This quote would make the message too long to send. Shorten the draft or select less text.",
4346
"188db618b91bf237": "Die Unterhaltung konnte nicht angezeigt werden",
4347
"86ba20bb0ac0e5d0": "Sende Feedback, um diese Anfrage abzulehnen",
4348
"880aa376639f0b04": "Sende eine Nachricht, um abzulehnen und den Agenten umzulenken",
@@ -4351,6 +4364,13 @@
4364
"c0e2a25e01e3236f": "{name} herunterladen",
4365
"71e7894d52a4dc83": "Vorlage verwenden",
4366
"0d2983c2dbaac338": "Vorlage {name} verwenden",
4367
+ "9c588b380359c9ac": "Quote is too long",
4368
+ "4867b752740e9a9b": "Select up to {max} characters to cite.",
4369
+ "ea59a48fb9657a5c": "Unable to locate quote",
4370
+ "9680ed7cf7c79355": "Select more surrounding text to cite its source accurately.",
4371
+ "623b6e7bc72d2688": "Choose quote source",
4372
+ "ae98d7a6f90f56f2": "This text appears more than once. Choose the passage you selected.",
4373
+ "a047920204bc0ec7": "Occurrence {index} of {count}",
4374
"cd03eb1b84271c02": "Agent",
4375
"0226edfcba8db105": "{label}: {summary}",
4376
"5d2859f3b56ad6cf": "Doppeltippen, um die Nachricht auszublenden.",
apps/mobile/src/i18n/translations/en.json
+22
-2
@@ -1237,6 +1237,14 @@
1237
"6df89a3609273ddf": "Return home",
1238
"ca91bde751481f6e": "Route not found",
1239
"fa7ad42d8043440e": "Return home",
1240
+ "67e94b9fb8ee633b": "Quote",
1241
+ "90b2fa60b4cd0c15": "Comment",
1242
+ "60f8d5f18d14777e": "Comment on quote",
1243
+ "b9185b31f8d03aaa": "Add an optional comment…",
1244
+ "c59ddf9a3543013f": "Go to message",
1245
+ "58d429970e815c66": "Copy quote",
1246
+ "200acb0e96f98096": "Remove from draft",
1247
+ "cf063d4a1ffd5c6e": "This comment makes the message too long to send. Shorten it to save and close.",
1248
"9d1893839b7b4881": "Dev",
1249
"ae2263d9d6e71fd8": "Preview",
1250
"525f2b92a20a9707": "Beta",
@@ -1262,7 +1270,6 @@
1270
"fb28c2c6667398c7": "merged",
1271
"8c5799964db00630": "Page",
1272
"bf14b3522e13a2c3": "URL",
1265
- "90b2fa60b4cd0c15": "Comment",
1273
"669b9d73d58ea020": "Selection",
1274
"6345ddd2e293ddd5": "Requested changes",
1275
"74e6003622876943": "Element",
@@ -1282,7 +1289,6 @@
1289
"eca94e6557931eae": "Try again when connected.",
1290
"be3fcbc1324d5f38": "Open {term, select, mr {merge request} cr {change request} other {pull request}}",
1291
"19f953915a468edd": "Open attachment",
1285
- "200acb0e96f98096": "Remove from draft",
1292
"13559139cab80bd6": [
1293
"Lines ",
1294
{
@@ -1306,6 +1312,8 @@
1312
"8fce5e0d1adf9939": "Some context is unavailable",
1313
"c80fb12238256d0d": "Those references are marked unavailable.",
1314
"d3fdcfa142649a36": "Try copying again.",
1315
+ "71369ce364d8ed08": "Could not update quote",
1316
+ "5f794b9980f91c26": "This comment would make the message too long to send. Shorten the comment or draft.",
1317
"b9cf50b7e7b1bc54": "Copying context…",
1318
"bda161176d64ec51": "Choose model",
1319
"54a5cee284438dd6": "Model and reasoning settings",
@@ -1465,6 +1473,7 @@
1473
"9f1b29c948772f0f": "Open link",
1474
"258d16c1554b734c": "Copy link",
1475
"d7dc565616d13a5c": "Share link",
1476
+ "51244cd196696a00": "Cite",
1477
"6cdca065884f77f2": "Copy",
1478
"0165ef55eb6c8a99": "Copy as Markdown",
1479
"7c1923203049d602": "Copy code",
@@ -1482,6 +1491,8 @@
1491
"v": "v"
1492
}
1493
],
1494
+ "ede9a884a11b7972": "Assistant quote",
1495
+ "f563a55ee229090e": "Open quote",
1496
"7b30d976b8508ddf": "Send Message",
1497
"40c503999bce960e": "New task",
1498
"2225f6bda46f4cc6": "Dismiss keyboard",
@@ -4331,6 +4342,8 @@
4342
"cebceafe7ddc7d5d": "Approval feedback",
4343
"0830bd81f19bb753": "Send approval feedback without attachments or added context.",
4344
"d15878f290283f53": "Could not edit message",
4345
+ "dd426ccfb3da6826": "Could not add quote",
4346
+ "ba2b33c3082441c4": "This quote would make the message too long to send. Shorten the draft or select less text.",
4347
"188db618b91bf237": "The conversation couldn't be displayed",
4348
"86ba20bb0ac0e5d0": "Send feedback to decline this request",
4349
"880aa376639f0b04": "Send a message to decline and redirect the agent",
@@ -4352,6 +4365,13 @@
4365
"c0e2a25e01e3236f": "Download {name}",
4366
"71e7894d52a4dc83": "Use template",
4367
"0d2983c2dbaac338": "Use {name} template",
4368
+ "9c588b380359c9ac": "Quote is too long",
4369
+ "4867b752740e9a9b": "Select up to {max} characters to cite.",
4370
+ "ea59a48fb9657a5c": "Unable to locate quote",
4371
+ "9680ed7cf7c79355": "Select more surrounding text to cite its source accurately.",
4372
+ "623b6e7bc72d2688": "Choose quote source",
4373
+ "ae98d7a6f90f56f2": "This text appears more than once. Choose the passage you selected.",
4374
+ "a047920204bc0ec7": "Occurrence {index} of {count}",
4375
"cd03eb1b84271c02": "Agent",
4376
"0226edfcba8db105": "{label}: {summary}",
4377
"5d2859f3b56ad6cf": "Double tap to hide the message.",
apps/mobile/src/i18n/translations/es.json
+22
-2
@@ -1237,6 +1237,14 @@
1237
"6df89a3609273ddf": "Volver al inicio",
1238
"ca91bde751481f6e": "Ruta no encontrada",
1239
"fa7ad42d8043440e": "Volver al inicio",
1240
+ "67e94b9fb8ee633b": "Quote",
1241
+ "90b2fa60b4cd0c15": "Comentario",
1242
+ "60f8d5f18d14777e": "Comment on quote",
1243
+ "b9185b31f8d03aaa": "Add an optional comment…",
1244
+ "c59ddf9a3543013f": "Go to message",
1245
+ "58d429970e815c66": "Copy quote",
1246
+ "200acb0e96f98096": "Quitar del borrador",
1247
+ "cf063d4a1ffd5c6e": "This comment makes the message too long to send. Shorten it to save and close.",
1248
"9d1893839b7b4881": "Dev",
1249
"ae2263d9d6e71fd8": "Vista previa",
1250
"525f2b92a20a9707": "Beta",
@@ -1262,7 +1270,6 @@
1270
"fb28c2c6667398c7": "fusionada",
1271
"8c5799964db00630": "Página",
1272
"bf14b3522e13a2c3": "URL",
1265
- "90b2fa60b4cd0c15": "Comentario",
1273
"669b9d73d58ea020": "Selección",
1274
"6345ddd2e293ddd5": "Cambios solicitados",
1275
"74e6003622876943": "Elemento",
@@ -1282,7 +1289,6 @@
1289
"eca94e6557931eae": "Inténtalo de nuevo cuando haya conexión.",
1290
"be3fcbc1324d5f38": "Abrir la {term, select, mr {merge request} cr {solicitud de cambios} other {pull request}}",
1291
"19f953915a468edd": "Abrir adjunto",
1285
- "200acb0e96f98096": "Quitar del borrador",
1292
"13559139cab80bd6": [
1293
"Líneas ",
1294
{
@@ -1306,6 +1312,8 @@
1312
"8fce5e0d1adf9939": "Parte del contexto no está disponible",
1313
"c80fb12238256d0d": "Esas referencias están marcadas como no disponibles.",
1314
"d3fdcfa142649a36": "Prueba a copiar de nuevo.",
1315
+ "71369ce364d8ed08": "Could not update quote",
1316
+ "5f794b9980f91c26": "This comment would make the message too long to send. Shorten the comment or draft.",
1317
"b9cf50b7e7b1bc54": "Copiando contexto…",
1318
"bda161176d64ec51": "Elegir modelo",
1319
"54a5cee284438dd6": "Ajustes del modelo y del razonamiento",
@@ -1465,6 +1473,7 @@
1473
"9f1b29c948772f0f": "Abrir enlace",
1474
"258d16c1554b734c": "Copiar enlace",
1475
"d7dc565616d13a5c": "Compartir enlace",
1476
+ "51244cd196696a00": "Cite",
1477
"6cdca065884f77f2": "Copiar",
1478
"0165ef55eb6c8a99": "Copiar como Markdown",
1479
"7c1923203049d602": "Copiar código",
@@ -1482,6 +1491,8 @@
1491
"v": "v"
1492
}
1493
],
1494
+ "ede9a884a11b7972": "Assistant quote",
1495
+ "f563a55ee229090e": "Open quote",
1496
"7b30d976b8508ddf": "Enviar mensaje",
1497
"40c503999bce960e": "Nueva tarea",
1498
"2225f6bda46f4cc6": "Ocultar teclado",
@@ -4323,6 +4334,8 @@
4334
"cebceafe7ddc7d5d": "Comentarios de la aprobación",
4335
"0830bd81f19bb753": "Envía los comentarios de aprobación sin adjuntos ni contexto añadido.",
4336
"d15878f290283f53": "No se pudo editar el mensaje",
4337
+ "dd426ccfb3da6826": "Could not add quote",
4338
+ "ba2b33c3082441c4": "This quote would make the message too long to send. Shorten the draft or select less text.",
4339
"188db618b91bf237": "No se pudo mostrar la conversación",
4340
"86ba20bb0ac0e5d0": "Envía comentarios para rechazar esta solicitud",
4341
"880aa376639f0b04": "Envía un mensaje para rechazar y redirigir al agente",
@@ -4344,6 +4357,13 @@
4357
"c0e2a25e01e3236f": "Descargar {name}",
4358
"71e7894d52a4dc83": "Usar plantilla",
4359
"0d2983c2dbaac338": "Usar la plantilla {name}",
4360
+ "9c588b380359c9ac": "Quote is too long",
4361
+ "4867b752740e9a9b": "Select up to {max} characters to cite.",
4362
+ "ea59a48fb9657a5c": "Unable to locate quote",
4363
+ "9680ed7cf7c79355": "Select more surrounding text to cite its source accurately.",
4364
+ "623b6e7bc72d2688": "Choose quote source",
4365
+ "ae98d7a6f90f56f2": "This text appears more than once. Choose the passage you selected.",
4366
+ "a047920204bc0ec7": "Occurrence {index} of {count}",
4367
"cd03eb1b84271c02": "Agente",
4368
"0226edfcba8db105": "{label}: {summary}",
4369
"5d2859f3b56ad6cf": "Toca dos veces para ocultar el mensaje.",
apps/mobile/src/i18n/translations/fr.json
+22
-2
@@ -1237,6 +1237,14 @@
1237
"6df89a3609273ddf": "Retour à l’accueil",
1238
"ca91bde751481f6e": "Route introuvable",
1239
"fa7ad42d8043440e": "Retour à l’accueil",
1240
+ "67e94b9fb8ee633b": "Quote",
1241
+ "90b2fa60b4cd0c15": "Commentaire",
1242
+ "60f8d5f18d14777e": "Comment on quote",
1243
+ "b9185b31f8d03aaa": "Add an optional comment…",
1244
+ "c59ddf9a3543013f": "Go to message",
1245
+ "58d429970e815c66": "Copy quote",
1246
+ "200acb0e96f98096": "Retirer du brouillon",
1247
+ "cf063d4a1ffd5c6e": "This comment makes the message too long to send. Shorten it to save and close.",
1248
"9d1893839b7b4881": "Dev",
1249
"ae2263d9d6e71fd8": "Preview",
1250
"525f2b92a20a9707": "Bêta",
@@ -1262,7 +1270,6 @@
1270
"fb28c2c6667398c7": "fusionnée",
1271
"8c5799964db00630": "Page",
1272
"bf14b3522e13a2c3": "URL",
1265
- "90b2fa60b4cd0c15": "Commentaire",
1273
"669b9d73d58ea020": "Sélection",
1274
"6345ddd2e293ddd5": "Modifications demandées",
1275
"74e6003622876943": "Élément",
@@ -1282,7 +1289,6 @@
1289
"eca94e6557931eae": "Réessayez une fois connecté.",
1290
"be3fcbc1324d5f38": "Ouvrir la {term, select, mr {merge request} cr {demande de modification} other {pull request}}",
1291
"19f953915a468edd": "Ouvrir la pièce jointe",
1285
- "200acb0e96f98096": "Retirer du brouillon",
1292
"13559139cab80bd6": [
1293
"Lignes ",
1294
{
@@ -1306,6 +1312,8 @@
1312
"8fce5e0d1adf9939": "Une partie du contexte est indisponible",
1313
"c80fb12238256d0d": "Ces références sont marquées comme indisponibles.",
1314
"d3fdcfa142649a36": "Essayez de copier à nouveau.",
1315
+ "71369ce364d8ed08": "Could not update quote",
1316
+ "5f794b9980f91c26": "This comment would make the message too long to send. Shorten the comment or draft.",
1317
"b9cf50b7e7b1bc54": "Copie du contexte…",
1318
"bda161176d64ec51": "Choisir un modèle",
1319
"54a5cee284438dd6": "Paramètres du modèle et du raisonnement",
@@ -1465,6 +1473,7 @@
1473
"9f1b29c948772f0f": "Ouvrir le lien",
1474
"258d16c1554b734c": "Copier le lien",
1475
"d7dc565616d13a5c": "Partager le lien",
1476
+ "51244cd196696a00": "Cite",
1477
"6cdca065884f77f2": "Copier",
1478
"0165ef55eb6c8a99": "Copier en Markdown",
1479
"7c1923203049d602": "Copier le code",
@@ -1482,6 +1491,8 @@
1491
"v": "v"
1492
}
1493
],
1494
+ "ede9a884a11b7972": "Assistant quote",
1495
+ "f563a55ee229090e": "Open quote",
1496
"7b30d976b8508ddf": "Envoyer le message",
1497
"40c503999bce960e": "Nouvelle tâche",
1498
"2225f6bda46f4cc6": "Masquer le clavier",
@@ -4324,6 +4335,8 @@
4335
"cebceafe7ddc7d5d": "Retour sur l’approbation",
4336
"0830bd81f19bb753": "Envoyez votre réponse à l’approbation sans pièces jointes ni contexte ajouté.",
4337
"d15878f290283f53": "Impossible de modifier le message",
4338
+ "dd426ccfb3da6826": "Could not add quote",
4339
+ "ba2b33c3082441c4": "This quote would make the message too long to send. Shorten the draft or select less text.",
4340
"188db618b91bf237": "La conversation n’a pas pu être affichée",
4341
"86ba20bb0ac0e5d0": "Envoyez un commentaire pour refuser cette demande",
4342
"880aa376639f0b04": "Envoyez un message pour refuser et réorienter l’agent",
@@ -4345,6 +4358,13 @@
4358
"c0e2a25e01e3236f": "Télécharger {name}",
4359
"71e7894d52a4dc83": "Utiliser le modèle",
4360
"0d2983c2dbaac338": "Utiliser le modèle {name}",
4361
+ "9c588b380359c9ac": "Quote is too long",
4362
+ "4867b752740e9a9b": "Select up to {max} characters to cite.",
4363
+ "ea59a48fb9657a5c": "Unable to locate quote",
4364
+ "9680ed7cf7c79355": "Select more surrounding text to cite its source accurately.",
4365
+ "623b6e7bc72d2688": "Choose quote source",
4366
+ "ae98d7a6f90f56f2": "This text appears more than once. Choose the passage you selected.",
4367
+ "a047920204bc0ec7": "Occurrence {index} of {count}",
4368
"cd03eb1b84271c02": "Agent",
4369
"0226edfcba8db105": "{label} : {summary}",
4370
"5d2859f3b56ad6cf": "Touchez deux fois pour masquer le message.",
apps/mobile/src/i18n/translations/ja.json
+22
-2
@@ -1237,6 +1237,14 @@
1237
"6df89a3609273ddf": "ホームに戻る",
1238
"ca91bde751481f6e": "ルートが見つかりません",
1239
"fa7ad42d8043440e": "ホームに戻る",
1240
+ "67e94b9fb8ee633b": "Quote",
1241
+ "90b2fa60b4cd0c15": "コメント",
1242
+ "60f8d5f18d14777e": "Comment on quote",
1243
+ "b9185b31f8d03aaa": "Add an optional comment…",
1244
+ "c59ddf9a3543013f": "Go to message",
1245
+ "58d429970e815c66": "Copy quote",
1246
+ "200acb0e96f98096": "下書きから削除",
1247
+ "cf063d4a1ffd5c6e": "This comment makes the message too long to send. Shorten it to save and close.",
1248
"9d1893839b7b4881": "Dev",
1249
"ae2263d9d6e71fd8": "プレビュー",
1250
"525f2b92a20a9707": "ベータ",
@@ -1262,7 +1270,6 @@
1270
"fb28c2c6667398c7": "マージ済み",
1271
"8c5799964db00630": "ページ",
1272
"bf14b3522e13a2c3": "URL",
1265
- "90b2fa60b4cd0c15": "コメント",
1273
"669b9d73d58ea020": "選択範囲",
1274
"6345ddd2e293ddd5": "変更をリクエスト済み",
1275
"74e6003622876943": "要素",
@@ -1282,7 +1289,6 @@
1289
"eca94e6557931eae": "接続されたらもう一度お試しください。",
1290
"be3fcbc1324d5f38": "{term, select, mr {マージリクエストを開く} cr {変更リクエストを開く} other {プルリクエストを開く}}",
1291
"19f953915a468edd": "添付ファイルを開く",
1285
- "200acb0e96f98096": "下書きから削除",
1292
"13559139cab80bd6": [
1293
{
1294
"i": 1,
@@ -1306,6 +1312,8 @@
1312
"8fce5e0d1adf9939": "一部のコンテキストを利用できません",
1313
"c80fb12238256d0d": "それらの参照は利用不可として表示されます。",
1314
"d3fdcfa142649a36": "もう一度コピーしてください。",
1315
+ "71369ce364d8ed08": "Could not update quote",
1316
+ "5f794b9980f91c26": "This comment would make the message too long to send. Shorten the comment or draft.",
1317
"b9cf50b7e7b1bc54": "コンテキストをコピーしています…",
1318
"bda161176d64ec51": "モデルを選択",
1319
"54a5cee284438dd6": "モデルと推論の設定",
@@ -1465,6 +1473,7 @@
1473
"9f1b29c948772f0f": "リンクを開く",
1474
"258d16c1554b734c": "リンクをコピー",
1475
"d7dc565616d13a5c": "リンクを共有",
1476
+ "51244cd196696a00": "Cite",
1477
"6cdca065884f77f2": "コピー",
1478
"0165ef55eb6c8a99": "Markdown としてコピー",
1479
"7c1923203049d602": "コードをコピー",
@@ -1482,6 +1491,8 @@
1491
"v": "v"
1492
}
1493
],
1494
+ "ede9a884a11b7972": "Assistant quote",
1495
+ "f563a55ee229090e": "Open quote",
1496
"7b30d976b8508ddf": "メッセージを送信",
1497
"40c503999bce960e": "新しいタスク",
1498
"2225f6bda46f4cc6": "キーボードを閉じる",
@@ -4305,6 +4316,8 @@
4316
"cebceafe7ddc7d5d": "承認へのフィードバック",
4317
"0830bd81f19bb753": "承認のフィードバックは、添付ファイルや追加のコンテキストなしで送信してください。",
4318
"d15878f290283f53": "メッセージを編集できませんでした",
4319
+ "dd426ccfb3da6826": "Could not add quote",
4320
+ "ba2b33c3082441c4": "This quote would make the message too long to send. Shorten the draft or select less text.",
4321
"188db618b91bf237": "会話を表示できませんでした",
4322
"86ba20bb0ac0e5d0": "このリクエストを拒否するにはフィードバックを送信してください",
4323
"880aa376639f0b04": "メッセージを送信して拒否し、エージェントに別の指示を出します",
@@ -4326,6 +4339,13 @@
4339
"c0e2a25e01e3236f": "{name} をダウンロード",
4340
"71e7894d52a4dc83": "テンプレートを使用",
4341
"0d2983c2dbaac338": "{name} テンプレートを使用",
4342
+ "9c588b380359c9ac": "Quote is too long",
4343
+ "4867b752740e9a9b": "Select up to {max} characters to cite.",
4344
+ "ea59a48fb9657a5c": "Unable to locate quote",
4345
+ "9680ed7cf7c79355": "Select more surrounding text to cite its source accurately.",
4346
+ "623b6e7bc72d2688": "Choose quote source",
4347
+ "ae98d7a6f90f56f2": "This text appears more than once. Choose the passage you selected.",
4348
+ "a047920204bc0ec7": "Occurrence {index} of {count}",
4349
"cd03eb1b84271c02": "エージェント",
4350
"0226edfcba8db105": "{label}: {summary}",
4351
"5d2859f3b56ad6cf": "ダブルタップでメッセージを非表示にします。",
apps/mobile/src/i18n/translations/ko.json
+22
-2
@@ -1237,6 +1237,14 @@
1237
"6df89a3609273ddf": "홈으로 돌아가기",
1238
"ca91bde751481f6e": "경로를 찾을 수 없음",
1239
"fa7ad42d8043440e": "홈으로 돌아가기",
1240
+ "67e94b9fb8ee633b": "Quote",
1241
+ "90b2fa60b4cd0c15": "댓글",
1242
+ "60f8d5f18d14777e": "Comment on quote",
1243
+ "b9185b31f8d03aaa": "Add an optional comment…",
1244
+ "c59ddf9a3543013f": "Go to message",
1245
+ "58d429970e815c66": "Copy quote",
1246
+ "200acb0e96f98096": "초안에서 제거",
1247
+ "cf063d4a1ffd5c6e": "This comment makes the message too long to send. Shorten it to save and close.",
1248
"9d1893839b7b4881": "Dev",
1249
"ae2263d9d6e71fd8": "Preview",
1250
"525f2b92a20a9707": "Beta",
@@ -1262,7 +1270,6 @@
1270
"fb28c2c6667398c7": "병합됨",
1271
"8c5799964db00630": "페이지",
1272
"bf14b3522e13a2c3": "URL",
1265
- "90b2fa60b4cd0c15": "댓글",
1273
"669b9d73d58ea020": "선택 영역",
1274
"6345ddd2e293ddd5": "수정 요청됨",
1275
"74e6003622876943": "요소",
@@ -1282,7 +1289,6 @@
1289
"eca94e6557931eae": "연결되면 다시 시도하세요.",
1290
"be3fcbc1324d5f38": "{term, select, mr {병합 요청} cr {변경 요청} other {풀 리퀘스트}} 열기",
1291
"19f953915a468edd": "첨부 파일 열기",
1285
- "200acb0e96f98096": "초안에서 제거",
1292
"13559139cab80bd6": [
1293
{
1294
"i": 1,
@@ -1306,6 +1312,8 @@
1312
"8fce5e0d1adf9939": "일부 컨텍스트를 사용할 수 없습니다",
1313
"c80fb12238256d0d": "해당 참조는 사용할 수 없음으로 표시됩니다.",
1314
"d3fdcfa142649a36": "다시 복사해 보세요.",
1315
+ "71369ce364d8ed08": "Could not update quote",
1316
+ "5f794b9980f91c26": "This comment would make the message too long to send. Shorten the comment or draft.",
1317
"b9cf50b7e7b1bc54": "컨텍스트 복사 중…",
1318
"bda161176d64ec51": "모델 선택",
1319
"54a5cee284438dd6": "모델 및 추론 설정",
@@ -1465,6 +1473,7 @@
1473
"9f1b29c948772f0f": "링크 열기",
1474
"258d16c1554b734c": "링크 복사",
1475
"d7dc565616d13a5c": "링크 공유",
1476
+ "51244cd196696a00": "Cite",
1477
"6cdca065884f77f2": "복사",
1478
"0165ef55eb6c8a99": "Markdown으로 복사",
1479
"7c1923203049d602": "코드 복사",
@@ -1482,6 +1491,8 @@
1491
"v": "v"
1492
}
1493
],
1494
+ "ede9a884a11b7972": "Assistant quote",
1495
+ "f563a55ee229090e": "Open quote",
1496
"7b30d976b8508ddf": "메시지 보내기",
1497
"40c503999bce960e": "새 작업",
1498
"2225f6bda46f4cc6": "키보드 닫기",
@@ -4310,6 +4321,8 @@
4321
"cebceafe7ddc7d5d": "승인 피드백",
4322
"0830bd81f19bb753": "첨부 파일이나 추가 컨텍스트 없이 승인 피드백을 보내세요.",
4323
"d15878f290283f53": "메시지를 편집할 수 없습니다",
4324
+ "dd426ccfb3da6826": "Could not add quote",
4325
+ "ba2b33c3082441c4": "This quote would make the message too long to send. Shorten the draft or select less text.",
4326
"188db618b91bf237": "대화를 표시할 수 없습니다",
4327
"86ba20bb0ac0e5d0": "이 요청을 거부하려면 피드백을 보내세요",
4328
"880aa376639f0b04": "거부하고 에이전트의 방향을 바꾸려면 메시지를 보내세요",
@@ -4331,6 +4344,13 @@
4344
"c0e2a25e01e3236f": "{name} 다운로드",
4345
"71e7894d52a4dc83": "템플릿 사용",
4346
"0d2983c2dbaac338": "{name} 템플릿 사용",
4347
+ "9c588b380359c9ac": "Quote is too long",
4348
+ "4867b752740e9a9b": "Select up to {max} characters to cite.",
4349
+ "ea59a48fb9657a5c": "Unable to locate quote",
4350
+ "9680ed7cf7c79355": "Select more surrounding text to cite its source accurately.",
4351
+ "623b6e7bc72d2688": "Choose quote source",
4352
+ "ae98d7a6f90f56f2": "This text appears more than once. Choose the passage you selected.",
4353
+ "a047920204bc0ec7": "Occurrence {index} of {count}",
4354
"cd03eb1b84271c02": "에이전트",
4355
"0226edfcba8db105": "{label}: {summary}",
4356
"5d2859f3b56ad6cf": "두 번 탭하여 메시지를 숨깁니다.",
apps/mobile/src/i18n/translations/pt-BR.json
+22
-2
@@ -1237,6 +1237,14 @@
1237
"6df89a3609273ddf": "Voltar ao início",
1238
"ca91bde751481f6e": "Rota não encontrada",
1239
"fa7ad42d8043440e": "Voltar ao início",
1240
+ "67e94b9fb8ee633b": "Quote",
1241
+ "90b2fa60b4cd0c15": "Comentário",
1242
+ "60f8d5f18d14777e": "Comment on quote",
1243
+ "b9185b31f8d03aaa": "Add an optional comment…",
1244
+ "c59ddf9a3543013f": "Go to message",
1245
+ "58d429970e815c66": "Copy quote",
1246
+ "200acb0e96f98096": "Remover do rascunho",
1247
+ "cf063d4a1ffd5c6e": "This comment makes the message too long to send. Shorten it to save and close.",
1248
"9d1893839b7b4881": "Dev",
1249
"ae2263d9d6e71fd8": "Preview",
1250
"525f2b92a20a9707": "Beta",
@@ -1262,7 +1270,6 @@
1270
"fb28c2c6667398c7": "mesclado",
1271
"8c5799964db00630": "Página",
1272
"bf14b3522e13a2c3": "URL",
1265
- "90b2fa60b4cd0c15": "Comentário",
1273
"669b9d73d58ea020": "Seleção",
1274
"6345ddd2e293ddd5": "Alterações solicitadas",
1275
"74e6003622876943": "Elemento",
@@ -1282,7 +1289,6 @@
1289
"eca94e6557931eae": "Tente novamente quando estiver conectado.",
1290
"be3fcbc1324d5f38": "Abrir {term, select, mr {o merge request} cr {a solicitação de alteração} other {o pull request}}",
1291
"19f953915a468edd": "Abrir anexo",
1285
- "200acb0e96f98096": "Remover do rascunho",
1292
"13559139cab80bd6": [
1293
"Linhas ",
1294
{
@@ -1306,6 +1312,8 @@
1312
"8fce5e0d1adf9939": "Parte do contexto está indisponível",
1313
"c80fb12238256d0d": "Essas referências estão marcadas como indisponíveis.",
1314
"d3fdcfa142649a36": "Tente copiar novamente.",
1315
+ "71369ce364d8ed08": "Could not update quote",
1316
+ "5f794b9980f91c26": "This comment would make the message too long to send. Shorten the comment or draft.",
1317
"b9cf50b7e7b1bc54": "Copiando contexto…",
1318
"bda161176d64ec51": "Escolher modelo",
1319
"54a5cee284438dd6": "Configurações de modelo e raciocínio",
@@ -1465,6 +1473,7 @@
1473
"9f1b29c948772f0f": "Abrir link",
1474
"258d16c1554b734c": "Copiar link",
1475
"d7dc565616d13a5c": "Compartilhar link",
1476
+ "51244cd196696a00": "Cite",
1477
"6cdca065884f77f2": "Copiar",
1478
"0165ef55eb6c8a99": "Copiar como Markdown",
1479
"7c1923203049d602": "Copiar código",
@@ -1482,6 +1491,8 @@
1491
"v": "v"
1492
}
1493
],
1494
+ "ede9a884a11b7972": "Assistant quote",
1495
+ "f563a55ee229090e": "Open quote",
1496
"7b30d976b8508ddf": "Enviar mensagem",
1497
"40c503999bce960e": "Nova tarefa",
1498
"2225f6bda46f4cc6": "Ocultar teclado",
@@ -4324,6 +4335,8 @@
4335
"cebceafe7ddc7d5d": "Feedback da aprovação",
4336
"0830bd81f19bb753": "Envie o feedback da aprovação sem anexos nem contexto adicional.",
4337
"d15878f290283f53": "Não foi possível editar a mensagem",
4338
+ "dd426ccfb3da6826": "Could not add quote",
4339
+ "ba2b33c3082441c4": "This quote would make the message too long to send. Shorten the draft or select less text.",
4340
"188db618b91bf237": "Não foi possível exibir a conversa",
4341
"86ba20bb0ac0e5d0": "Envie um feedback para recusar esta solicitação",
4342
"880aa376639f0b04": "Envie uma mensagem para recusar e redirecionar o agente",
@@ -4345,6 +4358,13 @@
4358
"c0e2a25e01e3236f": "Baixar {name}",
4359
"71e7894d52a4dc83": "Usar modelo",
4360
"0d2983c2dbaac338": "Usar o template {name}",
4361
+ "9c588b380359c9ac": "Quote is too long",
4362
+ "4867b752740e9a9b": "Select up to {max} characters to cite.",
4363
+ "ea59a48fb9657a5c": "Unable to locate quote",
4364
+ "9680ed7cf7c79355": "Select more surrounding text to cite its source accurately.",
4365
+ "623b6e7bc72d2688": "Choose quote source",
4366
+ "ae98d7a6f90f56f2": "This text appears more than once. Choose the passage you selected.",
4367
+ "a047920204bc0ec7": "Occurrence {index} of {count}",
4368
"cd03eb1b84271c02": "Agente",
4369
"0226edfcba8db105": "{label}: {summary}",
4370
"5d2859f3b56ad6cf": "Toque duas vezes para ocultar a mensagem.",
apps/mobile/src/i18n/translations/ru.json
+22
-2
@@ -1237,6 +1237,14 @@
1237
"6df89a3609273ddf": "На главную",
1238
"ca91bde751481f6e": "Маршрут не найден",
1239
"fa7ad42d8043440e": "На главную",
1240
+ "67e94b9fb8ee633b": "Quote",
1241
+ "90b2fa60b4cd0c15": "Комментарий",
1242
+ "60f8d5f18d14777e": "Comment on quote",
1243
+ "b9185b31f8d03aaa": "Add an optional comment…",
1244
+ "c59ddf9a3543013f": "Go to message",
1245
+ "58d429970e815c66": "Copy quote",
1246
+ "200acb0e96f98096": "Убрать из черновика",
1247
+ "cf063d4a1ffd5c6e": "This comment makes the message too long to send. Shorten it to save and close.",
1248
"9d1893839b7b4881": "Dev",
1249
"ae2263d9d6e71fd8": "Предварительная версия",
1250
"525f2b92a20a9707": "Бета",
@@ -1262,7 +1270,6 @@
1270
"fb28c2c6667398c7": "слит",
1271
"8c5799964db00630": "Страница",
1272
"bf14b3522e13a2c3": "URL",
1265
- "90b2fa60b4cd0c15": "Комментарий",
1273
"669b9d73d58ea020": "Выделение",
1274
"6345ddd2e293ddd5": "Запрошены изменения",
1275
"74e6003622876943": "Элемент",
@@ -1282,7 +1289,6 @@
1289
"eca94e6557931eae": "Попробуйте ещё раз после подключения.",
1290
"be3fcbc1324d5f38": "{term, select, mr {Открыть мерж-реквест} cr {Открыть запрос на изменение} other {Открыть пул-реквест}}",
1291
"19f953915a468edd": "Открыть вложение",
1285
- "200acb0e96f98096": "Убрать из черновика",
1292
"13559139cab80bd6": [
1293
"Строки ",
1294
{
@@ -1306,6 +1312,8 @@
1312
"8fce5e0d1adf9939": "Часть контекста недоступна",
1313
"c80fb12238256d0d": "Эти ссылки помечены как недоступные.",
1314
"d3fdcfa142649a36": "Попробуйте скопировать снова.",
1315
+ "71369ce364d8ed08": "Could not update quote",
1316
+ "5f794b9980f91c26": "This comment would make the message too long to send. Shorten the comment or draft.",
1317
"b9cf50b7e7b1bc54": "Копирование контекста…",
1318
"bda161176d64ec51": "Выберите модель",
1319
"54a5cee284438dd6": "Настройки модели и рассуждений",
@@ -1465,6 +1473,7 @@
1473
"9f1b29c948772f0f": "Открыть ссылку",
1474
"258d16c1554b734c": "Копировать ссылку",
1475
"d7dc565616d13a5c": "Поделиться ссылкой",
1476
+ "51244cd196696a00": "Cite",
1477
"6cdca065884f77f2": "Копировать",
1478
"0165ef55eb6c8a99": "Копировать как Markdown",
1479
"7c1923203049d602": "Копировать код",
@@ -1482,6 +1491,8 @@
1491
"v": "v"
1492
}
1493
],
1494
+ "ede9a884a11b7972": "Assistant quote",
1495
+ "f563a55ee229090e": "Open quote",
1496
"7b30d976b8508ddf": "Отправить сообщение",
1497
"40c503999bce960e": "Новая задача",
1498
"2225f6bda46f4cc6": "Скрыть клавиатуру",
@@ -4402,6 +4413,8 @@
4413
"cebceafe7ddc7d5d": "Отзыв на подтверждение",
4414
"0830bd81f19bb753": "Отправьте отзыв на подтверждение без вложений и добавленного контекста.",
4415
"d15878f290283f53": "Не удалось изменить сообщение",
4416
+ "dd426ccfb3da6826": "Could not add quote",
4417
+ "ba2b33c3082441c4": "This quote would make the message too long to send. Shorten the draft or select less text.",
4418
"188db618b91bf237": "Не удалось отобразить беседу",
4419
"86ba20bb0ac0e5d0": "Отправьте отзыв, чтобы отклонить этот запрос",
4420
"880aa376639f0b04": "Отправьте сообщение, чтобы отклонить запрос и перенаправить агента",
@@ -4423,6 +4436,13 @@
4436
"c0e2a25e01e3236f": "Скачать {name}",
4437
"71e7894d52a4dc83": "Использовать шаблон",
4438
"0d2983c2dbaac338": "Использовать шаблон {name}",
4439
+ "9c588b380359c9ac": "Quote is too long",
4440
+ "4867b752740e9a9b": "Select up to {max} characters to cite.",
4441
+ "ea59a48fb9657a5c": "Unable to locate quote",
4442
+ "9680ed7cf7c79355": "Select more surrounding text to cite its source accurately.",
4443
+ "623b6e7bc72d2688": "Choose quote source",
4444
+ "ae98d7a6f90f56f2": "This text appears more than once. Choose the passage you selected.",
4445
+ "a047920204bc0ec7": "Occurrence {index} of {count}",
4446
"cd03eb1b84271c02": "Агент",
4447
"0226edfcba8db105": "{label}: {summary}",
4448
"5d2859f3b56ad6cf": "Дважды нажмите, чтобы скрыть сообщение.",
apps/mobile/src/i18n/translations/sv.json
+22
-2
@@ -1237,6 +1237,14 @@
1237
"6df89a3609273ddf": "Gå till start",
1238
"ca91bde751481f6e": "Sidan hittades inte",
1239
"fa7ad42d8043440e": "Gå till start",
1240
+ "67e94b9fb8ee633b": "Quote",
1241
+ "90b2fa60b4cd0c15": "Kommentar",
1242
+ "60f8d5f18d14777e": "Comment on quote",
1243
+ "b9185b31f8d03aaa": "Add an optional comment…",
1244
+ "c59ddf9a3543013f": "Go to message",
1245
+ "58d429970e815c66": "Copy quote",
1246
+ "200acb0e96f98096": "Ta bort från utkastet",
1247
+ "cf063d4a1ffd5c6e": "This comment makes the message too long to send. Shorten it to save and close.",
1248
"9d1893839b7b4881": "Dev",
1249
"ae2263d9d6e71fd8": "Förhandsversion",
1250
"525f2b92a20a9707": "Beta",
@@ -1262,7 +1270,6 @@
1270
"fb28c2c6667398c7": "mergad",
1271
"8c5799964db00630": "Sida",
1272
"bf14b3522e13a2c3": "URL",
1265
- "90b2fa60b4cd0c15": "Kommentar",
1273
"669b9d73d58ea020": "Markering",
1274
"6345ddd2e293ddd5": "Begärda ändringar",
1275
"74e6003622876943": "Element",
@@ -1282,7 +1289,6 @@
1289
"eca94e6557931eae": "Försök igen när du är ansluten.",
1290
"be3fcbc1324d5f38": "Öppna {term, select, mr {merge request} cr {ändringsbegäran} other {pull request}}",
1291
"19f953915a468edd": "Öppna bilaga",
1285
- "200acb0e96f98096": "Ta bort från utkastet",
1292
"13559139cab80bd6": [
1293
"Rad ",
1294
{
@@ -1306,6 +1312,8 @@
1312
"8fce5e0d1adf9939": "Viss kontext är inte tillgänglig",
1313
"c80fb12238256d0d": "De referenserna är markerade som inte tillgängliga.",
1314
"d3fdcfa142649a36": "Försök kopiera igen.",
1315
+ "71369ce364d8ed08": "Could not update quote",
1316
+ "5f794b9980f91c26": "This comment would make the message too long to send. Shorten the comment or draft.",
1317
"b9cf50b7e7b1bc54": "Kopierar kontext…",
1318
"bda161176d64ec51": "Välj modell",
1319
"54a5cee284438dd6": "Inställningar för modell och resonerande",
@@ -1465,6 +1473,7 @@
1473
"9f1b29c948772f0f": "Öppna länk",
1474
"258d16c1554b734c": "Kopiera länk",
1475
"d7dc565616d13a5c": "Dela länk",
1476
+ "51244cd196696a00": "Cite",
1477
"6cdca065884f77f2": "Kopiera",
1478
"0165ef55eb6c8a99": "Kopiera som Markdown",
1479
"7c1923203049d602": "Kopiera kod",
@@ -1482,6 +1491,8 @@
1491
"v": "v"
1492
}
1493
],
1494
+ "ede9a884a11b7972": "Assistant quote",
1495
+ "f563a55ee229090e": "Open quote",
1496
"7b30d976b8508ddf": "Skicka meddelande",
1497
"40c503999bce960e": "Ny uppgift",
1498
"2225f6bda46f4cc6": "Stäng tangentbordet",
@@ -4330,6 +4341,8 @@
4341
"cebceafe7ddc7d5d": "Feedback på godkännande",
4342
"0830bd81f19bb753": "Skicka feedback om godkännandet utan bilagor eller tillagd kontext.",
4343
"d15878f290283f53": "Kunde inte redigera meddelandet",
4344
+ "dd426ccfb3da6826": "Could not add quote",
4345
+ "ba2b33c3082441c4": "This quote would make the message too long to send. Shorten the draft or select less text.",
4346
"188db618b91bf237": "Konversationen kunde inte visas",
4347
"86ba20bb0ac0e5d0": "Skicka feedback för att avböja den här begäran",
4348
"880aa376639f0b04": "Skicka ett meddelande för att avböja och styra om agenten",
@@ -4351,6 +4364,13 @@
4364
"c0e2a25e01e3236f": "Ladda ned {name}",
4365
"71e7894d52a4dc83": "Använd mall",
4366
"0d2983c2dbaac338": "Använd mallen {name}",
4367
+ "9c588b380359c9ac": "Quote is too long",
4368
+ "4867b752740e9a9b": "Select up to {max} characters to cite.",
4369
+ "ea59a48fb9657a5c": "Unable to locate quote",
4370
+ "9680ed7cf7c79355": "Select more surrounding text to cite its source accurately.",
4371
+ "623b6e7bc72d2688": "Choose quote source",
4372
+ "ae98d7a6f90f56f2": "This text appears more than once. Choose the passage you selected.",
4373
+ "a047920204bc0ec7": "Occurrence {index} of {count}",
4374
"cd03eb1b84271c02": "Agent",
4375
"0226edfcba8db105": "{label}: {summary}",
4376
"5d2859f3b56ad6cf": "Dubbeltryck för att dölja meddelandet.",
apps/mobile/src/i18n/translations/zh.json
+22
-2
@@ -1237,6 +1237,14 @@
1237
"6df89a3609273ddf": "返回主页",
1238
"ca91bde751481f6e": "未找到路由",
1239
"fa7ad42d8043440e": "返回主页",
1240
+ "67e94b9fb8ee633b": "Quote",
1241
+ "90b2fa60b4cd0c15": "评论",
1242
+ "60f8d5f18d14777e": "Comment on quote",
1243
+ "b9185b31f8d03aaa": "Add an optional comment…",
1244
+ "c59ddf9a3543013f": "Go to message",
1245
+ "58d429970e815c66": "Copy quote",
1246
+ "200acb0e96f98096": "从草稿中移除",
1247
+ "cf063d4a1ffd5c6e": "This comment makes the message too long to send. Shorten it to save and close.",
1248
"9d1893839b7b4881": "Dev",
1249
"ae2263d9d6e71fd8": "预览版",
1250
"525f2b92a20a9707": "测试版",
@@ -1262,7 +1270,6 @@
1270
"fb28c2c6667398c7": "已合并",
1271
"8c5799964db00630": "页面",
1272
"bf14b3522e13a2c3": "URL",
1265
- "90b2fa60b4cd0c15": "评论",
1273
"669b9d73d58ea020": "选区",
1274
"6345ddd2e293ddd5": "已请求更改",
1275
"74e6003622876943": "元素",
@@ -1282,7 +1289,6 @@
1289
"eca94e6557931eae": "连接后请重试。",
1290
"be3fcbc1324d5f38": "打开 {term, select, mr {MR} cr {change request} other {PR}}",
1291
"19f953915a468edd": "打开附件",
1285
- "200acb0e96f98096": "从草稿中移除",
1292
"13559139cab80bd6": [
1293
"第 ",
1294
{
@@ -1307,6 +1313,8 @@
1313
"8fce5e0d1adf9939": "部分上下文不可用",
1314
"c80fb12238256d0d": "这些引用已标记为不可用。",
1315
"d3fdcfa142649a36": "请尝试重新复制。",
1316
+ "71369ce364d8ed08": "Could not update quote",
1317
+ "5f794b9980f91c26": "This comment would make the message too long to send. Shorten the comment or draft.",
1318
"b9cf50b7e7b1bc54": "正在复制上下文…",
1319
"bda161176d64ec51": "选择模型",
1320
"54a5cee284438dd6": "模型和推理设置",
@@ -1466,6 +1474,7 @@
1474
"9f1b29c948772f0f": "打开链接",
1475
"258d16c1554b734c": "复制链接",
1476
"d7dc565616d13a5c": "分享链接",
1477
+ "51244cd196696a00": "Cite",
1478
"6cdca065884f77f2": "复制",
1479
"0165ef55eb6c8a99": "复制为 Markdown",
1480
"7c1923203049d602": "复制代码",
@@ -1483,6 +1492,8 @@
1492
"v": "v"
1493
}
1494
],
1495
+ "ede9a884a11b7972": "Assistant quote",
1496
+ "f563a55ee229090e": "Open quote",
1497
"7b30d976b8508ddf": "发送消息",
1498
"40c503999bce960e": "新建任务",
1499
"2225f6bda46f4cc6": "收起键盘",
@@ -4313,6 +4324,8 @@
4324
"cebceafe7ddc7d5d": "批准反馈",
4325
"0830bd81f19bb753": "发送审批反馈时请不要带附件或额外上下文。",
4326
"d15878f290283f53": "无法编辑消息",
4327
+ "dd426ccfb3da6826": "Could not add quote",
4328
+ "ba2b33c3082441c4": "This quote would make the message too long to send. Shorten the draft or select less text.",
4329
"188db618b91bf237": "无法显示对话",
4330
"86ba20bb0ac0e5d0": "发送反馈以拒绝这个请求",
4331
"880aa376639f0b04": "发送消息以拒绝,并给智能体新的指示",
@@ -4334,6 +4347,13 @@
4347
"c0e2a25e01e3236f": "下载 {name}",
4348
"71e7894d52a4dc83": "使用模板",
4349
"0d2983c2dbaac338": "使用 {name} 模板",
4350
+ "9c588b380359c9ac": "Quote is too long",
4351
+ "4867b752740e9a9b": "Select up to {max} characters to cite.",
4352
+ "ea59a48fb9657a5c": "Unable to locate quote",
4353
+ "9680ed7cf7c79355": "Select more surrounding text to cite its source accurately.",
4354
+ "623b6e7bc72d2688": "Choose quote source",
4355
+ "ae98d7a6f90f56f2": "This text appears more than once. Choose the passage you selected.",
4356
+ "a047920204bc0ec7": "Occurrence {index} of {count}",
4357
"cd03eb1b84271c02": "智能体",
4358
"0226edfcba8db105": "{label}:{summary}",
4359
"5d2859f3b56ad6cf": "轻点两下以隐藏消息。",
apps/mobile/src/lib/assistantCitationSelection.test.ts
new
+108
@@ -0,0 +1,108 @@
1
+import { expect, it } from "vite-plus/test";
2
+import { collectMobileAssistantTextSelectors } from "./assistantCitationSelection";
3
+import {
4
+ findAssistantCitationText,
5
+ serializeAssistantCitation,
6
+ expandAssistantCitationsForProvider,
7
+} from "@t3tools/shared/assistantCitations";
8
+import { EnvironmentId, ThreadId, MessageId } from "@t3tools/contracts";
9
+
10
+it("offers distinct source choices within a block and maps recursive folds without merging occurrences", () => {
11
+ const paragraph = `${"x".repeat(40)}**quote**${"x".repeat(40)}`;
12
+ const markdown = `${paragraph}\n\n<details><summary>Outer</summary>\n\n<details><summary>Inner</summary>\n\n${paragraph}\n\n</details>\n\n</details>`;
13
+ const [first] = collectMobileAssistantTextSelectors(markdown, "0:0", "quote");
14
+ const [second] = collectMobileAssistantTextSelectors(markdown, "1/1/0:0", "quote");
15
+ expect([first?.index, first?.count, second?.index, second?.count]).toEqual([0, 2, 1, 2]);
16
+ const rendered = `${"x".repeat(40)}quote${"x".repeat(40)} ${"x".repeat(40)}quote${"x".repeat(40)}`;
17
+ expect(second?.selector.start).toBe(rendered.lastIndexOf("quote"));
18
+ // Identical context on both sides stays ambiguous rather than guessing.
19
+ expect(findAssistantCitationText(rendered, second!.selector)).toBeNull();
20
+ const markers = [first!, second!].map(({ selector }) =>
21
+ serializeAssistantCitation({
22
+ version: 1,
23
+ environmentId: EnvironmentId.make("env"),
24
+ threadId: ThreadId.make("thread"),
25
+ messageId: MessageId.make("assistant"),
26
+ ...selector,
27
+ }),
28
+ );
29
+ expect(markers[0]).not.toBe(markers[1]);
30
+ expect(expandAssistantCitationsForProvider(markers.join(" "))).toContain(
31
+ '"id": "assistant-quote-2"',
32
+ );
33
+ const [reference] = collectMobileAssistantTextSelectors(
34
+ "before [label][id] after\n\n<details><summary>More</summary>\n\n[id]: https://example.com\n\n</details>",
35
+ "0:0",
36
+ "before label after",
37
+ );
38
+ expect(reference?.selector.text).toBe("before label after");
39
+ const sameBlock = collectMobileAssistantTextSelectors(
40
+ "first **quote** then **quote** last",
41
+ "0:0",
42
+ "quote",
43
+ );
44
+ expect(sameBlock[1]?.selector.start).toBe(17);
45
+ expect(sameBlock[1]?.selector.prefix).toBe("first quote then ");
46
+ const [leadingSpace] = collectMobileAssistantTextSelectors(
47
+ "x\n\n<details><summary>More</summary>\n\n` quote`\n\n</details>",
48
+ "1/0:0",
49
+ "quote",
50
+ );
51
+ expect(leadingSpace?.selector.start).toBe(2);
52
+ expect(leadingSpace?.count).toBe(1);
53
+ const codeChoices = collectMobileAssistantTextSelectors(
54
+ "quote\n\n```text\nquote\n```\n\nquote",
55
+ "0:0",
56
+ "quote",
57
+ );
58
+ expect(codeChoices.map((choice) => [choice.index, choice.count])).toEqual([
59
+ [0, 3],
60
+ [1, 3],
61
+ [2, 3],
62
+ ]);
63
+ for (const { source, path } of [
64
+ { source: "\n\nquote quote\n\n", path: "0:0" },
65
+ {
66
+ source: 'quote\n\n```mermaid\nflowchart TD\nA["quote"]\n```\n\nquote',
67
+ path: "0:0",
68
+ },
69
+ {
70
+ source:
71
+ "\n\n<details><summary>More</summary>\n\nquote quote\n\n</details>\n\n",
72
+ path: "1/0:0",
73
+ },
74
+ ]) {
75
+ const selectors = collectMobileAssistantTextSelectors(source, path, "quote");
76
+ expect(selectors).toHaveLength(2);
77
+ for (const [index, { selector }] of selectors.entries()) {
78
+ expect(findAssistantCitationText("quote quote", selector)).toEqual({
79
+ start: index * 6,
80
+ end: index * 6 + 5,
81
+ });
82
+ }
83
+ }
84
+});
85
+
86
+it("rejects unmappable or blank selections instead of inventing a source", () => {
87
+ expect(collectMobileAssistantTextSelectors("quote quote", "0:0", " ")).toEqual([]);
88
+ expect(collectMobileAssistantTextSelectors("quote ".repeat(21), "0:0", "quote")).toEqual([]);
89
+ expect(collectMobileAssistantTextSelectors("quote quote", "0:0", "other")).toEqual([]);
90
+ expect(collectMobileAssistantTextSelectors("quote quote", "missing", "quote")).toEqual([]);
91
+});
92
+
93
+it("uses the web math representation around a selected passage", () => {
94
+ for (const formula of ["$x$", "\\(x\\)"]) {
95
+ const [choice] = collectMobileAssistantTextSelectors(`Before ${formula} after`, "0:0", "after");
96
+ expect(choice?.selector.prefix).toBe("Before \\(x\\) ");
97
+ expect(findAssistantCitationText("Before \\(x\\) after", choice!.selector)).toEqual({
98
+ start: 13,
99
+ end: 18,
100
+ });
101
+ }
102
+ const [display] = collectMobileAssistantTextSelectors(
103
+ "Before\n\n$$\nx\n$$\n\nafter",
104
+ "0:0",
105
+ "after",
106
+ );
107
+ expect(display?.selector.prefix).toBe("Before \\[ x \\] ");
108
+});
apps/mobile/src/lib/assistantCitationSelection.ts
new
+120
@@ -0,0 +1,120 @@
1
+import { markdownMathRanges } from "@t3tools/shared/markdownMath";
2
+import { createAssistantTextSelector } from "@t3tools/shared/assistantCitations";
3
+import {
4
+ splitCodexArtifactTemplateMarkdown,
5
+ renderCodexInlineDirectivesAsMarkdown,
6
+} from "@t3tools/shared/codexMarkdownDirectives";
7
+import { splitMarkdownDetails } from "./markdownDetails";
8
+import {
9
+ markdownReferenceDefinitions,
10
+ parseMarkdownDocument,
11
+ withReferenceDefinitions,
12
+ type MarkdownNode,
13
+} from "./markdownDocument";
14
+
15
+function renderedText(node: MarkdownNode, restoreMath: (value: string) => string): string {
16
+ if (
17
+ node.type === "definition" ||
18
+ node.type === "image" ||
19
+ node.type === "imageReference" ||
20
+ node.type === "html" ||
21
+ (node.type === "code" && node.lang === "mermaid")
22
+ )
23
+ return "";
24
+ if ("value" in node) return restoreMath(node.value);
25
+ if ("children" in node) {
26
+ const inline =
27
+ node.type === "paragraph" ||
28
+ node.type === "heading" ||
29
+ node.type === "link" ||
30
+ node.type === "linkReference" ||
31
+ node.type === "emphasis" ||
32
+ node.type === "strong" ||
33
+ node.type === "delete" ||
34
+ node.type === "tableCell";
35
+ return node.children
36
+ .map((child) => renderedText(child, restoreMath))
37
+ .filter((text) => text.length > 0)
38
+ .join(inline ? "" : "\n");
39
+ }
40
+ return node.type === "break" ? "\n" : "";
41
+}
42
+
43
+function citationText(markdown: string): string {
44
+ const formulas = markdownMathRanges(markdown);
45
+ let marker = "\ue000t3math";
46
+ while (markdown.includes(marker)) marker += "_";
47
+ const tokens = formulas.map((_, index) => `${marker}${index}\ue001`);
48
+ let cursor = 0;
49
+ let prose = "";
50
+ for (const [index, formula] of formulas.entries()) {
51
+ prose += markdown.slice(cursor, formula.start) + tokens[index];
52
+ cursor = formula.end;
53
+ }
54
+ prose += markdown.slice(cursor);
55
+ return renderedText(parseMarkdownDocument(prose), (value) =>
56
+ value.replace(new RegExp(`${marker}(\\d+)\ue001`, "g"), (_, index: string) => {
57
+ const formula = formulas[Number(index)]!;
58
+ const tex = formula.tex.trim();
59
+ return formula.display ? `\\[\n${tex}\n\\]` : `\\(${tex}\\)`;
60
+ }),
61
+ );
62
+}
63
+
64
+function citationSegments(
65
+ markdown: string,
66
+ path = "",
67
+ definitions = markdownReferenceDefinitions(markdown),
68
+): Array<{ path: string; text: string }> {
69
+ return splitMarkdownDetails(markdown).flatMap((block, index) => {
70
+ if (block.kind === "details")
71
+ return citationSegments(block.body, `${path}${index}/`, definitions);
72
+ return splitCodexArtifactTemplateMarkdown(block.markdown).flatMap((segment, segmentIndex) =>
73
+ segment.kind === "markdown"
74
+ ? [
75
+ {
76
+ path: `${path}${index}:${segmentIndex}`,
77
+ text: citationText(
78
+ renderCodexInlineDirectivesAsMarkdown(
79
+ withReferenceDefinitions(segment.markdown, definitions),
80
+ ),
81
+ ),
82
+ },
83
+ ]
84
+ : [],
85
+ );
86
+ });
87
+}
88
+
89
+function occurrences(text: string, quote: string): number[] {
90
+ const result: number[] = [];
91
+ for (let index = text.indexOf(quote); index !== -1; index = text.indexOf(quote, index + 1))
92
+ result.push(index);
93
+ return result;
94
+}
95
+
96
+export function collectMobileAssistantTextSelectors(markdown: string, path: string, text: string) {
97
+ if (!text.trim()) return [];
98
+ const normalize = (value: string) => value.replace(/\s+/g, " ");
99
+ const quote = normalize(text);
100
+ const segments = citationSegments(markdown).filter((segment) => segment.text.trim().length > 0);
101
+ const segmentIndex = segments.findIndex((segment) => segment.path === path);
102
+ const segment = segments[segmentIndex];
103
+ if (!segment) return [];
104
+ const fullText = normalize(segments.map((entry) => entry.text).join("\n"));
105
+ const throughSegment = segments
106
+ .slice(0, segmentIndex + 1)
107
+ .map((entry) => entry.text)
108
+ .join("\n");
109
+ const offset = normalize(throughSegment).length - normalize(segment.text).length;
110
+ const matches = occurrences(fullText, quote);
111
+ const localMatches = occurrences(normalize(segment.text), quote);
112
+ if (localMatches.length > 20) return [];
113
+ return localMatches.flatMap((localStart) => {
114
+ const start = offset + localStart;
115
+ const index = matches.indexOf(start);
116
+ if (index === -1) return [];
117
+ const selector = createAssistantTextSelector(fullText, start, start + quote.length);
118
+ return selector ? [{ selector: { ...selector, text }, index, count: matches.length }] : [];
119
+ });
120
+}
apps/mobile/src/lib/composerChipPresentation.ts
+1
@@ -34,6 +34,7 @@ const CONTEXT_CHIP_PRESENTATIONS = {
34
icon: "mouse-pointer-click",
35
},
36
"review-comment": { accent: "#8a70dd", icon: "message-circle" },
37
+ citation: { accent: "#8a70dd", icon: "message-circle" },
38
"pull-request": {
39
accent: "#7079e4",
40
icon: "git-pull-request-arrow",
apps/mobile/src/lib/composerContext.test.ts
+46
-2
@@ -1,9 +1,14 @@
1
import {
2
+ PROVIDER_SEND_TURN_MAX_INPUT_CHARS,
3
ComposerContextId,
4
+ EnvironmentId,
5
+ MessageId,
6
+ ThreadId,
7
type OrchestrationMessageContext,
8
type ServerProviderSkill,
9
} from "@t3tools/contracts";
10
import { collectComposerInlineTokens } from "@t3tools/shared/composerInlineTokens";
11
+import { serializeAssistantCitation } from "@t3tools/shared/assistantCitations";
12
import {
13
ATTACHMENT_ONLY_BOOTSTRAP_PROMPT,
14
collectComposerContextReferences,
@@ -12,6 +17,7 @@ import {
17
} from "@t3tools/shared/composerContextReferences";
18
import { describe, expect, it } from "vite-plus/test";
19
import {
20
+ assistantCitationDraftWithinLimit,
21
collectComposerModelTokens,
22
composerContextEditorTokens,
23
composerSkillLabels,
@@ -201,9 +207,45 @@ describe("mobile composer context", () => {
207
expect(collectComposerModelTokens("model:codex/gpt-6.1", known, kept)).toEqual([]);
208
});
209
210
+ it("rejects citation drafts exceeding either encoded or expanded input limits", () => {
211
+ const quote = (text: string) =>
212
+ serializeAssistantCitation({
213
+ version: 1,
214
+ environmentId: EnvironmentId.make("remote"),
215
+ threadId: ThreadId.make("thread"),
216
+ messageId: MessageId.make("message"),
217
+ text,
218
+ start: 0,
219
+ end: text.length,
220
+ prefix: "",
221
+ suffix: "",
222
+ });
223
+ expect(assistantCitationDraftWithinLimit(`Explain ${quote("short quote")}`)).toBe(true);
224
+ expect(
225
+ assistantCitationDraftWithinLimit(
226
+ `${quote("日".repeat(8_000))} ${quote("語".repeat(8_000))}`,
227
+ ),
228
+ ).toBe(false);
229
+ const short = quote("x");
230
+ const expandedOverflow = "a".repeat(PROVIDER_SEND_TURN_MAX_INPUT_CHARS - short.length) + short;
231
+ expect(expandedOverflow.length).toBe(PROVIDER_SEND_TURN_MAX_INPUT_CHARS);
232
+ expect(assistantCitationDraftWithinLimit(expandedOverflow)).toBe(false);
233
+ });
234
+
235
it("keeps exact source positions and repeated references alongside existing native tokens", () => {
236
const reference = formatComposerContextReference(terminal);
206
- const text = `Use $babysit with $disabled $agentOnly $HOME $PATH $anything $notaskill $20 $20k and [app.ts](src/app.ts) with ${reference} then ${reference}`;
237
+ const citation = serializeAssistantCitation({
238
+ version: 1,
239
+ environmentId: EnvironmentId.make("remote"),
240
+ threadId: ThreadId.make("thread"),
241
+ messageId: MessageId.make("message"),
242
+ text: "日本語 🚀 with @file.ts and $HOME",
243
+ start: 0,
244
+ end: 33,
245
+ prefix: "",
246
+ suffix: "",
247
+ });
248
+ const text = `Use $babysit with $disabled $agentOnly $HOME $PATH $anything $notaskill $20 $20k and [app.ts](src/app.ts) with ${reference} then ${reference} (${citation}),${citation}!`;
249
const babysit: ServerProviderSkill = {
250
name: "babysit",
251
path: "/skills/babysit",
@@ -222,6 +264,8 @@ describe("mobile composer context", () => {
264
"[app.ts](src/app.ts)",
265
reference,
266
reference,
267
+ citation,
268
+ citation,
269
]);
270
for (const token of tokens) expect(text.slice(token.start, token.end)).toBe(token.source);
271
expect(
@@ -230,7 +274,7 @@ describe("mobile composer context", () => {
274
collectComposerInlineTokens(text),
275
composerSkillLabels([]),
276
).map((token) => token.type),
233
- ).toEqual(["mention", "context", "context"]);
277
+ ).toEqual(["mention", "context", "context", "citation", "citation"]);
278
expect(
279
composerContextEditorTokens(
280
text,
apps/mobile/src/lib/composerContext.ts
+22
-2
@@ -9,6 +9,12 @@ import { videoMimeType } from "@t3tools/shared/video";
9
import { msg } from "gt-react-native";
10
import { m } from "../i18n/messages";
11
import {
12
+ assistantCitationLabel,
13
+ collectAssistantCitations,
14
+ expandAssistantCitationsForProvider,
15
+} from "@t3tools/shared/assistantCitations";
16
+import {
17
+ PROVIDER_SEND_TURN_MAX_INPUT_CHARS,
18
COMPOSER_CONTEXT_MAX_RECORDS,
19
COMPOSER_CONTEXT_REVIEW_TEXT_MAX_CHARS,
20
ComposerContextId,
@@ -38,6 +44,13 @@ import {
44
const isMessageContext = Schema.is(OrchestrationMessageContext);
45
const decodeMessageContext = Schema.decodeUnknownOption(OrchestrationMessageContext);
46
47
+export function assistantCitationDraftWithinLimit(text: string): boolean {
48
+ return (
49
+ text.length <= PROVIDER_SEND_TURN_MAX_INPUT_CHARS &&
50
+ expandAssistantCitationsForProvider(text).length <= PROVIDER_SEND_TURN_MAX_INPUT_CHARS
51
+ );
52
+}
53
+
54
export function composerContextSendBlockReason(
55
context?: OrchestrationMessageContext,
56
): string | null {
@@ -201,13 +214,15 @@ export function composerContextEditorTokens(
214
modelTokens: ReadonlyArray<ComposerModelMentionOccurrence> = [],
215
) {
216
const references = collectComposerContextReferences(text);
217
+ const citations = collectAssistantCitations(text);
218
const inlineTokens = tokens.filter(
219
(token) =>
220
// `$HOME` and other `$name` text that is not one of the provider's skills stays prose.
221
(token.type !== "skill" || knownSkills.has(token.value)) &&
208
- !references.some((ref) => token.start < ref.end && token.end > ref.start),
222
+ !references.some((ref) => token.start < ref.end && token.end > ref.start) &&
223
+ !citations.some((ref) => token.start < ref.end && token.end > ref.start),
224
);
210
- const taken = [...inlineTokens, ...references, ...composerMathRanges(text)];
225
+ const taken = [...inlineTokens, ...references, ...citations, ...composerMathRanges(text)];
226
const models = modelTokens.filter(
227
(mention) => !taken.some((range) => mention.start < range.end && mention.end > range.start),
228
);
@@ -223,6 +238,11 @@ export function composerContextEditorTokens(
238
value: mention.model,
239
...mention,
240
})),
241
+ ...citations.map((ref) => ({
242
+ type: "citation" as const,
243
+ value: assistantCitationLabel(ref.citation),
244
+ ...ref,
245
+ })),
246
].sort((a, b) => a.start - b.start);
247
}
248
apps/mobile/src/lib/filePreview.test.ts
+8
@@ -89,6 +89,7 @@ vi.mock("react-native", () => ({
89
addEventListener: () => ({ remove() {} }),
90
},
91
View: ({ children }: { children?: ReactNode }) => createElement("div", null, children),
92
+ ScrollView: ({ children }: { children?: ReactNode }) => createElement("div", null, children),
93
Pressable: (props: {
94
children?: ReactNode;
95
onPress: () => void;
@@ -237,6 +238,13 @@ vi.mock("expo-haptics", () => ({ selectionAsync: async () => {} }));
238
vi.mock("expo-image", () => ({}));
239
vi.mock("uniwind", () => ({}));
240
vi.mock("../components/ui/Dialog", () => ({}));
241
+vi.mock("../components/ui/Sheet", () => ({
242
+ Sheet: ({ children }: { children?: ReactNode }) => children,
243
+}));
244
+vi.mock("../components/ui/ListActionRow", () => ({
245
+ ListActionRow: ({ label, onPress }: { label: string; onPress(): void }) =>
246
+ createElement("button", { onClick: onPress }, label),
247
+}));
248
vi.mock("../components/ui/NativePresentation", () => ({
249
PresentationSource: ({ children }: { children?: ReactNode }) => children,
250
}));
apps/mobile/src/native/EnrichedMarkdownText.tsx
+11
@@ -447,6 +447,17 @@ export function MobileEnrichedMarkdownText(props: SelectableMarkdownTextProps) {
447
containerStyle={{ flexShrink: 1, minWidth: 0 }}
448
flavor="github"
449
selectable
450
+ contextMenuItems={
451
+ props.onCiteText
452
+ ? [
453
+ {
454
+ text: gt("Cite", { $context: "verb, quote selected text" }),
455
+ icon: "quote.bubble",
456
+ onPress: ({ text }) => props.onCiteText?.(text),
457
+ },
458
+ ]
459
+ : undefined
460
+ }
461
selectionClipboard={selectionClipboard}
462
selectionColor={props.textStyle.selectionColor}
463
selectionHandleColor={props.textStyle.selectionHandleColor}
apps/mobile/src/native/SelectableMarkdownText.tsx
+54
-1
@@ -1,4 +1,10 @@
1
import { Platform } from "react-native";
2
+import { useState } from "react";
3
+import { useGT } from "gt-react-native";
4
+import type { AssistantCitation } from "@t3tools/contracts";
5
+import { parseAssistantCitationHref } from "@t3tools/shared/assistantCitations";
6
+import { AssistantCitationSheet } from "../components/AssistantCitationSheet";
7
+import { copyTextWithHaptic } from "../lib/copyTextWithHaptic";
8
import type { SelectableMarkdownTextProps } from "./SelectableMarkdownText.types";
9
10
import { MobileEnrichedMarkdownText } from "./EnrichedMarkdownText";
@@ -17,6 +23,9 @@ export type {
23
} from "./SelectableMarkdownText.types";
24
25
export function SelectableMarkdownText(props: SelectableMarkdownTextProps) {
26
+ const [citation, setCitation] = useState<AssistantCitation | null>(null);
27
+ const gt = useGT();
28
+ const hasCitations = props.markdown.includes("t3-citation:");
29
const theme = useUniwindTheme();
30
const selectionColor = themeColorWithAlpha(theme["--color-focus"], 0.32);
31
const selectionHandleColor = theme["--color-focus"];
@@ -24,5 +33,49 @@ export function SelectableMarkdownText(props: SelectableMarkdownTextProps) {
33
Platform.OS === "android"
34
? { selectionColor, selectionHandleColor, ...props.textStyle }
35
: props.textStyle;
27
- return <MobileEnrichedMarkdownText {...props} textStyle={textStyle} />;
36
+ return (
37
+ <>
38
+ <MobileEnrichedMarkdownText
39
+ {...props}
40
+ textStyle={textStyle}
41
+ onLinkPress={
42
+ hasCitations
43
+ ? (href) => {
44
+ const quote = parseAssistantCitationHref(href);
45
+ if (quote) setCitation(quote);
46
+ else props.onLinkPress?.(href);
47
+ }
48
+ : props.onLinkPress
49
+ }
50
+ fileContextMenu={
51
+ hasCitations
52
+ ? (href) =>
53
+ parseAssistantCitationHref(href)
54
+ ? {
55
+ title: gt("Assistant quote"),
56
+ actions: [
57
+ { id: "open-quote", title: gt("Open quote") },
58
+ { id: "copy-quote", title: gt("Copy quote") },
59
+ ],
60
+ }
61
+ : props.fileContextMenu?.(href)
62
+ : props.fileContextMenu
63
+ }
64
+ onFileContextMenuAction={
65
+ hasCitations
66
+ ? (href, actionId) => {
67
+ const quote = parseAssistantCitationHref(href);
68
+ if (quote) {
69
+ if (actionId === "open-quote") setCitation(quote);
70
+ else if (actionId === "copy-quote") copyTextWithHaptic(quote.text);
71
+ } else props.onFileContextMenuAction?.(href, actionId);
72
+ }
73
+ : props.onFileContextMenuAction
74
+ }
75
+ />
76
+ {citation ? (
77
+ <AssistantCitationSheet citation={citation} onClose={() => setCitation(null)} />
78
+ ) : null}
79
+ </>
80
+ );
81
}
apps/mobile/src/native/SelectableMarkdownText.types.ts
+1
@@ -77,6 +77,7 @@ export interface SelectableMarkdownTextProps {
77
readonly models?: ReadonlyArray<SelectableMarkdownModel>;
78
readonly preserveSoftBreaks?: boolean;
79
readonly onLinkPress?: (href: string) => void;
80
+ readonly onCiteText?: (text: string) => void;
81
readonly fileContextMenu?: (href: string) => MarkdownFileContextMenu | undefined;
82
readonly onFileContextMenuAction?: (href: string, actionId: string) => void;
83
readonly linkCustomization?: (href: string) => MarkdownLinkCustomization | undefined;
apps/mobile/src/native/T3ComposerEditor.ios.tsx
+4
-2
@@ -202,7 +202,7 @@ export function ComposerEditor({
202
token.type === "mention" ? token.value : contextRecordFileName(record),
203
);
204
return {
205
- type: token.type,
205
+ type: token.type === "citation" ? "context" : token.type,
206
source: token.source,
207
start: token.start,
208
end: token.end,
@@ -218,7 +218,9 @@ export function ComposerEditor({
218
? model.label
219
: token.type === "context"
220
? `${token.label}${props.context?.records.some((record) => record.contextId === token.contextId) ? "" : " · unavailable"}`
221
- : basename(token.value),
221
+ : token.type === "citation"
222
+ ? token.value
223
+ : basename(token.value),
224
detail: token.type === "context" ? composerChipSizeSuffix(record) : "",
225
iconUri: model ? modelChipIconUri(model) : contextChipIconUri(icon),
226
tintsIcon: model ? modelChipIcon(model).tintsIcon : icon.kind === "chip",
apps/mobile/src/native/T3ComposerEditor.native.tsx
+5
-2
@@ -201,7 +201,8 @@ export function ComposerEditor({
201
);
202
return {
203
// Android taps only known token types; a model chip opens like a skill chip.
204
- type: token.type === "model" ? "skill" : token.type,
204
+ type:
205
+ token.type === "model" ? "skill" : token.type === "citation" ? "context" : token.type,
206
source: token.source,
207
start: token.start,
208
end: token.end,
@@ -217,7 +218,9 @@ export function ComposerEditor({
218
? model.label
219
: token.type === "context"
220
? `${token.label}${props.context?.records.some((record) => record.contextId === token.contextId) ? "" : " · unavailable"}`
220
- : basename(token.value),
221
+ : token.type === "citation"
222
+ ? token.value
223
+ : basename(token.value),
224
detail: token.type === "context" ? composerChipSizeSuffix(record) : "",
225
iconUri: model ? modelChipIconUri(model) : contextChipIconUri(icon),
226
tintsIcon: model ? modelChipIcon(model).tintsIcon : icon.kind === "chip",
apps/mobile/src/native/useEnrichedLinkVariants.ts
+11
@@ -1,5 +1,9 @@
1
import { modelChipIcon } from "../lib/contextChipIconSource";
2
import { useMemo } from "react";
3
+import {
4
+ assistantCitationLabel,
5
+ parseAssistantCitationHref,
6
+} from "@t3tools/shared/assistantCitations";
7
import { Image } from "react-native";
8
import type { LinkPillContent, MarkdownStyle } from "react-native-enriched-markdown";
9
import type { ComposerContextRecord } from "@t3tools/contracts";
@@ -65,6 +69,13 @@ function presentation(
69
): MarkdownLinkCustomization | undefined {
70
const custom = props.linkCustomization?.(url);
71
if (custom) return custom;
72
+ const citation = parseAssistantCitationHref(url);
73
+ if (citation)
74
+ return {
75
+ label: assistantCitationLabel(citation),
76
+ icon: CONTEXT_CHIP_ICON_SOURCES["message-circle"],
77
+ chip: { accent: contextChipPresentation("citation").accent, tintsIcon: true },
78
+ };
79
const context = enrichedContextLinkCustomization(url);
80
if (context) return context;
81
const skill = enrichedSkillReference(url, props.skills);
apps/server/src/orchestration-v2/Orchestrator.ts
+11
@@ -67,6 +67,7 @@ import {
67
parseGoalCommand,
68
orchestrationV2RunWorkStartedAt,
69
ProviderInstanceId,
70
+ PROVIDER_SEND_TURN_MAX_INPUT_CHARS,
71
ProviderInteractionMode,
72
isRuntimeModeAbove,
73
resolveProviderInstanceEnabled,
@@ -82,6 +83,7 @@ import {
83
} from "@t3tools/contracts";
84
import * as KeyedLock from "@t3tools/shared/KeyedLock";
85
import { modelSelectionsEqual } from "@t3tools/shared/model";
86
+import { expandAssistantCitationsForProvider } from "@t3tools/shared/assistantCitations";
87
import { modelSwitchSince } from "./modelSwitch.ts";
88
import { contextBoundaryOrdinal, isScheduledFreshRun } from "./contextBoundary.ts";
89
import { isPlaceholderThreadTitle } from "./placeholderThreadTitle.ts";
@@ -5980,6 +5982,15 @@ const makeOrchestrator = Effect.fn("orchestrationV2.Orchestrator.layer")(functio
5982
>,
5983
message: Pick<OrchestrationV2ConversationMessage, "text" | "attachments" | "context">,
5984
) {
5985
+ if (
5986
+ expandAssistantCitationsForProvider(message.text).length > PROVIDER_SEND_TURN_MAX_INPUT_CHARS
5987
+ ) {
5988
+ return yield* new OrchestratorCommandRejectedError({
5989
+ commandId: command.commandId,
5990
+ commandType: command.type,
5991
+ cause: `Message exceeds ${PROVIDER_SEND_TURN_MAX_INPUT_CHARS.toLocaleString("en-US")} characters after expanding quotes. Shorten it and try again.`,
5992
+ });
5993
+ }
5994
if (isNativeMaintenanceCommand(message)) {
5995
return yield* new OrchestratorDispatchError({
5996
commandId: command.commandId,
apps/server/src/orchestration-v2/ProviderTurnStartService.test.ts
+39
@@ -1,3 +1,7 @@
1
+import {
2
+ serializeAssistantCitation,
3
+ expandAssistantCitationsForProvider,
4
+} from "@t3tools/shared/assistantCitations";
5
import * as NodeCrypto from "@effect/platform-node/NodeCrypto";
6
import * as NodeServices from "@effect/platform-node/NodeServices";
7
import { expect, it, vi } from "vite-plus/test";
@@ -20,6 +24,8 @@ import {
24
RunId,
25
ThreadId,
26
ProjectId,
27
+ EnvironmentId,
28
+ PROVIDER_SEND_TURN_MAX_INPUT_CHARS,
29
type OrchestrationV2ThreadProjection,
30
OrchestrationV2DomainEvent,
31
} from "@t3tools/contracts";
@@ -3056,3 +3062,36 @@ for (const previousMessages of [[], ["/compact", " /COMPACT "]]) {
3062
}),
3063
);
3064
}
3065
+
3066
+effectIt.effect("rejects citation expansion before opening a provider session", () =>
3067
+ Effect.gen(function* () {
3068
+ const marker = serializeAssistantCitation({
3069
+ version: 1,
3070
+ environmentId: EnvironmentId.make("env"),
3071
+ threadId: ThreadId.make("thread"),
3072
+ messageId: MessageId.make("assistant"),
3073
+ text: "\u0001".repeat(8_000),
3074
+ start: 0,
3075
+ end: 8_000,
3076
+ prefix: "",
3077
+ suffix: "",
3078
+ });
3079
+ const text = "x".repeat(80_000) + marker;
3080
+ expect(text.length).toBeLessThan(PROVIDER_SEND_TURN_MAX_INPUT_CHARS);
3081
+ expect(expandAssistantCitationsForProvider(text).length).toBeGreaterThan(
3082
+ PROVIDER_SEND_TURN_MAX_INPUT_CHARS,
3083
+ );
3084
+ const harness = makeLocalCommandHarness({ text });
3085
+ yield* harness.start;
3086
+ expect(harness.open).not.toHaveBeenCalled();
3087
+ expect(harness.startTurn).not.toHaveBeenCalled();
3088
+ expect(harness.projection().runs.at(-1)?.status).toBe("failed");
3089
+ expect(harness.projection().turnItems).toMatchObject([
3090
+ {
3091
+ type: "error",
3092
+ failure: { class: "validation_error", message: expect.stringContaining("120,000") },
3093
+ },
3094
+ ]);
3095
+ expect(harness.projection().messages[0]?.text).toBe(text);
3096
+ }),
3097
+);
apps/server/src/orchestration-v2/ProviderTurnStartService.ts
+27
@@ -1,7 +1,9 @@
1
import { modelSelectionsEqual } from "@t3tools/shared/model";
2
import { projectComposerContextForProvider } from "@t3tools/shared/composerContextReferences";
3
+import { expandAssistantCitationsForProvider } from "@t3tools/shared/assistantCitations";
4
import {
5
CommandId,
6
+ PROVIDER_SEND_TURN_MAX_INPUT_CHARS,
7
latestProviderTurnForAttempt,
8
type OrchestrationV2DomainEvent,
9
type OrchestrationV2ContextHandoff,
@@ -601,6 +603,31 @@ export const layer: Layer.Layer<
603
});
604
},
605
);
606
+ if (
607
+ expandAssistantCitationsForProvider(providerMessage.text).length >
608
+ PROVIDER_SEND_TURN_MAX_INPUT_CHARS
609
+ ) {
610
+ yield* settleRunBeforeStart({
611
+ run,
612
+ rootNode,
613
+ attempt,
614
+ turnItems: projection.turnItems,
615
+ signal: "expanded-input-too-long",
616
+ status: "failed",
617
+ now: yield* DateTime.now,
618
+ providerInstanceId: run.providerInstanceId,
619
+ itemProviderThreadId: providerThread.id,
620
+ item: {
621
+ type: "error",
622
+ title: "Message is too long",
623
+ failure: makeProviderFailure({
624
+ class: "validation_error",
625
+ message: `Message exceeds ${PROVIDER_SEND_TURN_MAX_INPUT_CHARS.toLocaleString("en-US")} characters after expanding quotes. Shorten it and try again.`,
626
+ }),
627
+ },
628
+ });
629
+ return;
630
+ }
631
if (
632
providerMessage.attachments.length === 0 &&
633
providerMessage.text.trimStart().startsWith("/")
apps/server/src/orchestration-v2/SteeringCompletion.integration.test.ts
+155
@@ -2,6 +2,8 @@ import { assert, it } from "@effect/vitest";
2
import * as TestClock from "effect/testing/TestClock";
3
import {
4
ChatAttachmentId,
5
+ COMPOSER_CONTEXT_TERMINAL_TEXT_MAX_CHARS,
6
+ ComposerContextId,
7
CommandId,
8
EnvironmentId,
9
MessageId,
@@ -12,12 +14,18 @@ import {
14
ProviderInstanceId,
15
ProviderThreadId,
16
ProviderTurnId,
17
+ PROVIDER_SEND_TURN_MAX_INPUT_CHARS,
18
ScheduledTaskId,
19
ThreadId,
20
TurnItemId,
21
type ModelSelection,
22
type OrchestrationV2DomainEvent,
23
} from "@t3tools/contracts";
24
+import {
25
+ expandAssistantCitationsForProvider,
26
+ serializeAssistantCitation,
27
+} from "@t3tools/shared/assistantCitations";
28
+import { projectComposerContextForProvider } from "@t3tools/shared/composerContextReferences";
29
import * as DateTime from "effect/DateTime";
30
import * as Deferred from "effect/Deferred";
31
import * as Effect from "effect/Effect";
@@ -37,6 +45,7 @@ import * as ThreadManagementService from "./ThreadManagementService.ts";
45
import * as ServerSettings from "../serverSettings.ts";
46
import * as SqlitePersistence from "../persistence/Sqlite.ts";
47
import * as CommandReceiptStore from "./CommandReceiptStore.ts";
48
+import { userFacingDispatchErrorMessage } from "./UserFacingErrors.ts";
49
import { checkpointWorkspace } from "@t3tools/provider-testing/replayWorkspace";
50
import * as ProviderAdapter from "@t3tools/provider-core/server/ProviderAdapter";
51
import * as ProviderContinuationRequests from "@t3tools/provider-core/server/ProviderContinuationRequests";
@@ -2189,6 +2198,152 @@ it.effect("keeps a held commentary draft before the steer when turn end flushes
2198
}),
2199
);
2200
2201
+it.effect.each(["auto", "deferred", "promote-edited"] as const)(
2202
+ "rejects expanded steering input before commit: %s",
2203
+ (delivery) =>
2204
+ Effect.scoped(
2205
+ Effect.gen(function* () {
2206
+ const { started, steered, interrupted, layer, startFirstTurn } =
2207
+ yield* nextTurnSelectionHarness(`oversized-steer-${delivery}`, true);
2208
+ yield* Effect.gen(function* () {
2209
+ const orchestrator = yield* Orchestrator.OrchestratorV2;
2210
+ const worker = yield* EffectWorker.OrchestrationEffectWorkerV2;
2211
+ const outbox = yield* EffectOutbox.EffectOutboxV2;
2212
+ const sink = yield* EventSink.EventSinkV2;
2213
+ const threadId = yield* startFirstTurn;
2214
+ const first = started[0]!;
2215
+ const citation = serializeAssistantCitation({
2216
+ version: 1,
2217
+ environmentId: EnvironmentId.make("env"),
2218
+ threadId,
2219
+ messageId: MessageId.make("assistant"),
2220
+ text: "\u0001".repeat(8_000),
2221
+ start: 0,
2222
+ end: 8_000,
2223
+ prefix: "",
2224
+ suffix: "",
2225
+ });
2226
+ const text = `${"x".repeat(80_000)}${citation}`;
2227
+ // Context excerpts are not part of the limit, matching the web composer's check.
2228
+ const largeContextText =
2229
+ "Read [one](t3-context://v1/terminal/one) and [two](t3-context://v1/terminal/two)";
2230
+ const context = {
2231
+ version: 1 as const,
2232
+ records: (["one", "two"] as const).map((id) => ({
2233
+ version: 1 as const,
2234
+ kind: "terminal" as const,
2235
+ contextId: ComposerContextId.make(id),
2236
+ label: id,
2237
+ terminalId: "terminal",
2238
+ terminalLabel: "Terminal",
2239
+ lineStart: 1,
2240
+ lineEnd: 1,
2241
+ text: "y".repeat(COMPOSER_CONTEXT_TERMINAL_TEXT_MAX_CHARS),
2242
+ })),
2243
+ };
2244
+ assert.isBelow(text.length, PROVIDER_SEND_TURN_MAX_INPUT_CHARS);
2245
+ assert.isAbove(
2246
+ expandAssistantCitationsForProvider(text).length,
2247
+ PROVIDER_SEND_TURN_MAX_INPUT_CHARS,
2248
+ );
2249
+ assert.isAbove(
2250
+ projectComposerContextForProvider({
2251
+ text: largeContextText,
2252
+ records: context.records,
2253
+ }).length,
2254
+ PROVIDER_SEND_TURN_MAX_INPUT_CHARS,
2255
+ );
2256
+ if (delivery === "deferred") {
2257
+ const turn = (yield* orchestrator.getThreadProjection(threadId)).providerTurns[0]!;
2258
+ yield* sink.write({
2259
+ events: [
2260
+ {
2261
+ id: EventId.make("turn-not-ready"),
2262
+ type: "provider-turn.updated",
2263
+ threadId,
2264
+ occurredAt: yield* DateTime.now,
2265
+ payload: { ...turn, status: "pending" },
2266
+ },
2267
+ ],
2268
+ });
2269
+ }
2270
+ const commandId = CommandId.make("oversized-steer");
2271
+ let command: Parameters<typeof orchestrator.dispatch>[0] = {
2272
+ type: "message.dispatch",
2273
+ commandId,
2274
+ threadId,
2275
+ messageId: MessageId.make("oversized"),
2276
+ text,
2277
+ attachments: [],
2278
+ dispatchMode: { type: "start_immediately" },
2279
+ deliveryIntent: delivery === "deferred" ? "steer" : "auto",
2280
+ createdBy: "user",
2281
+ creationSource: "mobile",
2282
+ };
2283
+ if (delivery === "promote-edited") {
2284
+ yield* orchestrator.dispatch({
2285
+ ...command,
2286
+ commandId: CommandId.make("queue"),
2287
+ text: "Initially valid queued message",
2288
+ dispatchMode: { type: "queue_after_active" },
2289
+ deliveryIntent: undefined,
2290
+ });
2291
+ const queued = (yield* orchestrator.getThreadProjection(threadId)).runs.find(
2292
+ (run) => run.status === "queued",
2293
+ )!;
2294
+ yield* orchestrator.dispatch({
2295
+ type: "queued-run.edit",
2296
+ commandId: CommandId.make("edit"),
2297
+ threadId,
2298
+ runId: queued.id,
2299
+ text,
2300
+ });
2301
+ command = {
2302
+ type: "queued-message.promote-to-steer",
2303
+ commandId,
2304
+ threadId,
2305
+ queuedRunId: queued.id,
2306
+ targetRunId: first.runId,
2307
+ };
2308
+ }
2309
+ const before = yield* orchestrator.getThreadProjection(threadId);
2310
+ const sequence = yield* orchestrator.getThreadEventSequence(threadId);
2311
+ const error = yield* orchestrator.dispatch(command).pipe(Effect.flip);
2312
+ assert.instanceOf(error, Orchestrator.OrchestratorCommandRejectedError);
2313
+ assert.equal(
2314
+ userFacingDispatchErrorMessage(error),
2315
+ "Message exceeds 120,000 characters after expanding quotes. Shorten it and try again.",
2316
+ );
2317
+ assert.deepEqual(yield* outbox.listByCommandId(commandId), []);
2318
+ assert.deepEqual(yield* sink.readByCommandId({ commandId }).pipe(Stream.runCollect), []);
2319
+ yield* worker.drain();
2320
+ assert.equal(yield* orchestrator.getThreadEventSequence(threadId), sequence);
2321
+ assert.deepEqual(yield* orchestrator.getThreadProjection(threadId), before);
2322
+ assert.deepEqual(steered, []);
2323
+ assert.deepEqual(interrupted, []);
2324
+ assert.lengthOf(started, 1);
2325
+ if (delivery === "auto") {
2326
+ yield* orchestrator.dispatch({
2327
+ type: "message.dispatch",
2328
+ commandId: CommandId.make("large-context-steer"),
2329
+ threadId,
2330
+ messageId: MessageId.make("large-context"),
2331
+ text: largeContextText,
2332
+ context,
2333
+ attachments: [],
2334
+ dispatchMode: { type: "start_immediately" },
2335
+ deliveryIntent: "auto",
2336
+ createdBy: "user",
2337
+ creationSource: "mobile",
2338
+ });
2339
+ yield* worker.drain();
2340
+ assert.lengthOf(steered, 1);
2341
+ }
2342
+ }).pipe(Effect.provide(layer));
2343
+ }),
2344
+ ),
2345
+);
2346
+
2347
it.effect("steers a promoted queued message with the selection it was queued with", () =>
2348
Effect.gen(function* () {
2349
const { started, steered, layer, startFirstTurn } = yield* nextTurnSelectionHarness(
apps/web/src/lib/assistantTextSelection.ts
+12
-89
@@ -1,14 +1,18 @@
1
-import { ASSISTANT_CITATION_CONTEXT_LENGTH, type AssistantCitation } from "@t3tools/contracts";
1
+import { type AssistantCitation } from "@t3tools/contracts";
2
3
import { mathWrapperOf } from "../markdown-clipboard";
4
5
-export type AssistantTextSelector = {
6
- readonly text: string;
7
- readonly start: number;
8
- readonly end: number;
9
- readonly prefix: string;
10
- readonly suffix: string;
11
-};
5
+export {
6
+ createAssistantTextSelector,
7
+ findAssistantCitationText,
8
+} from "@t3tools/shared/assistantCitations";
9
+import {
10
+ createAssistantTextSelector,
11
+ findAssistantCitationText,
12
+ splitsSurrogatePair,
13
+ type AssistantTextSelector,
14
+} from "@t3tools/shared/assistantCitations";
15
+export type { AssistantTextSelector } from "@t3tools/shared/assistantCitations";
16
17
export type AssistantCitationSourceAnchor = {
18
source: HTMLElement;
@@ -39,87 +43,6 @@ const EXCLUDED_SELECTOR = `${CONTROL_SELECTOR}, [hidden], [aria-hidden=true], sc
43
const BLOCK_SELECTOR =
44
"address, article, aside, blockquote, dd, div, dl, dt, figcaption, figure, footer, h1, h2, h3, h4, h5, h6, header, hr, li, main, nav, ol, p, pre, section, table, td, th, tr, ul";
45
42
-function normalizeWhitespace(text: string): string {
43
- return text.replace(/\s+/g, " ");
44
-}
45
-
46
-function splitsSurrogatePair(text: string, offset: number): boolean {
47
- const before = text.charCodeAt(offset - 1);
48
- const after = text.charCodeAt(offset);
49
- return before >= 0xd800 && before <= 0xdbff && after >= 0xdc00 && after <= 0xdfff;
50
-}
51
-
52
-export function createAssistantTextSelector(
53
- text: string,
54
- rawStart: number,
55
- rawEnd: number,
56
-): AssistantTextSelector | null {
57
- const quote = text.slice(rawStart, rawEnd);
58
- if (quote.trim().length === 0) return null;
59
-
60
- const normalized = normalizeWhitespace(text);
61
- let start = normalizeWhitespace(text.slice(0, rawStart)).length;
62
- if (rawStart > 0 && /\s/.test(text[rawStart - 1]!) && /\s/.test(text[rawStart]!)) {
63
- start -= 1;
64
- }
65
- const end = normalizeWhitespace(text.slice(0, rawEnd)).length;
66
- let prefixStart = Math.max(0, start - ASSISTANT_CITATION_CONTEXT_LENGTH);
67
- let suffixEnd = Math.min(normalized.length, end + ASSISTANT_CITATION_CONTEXT_LENGTH);
68
- // A split pair becomes a replacement character when the context enters a URL.
69
- if (splitsSurrogatePair(normalized, prefixStart)) prefixStart += 1;
70
- if (splitsSurrogatePair(normalized, suffixEnd)) suffixEnd -= 1;
71
- return {
72
- text: quote,
73
- start,
74
- end,
75
- prefix: normalized.slice(prefixStart, start),
76
- suffix: normalized.slice(end, suffixEnd),
77
- };
78
-}
79
-
80
-/** Offsets use normalized UTF-16 units. Saved offsets may drift, so they cannot break context ties. */
81
-export function findAssistantCitationText(
82
- text: string,
83
- selector: AssistantTextSelector,
84
-): { start: number; end: number } | null {
85
- const normalized = normalizeWhitespace(text);
86
- const quote = normalizeWhitespace(selector.text);
87
- if (quote.trim().length === 0) return null;
88
-
89
- const prefix = normalizeWhitespace(selector.prefix);
90
- const suffix = normalizeWhitespace(selector.suffix);
91
- const matchesContext = (start: number, end: number) =>
92
- normalized.slice(Math.max(0, start - prefix.length), start) === prefix &&
93
- normalized.slice(end, end + suffix.length) === suffix;
94
-
95
- let match =
96
- Number.isSafeInteger(selector.start) &&
97
- Number.isSafeInteger(selector.end) &&
98
- selector.start >= 0 &&
99
- selector.end - selector.start === quote.length &&
100
- normalized.slice(selector.start, selector.end) === quote &&
101
- matchesContext(selector.start, selector.end)
102
- ? { start: selector.start, end: selector.end }
103
- : null;
104
- let onlyQuote: { start: number; end: number } | null = null;
105
- let quoteCount = 0;
106
-
107
- for (
108
- let start = normalized.indexOf(quote);
109
- start !== -1;
110
- start = normalized.indexOf(quote, start + 1)
111
- ) {
112
- const end = start + quote.length;
113
- quoteCount += 1;
114
- onlyQuote = { start, end };
115
- if (!matchesContext(start, end)) continue;
116
- if (match !== null && match.start !== start) return null;
117
- match = { start, end };
118
- }
119
-
120
- return match ?? (quoteCount === 1 ? onlyQuote : null);
121
-}
122
-
46
/** A text node, or a whole rendered formula standing for its TeX. */
47
type TextChunk = { node: Text | Element; start: number; end: number };
48
docs/internals/assistant-citations.md
+6
-1
@@ -12,7 +12,12 @@ refer to rendered text after whitespace normalization, measured in UTF-16 units.
12
They cannot be applied to raw Markdown. The original excerpt keeps its whitespace;
13
normalization is only for locating it. Repeated text needs an unambiguous context
14
match, even if one occurrence still sits at the saved offsets. Guessing could
15
-highlight the wrong claim.
15
+highlight the wrong claim. Mobile's native selection reports only text, so when a
16
+passage repeats within its block the user picks the occurrence, and mobile saves
17
+that occurrence's offsets and context like any other selector.
18
+
19
+Released servers and clients reject a citation link with an unknown query key and
20
+send or show it unexpanded. Adding a field to the link needs a new link version.
21
22
Navigation owns the highlight's lifetime across virtual-row remounts. The source
23
row must be fetched, unfolded, mounted, and measured before quote positioning
docs/user/composer.md
+6
-2
@@ -142,8 +142,12 @@ delete it like other inline context. Copying, reloading, and restoring a
142
with its quote, and sending tells the agent which words were quoted and which comment you wrote.
143
The quoted text and comment count toward the message limit.
144
145
-Mobile displays saved quotes and comments, but does not create citations or
146
-navigate to their sources.
145
+On mobile, long-press an assistant response, adjust the text selection, and choose
146
+**Cite** to insert a quote at the composer cursor. If the passage appears more than
147
+once in that section, choose its source occurrence. Select more surrounding text
148
+if a short passage appears too often. Tap a quote in a draft to add
149
+or edit its comment, or to remove it. To open the source message, tap a quote in
150
+a draft or sent message, then choose **Go to message**.
151
152
## Recall a sent prompt
153
packages/shared/src/assistantCitations.ts
+89
@@ -198,3 +198,92 @@ export function renderAssistantCitationsAsText(prompt: string): string {
198
}
199
return text + prompt.slice(cursor);
200
}
201
+
202
+export type AssistantTextSelector = {
203
+ readonly text: string;
204
+ readonly start: number;
205
+ readonly end: number;
206
+ readonly prefix: string;
207
+ readonly suffix: string;
208
+};
209
+
210
+function normalizeWhitespace(text: string): string {
211
+ return text.replace(/\s+/g, " ");
212
+}
213
+
214
+export function splitsSurrogatePair(text: string, offset: number): boolean {
215
+ const before = text.charCodeAt(offset - 1);
216
+ const after = text.charCodeAt(offset);
217
+ return before >= 0xd800 && before <= 0xdbff && after >= 0xdc00 && after <= 0xdfff;
218
+}
219
+
220
+export function createAssistantTextSelector(
221
+ text: string,
222
+ rawStart: number,
223
+ rawEnd: number,
224
+): AssistantTextSelector | null {
225
+ const quote = text.slice(rawStart, rawEnd);
226
+ if (quote.trim().length === 0) return null;
227
+
228
+ const normalized = normalizeWhitespace(text);
229
+ let start = normalizeWhitespace(text.slice(0, rawStart)).length;
230
+ if (rawStart > 0 && /\s/.test(text[rawStart - 1]!) && /\s/.test(text[rawStart]!)) {
231
+ start -= 1;
232
+ }
233
+ const end = normalizeWhitespace(text.slice(0, rawEnd)).length;
234
+ let prefixStart = Math.max(0, start - ASSISTANT_CITATION_CONTEXT_LENGTH);
235
+ let suffixEnd = Math.min(normalized.length, end + ASSISTANT_CITATION_CONTEXT_LENGTH);
236
+ // A split pair becomes a replacement character when the context enters a URL.
237
+ if (splitsSurrogatePair(normalized, prefixStart)) prefixStart += 1;
238
+ if (splitsSurrogatePair(normalized, suffixEnd)) suffixEnd -= 1;
239
+ return {
240
+ text: quote,
241
+ start,
242
+ end,
243
+ prefix: normalized.slice(prefixStart, start),
244
+ suffix: normalized.slice(end, suffixEnd),
245
+ };
246
+}
247
+
248
+/** Offsets use normalized UTF-16 units. Saved offsets may drift, so they cannot break context ties. */
249
+export function findAssistantCitationText(
250
+ text: string,
251
+ selector: AssistantTextSelector,
252
+): { start: number; end: number } | null {
253
+ const normalized = normalizeWhitespace(text);
254
+ const quote = normalizeWhitespace(selector.text);
255
+ if (quote.trim().length === 0) return null;
256
+
257
+ const prefix = normalizeWhitespace(selector.prefix);
258
+ const suffix = normalizeWhitespace(selector.suffix);
259
+ const matchesContext = (start: number, end: number) =>
260
+ normalized.slice(Math.max(0, start - prefix.length), start) === prefix &&
261
+ normalized.slice(end, end + suffix.length) === suffix;
262
+
263
+ let match =
264
+ Number.isSafeInteger(selector.start) &&
265
+ Number.isSafeInteger(selector.end) &&
266
+ selector.start >= 0 &&
267
+ selector.end - selector.start === quote.length &&
268
+ normalized.slice(selector.start, selector.end) === quote &&
269
+ matchesContext(selector.start, selector.end)
270
+ ? { start: selector.start, end: selector.end }
271
+ : null;
272
+ let onlyQuote: { start: number; end: number } | null = null;
273
+ let quoteCount = 0;
274
+
275
+ for (
276
+ let start = normalized.indexOf(quote);
277
+ start !== -1;
278
+ start = normalized.indexOf(quote, start + 1)
279
+ ) {
280
+ const end = start + quote.length;
281
+ quoteCount += 1;
282
+ onlyQuote = { start, end };
283
+ if (!matchesContext(start, end)) continue;
284
+ if (match !== null && match.start !== start) return null;
285
+ match = { start, end };
286
+ }
287
+
288
+ return match ?? (quoteCount === 1 ? onlyQuote : null);
289
+}