hermes-agent/tests/hermes_cli
kshitij d06104a9ee
fix(dashboard): resolve chat TUI argv off event loop (#48561)
* fix(dashboard): resolve chat TUI argv off event loop

Dashboard chat now resolves its TUI launch command off the
FastAPI/WebSocket event loop. The resolver can run `npm install` /
`npm run build` through `_make_tui_argv()`, and doing that synchronously
in `/api/pty` can block proxy keepalives and other dashboard WebSocket
work long enough for reverse-proxy deployments to drop the chat
connection.

This keeps the current TUI build policy intact: normal production
launches still run the correctness-first `npm run build` path, while
`HERMES_TUI_DIR` remains the prebuilt/no-build path for distros and
containers. The change only moves the potentially slow resolver work to
a worker thread for the dashboard chat path, serialized by an
`asyncio.Lock` so concurrent chat tabs preserve one-build-at-a-time
behavior. `SystemExit` (node/npm missing) and the profile `HTTPException`
path still propagate cleanly through `asyncio.to_thread()`.

Salvaged from #26124 — rebased onto current main. The async wrapper now
threads the `profile` parameter that `_resolve_chat_argv` gained on main
since the PR was opened, so cross-profile chat is preserved.

Co-authored-by: kshitijk4poor <82637225+kshitijk4poor@users.noreply.github.com>

* chore: add 0xdany to AUTHOR_MAP

* fix(dashboard): bind chat-argv lock to app.state; cover error propagation

Self-review hardening on top of the salvaged fix:

- Move `_chat_argv_lock` from a module-level `asyncio.Lock()` onto
  `app.state` (initialised in `_lifespan`, lazy fallback via
  `_get_chat_argv_lock`), mirroring `event_lock`. A module-level
  `asyncio.Lock()` binds to whatever event loop is active at import time,
  which is the exact pattern `_get_event_state`'s docstring warns against
  (breaks across TestClient instances / uvicorn reloads). This keeps the
  lock on the running loop.
- Add two tests exercising the real `_resolve_chat_argv_async` →
  `asyncio.to_thread` → lock → re-raise chain: `SystemExit` (node/npm
  missing) and `HTTPException` (invalid profile) both propagate out of the
  worker thread and are caught by `pty_ws`'s existing handlers. The prior
  tests mocked `asyncio.to_thread` away and never covered this path.

* test(dashboard): dedupe pty error-propagation tests; assert close code

simplify-code cleanup pass on the salvage stack:

- Extract the shared scaffolding of the two pty_ws error-propagation tests
  into `_assert_pty_propagates`, keeping the two tests as distinct contracts
  for the `except SystemExit` and `except HTTPException` arms.
- Assert the stable WebSocket close code (1011) instead of relying solely on
  the user-facing "Chat unavailable" notice wording — a behavior contract per
  the AGENTS.md "behavior contracts over snapshots" rule, robust to notice
  rewording. The detail substring ("unknown profile") is still checked for the
  HTTPException case since proving the detail survives the thread hop is the
  point of that test.

No production-code change; the helper exercises the same real
_resolve_chat_argv_async -> asyncio.to_thread -> lock -> re-raise chain.

---------

Co-authored-by: draihan <draihan@student.ubc.ca>
2026-06-18 22:20:52 -04:00
..
__init__.py
…
conftest.py
…
conftest_dashboard_auth.py
…
test_active_sessions.py
…
test_anthropic_model_flow_stale_oauth.py
…
test_anthropic_oauth_flow.py
…
test_anthropic_picker_curated.py
…
test_anthropic_provider_persistence.py
…
test_api_key_providers.py
…
test_apply_model_switch_result_context.py
…
test_apply_profile_override.py fix(s6): reserved default gateway must not follow sticky active_profile (#46483) 2026-06-15 05:36:20 +00:00
test_arcee_provider.py
…
test_argparse_flag_propagation.py
…
test_at_context_completion_filter.py
…
test_atomic_json_write.py
…
test_atomic_yaml_write.py
…
test_auth_codex_provider.py fix(auth): retry Codex device-code login on 429 with clear rate-limit message (#47860) 2026-06-17 05:48:35 -07:00
test_auth_codex_self_heal.py fix(auth): self-heal missing Codex access tokens 2026-06-13 05:15:26 -07:00
test_auth_commands.py fix(auth): preserve Codex pool-only rate-limit state 2026-06-16 05:56:11 -07:00
test_auth_loopback_ssh_hint.py
…
test_auth_manual_paste.py
…
test_auth_nous_provider.py
…
test_auth_profile_fallback.py
…
test_auth_provider_gate.py
…
test_auth_qwen_provider.py
…
test_auth_ssl_macos.py
…
test_auth_toctou_file_modes.py
…
test_auth_usable_secret.py
…
test_auth_xai_oauth_provider.py fix(auth): refresh xAI OAuth tokens earlier 2026-06-15 05:40:23 -07:00
test_aux_config.py
…
test_azure_detect.py
…
test_azure_foundry_entra.py
…
test_backup.py fix(skills): rmtree scope guard + default pre_update_backup to true (#48200) 2026-06-18 08:53:35 -07:00
test_banner.py fix(mcp): avoid false failed startup status 2026-06-11 09:01:52 -07:00
test_banner_git_state.py
…
test_banner_pip_update.py
…
test_banner_skills.py
…
test_bedrock_model_picker.py
…
test_billing_cli.py feat(billing): /billing terminal billing — interactive TUI + CLI client (#45449) 2026-06-19 01:53:32 +05:30
test_billing_portal_url.py feat(billing): /billing terminal billing — interactive TUI + CLI client (#45449) 2026-06-19 01:53:32 +05:30
test_billing_scope_stepup.py feat(billing): /billing terminal billing — interactive TUI + CLI client (#45449) 2026-06-19 01:53:32 +05:30
test_build_info.py
…
test_bundles.py
…
test_chat_skills_flag.py
…
test_claw.py
…
test_clear_stale_base_url.py
…
test_cli_active_session_limit.py
…
test_cli_output.py
…
test_cmd_update.py
…
test_cmd_update_docker.py fix(ci): remove pytest-timeout, use per-file timeout only 2026-06-12 13:42:42 -04:00
test_coalesce_session_args.py
…
test_codex_cli_model_picker.py
…
test_codex_models.py
…
test_codex_runtime_plugin_migration.py
…
test_codex_runtime_switch.py
…
test_commands.py feat(billing): /credits command — balance + portal top-up handoff (#44776) 2026-06-12 08:51:10 +00:00
test_completion.py
…
test_config.py
…
test_config_drift.py
…
test_config_env_expansion.py
…
test_config_env_refs.py
…
test_config_validation.py
…
test_container_aware_cli.py
…
test_container_boot.py fix(docker): skip gateway reconciliation in dashboard container (autodetect) (#46293) 2026-06-15 20:51:48 +10:00
test_copilot_auth.py
…
test_copilot_catalog_oauth_fallback.py
…
test_copilot_context.py
…
test_copilot_in_model_list.py
…
test_copilot_token_exchange.py
…
test_cron.py
…
test_cron_parser_builder.py
…
test_curator_archive_prune.py
…
test_curator_recent_run_notice.py
…
test_curator_run.py
…
test_curator_status.py
…
test_curses_arrow_keys.py
…
test_curses_color_compat.py
…
test_curses_ui_fuzzy_rank.py
…
test_curses_ui_search.py
…
test_custom_provider_context_length.py
…
test_custom_provider_identity.py Fix custom provider identity loss in session persistence 2026-06-13 05:51:05 -07:00
test_custom_provider_model_switch.py
…
test_dashboard_admin_endpoints.py feat(dashboard): surface full per-MCP catalog detail; fix pip-install doc (#48520) 2026-06-18 09:40:56 -07:00
test_dashboard_auth_401_reauth.py
…
test_dashboard_auth_audit.py
…
test_dashboard_auth_cookies.py
…
test_dashboard_auth_gate.py refactor(desktop): use port 0 for ephemeral port discovery instead of PortPool reservation 2026-06-12 14:02:19 -04:00
test_dashboard_auth_middleware.py
…
test_dashboard_auth_password_login.py
…
test_dashboard_auth_plugin_hook.py
…
test_dashboard_auth_prefix.py
…
test_dashboard_auth_provider_base.py
…
test_dashboard_auth_status_endpoint.py fix(security): stop /api/status leaking host paths and PID on gated binds 2026-06-13 07:18:59 -07:00
test_dashboard_auth_stub_provider.py
…
test_dashboard_auth_ws_auth.py
…
test_dashboard_auth_ws_tickets.py
…
test_dashboard_browser_safe_imports.py
…
test_dashboard_lifecycle_flags.py
…
test_dashboard_profiles_nav_label.py
…
test_dashboard_register.py
…
test_dashboard_tui_backcompat.py
…
test_dashboard_unified_launch.py fix(dashboard): pin machine-dashboard reroute to the machine root, not $HOME/.hermes (#46487) 2026-06-15 15:33:15 +10:00
test_debug.py
…
test_default_interface_resolution.py
…
test_dep_ensure.py
…
test_deprecated_cwd_warning.py
…
test_destructive_slash_confirm_gate.py
…
test_detect_api_mode_for_url.py fix(providers): support anthropic proxy v1 endpoints 2026-06-14 02:09:16 -07:00
test_determine_api_mode_hostname.py
…
test_dingtalk_auth.py
…
test_discord_skill_clamp_warning.py
…
test_doctor.py fix(doctor): recognize nvidia as vendor-slug-accepting provider 2026-06-15 12:24:46 -07:00
test_doctor_command_install.py
…
test_doctor_dedicated_provider_skip.py
…
test_dump_git_commit.py fix(dump): show commit date instead of release date in hermes debug (#48104) 2026-06-17 16:53:42 -07:00
test_dump_terminal_backend.py test(dump): cover terminal backend override reporting 2026-06-15 12:31:23 -07:00
test_ensure_hermes_home_uid_34107.py
…
test_ensure_utf8_locale.py
…
test_env_load_cache.py
…
test_env_loader.py
…
test_env_sanitize_on_load.py
…
test_fallback_cmd.py
…
test_gateway.py feat(relay): connector⇄gateway channel auth + signed-HTTP inbound receiver + enroll CLI (#48147) 2026-06-18 12:01:54 +10:00
test_gateway_linger.py
…
test_gateway_platform_gating.py
…
test_gateway_proc_fallback.py
…
test_gateway_restart_loop.py
…
test_gateway_runtime_health.py Fix dashboard gateway profile scoping 2026-06-17 05:40:57 -07:00
test_gateway_s6_dispatch.py
…
test_gateway_service.py fix(gateway): defer macOS launchd reload when run inside the gateway tree (#47842) 2026-06-17 05:19:21 -07:00
test_gateway_service_paths.py
…
test_gateway_windows.py
…
test_gateway_wsl.py
…
test_gemini_free_tier_setup_block.py
…
test_gemini_provider.py fix(gemini): strip native self prefixes before generateContent (#36141) 2026-06-13 13:47:08 -07:00
test_gmi_provider.py
…
test_goals.py
…
test_graphical_browser_detection.py
…
test_gui_command.py fix(desktop): resolve electronDist dynamically + self-heal blocked installs (supersedes #48081/#48082) (#48091) 2026-06-17 18:48:35 -05:00
test_gui_uninstall.py
…
test_hooks_cli.py
…
test_ignore_user_config_flags.py
…
test_image_gen_picker.py
…
test_install_cua_driver.py
…
test_inventory.py fix(picker): remove max_models=50 cap in interactive model pickers 2026-06-18 13:47:31 -07:00
test_inventory_pricing.py
…
test_kanban_blocked_sticky.py
…
test_kanban_boards.py
…
test_kanban_cli.py
…
test_kanban_cli_dispatch_passthrough.py
…
test_kanban_core_functionality.py
…
test_kanban_db.py
…
test_kanban_db_init.py
…
test_kanban_decompose.py
…
test_kanban_decompose_db.py
…
test_kanban_default_assignee.py
…
test_kanban_diagnostics.py
…
test_kanban_goal_mode.py
…
test_kanban_notify.py
…
test_kanban_per_profile_cap.py
…
test_kanban_promote.py
…
test_kanban_specify.py
…
test_kanban_specify_db.py
…
test_kanban_swarm.py
…
test_kanban_worker_image_extraction.py
…
test_kanban_worker_spawn_toolsets.py fix(kanban): pin assigned profile toolsets for workers (#45590) 2026-06-13 05:50:09 -07:00
test_launcher.py
…
test_list_picker_providers.py
…
test_logs.py
…
test_managed_installs.py
…
test_managed_uv.py
…
test_mcp_add_command_dest.py fix(mcp): preserve stdio argv passthrough 2026-06-11 08:59:55 -07:00
test_mcp_catalog.py fix(mcp): block exfil-shaped stdio server configs (#46083) 2026-06-14 04:24:14 -07:00
test_mcp_config.py fix(mcp): fail fast for noninteractive oauth without tokens 2026-06-15 04:22:07 -07:00
test_mcp_reload_confirm_gate.py
…
test_mcp_security.py fix(mcp): block suspicious stdio configs before probe (#46112) 2026-06-14 04:46:54 -07:00
test_mcp_startup.py
…
test_mcp_tools_config.py
…
test_memory_providers.py fix(desktop): show Hindsight memory provider (#37546) 2026-06-18 16:48:47 -05:00
test_memory_reset.py
…
test_memory_setup.py feat(memory): improve OpenViking setup UX 2026-06-17 01:04:26 +08:00
test_memory_setup_provider_arg.py
…
test_migrate_xai.py
…
test_model_catalog.py fix(picker): keep max_models=0 distinct from unlimited; lock cap semantics 2026-06-18 13:47:31 -07:00
test_model_cost_guard.py
…
test_model_normalize.py fix(gemini): strip native self prefixes before generateContent (#36141) 2026-06-13 13:47:08 -07:00
test_model_picker_expensive_confirm.py
…
test_model_picker_viewport.py
…
test_model_provider_persistence.py
…
test_model_switch_context_display.py
…
test_model_switch_copilot_api_mode.py
…
test_model_switch_custom_providers.py fix(model): show bare custom endpoints in gateway picker (#45597) 2026-06-13 06:05:30 -07:00
test_model_switch_opencode_anthropic.py
…
test_model_switch_variant_tags.py
…
test_model_validation.py fix(providers): support anthropic proxy v1 endpoints 2026-06-14 02:09:16 -07:00
test_models.py
…
test_models_dev_preferred_merge.py fix(models): keep curated-first ordering in live+curated merge; use pure-catalog helper in validation 2026-06-16 23:25:07 +05:30
test_non_ascii_credential.py
…
test_nous_account.py feat(billing): /credits command — balance + portal top-up handoff (#44776) 2026-06-12 08:51:10 +00:00
test_nous_auth_status_cache.py fix(desktop): route global remote profile REST calls (#47011) 2026-06-15 23:24:55 -05:00
test_nous_hermes_non_agentic.py
…
test_nous_inference_url_validation.py
…
test_nous_subscription.py
…
test_ollama_cloud_auth.py
…
test_ollama_cloud_provider.py
…
test_openai_codex_model_validation_fallback.py
…
test_openai_picker_curated.py
…
test_opencode_go_flat_namespace.py
…
test_opencode_go_in_model_list.py
…
test_opencode_go_validation_fallback.py
…
test_overlay_slug_resolution.py
…
test_path_completion.py test(cli): URL tokens must not trigger filesystem path completion 2026-06-17 12:33:56 +05:30
test_picker_prewarm.py
…
test_pin_kanban_board_env.py
…
test_pip_install_detection.py fix(update): scope install-method stamp to the code tree, not $HERMES_HOME (#48188) 2026-06-18 14:14:41 +10:00
test_placeholder_usage.py
…
test_plugin_auxiliary_tasks.py
…
test_plugin_cli_registration.py
…
test_plugin_scanner_recursion.py
…
test_plugins.py fix(plugins): credit shared hook/middleware/tool names to every plugin 2026-06-12 10:57:25 +05:30
test_plugins_cmd.py fix(plugins): normalize browser-pasted GitHub repo URLs (#33539) 2026-06-13 13:23:59 -07:00
test_plugins_cmd_category_discovery.py
…
test_plugins_cmd_enable_disable_nested.py
…
test_plugins_cmd_list.py
…
test_plugins_transcription_registration.py
…
test_plugins_tts_registration.py
…
test_post_setup_gating.py
…
test_profile_describer.py
…
test_profile_distribution.py
…
test_profile_export_credentials.py
…
test_profiles.py fix: migrate cloned profile configs (#46345) 2026-06-14 16:30:23 -07:00
test_profiles_s6_hooks.py fix(s6): register profile gateways without auto-starting (#46266) 2026-06-15 11:43:23 +10:00
test_project_plugin_rce_bypass.py
…
test_prompt_api_key.py
…
test_prompt_size.py
…
test_provider_config_validation.py
…
test_provider_groups.py
…
test_provider_live_curated_merge.py fix(models): keep curated-first ordering in live+curated merge; use pure-catalog helper in validation 2026-06-16 23:25:07 +05:30
test_proxy.py
…
test_psutil_android_extract.py
…
test_pty_bridge.py
…
test_reasoning_effort_menu.py
…
test_redact_config_bridge.py
…
test_regression_16767.py
…
test_relaunch.py
…
test_resolve_last_session.py
…
test_resolve_provider_openrouter_pool.py
…
test_run_with_idle_timeout.py
…
test_runtime_provider_resolution.py
…
test_safe_mode.py fix(desktop): keep composer usable during reconnect (#45488) 2026-06-13 02:36:09 -07:00
test_secret_prompt.py feat(memory): improve OpenViking setup UX 2026-06-17 01:04:26 +08:00
test_secrets_bitwarden_non_tty.py
…
test_security_advisories.py
…
test_security_audit.py
…
test_send_cmd.py fix(send): helpful error when --file gets a binary; document MEDIA: attachments (#45116) 2026-06-12 11:48:06 -07:00
test_service_manager.py fix(docker): supervised gateway uses --replace to take over stale holder (NS-505) (#47555) 2026-06-18 10:49:02 +10:00
test_session_browse.py
…
test_session_handoff.py
…
test_session_recap.py
…
test_sessions_delete.py
…
test_set_config_value.py
…
test_setup.py
…
test_setup_agent_settings.py
…
test_setup_hermes_script.py
…
test_setup_irc.py
…
test_setup_matrix_e2ee.py
…
test_setup_menu_curses_migration.py
…
test_setup_model_provider.py
…
test_setup_noninteractive.py
…
test_setup_ollama_cloud_force_refresh.py
…
test_setup_openclaw_migration.py
…
test_setup_prompt_menus.py
…
test_setup_reconfigure.py
…
test_signal_handler_kanban_worker.py
…
test_skills_config.py fix(skills): apply global|platform disabled union to all resolution sites 2026-06-14 22:54:54 +05:30
test_skills_hub.py
…
test_skills_install_flags.py
…
test_skills_skip_confirm.py
…
test_skills_subparser.py
…
test_skin_engine.py
…
test_slack_cli.py
…
test_spotify_auth.py
…
test_startup_plugin_gating.py
…
test_status.py
…
test_status_model_provider.py
…
test_subcommands_batch.py fix(cli): deprecated `hermes login` fails gracefully for any provider 2026-06-17 12:55:40 +05:30
test_subcommands_followup.py
…
test_subcommands_profile_gateway.py feat(relay): connector⇄gateway channel auth + signed-HTTP inbound receiver + enroll CLI (#48147) 2026-06-18 12:01:54 +10:00
test_subparser_routing_fallback.py
…
test_subprocess_timeouts.py
…
test_suppress_eio_on_interrupt.py
…
test_system_stats_platform.py fix(dashboard): show Windows 11 in host panel (#44511) 2026-06-11 19:06:29 -04:00
test_systemd_optional_directives.py
…
test_teams_pipeline_plugin_cli.py
…
test_telegram_managed_bot.py fix(desktop): keep profile homes out of bootstrap (#46073) 2026-06-14 03:08:52 -07:00
test_tencent_tokenhub_provider.py
…
test_terminal_menu_fallbacks.py
…
test_timeouts.py
…
test_tips.py
…
test_tool_token_estimation.py
…
test_tools_config.py refactor: remove agent-callable send_message tool (#47856) 2026-06-17 07:11:23 -07:00
test_tools_disable_enable.py
…
test_tts_picker.py
…
test_tui_bundled.py
…
test_tui_heap_sizing.py
…
test_tui_mouse_residue_suppression.py
…
test_tui_npm_install.py fix(tui): decode startup subprocess output as utf-8 2026-06-11 09:00:55 -07:00
test_tui_resume_flow.py
…
test_uninstall_node_symlinks.py
…
test_update_autostash.py fix(cli,deps): clear esbuild audit loop 2026-06-15 06:18:27 -07:00
test_update_check.py
…
test_update_concurrent_quarantine.py fix(update): stop Windows gateways before mutating install 2026-06-13 10:46:08 -07:00
test_update_config_clears_custom_fields.py
…
test_update_hangup_protection.py
…
test_update_interrupted_recovery.py
…
test_update_modified_notice.py refactor(skills): dedupe file-listing, share user-modified predicate, trim diff contract 2026-06-18 12:42:58 +05:30
test_update_post_pull_syntax_guard.py
…
test_update_stale_dashboard.py
…
test_update_yes_flag.py
…
test_update_zip_symlink_reject.py
…
test_user_providers_model_switch.py test(model-switch): cover section-3 no-auth probe; map chimpera author 2026-06-16 13:07:52 -07:00
test_uv_tool_update.py
…
test_verify_core_dependencies.py
…
test_video_gen_picker.py
…
test_voice_wrapper.py
…
test_web_oauth_dispatch.py feat(desktop): disconnect external (CLI-managed) providers 2026-06-16 00:08:21 -05:00
test_web_server.py fix(dashboard): resolve chat TUI argv off event loop (#48561) 2026-06-18 22:20:52 -04:00
test_web_server_cron_profiles.py
…
test_web_server_files.py fix(dashboard): stream file uploads via multipart instead of base64 JSON (NS-501) (#47663) 2026-06-18 15:54:32 +10:00
test_web_server_fs.py fix(desktop): scope remote workspace defaults 2026-06-11 09:41:35 -07:00
test_web_server_host_header.py
…
test_web_server_messaging_profiles.py Fix dashboard gateway profile scoping 2026-06-17 05:40:57 -07:00
test_web_server_oauth_write.py
…
test_web_server_profile_unification.py Fix dashboard gateway profile scoping 2026-06-17 05:40:57 -07:00
test_web_server_pty_import.py
…
test_web_server_session_search.py
…
test_web_server_skill_editor.py
…
test_web_server_skills_profiles.py fix(dashboard): skill installs from the dashboard silently auto-cancel (#45150) 2026-06-12 12:58:36 -07:00
test_web_ui_build.py fix(dashboard): suppress unicode-animations postinstall during npm ci 2026-06-11 11:49:08 -07:00
test_webhook_cli.py
…
test_whatsapp_cloud_setup.py
…
test_whatsapp_setup_ordering.py
…
test_win_pty_bridge.py
…
test_windows_native_docs.py
…
test_xai_curated_models.py chore: add AUTHOR_MAP entry for #47904 salvage 2026-06-17 09:49:46 -07:00
test_xai_model_flow.py
…
test_xai_oauth_pkce_token_exchange.py
…
test_xai_oauth_profile_auth.py fix(auth): resolve xAI OAuth credentials across profiles 2026-06-15 17:03:35 +05:30
test_xai_oauth_refresh.py fix(auth): refresh xAI OAuth tokens earlier 2026-06-15 05:40:23 -07:00
test_xai_oauth_writethrough.py fix(auth): write rotated xAI OAuth tokens back to global root (#43589) 2026-06-15 17:08:19 +05:30
test_xai_provider_labels.py
…
test_xai_retirement.py
…
test_xiaomi_provider.py
…