mirror of
https://github.com/lobehub/lobehub
synced 2026-04-21 09:37:28 +00:00
* ✨ feat(hetero-agent): add hetero-mode actions bar with copy/delete only Hide edit, regenerate, branching, translate, tts, share and delAndRegenerate for heterogeneous-agent sessions where these actions don't apply. Introduce `mode: 'hetero'` on MessageActionsConfig and dispatch to dedicated Hetero action bars for user, assistant, and assistant-group messages. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com> * ♻️ refactor(conversation): replace per-role action hooks with declarative action registry Replace the 4 duplicate per-role action hooks (useUserActions / useAssistantActions / useGroupActions / Task.useAssistantActions) and the 4 copies of stripHandleClick / buildActionsMap / dispatch logic with a single registry + universal MessageActionBar renderer. Each action (copy / del / edit / regenerate / delAndRegenerate / continueGeneration / translate / tts / share / collapse / branching) is now a standalone module under components/MessageActionBar/actions/. Config is declarative — string slot keys (e.g. ['copy', 'divider', 'del']) resolved against the registry at render time. Hetero-agent sessions drop the special mode flag; they just declare copy-only slot lists via config. Dev-mode branching becomes a registry key instead of a factory. Deletes ErrorActionsBar (handled in-place via slot lists), the dead Supervisor/Actions folder, and the HeteroActionsBar scaffold introduced in the previous commit. Net: -1900 lines, one place to add a new action. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com> --------- Co-authored-by: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
38 lines
1.6 KiB
TypeScript
38 lines
1.6 KiB
TypeScript
import { type MessageActionItem } from '../../../types';
|
|
import { branchingAction } from './actions/branching';
|
|
import { collapseAction } from './actions/collapse';
|
|
import { continueGenerationAction } from './actions/continueGeneration';
|
|
import { copyAction } from './actions/copy';
|
|
import { delAction } from './actions/del';
|
|
import { delAndRegenerateAction } from './actions/delAndRegenerate';
|
|
import { editAction } from './actions/edit';
|
|
import { regenerateAction } from './actions/regenerate';
|
|
import { shareAction } from './actions/share';
|
|
import { translateAction } from './actions/translate';
|
|
import { ttsAction } from './actions/tts';
|
|
import { type MessageActionContext } from './types';
|
|
|
|
/**
|
|
* Calls every registered action's `useBuild` hook for the given context.
|
|
*
|
|
* Returns a record keyed by action `key`. Hook order is fixed — don't change
|
|
* this call sequence without updating React dev expectations.
|
|
*
|
|
* Actions that don't apply to the current role return `null` and are simply
|
|
* absent from the result when consumed.
|
|
*/
|
|
export const useBuildActions = (
|
|
ctx: MessageActionContext,
|
|
): Record<string, MessageActionItem | null> => ({
|
|
branching: branchingAction.useBuild(ctx),
|
|
collapse: collapseAction.useBuild(ctx),
|
|
continueGeneration: continueGenerationAction.useBuild(ctx),
|
|
copy: copyAction.useBuild(ctx),
|
|
del: delAction.useBuild(ctx),
|
|
delAndRegenerate: delAndRegenerateAction.useBuild(ctx),
|
|
edit: editAction.useBuild(ctx),
|
|
regenerate: regenerateAction.useBuild(ctx),
|
|
share: shareAction.useBuild(ctx),
|
|
translate: translateAction.useBuild(ctx),
|
|
tts: ttsAction.useBuild(ctx),
|
|
});
|