Skip to content

Commit b015428

Browse files
dev-swarupclaude
andcommitted
feat: add helper install prompt and preferences section
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
1 parent 35282c4 commit b015428

5 files changed

Lines changed: 114 additions & 7 deletions

File tree

‎src/agent/roles.py‎

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,8 +48,9 @@
4848
parts "Crate.Body", "Crate.Lid", materials "Crate.Wood". If the file already has a naming scheme, follow it.
4949
- Build each asset in its own collection named after it. Don't change objects you didn't make unless asked;
5050
inspect with get_scene_info before editing them. Names are case-sensitive.
51-
- get_capabilities lists optional helper add-ons, image generation and connected MCP servers. If a request
52-
needs something missing, say which add-on or setting the user should enable.
51+
- get_capabilities lists the helper add-ons (Rigify, MPFB, LoopTools, Extra Mesh Objects), image generation and
52+
connected MCP servers. If a helper is missing, tell the user to click Install helper add-ons in Blender AI's
53+
preferences; for any other missing setting, say which one to change.
5354
- Image textures are packed into the .blend automatically, so the file stays self-contained.
5455
- Destructive steps (delete, apply modifier, bake) are fine when they're the right step; mention them.
5556
- Each user message starts with a short scene summary. Viewport screenshots may follow your tool calls; use

‎src/preferences.py‎

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99

1010
from . import models, state
1111
from .agent.config import AgentConfig
12+
from .integrations import registry as helpers
1213
from .providers import ANTHROPIC_URL, OPENAI_URL
1314
from .tools.registry import Mode
1415

@@ -140,8 +141,11 @@ class BlenderAIPreferences(AddonPreferences):
140141
)
141142
normal_convention: EnumProperty(name="Normal maps", items=[("OPENGL", "OpenGL (Blender)", ""), ("DIRECTX", "DirectX", "")], default="OPENGL")
142143

144+
helpers_prompted: BoolProperty(name="Asked about helper add-ons", default=False, options={"HIDDEN"})
145+
143146
show_images: BoolProperty(name="Separate image API", default=False)
144147
show_mcp: BoolProperty(name="MCP servers", default=False)
148+
show_helpers: BoolProperty(name="Helper add-ons", default=False)
145149
show_more: BoolProperty(name="More options", default=False)
146150

147151
def current_mode(self) -> Mode:
@@ -240,6 +244,8 @@ def draw(self, context: Any) -> None:
240244
_section(layout, self, "show_images", "Separate image API (optional)", "IMAGE_DATA", self._draw_images)
241245
count = len(self.mcp_servers)
242246
_section(layout, self, "show_mcp", f"MCP servers ({count})", "PLUGIN", self._draw_mcp)
247+
ready = len(helpers.HELPERS) - len(helpers.missing())
248+
_section(layout, self, "show_helpers", f"Helper add-ons ({ready} of {len(helpers.HELPERS)} ready)", "PACKAGE", self._draw_helpers)
243249
_section(layout, self, "show_more", "More options", "PREFERENCES", self._draw_more)
244250

245251
col = layout.column()
@@ -286,6 +292,15 @@ def _draw_mcp(self, col: Any) -> None:
286292
col.label(text=state.get().connection["mcp"], icon="INFO")
287293
col.label(text="New MCP tools are used from the next new conversation.", icon="INFO")
288294

295+
def _draw_helpers(self, col: Any) -> None:
296+
col.label(text="Blender AI builds better models, rigs and characters with these add-ons.")
297+
for helper in helpers.HELPERS.values():
298+
status = helpers.status(helper)
299+
row = col.row()
300+
row.label(text=helper.name, icon="CHECKBOX_HLT" if status == "enabled" else "CHECKBOX_DEHLT")
301+
row.label(text=status.capitalize())
302+
col.operator("blender_ai.install_helpers", icon="IMPORT")
303+
289304
def _draw_more(self, col: Any) -> None:
290305
col.prop(self, "confirm_python")
291306
row = col.row()

‎src/runtime.py‎

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,7 @@ def start() -> None:
8080
bpy.app.timers.register(_tick, first_interval=0.05, persistent=True)
8181
st.timers.append(_tick)
8282
bpy.app.timers.register(_startup, first_interval=1.0)
83+
dialogs.open_helpers_prompt_later()
8384
for handler_list, fn in ((bpy.app.handlers.load_post, _on_load), (bpy.app.handlers.save_pre, _on_save)):
8485
handler_list.append(fn)
8586
st.handlers.append((handler_list, fn))
@@ -94,8 +95,9 @@ def unregister() -> None:
9495
st.session.stop()
9596
if st.mcp is not None:
9697
st.mcp.shutdown()
97-
if bpy.app.timers.is_registered(_startup):
98-
bpy.app.timers.unregister(_startup)
98+
for fn in (_startup, dialogs.open_helpers_prompt):
99+
if bpy.app.timers.is_registered(fn):
100+
bpy.app.timers.unregister(fn)
99101
for module in reversed(UI_MODULES):
100102
with contextlib.suppress(RuntimeError):
101103
module.unregister()

‎src/tools/scene.py‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -64,8 +64,8 @@ def _collection_tree(col: bpy.types.Collection) -> dict[str, Any]:
6464

