Skip to content

Commit b462670

Browse files
authored
Merge pull request #231 from FlowFuse/7000-emit-tab-info
[7000] Emit active tab info on workspace change
2 parents 27d51a3 + f60df21 commit b462670

File tree

1 file changed

+17
-1
lines changed

1 file changed

+17
-1
lines changed

resources/expertComms.js

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -141,7 +141,10 @@ export class ExpertComms {
141141
'registry:node-set-disabled': 'notifyPaletteChange',
142142
'registry:node-set-enabled': 'notifyPaletteChange',
143143
// selection changes
144-
'view:selection-changed': 'notifySelectionChanged'
144+
'view:selection-changed': 'notifySelectionChanged',
145+
// workspace changes
146+
'workspace:change': 'notifyWorkspaceChange',
147+
'flows:loaded': 'notifyWorkspaceChange'
145148
}
146149

147150
/**
@@ -212,6 +215,8 @@ export class ExpertComms {
212215

213216
this.setupMessageListeners()
214217

218+
this.notifyWorkspaceChange()
219+
215220
// Notify the parent window that the assistant is ready
216221
this.postParent({
217222
type: 'assistant-ready',
@@ -502,6 +507,17 @@ export class ExpertComms {
502507
}
503508
}
504509

510+
notifyWorkspaceChange () {
511+
const activeTab = this.RED.workspaces?.active?.()
512+
const tab = activeTab ? (this.RED.nodes?.workspace(activeTab) || this.RED.nodes?.subflow(activeTab)) : null
513+
const label = tab?.label || tab?.name
514+
if (!label) { return }
515+
this.postParent({
516+
type: 'nr-assistant/workspace:change',
517+
tab: { id: tab.id, label }
518+
})
519+
}
520+
505521
/**
506522
* FlowFuse Expert message handlers
507523
*/

0 commit comments

Comments
 (0)