@@ -663,6 +663,64 @@ func TestGenerateCannedInsight_UsesSessionFilterPayload(t *testing.T) {
663663 assert .NotContains (t , generatedPrompts [1 ], codexPrompt )
664664}
665665
666+ func TestGenerateCannedInsight_CoachSummaryUsesFilterTimezone (t * testing.T ) {
667+ var generatedPrompt string
668+ stubGen := func (
669+ _ context.Context , _ string , prompt string , _ insight.LogFunc ,
670+ ) (insight.Result , error ) {
671+ generatedPrompt = prompt
672+ return insight.Result {
673+ Agent : "claude" ,
674+ Model : "test-model" ,
675+ Content : `{
676+ "schema_version":"llm_insight.v1",
677+ "kind":"prompt_maturity_review",
678+ "summary":"Prompt maturity evidence is scoped to the requested local day.",
679+ "confidence":"medium",
680+ "recommendations":[{
681+ "title":"Keep local-day Coach scope aligned",
682+ "rationale":"Coach prompt maturity uses the same local-date filter as the canned payload.",
683+ "actions":["Generate recommendations from the selected local day"],
684+ "evidence_refs":["coach:prompt_maturity"],
685+ "impact":"medium",
686+ "effort":"low"
687+ }],
688+ "risks":[],
689+ "evidence_refs":["coach:prompt_maturity"]
690+ }` ,
691+ }, nil
692+ }
693+ te := setupWithServerOpts (t , []server.Option {
694+ server .WithGenerateStreamFunc (stubGen ),
695+ })
696+
697+ localDayPrompt := "Implement local-day filtering with acceptance criteria and verification steps"
698+ previousLocalDayPrompt := "Implement previous-day filtering with acceptance criteria and verification steps"
699+ te .seedSession (t , "local-day-match" , "my-app" , 4 , func (s * db.Session ) {
700+ started := "2025-01-16T07:30:00Z"
701+ ended := "2025-01-16T07:45:00Z"
702+ s .StartedAt = & started
703+ s .EndedAt = & ended
704+ s .FirstMessage = & localDayPrompt
705+ })
706+ te .seedSession (t , "previous-local-day" , "my-app" , 4 , func (s * db.Session ) {
707+ started := "2025-01-15T01:00:00Z"
708+ ended := "2025-01-15T01:15:00Z"
709+ s .StartedAt = & started
710+ s .EndedAt = & ended
711+ s .FirstMessage = & previousLocalDayPrompt
712+ })
713+
714+ payload := `{"type":"llm_canned","kind":"prompt_maturity_review","date_from":"2025-01-15","date_to":"2025-01-15","project":"my-app","agent":"claude","llm_opt_in":true,"filters":{"timezone":"America/Los_Angeles","include_one_shot":false,"automated_scope":"human"}}`
715+ w := te .post (t , "/api/v1/insights/generate" , payload )
716+ assertStatus (t , w , http .StatusOK )
717+
718+ assert .Contains (t , generatedPrompt , `"timezone":"America/Los_Angeles"` )
719+ assert .Contains (t , generatedPrompt , `"session_count":1` )
720+ assert .Contains (t , generatedPrompt , localDayPrompt )
721+ assert .NotContains (t , generatedPrompt , previousLocalDayPrompt )
722+ }
723+
666724func TestGenerateCannedInsight_RejectsOversizedFocus (t * testing.T ) {
667725 te := setup (t )
668726 longFocus := strings .Repeat ("x" , insight .MaxCannedFocusRunes + 1 )
0 commit comments