@@ -9,7 +9,11 @@ describe("resolveUserMessagePresentation", () => {
99 it ( "removes attribution from legacy scheduled prompts" , ( ) => {
1010 expect (
1111 resolveUserMessagePresentation ( { role : "user" , createdBy : "agent" , text : legacyText } ) ,
12- ) . toEqual ( { text : "Check for crashes.\n" , isAutomation : true , scheduledTaskId : undefined } ) ;
12+ ) . toEqual ( {
13+ text : "Check for crashes.\n" ,
14+ attribution : "automation" ,
15+ scheduledTaskId : undefined ,
16+ } ) ;
1317 } ) ;
1418
1519 it ( "uses task metadata without changing the prompt" , ( ) => {
@@ -20,7 +24,7 @@ describe("resolveUserMessagePresentation", () => {
2024 scheduledTaskId : ScheduledTaskId . make ( "task-1" ) ,
2125 text : legacyText ,
2226 } ) ,
23- ) . toEqual ( { text : legacyText , isAutomation : true , scheduledTaskId : "task-1" } ) ;
27+ ) . toEqual ( { text : legacyText , attribution : "automation" , scheduledTaskId : "task-1" } ) ;
2428 } ) ;
2529
2630 it ( "preserves user-written and assistant-quoted schedule headers" , ( ) => {
@@ -31,7 +35,7 @@ describe("resolveUserMessagePresentation", () => {
3135 ] ) {
3236 expect ( resolveUserMessagePresentation ( { ...message , text : legacyText } ) ) . toEqual ( {
3337 text : legacyText ,
34- isAutomation : false ,
38+ attribution : null ,
3539 scheduledTaskId : undefined ,
3640 } ) ;
3741 }
@@ -45,12 +49,29 @@ describe("resolveUserMessagePresentation", () => {
4549 ] ) {
4650 expect ( resolveUserMessagePresentation ( { role : "user" , createdBy : "agent" , text } ) ) . toEqual ( {
4751 text,
48- isAutomation : false ,
52+ attribution : "agent" ,
4953 scheduledTaskId : undefined ,
5054 } ) ;
5155 }
5256 } ) ;
5357
58+ it ( "attributes older server-sent restart continuations to T3 Code, not another agent" , ( ) => {
59+ const text = "Note: the T3 server restarted." ;
60+ expect (
61+ resolveUserMessagePresentation ( {
62+ role : "user" ,
63+ createdBy : "agent" ,
64+ creationSource : "server" ,
65+ text,
66+ } ) ,
67+ ) . toMatchObject ( { attribution : "t3code" } ) ;
68+ for ( const creationSource of [ "mcp" , "provider" ] as const ) {
69+ expect (
70+ resolveUserMessagePresentation ( { role : "user" , createdBy : "agent" , creationSource, text } ) ,
71+ ) . toMatchObject ( { attribution : "agent" } ) ;
72+ }
73+ } ) ;
74+
5475 it ( "recovers the triggering automation from older scheduler message ids" , ( ) => {
5576 for ( const trigger of [ "scheduled" , "manual" ] ) {
5677 expect (
@@ -62,7 +83,7 @@ describe("resolveUserMessagePresentation", () => {
6283 } ) ,
6384 ) . toEqual ( {
6485 text : "Check for crashes.\n" ,
65- isAutomation : true ,
86+ attribution : "automation" ,
6687 scheduledTaskId : "task:daily-audit" ,
6788 } ) ;
6889 }
0 commit comments