Skip to content

fix(aiassistant): wait for the Macros panel when saving a macro - #81

Merged
PierreRaybaut merged 1 commit into
developfrom
fix/ai-assistant-save-macro-race
Oct 31, 2026
Merged

PierreRaybaut merged 1 commit into
developfrom
fix/ai-assistant-save-macro-race

Conversation

@PierreRaybaut

Copy link
Copy Markdown
Contributor

Summary

The Playwright test AI Assistant — Save to Macros (worker mode) › saves the macro of a conversation restored after a reload fails intermittently: on develop (run 40705623006, commit 52aabe0) and on the Dependabot PR #79 (marked 18.1.1 → 18.1.2, which is not involved). Both runs failed the first attempt and the retry.

Root causes and fixes

  • Early click after a reload: the AI Assistant panel is loaded with the app, whereas the Macros panel is lazy-loaded. After a reload, the restored conversation shows Save to Macros before the Macros panel is mounted; an early click failed with Macros panel is not available yet ("Retry save" / "save failed (see console)"), and the Macros tab stayed hidden. The trace of the failed CI run shows exactly this error. App now waits for the panel through a small PendingHandle (callback ref + bounded wait, 60 s), for Save to Macros and for Convert to macro (notebooks).
  • Import during the restoration of the macros: the initial load of MacroPanel replaces its macros, open tabs and active tab with what it listed. A macro imported while it ran was created in the workspace but disappeared from the panel (the hidden-macro symptom of AI Assistant: "Save to Macros" does nothing in worker mode, and the model writes macro code instead of calling the tool #76). MacroPanel now exposes its handle only once that load is done (useImperativeHandle(loaded ? ref : null, …)), so callers wait for it.

No changelog entry: this completes the unreleased AI Assistant — Save to Macros fix (#77), whose entry already covers conversations reopened from the history.

Tests

  • E2E (permanent, the mechanism is a subtle race): ai_assistant_macro.spec.ts now holds the MacroPanel.tsx module until the click, which makes the reload scenario deterministic. It fails on develop with the CI symptom and passes with the fix (3 repeated runs).
  • Unit: MacroPanel.test.tsx (a macro imported while the workspace macros are restored stays open and active — fails without the MacroPanel change), pendingHandle.test.ts.
  • prettier, eslint, tsc -b, vitest run (984 passed), Playwright ai_assistant_macro (×3) and macro specs; a throwaway probe (deleted) checked Convert to macro from a notebook.

After a reload, the restored conversation shows "Save to Macros" before the
lazy-loaded Macros panel is mounted: an early click failed, which made the
E2E test flaky in CI. The save now waits for the panel, which exposes its
handle only once it has restored the workspace macros: a macro imported
during that restoration disappeared from the panel.

Assisted-by: Claude Opus 5.5
@PierreRaybaut
PierreRaybaut merged commit 56d0d1c into develop Oct 31, 2026
9 checks passed
@PierreRaybaut
PierreRaybaut deleted the fix/ai-assistant-save-macro-race branch October 31, 2026 08:33
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