Skip to content

🤯 LobeHub - Super-Agents on Your Team. Add super-agents to the chats your team already uses.They take on work by themselves and get better every week.

700 B
Raw Blame
import type { UIChatMessage } from '@lobechat/types';

import { isLocalOnlyMessage } from '@/store/chat/utils/localMessages';

export const getMessageInteractionState = (
  message: UIChatMessage | undefined,
  disableEditing?: boolean,
) => {
  const isLocalOnly = isLocalOnlyMessage(message);

  return {
    effectiveDisableEditing: Boolean(disableEditing || isLocalOnly),
    shouldSuppressContextMenu: isLocalOnly,
  };
};

export const getMessageContextMenuAction = (target: EventTarget, suppress: boolean) => {
  // Let the platform hit-test the actual image for its Copy Image command.
  if (target instanceof HTMLImageElement) return 'native';
  return suppress ? 'suppress' : 'message';
};