H-2480: Convert browser plugin to use Flows
π What is the purpose of this PR?
This PR converts the browser plugin to use flows instead of its legacy code, mainly:
- Introducing two special flow definitions for manual and automatic browser plugin inference
- Updating the browser plugin and API to trigger these flows instead of the previous dedicated workflow for browser inference
- Replace the old 'Logs' tab with a 'History' tab to show flows (internal design)
- Delete the code the old browser plugin inference functions were using, apart from anything that is still in use by other flow actions (to be cleaned up later)
Some changes to the Temporal workfow
- Throw errors from the workflow rather than returning them so Temporal views the workflow as failed
- Switch from using
WAIT_CANCELLATION_COMPLETEDfor activities because activities are not set up to receive cancellation signals and clean up (H-2545) - Set explicit activity ids on the non-Flow step activities (persist flow, check user permission) to avoid auto-generated ids clashing with our step ids
Tangentially:
- Add a
getFlowRunByIdresolver and refactor the existinggetFlowRunsto allow for requesting a list of flow runs without needing to check the event history if it isn't required β I ended up not needing this but I will use it for H-1323 so that we can poll for lists of flows without bothering with the event history for all of them. - Update
getFlowRunsto fetch the FlowRun entities visible to the user instead of fetching all flows in Temporal
Pre-Merge Checklist π
π’ Has this modified a publishable library?
This PR:
- [x] does not modify any publishable blocks or libraries, or modifications do not need publishing
π Does this require a change to the docs?
The changes in this PR:
- [x] are internal and do not require a docs change
πΈοΈ Does this require a change to the Turbo Graph?
The changes in this PR:
- [x] do not affect the execution graph
β οΈ Known issues
- H-1323: Some pages the plugin links to don't yet exist (up next), e.g. a page listing all flows
- H-2715: The history tab in the plugin doesn't show background requests from flows for pages
- H-2669: Overflow if the DAG is too wide for the screen isn't handled properly if the nav sidebar is open
πΎ Next steps
H-1323.
π‘ What tests cover this?
None yet
β How to test this?
- Run the API, AI worker and plugin locally, load plugin into browser
- Trigger some manual flows from the plugin or configure automatic and browse
- Check history tab, check view of flow definitions + runs in HASH
πΉ Demo
https://github.com/hashintel/hash/assets/37743469/dfee89d6-c7bc-4183-a42c-530e74623ca7
Codecov Report
Attention: Patch coverage is 0% with 155 lines in your changes missing coverage. Please review.
Project coverage is 21.53%. Comparing base (
b59a6d4) to head (90d859e). Report is 2054 commits behind head on main.
Additional details and impacted files
@@ Coverage Diff @@
## main #4473 +/- ##
==========================================
+ Coverage 21.08% 21.53% +0.45%
==========================================
Files 449 446 -3
Lines 15259 14940 -319
Branches 2282 2224 -58
==========================================
Hits 3218 3218
+ Misses 12000 11681 -319
Partials 41 41
| Flag | Coverage Ξ | |
|---|---|---|
| apps.hash-ai-worker-ts | 2.00% <0.00%> (+0.21%) |
:arrow_up: |
| apps.hash-api | 0.00% <0.00%> (ΓΈ) |
|
| local.hash-backend-utils | 4.38% <0.00%> (-1.04%) |
:arrow_down: |
| local.hash-isomorphic-utils | 0.00% <0.00%> (ΓΈ) |
Flags with carried forward coverage won't be shown. Click here to find out more.
:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.
π New features to boost your workflow:
- β Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
- π¦ JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.