6565
@tool(obj({}), group="meta", mutates=False)
6666
def get_capabilities() -> dict[str, Any]:
67-
"""Report optional helpers (Rigify, MPFB, LoopTools, Extra Objects) and whether each is installed and
68-
enabled, whether image generation is configured (and with which model), the connected MCP servers, and
67+
"""Report the helper add-ons (Rigify, MPFB, LoopTools, Extra Mesh Objects) and whether each is installed
68+
and enabled, whether image generation is configured (and with which model), the connected MCP servers, and
6969
the Blender version. Call this before relying on a helper add-on or on image generation."""
7070
from .. import state
7171
from ..preferences import get_prefs

‎src/ui/dialogs.py‎

Lines changed: 90 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,10 @@
77

88
from .. import state
99
from ..agent.messages import Phase
10+
from ..integrations import registry as helpers
1011

1112
PREVIEW_LINES = 18
13+
HELPERS_DIALOG_ROWS = 7
1214

1315

1416
def _session_pending(call_id: str = "") -> Any:
@@ -102,7 +104,94 @@ def cancel(self, context: Any) -> None:
102104
session.approve(False)
103105

104106

105-
CLASSES = (BLENDER_AI_OT_approval_dialog,)
107+
def _prefs() -> Any:
108+
from ..preferences import get_prefs
109+
110+
return get_prefs()
111+
112+
113+
def open_helpers_prompt() -> None:
114+
prefs = _prefs()
115+
if bpy.app.background or prefs is None or prefs.helpers_prompted or not bpy.app.online_access or not helpers.missing():
116+
return
117+
override = _view3d_override()
118+
if override is not None:
119+
window = override["window"]
120+
unit = 20 * bpy.context.preferences.system.ui_scale
121+
window.cursor_warp(window.width // 2 - round(2.5 * unit), window.height // 2 + round(HELPERS_DIALOG_ROWS * unit / 2))
122+
with bpy.context.temp_override(**override):
123+
bpy.ops.blender_ai.install_helpers("INVOKE_DEFAULT")
124+
125+
126+
def open_helpers_prompt_later() -> None:
127+
if not bpy.app.background:
128+
bpy.app.timers.register(open_helpers_prompt, first_interval=1.5)
129+
130+
131+
def _helpers_finished(missing: list[str]) -> None:
132+
session = state.get().session
133+
if session is not None:
134+
text = f"Couldn't install {', '.join(missing)}; see the Info editor." if missing else "Helper add-ons installed and enabled."
135+
session.notify(text, error=bool(missing))
136+
for window in bpy.context.window_manager.windows:
137+
for area in window.screen.areas:
138+
area.tag_redraw()
139+
140+
141+
class BLENDER_AI_OT_install_helpers(bpy.types.Operator):
142+
bl_idname = "blender_ai.install_helpers"
143+
bl_label = "Install helper add-ons"
144+
bl_description = "Install and enable the add-ons Blender AI builds with: Rigify, MPFB, LoopTools and Extra Mesh Objects"
145+
bl_options = {"INTERNAL"}
146+
147+
@classmethod
148+
def poll(cls, context: Any) -> bool:
149+
return bool(helpers.missing())
150+
151+
def invoke(self, context: Any, event: Any) -> set[str]:
152+
wm = context.window_manager
153+
try:
154+
return wm.invoke_props_dialog(self, width=520, title="Install helper add-ons?", confirm_text="Install")
155+
except TypeError:
156+
return wm.invoke_props_dialog(self, width=520)
157+
158+
def draw(self, context: Any) -> None:
159+
layout = self.layout
160+
layout.label(text="Blender AI builds better models, rigs and characters with these add-ons:", icon="PACKAGE")
161+
col = layout.box().column(align=True)
162+
for helper in helpers.HELPERS.values():
163+
ready = helpers.enabled_module(helper.id) is not None
164+
source = "included with Blender" if helper.bundled else f"extensions.blender.org, {helper.size}"
165+
col.label(text=f"{helper.name}: {'enabled' if ready else source}", icon="CHECKBOX_HLT" if ready else "CHECKBOX_DEHLT")
166+
col = layout.column(align=True)
167+
col.label(text="Install downloads the missing ones from extensions.blender.org and enables them all.", icon="INFO")
168+
col.label(text="Cancel skips this; you can install them later in Blender AI's preferences.")
169+
170+
def execute(self, context: Any) -> set[str]:
171+
from ..integrations import installer
172+
173+
prefs = _prefs()
174+
if prefs is not None:
175+
prefs.helpers_prompted = True
176+
try:
177+
enabled, downloading = installer.install(interactive=context.window is not None)
178+
except installer.InstallError as exc:
179+
self.report({"ERROR"}, str(exc))
180+
return {"CANCELLED"}
181+
if downloading:
182+
installer.watch(_helpers_finished)
183+
self.report({"INFO"}, (f"Enabled {', '.join(enabled)}. " if enabled else "") + f"Installing {', '.join(downloading)}…")
184+
else:
185+
_helpers_finished([h.name for h in helpers.missing()])
186+
return {"FINISHED"}
187+
188+
def cancel(self, context: Any) -> None:
189+
prefs = _prefs()
190+
if prefs is not None:
191+
prefs.helpers_prompted = True
192+
193+
194+
CLASSES = (BLENDER_AI_OT_approval_dialog, BLENDER_AI_OT_install_helpers)
106195

107196

108197
def register() -> None:

0 commit comments

Comments
 (0)