Add "Always" condition type to profiles

- Add AlwaysCondition model and evaluation (always returns true)
- Add condition type selector (Always/Application) in profile editor
- Show condition type pill on profile cards
- Fix misleading empty-conditions text (was "never activate", actually always active)
- Add i18n keys for Always condition (en + ru)
- Add CSS for condition type selector and description

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
2026-02-25 14:38:25 +03:00
parent 466527bd4a
commit 701eac19e5
6 changed files with 101 additions and 38 deletions

View File

@@ -18,11 +18,24 @@ class Condition:
def from_dict(cls, data: dict) -> "Condition":
"""Factory: dispatch to the correct subclass."""
ct = data.get("condition_type", "")
if ct == "always":
return AlwaysCondition.from_dict(data)
if ct == "application":
return ApplicationCondition.from_dict(data)
raise ValueError(f"Unknown condition type: {ct}")
@dataclass
class AlwaysCondition(Condition):
"""Always-true condition — profile activates unconditionally when enabled."""
condition_type: str = "always"
@classmethod
def from_dict(cls, data: dict) -> "AlwaysCondition":
return cls()
@dataclass
class ApplicationCondition(Condition):
"""Activate when specified applications are running or topmost."""