Skip to content

FE-1534: Run Storybook against the real optimizer service - #9395

Merged
kube merged 4 commits into
mainfrom
cf/fe-1534-run-storybook-against-the-real-optimizer-service
Sep 3, 2026
Merged

FE-1534: Run Storybook against the real optimizer service#9395
kube merged 4 commits into
mainfrom
cf/fe-1534-run-storybook-against-the-real-optimizer-service

Conversation

@kube

@kube kube commented Aug 28, 2026

Copy link
Copy Markdown
Collaborator

Important

Dev tooling, nothing user-facing.

Summary

Before this PR, demo website consumes Petrinaut's built dist, so editor changes need a rebuild before they show against the real optimizer. Storybook builds the editor from source with fast refresh but only offered a fake optimizer.

turbo run dev --filter @hashintel/petrinaut -- --with-optimizer-service now runs Petrinaut's Storybook against the real service. Service adapter moves into the shared optimizer client so the website and Storybook use one implementation.

Links

Changes

Shared adapter

  • Service adapter moves into @local/petrinaut-optimizer-client

    Exported as createServicePetrinautOptimization({ endpoint, fetchImpl }).
    Carries the client construction plus the error-classification fields category, httpStatus and retryAfter that Petrinaut's optimization provider reads for its reconnect logic.
    Its tests move with it.
    Website file shrinks to its dev-proxy endpoint plus a delegation.

Storybook

  • Storybook's Vite server proxies /api/petrinaut-opt/*

    Same proxy as the website's, targeting PETRINAUT_OPT_ORIGIN.

  • "With real optimizer" story mounts the full editor against the real service

    Supply-chain-profit net inside a PetrinautOptimizationContext backed by the service.
    Requires VITE_PETRINAUT_OPT_PROVIDER=service; otherwise the story renders the launch instructions.

  • Story files are exempted from the "no unpublished local packages" lint rule

    Stories are not part of the published build.

  • Petrinaut dev task gains --with-optimizer-service

    libs/@hashintel/petrinaut/scripts/dev.sh runs Storybook as before.
    With the flag it starts the optimizer service through the shared shell library first and passes the provider environment.
    Every other argument after -- goes to Storybook.

Test coverage

  • service-optimization.test.ts in @local/petrinaut-optimizer-client:

    Adapter's error classification, moved from the website.

How to test

  • turbo run dev --filter @hashintel/petrinaut -- --with-optimizer-service
  • Petrinaut > With real optimizer
  • Simulate mode > create optimization study
  • Expect study running on local container
  • Edit editor source
  • Expect fast refresh
  • turbo run dev --filter @hashintel/petrinaut alone
  • Expect story renders launch instructions instead

@kube kube self-assigned this Aug 28, 2026
@vercel

vercel Bot commented Aug 28, 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 3, 2026 4:26pm UTC
petrinaut Ready Ready Preview Sep 3, 2026 4:26pm UTC
petrinaut-docs Ready Ready Preview Sep 3, 2026 4:26pm UTC
1 Skipped Deployment
Project Deployment Actions Updated
hashdotdesign-tokens Ignored Ignored Preview Sep 3, 2026 4:26pm UTC

Request Review

@github-actions github-actions Bot added area/deps Relates to third-party dependencies (area) 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 area/apps area/apps > hash.design Affects the `hash.design` design site (app) labels Aug 28, 2026
@kube
kube force-pushed the cf/fe-1534-run-storybook-against-the-real-optimizer-service branch from baaf0d1 to 1fcc66b Compare August 30, 2026 13:08
@kube
kube force-pushed the cf/fe-1534-run-storybook-against-the-real-optimizer-service branch from 1fcc66b to 3a26525 Compare September 1, 2026 23:17
@kube
kube force-pushed the cf/fe-1534-run-storybook-against-the-real-optimizer-service branch from 3a26525 to 7006ea4 Compare September 2, 2026 15:04
@kube
kube force-pushed the cf/fe-1534-run-storybook-against-the-real-optimizer-service branch from 7006ea4 to 4ad2bc5 Compare September 2, 2026 16:12
YannisZa
YannisZa previously approved these changes Sep 3, 2026
TimDiekmann
TimDiekmann previously approved these changes Sep 3, 2026
@kube
kube added this pull request to the merge queue Sep 3, 2026
@github-merge-queue
github-merge-queue Bot removed this pull request from the merge queue due to a manual request Sep 3, 2026
@kube
kube dismissed stale reviews from TimDiekmann and YannisZa via 2d7149c September 3, 2026 13:03
@kube
kube force-pushed the cf/fe-1534-run-storybook-against-the-real-optimizer-service branch from 018bba3 to 2d7149c Compare September 3, 2026 13:03
@kube
kube requested a review from TimDiekmann September 3, 2026 13:03
TimDiekmann
TimDiekmann previously approved these changes Sep 3, 2026

@TimDiekmann TimDiekmann left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

re-approval of pre-rebase

@kube
kube added this pull request to the merge queue Sep 3, 2026
@github-merge-queue
github-merge-queue Bot removed this pull request from the merge queue due to failed status checks Sep 3, 2026
Base automatically changed from cf/fe-1529-local-optimizer-loop-docs-and-launcher to main September 3, 2026 16:17
kube added 4 commits September 3, 2026 16:17
`turbo run dev --filter @hashintel/petrinaut -- --with-optimizer-service` starts the local Petrinaut Optimizer around Storybook through the shared dev-service module, replacing the launcher's --storybook mode.
@kube
kube force-pushed the cf/fe-1534-run-storybook-against-the-real-optimizer-service branch from 696a60d to 0fdfdaf Compare September 3, 2026 16:17
@hash-release hash-release Bot mentioned this pull request Sep 3, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area/apps > hash.design Affects the `hash.design` design site (app) area/apps area/deps Relates to third-party dependencies (area) area/infra Relates to version control, CI, CD or IaC (area) area/libs Relates to first-party libraries/crates/packages (area) 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