diff --git a/aider/main.py b/aider/main.py index e1462f195..0f08ad835 100644 --- a/aider/main.py +++ b/aider/main.py @@ -560,6 +560,7 @@ def main(argv=None, input=None, output=None, force_git_root=None): io.tool_error(f"Git working dir: {git_root}") if args.message: + io.add_to_input_history(args.message) io.tool_output() coder.run(with_message=args.message) else: diff --git a/tests/test_main.py b/tests/test_main.py index d16e1672d..c02204217 100644 --- a/tests/test_main.py +++ b/tests/test_main.py @@ -196,3 +196,13 @@ class TestMain(TestCase): MockSend.side_effect = side_effect main(["--yes", fname, "--encoding", "iso-8859-15"]) + @patch("aider.main.InputOutput") + @patch("openai.ChatCompletion.create") + def test_main_message_adds_to_input_history(self, mock_chat_completion, MockInputOutput): + test_message = "test message" + mock_io_instance = MockInputOutput.return_value + mock_chat_completion.return_value = MagicMock(choices=[{"text": "mocked response"}]) + + main(["--message", test_message], input=DummyInput(), output=DummyOutput()) + + mock_io_instance.add_to_input_history.assert_called_once_with(test_message)