@@ -8,7 +8,14 @@ import { Controller } from "@hotwired/stimulus";
88 * pointer until it tags it back. Messages arrive already translated.
99 */
1010export default class extends Controller {
11- static targets = [ "bubble" , "text" , "cta" , "play" , "finish" ] ;
11+ static targets = [
12+ "bubble" ,
13+ "text" ,
14+ "cta" ,
15+ "play" ,
16+ "finish" ,
17+ "finishContact" ,
18+ ] ;
1219
1320 static values = {
1421 messages : { type : Array , default : [ ] } ,
@@ -20,6 +27,7 @@ export default class extends Controller {
2027 giveup : String ,
2128 escaped : String ,
2229 finishTexts : { type : Array , default : [ ] } ,
30+ finishContactTexts : { type : Array , default : [ ] } ,
2331 enabled : { type : Boolean , default : true } ,
2432 farewell : String ,
2533 welcome : String ,
@@ -193,13 +201,16 @@ export default class extends Controller {
193201 this . scheduleNext ( this . intervalValue ) ;
194202 }
195203
196- // Clicking the avatar only does something during the play-catch game; a plain
197- // idle click is intentionally inert (no message, no animation) .
204+ // Clicking the avatar plays catch mid-game; an idle click pops a fresh
205+ // message and resets the cadence so the next auto- message isn't right behind .
198206 poke ( ) {
199207 if ( "invited" === this . mode ) {
200208 this . startFlee ( ) ;
201209 } else if ( "flee" === this . mode ) {
202210 this . caught ( ) ;
211+ } else if ( "idle" === this . mode ) {
212+ this . speak ( ) ;
213+ this . scheduleNext ( this . intervalValue ) ;
203214 }
204215 }
205216
@@ -212,13 +223,29 @@ export default class extends Controller {
212223 return ;
213224 }
214225
226+ // A contact created on the fly (name only) gets a gentle reminder to
227+ // finish it, linking straight to its edit page.
228+ const contactTexts = this . finishContactTextsValue ;
229+ if (
230+ this . hasFinishContactTarget &&
231+ contactTexts . length > 0 &&
232+ Math . random ( ) < 0.15
233+ ) {
234+ this . say (
235+ contactTexts [ Math . floor ( Math . random ( ) * contactTexts . length ) ] ,
236+ "finishContact" ,
237+ ) ;
238+
239+ return ;
240+ }
241+
215242 // Now and then, nudge the user to finish their least-complete initiative,
216243 // picking one of the finish lines at random for variety.
217244 const finishTexts = this . finishTextsValue ;
218245 if (
219246 this . hasFinishTarget &&
220247 finishTexts . length > 0 &&
221- Math . random ( ) < 0.4
248+ Math . random ( ) < 0.15
222249 ) {
223250 this . say (
224251 finishTexts [ Math . floor ( Math . random ( ) * finishTexts . length ) ] ,
@@ -388,6 +415,9 @@ export default class extends Controller {
388415 if ( this . hasFinishTarget ) {
389416 this . finishTarget . hidden = "finish" !== action ;
390417 }
418+ if ( this . hasFinishContactTarget ) {
419+ this . finishContactTarget . hidden = "finishContact" !== action ;
420+ }
391421 this . bubbleTarget . hidden = false ;
392422 window . requestAnimationFrame ( ( ) => {
393423 this . bubbleTarget . classList . add ( "is-visible" ) ;
0 commit comments