hash icon indicating copy to clipboard operation
hash copied to clipboard

H-2480: Convert browser plugin to use Flows

Open CiaranMn opened this issue 9 months ago β€’ 1 comments

🌟 What is the purpose of this PR?

This PR converts the browser plugin to use flows instead of its legacy code, mainly:

  1. Introducing two special flow definitions for manual and automatic browser plugin inference
  2. Updating the browser plugin and API to trigger these flows instead of the previous dedicated workflow for browser inference
  3. Replace the old 'Logs' tab with a 'History' tab to show flows (internal design)
  4. 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

  1. Throw errors from the workflow rather than returning them so Temporal views the workflow as failed
  2. Switch from using WAIT_CANCELLATION_COMPLETED for activities because activities are not set up to receive cancellation signals and clean up (H-2545)
  3. 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:

  1. Add a getFlowRunById resolver and refactor the existing getFlowRuns to 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.
  2. Update getFlowRuns to 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?

  1. Run the API, AI worker and plugin locally, load plugin into browser
  2. Trigger some manual flows from the plugin or configure automatic and browse
  3. Check history tab, check view of flow definitions + runs in HASH

πŸ“Ή Demo

https://github.com/hashintel/hash/assets/37743469/dfee89d6-c7bc-4183-a42c-530e74623ca7

CiaranMn avatar May 16 '24 12:05 CiaranMn