Skip to content

AI Assistant: restore Save to Macros in reloaded conversations, show saved macros, propose macros without running them - #448

Merged
PierreRaybaut merged 2 commits into
developfrom
fix/447-ai-assistant-save-macro
Oct 28, 2026
Merged

PierreRaybaut merged 2 commits into
developfrom
fix/447-ai-assistant-save-macro

Conversation

@PierreRaybaut

@PierreRaybaut PierreRaybaut commented Oct 28, 2026 •

Copy link
Copy Markdown
Contributor

Summary

Macros proposed by the AI Assistant could get lost or stay out of reach. Found while checking the DataLab-Web issue DataLab-Platform/web#76 against DataLab desktop (Web fix: DataLab-Platform/web#77).

Closes #447

Changes

  • Reloaded conversations: live turns and conversations reopened from History... now share the tool-result rendering (_append_tool_result). The JSON payload of each tool message is parsed, so a reloaded conversation shows the actual ✓/✗ outcome of each call and restores the Save to Macros link of create_and_run_macro results.
  • Saved macro hidden: the Macro panel is tabbed with the AI Assistant; the confirmation line now offers a Show in Macro panel link (no automatic switch, which would hide the conversation).
  • Write without running: the existing autorun parameter of create_and_run_macro is now documented in the tool schema, and the system prompt routes "write a macro" requests to autorun=false instead of plain code in the reply. The confirmation dialog states that such a macro will not be executed (Approve instead of Run), and the tool result tells the model so.
  • Code blocks in replies: as a fallback, a Save to Macros link is offered under each Python code block of the replies (new optional code_block_footer callback of markdown_to_html), named after the user request, unless AI macros are disabled.
  • Docs: user guide (ai_assistant.rst), 1.4.0 release notes, French translations (UI, user guide, release notes).

Tests

  • New test_chatpanel_macros.py (GUI): autorun=False runs nothing; reloaded conversation restores the links and the failed status; saving from tool results and code blocks; Show in Macro panel brings the panel to the front; no code-block link when AI macros are disabled; confirmation dialog wording. The reload and live-turn tests fail on the previous chatpanel.py.
  • New test_markdown.py: Python block detection and footer callback.
  • test_tool_registry.py / test_controller.py: documented autorun, prompt rule only when the macro tool is exposed.
  • pytest datalab/tests/aiassistant datalab/tests/features/macro datalab/tests/features/common/welcome_unit_test.py: 102 passed. Ruff and Pylint (10/10) clean on the changed files.

Not covered: the actual choice of a real LLM (the prompt makes plain-code answers less likely; the code-block link covers the remaining cases).

Macros proposed by the AI Assistant could get lost or stay out of reach:

- A conversation reopened from History... showed a 200-character summary
  of each tool message, without parsing its JSON payload: the "Save to
  Macros" link of create_and_run_macro results was not restored, and
  failed tool calls were displayed as successful. Live turns and reloaded
  conversations now share _append_tool_result, which uses the actual
  status and restores the link.
- Saving a macro added it to the Macro panel, which is tabbed with the AI
  Assistant and stayed hidden. The confirmation line now has a "Show in
  Macro panel" link (no automatic switch, which would hide the
  conversation).
- create_and_run_macro accepted autorun=False (validate and offer the
  macro without running it), but neither the schema nor the system prompt
  said so: a "write a macro" request could be answered with plain code
  that cannot be saved. The parameter is now documented, the prompt routes
  such requests to autorun=False, and the confirmation dialog states that
  the macro will not be executed ("Approve" instead of "Run").
- As a fallback, a "Save to Macros" link is offered under each Python code
  block of the replies (markdown_to_html gets an optional code_block_footer
  callback), named after the user request, unless AI macros are disabled.

Closes #447

Assisted-by: Claude Opus 5.5
…ons)

Describe macros proposed without being run, the "Save to Macros" links
under code blocks and in reloaded conversations, and the "Show in Macro
panel" link; add the corresponding 1.4.0 bug-fix notes, with their French
translations.

Refs #447

Assisted-by: Claude Opus 5.5
@PierreRaybaut
PierreRaybaut merged commit 4586037 into develop Oct 28, 2026
6 checks passed
@PierreRaybaut
PierreRaybaut deleted the fix/447-ai-assistant-save-macro branch October 28, 2026 14:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant