diff --git a/esphome/__main__.py b/esphome/__main__.py index 88c314ad8d..6393e4a70e 100644 --- a/esphome/__main__.py +++ b/esphome/__main__.py @@ -2739,8 +2739,10 @@ def run_esphome(argv): ) # An explicit CLI toolchain must run the per-platform validators; the # cache was validated under whatever the last compile used. Only the - # read is gated: the refresh below may still save the freshly - # validated config, and its sidecar records the resolved toolchain. + # read is gated: the refresh below still saves the freshly validated + # config. The sidecar is only written when none exists; a + # compile-written one keeps the compile's toolchain (the firmware on + # disk was built by it), which upload/logs then restore. cache_read_eligible = cache_write_eligible and args.toolchain is None if cache_read_eligible: from esphome.compiled_config import load_compiled_config diff --git a/tests/unit_tests/test_main.py b/tests/unit_tests/test_main.py index 1bf971fbb1..b991c9900e 100644 --- a/tests/unit_tests/test_main.py +++ b/tests/unit_tests/test_main.py @@ -7253,8 +7253,8 @@ def test_cli_toolchain_still_refreshes_the_validated_config_cache( tmp_path: Path, ) -> None: """An explicit --toolchain gates only the cache read; the freshly - validated config is still saved, and its sidecar records the resolved - toolchain for a later plain run.""" + validated config is still saved so a later plain run keeps the fast + path (an existing compile-written sidecar keeps its toolchain).""" from esphome.__main__ import run_esphome conf = tmp_path / "device.yaml"