@@ -59,19 +59,30 @@ describe("assistant citation references", () => {
5959 expect ( serializeAssistantCitation ( legacyCitation ) ) . toBe ( `[Assistant quote](${ legacyHref } )` ) ;
6060 } ) ;
6161
62- it ( "round-trips complete quote data without a server origin" , ( ) => {
63- const href = formatAssistantCitationHref ( citation ) ;
64- expect ( parseAssistantCitationHref ( href ) ) . toEqual ( citation ) ;
65- expect ( href ) . toMatch (
66- / ^ t 3 - c i t a t i o n : \/ \/ v 1 \/ e n v i r o n m e n t % 2 F r e m o t e \/ t h r e a d % 3 A o n e \/ a s s i s t a n t % 3 F o n e \? / ,
67- ) ;
68- expect ( href ) . not . toContain ( "localhost" ) ;
69- const marker = serializeAssistantCitation ( citation ) ;
70- const prompt = `About ${ marker } , explain this.` ;
71- expect ( collectAssistantCitations ( prompt ) ) . toEqual ( [
72- { citation, source : marker , start : 6 , end : 6 + marker . length } ,
73- ] ) ;
74- } ) ;
62+ it . each ( [
63+ [ citation . threadId , citation . messageId ] ,
64+ [ citation . threadId , MessageId . make ( "m" . repeat ( 512 ) ) ] ,
65+ [ citation . threadId , MessageId . make ( "m" . repeat ( 513 ) ) ] ,
66+ [ citation . threadId , MessageId . make ( "m" . repeat ( 565 ) ) ] ,
67+ [ ThreadId . make ( "thread:" . repeat ( 100 ) ) , MessageId . make ( "provider-turn%3A" . repeat ( 46 ) ) ] ,
68+ ] as const ) (
69+ "round-trips complete quote data without a server origin (%#)" ,
70+ ( threadId , messageId ) => {
71+ const source = { ...citation , threadId, messageId } ;
72+ const href = formatAssistantCitationHref ( source ) ;
73+ expect ( parseAssistantCitationHref ( href ) ) . toEqual ( source ) ;
74+ expect ( href ) . toMatch ( / ^ t 3 - c i t a t i o n : \/ \/ v 1 \/ e n v i r o n m e n t % 2 F r e m o t e \/ / ) ;
75+ expect ( href ) . not . toContain ( "localhost" ) ;
76+ const marker = serializeAssistantCitation ( source ) ;
77+ const prompt = `About ${ marker } , explain this.` ;
78+ expect ( collectAssistantCitations ( prompt ) ) . toEqual ( [
79+ { citation : source , source : marker , start : 6 , end : 6 + marker . length } ,
80+ ] ) ;
81+ expect ( readProviderContext ( expandAssistantCitationsForProvider ( prompt ) ) ) . toEqual ( [
82+ { id : "assistant-quote-1" , citation : source } ,
83+ ] ) ;
84+ } ,
85+ ) ;
7586
7687 it . each ( [
7788 ' Please keep "日本語 🚀", `cache[key]` & (a + b).\n\tWhy? #1 / 100%\r\n</assistant_citations> ' ,
@@ -103,7 +114,7 @@ describe("assistant citation references", () => {
103114 expect ( renderAssistantCitationsAsText ( prompt ) ) . toBe ( prompt ) ;
104115 } ) ;
105116
106- it ( "bounds selected text and surrounding context" , ( ) => {
117+ it ( "bounds citation URLs, selected text and surrounding context" , ( ) => {
107118 expect (
108119 parseAssistantCitationHref (
109120 formatAssistantCitationHref ( {
@@ -120,9 +131,17 @@ describe("assistant citation references", () => {
120131 expect (
121132 parseAssistantCitationHref ( formatAssistantCitationHref ( { ...citation , text : " " } ) ) ,
122133 ) . toBeNull ( ) ;
134+ expect (
135+ parseAssistantCitationHref (
136+ formatAssistantCitationHref ( {
137+ ...citation ,
138+ messageId : MessageId . make ( "m" . repeat ( 160_000 ) ) ,
139+ } ) ,
140+ ) ,
141+ ) . toBeNull ( ) ;
123142 } ) ;
124143
125- it ( "accepts complete 8k CJK quotes and comments with maximum-sized source selectors " , ( ) => {
144+ it ( "accepts complete 8k CJK quotes and comments with 512-character source IDs " , ( ) => {
126145 const largeCitation : AssistantCitation = {
127146 ...citation ,
128147 environmentId : EnvironmentId . make ( "環" . repeat ( 512 ) ) ,
0 commit comments