@@ -25,64 +25,35 @@ function forward(position: ComposerPromptHistoryPosition | null, currentPrompt:
2525
2626describe ( "recallableComposerPrompt" , ( ) => {
2727 it . each ( [
28- "Render <preview_annotation>" ,
29- "Render\n<preview_annotation>\nhere" ,
30- "Render <preview_annotation>" ,
31- ] ) ( "strips an annotation whose comment contains a literal opening tag: %s" , ( comment ) => {
32- expect (
33- recallableComposerPrompt (
34- `Prompt\n<preview_annotation>\nComment: ${ comment } \n</preview_annotation>` ,
35- ) ,
36- ) . toBe ( "Prompt" ) ;
37- } ) ;
38-
39- it ( "preserves a malformed annotation containing a nested opening tag" , ( ) => {
40- const text =
41- "Prompt\n<preview_annotation>\nouter literal\n<preview_annotation>\ninner\n</preview_annotation>" ;
28+ "Ultrathink:\nKeep this prefix in my example" ,
29+ 'Keep this example\n<review_comment filePath="a.ts">literal</review_comment>' ,
30+ " Preserve surrounding whitespace\n" ,
31+ "PLEASE IMPLEMENT THIS PLAN:\nThis is a literal example" ,
32+ ] ) ( "preserves authored text when its provenance is unknown: %s" , ( text ) => {
4233 expect ( recallableComposerPrompt ( text ) ) . toBe ( text ) ;
4334 } ) ;
44- it ( "does not strip a terminal label embedded in ordinary prose" , ( ) => {
35+ it ( "uses origin metadata and skips generated-only messages" , ( ) => {
36+ const text = "Ultrathink:\nKeep this prefix" ;
4537 expect (
46- recallableComposerPrompt (
47- "email@build:7\n<terminal_context>\n- Build line 7:\n output\n</terminal_context>" ,
48- ) ,
49- ) . toBe ( "email@build:7" ) ;
50- } ) ;
51- it ( "strips legacy send-time context blocks and the ultrathink prefix" , ( ) => {
52- const sent =
53- "Ultrathink:\nInvestigate this\n\n<terminal_context>\n- Terminal 1 lines 12-13:\n 12 | git status\n 13 | On branch main\n</terminal_context>\n\n<element_context>\n- <button>:\n url: https://example.com\n</element_context>" ;
54- expect ( recallableComposerPrompt ( sent ) ) . toBe ( "Investigate this" ) ;
55- } ) ;
56-
57- it . each ( [
58- [ "Look at @terminal-1:4 please" , "Look at please" ] ,
59- [
60- "@terminal-1:4 typed twice: @terminal-1:4\n indented code" ,
61- "typed twice: @terminal-1:4\n indented code" ,
62- ] ,
63- [
64- "see @terminal-1:40 and @terminal-1:4-12 then @terminal-1:4" ,
65- "see @terminal-1:40 and @terminal-1:4-12 then" ,
66- ] ,
67- ] ) ( "removes only the matching legacy terminal label from %s" , ( typed , expected ) => {
68- const sent =
69- typed + "\n\n<terminal_context>\n- Terminal 1 line 4:\n 4 | ls\n</terminal_context>" ;
70- expect ( recallableComposerPrompt ( sent ) ) . toBe ( expected ) ;
71- } ) ;
72-
73- it ( "strips only review comments appended at the end" , ( ) => {
74- const block = '<review_comment filePath="src/app.ts">Keep this configurable.</review_comment>' ;
75- expect ( recallableComposerPrompt ( "Please update this.\n\n" + block ) ) . toBe ( "Please update this." ) ;
76- const midPrompt = "Before\n\n" + block + "\n\nAfter" ;
77- expect ( recallableComposerPrompt ( midPrompt ) ) . toBe ( midPrompt ) ;
78- expect ( recallableComposerPrompt ( midPrompt + "\n\n" + block ) ) . toBe ( midPrompt ) ;
79- } ) ;
80-
81- it ( "removes canonical references without restoring dangling chips" , ( ) => {
82- const sent =
83- "Look at [Terminal](t3-context://v1/terminal/term-1) please\n indented code\n" ;
84- expect ( recallableComposerPrompt ( sent ) ) . toBe ( "Look at please\n indented code" ) ;
85- expect ( recallableComposerPrompt ( "" ) ) . toBe ( "" ) ;
38+ buildComposerPromptHistoryEntries ( [
39+ { id : "literal" , role : "user" , text } ,
40+ {
41+ id : "generated" ,
42+ role : "user" ,
43+ text,
44+ context : { version : 1 , records : [ ] , composerRecall : [ 12 , text . length ] } ,
45+ } ,
46+ {
47+ id : "plan" ,
48+ role : "user" ,
49+ text : "PLEASE IMPLEMENT THIS PLAN:\nplan" ,
50+ context : { version : 1 , records : [ ] , composerRecall : "" } ,
51+ } ,
52+ ] ) ,
53+ ) . toEqual ( [
54+ { id : "literal" , prompt : text } ,
55+ { id : "generated" , prompt : "Keep this prefix" } ,
56+ ] ) ;
8657 } ) ;
8758} ) ;
8859
0 commit comments