Skip to content

Commit faf95f4

Browse files
committed
feat(hub): add a command kind for message-panel actions
DevframeMessageAction gains a second variant, 'command', alongside the existing 'activate' kind: it invokes a command from the hub's command registry (the same one backing the command palette) by command.id, via the hub:commands:execute RPC. Wired the dispatch in the messages plugin's onActivate handler; MessageDetail.vue already renders any action kind generically and needed no change. Additive only — the existing 'activate' kind and its behavior are unchanged. Updates the tsnapi public-API snapshots for @devframes/hub to reflect the new exported type.
1 parent f94cf6e commit faf95f4

3 files changed

Lines changed: 6 additions & 6 deletions

File tree

packages/hub/src/types/messages.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -42,8 +42,8 @@ export interface DevframeMessageActivateAction {
4242

4343
/**
4444
* `'command'` invokes a command from the hub's command registry (the same
45-
* registry backing the command palette) by `command.id`, passing
46-
* `command.params` through as its argument, via the hub's
45+
* registry backing the command palette) by `command.id`, spreading
46+
* `command.params` as its positional arguments, via the hub's
4747
* `hub:commands:execute` RPC.
4848
*/
4949
export interface DevframeMessageCommandAction {
@@ -52,8 +52,8 @@ export interface DevframeMessageCommandAction {
5252
/** Button label shown in the messages panel. */
5353
label: string
5454
kind: 'command'
55-
/** The command to invoke, plus an optional params bag. */
56-
command: { id: string, params?: Record<string, unknown> }
55+
/** The command to invoke, plus an optional list of positional arguments. */
56+
command: { id: string, params?: unknown[] }
5757
}
5858

5959
export type DevframeMessageAction = DevframeMessageActivateAction | DevframeMessageCommandAction

plugins/messages/src/client/App.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ async function onActivate(action: DevframeMessageAction): Promise<void> {
7575
return
7676
}
7777
if (action.kind === 'command')
78-
await callOptional('hub:commands:execute', action.command.id, action.command.params)
78+
await callOptional('hub:commands:execute', action.command.id, ...(action.command.params ?? []))
7979
}
8080
8181
async function onDismiss(id: string): Promise<void> {

tests/__snapshots__/tsnapi/@devframes/hub/index.snapshot.d.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -147,7 +147,7 @@ export interface DevframeMessageCommandAction {
147147
kind: 'command';
148148
command: {
149149
id: string;
150-
params?: Record<string, unknown>;
150+
params?: unknown[];
151151
};
152152
}
153153
export interface DevframeMessageElementPosition {

0 commit comments

Comments
 (0)