Don't execute fragments/attachments in !edit sessions, closes #1074

This commit is contained in:
Simon Willison 2025-05-23 23:43:47 -07:00
parent 9dace69af7
commit a7c51e2871
2 changed files with 2 additions and 6 deletions

View file

@ -73,7 +73,7 @@ Explain the difference between fragments and templates to me
!end
```
Additionally, any `!fragment` lines found in a prompt created with `!edit` will also be parsed.
Any `!fragment` lines found in a prompt created with `!edit` will not be parsed.
(fragments-browsing)=
## Browsing fragments

View file

@ -1156,11 +1156,7 @@ def chat(
if edited_prompt is None:
click.echo("Editor closed without saving.", err=True)
continue
prompt, fragments, attachments = process_fragments_in_chat(
db, edited_prompt.strip()
)
if not prompt and not fragments and not attachments:
continue
prompt = edited_prompt.strip()
if prompt.strip().startswith("!fragment "):
prompt, fragments, attachments = process_fragments_in_chat(db, prompt)