Skip to content

FE-1667: Run experiments from Petrinaut AI chat - #9678

Merged
kube merged 6 commits into
codex/fe-1666-experiment-hostfrom
codex/fe-1667-ai-experiment-chat
Sep 15, 2026
Merged

kube merged 6 commits into
codex/fe-1666-experiment-hostfrom
codex/fe-1667-ai-experiment-chat

Conversation

@kube

@kube kube commented Sep 11, 2026 •

Copy link
Copy Markdown
Contributor

Important

Experimental optimization
Optimization requires Parameter sweeps and In-browser optimization. Simulation is available without these flags.

Summary

Petrinaut AI can create experiments through the browser host and show their progress in the conversation. A compact card provides cancellation, the final metric, and a link to the experiment drawer.

The conversation stays mounted while the user inspects an experiment. Completion returns one captured tool result with the original call ID.

Experiments in chat

Links

Blocked by

Changes

  • Register createExperiment with its canonical schema and dispatch it from the AI panel
  • Show blue simulation cards and purple optimization cards with animated progress and reduced-motion support
  • Cancel owned requests when the chat stops, clears, changes conversation, or unmounts
  • Keep chat state across Edit, Simulate, and Notebook modes
  • Include core and React patch changesets and a chat flow diagram

Known issues

The additional Brunch test:root-creation and test:typed-state browser scripts stop at Unknown admitted browser observation call before reaching the changed diagnostic assertions. Those two runs are not counted as passing coverage.

Test coverage

The AI request schema now imports from the contract module, without the worker backend. The inherited bundler regression reproduced the HASH Edge deployment failure and passes with this import fixed.

After the 15 September restack onto main a898a13810, core, editor, website, and Brunch builds, unit tests, TypeScript, and lint passed on the integrated stack (52 tasks). Architecture validation, the documentation site build, and changed-file formatting passed. The 96 focused tests cover experiment cards, panel execution, and title editing.

  • AI panel tests cover tool-call identity, progress, cancellation before the first progress update, conversation changes, host rejection, and observed history
  • Card tests cover active ownership, unavailable results, terminal states, and accessible controls
  • Editor tests cover keeping the conversation mounted across modes
  • Browser verification completed a 256-run simulation, opened its heatmap and histogram, and retained the chat across modes without console errors. Browser optimization was not rerun at the user's request; optimization and cancellation remain covered by tests.

The earlier browser compiler-repair test passed through invalid code, repair, an unchanged diagnostic result, and recorded layout using installed Playwright Chromium. That run and the existing recordings predate this restack.

How to test

  • Run yarn workspace @hashintel/petrinaut test:unit --run src/ui/views/Editor/panels/ai-assistant-panel.test.tsx src/ui/views/Editor/panels/ai-assistant-panel/ai-assistant-contents/experiment-card.test.tsx src/ui/views/Editor/editor-view.test.tsx
  • Use the integration demo to inspect live cards and open the experiment drawer

@kube kube self-assigned this Sep 11, 2026
@vercel

vercel Bot commented Sep 11, 2026 •

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated
hash Ready Ready Preview Sep 15, 2026 12:29pm UTC
petrinaut Ready Ready Preview Sep 15, 2026 12:29pm UTC
petrinaut-docs Ready Ready Preview Sep 15, 2026 12:29pm UTC
1 Skipped Deployment
Project Deployment Actions Updated
hashdotdesign-tokens Ignored Ignored Preview Sep 15, 2026 12:29pm UTC

Request Review

@github-actions github-actions Bot added area/infra Relates to version control, CI, CD or IaC (area) area/libs Relates to first-party libraries/crates/packages (area) type/eng > frontend Owned by the @frontend team type/eng > backend Owned by the @backend team labels Sep 11, 2026
@kube
kube added this pull request to stack #9679 September 11, 2026 14:48
@kube
kube marked this pull request as ready for review September 11, 2026 18:33
Copilot AI balanced review requested due to automatic review settings September 11, 2026 18:33
@cursor

cursor Bot commented Sep 11, 2026 •

Copy link
Copy Markdown

PR Summary

Medium Risk
New client-side experiment execution from chat ties into the browser experiment host with cancellation and conversation lifecycle; incorrect handling could leak stale results or abort runs unexpectedly, but behavior is heavily tested.

Overview
Adds createExperiment to the Petrinaut AI tool manifest (core schema + export) so chat can start simulations and optimizations through the browser ExperimentHostContext.

The assistant panel runs the tool client-side: progress and cancellation state per tool call, a single automatic tool result when the host finishes, and abort on stop/clear/conversation change. Chat renders a dedicated ExperimentCard (status, runs, metrics, cancel, View experiment) instead of a generic tool row.

EditorView keeps AiAssistantPanel mounted when switching to Simulate or Notebook so users can inspect experiments without losing the thread. Clean net diagnostics text now notes that scenario and metric compilation is validated when creating an experiment.

User and architecture docs, changesets, and unit/integration test updates align with the new flow.

Reviewed by Cursor Bugbot for commit 97a299e. Bugbot is set up for automated code reviews on this repo. Configure here.

