Skip to content

solidworks_mcp.ui.prefab_dashboard

solidworks_mcp.ui.prefab_dashboard

Prefab dashboard for the interactive SolidWorks assistant.

Control-to-endpoint mapping and operator guidance live in: - docs/getting- started/prefab-ui-dashboard.md - docs/getting-started/prefab-ui-controls-reference.md

Attributes

API_ORIGIN module-attribute

API_ORIGIN = getenv('SOLIDWORKS_UI_API_ORIGIN', 'http://127.0.0.1:8766')

SESSION_ID_EXPR module-attribute

SESSION_ID_EXPR = "{{ session_id || 'prefab-dashboard' }}"

SHOW_EXPERIMENTAL_ORCHESTRATION module-attribute

SHOW_EXPERIMENTAL_ORCHESTRATION = lower() in {'1', 'true', 'yes', 'on'}

ctx_pct module-attribute

ctx_pct = ctx_tick % 24 * 3 + 18

ctx_tick module-attribute

ctx_tick = Rx('ctx_tick')

ctx_variant module-attribute

ctx_variant = then('destructive', then('success', 'default'))

Classes

DashboardUIState

Bases: BaseModel

Top-level dashboard state shared between backend and Prefab UI.

Field descriptions are user-facing semantics and validation intent.

Attributes:

Name Type Description
accepted_family str

The accepted family value.

active_model_configuration str

The active model configuration value.

active_model_path str

The active model path value.

active_model_status str

The active model status value.

active_model_type str

The active model type value.

api_origin str

The api origin value.

assumptions_text str

The assumptions text value.

canonical_prompt_text str

The canonical prompt text value.

checkpoints list[DashboardCheckpoint]

The checkpoints value.

checkpoints_text str

The checkpoints text value.

clarifying_questions_text str

The clarifying questions text value.

context_file_input str

The context file input value.

context_load_status str

The context load status value.

context_name_input str

The context name input value.

context_save_status str

The context save status value.

context_text str

The context text value.

context_used_pct int

The context used pct value.

ctx_tick int

The ctx tick value.

docs_context_text str

The docs context text value.

docs_query str

The docs query value.

evidence_rows list[DashboardEvidenceRow]

The evidence rows value.

evidence_rows_text str

The evidence rows text value.

family_confidence str

The family confidence value.

family_evidence_text str

The family evidence text value.

family_warning_text str

The family warning text value.

feature_grounding_warning_text str

The feature grounding warning text value.

feature_target_status str

The feature target status value.

feature_target_text str

The feature target text value.

feature_tree_items list[dict]

The feature tree items value.

flow_header_text str

The flow header text value.

latest_error_text str

The latest error text value.

latest_message str

The latest message value.

latest_tool str

The latest tool value.

local_endpoint str

The local endpoint value.

local_model_available bool

The local model available value.

local_model_busy bool

The local model busy value.

local_model_label str

The local model label value.

local_model_pull_command str

The local model pull command value.

local_model_recommended_ollama_model str

The local model recommended ollama model value.

local_model_recommended_tier str

The local model recommended tier value.

local_model_status_text str

The local model status text value.

manual_sync_ready bool

The manual sync ready value.

mocked_tools_text str

The mocked tools text value.

model_config Any

The model config value.

model_context_text str

The model context text value.

model_name str

The model name value.

model_path_input_chooser str

The model path input chooser value.

model_path_input_edit str

The model path input edit value.

model_profile str

The model profile value.

model_provider str

The model provider value.

normalized_brief str

The normalized brief value.

notes_text str

The notes text value.

orchestration_status str

The orchestration status value.

preview_orientation str

The preview orientation value.

preview_status str

The preview status value.

preview_url str

The preview url value.

preview_view_urls dict[str, str]

The preview view urls value.

preview_viewer_url str

The preview viewer url value.

proposed_family str

The proposed family value.

rag_chunk_count int

The rag chunk count value.

rag_index_path str

The rag index path value.

rag_namespace str

The rag namespace value.

rag_provenance_text str

The rag provenance text value.

rag_source_path str

The rag source path value.

rag_status str

The rag status value.

readiness_adapter_mode str

The readiness adapter mode value.

readiness_db_ready bool

The readiness db ready value.

readiness_preview_ready bool

The readiness preview ready value.

readiness_provider_configured bool

The readiness provider configured value.

readiness_summary str

The readiness summary value.

remediation_hint str

The remediation hint value.

selected_feature_name str

The selected feature name value.

session_id str

The session id value.

structured_rendering_enabled bool

The structured rendering enabled value.

tool_history_text str

The tool history text value.

uploaded_file_payloads list[dict[str, Any]]

The uploaded file payloads value.

user_clarification_answer str

