Skip to content

Vtk prompt fixes#42

Merged
jlee-kitware merged 10 commits into
masterfrom
vtk-prompt-fixes
Jun 18, 2026
Merged

Vtk prompt fixes#42
jlee-kitware merged 10 commits into
masterfrom
vtk-prompt-fixes

Conversation

@jlee-kitware

Copy link
Copy Markdown
Collaborator

Summary

A batch of independent bug and UX fixes for the vtk-prompt UI and its
vtk-mcp / config plumbing. These accumulated while building the editor
work and don't depend on it, so they're split out here to land on their
own. The editor feature builds on this branch and follows in a separate
PR.

Config and startup

  • Zero-arg startup now auto-discovers configuration (VTK_PROMPT_CONFIG,
    ./vtk-prompt.yml, ~/.config/vtk-prompt/config.yml) and loads .env,
    so vtk-prompt-ui comes up configured without explicit flags.
  • Config round-trip is complete: the loader reads mcp_url and
    base_url, and save_config writes base_url back out (previously
    dropped on save).
  • The api_token is seeded from OPENAI_API_KEY, so the Generate button
    appears when the key comes from .env or the environment rather than
    only from manual entry in the dialog.

vtk-mcp integration and prompt assembly

  • Replaced the dead RAG checkbox with a vtk-mcp URL field and gated Top K
    on mcp_url, matching the move to delegate VTK knowledge to vtk-mcp.
  • Fixed an empty-messages 400: config files with no messages key are
    settings-only, not prompts, so the client now falls back to built-in
    prompt assembly instead of sending an empty request.
  • Fixed retrieved context_snippets being rejected as "dangerous": the
    scalar guards (dunder / length checks) now exempt trusted
    retrieved-code variables.

Code generation and rendering

  • Fixed the renderer round-trip: generated code is exec'd with
    __name__ == "__main__" in a single namespace so scripts guarded by
    if __name__ == "__main__": actually run, and render_window is
    injected alongside renderer. Without this the guarded scripts no-op'd
    to a blank view.
  • Fixed import normalization that truncated
    from vtkmodules.X import vtkY down to import vtkY.

UI

  • Added persistent_placeholder on the prompt textarea to stop the label
    and placeholder text overlapping.

Notes

Base is master. The editor / completion feature is stacked on top of
this branch in a follow-up PR; merging this first lets that PR retarget
to master cleanly.

…o 'import vtkY'

Shared ensure_vtk_importable() replaces the brittle find('import vtk') slice in
client.py and code_executor.py; bump UI retry_attempts default to 3 so the
validation feedback loop can act. Adds regression tests.
…orts base_url

Lets a single --prompt-file restore local provider, Ollama base URL, model,
vtk-mcp URL, retries and params without re-typing in the UI.
…prompt.yml, ~/.config/vtk-prompt/config.yml) and loads .env
…hen the key comes from .env/env, not just manual entry
…y, not prompts; client falls back to built-in assembly
…d-code vars from scalar guards (dunder/length)
… (single namespace) so guarded main() scripts run; inject render_window
@jlee-kitware jlee-kitware mentioned this pull request Jun 17, 2026
@vicentebolea

vicentebolea commented Jun 18, 2026

Copy link
Copy Markdown
Member

I cant seem to submit a query (enter or ctrl-enter does not work) The issue seems to be only happening with local models. Also happens in #43

Screencast.from.2026-06-17.20-44-32.webm

@jlee-kitware

Copy link
Copy Markdown
Collaborator Author

if you go and set the API key in the settings->model tab then the Generate Code button will appear. AFAIK that has been the behavior that api key required even for local models. I just set to ollama but we can revisit the logic to just not require a key if running a local model.

In local mode the OpenAI-compatible endpoint (Ollama, LM Studio, ...)
ignores auth, but two things blocked submitting a query without a key:
the Generate Code button was gated on a non-empty api_token, so it never
appeared, and the client refuses to construct an OpenAI client with an
empty key.

Show the button whenever a key is not required (local mode) or one is
present (cloud), and fall back to a placeholder key in local mode that a
real key typed into the field overrides. Cloud providers (OpenAI,
Anthropic, Gemini, NIM) still require a real key, so an empty key there
still surfaces the "Set API Key" prompt as before.

@vicentebolea vicentebolea left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks great!

@jlee-kitware jlee-kitware merged commit e04f58d into master Jun 18, 2026
11 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants