This commit is contained in:
2026-05-04 15:58:24 -07:00
parent bca85defa4
commit 3ce339b3c1
6 changed files with 322 additions and 18 deletions
+32 -3
View File
@@ -33,7 +33,7 @@ from SYS.plugin_config import (
get_item_schema_map,
get_required_config_keys,
)
from ProviderCore.registry import get_plugin, get_plugin_class
from ProviderCore.registry import get_plugin, get_plugin_class, get_plugin_capabilities
from TUI.modalscreen.matrix_room_picker import MatrixRoomPicker
from TUI.modalscreen.selection_modal import SelectionModal
import logging
@@ -459,6 +459,21 @@ class ConfigModal(ModalScreen):
)
container.mount(row)
def _plugin_capability_summary(self, plugin_name: str) -> str:
caps = get_plugin_capabilities(plugin_name, self.config_data)
cmdlets = [str(v) for v in (caps.get("supported_cmdlets") or []) if str(v).strip()]
if caps.get("supports_pipe_download") and "pipe-download" not in cmdlets:
cmdlets.append("pipe-download")
if not cmdlets:
return ""
return ", ".join(sorted(set(cmdlets)))
def _plugin_label_with_capabilities(self, base_label: str, plugin_name: str) -> str:
summary = self._plugin_capability_summary(plugin_name)
if not summary:
return base_label
return f"{base_label} [caps: {summary}]"
def render_providers(self, container: ScrollableContainer) -> None:
container.mount(Label("Configured Plugins", classes="config-label"))
providers = self.config_data.get("provider", {})
@@ -482,8 +497,12 @@ class ConfigModal(ModalScreen):
del_id = f"del-provider-{idx}"
self._button_id_map[edit_id] = ("edit", f"plugin-{plugin_name}", instance_name)
self._button_id_map[del_id] = ("del", f"plugin-{plugin_name}", instance_name)
row_label = self._plugin_label_with_capabilities(
f"{display_name} ({plugin_name})",
str(plugin_name),
)
row = Horizontal(
Static(f"{display_name} ({plugin_name})", classes="item-label"),
Static(row_label, classes="item-label"),
Button("Edit", id=edit_id),
Button("Delete", variant="error", id=del_id),
classes="item-row"
@@ -496,8 +515,9 @@ class ConfigModal(ModalScreen):
del_id = f"del-provider-{idx}"
self._button_id_map[edit_id] = ("edit", "plugin", plugin_name)
self._button_id_map[del_id] = ("del", "plugin", plugin_name)
row_label = self._plugin_label_with_capabilities(str(plugin_name), str(plugin_name))
row = Horizontal(
Static(plugin_name, classes="item-label"),
Static(row_label, classes="item-label"),
Button("Edit", id=edit_id),
Button("Delete", variant="error", id=del_id),
classes="item-row"
@@ -530,16 +550,20 @@ class ConfigModal(ModalScreen):
item_name = str(self.editing_item_name or "")
item_schema_map = get_item_schema_map(item_type, item_name)
render_state = {"group": None, "mounted_any": False}
provider_for_caps: Optional[str] = None
# Parse item_type: plugin-{ptype} (multi-instance) or flat type
if item_type.startswith("plugin-"):
ptype = item_type[len("plugin-"):]
container.mount(Label(f"Editing {ptype}: {item_name}", classes="config-label"))
provider_for_caps = str(ptype)
plugin_block = self.config_data.get("plugin") or self.config_data.get("provider") or {}
plugin_instances = plugin_block.get(ptype, {}) if isinstance(plugin_block, dict) else {}
section = plugin_instances.get(item_name, {}) if isinstance(plugin_instances, dict) else {}
else:
container.mount(Label(f"Editing {item_type.capitalize()}: {item_name}", classes="config-label"))
if item_type in ("plugin", "provider"):
provider_for_caps = str(item_name)
section = self.config_data.get(item_type, {}).get(item_name, {})
# Use columns for better layout of inputs with paste buttons
@@ -549,6 +573,11 @@ class ConfigModal(ModalScreen):
# actually we don't need to do anything else here because refresh_view calls render_item_editor
# which now handles the paste buttons.
if provider_for_caps:
caps_summary = self._plugin_capability_summary(provider_for_caps)
if caps_summary:
container.mount(Static(f"Capabilities: {caps_summary}", classes="config-help"))
# Show all existing keys
existing_keys_upper = set()
idx = 0