11/**
2- * End-to-end: a recognized skill/agent name typed into the real prompt
3- * widget paints orange; a lookalike that merely contains a recognized name
4- * does not.
2+ * End-to-end: a leading `/command` or `@mention` typed into the real prompt
3+ * widget paints orange; bare skill/agent words and mid-prose slashes do not.
54 */
65import { describe , expect , test } from "bun:test"
76import { RGBA } from "@opentui/core"
@@ -26,8 +25,7 @@ function withShell(
2625 run : "idle" ,
2726 } )
2827 setPromptRecognitionSource ( shell , ( ) => ( {
29- skillNames : [ "brand review" ] ,
30- agentNames : [ "emil" , "draper" ] ,
28+ commandNames : [ "implement" , "review" , "improve" , "linear-create" ] ,
3129 } ) )
3230 try {
3331 await fn ( shell , h )
@@ -55,40 +53,50 @@ function spansFor(h: Harness, text: string): { text: string; fg: RGBA }[] {
5553}
5654
5755describe ( "prompt recognition highlighting" , ( ) => {
58- test ( "a recognized agent name paints in the action color" , async ( ) => {
56+ test ( "a leading slash command paints in the action color" , async ( ) => {
5957 await withShell ( async ( shell , h ) => {
60- await compose ( shell , h , "ask emil to review " )
61- const spans = spansFor ( h , "emil " )
58+ await compose ( shell , h , "/implement " )
59+ const spans = spansFor ( h , "/implement " )
6260 expect ( spans . length ) . toBeGreaterThan ( 0 )
6361 expect ( spans . some ( ( s ) => s . fg . equals ( ACTION_FG ) ) ) . toBe ( true )
6462 } )
6563 } )
6664
67- test ( "a recognized multi-word skill name paints in the action color" , async ( ) => {
65+ test ( "an @mention paints in the action color" , async ( ) => {
6866 await withShell ( async ( shell , h ) => {
69- await compose ( shell , h , "ask draper to run a brand review" )
70- const spans = spansFor ( h , "brand review " )
67+ await compose ( shell , h , "ask @emil to review" )
68+ const spans = spansFor ( h , "@emil " )
7169 expect ( spans . length ) . toBeGreaterThan ( 0 )
7270 expect ( spans . some ( ( s ) => s . fg . equals ( ACTION_FG ) ) ) . toBe ( true )
7371 } )
7472 } )
7573
76- test ( "a lookalike that is not a recognized name stays unstyled" , async ( ) => {
74+ test ( "bare words stay unstyled" , async ( ) => {
7775 await withShell ( async ( shell , h ) => {
78- await compose ( shell , h , "emily is not emil" )
79- const spans = spansFor ( h , "emily" )
76+ for ( const word of [ "emil" , "implement" , "brand review" , "improve" , "linear-create" ] ) {
77+ await compose ( shell , h , word )
78+ const spans = spansFor ( h , word )
79+ expect ( spans . length ) . toBeGreaterThan ( 0 )
80+ expect ( spans . every ( ( s ) => ! s . fg . equals ( ACTION_FG ) ) ) . toBe ( true )
81+ }
82+ } )
83+ } )
84+
85+ test ( "a mid-prose slash command stays unstyled" , async ( ) => {
86+ await withShell ( async ( shell , h ) => {
87+ await compose ( shell , h , "please /review this" )
88+ const spans = spansFor ( h , "/review" )
8089 expect ( spans . length ) . toBeGreaterThan ( 0 )
8190 expect ( spans . every ( ( s ) => ! s . fg . equals ( ACTION_FG ) ) ) . toBe ( true )
8291 } )
8392 } )
8493
85- test ( "a mixed line highlights only the recognized tokens " , async ( ) => {
94+ test ( "a lookalike that is not a mention stays unstyled " , async ( ) => {
8695 await withShell ( async ( shell , h ) => {
87- await compose ( shell , h , "emily asked emil and draper for a brand review" )
88- expect ( spansFor ( h , "emily" ) . every ( ( s ) => ! s . fg . equals ( ACTION_FG ) ) ) . toBe ( true )
89- expect ( spansFor ( h , "emil" ) . some ( ( s ) => s . fg . equals ( ACTION_FG ) ) ) . toBe ( true )
90- expect ( spansFor ( h , "draper" ) . some ( ( s ) => s . fg . equals ( ACTION_FG ) ) ) . toBe ( true )
91- expect ( spansFor ( h , "brand review" ) . some ( ( s ) => s . fg . equals ( ACTION_FG ) ) ) . toBe ( true )
96+ await compose ( shell , h , "emily is not emil" )
97+ const spans = spansFor ( h , "emily" )
98+ expect ( spans . length ) . toBeGreaterThan ( 0 )
99+ expect ( spans . every ( ( s ) => ! s . fg . equals ( ACTION_FG ) ) ) . toBe ( true )
92100 } )
93101 } )
94102} )
0 commit comments