Put the new instance in the Expert's context so it can navigate to the editor
- Dominant language
- JavaScript
- Stars
- 400
- Forks
- 89
- Avg merge
- 1d 20h
- Merged PRs (30d)
- 149
Description
The Expert already knows that building flows needs the Node-RED editor, and that it can take the user there itself rather than reading out manual steps. That behaviour exists and the prompt for it is good: one `ui_navigate` call to the editor route, explicitly told not to list routes first or re-check afterwards, and to say something warm rather than telling the user to wait for a page to load.
It's just switched off during onboarding.
The gate is:
```js
const canAutoNavigateToEditor = !!(supportsPlatformUIAutomations && !isImmersive
&& !supportsFlowBuildingAutomations && editorTargetId)
const editorTargetId = deviceId || instanceId
```
`editorTargetId` comes from the chat context, which follows the route. During onboarding the user is on a team page, so there's no instance in context, so it's null, so the whole behaviour is off.
Once the Expert has provisioned the instance, its id needs to reach the expert context so the capability comes back.
### Done when
* Approving a plan during onboarding takes the user into the editor.
* The Expert makes one navigation call rather than exploring first.
### Worth knowing
The context object is built in `frontend/src/stores/context.js` from `contextStore.instance`, which tracks the current route. The instance the Expert just created isn't the route the user is on, so this isn't just a matter of waiting for a navigation, something has to put it there deliberately.
Worth checking the other three conditions in that gate hold during onboarding too, since fixing one and leaving another false gets you nowhere. `supportsPlatformUIAutomations` depends on the platform automation feature check, and `!isImmersive` is true on a team page, so the target id is probably the only missing piece, but it's worth confirming rather than assuming.
Navigation is user-triggered, not automatic. The Expert offers to go ahead once it knows the workspace is ready, and the user's approval of the plan is what actually moves them into the editor. So this behaviour fires on approval rather than on provisioning finishing.
Related: flow building itself needs `scope === 'immersive'` and an `assistantVersion` on the instance, so the capability only appears once the user is actually in the editor. The navigation is what unlocks the building, which means the order is fixed: navigate, then build. flowfuse#8323 is an open bug about the Expert starting to write before the editor has finished loading, which sits exactly on this transition and is worth reading before touching it.
Contributor guide
Assessment
This issue has not been assessed yet.