hash icon indicating copy to clipboard operation
hash copied to clipboard

H-2480: Convert browser plugin to use Flows

Open CiaranMn opened this issue 1 year 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

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.

Files with missing lines Patch % Lines
libs/@local/hash-backend-utils/src/flows.ts 0.00% 36 Missing :warning:
...ties/process-automatic-browsing-settings-action.ts 0.00% 25 Missing :warning:
...sh-ai-worker-ts/src/workflows/run-flow-workflow.ts 0.00% 23 Missing :warning:
...l/hash-backend-utils/flows/get-flow-run-details.ts 0.00% 15 Missing :warning:
...ntities-websocket/handle-infer-entities-request.ts 0.00% 12 Missing :warning:
apps/hash-api/src/ai/infer-entities-websocket.ts 0.00% 10 Missing :warning:
.../src/graphql/resolvers/flows/get-flow-run-by-id.ts 0.00% 7 Missing :warning:
...ers/flows/shared/were-detailed-fields-requested.ts 0.00% 7 Missing :warning:
...h-api/src/graphql/resolvers/flows/get-flow-runs.ts 0.00% 5 Missing :warning:
...-websocket/handle-cancel-infer-entities-request.ts 0.00% 4 Missing :warning:
... and 7 more
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.

codecov[bot] avatar May 16 '24 13:05 codecov[bot]