@cursor cursor Bot left a comment •

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Stale Bugbot comment from a previous run.

Comment thread libs/@hashintel/petrinaut/src/ui/views/Editor/panels/ai-assistant-panel.tsx Outdated

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Changes recommended

AI optimization currently bypasses the required Parameter sweeps feature flag.

Once you've addressed the issues Copilot identified, you can request another Copilot review.

Pull request overview

Adds AI-driven Petrinaut experiments with live progress, cancellation, result cards, and persistent chat across editor modes.

Changes:

  • Registers and executes createExperiment.
  • Adds experiment cards, lifecycle handling, and tests.
  • Updates architecture docs, user guides, and changesets.
File summaries
File Description
libs/@local/petrinaut-arch-docs/content/experiments/ai-created-experiments.mdx Links browser-host and chat architecture.
libs/@local/petrinaut-arch-docs/content/diagrams/ai-experiment-chat.d2 Adds chat experiment flow diagram.
libs/@local/petrinaut-arch-docs/content/ai/experiment-chat.mdx Documents chat integration.
libs/@hashintel/petrinaut/src/ui/views/Editor/panels/ai-assistant-panel/types.ts Adds experiment tool message types.
libs/@hashintel/petrinaut/src/ui/views/Editor/panels/ai-assistant-panel/README.md Declares the AI panel architecture layer.
libs/@hashintel/petrinaut/src/ui/views/Editor/panels/ai-assistant-panel/format-diagnostics-for-ai.ts Clarifies experiment compilation behavior.
libs/@hashintel/petrinaut/src/ui/views/Editor/panels/ai-assistant-panel/format-diagnostics-for-ai.test.ts Updates diagnostics expectation.
libs/@hashintel/petrinaut/src/ui/views/Editor/panels/ai-assistant-panel/ai-assistant-contents/get-message-render-items.ts Routes experiment parts to cards.
libs/@hashintel/petrinaut/src/ui/views/Editor/panels/ai-assistant-panel/ai-assistant-contents/experiment-card.tsx Implements progress and result cards.
libs/@hashintel/petrinaut/src/ui/views/Editor/panels/ai-assistant-panel/ai-assistant-contents/experiment-card.test.tsx Tests card states and progress.
libs/@hashintel/petrinaut/src/ui/views/Editor/panels/ai-assistant-panel/ai-assistant-contents.tsx Renders experiment state and controls.
libs/@hashintel/petrinaut/src/ui/views/Editor/panels/ai-assistant-panel.tsx Dispatches and manages experiment requests.
libs/@hashintel/petrinaut/src/ui/views/Editor/panels/ai-assistant-panel.test.tsx Tests experiment lifecycle integration.
libs/@hashintel/petrinaut/src/ui/views/Editor/editor-view.tsx Keeps chat mounted across modes.
libs/@hashintel/petrinaut/src/ui/views/Editor/editor-view.test.tsx Verifies persistent panel mounting.
libs/@hashintel/petrinaut/docs/experiments.md Documents assistant-created experiments.
libs/@hashintel/petrinaut/docs/ai-assistant.md Documents chat experiment workflows.
libs/@hashintel/petrinaut-core/src/index.ts Exports the experiment tool name.
libs/@hashintel/petrinaut-core/src/ai.ts Registers the canonical tool schema.
.changeset/small-experiments-chat.md Records the Petrinaut package change.
.changeset/experiment-ai-tool.md Records the core package change.
Review details
  • Files reviewed: 21/21 changed files
  • Comments generated: 1
  • Review effort level: Balanced (auto)

Note

Copilot is running an experiment and ran this review at Balanced.


💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment thread libs/@hashintel/petrinaut/src/ui/views/Editor/panels/ai-assistant-panel.tsx Outdated

@cursor cursor Bot left a comment •

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Stale Bugbot comment from a previous run.

@kube
kube removed this pull request from stack #9698 September 14, 2026 15:50
@kube
kube added this pull request to stack #9717 September 14, 2026 15:51

@cursor cursor Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cursor Bugbot has reviewed your changes and found 1 potential issue.

Fix All in Cursor

❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.

Reviewed by Cursor Bugbot for commit 17833c9. Configure here.

CiaranMn
CiaranMn previously approved these changes Sep 15, 2026
@kube
kube added this pull request to the merge queue Sep 15, 2026
Merged via the queue into main with commit e563842 Sep 15, 2026
108 of 119 checks passed
@hash-release hash-release Bot mentioned this pull request Sep 15, 2026

This branch was successfully deployed

3 active deployments
Preview – hash — 97a299e7 Deployed Sep 15, 2026 by vercel[bot]
Preview – petrinaut-docs — 97a299e7 Deployed Sep 15, 2026 by vercel[bot]
Preview – petrinaut — 97a299e7 Deployed Sep 15, 2026 by vercel[bot]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area/apps area/infra Relates to version control, CI, CD or IaC (area) area/libs Relates to first-party libraries/crates/packages (area) area/tests New or updated tests type/eng > backend Owned by the @backend team type/eng > frontend Owned by the @frontend team

Development

Successfully merging this pull request may close these issues.

4 participants