From 7ccffb6ee3d8b8970a02a2e1cf5f3b217dcbc253 Mon Sep 17 00:00:00 2001 From: Max Date: Tue, 22 Sep 2026 02:40:21 +0800 Subject: [PATCH] fix(config): derive project lists on access instead of caching them (#2092) SerenaConfig.project_names / project_paths were cached_property values that were never invalidated after projects were added or removed mid-session, so user-facing project lists and error messages stayed stale. They are cheap to derive, so drop the caching (plain properties) instead of invalidating. --- CHANGELOG.md | 3 +++ src/serena/config/serena_config.py | 5 ++--- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 7d1ef3dd..5f661bb3 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -30,6 +30,9 @@ Status of the `main` branch. Changes prior to the next official version change w - Fix: process-tree cleanup signaled descendant language-server processes without waiting for them, which could leave grandchildren as zombies; cleanup now waits for the discovered descendants (#1464) - Fix: `read_only` restriction in project definition was not applied to base tool set when in single-project context (#1938) + - Fix: `SerenaConfig.project_names` / `project_paths` were cached and never invalidated after + projects were added or removed mid-session, so user-facing project lists and error messages + stayed stale; the lists are no longer cached - Docs: `trusted_project_path_patterns` now documents how to trust a single project. Trust is decided by the project's root path, so a `/**` entry matches only paths below the root and therefore trusts no project at all; the template now shows the bare root form alongside the parent-directory diff --git a/src/serena/config/serena_config.py b/src/serena/config/serena_config.py index a73c3d49..4a003635 100644 --- a/src/serena/config/serena_config.py +++ b/src/serena/config/serena_config.py @@ -14,7 +14,6 @@ from copy import deepcopy from dataclasses import dataclass, field from datetime import UTC, datetime from enum import Enum -from functools import cached_property from pathlib import Path from typing import TYPE_CHECKING, Any, Optional, Self, TypeVar from uuid import uuid4 @@ -1249,11 +1248,11 @@ class SerenaConfig(SharedConfig, ModeSelectionDefinitionWithBaseModes): self.jetbrains_launch_command = None return self - @cached_property + @property def project_paths(self) -> list[str]: return sorted(str(project.project_root) for project in self.projects) - @cached_property + @property def project_names(self) -> list[str]: return sorted(project.project_config.project_name for project in self.projects)