@@ -34,8 +34,17 @@ const executeScriptInContainerWithBash = async (
3434 ` ,
3535 ] ) ;
3636
37- // Run the script
38- const resp = await execContainer ( id , [ "bash" , "-c" , instance . script ] ) ;
37+ // Run the script with the environment variables from extraCommands
38+ // Modifying to preserve environment variables
39+ const resp = await execContainer ( id , [ "bash" , "-c" , `
40+ # Source any environment variables that might have been set
41+ if [ -f /tmp/env_vars.sh ]; then
42+ source /tmp/env_vars.sh
43+ fi
44+
45+ # Run the script
46+ ${ instance . script }
47+ ` ] ) ;
3948 const stdout = resp . stdout . trim ( ) . split ( "\n" ) ;
4049 const stderr = resp . stderr . trim ( ) . split ( "\n" ) ;
4150 return {
@@ -109,17 +118,21 @@ describe("aider", async () => {
109118 const output = await executeScriptInContainerWithBash (
110119 state ,
111120 "alpine" ,
112- `export CODER_MCP_AIDER_TASK_PROMPT="${ testPrompt } "` ,
121+ `echo ' export CODER_MCP_AIDER_TASK_PROMPT="${ testPrompt } "' > /tmp/env_vars.sh`
113122 ) ;
114123
124+ // Debug: print all output lines
125+ console . log ( "DEBUG OUTPUT LINES:" ) ;
126+ output . stdout . forEach ( line => console . log ( `> ${ line } ` ) ) ;
127+
115128 // Check if script contains the proper command construction with --message and --yes-always flags
116129 const instance = findResourceInstance ( state , "coder_script" ) ;
117130
118- // Verify the script uses --message flag
119- expect ( instance . script . includes ( "aider --message" ) ) . toBe ( true ) ;
120-
121131 // Verify the script uses --yes-always flag
122- expect ( instance . script . includes ( "--yes-always" ) ) . toBe ( true ) ;
132+ expect ( instance . script . includes ( "aider --yes-always" ) ) . toBe ( true ) ;
133+
134+ // Verify the script uses --message flag
135+ expect ( instance . script . includes ( "--message" ) ) . toBe ( true ) ;
123136
124137 // Verify the script creates a flag file to prevent duplicate execution
125138 expect ( instance . script . includes ( 'touch "$HOME/.aider_task_executed"' ) ) . toBe (
@@ -128,7 +141,7 @@ describe("aider", async () => {
128141
129142 // Verify the output shows the right message
130143 expect (
131- output . stdout . some ( ( line ) => line . includes ( "Running Aider with message" ) ) ,
144+ output . stdout . some ( ( line ) => line . includes ( "Running Aider with message in screen session " ) ) ,
132145 ) . toBe ( true ) ;
133146 } ) ;
134147
0 commit comments