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.
This commit is contained in:
Max authored and GitHub committed 2026-09-21 20:40:21 +02:00
1 parent 349d47baf5
commit 7ccffb6ee3
2 files changed
+5 -3

No files matched your search

+3
View File
@@ -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, - 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) 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: `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 - Docs: `trusted_project_path_patterns` now documents how to trust a single project. Trust is decided by
the project's root path, so a `<project root>/**` entry matches only paths below the root and therefore the project's root path, so a `<project root>/**` 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 trusts no project at all; the template now shows the bare root form alongside the parent-directory
+2 -3
View File
@@ -14,7 +14,6 @@ from copy import deepcopy
from dataclasses import dataclass, field from dataclasses import dataclass, field
from datetime import UTC, datetime from datetime import UTC, datetime
from enum import Enum from enum import Enum
from functools import cached_property
from pathlib import Path from pathlib import Path
from typing import TYPE_CHECKING, Any, Optional, Self, TypeVar from typing import TYPE_CHECKING, Any, Optional, Self, TypeVar
from uuid import uuid4 from uuid import uuid4
@@ -1249,11 +1248,11 @@ class SerenaConfig(SharedConfig, ModeSelectionDefinitionWithBaseModes):
self.jetbrains_launch_command = None self.jetbrains_launch_command = None
return self return self
@cached_property @property
def project_paths(self) -> list[str]: def project_paths(self) -> list[str]:
return sorted(str(project.project_root) for project in self.projects) return sorted(str(project.project_root) for project in self.projects)
@cached_property @property
def project_names(self) -> list[str]: def project_names(self) -> list[str]:
return sorted(project.project_config.project_name for project in self.projects) return sorted(project.project_config.project_name for project in self.projects)