Skip to main content

render_delete_context_preview

Function render_delete_context_preview 

Source
pub fn render_delete_context_preview(
    id: &str,
    preview: &DeleteContextPreviewResultBody,
    book: &NameBook,
) -> bool
Expand description

Print the human-readable resource preview shown before context deletion. Returns true when the preview lists any resources (i.e. the caller should prompt for confirmation unless --yes).

Shared by online + offline delete paths so both warn about exactly the same resource classes. Render what deleting id destroys, and say whether it destroys anything — which is what the caller uses to decide whether to prompt.

The subtree comes from the agent now (subContexts, trust-tasks 0.21.4). Both callers used to derive it from the context list, which worked but put two reimplementations of the agent’s own cascade rule in front of a destructive prompt — and the CLI’s answer was only as good as its copy of the path matching.

It must count toward the “anything at all” answer: a parent holding nothing over children holding everything otherwise renders as an empty preview, and the caller deletes the whole subtree without asking.

did_templates counts here too. It did not, so a context whose only contents were templates rendered nothing and skipped the prompt.