Skip to content

Commit f3e7d04

Browse files
ElliotDrelclaude
andcommitted
refactor(web): style the marker highlight in feature CSS and share the citation prefix
Co-Authored-By: Claude Opus 5.5 <[email protected]>
1 parent 45fd664 commit f3e7d04

3 files changed

Lines changed: 9 additions & 2 deletions

File tree

‎apps/web/src/components/chat/AssistantCitationMarkers.tsx‎

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import { ASSISTANT_CITATION_MARKDOWN_PREFIX } from "@t3tools/shared/assistantCitations";
12
import { Badge } from "~/components/ui/badge";
23
import { useComposerDraftStore, type ComposerThreadTarget } from "~/composerDraftStore";
34
import { draftCitationMarkers } from "./assistantCitationMarkers.logic";
@@ -34,7 +35,7 @@ export function AssistantCitationMarkers({
3435
onOpen: (key: string, anchor: AssistantCitationSourceAnchor) => void;
3536
}) {
3637
const citationJson = JSON.stringify(
37-
showingDraft && prompt.includes("[Assistant quote](t3-citation://v1/")
38+
showingDraft && prompt.includes(ASSISTANT_CITATION_MARKDOWN_PREFIX)
3839
? draftCitationMarkers(buildDocJson(prompt, () => null, { styling: richTextEnabled }))
3940
: [],
4041
);
@@ -198,7 +199,7 @@ function CitationMarkers({
198199
onBlur={updateCitationHighlight}
199200
render={<button type="button" />}
200201
hidden={!viewport}
201-
className="pointer-events-auto absolute data-[citation-highlight]:ring-2 data-[citation-highlight]:ring-ring data-[citation-highlight]:ring-offset-2 data-[citation-highlight]:ring-offset-background"
202+
className="pointer-events-auto absolute"
202203
aria-label={`Edit citation ${number} comment`}
203204
onPointerDown={(event) => event.preventDefault()}
204205
onClick={() => {

‎apps/web/src/index.css‎

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2549,6 +2549,11 @@ code {
25492549
[data-has-draft-citations] {
25502550
--draft-citation-gutter: 2rem;
25512551
}
2552+
[data-citation-marker-key][data-citation-highlight] {
2553+
box-shadow:
2554+
0 0 0 2px var(--background),
2555+
0 0 0 4px var(--ring);
2556+
}
25522557
.chat-scroll-to-bottom,
25532558
.chat-banner-lane {
25542559
inset-inline-start: var(--chat-lane-inset-start, 0px);

‎packages/shared/src/assistantCitations.ts‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ import * as Schema from "effect/Schema";
88

99
const CITATION_PROTOCOL = "t3-citation:";
1010
const CITATION_HREF_PREFIX = `${CITATION_PROTOCOL}//v1/`;
11+
export const ASSISTANT_CITATION_MARKDOWN_PREFIX = `[Assistant quote](${CITATION_HREF_PREFIX}`;
1112
// Percent encoding needs up to nine characters per UTF-16 code unit; 16k covers selectors.
1213
const MAX_CITATION_HREF_LENGTH =
1314
9 * (ASSISTANT_CITATION_MAX_TEXT_LENGTH + ASSISTANT_CITATION_MAX_COMMENT_LENGTH) + 16_000;

0 commit comments

Comments
 (0)