This commit is contained in:
2026-02-02 14:09:42 -08:00
parent ccd47db869
commit 6309a3ff3e
7 changed files with 134 additions and 82 deletions

View File

@@ -3825,3 +3825,65 @@ def check_url_exists_in_storage(
_mark_preflight_checked()
return True
def display_and_persist_items(
items: List[Any],
title: str = "Result",
subject: Optional[Any] = None,
display_type: str = "item",
table: Optional[Table] = None,
) -> None:
"""Display detail panels and persist items for @N selection.
This helper function:
1. Renders individual detail panels for each item
2. Creates a result table with all items (or uses provided table)
3. Persists the table so @N selection works across command boundaries
Args:
items: List of items/dicts to display and make selectable
title: Title for the result table (default: "Result")
subject: Optional subject to associate with the results (usually first item or list)
display_type: Type of display - "item" (default), "tag", or "custom" (no panels)
table: Optional pre-built Table object (if None, creates new Table with title)
"""
if not items:
return
try:
# Create result table if not provided
if table is None:
table = Table(title=title)
# Render detail panels for each item (unless display_type is "custom")
if display_type != "custom":
try:
from SYS.rich_display import render_item_details_panel
# Determine panel title prefix based on display type
panel_prefix = "Tag" if display_type == "tag" else "Item"
# Render detail panel for each item
for idx, item in enumerate(items, 1):
try:
render_item_details_panel(item, title=f"#{idx} {panel_prefix} Details")
except Exception:
pass
except Exception:
pass
# Add items to table if not already added by caller
if not getattr(table, "_items_added", False):
for item in items:
table.add_result(item)
setattr(table, "_rendered_by_cmdlet", True)
# Use provided subject or default to first item
if subject is None:
subject = items[0] if len(items) == 1 else list(items)
# Persist table for @N selection across command boundaries
pipeline_context.set_last_result_table(table, list(items), subject=subject)
except Exception:
pass