Skip to content

Avoid launching a second shared Desktop client when attaching to an existing mphclient session #32

@jiweiqi

Description

@jiweiqi

Problem

The COMSOL skill/driver guidance currently makes visual_mode=shared-desktop sound like the default attach path for any live GUI collaboration. That is correct when the agent should create/manage the visible COMSOL Desktop client, but it is misleading when the user has already started comsolmphserver and opened the target .mph in an existing comsol.exe mphclient -host ... -port ... Desktop.

In that case, running:

sim connect --solver comsol --ui-mode gui `
  --driver-option attach_only=true `
  --driver-option port=2036 `
  --driver-option visual_mode=shared-desktop

can launch an additional COMSOL Desktop client, trigger a "server in use" / connection popup, or create extra sidecar model tags. The desired operation for inspection is only to attach the agent/API client to the already-running server and inspect the existing model tags.

Observed session

Workflow used:

  1. User starts comsolmphserver on port 2036.
  2. User opens comsol.exe mphclient -host localhost -port 2036.
  3. User opens 双饼_屏蔽电流计算.mph in that GUI.
  4. Agent tries to inspect tags with visual_mode=shared-desktop.

Observed effects:

  • An extra ComsolUI process appeared.
  • The GUI showed a server/client conflict popup.
  • Earlier attempts created sidecar tags such as Model1/Model3.
  • After cleanup, the correct state was obtained by using an existing session/no-new-GUI attach: one model tag (Model2) with label 双饼_屏蔽电流计算.mph, comp1, physics mfh/cc, and studies std1/std3.

Proposal

Documentation / skill routing

Clarify the routing rule:

  • Use visual_mode=shared-desktop when the agent should launch/manage the visible COMSOL Desktop client.
  • If the human already has a server-backed GUI open (comsol.exe mphclient -host ... -port ...) with the target model loaded, first attach without launching a new GUI:
sim connect --solver comsol --ui-mode no_gui `
  --driver-option attach_only=true `
  --driver-option port=2036

Then inspect:

sim inspect session.health
sim exec "_result = {'tags': [str(t) for t in list(ModelUtil.tags())], 'bound': str(model.tag()), 'label': str(model.label())}"

Driver/CLI behavior

Consider one of these improvements:

  1. Add an explicit visual_mode=existing-desktop or desktop_attach=existing mode that attaches to the server/API without launching a new mphclient, but still reports observed COMSOL windows.
  2. When attach_only=true and a matching COMSOL Desktop/mphclient window is already present for the target port, warn before launching a second Desktop client.
  3. Split health semantics so model_builder_live=true does not imply the driver should always create a new visible client. It should distinguish:
    • desktop_client_owner=plugin
    • desktop_client_owner=user
    • desktop_observed=true/false
  4. Add a tag-inspection command/path that is explicitly no-GUI and safe for existing human-owned GUI sessions.

Why this matters

This is a common collaborative workflow: the user wants to own the COMSOL GUI and open the model manually, while the agent only attaches to the same server for structured inspection/mutations. Launching an additional Desktop client is surprising and can disturb the GUI/session state.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions