fix: prevent PyMOL crash from unhandled AI component exceptions#4
Open
nmrson wants to merge 1 commit intoravishar313:masterfrom
Open
fix: prevent PyMOL crash from unhandled AI component exceptions#4nmrson wants to merge 1 commit intoravishar313:masterfrom
nmrson wants to merge 1 commit intoravishar313:masterfrom
Conversation
The PyMOL GUI would crash on startup or during use when AI component initialization or event processing raised unhandled exceptions. This was caused by several missing error boundaries: - get_ai_runtime() in _gui.py only wrapped the import in try/except but left the AiRuntime constructor call unprotected - update_feedback() timer callback had no error handling, so any exception would kill the Qt event loop and freeze/crash PyMOL - AI UI components (chat panel, chat store, history popup) were imported eagerly and created unconditionally, so any failure in these modules would prevent PyMOL from starting entirely - OpenGL widget was created after the chat panel, meaning a chat panel failure would prevent the core PyMOL viewer from initializing Key changes: - Move OpenGL widget creation before AI components so PyMOL core always initializes even if AI features fail - Make all AI-related imports defensive with try/except fallbacks - Guard all self.chat_panel, self.ext_window, self._chat_store references with None checks for graceful degradation - Wrap update_feedback() in try/finally to ensure the timer always restarts - Wrap doTypedCommand() AI handling in try/except so commands fall through to standard PyMOL processing on failure Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Owner
|
I will have a look at this |
Owner
|
Thanks for the fix. I validated PR #4 locally and AI init/runtime failures can currently crash the Qt app. I’d like a small follow-up before merge:
|
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.
Summary
Problem
PyMOL would crash entirely when:
get_ai_runtime()constructor failed (the function call was outside try/except)update_feedback()timer callback hit any exception (no error handling, kills Qt event loop)Changes
modules/pymol/ai/__init__.py: Defensive import of runtime modulemodules/pymol/_gui.py:get_ai_runtime()fully wrapped in try/except;doTypedCommand()AI path protectedmodules/pmg_qt/pymol_qt_gui.py:chat_panel,ext_window,_chat_storereferences null-guardedupdate_feedback()uses try/finally to always restart timer_on_chat_command_submitted,_on_chat_clear_requested,_on_chat_stop_requested) wrapped in try/exceptTest plan
claude-agent-sdk→ PyMOL starts without crash, AI features gracefully degradedopenaipackage → PyMOL starts without crash🤖 Generated with Claude Code