1# Assistant citations
2
3Citations carry the selected excerpt and source identity in ordinary message text.
4Drafts, clipboard copies, stashes, and sent messages keep that representation
5without a separate citation store. The saved quote remains usable when its source
6disappears or changes. The [shared format](../../packages/shared/src/assistantCitations.ts) uses
7stable environment IDs without a browser origin, so moving between local, remote,
8and tunnel connections does not change a citation's identity.
9
10Source navigation is best effort. [Text selectors](../../apps/web/src/lib/assistantTextSelection.ts)
11refer to rendered text after whitespace normalization, measured in UTF-16 units.
12They cannot be applied to raw Markdown. The original excerpt keeps its whitespace;
13normalization is only for locating it. Repeated text needs an unambiguous context
14match, even if one occurrence still sits at the saved offsets. Guessing could
15highlight the wrong claim.
16
17Navigation owns the highlight's lifetime across virtual-row remounts. The source
18row must be fetched, unfolded, mounted, and measured before quote positioning
19takes over from normal timeline scrolling. Remounting must not revive a dismissed
20highlight. The [navigation hash](../../apps/web/src/lib/assistantCitationNavigation.ts)
21uses base64url because router normalization otherwise decodes whitespace and
22source IDs inside the citation URI.
23
24Expand citations with the [shared formatter](../../packages/shared/src/assistantCitations.ts)
25before dispatch to a provider adapter. Send the saved excerpt without looking up
26the source, distinguish quoted reference material from the user's comment, and
27leave persisted messages in their original form. Input limits apply after
28expansion as well as before it. A draft that fits as encoded links can exceed the
29provider limit once expanded.