File tree Expand file tree Collapse file tree
plugins/messages/src/client
tests/__snapshots__/tsnapi/@devframes/hub Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -40,7 +40,23 @@ export interface DevframeMessageActivateAction {
4040 activate : { dockId : string , params ?: Record < string , unknown > }
4141}
4242
43- export type DevframeMessageAction = DevframeMessageActivateAction
43+ /**
44+ * `'command'` invokes a command from the hub's command registry (the same
45+ * registry backing the command palette) by `command.id`, spreading
46+ * `command.params` as its positional arguments, via the hub's
47+ * `hub:commands:execute` RPC.
48+ */
49+ export interface DevframeMessageCommandAction {
50+ /** Stable id for the action within its entry. */
51+ id : string
52+ /** Button label shown in the messages panel. */
53+ label : string
54+ kind : 'command'
55+ /** The command to invoke, plus an optional list of positional arguments. */
56+ command : { id : string , params ?: unknown [ ] }
57+ }
58+
59+ export type DevframeMessageAction = DevframeMessageActivateAction | DevframeMessageCommandAction
4460
4561export interface DevframeMessageEntry {
4662 /**
Original file line number Diff line number Diff line change @@ -69,12 +69,13 @@ onMounted(() => {
6969})
7070
7171async function onActivate(action : DevframeMessageAction ): Promise <void > {
72- if (action .kind !== ' activate' )
72+ const callOptional = props .rpc .callOptional as (name : string , ... args : unknown []) => Promise <unknown >
73+ if (action .kind === ' activate' ) {
74+ await callOptional (' hub:docks:activate' , action .activate )
7375 return
74- await (props .rpc .callOptional as (name : string , ... args : unknown []) => Promise <unknown >)(
75- ' hub:docks:activate' ,
76- action .activate ,
77- )
76+ }
77+ if (action .kind === ' command' )
78+ await callOptional (' hub:commands:execute' , action .command .id , ... (action .command .params ?? []))
7879}
7980
8081async function onDismiss(id : string ): Promise <void > {
Original file line number Diff line number Diff line change @@ -141,6 +141,15 @@ export interface DevframeMessageActivateAction {
141141 params ?: Record < string , unknown > ;
142142 } ;
143143}
144+ export interface DevframeMessageCommandAction {
145+ id : string ;
146+ label : string ;
147+ kind : 'command' ;
148+ command : {
149+ id : string ;
150+ params ?: unknown [ ] ;
151+ } ;
152+ }
144153export interface DevframeMessageElementPosition {
145154 selector ?: string ;
146155 boundingBox ?: {
@@ -337,7 +346,7 @@ export type DevframeDockEntryIcon = string | {
337346 dark : string ;
338347} ;
339348export type DevframeDockUserEntry = DevframeDockEntryRegistry [ keyof DevframeDockEntryRegistry ] ;
340- export type DevframeMessageAction = DevframeMessageActivateAction ;
349+ export type DevframeMessageAction = DevframeMessageActivateAction | DevframeMessageCommandAction ;
341350export type DevframeMessageEntryFrom = 'server' | 'browser' ;
342351export type DevframeMessageEntryInput = Omit < DevframeMessageEntry , 'id' | 'timestamp' | 'from' > & {
343352 id ?: string ;
Original file line number Diff line number Diff line change @@ -37,6 +37,7 @@ export { DevframeHost }
3737export { DevframeHubContext }
3838export { DevframeMessageAction }
3939export { DevframeMessageActivateAction }
40+ export { DevframeMessageCommandAction }
4041export { DevframeMessageElementPosition }
4142export { DevframeMessageEntry }
4243export { DevframeMessageEntryFrom }
You can’t perform that action at this time.
0 commit comments