fix(dashboard): persist and scope profile switching - #13823
Conversation
3a803d4 to
1a2d218
Compare
|
Would love to see this merged. |
teknium1
left a comment
There was a problem hiding this comment.
Thanks for the dashboard profile-scoping work. The stated dashboard behavior is now implemented on current main, but this branch also contains unrelated image-backend changes that need separation before any salvage.
Problems
- Current main already scopes sessions and analytics via
hermes_cli/web_server.py:9583-9608and regression coverage attests/hermes_cli/test_web_server.py:1154-1291; commit62b4618e9introduced that guarantee. Current profile persistence is handled byweb/src/contexts/ProfileProvider.tsx:42-79, and cron profile storage byhermes_cli/web_server.py:10092-10170. - The CPA addition introduces
HERMES_IMAGE_BACKENDattools/image_generation_tool.py:508; behavioral configuration must remain inconfig.yaml. - The CPA output path at
tools/image_generation_tool.py:640hardcodes~/.hermes, bypassing profile isolation. - The PR's request scope mutates process-global
HERMES_HOME(hermes_cli/web_server.py:150on the PR head). Current main documents why await-safe context-local scoping is required athermes_cli/web_server.py:13118-13148.
Suggested changes
- Split and rework the CPA integration against the established image-provider plugin path; retain
config.yamlconfiguration andget_hermes_home()paths.
Automated hermes-sweeper review.
| @contextlib.contextmanager | ||
| def _cm(): | ||
| old = os.environ.get("HERMES_HOME") | ||
| os.environ["HERMES_HOME"] = str(profile_home) |
There was a problem hiding this comment.
This mutates process-global process state for an HTTP request. Because handlers using this scope can await, concurrent requests can read or restore the wrong profile. Please use the current context-local/direct-profile-open approach instead; current main documents the await-safety requirement in _config_profile_scope.
|
|
||
| def _resolve_image_backend() -> str: | ||
| cfg = _load_image_gen_config() | ||
| raw = str(cfg.get("backend") or os.getenv("HERMES_IMAGE_BACKEND") or "fal").strip().lower() |
There was a problem hiding this comment.
HERMES_IMAGE_BACKEND is a new user-facing non-secret behavior setting. Please keep backend selection solely in image_gen config.yaml; .env is reserved for credentials.
| ext = mime.split("/", 1)[1] | ||
| except Exception: | ||
| pass | ||
| out_dir = Path.home() / ".hermes" / "images" |
There was a problem hiding this comment.
This hardcodes the default ~/.hermes path and writes a selected profile's generated image into the wrong home. Use get_hermes_home() / "images" so output remains profile-isolated.
Summary
Test Plan