Skip to content

fix(tui-gateway): install the selected profile's secret scope (Desktop/dashboard) - #72293

Merged
teknium1 merged 2 commits into
mainfrom
hermes/hermes-be2de496
Jul 26, 2026
Merged

teknium1 merged 2 commits into
mainfrom
hermes/hermes-be2de496

Conversation

@teknium1

Copy link
Copy Markdown
Collaborator

Summary

Credentials in Desktop/dashboard sessions now resolve from the selected profile's .env instead of falling through to the launch profile's process environment. Fixes item 2 of #67605 (secret scope never installed on the tui_gateway path); salvage of #67623 by @kyssta-exe.

Root cause: gateway/run.py and hermes_cli/web_server.py install the profile secret scope around profile-bound work, but nothing in tui_gateway/ did — so get_secret() fell through to os.environ, which holds the launch profile's .env (loaded with override=True at module import).

Changes

  • tui_gateway/server.py: install set_secret_scope(build_profile_secret_scope(profile_home)) alongside the existing HERMES_HOME override at all three bind sites — agent build (_start_agent_build), session resume (_reuse_live_payload, both init paths), and per-turn prompt (run) — with paired resets in finally (contributor).
  • tui_gateway/compute_host.py: same pairing in _ensure_server_session (contributor).
  • tests/test_tui_gateway_server.py: regression test proving agent build installs the selected profile's scope (follow-up; the PR shipped without tests).

Dropped from the original branch: the hermes_cli/mcp_startup.py gate removal — superseded by #72219, which fixed the discovery gate properly by propagating the profile override into the discovery thread.

Validation

Check Result
tests/test_tui_gateway_server.py (468) pass
tests/tui_gateway/ + tests/agent/test_secret_scope.py (988 total) pass
Sabotage run (secret-scope install removed from _start_agent_build) new test fails as expected
E2E (real imports, temp homes, poisoned process env) 6/6: profile value wins over launch env; multiplex-off overlay fallthrough preserved; multiplex-on absent-key no-leak; reset restores env

Infographic

Profile secret scope for tui_gateway

kyssta-exe and others added 2 commits July 26, 2026 16:03
…le (#67605)

The dashboard/desktop profile switch was partial — switching to profile X
ran the launch profile's resources in two ways:

1. MCP discovery was gated on the launch profile's config having
   mcp_servers. If the launch profile had none, the background thread
   never started and zero MCP servers existed for every profile. Fix:
   always start discovery and let discover_mcp_tools() handle the
   empty-config case.

2. The profile secret scope (.env credentials) was never installed on the
   tui_gateway path. get_secret() fell through to os.environ, resolving
   secrets from the launch profile instead of the selected one. Fix:
   install set_secret_scope(build_profile_secret_scope(...)) alongside
   every set_hermes_home_override() call site:
   - compute_host.py:_ensure_server_session (build-time)
   - server.py:_build (lazy resume)
   - server.py:_handle_resume_session (_make_agent scope)
   - server.py:_handle_resume_session (_init_session scope)
   - server.py:_handle_submit_or_edit (per-turn handler)
…cope

Sabotage-verified: fails when the set_secret_scope call in
_start_agent_build is removed.
@github-actions

github-actions Bot commented Jul 26, 2026

Copy link
Copy Markdown
Contributor

૮ >ﻌ< ა ci review

ran on f5a69ef

ℹ️ Info

Desktop E2E visual evidence · View test artifacts · View job

1 visual diff.

inline evidence upload failed.

Failed to upload diff-665a0833239e-onboarding-overlay-diff.png with gh image (exit code 1): Error uploading /home/runner/work/_temp/e2e-evidence/diff-665a0833239e-onboarding-overlay-diff.png: step 0 (get upload token): uploadToken not found on repo page — do you have write access to NousResearch/hermes-agent? (or, if NousResearch enforces SAML SSO, authorize at https://github.com/orgs/NousResearch/sso)

@alt-glitch alt-glitch added type/bug Something isn't working comp/tui Terminal UI (ui-tui/ + tui_gateway/) area/auth Authentication, OAuth, credential pools area/profiles Multi-profile isolation, HERMES_HOME scoping P2 Medium — degraded but workaround exists sweeper:risk-session-state Sweeper risk: may lose/corrupt/mis-associate session or context state sweeper:risk-security-boundary Sweeper risk: may affect sandboxing, auth, credentials, or sensitive data labels Jul 26, 2026
@alt-glitch

Copy link
Copy Markdown
Contributor

This was generated by AI during triage.

Related: #67605 tracks the profile-switching bug; this core-team salvage isolates its remaining TUI secret-scope repair. #67623 is the earlier broader attempt, while #72219 already merged the separate MCP-discovery repair.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area/auth Authentication, OAuth, credential pools area/profiles Multi-profile isolation, HERMES_HOME scoping comp/tui Terminal UI (ui-tui/ + tui_gateway/) P2 Medium — degraded but workaround exists sweeper:risk-security-boundary Sweeper risk: may affect sandboxing, auth, credentials, or sensitive data sweeper:risk-session-state Sweeper risk: may lose/corrupt/mis-associate session or context state type/bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants