diff --git a/api/workspace.py b/api/workspace.py index 0db7b5b..de0ff05 100644 --- a/api/workspace.py +++ b/api/workspace.py @@ -53,17 +53,31 @@ def _last_workspace_file() -> Path: def _profile_default_workspace() -> str: """Read the profile's default workspace from its config.yaml. + Checks keys in priority order: + 1. 'workspace' — explicit webui workspace key + 2. 'default_workspace' — alternate explicit key + 3. 'terminal.cwd' — hermes-agent terminal working dir (most common) + Falls back to the boot-time DEFAULT_WORKSPACE constant. """ try: - from api.profiles import get_active_hermes_home from api.config import get_config cfg = get_config() - ws = cfg.get('default_workspace') - if ws: - p = Path(ws).expanduser().resolve() - if p.is_dir(): - return str(p) + # Explicit webui workspace keys first + for key in ('workspace', 'default_workspace'): + ws = cfg.get(key) + if ws: + p = Path(str(ws)).expanduser().resolve() + if p.is_dir(): + return str(p) + # Fall through to terminal.cwd — the agent's configured working directory + terminal_cfg = cfg.get('terminal', {}) + if isinstance(terminal_cfg, dict): + cwd = terminal_cfg.get('cwd', '') + if cwd and str(cwd) not in ('.', ''): + p = Path(str(cwd)).expanduser().resolve() + if p.is_dir(): + return str(p) except (ImportError, Exception): pass return str(_BOOT_DEFAULT_WORKSPACE) diff --git a/static/style.css b/static/style.css index b13bfda..e5c39ed 100644 --- a/static/style.css +++ b/static/style.css @@ -345,7 +345,7 @@ /* ── Workspace dropdown (topbar) ── */ .ws-chip{user-select:none;} -.ws-dropdown{display:none;position:absolute;top:calc(100% + 4px);left:0;right:0;min-width:200px;background:#1a2535;border:1px solid var(--border2);border-radius:10px;box-shadow:0 8px 24px rgba(0,0,0,.4);z-index:200;overflow:hidden;max-height:320px;overflow-y:auto;} +.ws-dropdown{display:none;position:absolute;bottom:calc(100% + 4px);left:0;right:0;min-width:200px;background:#1a2535;border:1px solid var(--border2);border-radius:10px;box-shadow:0 -4px 24px rgba(0,0,0,.4);z-index:200;overflow:hidden;max-height:320px;overflow-y:auto;} .ws-dropdown.open{display:block;} .ws-opt{padding:9px 14px;cursor:pointer;transition:background .12s;} .ws-opt:hover{background:rgba(255,255,255,.07);}