Skip to content

armgit / macro

Public Imported from GitHub
0

Macro is a unified workspace for teams: email, chat, docs, tasks, agents, calls, and CRM — @-linked together with shared AI memory.

feat(command-k): copy entity id (#2737)

gbirman2c9c617320d1
diff --git a/js/app/packages/app/component/next-soup/actions/index.ts b/js/app/packages/app/component/next-soup/actions/index.ts
index 9a78558329..d33d6c688b 100644
--- a/js/app/packages/app/component/next-soup/actions/index.ts
+++ b/js/app/packages/app/component/next-soup/actions/index.ts
@@ -8,6 +8,7 @@ export { makeCopyAction } from './make-copy-action';
export { makeMoveToProjectAction } from './make-move-to-project-action';
export { makeCopyLinkAction } from './make-copy-link-action';
export { makeCopyBranchNameAction } from './make-copy-branch-name-action';
+export { makeCopyEntityIdAction } from './make-copy-entity-id-action';
export { makeShareAction } from './make-share-action';
export { useEntityActionHotkeys } from './use-entity-action-hotkeys';
diff --git a/js/app/packages/app/component/next-soup/actions/make-copy-entity-id-action.ts b/js/app/packages/app/component/next-soup/actions/make-copy-entity-id-action.ts
new file mode 100644
index 0000000000..7b2bf54744
--- /dev/null
+++ b/js/app/packages/app/component/next-soup/actions/make-copy-entity-id-action.ts
@@ -0,0 +1,23 @@
+import { toast } from '@core/component/Toast/Toast';
+import type { EntityData } from '@entity';
+import type { SoupState } from '../create-soup-state';
+
+export const makeCopyEntityIdAction = () => {
+ const canExecute = (_entity: EntityData): boolean => {
+ return true;
+ };
+
+ const execute = async (entities: EntityData[]) => {
+ const entity = entities[0];
+ if (!entity) return;
+
+ await navigator.clipboard.writeText(entity.id);
+ toast.success('ID copied to clipboard');
+ };
+
+ const executeWithSoup = async (entities: EntityData[], _soup: SoupState) => {
+ await execute(entities);
+ };
+
+ return { canExecute, execute, executeWithSoup };
+};
diff --git a/js/app/packages/app/component/next-soup/actions/use-block-entity-commands.ts b/js/app/packages/app/component/next-soup/actions/use-block-entity-commands.ts
index c89b8aa7d6..f8ab862d9d 100644
--- a/js/app/packages/app/component/next-soup/actions/use-block-entity-commands.ts
+++ b/js/app/packages/app/component/next-soup/actions/use-block-entity-commands.ts
@@ -18,6 +18,7 @@ import { createEffect, onCleanup } from 'solid-js';
import {
makeCopyAction,
makeCopyBranchNameAction,
+ makeCopyEntityIdAction,
makeCopyLinkAction,
makeDeleteAction,
makeMarkDoneAction,
@@ -48,6 +49,7 @@ export const useBlockEntityCommands = () => {
const moveToProjectAction = makeMoveToProjectAction();
const copyLinkAction = makeCopyLinkAction();
const copyBranchNameAction = makeCopyBranchNameAction();
+ const copyEntityIdAction = makeCopyEntityIdAction();
const allProperties = useAllProperties();
@@ -219,6 +221,26 @@ export const useBlockEntityCommands = () => {
tags: [HotkeyTags.SelectionModification],
}).withGroup(group);
+ // Copy entity id (command menu only, no keybinding)
+ registerHotkey({
+ hotkeyToken: TOKENS.entity.action.copyEntityId,
+ scopeId,
+ description: 'Copy ID',
+ keyDownHandler: () => {
+ const entity = getEntity();
+ if (!entity) return false;
+ if (!copyEntityIdAction.canExecute(entity)) return false;
+ copyEntityIdAction.execute([entity]);
+ return true;
+ },
+ condition: () => {
+ const entity = getEntity();
+ return entity !== undefined && copyEntityIdAction.canExecute(entity);
+ },
+ displayPriority: 10,
+ tags: [HotkeyTags.SelectionModification],
+ }).withGroup(group);
+
// Open property selector - 'shift+cmd+o'
registerHotkey({
hotkey: ['shift+cmd+o'],
diff --git a/js/app/packages/app/component/next-soup/actions/use-entity-action-hotkeys.ts b/js/app/packages/app/component/next-soup/actions/use-entity-action-hotkeys.ts
index 33a99b827c..0fc7f98a86 100644
--- a/js/app/packages/app/component/next-soup/actions/use-entity-action-hotkeys.ts
+++ b/js/app/packages/app/component/next-soup/actions/use-entity-action-hotkeys.ts
@@ -6,6 +6,7 @@ import type { SoupState } from '../create-soup-state';
import {
makeCopyAction,
makeCopyBranchNameAction,
+ makeCopyEntityIdAction,
makeCopyLinkAction,
makeDeleteAction,
makeMarkDoneAction,
@@ -66,6 +67,8 @@ export const useEntityActionHotkeys = (
const copyBranchNameAction = makeCopyBranchNameAction();
+ const copyEntityIdAction = makeCopyEntityIdAction();
+
const shareAction = makeShareAction();
const getEntitiesForAction = (): EntityData[] => {
@@ -291,6 +294,29 @@ export const useEntityActionHotkeys = (
tags: [HotkeyTags.SelectionModification],
}).withGroup(group);
+ // Copy entity id (command menu only, no keybinding)
+ registerHotkey({
+ hotkeyToken: TOKENS.entity.action.copyEntityId,
+ scopeId,
+ description: 'Copy ID',
+ keyDownHandler: () => {
+ const entities = getEntitiesForAction();
+ if (entities.length === 0) return false;
+ if (!copyEntityIdAction.canExecute(entities[0])) return false;
+ copyEntityIdAction.executeWithSoup(entities, soup);
+ return true;
+ },
+ condition: () => {
+ if (condition && !condition()) return false;
+ const entities = getEntitiesForAction();
+ return (
+ entities.length === 1 && copyEntityIdAction.canExecute(entities[0])
+ );
+ },
+ displayPriority: 10,
+ tags: [HotkeyTags.SelectionModification],
+ }).withGroup(group);
+
// Share
registerHotkey({
hotkeyToken: TOKENS.entity.action.share,
diff --git a/js/app/packages/app/component/next-soup/soup-view/create-soup-entity-actions.ts b/js/app/packages/app/component/next-soup/soup-view/create-soup-entity-actions.ts
index 4409cbb446..9f9073ef50 100644
--- a/js/app/packages/app/component/next-soup/soup-view/create-soup-entity-actions.ts
+++ b/js/app/packages/app/component/next-soup/soup-view/create-soup-entity-actions.ts
@@ -6,6 +6,7 @@ import {
makeBlockSenderAction,
makeCopyAction,
makeCopyBranchNameAction,
+ makeCopyEntityIdAction,
makeCopyLinkAction,
makeDeleteAction,
makeMarkDoneAction,
@@ -67,6 +68,7 @@ export function createSoupEntityActions(): {
const moveToProjectAction = makeMoveToProjectAction();
const copyLinkAction = makeCopyLinkAction();
const copyBranchNameAction = makeCopyBranchNameAction();
+ const copyEntityIdAction = makeCopyEntityIdAction();
const shareAction = makeShareAction();
const blockSenderAction = makeBlockSenderAction();
const markSenderSignalAction = makeMarkSenderSignalAction();
@@ -208,6 +210,12 @@ export function createSoupEntityActions(): {
});
}
+ middleItems.push({
+ id: 'copy-entity-id',
+ label: 'Copy ID',
+ onClick: handle(copyEntityIdAction.executeWithSoup),
+ });
+
if (shareAction.canExecute(entities[0])) {
middleItems.push({
id: 'share',
diff --git a/js/app/packages/core/hotkey/tokens.ts b/js/app/packages/core/hotkey/tokens.ts
index 0e864d86b5..465f3221b5 100644
--- a/js/app/packages/core/hotkey/tokens.ts
+++ b/js/app/packages/core/hotkey/tokens.ts
@@ -51,6 +51,7 @@ export const TOKENS = {
copyLink: 'entity.action.copyLink',
share: 'entity.action.share',
copyBranchName: 'entity.action.copyBranchName',
+ copyEntityId: 'entity.action.copyEntityId',
properties: 'entity.action.properties',
priority: 'entity.action.priority',
status: 'entity.action.status',