fix(desktop): expose preview tools for remote gateways - #80597
Closed
BearHuddleston wants to merge 1 commit into
Closed
fix(desktop): expose preview tools for remote gateways#80597BearHuddleston wants to merge 1 commit into
BearHuddleston wants to merge 1 commit into
Conversation
Use session-scoped platform context when filtering tool definitions so independently launched gateways retain open_preview and read_preview for Desktop sessions. Keep both cache layers platform-isolated and preserve the platform across MCP refreshes.
BearHuddleston
force-pushed
the
fix/desktop-remote-preview-tools
branch
from
August 6, 2026 21:12
3f38c92 to
80033af
Compare
Contributor
Author
|
Closing as superseded by #80699, which landed the same remote/cloud Desktop tool-availability fix on main using the dedicated desktop_ui toolset and session-source scoping. That broader implementation also covers the terminal, pane-focus, reaction, and late-MCP-refresh paths. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What does this PR do?
Hermes Desktop identifies remote-gateway sessions as
platform="desktop", but the preview tools were gated only by the gateway process'sHERMES_DESKTOPenvironment variable. A separately launched gateway does not inherit that variable, soopen_previewandread_previewwere omitted from the agent's tool schemas even though the existing gateway transport can route their events to Desktop.This change evaluates preview-tool availability in a context-local session-platform scope. It keeps the existing
HERMES_DESKTOPbehavior for locally Desktop-managed gateways while making the tools available to remote Desktop sessions. Both the tool-definition cache and requirement-check cache include the session platform so concurrent Desktop and CLI sessions cannot influence each other's tool surfaces.Related Issue
Fixes #79585
Related: #76008 addressed rendering remote HTML files over SSH. This PR covers the separate case where the model never receives the in-app browser tools when Desktop connects to an independently launched gateway.
Also distinct from #48760, which proposes a separate
desktop_browser_*surface. This patch fixes the existingopen_preview/read_previewtools on currentmainand does not add a new browser implementation.Type of Change
Changes Made
tools/registry.py.open_previewandread_previewfor Desktop-platform sessions while retaining the existing environment-based behavior.How to Test
HERMES_DESKTOPand construct anAIAgentwithplatform="desktop"; verifyopen_previewandread_previewremain invalid_tool_names.Checklist
Code
fix(scope):,feat(scope):, etc.)pytest tests/ -qand all tests passDocumentation & Housekeeping
docs/, docstrings) — or N/Acli-config.yaml.exampleif I added/changed config keys — or N/ACONTRIBUTING.mdorAGENTS.mdif I changed architecture or workflows — or N/ASecurity / Cross-platform Impact
This does not change authentication, gateway routing, renderer permissions, or the preview event protocol. It only makes an existing Desktop-only tool surface depend on immutable per-session context rather than mutable process-global state.
ContextVarscoping prevents concurrent sessions from leaking availability state. The implementation uses only cross-platform Python primitives, andscripts/check-windows-footguns.pyreports no new issues.Limitations
This intentionally covers only the Desktop preview/browser tools involved in #79585. It does not broaden remote availability for unrelated Desktop terminal or pane-control tools.
Screenshots / Logs
Final focused canonical suite: 110 tests passed across 10 files. The full canonical suite completed before the comment-only review follow-up with 26,143 passed and 1 failed. The failure was the unrelated
tests/agent/test_credential_pool_routing.py::TestFailureAttribution::test_unmatched_key_does_not_retry_only_pool_entry; it reproduces with the same assertion on a disposable worktree at the exactupstream/mainbase commit. The runner also retried two unrelated flaky files (test_config_read_guard.pyandtest_wake_word.py), both of which passed on retry.The split-process compute-host path also emitted a real
preview.openJSON-RPC event to the owning session, confirming that current gateway event transport is already present once the tool is exposed.