fix: register embedded profiles in CLI metadata on daemon start (#546)
When HindsightEmbedded(profile="myapp") starts a daemon, the profile
was never written to metadata.json or given a .env file, making it
invisible to `hindsight-embed profile list` and other CLI commands.
Add _register_profile() to DaemonEmbedManager which saves HINDSIGHT_API_*
config to ~/.hindsight/profiles/{name}.env and registers the port in
metadata.json. Called after a successful new daemon start and when the
daemon is already running, so orphaned profiles also get registered on
next use.
This commit is contained in:
parent
0560f6260d
commit
06b0f74a48
1 changed files with 18 additions and 0 deletions
|
|
@ -241,6 +241,9 @@ class DaemonEmbedManager(EmbedManager):
|
|||
live.update(panel)
|
||||
live.refresh()
|
||||
console.print()
|
||||
# Register profile in metadata so CLI can discover it
|
||||
if profile:
|
||||
self._register_profile(profile, port, config)
|
||||
return True
|
||||
else:
|
||||
log_lines.append("")
|
||||
|
|
@ -307,6 +310,18 @@ class DaemonEmbedManager(EmbedManager):
|
|||
console.print()
|
||||
return False
|
||||
|
||||
def _register_profile(self, profile: str, port: int, config: dict) -> None:
|
||||
"""Register a named profile in metadata so it's discoverable by the CLI.
|
||||
|
||||
Only saves HINDSIGHT_API_* config keys (not internal daemon keys).
|
||||
Silently ignores errors to avoid blocking daemon startup.
|
||||
"""
|
||||
try:
|
||||
api_config = {k: v for k, v in config.items() if k.startswith("HINDSIGHT_API_")}
|
||||
self._profile_manager.create_profile(profile, port, api_config)
|
||||
except Exception as e:
|
||||
logger.debug(f"Failed to register profile '{profile}' in metadata: {e}")
|
||||
|
||||
def ensure_running(self, config: dict, profile: str) -> bool:
|
||||
"""
|
||||
Ensure daemon is running, starting it if needed.
|
||||
|
|
@ -320,6 +335,9 @@ class DaemonEmbedManager(EmbedManager):
|
|||
"""
|
||||
if self.is_running(profile):
|
||||
logger.debug(f"Daemon already running for profile '{profile}'")
|
||||
if profile:
|
||||
paths = self._profile_manager.resolve_profile_paths(profile)
|
||||
self._register_profile(profile, paths.port, config)
|
||||
return True
|
||||
return self._start_daemon(config, profile)
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue