From 6cb446baf8cff053026ac6f4eac390947c89eb10 Mon Sep 17 00:00:00 2001 From: "J. Nick Koston" Date: Fri, 21 Aug 2026 09:58:32 -0500 Subject: [PATCH] State what the cache refresh actually writes The comment claimed the refresh's sidecar records the CLI toolchain; _refresh_sidecar returns early when a compile-written sidecar exists, so the compile's toolchain stands. Reword the comment and the test docstring to match. --- esphome/__main__.py | 6 ++++-- tests/unit_tests/test_main.py | 4 ++-- 2 files changed, 6 insertions(+), 4 deletions(-) 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"