refactor: rename resolve_herdr_workspace to resolve_herdr_session and use herdr_session database field consistently

This commit is contained in:
Antigravity
2026-07-20 11:13:17 +09:00
parent daa1476714
commit 87bb2780ac
12 changed files with 166 additions and 28 deletions
+4 -10
View File
@@ -495,9 +495,9 @@ herdr() {
}
# ---------------------------------------------------------------------------
# resolve_herdr_server <session_name>
# resolve_herdr_session <session_name>
#
# Query agent-sessions.yaml to find the herdr_server associated with a session.
# Query agent-sessions.yaml to find the herdr_session associated with a session.
# Fallback to HERDR_SERVER_NAME or 'default' if not registered or field is missing.
# Prints the resolved server name on stdout.
# ---------------------------------------------------------------------------
@@ -541,13 +541,7 @@ print(json.dumps(d, ensure_ascii=False))
PYEOF
}
# Despite the name (kept for caller compatibility — resume/stop/update_yaml_resumed
# all do `HERDR_SERVER_NAME="$(resolve_herdr_workspace "$SESSION_NAME")"`), this
# returns the isolated herdr *session* name to use for this MAM session row, not
# a workspace id. Real isolation is `--session <name>` (see `_MAM_SESSION` in the
# generated wrapper) — a workspace label match provides no actual isolation
# since agent/pane commands are server-global regardless of workspace.
resolve_herdr_workspace() {
resolve_herdr_session() {
local session_name="$1"
MAM_STATE_JSON="$(load_state_json)" SESSION_NAME="$session_name" python3 -c "
import sys, os, json
@@ -555,7 +549,7 @@ name = os.environ['SESSION_NAME']
d = json.loads(os.environ.get('MAM_STATE_JSON', '{}'))
for s in d.get('herdr_sessions', []):
if s.get('name') == name:
print(s.get('herdr_workspace') or s.get('herdr_server') or 'default')
print(s.get('herdr_session') or s.get('herdr_workspace') or s.get('herdr_server') or 'default')
sys.exit(0)
print(os.environ.get('HERDR_SERVER_NAME', 'default'))
"