The user clarification answer value.

user_goal str

The user goal value.

workflow_guidance_text str

The workflow guidance text value.

workflow_label str

The workflow label value.

workflow_mode str

The workflow mode value.

Functions

_error_toast

_error_toast() -> ShowToast

Build internal error toast.

Returns:

Name Type Description
ShowToast ShowToast

The result produced by the operation.

Source code in src/solidworks_mcp/ui/prefab_dashboard.py
def _error_toast() -> ShowToast:
    """Build internal error toast.

    Returns:
        ShowToast: The result produced by the operation.
    """

    return ShowToast("Request failed", variant="error")

_hydrate_from_result

_hydrate_from_result() -> list[Any]

Build internal hydrate from result.

Returns:

Type Description
list[Any]

list[Any]: A list containing the resulting items.

Source code in src/solidworks_mcp/ui/prefab_dashboard.py
def _hydrate_from_result() -> list[Any]:
    """Build internal hydrate from result.

    Returns:
        list[Any]: A list containing the resulting items.
    """

    state_keys = [
        "workflow_mode",
        "workflow_label",
        "workflow_guidance_text",
        "flow_header_text",
        "assumptions_text",
        "active_model_path",
        "active_model_status",
        "active_model_type",
        "active_model_configuration",
        "feature_target_text",
        "feature_target_status",
        "feature_grounding_warning_text",
        "normalized_brief",
        "clarifying_questions_text",
        "proposed_family",
        "family_confidence",
        "family_evidence_text",
        "family_warning_text",
        "accepted_family",
        "checkpoints",
        "checkpoints_text",
        "evidence_rows",
        "evidence_rows_text",
        "structured_rendering_enabled",
        "preview_url",
        "preview_viewer_url",
        "preview_status",
        "preview_orientation",
        "latest_message",
        "latest_tool",
        "mocked_tools_text",
        "latest_error_text",
        "remediation_hint",
        "model_provider",
        "model_name",
        "model_profile",
        "local_endpoint",
        "local_model_status_text",
        "local_model_busy",
        "local_model_available",
        "local_model_recommended_tier",
        "local_model_recommended_ollama_model",
        "local_model_pull_command",
        "local_model_label",
        "rag_source_path",
        "rag_namespace",
        "rag_status",
        "rag_index_path",
        "rag_chunk_count",
        "rag_provenance_text",
        "docs_query",
        "docs_context_text",
        "notes_text",
        "orchestration_status",
        "context_save_status",
        "context_load_status",
        "context_name_input",
        "context_file_input",
        "model_context_text",
        "canonical_prompt_text",
        "tool_history_text",
        "readiness_provider_configured",
        "readiness_adapter_mode",
        "readiness_preview_ready",
        "readiness_db_ready",
        "readiness_summary",
        "manual_sync_ready",
        "context_text",
        "feature_tree_items",
        "selected_feature_name",
        "preview_view_urls",
    ]
    hydrated = [
        SetState(key, _result_state(key, getattr(STATE, key))) for key in state_keys
    ]
    # Mirror canonical active path into editable draft fields used by attach buttons.
    hydrated.extend(
        [
            SetState(
                "model_path_input_chooser", _result_state("active_model_path", "")
            ),
            SetState("model_path_input_edit", _result_state("active_model_path", "")),
        ]
    )
    return hydrated

_on_attach_success

_on_attach_success() -> list[object]

Hydrate attach results without letting the UI fall back to chooser-only state.

Returns:

Type Description
list[object]

list[object]: A list containing the resulting items.

Source code in src/solidworks_mcp/ui/prefab_dashboard.py
def _on_attach_success() -> list[object]:
    """Hydrate attach results without letting the UI fall back to chooser-only state.

    Returns:
        list[object]: A list containing the resulting items.
    """
    return [
        SetState("workflow_mode", "edit_existing"),
        SetState("workflow_label", "Editing Existing Part or Assembly"),
        *_hydrate_from_result(),
        _refresh_state(),
        ShowToast("Target model attached and preview refreshed"),
    ]

_open_then_connect

_open_then_connect(connect_body: dict[str, object]) -> Fetch

Run full connect + preview refresh in one request for reliable attach behavior.

Parameters:

Name Type Description Default
connect_body dict[str, object]

The connect body value.

required

Returns:

Name Type Description
Fetch Fetch

The result produced by the operation.

Source code in src/solidworks_mcp/ui/prefab_dashboard.py
def _open_then_connect(connect_body: dict[str, object]) -> Fetch:
    """Run full connect + preview refresh in one request for reliable attach behavior.

    Args:
        connect_body (dict[str, object]): The connect body value.

    Returns:
        Fetch: The result produced by the operation.
    """
    return Fetch.post(
        f"{API_ORIGIN}/api/ui/model/connect",
        body=connect_body,
        on_success=_on_attach_success(),
        on_error=ShowToast("Attach/connect request failed", variant="error"),
    )

