@@ -127,6 +127,46 @@ describe("CodexAcpAgent", () => {
127127 ) . toBe ( "read-only" ) ;
128128 } ) ;
129129
130+ it ( "prepends _meta.prContext to the forwarded prompt but not to the broadcast" , async ( ) => {
131+ const { agent, client } = createAgent ( ) ;
132+ mockCodexConnection . newSession . mockResolvedValue ( {
133+ sessionId : "session-1" ,
134+ modes : { currentModeId : "auto" , availableModes : [ ] } ,
135+ configOptions : [ ] ,
136+ } satisfies Partial < NewSessionResponse > ) ;
137+ await agent . newSession ( {
138+ cwd : process . cwd ( ) ,
139+ } as never ) ;
140+
141+ mockCodexConnection . prompt . mockResolvedValue ( { stopReason : "end_turn" } ) ;
142+
143+ await agent . prompt ( {
144+ sessionId : "session-1" ,
145+ prompt : [ { type : "text" , text : "ship the fix" } ] ,
146+ _meta : { prContext : "PR #123 is open; review before editing." } ,
147+ } as never ) ;
148+
149+ // codex-acp receives the PR context prepended as a text block.
150+ expect ( mockCodexConnection . prompt ) . toHaveBeenCalledWith (
151+ expect . objectContaining ( {
152+ prompt : [
153+ { type : "text" , text : "PR #123 is open; review before editing." } ,
154+ { type : "text" , text : "ship the fix" } ,
155+ ] ,
156+ } ) ,
157+ ) ;
158+ // The broadcast shows only the real user turn — the prContext prefix
159+ // is internal routing and should not render as a user message.
160+ expect ( client . sessionUpdate ) . toHaveBeenCalledTimes ( 1 ) ;
161+ expect ( client . sessionUpdate ) . toHaveBeenCalledWith ( {
162+ sessionId : "session-1" ,
163+ update : {
164+ sessionUpdate : "user_message_chunk" ,
165+ content : { type : "text" , text : "ship the fix" } ,
166+ } ,
167+ } ) ;
168+ } ) ;
169+
130170 it ( "broadcasts user prompt as user_message_chunk before delegating to codex-acp" , async ( ) => {
131171 const { agent, client } = createAgent ( ) ;
132172 // Seed an active session so prompt() has the state it expects.
0 commit comments