The best way to control Claude Code, Codex and more from any computer or phone
Mirrored from https://github.com/Camo67/t3code.git
Synced Nov 21, 08:30 UTC
fix(web): minimap previews show cited assistant text, not the raw link (#38250)
Co-authored-by: Julius Marminge <julius0216@outlook.com>
nikalezah committed
Nov 17, 2026 at 23:27 UTC
68108be900aac53cad3ae90d80d3225bca13f513
2 files changed
+53
-10
apps/web/src/components/chat/timelineMinimapItems.test.ts
+35
-2
@@ -1,6 +1,11 @@
1
import { describe, expect, it } from "vite-plus/test";
2
-import { MessageId } from "@t3tools/contracts";
3
-import { ATTACHMENT_ONLY_BOOTSTRAP_PROMPT } from "@t3tools/shared/composerContextReferences";
2
+import { EnvironmentId, MessageId, ThreadId } from "@t3tools/contracts";
3
+import { serializeAssistantCitation } from "@t3tools/shared/assistantCitations";
4
+import {
5
+ ATTACHMENT_ONLY_BOOTSTRAP_PROMPT,
6
+ formatComposerContextReference,
7
+ toComposerContextId,
8
+} from "@t3tools/shared/composerContextReferences";
9
10
import { deriveTimelineMinimapItems, resolveTimelineMinimapPreview } from "./timelineMinimapItems";
11
@@ -45,4 +50,32 @@ describe("resolveTimelineMinimapPreview", () => {
50
});
51
expect(preview?.assistantText).toBe("Started a thread and Fix CI.");
52
});
53
+
54
+ it("previews a quote, a context chip and a file link in the user's message as their text", () => {
55
+ const quote = serializeAssistantCitation({
56
+ version: 1,
57
+ environmentId: EnvironmentId.make("env-1"),
58
+ threadId: ThreadId.make("thread-1"),
59
+ messageId: MessageId.make("assistant-1"),
60
+ text: "The cache misses on a cold start.",
61
+ start: 0,
62
+ end: 33,
63
+ prefix: "",
64
+ suffix: "",
65
+ });
66
+ const file = formatComposerContextReference({
67
+ kind: "file",
68
+ contextId: toComposerContextId("readme"),
69
+ label: "README.md",
70
+ });
71
+ const preview = resolveTimelineMinimapPreview({
72
+ id: "turn-1",
73
+ rowIndex: 0,
74
+ userText: `${quote}\nWhere do ${file} and [math.ts](src/math.ts) cover this?`,
75
+ assistantText: null,
76
+ });
77
+ expect(preview?.userText).toBe(
78
+ "The cache misses on a cold start. Where do README.md and math.ts cover this?",
79
+ );
80
+ });
81
});
apps/web/src/components/chat/timelineMinimapItems.ts
+18
-8
@@ -1,5 +1,9 @@
1
+import { assistantCitationsToPlainText } from "@t3tools/shared/assistantCitations";
2
import { parseThreadLinkHref } from "@t3tools/shared/threadLinks";
2
-import { isAttachmentOnlyBootstrapPrompt } from "@t3tools/shared/composerContextReferences";
3
+import {
4
+ isAttachmentOnlyBootstrapPrompt,
5
+ replaceComposerContextReferences,
6
+} from "@t3tools/shared/composerContextReferences";
7
import type { Nodes } from "mdast";
8
import remarkGfm from "remark-gfm";
9
import remarkParse from "remark-parse";
@@ -94,8 +98,12 @@ export function markdownPlainText(markdown: string): string {
98
return markdownNodeText(markdownPreviewParser.parse(markdown)).replace(/\s+/g, " ").trim();
99
}
100
97
-function compactMinimapPreview(text: string | null | undefined) {
98
- const compact = text?.replace(/\s+/g, " ").trim() ?? "";
101
+// The tooltip shows a few lines; bound parsing work for long messages and streaming responses.
102
+function markdownMinimapPreview(markdown: string | null) {
103
+ if (markdown === null) return null;
104
+ const compact = markdownNodeText(markdownPreviewParser.parse(markdown.slice(0, 1_500)))
105
+ .replace(/\s+/g, " ")
106
+ .trim();
107
return compact.length > 0 ? compact : null;
108
}
109
@@ -106,12 +114,14 @@ export function resolveTimelineMinimapPreview(
114
? null
115
: {
116
...item,
109
- userText: compactMinimapPreview(item.userText),
110
- // The tooltip shows three lines; bound parsing work while long responses stream.
111
- assistantText: compactMinimapPreview(
112
- item.assistantText === null
117
+ // Before markdown parsing, which would reduce a citation link to "Assistant quote".
118
+ userText: markdownMinimapPreview(
119
+ item.userText === null
120
? null
114
- : markdownNodeText(markdownPreviewParser.parse(item.assistantText.slice(0, 1_500))),
121
+ : assistantCitationsToPlainText(
122
+ replaceComposerContextReferences(item.userText, (reference) => reference.label),
123
+ ),
124
),
125
+ assistantText: markdownMinimapPreview(item.assistantText),
126
};
127
}