_probe_local_model

_probe_local_model() -> Fetch

Build internal probe local model.

Returns:

Name Type Description
Fetch Fetch

The result produced by the operation.

Source code in src/solidworks_mcp/ui/prefab_dashboard.py
def _probe_local_model() -> Fetch:
    """Build internal probe local model.

    Returns:
        Fetch: The result produced by the operation.
    """

    return Fetch.get(
        f"{API_ORIGIN}/api/ui/local-model/probe",
        on_success=[
            SetState("local_model_busy", False),
            SetState("local_model_available", RESULT.available),
            SetState("local_model_recommended_tier", RESULT.tier),
            SetState("local_model_recommended_ollama_model", RESULT.ollama_model),
            SetState("local_model_pull_command", RESULT.pull_command),
            SetState("local_model_label", RESULT.label),
            SetState("local_endpoint", RESULT.openai_endpoint),
            SetState("model_name", RESULT.service_model),
            SetState("model_provider", "local"),
            SetState("local_model_status_text", RESULT.status_message),
            ShowToast("Local model probe complete"),
        ],
        on_error=[
            SetState("local_model_busy", False),
            SetState(
                "local_model_status_text",
                "Local model probe failed. Confirm the backend can reach Ollama.",
            ),
            _error_toast(),
        ],
    )
_pull_recommended_local_model() -> Fetch

Build internal pull recommended local model.

Returns:

Name Type Description
Fetch Fetch

The result produced by the operation.

Source code in src/solidworks_mcp/ui/prefab_dashboard.py
def _pull_recommended_local_model() -> Fetch:
    """Build internal pull recommended local model.

    Returns:
        Fetch: The result produced by the operation.
    """

    return Fetch.post(
        f"{API_ORIGIN}/api/ui/local-model/pull",
        body={"model": STATE.local_model_recommended_ollama_model},
        on_success=[
            SetState("local_model_busy", False),
            SetState(
                "local_model_status_text",
                "Model pull completed. Re-run Auto-Detect Local Model to refresh availability.",
            ),
            ShowToast("Recommended Ollama model pull completed"),
        ],
        on_error=[
            SetState("local_model_busy", False),
            SetState(
                "local_model_status_text",
                "Recommended model pull failed. Check Ollama and retry.",
            ),
            _error_toast(),
        ],
    )

_refresh_preview

_refresh_preview() -> Fetch

Refresh preview and hydrate from the POST result payload directly.

Returns:

Name Type Description
Fetch Fetch

The result produced by the operation.

Source code in src/solidworks_mcp/ui/prefab_dashboard.py
def _refresh_preview() -> Fetch:
    """Refresh preview and hydrate from the POST result payload directly.

    Returns:
        Fetch: The result produced by the operation.
    """
    return Fetch.post(
        f"{API_ORIGIN}/api/ui/preview/refresh",
        body={"session_id": STATE.session_id, "orientation": "isometric"},
        on_success=_hydrate_from_result(),
        on_error=_error_toast(),
    )

_refresh_state

_refresh_state() -> Fetch

Re-hydrate from canonical session state after multi-step actions.

Returns:

Name Type Description
Fetch Fetch

The result produced by the operation.

Source code in src/solidworks_mcp/ui/prefab_dashboard.py
def _refresh_state() -> Fetch:
    """Re-hydrate from canonical session state after multi-step actions.

    Returns:
        Fetch: The result produced by the operation.
    """
    return Fetch.get(
        f"{API_ORIGIN}/api/ui/state",
        params={"session_id": SESSION_ID_EXPR},
        on_success=_hydrate_from_result(),
        on_error=_error_toast(),
    )

_result_state

_result_state(key: str, fallback: object | None = None) -> object

Build internal result state.

Parameters:

Name Type Description Default
key str

The key value.

required
fallback object | None

The fallback value. Defaults to None.

None

Returns:

Name Type Description
object object

The result produced by the operation.

Source code in src/solidworks_mcp/ui/prefab_dashboard.py
def _result_state(key: str, fallback: object | None = None) -> object:
    """Build internal result state.

    Args:
        key (str): The key value.
        fallback (object | None): The fallback value. Defaults to None.

    Returns:
        object: The result produced by the operation.
    """

    value = getattr(RESULT, key)
    # Keep unit-test semantics for the lightweight stubbed _Expr object.
    if (
        fallback is not None
        and type(value).__name__ == "_Expr"
        and getattr(value, "value", None) == key
    ):
        return fallback
    return value