@athenaintel/react 0.20.0 → 0.21.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +74 -0
- package/dist/assets/use-asset-embed.cjs +8 -0
- package/dist/assets/use-asset-embed.cjs.map +1 -1
- package/dist/assets/use-asset-embed.js +8 -0
- package/dist/assets/use-asset-embed.js.map +1 -1
- package/dist/chat/StatewireApprovalCard.cjs +22 -4
- package/dist/chat/StatewireApprovalCard.cjs.map +1 -1
- package/dist/chat/StatewireApprovalCard.d.ts +14 -0
- package/dist/chat/StatewireApprovalCard.js +23 -5
- package/dist/chat/StatewireApprovalCard.js.map +1 -1
- package/dist/chat/StatewireClientToolBridge.cjs +2 -1
- package/dist/chat/StatewireClientToolBridge.cjs.map +1 -1
- package/dist/chat/StatewireClientToolBridge.js +2 -1
- package/dist/chat/StatewireClientToolBridge.js.map +1 -1
- package/dist/chat/StatewireQueuedMessages.cjs +2 -1
- package/dist/chat/StatewireQueuedMessages.cjs.map +1 -1
- package/dist/chat/StatewireQueuedMessages.js +2 -1
- package/dist/chat/StatewireQueuedMessages.js.map +1 -1
- package/dist/chat/athena-citation-links.cjs +17 -1
- package/dist/chat/athena-citation-links.cjs.map +1 -1
- package/dist/chat/athena-citation-links.js +17 -1
- package/dist/chat/athena-citation-links.js.map +1 -1
- package/dist/chat/statewire-client-tools.cjs +2 -1
- package/dist/chat/statewire-client-tools.cjs.map +1 -1
- package/dist/chat/statewire-client-tools.js +2 -1
- package/dist/chat/statewire-client-tools.js.map +1 -1
- package/dist/chat/super-grouping/SuperGroupingCard.cjs +69 -187
- package/dist/chat/super-grouping/SuperGroupingCard.cjs.map +1 -1
- package/dist/chat/super-grouping/SuperGroupingCard.d.ts +10 -6
- package/dist/chat/super-grouping/SuperGroupingCard.js +73 -191
- package/dist/chat/super-grouping/SuperGroupingCard.js.map +1 -1
- package/dist/chat/super-grouping/ToolTimeline.cjs +131 -0
- package/dist/chat/super-grouping/ToolTimeline.cjs.map +1 -0
- package/dist/chat/super-grouping/ToolTimeline.d.ts +16 -0
- package/dist/chat/super-grouping/ToolTimeline.js +131 -0
- package/dist/chat/super-grouping/ToolTimeline.js.map +1 -0
- package/dist/chat/super-grouping/activity-timeline.cjs +14 -8
- package/dist/chat/super-grouping/activity-timeline.cjs.map +1 -1
- package/dist/chat/super-grouping/activity-timeline.d.ts +3 -0
- package/dist/chat/super-grouping/activity-timeline.js +14 -8
- package/dist/chat/super-grouping/activity-timeline.js.map +1 -1
- package/dist/chat/super-grouping/timeline-step.cjs +65 -0
- package/dist/chat/super-grouping/timeline-step.cjs.map +1 -0
- package/dist/chat/super-grouping/timeline-step.d.ts +17 -0
- package/dist/chat/super-grouping/timeline-step.js +65 -0
- package/dist/chat/super-grouping/timeline-step.js.map +1 -0
- package/dist/chat/tiptap-text.cjs +8 -8
- package/dist/chat/tiptap-text.cjs.map +1 -1
- package/dist/chat/use-athena-run-live.cjs +2 -1
- package/dist/chat/use-athena-run-live.cjs.map +1 -1
- package/dist/chat/use-athena-run-live.js +2 -1
- package/dist/chat/use-athena-run-live.js.map +1 -1
- package/dist/chat/use-statewire-approval-request.cjs +7 -2
- package/dist/chat/use-statewire-approval-request.cjs.map +1 -1
- package/dist/chat/use-statewire-approval-request.d.ts +12 -2
- package/dist/chat/use-statewire-approval-request.js +8 -3
- package/dist/chat/use-statewire-approval-request.js.map +1 -1
- package/dist/chat-ui/composer/tiptap-composer.cjs +24 -65
- package/dist/chat-ui/composer/tiptap-composer.cjs.map +1 -1
- package/dist/chat-ui/composer/tiptap-composer.js +24 -65
- package/dist/chat-ui/composer/tiptap-composer.js.map +1 -1
- package/dist/chat-ui/index.cjs +2 -1
- package/dist/chat-ui/index.cjs.map +1 -1
- package/dist/chat-ui/index.js +2 -1
- package/dist/chat-ui/index.js.map +1 -1
- package/dist/chat-ui/mentions/mention-chip.cjs +49 -4
- package/dist/chat-ui/mentions/mention-chip.cjs.map +1 -1
- package/dist/chat-ui/mentions/mention-chip.d.ts +11 -0
- package/dist/chat-ui/mentions/mention-chip.js +50 -5
- package/dist/chat-ui/mentions/mention-chip.js.map +1 -1
- package/dist/chat-ui/mentions/mention-extension.cjs +18 -6
- package/dist/chat-ui/mentions/mention-extension.cjs.map +1 -1
- package/dist/chat-ui/mentions/mention-extension.d.ts +2 -0
- package/dist/chat-ui/mentions/mention-extension.js +18 -6
- package/dist/chat-ui/mentions/mention-extension.js.map +1 -1
- package/dist/chat-ui/mentions/suggestions/components/mention-suggestion-list.cjs +1 -1
- package/dist/chat-ui/mentions/suggestions/components/mention-suggestion-list.cjs.map +1 -1
- package/dist/chat-ui/mentions/suggestions/components/mention-suggestion-list.js +1 -1
- package/dist/chat-ui/mentions/suggestions/components/mention-suggestion-list.js.map +1 -1
- package/dist/chat-ui/mentions/suggestions/components/menu-item.cjs +9 -6
- package/dist/chat-ui/mentions/suggestions/components/menu-item.cjs.map +1 -1
- package/dist/chat-ui/mentions/suggestions/components/menu-item.d.ts +2 -2
- package/dist/chat-ui/mentions/suggestions/components/menu-item.js +10 -7
- package/dist/chat-ui/mentions/suggestions/components/menu-item.js.map +1 -1
- package/dist/chat-ui/mentions/suggestions/components/menu-list.cjs +2 -2
- package/dist/chat-ui/mentions/suggestions/components/menu-list.cjs.map +1 -1
- package/dist/chat-ui/mentions/suggestions/components/menu-list.d.ts +2 -2
- package/dist/chat-ui/mentions/suggestions/components/menu-list.js +2 -2
- package/dist/chat-ui/mentions/suggestions/components/menu-list.js.map +1 -1
- package/dist/chat-ui/mentions/suggestions/data/api-client.cjs +2 -1
- package/dist/chat-ui/mentions/suggestions/data/api-client.cjs.map +1 -1
- package/dist/chat-ui/mentions/suggestions/data/api-client.d.ts +3 -2
- package/dist/chat-ui/mentions/suggestions/data/api-client.js +2 -1
- package/dist/chat-ui/mentions/suggestions/data/api-client.js.map +1 -1
- package/dist/chat-ui/messages/message-components.cjs +6 -29
- package/dist/chat-ui/messages/message-components.cjs.map +1 -1
- package/dist/chat-ui/messages/message-components.d.ts +1 -13
- package/dist/chat-ui/messages/message-components.js +8 -31
- package/dist/chat-ui/messages/message-components.js.map +1 -1
- package/dist/chat-ui/messages/runtime-message.cjs +3 -2
- package/dist/chat-ui/messages/runtime-message.cjs.map +1 -1
- package/dist/chat-ui/messages/runtime-message.js +3 -2
- package/dist/chat-ui/messages/runtime-message.js.map +1 -1
- package/dist/chat-ui/messages/statewire-continue-run.cjs +23 -8
- package/dist/chat-ui/messages/statewire-continue-run.cjs.map +1 -1
- package/dist/chat-ui/messages/statewire-continue-run.d.ts +14 -4
- package/dist/chat-ui/messages/statewire-continue-run.js +23 -8
- package/dist/chat-ui/messages/statewire-continue-run.js.map +1 -1
- package/dist/chat-ui/messages/user-edit-composer.cjs +2 -1
- package/dist/chat-ui/messages/user-edit-composer.cjs.map +1 -1
- package/dist/chat-ui/messages/user-edit-composer.js +2 -1
- package/dist/chat-ui/messages/user-edit-composer.js.map +1 -1
- package/dist/chat-ui/rich-text/chat-message-body.cjs +76 -0
- package/dist/chat-ui/rich-text/chat-message-body.cjs.map +1 -0
- package/dist/chat-ui/rich-text/chat-message-body.d.ts +5 -0
- package/dist/chat-ui/rich-text/chat-message-body.js +76 -0
- package/dist/chat-ui/rich-text/chat-message-body.js.map +1 -0
- package/dist/chat-ui/rich-text/chat-node-views.cjs +51 -0
- package/dist/chat-ui/rich-text/chat-node-views.cjs.map +1 -0
- package/dist/chat-ui/rich-text/chat-node-views.d.ts +13 -0
- package/dist/chat-ui/rich-text/chat-node-views.js +51 -0
- package/dist/chat-ui/rich-text/chat-node-views.js.map +1 -0
- package/dist/chat-ui/rich-text/chat-text-schema.cjs +70 -0
- package/dist/chat-ui/rich-text/chat-text-schema.cjs.map +1 -0
- package/dist/chat-ui/rich-text/chat-text-schema.d.ts +7 -0
- package/dist/chat-ui/rich-text/chat-text-schema.js +70 -0
- package/dist/chat-ui/rich-text/chat-text-schema.js.map +1 -0
- package/dist/chat-ui/rich-text/dom-output-spec.cjs +83 -0
- package/dist/chat-ui/rich-text/dom-output-spec.cjs.map +1 -0
- package/dist/chat-ui/rich-text/dom-output-spec.d.ts +11 -0
- package/dist/chat-ui/rich-text/dom-output-spec.js +83 -0
- package/dist/chat-ui/rich-text/dom-output-spec.js.map +1 -0
- package/dist/chat-ui/statewire.cjs +2 -1
- package/dist/chat-ui/statewire.cjs.map +1 -1
- package/dist/chat-ui/statewire.js +2 -1
- package/dist/chat-ui/statewire.js.map +1 -1
- package/dist/chat-ui/thread/statewire-history-edge.cjs +2 -1
- package/dist/chat-ui/thread/statewire-history-edge.cjs.map +1 -1
- package/dist/chat-ui/thread/statewire-history-edge.js +2 -1
- package/dist/chat-ui/thread/statewire-history-edge.js.map +1 -1
- package/dist/index.cjs +2 -1
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +2 -1
- package/dist/index.js.map +1 -1
- package/dist/node_modules/qrcode-generator/dist/qrcode.cjs +32 -0
- package/dist/node_modules/qrcode-generator/dist/qrcode.cjs.map +1 -0
- package/dist/node_modules/qrcode-generator/dist/qrcode.js +31 -0
- package/dist/node_modules/qrcode-generator/dist/qrcode.js.map +1 -0
- package/dist/node_modules/zod/v4/classic/errors.cjs +44 -0
- package/dist/node_modules/zod/v4/classic/errors.cjs.map +1 -0
- package/dist/node_modules/zod/v4/classic/errors.js +44 -0
- package/dist/node_modules/zod/v4/classic/errors.js.map +1 -0
- package/dist/node_modules/zod/v4/classic/iso.cjs +43 -0
- package/dist/node_modules/zod/v4/classic/iso.cjs.map +1 -0
- package/dist/node_modules/zod/v4/classic/iso.js +43 -0
- package/dist/node_modules/zod/v4/classic/iso.js.map +1 -0
- package/dist/node_modules/zod/v4/classic/parse.cjs +29 -0
- package/dist/node_modules/zod/v4/classic/parse.cjs.map +1 -0
- package/dist/node_modules/zod/v4/classic/parse.js +29 -0
- package/dist/node_modules/zod/v4/classic/parse.js.map +1 -0
- package/dist/node_modules/zod/v4/classic/schemas.cjs +871 -0
- package/dist/node_modules/zod/v4/classic/schemas.cjs.map +1 -0
- package/dist/node_modules/zod/v4/classic/schemas.js +871 -0
- package/dist/node_modules/zod/v4/classic/schemas.js.map +1 -0
- package/dist/node_modules/zod/v4/core/api.cjs +570 -0
- package/dist/node_modules/zod/v4/core/api.cjs.map +1 -0
- package/dist/node_modules/zod/v4/core/api.js +570 -0
- package/dist/node_modules/zod/v4/core/api.js.map +1 -0
- package/dist/node_modules/zod/v4/core/checks.cjs +411 -0
- package/dist/node_modules/zod/v4/core/checks.cjs.map +1 -0
- package/dist/node_modules/zod/v4/core/checks.js +411 -0
- package/dist/node_modules/zod/v4/core/checks.js.map +1 -0
- package/dist/node_modules/zod/v4/core/core.cjs +77 -0
- package/dist/node_modules/zod/v4/core/core.cjs.map +1 -0
- package/dist/node_modules/zod/v4/core/core.js +77 -0
- package/dist/node_modules/zod/v4/core/core.js.map +1 -0
- package/dist/node_modules/zod/v4/core/doc.cjs +38 -0
- package/dist/node_modules/zod/v4/core/doc.cjs.map +1 -0
- package/dist/node_modules/zod/v4/core/doc.js +38 -0
- package/dist/node_modules/zod/v4/core/doc.js.map +1 -0
- package/dist/node_modules/zod/v4/core/errors.cjs +76 -0
- package/dist/node_modules/zod/v4/core/errors.cjs.map +1 -0
- package/dist/node_modules/zod/v4/core/errors.js +76 -0
- package/dist/node_modules/zod/v4/core/errors.js.map +1 -0
- package/dist/node_modules/zod/v4/core/json-schema-processors.cjs +312 -0
- package/dist/node_modules/zod/v4/core/json-schema-processors.cjs.map +1 -0
- package/dist/node_modules/zod/v4/core/json-schema-processors.js +312 -0
- package/dist/node_modules/zod/v4/core/json-schema-processors.js.map +1 -0
- package/dist/node_modules/zod/v4/core/parse.cjs +96 -0
- package/dist/node_modules/zod/v4/core/parse.cjs.map +1 -0
- package/dist/node_modules/zod/v4/core/parse.js +96 -0
- package/dist/node_modules/zod/v4/core/parse.js.map +1 -0
- package/dist/node_modules/zod/v4/core/regexes.cjs +86 -0
- package/dist/node_modules/zod/v4/core/regexes.cjs.map +1 -0
- package/dist/node_modules/zod/v4/core/regexes.js +86 -0
- package/dist/node_modules/zod/v4/core/regexes.js.map +1 -0
- package/dist/node_modules/zod/v4/core/registries.cjs +52 -0
- package/dist/node_modules/zod/v4/core/registries.cjs.map +1 -0
- package/dist/node_modules/zod/v4/core/registries.js +52 -0
- package/dist/node_modules/zod/v4/core/registries.js.map +1 -0
- package/dist/node_modules/zod/v4/core/schemas.cjs +1412 -0
- package/dist/node_modules/zod/v4/core/schemas.cjs.map +1 -0
- package/dist/node_modules/zod/v4/core/schemas.js +1413 -0
- package/dist/node_modules/zod/v4/core/schemas.js.map +1 -0
- package/dist/node_modules/zod/v4/core/to-json-schema.cjs +370 -0
- package/dist/node_modules/zod/v4/core/to-json-schema.cjs.map +1 -0
- package/dist/node_modules/zod/v4/core/to-json-schema.js +370 -0
- package/dist/node_modules/zod/v4/core/to-json-schema.js.map +1 -0
- package/dist/node_modules/zod/v4/core/util.cjs +444 -0
- package/dist/node_modules/zod/v4/core/util.cjs.map +1 -0
- package/dist/node_modules/zod/v4/core/util.js +444 -0
- package/dist/node_modules/zod/v4/core/util.js.map +1 -0
- package/dist/node_modules/zod/v4/core/versions.cjs +9 -0
- package/dist/node_modules/zod/v4/core/versions.cjs.map +1 -0
- package/dist/node_modules/zod/v4/core/versions.js +9 -0
- package/dist/node_modules/zod/v4/core/versions.js.map +1 -0
- package/dist/packages/agent-runtime/src/client-tool-bridge.cjs +7 -1
- package/dist/packages/agent-runtime/src/client-tool-bridge.cjs.map +1 -1
- package/dist/packages/agent-runtime/src/client-tool-bridge.js +7 -1
- package/dist/packages/agent-runtime/src/client-tool-bridge.js.map +1 -1
- package/dist/packages/agent-runtime/src/conversation-list.cjs +4 -0
- package/dist/packages/agent-runtime/src/conversation-list.cjs.map +1 -1
- package/dist/packages/agent-runtime/src/conversation-list.js +4 -0
- package/dist/packages/agent-runtime/src/conversation-list.js.map +1 -1
- package/dist/packages/agent-runtime/src/edit-command.cjs.map +1 -1
- package/dist/packages/agent-runtime/src/edit-command.js.map +1 -1
- package/dist/packages/agent-runtime/src/generated/runconfig-contract.cjs +2 -0
- package/dist/packages/agent-runtime/src/generated/runconfig-contract.cjs.map +1 -1
- package/dist/packages/agent-runtime/src/generated/runconfig-contract.js +2 -0
- package/dist/packages/agent-runtime/src/generated/runconfig-contract.js.map +1 -1
- package/dist/packages/agent-runtime/src/interrupts.cjs +31 -7
- package/dist/packages/agent-runtime/src/interrupts.cjs.map +1 -1
- package/dist/packages/agent-runtime/src/interrupts.js +31 -7
- package/dist/packages/agent-runtime/src/interrupts.js.map +1 -1
- package/dist/packages/agent-runtime/src/messages.cjs +35 -5
- package/dist/packages/agent-runtime/src/messages.cjs.map +1 -1
- package/dist/packages/agent-runtime/src/messages.js +35 -5
- package/dist/packages/agent-runtime/src/messages.js.map +1 -1
- package/dist/packages/agent-runtime/src/protocol.cjs +4 -6
- package/dist/packages/agent-runtime/src/protocol.cjs.map +1 -1
- package/dist/packages/agent-runtime/src/protocol.js +4 -6
- package/dist/packages/agent-runtime/src/protocol.js.map +1 -1
- package/dist/packages/agent-runtime/src/quota-safe-local-storage-session.cjs +296 -14
- package/dist/packages/agent-runtime/src/quota-safe-local-storage-session.cjs.map +1 -1
- package/dist/packages/agent-runtime/src/quota-safe-local-storage-session.js +293 -11
- package/dist/packages/agent-runtime/src/quota-safe-local-storage-session.js.map +1 -1
- package/dist/packages/agent-runtime/src/screen-point.cjs +68 -0
- package/dist/packages/agent-runtime/src/screen-point.cjs.map +1 -0
- package/dist/packages/agent-runtime/src/screen-point.js +68 -0
- package/dist/packages/agent-runtime/src/screen-point.js.map +1 -0
- package/dist/packages/agent-runtime/src/statewire-transport.cjs +6 -1
- package/dist/packages/agent-runtime/src/statewire-transport.cjs.map +1 -1
- package/dist/packages/agent-runtime/src/statewire-transport.js +6 -1
- package/dist/packages/agent-runtime/src/statewire-transport.js.map +1 -1
- package/dist/packages/agent-runtime/src/thread-handoff.cjs +85 -0
- package/dist/packages/agent-runtime/src/thread-handoff.cjs.map +1 -0
- package/dist/packages/agent-runtime/src/thread-handoff.js +85 -0
- package/dist/packages/agent-runtime/src/thread-handoff.js.map +1 -0
- package/dist/packages/agent-runtime/src/thread-snapshot-cache.cjs +1 -1
- package/dist/packages/agent-runtime/src/thread-snapshot-cache.cjs.map +1 -1
- package/dist/packages/agent-runtime/src/thread-snapshot-cache.js +1 -1
- package/dist/packages/agent-runtime/src/thread-snapshot-cache.js.map +1 -1
- package/dist/packages/agent-runtime/src/tool-metadata.cjs +0 -8
- package/dist/packages/agent-runtime/src/tool-metadata.cjs.map +1 -1
- package/dist/packages/agent-runtime/src/tool-metadata.js +0 -8
- package/dist/packages/agent-runtime/src/tool-metadata.js.map +1 -1
- package/dist/packages/agent-runtime/src/use-deep-agent-config.cjs +14 -0
- package/dist/packages/agent-runtime/src/use-deep-agent-config.cjs.map +1 -0
- package/dist/packages/agent-runtime/src/use-deep-agent-config.js +14 -0
- package/dist/packages/agent-runtime/src/use-deep-agent-config.js.map +1 -0
- package/dist/packages/agent-runtime/src/use-deep-agent-edit-submit.cjs +21 -5
- package/dist/packages/agent-runtime/src/use-deep-agent-edit-submit.cjs.map +1 -1
- package/dist/packages/agent-runtime/src/use-deep-agent-edit-submit.js +21 -5
- package/dist/packages/agent-runtime/src/use-deep-agent-edit-submit.js.map +1 -1
- package/dist/packages/agent-runtime/src/use-deep-agent-runtime.cjs +13 -3
- package/dist/packages/agent-runtime/src/use-deep-agent-runtime.cjs.map +1 -1
- package/dist/packages/agent-runtime/src/use-deep-agent-runtime.js +14 -4
- package/dist/packages/agent-runtime/src/use-deep-agent-runtime.js.map +1 -1
- package/dist/packages/agent-runtime/src/use-deep-agent-thread.cjs +35 -15
- package/dist/packages/agent-runtime/src/use-deep-agent-thread.cjs.map +1 -1
- package/dist/packages/agent-runtime/src/use-deep-agent-thread.js +35 -15
- package/dist/packages/agent-runtime/src/use-deep-agent-thread.js.map +1 -1
- package/dist/packages/agent-runtime/src/voice-presentation.cjs.map +1 -1
- package/dist/packages/agent-runtime/src/voice-presentation.js.map +1 -1
- package/dist/packages/react/package.json.cjs +1 -1
- package/dist/packages/react/package.json.js +1 -1
- package/dist/provider/AthenaProvider.cjs +2 -1
- package/dist/provider/AthenaProvider.cjs.map +1 -1
- package/dist/provider/AthenaProvider.js +2 -1
- package/dist/provider/AthenaProvider.js.map +1 -1
- package/dist/runtime/statewire-lifecycle.cjs +2 -1
- package/dist/runtime/statewire-lifecycle.cjs.map +1 -1
- package/dist/runtime/statewire-lifecycle.js +2 -1
- package/dist/runtime/statewire-lifecycle.js.map +1 -1
- package/dist/runtime/useAthenaStatewireRuntime.cjs +2 -1
- package/dist/runtime/useAthenaStatewireRuntime.cjs.map +1 -1
- package/dist/runtime/useAthenaStatewireRuntime.js +2 -1
- package/dist/runtime/useAthenaStatewireRuntime.js.map +1 -1
- package/dist/styles.css +1 -1
- package/dist/threads/conversation-list-fetcher.cjs +4 -0
- package/dist/threads/conversation-list-fetcher.cjs.map +1 -1
- package/dist/threads/conversation-list-fetcher.js +4 -0
- package/dist/threads/conversation-list-fetcher.js.map +1 -1
- package/dist/threads/statewire-thread-list.cjs +2 -1
- package/dist/threads/statewire-thread-list.cjs.map +1 -1
- package/dist/threads/statewire-thread-list.js +2 -1
- package/dist/threads/statewire-thread-list.js.map +1 -1
- package/dist/threads/use-rest-conversation-history.cjs +2 -1
- package/dist/threads/use-rest-conversation-history.cjs.map +1 -1
- package/dist/threads/use-rest-conversation-history.js +2 -1
- package/dist/threads/use-rest-conversation-history.js.map +1 -1
- package/dist/threads/use-statewire-conversation-history.cjs +2 -1
- package/dist/threads/use-statewire-conversation-history.cjs.map +1 -1
- package/dist/threads/use-statewire-conversation-history.d.ts +1 -0
- package/dist/threads/use-statewire-conversation-history.js +2 -1
- package/dist/threads/use-statewire-conversation-history.js.map +1 -1
- package/dist/tools/index.cjs +2 -1
- package/dist/tools/index.cjs.map +1 -1
- package/dist/tools/index.js +2 -1
- package/dist/tools/index.js.map +1 -1
- package/dist/tools/misc-tool-uis.cjs +2 -1
- package/dist/tools/misc-tool-uis.cjs.map +1 -1
- package/dist/tools/misc-tool-uis.js +2 -1
- package/dist/tools/misc-tool-uis.js.map +1 -1
- package/dist/tools/primitives.cjs +2 -1
- package/dist/tools/primitives.cjs.map +1 -1
- package/dist/tools/primitives.js +2 -1
- package/dist/tools/primitives.js.map +1 -1
- package/dist/tools/tool-fallback.cjs +2 -1
- package/dist/tools/tool-fallback.cjs.map +1 -1
- package/dist/tools/tool-fallback.js +2 -1
- package/dist/tools/tool-fallback.js.map +1 -1
- package/dist/tools/voice-update-tool-ui.cjs +2 -1
- package/dist/tools/voice-update-tool-ui.cjs.map +1 -1
- package/dist/tools/voice-update-tool-ui.js +2 -1
- package/dist/tools/voice-update-tool-ui.js.map +1 -1
- package/dist/voice/index.cjs +6 -0
- package/dist/voice/index.cjs.map +1 -0
- package/dist/voice/index.d.ts +2 -0
- package/dist/voice/index.js +6 -0
- package/dist/voice/index.js.map +1 -0
- package/dist/voice/use-athena-voice-session.cjs +315 -0
- package/dist/voice/use-athena-voice-session.cjs.map +1 -0
- package/dist/voice/use-athena-voice-session.d.ts +145 -0
- package/dist/voice/use-athena-voice-session.js +315 -0
- package/dist/voice/use-athena-voice-session.js.map +1 -0
- package/package.json +17 -3
|
@@ -1,6 +1,21 @@
|
|
|
1
1
|
import { jsx, jsxs, Fragment } from "react/jsx-runtime";
|
|
2
2
|
import { useContext } from "react";
|
|
3
|
-
import
|
|
3
|
+
import "../../packages/agent-runtime/src/generated/runconfig-contract.js";
|
|
4
|
+
import "@assistant-ui/tap";
|
|
5
|
+
import "statewire";
|
|
6
|
+
import "../../packages/agent-runtime/src/statewire-suspended.js";
|
|
7
|
+
import "@tanstack/react-query";
|
|
8
|
+
import "../../packages/agent-runtime/src/statewire-state.js";
|
|
9
|
+
import "../../packages/agent-runtime/src/messages.js";
|
|
10
|
+
import "@assistant-ui/react-statewire";
|
|
11
|
+
import "@assistant-ui/store";
|
|
12
|
+
import { isScreenPointHref, parseScreenPointHref, formatScreenPoint } from "../../packages/agent-runtime/src/screen-point.js";
|
|
13
|
+
import "../../packages/agent-runtime/src/quota-safe-local-storage-session.js";
|
|
14
|
+
import "../../packages/agent-runtime/src/statewire-attach-observer.js";
|
|
15
|
+
import "../../packages/agent-runtime/src/thread-status.js";
|
|
16
|
+
import "@assistant-ui/core";
|
|
17
|
+
import "../../packages/agent-runtime/src/thread-handoff.js";
|
|
18
|
+
import { Globe2Icon, CrosshairIcon } from "lucide-react";
|
|
4
19
|
import { createOlympusAssetUrl } from "../lib/asset-urls.js";
|
|
5
20
|
import { MentionAuthCtx } from "./suggestions/data/api-client.js";
|
|
6
21
|
import { assetTypeToThumb } from "./suggestions/data/sources/asset-type-icons.js";
|
|
@@ -13,7 +28,7 @@ function getSpacesAssetType(url) {
|
|
|
13
28
|
const assetType = url.searchParams.get("assetType") || url.searchParams.get("asset_type") || url.searchParams.get("type");
|
|
14
29
|
return assetType === "sheet" ? "spreadsheet" : assetType;
|
|
15
30
|
}
|
|
16
|
-
const MentionLink = ({ href, children }) => {
|
|
31
|
+
const MentionLink = ({ href, children, interactive = true }) => {
|
|
17
32
|
if (href && (href.startsWith("mention://") || isSpacesMentionUrl(href))) {
|
|
18
33
|
const name = typeof children === "string" ? children.replace(/^@/, "") : Array.isArray(children) ? String(children[0] ?? "").replace(/^@/, "") : "";
|
|
19
34
|
const parsed = parseMentionUrl(href);
|
|
@@ -24,16 +39,45 @@ const MentionLink = ({ href, children }) => {
|
|
|
24
39
|
type: parsed.type,
|
|
25
40
|
assetIds: parsed.assetIds,
|
|
26
41
|
thumbnailUrl: parsed.thumbnailUrl,
|
|
27
|
-
sourceHref: isSpacesMentionUrl(href) ? href : void 0
|
|
42
|
+
sourceHref: isSpacesMentionUrl(href) ? href : void 0,
|
|
43
|
+
interactive
|
|
28
44
|
}
|
|
29
45
|
);
|
|
30
46
|
}
|
|
31
47
|
if (href == null ? void 0 : href.startsWith("chrome-extension://")) {
|
|
32
48
|
return /* @__PURE__ */ jsx("span", { children });
|
|
33
49
|
}
|
|
50
|
+
if (isScreenPointHref(href)) {
|
|
51
|
+
return /* @__PURE__ */ jsx(ScreenPointChip, { href, children });
|
|
52
|
+
}
|
|
34
53
|
return /* @__PURE__ */ jsx("a", { href, target: "_blank", rel: "noopener noreferrer", children });
|
|
35
54
|
};
|
|
36
|
-
const
|
|
55
|
+
const ScreenPointChip = ({ href, children }) => {
|
|
56
|
+
const parsed = parseScreenPointHref(href);
|
|
57
|
+
if (!parsed.ok) {
|
|
58
|
+
return /* @__PURE__ */ jsx("span", { children });
|
|
59
|
+
}
|
|
60
|
+
const description = formatScreenPoint(parsed.point);
|
|
61
|
+
return /* @__PURE__ */ jsxs(
|
|
62
|
+
"span",
|
|
63
|
+
{
|
|
64
|
+
className: "not-prose inline-flex max-w-[260px] items-center gap-1 whitespace-nowrap rounded-md border border-slate-300 bg-white px-1.5 py-px align-middle text-[0.85em] font-medium leading-[1.4] text-slate-600",
|
|
65
|
+
title: description,
|
|
66
|
+
"aria-label": description,
|
|
67
|
+
"data-screen-point": "valid",
|
|
68
|
+
children: [
|
|
69
|
+
/* @__PURE__ */ jsx(CrosshairIcon, { className: "size-3.5 shrink-0", "aria-hidden": "true" }),
|
|
70
|
+
/* @__PURE__ */ jsx("span", { className: "max-w-[180px] overflow-hidden text-ellipsis", children }),
|
|
71
|
+
/* @__PURE__ */ jsxs("span", { className: "font-normal text-slate-400", children: [
|
|
72
|
+
parsed.point.x,
|
|
73
|
+
", ",
|
|
74
|
+
parsed.point.y
|
|
75
|
+
] })
|
|
76
|
+
]
|
|
77
|
+
}
|
|
78
|
+
);
|
|
79
|
+
};
|
|
80
|
+
const MentionChip = ({ name, type, assetIds, thumbnailUrl, sourceHref, interactive = true }) => {
|
|
37
81
|
const auth = useContext(MentionAuthCtx);
|
|
38
82
|
const assetRootHref = type === "asset" && (assetIds == null ? void 0 : assetIds.length) ? createOlympusAssetUrl({
|
|
39
83
|
appUrl: auth == null ? void 0 : auth.appUrl,
|
|
@@ -71,7 +115,7 @@ const MentionChip = ({ name, type, assetIds, thumbnailUrl, sourceHref }) => {
|
|
|
71
115
|
!thumbnailUrl && type === "webpage" && /* @__PURE__ */ jsx(Globe2Icon, { className: "size-3.5 shrink-0", "aria-hidden": "true" }),
|
|
72
116
|
/* @__PURE__ */ jsx("span", { className: "max-w-[180px] overflow-hidden text-ellipsis", children: name })
|
|
73
117
|
] });
|
|
74
|
-
if (href) {
|
|
118
|
+
if (href && interactive) {
|
|
75
119
|
return /* @__PURE__ */ jsx(
|
|
76
120
|
"a",
|
|
77
121
|
{
|
|
@@ -201,6 +245,7 @@ function parseMentionsInText(text) {
|
|
|
201
245
|
export {
|
|
202
246
|
MentionChip,
|
|
203
247
|
MentionLink,
|
|
248
|
+
ScreenPointChip,
|
|
204
249
|
normalizeAthenaMentionHtml,
|
|
205
250
|
parseMentionUrl,
|
|
206
251
|
parseMentionsInText
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"mention-chip.js","sources":["../../../src/chat-ui/mentions/mention-chip.tsx"],"sourcesContent":["/**\n * Mention chip rendering for message display.\n *\n * Parses [@name](mention://type?...) markdown links and renders them\n * as styled inline chips matching the Olympus mention style.\n * Used in both user messages (inline text) and assistant messages (markdown links).\n */\n\nimport { useContext, type FC, type ReactElement, type ReactNode } from \"react\";\nimport { Globe2Icon } from \"lucide-react\";\nimport { cn } from \"../../lib/utils\";\nimport { createOlympusAssetUrl } from \"../lib/asset-urls\";\nimport { MentionAuthCtx } from \"./suggestions/data/api-client\";\nimport { assetTypeToThumb } from \"./suggestions/data/sources/asset-type-icons\";\n\nconst SPACES_MENTION_PATH = /\\/dashboard\\/spaces\\/?\\?/;\n\nfunction isSpacesMentionUrl(url: string): boolean {\n return SPACES_MENTION_PATH.test(url);\n}\n\nfunction getSpacesAssetType(url: URL): string | null {\n const assetType =\n url.searchParams.get(\"assetType\") ||\n url.searchParams.get(\"asset_type\") ||\n url.searchParams.get(\"type\");\n return assetType === \"sheet\" ? \"spreadsheet\" : assetType;\n}\n\n// ── Mention link component for markdown renderer ──\n\n/**\n * Custom <a> renderer for MarkdownTextPrimitive.\n * Intercepts mention:// links and renders them as chips.\n * Falls through to a normal link for non-mention URLs.\n */\nexport const MentionLink: FC<{\n href?: string;\n children?: ReactNode;\n}> = ({ href, children }) => {\n if (\n href &&\n (href.startsWith(\"mention://\") || isSpacesMentionUrl(href))\n ) {\n const name = typeof children === \"string\"\n ? children.replace(/^@/, \"\")\n : Array.isArray(children)\n ? String(children[0] ?? \"\").replace(/^@/, \"\")\n : \"\";\n\n const parsed = parseMentionUrl(href);\n\n return (\n <MentionChip\n name={name || parsed.name}\n type={parsed.type}\n assetIds={parsed.assetIds}\n thumbnailUrl={parsed.thumbnailUrl}\n sourceHref={isSpacesMentionUrl(href) ? href : undefined}\n />\n );\n }\n\n if (href?.startsWith(\"chrome-extension://\")) {\n return <span>{children}</span>;\n }\n\n // Normal link — render as-is\n return (\n <a href={href} target=\"_blank\" rel=\"noopener noreferrer\">\n {children}\n </a>\n );\n};\n\n// ── Inline mention chip ──\n\nexport const MentionChip: FC<{\n name: string;\n type?: string;\n assetIds?: string[];\n thumbnailUrl?: string;\n sourceHref?: string;\n}> = ({ name, type, assetIds, thumbnailUrl, sourceHref }) => {\n const auth = useContext(MentionAuthCtx);\n const assetRootHref =\n type === \"asset\" && assetIds?.length\n ? createOlympusAssetUrl({\n appUrl: auth?.appUrl,\n backendUrl: auth?.backendUrl,\n assetIds,\n })\n : null;\n const href = (() => {\n if (!assetRootHref || !sourceHref) return assetRootHref;\n try {\n const source = new URL(sourceHref, \"https://app.athenaintel.com\");\n const destination = new URL(assetRootHref);\n for (const [key, value] of source.searchParams) {\n destination.searchParams.set(key, value);\n }\n destination.searchParams.set(\"asset_ids\", assetIds?.join(\",\") ?? \"\");\n return destination.toString();\n } catch {\n return assetRootHref;\n }\n })();\n // `not-prose` matters: assistant messages render inside Tailwind\n // Typography's `prose`, whose zero-specificity `img` margins (~1.7em\n // top/bottom) would otherwise inflate the chip's icon into a tall card\n // that breaks the sentence flow around it.\n const className = cn(\n \"not-prose inline-flex max-w-[220px] items-center gap-1 whitespace-nowrap rounded-md border border-slate-300 bg-white px-1.5 py-px align-middle text-[0.85em] font-medium leading-[1.4] text-slate-600 no-underline\",\n href &&\n \"cursor-pointer transition-colors hover:border-slate-400 hover:bg-slate-50 hover:text-slate-800 hover:no-underline focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary focus-visible:ring-offset-1\",\n );\n const contents = (\n <>\n {thumbnailUrl && (\n <img\n src={thumbnailUrl}\n alt=\"\"\n className=\"size-3.5 shrink-0\"\n draggable={false}\n />\n )}\n {!thumbnailUrl && type === \"webpage\" && (\n <Globe2Icon className=\"size-3.5 shrink-0\" aria-hidden=\"true\" />\n )}\n <span className=\"max-w-[180px] overflow-hidden text-ellipsis\">\n {name}\n </span>\n </>\n );\n\n if (href) {\n return (\n <a\n href={href}\n target=\"_blank\"\n rel=\"noopener noreferrer\"\n className={className}\n aria-label={`Open ${name} in Spaces`}\n title={`Open ${name} in Spaces`}\n >\n {contents}\n </a>\n );\n }\n\n return <span className={className}>{contents}</span>;\n};\n\n// ── Parse mention:// URLs ──\n\nexport function parseMentionUrl(url: string): {\n type: string;\n name: string;\n id: string;\n assetIds?: string[];\n thumbnailUrl?: string;\n} {\n try {\n if (isSpacesMentionUrl(url)) {\n const parsed = new URL(url, \"https://app.athenaintel.com\");\n const assetIds = (parsed.searchParams.get(\"asset_ids\") ?? \"\")\n .split(\",\")\n .map((id) => id.trim())\n .filter(Boolean);\n const id = assetIds[0] ?? \"\";\n const assetType = getSpacesAssetType(parsed);\n return {\n type: \"asset\",\n name: assetIds.length > 1 ? `${assetIds.length} assets` : \"Asset\",\n id,\n assetIds,\n thumbnailUrl: assetTypeToThumb(assetType),\n };\n }\n // mention://tool?name=...&description=...\n // mention://asset?id=...&assetType=project&thumb=../icons/files/ic-project.svg\n const u = new URL(url);\n const type = u.hostname || u.pathname.replace(/^\\/\\//, \"\").split(\"?\")[0];\n const isWebpage = type === \"webpage\";\n const id = isWebpage\n ? u.searchParams.get(\"tab_id\") || \"\"\n : u.searchParams.get(\"id\") || u.searchParams.get(\"name\") || \"\";\n const name = isWebpage\n ? u.searchParams.get(\"title\") || \"This webpage\"\n : u.searchParams.get(\"name\") || id;\n\n // Get thumbnail: prefer explicit thumb param, then derive from assetType\n let thumbnailUrl = u.searchParams.get(\"thumb\") || undefined;\n if (!thumbnailUrl) {\n const assetType = u.searchParams.get(\"assetType\");\n if (assetType) {\n thumbnailUrl = assetTypeToThumb(assetType);\n } else if (type === \"asset\" || type === \"folder\") {\n thumbnailUrl = assetTypeToThumb(type === \"folder\" ? \"folder\" : null);\n }\n }\n\n return {\n type,\n name,\n id,\n assetIds: type === \"asset\" && id ? [id] : undefined,\n thumbnailUrl,\n };\n } catch {\n return { type: \"unknown\", name: \"\", id: \"\" };\n }\n}\n\nfunction htmlAttribute(attributes: string, name: string): string | null {\n const escapedName = name.replace(/[.*+?^${}()|[\\]\\\\]/g, \"\\\\$&\");\n const match = new RegExp(\n `(?:^|\\\\s)${escapedName}\\\\s*=\\\\s*(?:\"([^\"]*)\"|'([^']*)'|([^\\\\s>]+))`,\n \"i\",\n ).exec(attributes);\n return match?.[1] ?? match?.[2] ?? match?.[3] ?? null;\n}\n\nfunction decodeHtmlAttribute(value: string): string {\n return value\n .replace(/&/gi, \"&\")\n .replace(/"/gi, '\"')\n .replace(/'|'/gi, \"'\")\n .replace(/</gi, \"<\")\n .replace(/>/gi, \">\");\n}\n\n/** Turn complete model-emitted URL citation anchors into safe Markdown links. */\nexport function normalizeAthenaMentionHtml(text: string): string {\n return text.replace(\n /<a\\b([^>]*)>([\\s\\S]*?)<\\/a>/gi,\n (original, attributes: string, rawLabel: string) => {\n const className = htmlAttribute(attributes, \"class\") ?? \"\";\n const type = htmlAttribute(attributes, \"data-type\") ?? \"\";\n if (!className.split(/\\s+/).includes(\"mention\") || type !== \"url\") {\n return original;\n }\n\n const rawUrl =\n htmlAttribute(attributes, \"data-url\") ??\n htmlAttribute(attributes, \"href\");\n if (!rawUrl) return original;\n const url = decodeHtmlAttribute(rawUrl);\n let normalizedUrl: string;\n try {\n const parsed = new URL(url);\n if (parsed.protocol !== \"http:\" && parsed.protocol !== \"https:\") {\n return original;\n }\n normalizedUrl = parsed.toString();\n } catch {\n return original;\n }\n\n const label = decodeHtmlAttribute(rawLabel.replace(/<[^>]*>/g, \"\"))\n .trim()\n .replace(/([\\\\[\\]])/g, \"\\\\$1\");\n return label ? `[${label}](<${normalizedUrl}>)` : original;\n },\n );\n}\n// ── Parse mention markdown in plain text ──\n\nconst MENTION_RE =\n /\\[@([^\\]]*)\\]\\(((?:mention:\\/\\/|(?:https?:\\/\\/[^)\\s]+)?\\/dashboard\\/spaces\\/?\\?)[^)]+)\\)/g;\n\n/**\n * Parse text containing [@name](mention://...) patterns into\n * an array of string segments and MentionChip elements.\n */\nexport function parseMentionsInText(text: string): (string | ReactElement)[] {\n const parts: (string | ReactElement)[] = [];\n let lastIndex = 0;\n let match: RegExpExecArray | null;\n\n MENTION_RE.lastIndex = 0;\n\n while ((match = MENTION_RE.exec(text)) !== null) {\n if (match.index > lastIndex) {\n parts.push(text.slice(lastIndex, match.index));\n }\n\n const name = match[1];\n const url = match[2];\n const parsed = parseMentionUrl(url);\n\n parts.push(\n <MentionChip\n key={`mention-${match.index}`}\n name={name || parsed.name}\n type={parsed.type}\n assetIds={parsed.assetIds}\n thumbnailUrl={parsed.thumbnailUrl}\n sourceHref={isSpacesMentionUrl(url) ? url : undefined}\n />\n );\n\n lastIndex = match.index + match[0].length;\n }\n\n if (lastIndex < text.length) {\n parts.push(text.slice(lastIndex));\n }\n\n return parts.length > 0 ? parts : [text];\n}\n"],"names":["id"],"mappings":";;;;;;;AAeA,MAAM,sBAAsB;AAE5B,SAAS,mBAAmB,KAAsB;AAChD,SAAO,oBAAoB,KAAK,GAAG;AACrC;AAEA,SAAS,mBAAmB,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,MAAM,CAAC;AACpB,UAAM,MAAM,MAAM,CAAC;AACnB,UAAM,SAAS,gBAAgB,GAAG;AAElC,UAAM;AAAA,MACJ;AAAA,QAAC;AAAA,QAAA;AAAA,UAEC,MAAM,QAAQ,OAAO;AAAA,UACrB,MAAM,OAAO;AAAA,UACb,UAAU,OAAO;AAAA,UACjB,cAAc,OAAO;AAAA,UACrB,YAAY,mBAAmB,GAAG,IAAI,MAAM;AAAA,QAAA;AAAA,QALvC,WAAW,MAAM,KAAK;AAAA,MAAA;AAAA,IAM7B;AAGF,gBAAY,MAAM,QAAQ,MAAM,CAAC,EAAE;AAAA,EACrC;AAEA,MAAI,YAAY,KAAK,QAAQ;AAC3B,UAAM,KAAK,KAAK,MAAM,SAAS,CAAC;AAAA,EAClC;AAEA,SAAO,MAAM,SAAS,IAAI,QAAQ,CAAC,IAAI;AACzC;"}
|
|
1
|
+
{"version":3,"file":"mention-chip.js","sources":["../../../src/chat-ui/mentions/mention-chip.tsx"],"sourcesContent":["/**\n * Mention chip rendering for message display.\n *\n * Parses [@name](mention://type?...) markdown links and renders them\n * as styled inline chips matching the Olympus mention style.\n * Used in both user messages (inline text) and assistant messages (markdown links).\n */\n\nimport { useContext, type FC, type ReactElement, type ReactNode } from \"react\";\nimport {\n formatScreenPoint,\n isScreenPointHref,\n parseScreenPointHref,\n} from \"@athenaintel/agent-runtime\";\nimport { CrosshairIcon, Globe2Icon } from \"lucide-react\";\nimport { cn } from \"../../lib/utils\";\nimport { createOlympusAssetUrl } from \"../lib/asset-urls\";\nimport { MentionAuthCtx } from \"./suggestions/data/api-client\";\nimport { assetTypeToThumb } from \"./suggestions/data/sources/asset-type-icons\";\n\nconst SPACES_MENTION_PATH = /\\/dashboard\\/spaces\\/?\\?/;\n\nfunction isSpacesMentionUrl(url: string): boolean {\n return SPACES_MENTION_PATH.test(url);\n}\n\nfunction getSpacesAssetType(url: URL): string | null {\n const assetType =\n url.searchParams.get(\"assetType\") ||\n url.searchParams.get(\"asset_type\") ||\n url.searchParams.get(\"type\");\n return assetType === \"sheet\" ? \"spreadsheet\" : assetType;\n}\n\n// ── Mention link component for markdown renderer ──\n\n/**\n * Custom <a> renderer for MarkdownTextPrimitive.\n * Intercepts mention:// links and renders them as chips.\n * Falls through to a normal link for non-mention URLs.\n */\nexport const MentionLink: FC<{\n href?: string;\n children?: ReactNode;\n interactive?: boolean;\n}> = ({ href, children, interactive = true }) => {\n if (\n href &&\n (href.startsWith(\"mention://\") || isSpacesMentionUrl(href))\n ) {\n const name = typeof children === \"string\"\n ? children.replace(/^@/, \"\")\n : Array.isArray(children)\n ? String(children[0] ?? \"\").replace(/^@/, \"\")\n : \"\";\n\n const parsed = parseMentionUrl(href);\n\n return (\n <MentionChip\n name={name || parsed.name}\n type={parsed.type}\n assetIds={parsed.assetIds}\n thumbnailUrl={parsed.thumbnailUrl}\n sourceHref={isSpacesMentionUrl(href) ? href : undefined}\n interactive={interactive}\n />\n );\n }\n\n if (href?.startsWith(\"chrome-extension://\")) {\n return <span>{children}</span>;\n }\n\n if (isScreenPointHref(href)) {\n return <ScreenPointChip href={href}>{children}</ScreenPointChip>;\n }\n\n // Normal link — render as-is\n return (\n <a href={href} target=\"_blank\" rel=\"noopener noreferrer\">\n {children}\n </a>\n );\n};\n\n// ── Inline screen-point chip ──\n\n/**\n * Renders an `athena-point://` link as a non-navigating coordinate chip.\n * Surfaces without screenshot context (extension side panel, SDK consumers)\n * get the label plus the coordinates; malformed points fall back to text.\n */\nexport const ScreenPointChip: FC<{\n href: string;\n children?: ReactNode;\n}> = ({ href, children }) => {\n const parsed = parseScreenPointHref(href);\n if (!parsed.ok) {\n return <span>{children}</span>;\n }\n const description = formatScreenPoint(parsed.point);\n return (\n <span\n className=\"not-prose inline-flex max-w-[260px] items-center gap-1 whitespace-nowrap rounded-md border border-slate-300 bg-white px-1.5 py-px align-middle text-[0.85em] font-medium leading-[1.4] text-slate-600\"\n title={description}\n aria-label={description}\n data-screen-point=\"valid\"\n >\n <CrosshairIcon className=\"size-3.5 shrink-0\" aria-hidden=\"true\" />\n <span className=\"max-w-[180px] overflow-hidden text-ellipsis\">\n {children}\n </span>\n <span className=\"font-normal text-slate-400\">\n {parsed.point.x}, {parsed.point.y}\n </span>\n </span>\n );\n};\n\n// ── Inline mention chip ──\n\nexport const MentionChip: FC<{\n name: string;\n type?: string;\n assetIds?: string[];\n thumbnailUrl?: string;\n sourceHref?: string;\n interactive?: boolean;\n}> = ({ name, type, assetIds, thumbnailUrl, sourceHref, interactive = true }) => {\n const auth = useContext(MentionAuthCtx);\n const assetRootHref =\n type === \"asset\" && assetIds?.length\n ? createOlympusAssetUrl({\n appUrl: auth?.appUrl,\n backendUrl: auth?.backendUrl,\n assetIds,\n })\n : null;\n const href = (() => {\n if (!assetRootHref || !sourceHref) return assetRootHref;\n try {\n const source = new URL(sourceHref, \"https://app.athenaintel.com\");\n const destination = new URL(assetRootHref);\n for (const [key, value] of source.searchParams) {\n destination.searchParams.set(key, value);\n }\n destination.searchParams.set(\"asset_ids\", assetIds?.join(\",\") ?? \"\");\n return destination.toString();\n } catch {\n return assetRootHref;\n }\n })();\n // `not-prose` matters: assistant messages render inside Tailwind\n // Typography's `prose`, whose zero-specificity `img` margins (~1.7em\n // top/bottom) would otherwise inflate the chip's icon into a tall card\n // that breaks the sentence flow around it.\n const className = cn(\n \"not-prose inline-flex max-w-[220px] items-center gap-1 whitespace-nowrap rounded-md border border-slate-300 bg-white px-1.5 py-px align-middle text-[0.85em] font-medium leading-[1.4] text-slate-600 no-underline\",\n href &&\n \"cursor-pointer transition-colors hover:border-slate-400 hover:bg-slate-50 hover:text-slate-800 hover:no-underline focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary focus-visible:ring-offset-1\",\n );\n const contents = (\n <>\n {thumbnailUrl && (\n <img\n src={thumbnailUrl}\n alt=\"\"\n className=\"size-3.5 shrink-0\"\n draggable={false}\n />\n )}\n {!thumbnailUrl && type === \"webpage\" && (\n <Globe2Icon className=\"size-3.5 shrink-0\" aria-hidden=\"true\" />\n )}\n <span className=\"max-w-[180px] overflow-hidden text-ellipsis\">\n {name}\n </span>\n </>\n );\n\n if (href && interactive) {\n return (\n <a\n href={href}\n target=\"_blank\"\n rel=\"noopener noreferrer\"\n className={className}\n aria-label={`Open ${name} in Spaces`}\n title={`Open ${name} in Spaces`}\n >\n {contents}\n </a>\n );\n }\n\n return <span className={className}>{contents}</span>;\n};\n\n// ── Parse mention:// URLs ──\n\nexport function parseMentionUrl(url: string): {\n type: string;\n name: string;\n id: string;\n assetIds?: string[];\n thumbnailUrl?: string;\n} {\n try {\n if (isSpacesMentionUrl(url)) {\n const parsed = new URL(url, \"https://app.athenaintel.com\");\n const assetIds = (parsed.searchParams.get(\"asset_ids\") ?? \"\")\n .split(\",\")\n .map((id) => id.trim())\n .filter(Boolean);\n const id = assetIds[0] ?? \"\";\n const assetType = getSpacesAssetType(parsed);\n return {\n type: \"asset\",\n name: assetIds.length > 1 ? `${assetIds.length} assets` : \"Asset\",\n id,\n assetIds,\n thumbnailUrl: assetTypeToThumb(assetType),\n };\n }\n // mention://tool?name=...&description=...\n // mention://asset?id=...&assetType=project&thumb=../icons/files/ic-project.svg\n const u = new URL(url);\n const type = u.hostname || u.pathname.replace(/^\\/\\//, \"\").split(\"?\")[0];\n const isWebpage = type === \"webpage\";\n const id = isWebpage\n ? u.searchParams.get(\"tab_id\") || \"\"\n : u.searchParams.get(\"id\") || u.searchParams.get(\"name\") || \"\";\n const name = isWebpage\n ? u.searchParams.get(\"title\") || \"This webpage\"\n : u.searchParams.get(\"name\") || id;\n\n // Get thumbnail: prefer explicit thumb param, then derive from assetType\n let thumbnailUrl = u.searchParams.get(\"thumb\") || undefined;\n if (!thumbnailUrl) {\n const assetType = u.searchParams.get(\"assetType\");\n if (assetType) {\n thumbnailUrl = assetTypeToThumb(assetType);\n } else if (type === \"asset\" || type === \"folder\") {\n thumbnailUrl = assetTypeToThumb(type === \"folder\" ? \"folder\" : null);\n }\n }\n\n return {\n type,\n name,\n id,\n assetIds: type === \"asset\" && id ? [id] : undefined,\n thumbnailUrl,\n };\n } catch {\n return { type: \"unknown\", name: \"\", id: \"\" };\n }\n}\n\nfunction htmlAttribute(attributes: string, name: string): string | null {\n const escapedName = name.replace(/[.*+?^${}()|[\\]\\\\]/g, \"\\\\$&\");\n const match = new RegExp(\n `(?:^|\\\\s)${escapedName}\\\\s*=\\\\s*(?:\"([^\"]*)\"|'([^']*)'|([^\\\\s>]+))`,\n \"i\",\n ).exec(attributes);\n return match?.[1] ?? match?.[2] ?? match?.[3] ?? null;\n}\n\nfunction decodeHtmlAttribute(value: string): string {\n return value\n .replace(/&/gi, \"&\")\n .replace(/"/gi, '\"')\n .replace(/'|'/gi, \"'\")\n .replace(/</gi, \"<\")\n .replace(/>/gi, \">\");\n}\n\n/** Turn complete model-emitted URL citation anchors into safe Markdown links. */\nexport function normalizeAthenaMentionHtml(text: string): string {\n return text.replace(\n /<a\\b([^>]*)>([\\s\\S]*?)<\\/a>/gi,\n (original, attributes: string, rawLabel: string) => {\n const className = htmlAttribute(attributes, \"class\") ?? \"\";\n const type = htmlAttribute(attributes, \"data-type\") ?? \"\";\n if (!className.split(/\\s+/).includes(\"mention\") || type !== \"url\") {\n return original;\n }\n\n const rawUrl =\n htmlAttribute(attributes, \"data-url\") ??\n htmlAttribute(attributes, \"href\");\n if (!rawUrl) return original;\n const url = decodeHtmlAttribute(rawUrl);\n let normalizedUrl: string;\n try {\n const parsed = new URL(url);\n if (parsed.protocol !== \"http:\" && parsed.protocol !== \"https:\") {\n return original;\n }\n normalizedUrl = parsed.toString();\n } catch {\n return original;\n }\n\n const label = decodeHtmlAttribute(rawLabel.replace(/<[^>]*>/g, \"\"))\n .trim()\n .replace(/([\\\\[\\]])/g, \"\\\\$1\");\n return label ? `[${label}](<${normalizedUrl}>)` : original;\n },\n );\n}\n// ── Parse mention markdown in plain text ──\n\nconst MENTION_RE =\n /\\[@([^\\]]*)\\]\\(((?:mention:\\/\\/|(?:https?:\\/\\/[^)\\s]+)?\\/dashboard\\/spaces\\/?\\?)[^)]+)\\)/g;\n\n/**\n * Parse text containing [@name](mention://...) patterns into\n * an array of string segments and MentionChip elements.\n */\nexport function parseMentionsInText(text: string): (string | ReactElement)[] {\n const parts: (string | ReactElement)[] = [];\n let lastIndex = 0;\n let match: RegExpExecArray | null;\n\n MENTION_RE.lastIndex = 0;\n\n while ((match = MENTION_RE.exec(text)) !== null) {\n if (match.index > lastIndex) {\n parts.push(text.slice(lastIndex, match.index));\n }\n\n const name = match[1];\n const url = match[2];\n const parsed = parseMentionUrl(url);\n\n parts.push(\n <MentionChip\n key={`mention-${match.index}`}\n name={name || parsed.name}\n type={parsed.type}\n assetIds={parsed.assetIds}\n thumbnailUrl={parsed.thumbnailUrl}\n sourceHref={isSpacesMentionUrl(url) ? url : undefined}\n />\n );\n\n lastIndex = match.index + match[0].length;\n }\n\n if (lastIndex < text.length) {\n parts.push(text.slice(lastIndex));\n }\n\n return parts.length > 0 ? parts : [text];\n}\n"],"names":["id"],"mappings":";;;;;;;;;;;;;;;;;;;;;;AAoBA,MAAM,sBAAsB;AAE5B,SAAS,mBAAmB,KAAsB;AAChD,SAAO,oBAAoB,KAAK,GAAG;AACrC;AAEA,SAAS,mBAAmB,KAAyB;AACnD,QAAM,YACJ,IAAI,aAAa,IAAI,WAAW,KAChC,IAAI,aAAa,IAAI,YAAY,KACjC,IAAI,aAAa,IAAI,MAAM;AAC7B,SAAO,cAAc,UAAU,gBAAgB;AACjD;AASO,MAAM,cAIR,CAAC,EAAE,MAAM,UAAU,cAAc,WAAW;AAC/C,MACE,SACC,KAAK,WAAW,YAAY,KAAK,mBAAmB,IAAI,IACzD;AACA,UAAM,OAAO,OAAO,aAAa,WAC7B,SAAS,QAAQ,MAAM,EAAE,IACzB,MAAM,QAAQ,QAAQ,IACpB,OAAO,SAAS,CAAC,KAAK,EAAE,EAAE,QAAQ,MAAM,EAAE,IAC1C;AAEN,UAAM,SAAS,gBAAgB,IAAI;AAE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aACJ;AAMK,SAAS,oBAAoB,MAAyC;AAC3E,QAAM,QAAmC,CAAA;AACzC,MAAI,YAAY;AAChB,MAAI;AAEJ,aAAW,YAAY;AAEvB,UAAQ,QAAQ,WAAW,KAAK,IAAI,OAAO,MAAM;AAC/C,QAAI,MAAM,QAAQ,WAAW;AAC3B,YAAM,KAAK,KAAK,MAAM,WAAW,MAAM,KAAK,CAAC;AAAA,IAC/C;AAEA,UAAM,OAAO,MAAM,CAAC;AACpB,UAAM,MAAM,MAAM,CAAC;AACnB,UAAM,SAAS,gBAAgB,GAAG;AAElC,UAAM;AAAA,MACJ;AAAA,QAAC;AAAA,QAAA;AAAA,UAEC,MAAM,QAAQ,OAAO;AAAA,UACrB,MAAM,OAAO;AAAA,UACb,UAAU,OAAO;AAAA,UACjB,cAAc,OAAO;AAAA,UACrB,YAAY,mBAAmB,GAAG,IAAI,MAAM;AAAA,QAAA;AAAA,QALvC,WAAW,MAAM,KAAK;AAAA,MAAA;AAAA,IAM7B;AAGF,gBAAY,MAAM,QAAQ,MAAM,CAAC,EAAE;AAAA,EACrC;AAEA,MAAI,YAAY,KAAK,QAAQ;AAC3B,UAAM,KAAK,KAAK,MAAM,SAAS,CAAC;AAAA,EAClC;AAEA,SAAO,MAAM,SAAS,IAAI,QAAQ,CAAC,IAAI;AACzC;"}
|
|
@@ -2,6 +2,9 @@
|
|
|
2
2
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
3
3
|
const core = require("@tiptap/core");
|
|
4
4
|
function makeMentionUrl(attrs) {
|
|
5
|
+
if (attrs.href && (attrs.href.startsWith("mention://") || ASSET_MENTION_HREF.test(attrs.href))) {
|
|
6
|
+
return attrs.href;
|
|
7
|
+
}
|
|
5
8
|
if (attrs.type === "tool" || attrs.type === "toolkit") {
|
|
6
9
|
return `mention://${attrs.type}?name=${encodeURIComponent(attrs.id)}&description=${encodeURIComponent(attrs.description ?? "")}`;
|
|
7
10
|
}
|
|
@@ -34,6 +37,7 @@ function parseMentionAnchorAttributes({
|
|
|
34
37
|
const url = new URL(href);
|
|
35
38
|
const isWebpage = url.hostname === "webpage";
|
|
36
39
|
return {
|
|
40
|
+
href,
|
|
37
41
|
type: isWebpage ? "tab" : url.hostname || "tool",
|
|
38
42
|
name: (textContent == null ? void 0 : textContent.replace(/^@/, "")) || "",
|
|
39
43
|
id: isWebpage ? url.searchParams.get("tab_id") || "" : url.searchParams.get("name") || url.searchParams.get("id") || "",
|
|
@@ -45,7 +49,7 @@ function parseMentionAnchorAttributes({
|
|
|
45
49
|
assetType: url.searchParams.get("assetType") || ""
|
|
46
50
|
};
|
|
47
51
|
}
|
|
48
|
-
const ASSET_MENTION_HREF =
|
|
52
|
+
const ASSET_MENTION_HREF = /^(?:https?:\/\/[^/]+)?\/dashboard\/spaces\/?\?/;
|
|
49
53
|
function parseAssetAnchorAttributes({
|
|
50
54
|
href,
|
|
51
55
|
textContent
|
|
@@ -56,6 +60,7 @@ function parseAssetAnchorAttributes({
|
|
|
56
60
|
if (!id) return null;
|
|
57
61
|
return {
|
|
58
62
|
type: "asset",
|
|
63
|
+
href,
|
|
59
64
|
name: (textContent == null ? void 0 : textContent.replace(/^@/, "")) || "",
|
|
60
65
|
id,
|
|
61
66
|
assetType: params.get("assetType") || ""
|
|
@@ -70,6 +75,7 @@ const MentionExtension = core.Node.create({
|
|
|
70
75
|
atom: true,
|
|
71
76
|
addAttributes() {
|
|
72
77
|
return {
|
|
78
|
+
href: { default: null },
|
|
73
79
|
type: { default: "tool" },
|
|
74
80
|
name: { default: "" },
|
|
75
81
|
id: { default: "" },
|
|
@@ -103,6 +109,7 @@ const MentionExtension = core.Node.create({
|
|
|
103
109
|
var _a;
|
|
104
110
|
const el = dom;
|
|
105
111
|
return {
|
|
112
|
+
href: el.getAttribute("data-href"),
|
|
106
113
|
type: el.getAttribute("data-type") || "tool",
|
|
107
114
|
name: el.getAttribute("data-name") || ((_a = el.textContent) == null ? void 0 : _a.replace(/^@/, "")) || "",
|
|
108
115
|
id: el.getAttribute("data-id") || "",
|
|
@@ -121,14 +128,18 @@ const MentionExtension = core.Node.create({
|
|
|
121
128
|
priority: ANCHOR_RULE_PRIORITY,
|
|
122
129
|
getAttrs: (dom) => {
|
|
123
130
|
const el = dom;
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
131
|
+
try {
|
|
132
|
+
return parseMentionAnchorAttributes({
|
|
133
|
+
href: el.getAttribute("href") ?? el.href,
|
|
134
|
+
textContent: el.textContent
|
|
135
|
+
});
|
|
136
|
+
} catch {
|
|
137
|
+
return false;
|
|
138
|
+
}
|
|
128
139
|
}
|
|
129
140
|
},
|
|
130
141
|
{
|
|
131
|
-
tag: "a[href
|
|
142
|
+
tag: "a[href]",
|
|
132
143
|
priority: ANCHOR_RULE_PRIORITY,
|
|
133
144
|
getAttrs: (dom) => {
|
|
134
145
|
const el = dom;
|
|
@@ -159,6 +170,7 @@ const MentionExtension = core.Node.create({
|
|
|
159
170
|
"span",
|
|
160
171
|
core.mergeAttributes(HTMLAttributes, {
|
|
161
172
|
"data-mention": "",
|
|
173
|
+
"data-href": node.attrs.href || "",
|
|
162
174
|
"data-type": node.attrs.type,
|
|
163
175
|
"data-name": node.attrs.name,
|
|
164
176
|
"data-id": node.attrs.id,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"mention-extension.cjs","sources":["../../../src/chat-ui/mentions/mention-extension.ts"],"sourcesContent":["/**\n * Tiptap Mention Node Extension\n *\n * Defines the mention node type used in the editor. When a mention is\n * inserted, it creates a non-editable inline node with metadata.\n *\n * Renders as a chip with: [icon] Name. Serializes — to plain text and to\n * Markdown alike — as `[@Name](url)`, and parses that link back into a chip.\n */\n\nimport { mergeAttributes, Node } from \"@tiptap/core\";\nimport type { Node as ProseMirrorNode } from \"@tiptap/pm/model\";\n\nexport function makeMentionUrl(attrs: { id: string; type: string; name: string; title?: string; url?: string; description?: string; thumbnailUrl?: string; assetType?: string }): string {\n if (attrs.type === \"tool\" || attrs.type === \"toolkit\") {\n return `mention://${attrs.type}?name=${encodeURIComponent(attrs.id)}&description=${encodeURIComponent(attrs.description ?? \"\")}`;\n }\n if (attrs.type === \"asset\") {\n const params = new URLSearchParams({ asset_ids: attrs.id });\n if (attrs.assetType) params.set(\"assetType\", attrs.assetType);\n return `/dashboard/spaces?${params.toString()}`;\n }\n if (attrs.type === \"tab\") {\n const params = new URLSearchParams({\n tab_id: attrs.id,\n url: attrs.url ?? \"\",\n title: attrs.title ?? attrs.name,\n });\n return `mention://webpage?${params.toString()}`;\n }\n // Include athenaOriginalType and thumbnailUrl so the chip can be reconstructed\n const params = new URLSearchParams();\n params.set(\"id\", attrs.id);\n if (attrs.assetType) params.set(\"assetType\", attrs.assetType);\n if (attrs.thumbnailUrl) params.set(\"thumb\", attrs.thumbnailUrl);\n return `mention://${encodeURIComponent(attrs.type)}?${params.toString()}`;\n}\n\nexport interface MentionNodeAttrs {\n type: string;\n name: string;\n id: string;\n title?: string;\n url?: string;\n description?: string;\n thumbnailUrl?: string;\n fallbackIcon?: string;\n assetType?: string;\n displayAsPreview?: boolean;\n}\n\n/** The `[@Name](url)` form a mention takes in the outgoing text. */\nexport function serializeMention(attrs: MentionNodeAttrs): string {\n return `[@${attrs.name}](${makeMentionUrl(attrs)})`;\n}\n\nexport function parseMentionAnchorAttributes({\n href,\n textContent,\n}: {\n href: string;\n textContent: string | null;\n}): MentionNodeAttrs {\n const url = new URL(href);\n const isWebpage = url.hostname === \"webpage\";\n return {\n type: isWebpage ? \"tab\" : url.hostname || \"tool\",\n name: textContent?.replace(/^@/, \"\") || \"\",\n id: isWebpage\n ? url.searchParams.get(\"tab_id\") || \"\"\n : url.searchParams.get(\"name\") || url.searchParams.get(\"id\") || \"\",\n title: url.searchParams.get(\"title\") || \"\",\n url: url.searchParams.get(\"url\") || \"\",\n description: url.searchParams.get(\"description\") || \"\",\n thumbnailUrl: url.searchParams.get(\"thumb\") || \"\",\n fallbackIcon: \"\",\n assetType: url.searchParams.get(\"assetType\") || \"\",\n };\n}\n\n/** The asset link `makeMentionUrl` writes (`/dashboard/spaces?asset_ids=…`). */\nconst ASSET_MENTION_HREF = /^\\/dashboard\\/spaces\\?/;\n\n/**\n * Attributes of an asset mention from its `/dashboard/spaces?asset_ids=…`\n * link, or null for a spaces link that names no asset.\n */\nexport function parseAssetAnchorAttributes({\n href,\n textContent,\n}: {\n href: string;\n textContent: string | null;\n}): MentionNodeAttrs | null {\n if (!ASSET_MENTION_HREF.test(href)) return null;\n const params = new URLSearchParams(href.slice(href.indexOf(\"?\") + 1));\n const id = params.get(\"asset_ids\");\n if (!id) return null;\n return {\n type: \"asset\",\n name: textContent?.replace(/^@/, \"\") || \"\",\n id,\n assetType: params.get(\"assetType\") || \"\",\n };\n}\n\ninterface MarkdownSerializerState {\n write(text: string): void;\n}\n\n/**\n * ProseMirror tries parse rules by rule priority (default 50), mark rules\n * before node rules at a tie: a serialized mention is an anchor, so its rules\n * must outrank the Link mark's `a[href]` rule or the chip comes back as a\n * plain link.\n */\nconst ANCHOR_RULE_PRIORITY = 100;\n\nexport const MentionExtension = Node.create({\n name: \"mention\",\n group: \"inline\",\n inline: true,\n selectable: false,\n atom: true,\n\n addAttributes() {\n return {\n type: { default: \"tool\" },\n name: { default: \"\" },\n id: { default: \"\" },\n title: { default: \"\" },\n url: { default: \"\" },\n description: { default: \"\" },\n thumbnailUrl: { default: \"\" },\n fallbackIcon: { default: \"\" },\n assetType: { default: \"\" },\n displayAsPreview: { default: false },\n };\n },\n\n /** tiptap-markdown reads this spec so `getMarkdown()` writes the mention, not HTML. */\n addStorage() {\n return {\n markdown: {\n serialize(state: MarkdownSerializerState, node: ProseMirrorNode) {\n state.write(serializeMention(node.attrs as MentionNodeAttrs));\n },\n parse: {\n // The Markdown parser renders the link to an anchor; parseHTML takes it from there.\n },\n },\n };\n },\n\n parseHTML() {\n return [\n {\n tag: \"span[data-mention]\",\n getAttrs: (dom) => {\n const el = dom as HTMLElement;\n return {\n type: el.getAttribute(\"data-type\") || \"tool\",\n name: el.getAttribute(\"data-name\") || el.textContent?.replace(/^@/, \"\") || \"\",\n id: el.getAttribute(\"data-id\") || \"\",\n title: el.getAttribute(\"data-title\") || \"\",\n url: el.getAttribute(\"data-url\") || \"\",\n description: el.getAttribute(\"data-description\") || \"\",\n thumbnailUrl: el.getAttribute(\"data-thumbnail-url\") || \"\",\n fallbackIcon: el.getAttribute(\"data-fallback-icon\") || \"\",\n assetType: el.getAttribute(\"data-asset-type\") || \"\",\n displayAsPreview:\n el.getAttribute(\"data-display-as-preview\") === \"true\",\n };\n },\n },\n {\n tag: \"a[href^='mention://']\",\n priority: ANCHOR_RULE_PRIORITY,\n getAttrs: (dom) => {\n const el = dom as HTMLAnchorElement;\n return parseMentionAnchorAttributes({\n href: el.getAttribute(\"href\") ?? el.href,\n textContent: el.textContent,\n });\n },\n },\n {\n tag: \"a[href^='/dashboard/spaces?']\",\n priority: ANCHOR_RULE_PRIORITY,\n getAttrs: (dom) => {\n const el = dom as HTMLAnchorElement;\n return (\n parseAssetAnchorAttributes({\n href: el.getAttribute(\"href\") ?? \"\",\n textContent: el.textContent,\n }) ?? false\n );\n },\n },\n ];\n },\n\n renderHTML({ node, HTMLAttributes }) {\n const thumbnailUrl = node.attrs.thumbnailUrl;\n\n // Build child elements: [icon] name\n const children: any[] = [];\n\n if (thumbnailUrl) {\n // Render SVG thumbnail as an img element inside the chip\n children.push([\n \"img\",\n {\n src: thumbnailUrl,\n alt: \"\",\n class: \"mention-chip-icon\",\n draggable: \"false\",\n },\n ]);\n }\n\n children.push([\"span\", { class: \"mention-chip-text\" }, node.attrs.name]);\n\n return [\n \"span\",\n mergeAttributes(HTMLAttributes, {\n \"data-mention\": \"\",\n \"data-type\": node.attrs.type,\n \"data-name\": node.attrs.name,\n \"data-id\": node.attrs.id,\n \"data-title\": node.attrs.title || \"\",\n \"data-url\": node.attrs.url || \"\",\n \"data-thumbnail-url\": node.attrs.thumbnailUrl || \"\",\n \"data-asset-type\": node.attrs.assetType || \"\",\n \"data-display-as-preview\": String(node.attrs.displayAsPreview === true),\n class: \"mention-chip\",\n }),\n ...children,\n ];\n },\n\n renderText({ node }) {\n return serializeMention(node.attrs as MentionNodeAttrs);\n },\n});\n"],"names":["params","Node","mergeAttributes"],"mappings":";;;AAaO,SAAS,eAAe,OAA0J;AACvL,MAAI,MAAM,SAAS,UAAU,MAAM,SAAS,WAAW;AACrD,WAAO,aAAa,MAAM,IAAI,SAAS,mBAAmB,MAAM,EAAE,CAAC,gBAAgB,mBAAmB,MAAM,eAAe,EAAE,CAAC;AAAA,EAChI;AACA,MAAI,MAAM,SAAS,SAAS;AAC1B,UAAMA,UAAS,IAAI,gBAAgB,EAAE,WAAW,MAAM,IAAI;AAC1D,QAAI,MAAM,UAAWA,SAAO,IAAI,aAAa,MAAM,SAAS;AAC5D,WAAO,qBAAqBA,QAAO,SAAA,CAAU;AAAA,EAC/C;AACA,MAAI,MAAM,SAAS,OAAO;AACxB,UAAMA,UAAS,IAAI,gBAAgB;AAAA,MACjC,QAAQ,MAAM;AAAA,MACd,KAAK,MAAM,OAAO;AAAA,MAClB,OAAO,MAAM,SAAS,MAAM;AAAA,IAAA,CAC7B;AACD,WAAO,qBAAqBA,QAAO,SAAA,CAAU;AAAA,EAC/C;AAEA,QAAM,SAAS,IAAI,gBAAA;AACnB,SAAO,IAAI,MAAM,MAAM,EAAE;AACzB,MAAI,MAAM,UAAW,QAAO,IAAI,aAAa,MAAM,SAAS;AAC5D,MAAI,MAAM,aAAc,QAAO,IAAI,SAAS,MAAM,YAAY;AAC9D,SAAO,aAAa,mBAAmB,MAAM,IAAI,CAAC,IAAI,OAAO,UAAU;AACzE;AAgBO,SAAS,iBAAiB,OAAiC;AAChE,SAAO,KAAK,MAAM,IAAI,KAAK,eAAe,KAAK,CAAC;AAClD;AAEO,SAAS,6BAA6B;AAAA,EAC3C;AAAA,EACA;AACF,GAGqB;AACnB,QAAM,MAAM,IAAI,IAAI,IAAI;AACxB,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AAAA,EACxD;AACF,CAAC;;;;;;"}
|
|
1
|
+
{"version":3,"file":"mention-extension.cjs","sources":["../../../src/chat-ui/mentions/mention-extension.ts"],"sourcesContent":["/**\n * Tiptap Mention Node Extension\n *\n * Defines the mention node type used in the editor. When a mention is\n * inserted, it creates a non-editable inline node with metadata.\n *\n * Renders as a chip with: [icon] Name. Serializes — to plain text and to\n * Markdown alike — as `[@Name](url)`, and parses that link back into a chip.\n */\n\nimport { mergeAttributes, Node } from \"@tiptap/core\";\nimport type { Node as ProseMirrorNode } from \"@tiptap/pm/model\";\n\nexport function makeMentionUrl(attrs: { id: string; type: string; name: string; title?: string; url?: string; description?: string; thumbnailUrl?: string; assetType?: string; href?: string }): string {\n if (attrs.href && (attrs.href.startsWith(\"mention://\") || ASSET_MENTION_HREF.test(attrs.href))) {\n return attrs.href;\n }\n if (attrs.type === \"tool\" || attrs.type === \"toolkit\") {\n return `mention://${attrs.type}?name=${encodeURIComponent(attrs.id)}&description=${encodeURIComponent(attrs.description ?? \"\")}`;\n }\n if (attrs.type === \"asset\") {\n const params = new URLSearchParams({ asset_ids: attrs.id });\n if (attrs.assetType) params.set(\"assetType\", attrs.assetType);\n return `/dashboard/spaces?${params.toString()}`;\n }\n if (attrs.type === \"tab\") {\n const params = new URLSearchParams({\n tab_id: attrs.id,\n url: attrs.url ?? \"\",\n title: attrs.title ?? attrs.name,\n });\n return `mention://webpage?${params.toString()}`;\n }\n // Include athenaOriginalType and thumbnailUrl so the chip can be reconstructed\n const params = new URLSearchParams();\n params.set(\"id\", attrs.id);\n if (attrs.assetType) params.set(\"assetType\", attrs.assetType);\n if (attrs.thumbnailUrl) params.set(\"thumb\", attrs.thumbnailUrl);\n return `mention://${encodeURIComponent(attrs.type)}?${params.toString()}`;\n}\n\nexport interface MentionNodeAttrs {\n type: string;\n name: string;\n id: string;\n title?: string;\n url?: string;\n description?: string;\n thumbnailUrl?: string;\n fallbackIcon?: string;\n assetType?: string;\n displayAsPreview?: boolean;\n href?: string;\n}\n\n/** The `[@Name](url)` form a mention takes in the outgoing text. */\nexport function serializeMention(attrs: MentionNodeAttrs): string {\n return `[@${attrs.name}](${makeMentionUrl(attrs)})`;\n}\n\nexport function parseMentionAnchorAttributes({\n href,\n textContent,\n}: {\n href: string;\n textContent: string | null;\n}): MentionNodeAttrs {\n const url = new URL(href);\n const isWebpage = url.hostname === \"webpage\";\n return {\n href,\n type: isWebpage ? \"tab\" : url.hostname || \"tool\",\n name: textContent?.replace(/^@/, \"\") || \"\",\n id: isWebpage\n ? url.searchParams.get(\"tab_id\") || \"\"\n : url.searchParams.get(\"name\") || url.searchParams.get(\"id\") || \"\",\n title: url.searchParams.get(\"title\") || \"\",\n url: url.searchParams.get(\"url\") || \"\",\n description: url.searchParams.get(\"description\") || \"\",\n thumbnailUrl: url.searchParams.get(\"thumb\") || \"\",\n fallbackIcon: \"\",\n assetType: url.searchParams.get(\"assetType\") || \"\",\n };\n}\n\n/** The asset link `makeMentionUrl` writes (`/dashboard/spaces?asset_ids=…`). */\nconst ASSET_MENTION_HREF = /^(?:https?:\\/\\/[^/]+)?\\/dashboard\\/spaces\\/?\\?/;\n\n/**\n * Attributes of an asset mention from its `/dashboard/spaces?asset_ids=…`\n * link, or null for a spaces link that names no asset.\n */\nexport function parseAssetAnchorAttributes({\n href,\n textContent,\n}: {\n href: string;\n textContent: string | null;\n}): MentionNodeAttrs | null {\n if (!ASSET_MENTION_HREF.test(href)) return null;\n const params = new URLSearchParams(href.slice(href.indexOf(\"?\") + 1));\n const id = params.get(\"asset_ids\");\n if (!id) return null;\n return {\n type: \"asset\",\n href,\n name: textContent?.replace(/^@/, \"\") || \"\",\n id,\n assetType: params.get(\"assetType\") || \"\",\n };\n}\n\ninterface MarkdownSerializerState {\n write(text: string): void;\n}\n\n/**\n * ProseMirror tries parse rules by rule priority (default 50), mark rules\n * before node rules at a tie: a serialized mention is an anchor, so its rules\n * must outrank the Link mark's `a[href]` rule or the chip comes back as a\n * plain link.\n */\nconst ANCHOR_RULE_PRIORITY = 100;\n\nexport const MentionExtension = Node.create({\n name: \"mention\",\n group: \"inline\",\n inline: true,\n selectable: false,\n atom: true,\n\n addAttributes() {\n return {\n href: { default: null },\n type: { default: \"tool\" },\n name: { default: \"\" },\n id: { default: \"\" },\n title: { default: \"\" },\n url: { default: \"\" },\n description: { default: \"\" },\n thumbnailUrl: { default: \"\" },\n fallbackIcon: { default: \"\" },\n assetType: { default: \"\" },\n displayAsPreview: { default: false },\n };\n },\n\n /** tiptap-markdown reads this spec so `getMarkdown()` writes the mention, not HTML. */\n addStorage() {\n return {\n markdown: {\n serialize(state: MarkdownSerializerState, node: ProseMirrorNode) {\n state.write(serializeMention(node.attrs as MentionNodeAttrs));\n },\n parse: {\n // The Markdown parser renders the link to an anchor; parseHTML takes it from there.\n },\n },\n };\n },\n\n parseHTML() {\n return [\n {\n tag: \"span[data-mention]\",\n getAttrs: (dom) => {\n const el = dom as HTMLElement;\n return {\n href: el.getAttribute(\"data-href\"),\n type: el.getAttribute(\"data-type\") || \"tool\",\n name: el.getAttribute(\"data-name\") || el.textContent?.replace(/^@/, \"\") || \"\",\n id: el.getAttribute(\"data-id\") || \"\",\n title: el.getAttribute(\"data-title\") || \"\",\n url: el.getAttribute(\"data-url\") || \"\",\n description: el.getAttribute(\"data-description\") || \"\",\n thumbnailUrl: el.getAttribute(\"data-thumbnail-url\") || \"\",\n fallbackIcon: el.getAttribute(\"data-fallback-icon\") || \"\",\n assetType: el.getAttribute(\"data-asset-type\") || \"\",\n displayAsPreview:\n el.getAttribute(\"data-display-as-preview\") === \"true\",\n };\n },\n },\n {\n tag: \"a[href^='mention://']\",\n priority: ANCHOR_RULE_PRIORITY,\n getAttrs: (dom) => {\n const el = dom as HTMLAnchorElement;\n try {\n return parseMentionAnchorAttributes({\n href: el.getAttribute(\"href\") ?? el.href,\n textContent: el.textContent,\n });\n } catch {\n return false;\n }\n },\n },\n {\n tag: \"a[href]\",\n priority: ANCHOR_RULE_PRIORITY,\n getAttrs: (dom) => {\n const el = dom as HTMLAnchorElement;\n return (\n parseAssetAnchorAttributes({\n href: el.getAttribute(\"href\") ?? \"\",\n textContent: el.textContent,\n }) ?? false\n );\n },\n },\n ];\n },\n\n renderHTML({ node, HTMLAttributes }) {\n const thumbnailUrl = node.attrs.thumbnailUrl;\n\n // Build child elements: [icon] name\n const children: any[] = [];\n\n if (thumbnailUrl) {\n // Render SVG thumbnail as an img element inside the chip\n children.push([\n \"img\",\n {\n src: thumbnailUrl,\n alt: \"\",\n class: \"mention-chip-icon\",\n draggable: \"false\",\n },\n ]);\n }\n\n children.push([\"span\", { class: \"mention-chip-text\" }, node.attrs.name]);\n\n return [\n \"span\",\n mergeAttributes(HTMLAttributes, {\n \"data-mention\": \"\",\n \"data-href\": node.attrs.href || \"\",\n \"data-type\": node.attrs.type,\n \"data-name\": node.attrs.name,\n \"data-id\": node.attrs.id,\n \"data-title\": node.attrs.title || \"\",\n \"data-url\": node.attrs.url || \"\",\n \"data-thumbnail-url\": node.attrs.thumbnailUrl || \"\",\n \"data-asset-type\": node.attrs.assetType || \"\",\n \"data-display-as-preview\": String(node.attrs.displayAsPreview === true),\n class: \"mention-chip\",\n }),\n ...children,\n ];\n },\n\n renderText({ node }) {\n return serializeMention(node.attrs as MentionNodeAttrs);\n },\n});\n"],"names":["params","Node","mergeAttributes"],"mappings":";;;AAaO,SAAS,eAAe,OAAyK;AACtM,MAAI,MAAM,SAAS,MAAM,KAAK,WAAW,YAAY,KAAK,mBAAmB,KAAK,MAAM,IAAI,IAAI;AAC9F,WAAO,MAAM;AAAA,EACf;AACA,MAAI,MAAM,SAAS,UAAU,MAAM,SAAS,WAAW;AACrD,WAAO,aAAa,MAAM,IAAI,SAAS,mBAAmB,MAAM,EAAE,CAAC,gBAAgB,mBAAmB,MAAM,eAAe,EAAE,CAAC;AAAA,EAChI;AACA,MAAI,MAAM,SAAS,SAAS;AAC1B,UAAMA,UAAS,IAAI,gBAAgB,EAAE,WAAW,MAAM,IAAI;AAC1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AAK;AAAA,QAEV;AAAA,MAAA;AAAA,IACF;AAAA,EAEJ;AAAA,EAEA,WAAW,EAAE,MAAM,kBAAkB;AACnC,UAAM,eAAe,KAAK,MAAM;AAGhC,UAAM,WAAkB,CAAA;AAExB,QAAI,cAAc;AAEhB,eAAS,KAAK;AAAA,QACZ;AAAA,QACA;AAAA,UACE,KAAK;AAAA,UACL,KAAK;AAAA,UACL,OAAO;AAAA,UACP,WAAW;AAAA,QAAA;AAAA,MACb,CACD;AAAA,IACH;AAEA,aAAS,KAAK,CAAC,QAAQ,EAAE,OAAO,uBAAuB,KAAK,MAAM,IAAI,CAAC;AAEvE,WAAO;AAAA,MACL;AAAA,MACAC,KAAAA,gBAAgB,gBAAgB;AAAA,QAC9B,gBAAgB;AAAA,QAChB,aAAa,KAAK,MAAM,QAAQ;AAAA,QAChC,aAAa,KAAK,MAAM;AAAA,QACxB,aAAa,KAAK,MAAM;AAAA,QACxB,WAAW,KAAK,MAAM;AAAA,QACtB,cAAc,KAAK,MAAM,SAAS;AAAA,QAClC,YAAY,KAAK,MAAM,OAAO;AAAA,QAC9B,sBAAsB,KAAK,MAAM,gBAAgB;AAAA,QACjD,mBAAmB,KAAK,MAAM,aAAa;AAAA,QAC3C,2BAA2B,OAAO,KAAK,MAAM,qBAAqB,IAAI;AAAA,QACtE,OAAO;AAAA,MAAA,CACR;AAAA,MACD,GAAG;AAAA,IAAA;AAAA,EAEP;AAAA,EAEA,WAAW,EAAE,QAAQ;AACnB,WAAO,iBAAiB,KAAK,KAAyB;AAAA,EACxD;AACF,CAAC;;;;;;"}
|
|
@@ -18,6 +18,7 @@ export declare function makeMentionUrl(attrs: {
|
|
|
18
18
|
description?: string;
|
|
19
19
|
thumbnailUrl?: string;
|
|
20
20
|
assetType?: string;
|
|
21
|
+
href?: string;
|
|
21
22
|
}): string;
|
|
22
23
|
export interface MentionNodeAttrs {
|
|
23
24
|
type: string;
|
|
@@ -30,6 +31,7 @@ export interface MentionNodeAttrs {
|
|
|
30
31
|
fallbackIcon?: string;
|
|
31
32
|
assetType?: string;
|
|
32
33
|
displayAsPreview?: boolean;
|
|
34
|
+
href?: string;
|
|
33
35
|
}
|
|
34
36
|
/** The `[@Name](url)` form a mention takes in the outgoing text. */
|
|
35
37
|
export declare function serializeMention(attrs: MentionNodeAttrs): string;
|
|
@@ -1,5 +1,8 @@
|
|
|
1
1
|
import { Node, mergeAttributes } from "@tiptap/core";
|
|
2
2
|
function makeMentionUrl(attrs) {
|
|
3
|
+
if (attrs.href && (attrs.href.startsWith("mention://") || ASSET_MENTION_HREF.test(attrs.href))) {
|
|
4
|
+
return attrs.href;
|
|
5
|
+
}
|
|
3
6
|
if (attrs.type === "tool" || attrs.type === "toolkit") {
|
|
4
7
|
return `mention://${attrs.type}?name=${encodeURIComponent(attrs.id)}&description=${encodeURIComponent(attrs.description ?? "")}`;
|
|
5
8
|
}
|
|
@@ -32,6 +35,7 @@ function parseMentionAnchorAttributes({
|
|
|
32
35
|
const url = new URL(href);
|
|
33
36
|
const isWebpage = url.hostname === "webpage";
|
|
34
37
|
return {
|
|
38
|
+
href,
|
|
35
39
|
type: isWebpage ? "tab" : url.hostname || "tool",
|
|
36
40
|
name: (textContent == null ? void 0 : textContent.replace(/^@/, "")) || "",
|
|
37
41
|
id: isWebpage ? url.searchParams.get("tab_id") || "" : url.searchParams.get("name") || url.searchParams.get("id") || "",
|
|
@@ -43,7 +47,7 @@ function parseMentionAnchorAttributes({
|
|
|
43
47
|
assetType: url.searchParams.get("assetType") || ""
|
|
44
48
|
};
|
|
45
49
|
}
|
|
46
|
-
const ASSET_MENTION_HREF =
|
|
50
|
+
const ASSET_MENTION_HREF = /^(?:https?:\/\/[^/]+)?\/dashboard\/spaces\/?\?/;
|
|
47
51
|
function parseAssetAnchorAttributes({
|
|
48
52
|
href,
|
|
49
53
|
textContent
|
|
@@ -54,6 +58,7 @@ function parseAssetAnchorAttributes({
|
|
|
54
58
|
if (!id) return null;
|
|
55
59
|
return {
|
|
56
60
|
type: "asset",
|
|
61
|
+
href,
|
|
57
62
|
name: (textContent == null ? void 0 : textContent.replace(/^@/, "")) || "",
|
|
58
63
|
id,
|
|
59
64
|
assetType: params.get("assetType") || ""
|
|
@@ -68,6 +73,7 @@ const MentionExtension = Node.create({
|
|
|
68
73
|
atom: true,
|
|
69
74
|
addAttributes() {
|
|
70
75
|
return {
|
|
76
|
+
href: { default: null },
|
|
71
77
|
type: { default: "tool" },
|
|
72
78
|
name: { default: "" },
|
|
73
79
|
id: { default: "" },
|
|
@@ -101,6 +107,7 @@ const MentionExtension = Node.create({
|
|
|
101
107
|
var _a;
|
|
102
108
|
const el = dom;
|
|
103
109
|
return {
|
|
110
|
+
href: el.getAttribute("data-href"),
|
|
104
111
|
type: el.getAttribute("data-type") || "tool",
|
|
105
112
|
name: el.getAttribute("data-name") || ((_a = el.textContent) == null ? void 0 : _a.replace(/^@/, "")) || "",
|
|
106
113
|
id: el.getAttribute("data-id") || "",
|
|
@@ -119,14 +126,18 @@ const MentionExtension = Node.create({
|
|
|
119
126
|
priority: ANCHOR_RULE_PRIORITY,
|
|
120
127
|
getAttrs: (dom) => {
|
|
121
128
|
const el = dom;
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
129
|
+
try {
|
|
130
|
+
return parseMentionAnchorAttributes({
|
|
131
|
+
href: el.getAttribute("href") ?? el.href,
|
|
132
|
+
textContent: el.textContent
|
|
133
|
+
});
|
|
134
|
+
} catch {
|
|
135
|
+
return false;
|
|
136
|
+
}
|
|
126
137
|
}
|
|
127
138
|
},
|
|
128
139
|
{
|
|
129
|
-
tag: "a[href
|
|
140
|
+
tag: "a[href]",
|
|
130
141
|
priority: ANCHOR_RULE_PRIORITY,
|
|
131
142
|
getAttrs: (dom) => {
|
|
132
143
|
const el = dom;
|
|
@@ -157,6 +168,7 @@ const MentionExtension = Node.create({
|
|
|
157
168
|
"span",
|
|
158
169
|
mergeAttributes(HTMLAttributes, {
|
|
159
170
|
"data-mention": "",
|
|
171
|
+
"data-href": node.attrs.href || "",
|
|
160
172
|
"data-type": node.attrs.type,
|
|
161
173
|
"data-name": node.attrs.name,
|
|
162
174
|
"data-id": node.attrs.id,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"mention-extension.js","sources":["../../../src/chat-ui/mentions/mention-extension.ts"],"sourcesContent":["/**\n * Tiptap Mention Node Extension\n *\n * Defines the mention node type used in the editor. When a mention is\n * inserted, it creates a non-editable inline node with metadata.\n *\n * Renders as a chip with: [icon] Name. Serializes — to plain text and to\n * Markdown alike — as `[@Name](url)`, and parses that link back into a chip.\n */\n\nimport { mergeAttributes, Node } from \"@tiptap/core\";\nimport type { Node as ProseMirrorNode } from \"@tiptap/pm/model\";\n\nexport function makeMentionUrl(attrs: { id: string; type: string; name: string; title?: string; url?: string; description?: string; thumbnailUrl?: string; assetType?: string }): string {\n if (attrs.type === \"tool\" || attrs.type === \"toolkit\") {\n return `mention://${attrs.type}?name=${encodeURIComponent(attrs.id)}&description=${encodeURIComponent(attrs.description ?? \"\")}`;\n }\n if (attrs.type === \"asset\") {\n const params = new URLSearchParams({ asset_ids: attrs.id });\n if (attrs.assetType) params.set(\"assetType\", attrs.assetType);\n return `/dashboard/spaces?${params.toString()}`;\n }\n if (attrs.type === \"tab\") {\n const params = new URLSearchParams({\n tab_id: attrs.id,\n url: attrs.url ?? \"\",\n title: attrs.title ?? attrs.name,\n });\n return `mention://webpage?${params.toString()}`;\n }\n // Include athenaOriginalType and thumbnailUrl so the chip can be reconstructed\n const params = new URLSearchParams();\n params.set(\"id\", attrs.id);\n if (attrs.assetType) params.set(\"assetType\", attrs.assetType);\n if (attrs.thumbnailUrl) params.set(\"thumb\", attrs.thumbnailUrl);\n return `mention://${encodeURIComponent(attrs.type)}?${params.toString()}`;\n}\n\nexport interface MentionNodeAttrs {\n type: string;\n name: string;\n id: string;\n title?: string;\n url?: string;\n description?: string;\n thumbnailUrl?: string;\n fallbackIcon?: string;\n assetType?: string;\n displayAsPreview?: boolean;\n}\n\n/** The `[@Name](url)` form a mention takes in the outgoing text. */\nexport function serializeMention(attrs: MentionNodeAttrs): string {\n return `[@${attrs.name}](${makeMentionUrl(attrs)})`;\n}\n\nexport function parseMentionAnchorAttributes({\n href,\n textContent,\n}: {\n href: string;\n textContent: string | null;\n}): MentionNodeAttrs {\n const url = new URL(href);\n const isWebpage = url.hostname === \"webpage\";\n return {\n type: isWebpage ? \"tab\" : url.hostname || \"tool\",\n name: textContent?.replace(/^@/, \"\") || \"\",\n id: isWebpage\n ? url.searchParams.get(\"tab_id\") || \"\"\n : url.searchParams.get(\"name\") || url.searchParams.get(\"id\") || \"\",\n title: url.searchParams.get(\"title\") || \"\",\n url: url.searchParams.get(\"url\") || \"\",\n description: url.searchParams.get(\"description\") || \"\",\n thumbnailUrl: url.searchParams.get(\"thumb\") || \"\",\n fallbackIcon: \"\",\n assetType: url.searchParams.get(\"assetType\") || \"\",\n };\n}\n\n/** The asset link `makeMentionUrl` writes (`/dashboard/spaces?asset_ids=…`). */\nconst ASSET_MENTION_HREF = /^\\/dashboard\\/spaces\\?/;\n\n/**\n * Attributes of an asset mention from its `/dashboard/spaces?asset_ids=…`\n * link, or null for a spaces link that names no asset.\n */\nexport function parseAssetAnchorAttributes({\n href,\n textContent,\n}: {\n href: string;\n textContent: string | null;\n}): MentionNodeAttrs | null {\n if (!ASSET_MENTION_HREF.test(href)) return null;\n const params = new URLSearchParams(href.slice(href.indexOf(\"?\") + 1));\n const id = params.get(\"asset_ids\");\n if (!id) return null;\n return {\n type: \"asset\",\n name: textContent?.replace(/^@/, \"\") || \"\",\n id,\n assetType: params.get(\"assetType\") || \"\",\n };\n}\n\ninterface MarkdownSerializerState {\n write(text: string): void;\n}\n\n/**\n * ProseMirror tries parse rules by rule priority (default 50), mark rules\n * before node rules at a tie: a serialized mention is an anchor, so its rules\n * must outrank the Link mark's `a[href]` rule or the chip comes back as a\n * plain link.\n */\nconst ANCHOR_RULE_PRIORITY = 100;\n\nexport const MentionExtension = Node.create({\n name: \"mention\",\n group: \"inline\",\n inline: true,\n selectable: false,\n atom: true,\n\n addAttributes() {\n return {\n type: { default: \"tool\" },\n name: { default: \"\" },\n id: { default: \"\" },\n title: { default: \"\" },\n url: { default: \"\" },\n description: { default: \"\" },\n thumbnailUrl: { default: \"\" },\n fallbackIcon: { default: \"\" },\n assetType: { default: \"\" },\n displayAsPreview: { default: false },\n };\n },\n\n /** tiptap-markdown reads this spec so `getMarkdown()` writes the mention, not HTML. */\n addStorage() {\n return {\n markdown: {\n serialize(state: MarkdownSerializerState, node: ProseMirrorNode) {\n state.write(serializeMention(node.attrs as MentionNodeAttrs));\n },\n parse: {\n // The Markdown parser renders the link to an anchor; parseHTML takes it from there.\n },\n },\n };\n },\n\n parseHTML() {\n return [\n {\n tag: \"span[data-mention]\",\n getAttrs: (dom) => {\n const el = dom as HTMLElement;\n return {\n type: el.getAttribute(\"data-type\") || \"tool\",\n name: el.getAttribute(\"data-name\") || el.textContent?.replace(/^@/, \"\") || \"\",\n id: el.getAttribute(\"data-id\") || \"\",\n title: el.getAttribute(\"data-title\") || \"\",\n url: el.getAttribute(\"data-url\") || \"\",\n description: el.getAttribute(\"data-description\") || \"\",\n thumbnailUrl: el.getAttribute(\"data-thumbnail-url\") || \"\",\n fallbackIcon: el.getAttribute(\"data-fallback-icon\") || \"\",\n assetType: el.getAttribute(\"data-asset-type\") || \"\",\n displayAsPreview:\n el.getAttribute(\"data-display-as-preview\") === \"true\",\n };\n },\n },\n {\n tag: \"a[href^='mention://']\",\n priority: ANCHOR_RULE_PRIORITY,\n getAttrs: (dom) => {\n const el = dom as HTMLAnchorElement;\n return parseMentionAnchorAttributes({\n href: el.getAttribute(\"href\") ?? el.href,\n textContent: el.textContent,\n });\n },\n },\n {\n tag: \"a[href^='/dashboard/spaces?']\",\n priority: ANCHOR_RULE_PRIORITY,\n getAttrs: (dom) => {\n const el = dom as HTMLAnchorElement;\n return (\n parseAssetAnchorAttributes({\n href: el.getAttribute(\"href\") ?? \"\",\n textContent: el.textContent,\n }) ?? false\n );\n },\n },\n ];\n },\n\n renderHTML({ node, HTMLAttributes }) {\n const thumbnailUrl = node.attrs.thumbnailUrl;\n\n // Build child elements: [icon] name\n const children: any[] = [];\n\n if (thumbnailUrl) {\n // Render SVG thumbnail as an img element inside the chip\n children.push([\n \"img\",\n {\n src: thumbnailUrl,\n alt: \"\",\n class: \"mention-chip-icon\",\n draggable: \"false\",\n },\n ]);\n }\n\n children.push([\"span\", { class: \"mention-chip-text\" }, node.attrs.name]);\n\n return [\n \"span\",\n mergeAttributes(HTMLAttributes, {\n \"data-mention\": \"\",\n \"data-type\": node.attrs.type,\n \"data-name\": node.attrs.name,\n \"data-id\": node.attrs.id,\n \"data-title\": node.attrs.title || \"\",\n \"data-url\": node.attrs.url || \"\",\n \"data-thumbnail-url\": node.attrs.thumbnailUrl || \"\",\n \"data-asset-type\": node.attrs.assetType || \"\",\n \"data-display-as-preview\": String(node.attrs.displayAsPreview === true),\n class: \"mention-chip\",\n }),\n ...children,\n ];\n },\n\n renderText({ node }) {\n return serializeMention(node.attrs as MentionNodeAttrs);\n },\n});\n"],"names":["params"],"mappings":";AAaO,SAAS,eAAe,OAA0J;AACvL,MAAI,MAAM,SAAS,UAAU,MAAM,SAAS,WAAW;AACrD,WAAO,aAAa,MAAM,IAAI,SAAS,mBAAmB,MAAM,EAAE,CAAC,gBAAgB,mBAAmB,MAAM,eAAe,EAAE,CAAC;AAAA,EAChI;AACA,MAAI,MAAM,SAAS,SAAS;AAC1B,UAAMA,UAAS,IAAI,gBAAgB,EAAE,WAAW,MAAM,IAAI;AAC1D,QAAI,MAAM,UAAWA,SAAO,IAAI,aAAa,MAAM,SAAS;AAC5D,WAAO,qBAAqBA,QAAO,SAAA,CAAU;AAAA,EAC/C;AACA,MAAI,MAAM,SAAS,OAAO;AACxB,UAAMA,UAAS,IAAI,gBAAgB;AAAA,MACjC,QAAQ,MAAM;AAAA,MACd,KAAK,MAAM,OAAO;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,IAAI,CAAC;AAEvE,WAAO;AAAA,MACL;AAAA,MACA,gBAAgB,gBAAgB;AAAA,QAC9B,gBAAgB;AAAA,QAChB,aAAa,KAAK,MAAM;AAAA,QACxB,aAAa,KAAK,MAAM;AAAA,QACxB,WAAW,KAAK,MAAM;AAAA,QACtB,cAAc,KAAK,MAAM,SAAS;AAAA,QAClC,YAAY,KAAK,MAAM,OAAO;AAAA,QAC9B,sBAAsB,KAAK,MAAM,gBAAgB;AAAA,QACjD,mBAAmB,KAAK,MAAM,aAAa;AAAA,QAC3C,2BAA2B,OAAO,KAAK,MAAM,qBAAqB,IAAI;AAAA,QACtE,OAAO;AAAA,MAAA,CACR;AAAA,MACD,GAAG;AAAA,IAAA;AAAA,EAEP;AAAA,EAEA,WAAW,EAAE,QAAQ;AACnB,WAAO,iBAAiB,KAAK,KAAyB;AAAA,EACxD;AACF,CAAC;"}
|
|
1
|
+
{"version":3,"file":"mention-extension.js","sources":["../../../src/chat-ui/mentions/mention-extension.ts"],"sourcesContent":["/**\n * Tiptap Mention Node Extension\n *\n * Defines the mention node type used in the editor. When a mention is\n * inserted, it creates a non-editable inline node with metadata.\n *\n * Renders as a chip with: [icon] Name. Serializes — to plain text and to\n * Markdown alike — as `[@Name](url)`, and parses that link back into a chip.\n */\n\nimport { mergeAttributes, Node } from \"@tiptap/core\";\nimport type { Node as ProseMirrorNode } from \"@tiptap/pm/model\";\n\nexport function makeMentionUrl(attrs: { id: string; type: string; name: string; title?: string; url?: string; description?: string; thumbnailUrl?: string; assetType?: string; href?: string }): string {\n if (attrs.href && (attrs.href.startsWith(\"mention://\") || ASSET_MENTION_HREF.test(attrs.href))) {\n return attrs.href;\n }\n if (attrs.type === \"tool\" || attrs.type === \"toolkit\") {\n return `mention://${attrs.type}?name=${encodeURIComponent(attrs.id)}&description=${encodeURIComponent(attrs.description ?? \"\")}`;\n }\n if (attrs.type === \"asset\") {\n const params = new URLSearchParams({ asset_ids: attrs.id });\n if (attrs.assetType) params.set(\"assetType\", attrs.assetType);\n return `/dashboard/spaces?${params.toString()}`;\n }\n if (attrs.type === \"tab\") {\n const params = new URLSearchParams({\n tab_id: attrs.id,\n url: attrs.url ?? \"\",\n title: attrs.title ?? attrs.name,\n });\n return `mention://webpage?${params.toString()}`;\n }\n // Include athenaOriginalType and thumbnailUrl so the chip can be reconstructed\n const params = new URLSearchParams();\n params.set(\"id\", attrs.id);\n if (attrs.assetType) params.set(\"assetType\", attrs.assetType);\n if (attrs.thumbnailUrl) params.set(\"thumb\", attrs.thumbnailUrl);\n return `mention://${encodeURIComponent(attrs.type)}?${params.toString()}`;\n}\n\nexport interface MentionNodeAttrs {\n type: string;\n name: string;\n id: string;\n title?: string;\n url?: string;\n description?: string;\n thumbnailUrl?: string;\n fallbackIcon?: string;\n assetType?: string;\n displayAsPreview?: boolean;\n href?: string;\n}\n\n/** The `[@Name](url)` form a mention takes in the outgoing text. */\nexport function serializeMention(attrs: MentionNodeAttrs): string {\n return `[@${attrs.name}](${makeMentionUrl(attrs)})`;\n}\n\nexport function parseMentionAnchorAttributes({\n href,\n textContent,\n}: {\n href: string;\n textContent: string | null;\n}): MentionNodeAttrs {\n const url = new URL(href);\n const isWebpage = url.hostname === \"webpage\";\n return {\n href,\n type: isWebpage ? \"tab\" : url.hostname || \"tool\",\n name: textContent?.replace(/^@/, \"\") || \"\",\n id: isWebpage\n ? url.searchParams.get(\"tab_id\") || \"\"\n : url.searchParams.get(\"name\") || url.searchParams.get(\"id\") || \"\",\n title: url.searchParams.get(\"title\") || \"\",\n url: url.searchParams.get(\"url\") || \"\",\n description: url.searchParams.get(\"description\") || \"\",\n thumbnailUrl: url.searchParams.get(\"thumb\") || \"\",\n fallbackIcon: \"\",\n assetType: url.searchParams.get(\"assetType\") || \"\",\n };\n}\n\n/** The asset link `makeMentionUrl` writes (`/dashboard/spaces?asset_ids=…`). */\nconst ASSET_MENTION_HREF = /^(?:https?:\\/\\/[^/]+)?\\/dashboard\\/spaces\\/?\\?/;\n\n/**\n * Attributes of an asset mention from its `/dashboard/spaces?asset_ids=…`\n * link, or null for a spaces link that names no asset.\n */\nexport function parseAssetAnchorAttributes({\n href,\n textContent,\n}: {\n href: string;\n textContent: string | null;\n}): MentionNodeAttrs | null {\n if (!ASSET_MENTION_HREF.test(href)) return null;\n const params = new URLSearchParams(href.slice(href.indexOf(\"?\") + 1));\n const id = params.get(\"asset_ids\");\n if (!id) return null;\n return {\n type: \"asset\",\n href,\n name: textContent?.replace(/^@/, \"\") || \"\",\n id,\n assetType: params.get(\"assetType\") || \"\",\n };\n}\n\ninterface MarkdownSerializerState {\n write(text: string): void;\n}\n\n/**\n * ProseMirror tries parse rules by rule priority (default 50), mark rules\n * before node rules at a tie: a serialized mention is an anchor, so its rules\n * must outrank the Link mark's `a[href]` rule or the chip comes back as a\n * plain link.\n */\nconst ANCHOR_RULE_PRIORITY = 100;\n\nexport const MentionExtension = Node.create({\n name: \"mention\",\n group: \"inline\",\n inline: true,\n selectable: false,\n atom: true,\n\n addAttributes() {\n return {\n href: { default: null },\n type: { default: \"tool\" },\n name: { default: \"\" },\n id: { default: \"\" },\n title: { default: \"\" },\n url: { default: \"\" },\n description: { default: \"\" },\n thumbnailUrl: { default: \"\" },\n fallbackIcon: { default: \"\" },\n assetType: { default: \"\" },\n displayAsPreview: { default: false },\n };\n },\n\n /** tiptap-markdown reads this spec so `getMarkdown()` writes the mention, not HTML. */\n addStorage() {\n return {\n markdown: {\n serialize(state: MarkdownSerializerState, node: ProseMirrorNode) {\n state.write(serializeMention(node.attrs as MentionNodeAttrs));\n },\n parse: {\n // The Markdown parser renders the link to an anchor; parseHTML takes it from there.\n },\n },\n };\n },\n\n parseHTML() {\n return [\n {\n tag: \"span[data-mention]\",\n getAttrs: (dom) => {\n const el = dom as HTMLElement;\n return {\n href: el.getAttribute(\"data-href\"),\n type: el.getAttribute(\"data-type\") || \"tool\",\n name: el.getAttribute(\"data-name\") || el.textContent?.replace(/^@/, \"\") || \"\",\n id: el.getAttribute(\"data-id\") || \"\",\n title: el.getAttribute(\"data-title\") || \"\",\n url: el.getAttribute(\"data-url\") || \"\",\n description: el.getAttribute(\"data-description\") || \"\",\n thumbnailUrl: el.getAttribute(\"data-thumbnail-url\") || \"\",\n fallbackIcon: el.getAttribute(\"data-fallback-icon\") || \"\",\n assetType: el.getAttribute(\"data-asset-type\") || \"\",\n displayAsPreview:\n el.getAttribute(\"data-display-as-preview\") === \"true\",\n };\n },\n },\n {\n tag: \"a[href^='mention://']\",\n priority: ANCHOR_RULE_PRIORITY,\n getAttrs: (dom) => {\n const el = dom as HTMLAnchorElement;\n try {\n return parseMentionAnchorAttributes({\n href: el.getAttribute(\"href\") ?? el.href,\n textContent: el.textContent,\n });\n } catch {\n return false;\n }\n },\n },\n {\n tag: \"a[href]\",\n priority: ANCHOR_RULE_PRIORITY,\n getAttrs: (dom) => {\n const el = dom as HTMLAnchorElement;\n return (\n parseAssetAnchorAttributes({\n href: el.getAttribute(\"href\") ?? \"\",\n textContent: el.textContent,\n }) ?? false\n );\n },\n },\n ];\n },\n\n renderHTML({ node, HTMLAttributes }) {\n const thumbnailUrl = node.attrs.thumbnailUrl;\n\n // Build child elements: [icon] name\n const children: any[] = [];\n\n if (thumbnailUrl) {\n // Render SVG thumbnail as an img element inside the chip\n children.push([\n \"img\",\n {\n src: thumbnailUrl,\n alt: \"\",\n class: \"mention-chip-icon\",\n draggable: \"false\",\n },\n ]);\n }\n\n children.push([\"span\", { class: \"mention-chip-text\" }, node.attrs.name]);\n\n return [\n \"span\",\n mergeAttributes(HTMLAttributes, {\n \"data-mention\": \"\",\n \"data-href\": node.attrs.href || \"\",\n \"data-type\": node.attrs.type,\n \"data-name\": node.attrs.name,\n \"data-id\": node.attrs.id,\n \"data-title\": node.attrs.title || \"\",\n \"data-url\": node.attrs.url || \"\",\n \"data-thumbnail-url\": node.attrs.thumbnailUrl || \"\",\n \"data-asset-type\": node.attrs.assetType || \"\",\n \"data-display-as-preview\": String(node.attrs.displayAsPreview === true),\n class: \"mention-chip\",\n }),\n ...children,\n ];\n },\n\n renderText({ node }) {\n return serializeMention(node.attrs as MentionNodeAttrs);\n },\n});\n"],"names":["params"],"mappings":";AAaO,SAAS,eAAe,OAAyK;AACtM,MAAI,MAAM,SAAS,MAAM,KAAK,WAAW,YAAY,KAAK,mBAAmB,KAAK,MAAM,IAAI,IAAI;AAC9F,WAAO,MAAM;AAAA,EACf;AACA,MAAI,MAAM,SAAS,UAAU,MAAM,SAAS,WAAW;AACrD,WAAO,aAAa,MAAM,IAAI,SAAS,mBAAmB,MAAM,EAAE,CAAC,gBAAgB,mBAAmB,MAAM,eAAe,EAAE,CAAC;AAAA,EAChI;AACA,MAAI,MAAM,SAAS,SAAS;AAC1B,UAAMA,UAAS,IAAI,gBAAgB,EAAE,WAAW,MAAM,IAAI;AAC1D,QAAI,MAAM,UAAWA,SAAO,IAAI,aAAa,MAAM,SAAS;AAC5D,WAAO,qBAAqBA,QAAO,SAAA,CAAU;AAAA,EAC/C;AACA,MAAI,MAAM,SAAS,OAAO;AACxB,UAAMA,UAAS,IAAI,gBAAgB;AAAA,MACjC,QAAQ,MAAM;AAAA,MACd,KAAK,MAAM,OAAO;AAAA,MAClB,OAAO,MAAM,SAAS,MAAM;AAAA,IAAA,CAC7B;AACD,WAAO,qBAAqBA,QAAO,SAAA,CAAU;AAAA,EAC/C;AAEA,QAAM,SAAS,IAAI,gBAAA;AACnB,SAAO,IAAI,MAAM,MAAM,EAAE;AACzB,MAAI,MAAM,UAAW,QAAO,IAAI,aAAa,MAAM,SAAS;AAC5D,MAAI,MAAM,aAAc,QAAO,IAAI,SAAS,MAAM,YAAY;AAC9D,SAAO,aAAa,mBAAmB,MAAM,IAAI,CAAC,IAAI,OAAO,UAAU;AACzE;AAiBO,SAAS,iBAAiB,OAAiC;AAChE,SAAO,KAAK,MAAM,IAAI,KAAK,eAAe,KAAK,CAAC;AAClD;AAEO,SAAS,6BAA6B;AAAA,EAC3C;AAAA,EACA;AACF,GAGqB;AACnB,QAA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Aa;AAAA,QAC3C,2BAA2B,OAAO,KAAK,MAAM,qBAAqB,IAAI;AAAA,QACtE,OAAO;AAAA,MAAA,CACR;AAAA,MACD,GAAG;AAAA,IAAA;AAAA,EAEP;AAAA,EAEA,WAAW,EAAE,QAAQ;AACnB,WAAO,iBAAiB,KAAK,KAAyB;AAAA,EACxD;AACF,CAAC;"}
|
|
@@ -94,7 +94,7 @@ const MentionSuggestionList = react.forwardRef(({ store, editor, query, command,
|
|
|
94
94
|
isLoading: isFetching,
|
|
95
95
|
hasMore,
|
|
96
96
|
onSelect: handleSelect,
|
|
97
|
-
|
|
97
|
+
onMouseMove: (idx) => {
|
|
98
98
|
setSelectedIndexOverride(idx);
|
|
99
99
|
},
|
|
100
100
|
onLoadMore: loadMore
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"mention-suggestion-list.cjs","sources":["../../../../../src/chat-ui/mentions/suggestions/components/mention-suggestion-list.tsx"],"sourcesContent":["/**\n * MentionSuggestionList — Main mention menu component.\n *\n * Composed of:\n * - Registry + cache backed data (async fetching)\n * - useMenuNavigation for scope stack management\n * - useKeyboardNavigation for keyboard handling\n * - MenuList for item rendering with loading states\n * - MenuSummary for breadcrumbs + back\n */\n\nimport { useStore } from \"@tanstack/react-store\";\nimport type { Editor } from \"@tiptap/core\";\nimport { forwardRef, useCallback, useEffect, useState } from \"react\";\nimport type { MenuItem } from \"../data/types\";\nimport type { MentionSuggestionsStore } from \"../data/use-mention-suggestions\";\nimport { useMenuItems } from \"../data/use-menu-items\";\nimport { getSearchScope } from \"../data/scope-registry\";\nimport { getScopeName } from \"./get-scope-name\";\nimport { MenuList } from \"./menu-list\";\nimport { MenuSummary } from \"./menu-summary\";\nimport { useKeyboardNavigation, type KeyboardNavigationHandle } from \"./use-keyboard-navigation\";\nimport {\n getCurrentScope,\n getSelectedIndex,\n useMenuNavigation,\n} from \"./use-menu-navigation\";\nimport { clearTextAfterTrigger } from \"./utils\";\n\nexport interface MentionSuggestionListProps {\n store: MentionSuggestionsStore;\n editor: Editor;\n query: string;\n command: (item: MenuItem) => void;\n closeMenu: (dismissedByUser?: boolean) => void;\n}\n\nexport const MentionSuggestionList = forwardRef<\n KeyboardNavigationHandle,\n MentionSuggestionListProps\n>(({ store, editor, query, command, closeMenu }, ref) => {\n const [selectedIndexOverride, setSelectedIndexOverride] = useState<number | null>(null);\n const navStore = useMenuNavigation();\n\n // Get current scope from navigation\n const currentScopeId = useStore(navStore, (s) => getCurrentScope(s));\n const navSelectedIndex = useStore(navStore, (s) => getSelectedIndex(s));\n const selectedIndex = selectedIndexOverride ?? navSelectedIndex;\n const scopeStack = useStore(navStore, (s) => s.scopeStack);\n\n let effectiveScopeId = currentScopeId;\n\n if (query) {\n try {\n const searchScope = getSearchScope(store.state.registry, currentScopeId);\n if (searchScope) {\n effectiveScopeId = searchScope;\n }\n } catch {\n // No search scope binding — use current\n }\n }\n\n // Get items from the data store (reactive, with async fetching)\n const { items, isFetching, hasMore, loadMore } = useMenuItems(store, {\n scope: effectiveScopeId,\n query,\n minItems: 50,\n parentScope: currentScopeId !== effectiveScopeId ? currentScopeId : undefined,\n });\n\n // Reset selection on query or scope change\n useEffect(() => {\n setSelectedIndexOverride(null);\n }, [query, effectiveScopeId]);\n\n // Build scope path for breadcrumbs from the navigation stack\n const scopePath = scopeStack.map((entry) => ({\n id: entry.scope,\n name: entry.breadcrumbLabel ?? getScopeName(entry.scope, store),\n }));\n\n // Handle item selection\n const handleSelect = useCallback(\n (item: MenuItem) => {\n if (item.navigatesToScope) {\n navStore.navigateTo(item.navigatesToScope, selectedIndex, {\n breadcrumbLabel: item.name,\n parentScope: currentScopeId,\n });\n clearTextAfterTrigger(editor);\n setSelectedIndexOverride(null);\n return;\n }\n // Insert mention\n command(item);\n },\n [command, editor, navStore, selectedIndex, currentScopeId],\n );\n\n // Handle back navigation\n const handleBack = useCallback(() => {\n navStore.navigateBack();\n clearTextAfterTrigger(editor);\n setSelectedIndexOverride(null);\n }, [editor, navStore]);\n\n // Handle breadcrumb navigation\n const handleBreadcrumbNavigate = useCallback(\n (targetScopeId: string) => {\n // Navigate to specific scope in the stack\n const targetIdx = scopeStack.findIndex((entry) => entry.scope === targetScopeId);\n\n if (targetIdx >= 0) {\n // Pop stack down to the target\n const popsNeeded = scopeStack.length - 1 - targetIdx;\n for (let i = 0; i < popsNeeded; i++) {\n navStore.navigateBack();\n }\n clearTextAfterTrigger(editor);\n setSelectedIndexOverride(null);\n }\n },\n [editor, navStore, scopeStack],\n );\n\n // Keyboard navigation\n useKeyboardNavigation(ref, {\n items,\n selectedIndex,\n onSelect: handleSelect,\n onBack: currentScopeId !== \"root\" ? handleBack : undefined,\n onClose: () => closeMenu(true),\n setSelectedIndex: (idx: number) => {\n setSelectedIndexOverride(idx);\n },\n });\n\n return (\n <div className=\"bg-white border border-gray-300 rounded shadow-lg min-w-[280px] max-w-[380px] max-h-[320px] flex flex-col\">\n {/* Scrollable items */}\n <div className=\"flex-1 overflow-y-auto\">\n <MenuList\n items={items}\n selectedIndex={selectedIndex}\n isLoading={isFetching}\n hasMore={hasMore}\n onSelect={handleSelect}\n
|
|
1
|
+
{"version":3,"file":"mention-suggestion-list.cjs","sources":["../../../../../src/chat-ui/mentions/suggestions/components/mention-suggestion-list.tsx"],"sourcesContent":["/**\n * MentionSuggestionList — Main mention menu component.\n *\n * Composed of:\n * - Registry + cache backed data (async fetching)\n * - useMenuNavigation for scope stack management\n * - useKeyboardNavigation for keyboard handling\n * - MenuList for item rendering with loading states\n * - MenuSummary for breadcrumbs + back\n */\n\nimport { useStore } from \"@tanstack/react-store\";\nimport type { Editor } from \"@tiptap/core\";\nimport { forwardRef, useCallback, useEffect, useState } from \"react\";\nimport type { MenuItem } from \"../data/types\";\nimport type { MentionSuggestionsStore } from \"../data/use-mention-suggestions\";\nimport { useMenuItems } from \"../data/use-menu-items\";\nimport { getSearchScope } from \"../data/scope-registry\";\nimport { getScopeName } from \"./get-scope-name\";\nimport { MenuList } from \"./menu-list\";\nimport { MenuSummary } from \"./menu-summary\";\nimport { useKeyboardNavigation, type KeyboardNavigationHandle } from \"./use-keyboard-navigation\";\nimport {\n getCurrentScope,\n getSelectedIndex,\n useMenuNavigation,\n} from \"./use-menu-navigation\";\nimport { clearTextAfterTrigger } from \"./utils\";\n\nexport interface MentionSuggestionListProps {\n store: MentionSuggestionsStore;\n editor: Editor;\n query: string;\n command: (item: MenuItem) => void;\n closeMenu: (dismissedByUser?: boolean) => void;\n}\n\nexport const MentionSuggestionList = forwardRef<\n KeyboardNavigationHandle,\n MentionSuggestionListProps\n>(({ store, editor, query, command, closeMenu }, ref) => {\n const [selectedIndexOverride, setSelectedIndexOverride] = useState<number | null>(null);\n const navStore = useMenuNavigation();\n\n // Get current scope from navigation\n const currentScopeId = useStore(navStore, (s) => getCurrentScope(s));\n const navSelectedIndex = useStore(navStore, (s) => getSelectedIndex(s));\n const selectedIndex = selectedIndexOverride ?? navSelectedIndex;\n const scopeStack = useStore(navStore, (s) => s.scopeStack);\n\n let effectiveScopeId = currentScopeId;\n\n if (query) {\n try {\n const searchScope = getSearchScope(store.state.registry, currentScopeId);\n if (searchScope) {\n effectiveScopeId = searchScope;\n }\n } catch {\n // No search scope binding — use current\n }\n }\n\n // Get items from the data store (reactive, with async fetching)\n const { items, isFetching, hasMore, loadMore } = useMenuItems(store, {\n scope: effectiveScopeId,\n query,\n minItems: 50,\n parentScope: currentScopeId !== effectiveScopeId ? currentScopeId : undefined,\n });\n\n // Reset selection on query or scope change\n useEffect(() => {\n setSelectedIndexOverride(null);\n }, [query, effectiveScopeId]);\n\n // Build scope path for breadcrumbs from the navigation stack\n const scopePath = scopeStack.map((entry) => ({\n id: entry.scope,\n name: entry.breadcrumbLabel ?? getScopeName(entry.scope, store),\n }));\n\n // Handle item selection\n const handleSelect = useCallback(\n (item: MenuItem) => {\n if (item.navigatesToScope) {\n navStore.navigateTo(item.navigatesToScope, selectedIndex, {\n breadcrumbLabel: item.name,\n parentScope: currentScopeId,\n });\n clearTextAfterTrigger(editor);\n setSelectedIndexOverride(null);\n return;\n }\n // Insert mention\n command(item);\n },\n [command, editor, navStore, selectedIndex, currentScopeId],\n );\n\n // Handle back navigation\n const handleBack = useCallback(() => {\n navStore.navigateBack();\n clearTextAfterTrigger(editor);\n setSelectedIndexOverride(null);\n }, [editor, navStore]);\n\n // Handle breadcrumb navigation\n const handleBreadcrumbNavigate = useCallback(\n (targetScopeId: string) => {\n // Navigate to specific scope in the stack\n const targetIdx = scopeStack.findIndex((entry) => entry.scope === targetScopeId);\n\n if (targetIdx >= 0) {\n // Pop stack down to the target\n const popsNeeded = scopeStack.length - 1 - targetIdx;\n for (let i = 0; i < popsNeeded; i++) {\n navStore.navigateBack();\n }\n clearTextAfterTrigger(editor);\n setSelectedIndexOverride(null);\n }\n },\n [editor, navStore, scopeStack],\n );\n\n // Keyboard navigation\n useKeyboardNavigation(ref, {\n items,\n selectedIndex,\n onSelect: handleSelect,\n onBack: currentScopeId !== \"root\" ? handleBack : undefined,\n onClose: () => closeMenu(true),\n setSelectedIndex: (idx: number) => {\n setSelectedIndexOverride(idx);\n },\n });\n\n return (\n <div className=\"bg-white border border-gray-300 rounded shadow-lg min-w-[280px] max-w-[380px] max-h-[320px] flex flex-col\">\n {/* Scrollable items */}\n <div className=\"flex-1 overflow-y-auto\">\n <MenuList\n items={items}\n selectedIndex={selectedIndex}\n isLoading={isFetching}\n hasMore={hasMore}\n onSelect={handleSelect}\n onMouseMove={(idx) => {\n setSelectedIndexOverride(idx);\n }}\n onLoadMore={loadMore}\n />\n </div>\n\n {/* Bottom summary with breadcrumbs + back */}\n <MenuSummary\n scopePath={scopePath}\n onNavigate={handleBreadcrumbNavigate}\n onBackClick={currentScopeId !== \"root\" ? handleBack : undefined}\n isFetching={isFetching}\n />\n </div>\n );\n});\n\nMentionSuggestionList.displayName = \"MentionSuggestionList\";\n"],"names":["forwardRef","useState","useMenuNavigation","useStore","getCurrentScope","getSelectedIndex","getSearchScope","useMenuItems","useEffect","getScopeName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AAAA,QACV,aAAa,CAAC,QAAQ;AACpB,mCAAyB,GAAG;AAAA,QAC9B;AAAA,QACA,YAAY;AAAA,MAAA;AAAA,IAAA,GAEhB;AAAA,IAGAD,2BAAAA;AAAAA,MAACE,YAAAA;AAAAA,MAAA;AAAA,QACC;AAAA,QACA,YAAY;AAAA,QACZ,aAAa,mBAAmB,SAAS,aAAa;AAAA,QACtD;AAAA,MAAA;AAAA,IAAA;AAAA,EACF,GACF;AAEJ,CAAC;AAED,sBAAsB,cAAc;;"}
|
|
@@ -92,7 +92,7 @@ const MentionSuggestionList = forwardRef(({ store, editor, query, command, close
|
|
|
92
92
|
isLoading: isFetching,
|
|
93
93
|
hasMore,
|
|
94
94
|
onSelect: handleSelect,
|
|
95
|
-
|
|
95
|
+
onMouseMove: (idx) => {
|
|
96
96
|
setSelectedIndexOverride(idx);
|
|
97
97
|
},
|
|
98
98
|
onLoadMore: loadMore
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"mention-suggestion-list.js","sources":["../../../../../src/chat-ui/mentions/suggestions/components/mention-suggestion-list.tsx"],"sourcesContent":["/**\n * MentionSuggestionList — Main mention menu component.\n *\n * Composed of:\n * - Registry + cache backed data (async fetching)\n * - useMenuNavigation for scope stack management\n * - useKeyboardNavigation for keyboard handling\n * - MenuList for item rendering with loading states\n * - MenuSummary for breadcrumbs + back\n */\n\nimport { useStore } from \"@tanstack/react-store\";\nimport type { Editor } from \"@tiptap/core\";\nimport { forwardRef, useCallback, useEffect, useState } from \"react\";\nimport type { MenuItem } from \"../data/types\";\nimport type { MentionSuggestionsStore } from \"../data/use-mention-suggestions\";\nimport { useMenuItems } from \"../data/use-menu-items\";\nimport { getSearchScope } from \"../data/scope-registry\";\nimport { getScopeName } from \"./get-scope-name\";\nimport { MenuList } from \"./menu-list\";\nimport { MenuSummary } from \"./menu-summary\";\nimport { useKeyboardNavigation, type KeyboardNavigationHandle } from \"./use-keyboard-navigation\";\nimport {\n getCurrentScope,\n getSelectedIndex,\n useMenuNavigation,\n} from \"./use-menu-navigation\";\nimport { clearTextAfterTrigger } from \"./utils\";\n\nexport interface MentionSuggestionListProps {\n store: MentionSuggestionsStore;\n editor: Editor;\n query: string;\n command: (item: MenuItem) => void;\n closeMenu: (dismissedByUser?: boolean) => void;\n}\n\nexport const MentionSuggestionList = forwardRef<\n KeyboardNavigationHandle,\n MentionSuggestionListProps\n>(({ store, editor, query, command, closeMenu }, ref) => {\n const [selectedIndexOverride, setSelectedIndexOverride] = useState<number | null>(null);\n const navStore = useMenuNavigation();\n\n // Get current scope from navigation\n const currentScopeId = useStore(navStore, (s) => getCurrentScope(s));\n const navSelectedIndex = useStore(navStore, (s) => getSelectedIndex(s));\n const selectedIndex = selectedIndexOverride ?? navSelectedIndex;\n const scopeStack = useStore(navStore, (s) => s.scopeStack);\n\n let effectiveScopeId = currentScopeId;\n\n if (query) {\n try {\n const searchScope = getSearchScope(store.state.registry, currentScopeId);\n if (searchScope) {\n effectiveScopeId = searchScope;\n }\n } catch {\n // No search scope binding — use current\n }\n }\n\n // Get items from the data store (reactive, with async fetching)\n const { items, isFetching, hasMore, loadMore } = useMenuItems(store, {\n scope: effectiveScopeId,\n query,\n minItems: 50,\n parentScope: currentScopeId !== effectiveScopeId ? currentScopeId : undefined,\n });\n\n // Reset selection on query or scope change\n useEffect(() => {\n setSelectedIndexOverride(null);\n }, [query, effectiveScopeId]);\n\n // Build scope path for breadcrumbs from the navigation stack\n const scopePath = scopeStack.map((entry) => ({\n id: entry.scope,\n name: entry.breadcrumbLabel ?? getScopeName(entry.scope, store),\n }));\n\n // Handle item selection\n const handleSelect = useCallback(\n (item: MenuItem) => {\n if (item.navigatesToScope) {\n navStore.navigateTo(item.navigatesToScope, selectedIndex, {\n breadcrumbLabel: item.name,\n parentScope: currentScopeId,\n });\n clearTextAfterTrigger(editor);\n setSelectedIndexOverride(null);\n return;\n }\n // Insert mention\n command(item);\n },\n [command, editor, navStore, selectedIndex, currentScopeId],\n );\n\n // Handle back navigation\n const handleBack = useCallback(() => {\n navStore.navigateBack();\n clearTextAfterTrigger(editor);\n setSelectedIndexOverride(null);\n }, [editor, navStore]);\n\n // Handle breadcrumb navigation\n const handleBreadcrumbNavigate = useCallback(\n (targetScopeId: string) => {\n // Navigate to specific scope in the stack\n const targetIdx = scopeStack.findIndex((entry) => entry.scope === targetScopeId);\n\n if (targetIdx >= 0) {\n // Pop stack down to the target\n const popsNeeded = scopeStack.length - 1 - targetIdx;\n for (let i = 0; i < popsNeeded; i++) {\n navStore.navigateBack();\n }\n clearTextAfterTrigger(editor);\n setSelectedIndexOverride(null);\n }\n },\n [editor, navStore, scopeStack],\n );\n\n // Keyboard navigation\n useKeyboardNavigation(ref, {\n items,\n selectedIndex,\n onSelect: handleSelect,\n onBack: currentScopeId !== \"root\" ? handleBack : undefined,\n onClose: () => closeMenu(true),\n setSelectedIndex: (idx: number) => {\n setSelectedIndexOverride(idx);\n },\n });\n\n return (\n <div className=\"bg-white border border-gray-300 rounded shadow-lg min-w-[280px] max-w-[380px] max-h-[320px] flex flex-col\">\n {/* Scrollable items */}\n <div className=\"flex-1 overflow-y-auto\">\n <MenuList\n items={items}\n selectedIndex={selectedIndex}\n isLoading={isFetching}\n hasMore={hasMore}\n onSelect={handleSelect}\n
|
|
1
|
+
{"version":3,"file":"mention-suggestion-list.js","sources":["../../../../../src/chat-ui/mentions/suggestions/components/mention-suggestion-list.tsx"],"sourcesContent":["/**\n * MentionSuggestionList — Main mention menu component.\n *\n * Composed of:\n * - Registry + cache backed data (async fetching)\n * - useMenuNavigation for scope stack management\n * - useKeyboardNavigation for keyboard handling\n * - MenuList for item rendering with loading states\n * - MenuSummary for breadcrumbs + back\n */\n\nimport { useStore } from \"@tanstack/react-store\";\nimport type { Editor } from \"@tiptap/core\";\nimport { forwardRef, useCallback, useEffect, useState } from \"react\";\nimport type { MenuItem } from \"../data/types\";\nimport type { MentionSuggestionsStore } from \"../data/use-mention-suggestions\";\nimport { useMenuItems } from \"../data/use-menu-items\";\nimport { getSearchScope } from \"../data/scope-registry\";\nimport { getScopeName } from \"./get-scope-name\";\nimport { MenuList } from \"./menu-list\";\nimport { MenuSummary } from \"./menu-summary\";\nimport { useKeyboardNavigation, type KeyboardNavigationHandle } from \"./use-keyboard-navigation\";\nimport {\n getCurrentScope,\n getSelectedIndex,\n useMenuNavigation,\n} from \"./use-menu-navigation\";\nimport { clearTextAfterTrigger } from \"./utils\";\n\nexport interface MentionSuggestionListProps {\n store: MentionSuggestionsStore;\n editor: Editor;\n query: string;\n command: (item: MenuItem) => void;\n closeMenu: (dismissedByUser?: boolean) => void;\n}\n\nexport const MentionSuggestionList = forwardRef<\n KeyboardNavigationHandle,\n MentionSuggestionListProps\n>(({ store, editor, query, command, closeMenu }, ref) => {\n const [selectedIndexOverride, setSelectedIndexOverride] = useState<number | null>(null);\n const navStore = useMenuNavigation();\n\n // Get current scope from navigation\n const currentScopeId = useStore(navStore, (s) => getCurrentScope(s));\n const navSelectedIndex = useStore(navStore, (s) => getSelectedIndex(s));\n const selectedIndex = selectedIndexOverride ?? navSelectedIndex;\n const scopeStack = useStore(navStore, (s) => s.scopeStack);\n\n let effectiveScopeId = currentScopeId;\n\n if (query) {\n try {\n const searchScope = getSearchScope(store.state.registry, currentScopeId);\n if (searchScope) {\n effectiveScopeId = searchScope;\n }\n } catch {\n // No search scope binding — use current\n }\n }\n\n // Get items from the data store (reactive, with async fetching)\n const { items, isFetching, hasMore, loadMore } = useMenuItems(store, {\n scope: effectiveScopeId,\n query,\n minItems: 50,\n parentScope: currentScopeId !== effectiveScopeId ? currentScopeId : undefined,\n });\n\n // Reset selection on query or scope change\n useEffect(() => {\n setSelectedIndexOverride(null);\n }, [query, effectiveScopeId]);\n\n // Build scope path for breadcrumbs from the navigation stack\n const scopePath = scopeStack.map((entry) => ({\n id: entry.scope,\n name: entry.breadcrumbLabel ?? getScopeName(entry.scope, store),\n }));\n\n // Handle item selection\n const handleSelect = useCallback(\n (item: MenuItem) => {\n if (item.navigatesToScope) {\n navStore.navigateTo(item.navigatesToScope, selectedIndex, {\n breadcrumbLabel: item.name,\n parentScope: currentScopeId,\n });\n clearTextAfterTrigger(editor);\n setSelectedIndexOverride(null);\n return;\n }\n // Insert mention\n command(item);\n },\n [command, editor, navStore, selectedIndex, currentScopeId],\n );\n\n // Handle back navigation\n const handleBack = useCallback(() => {\n navStore.navigateBack();\n clearTextAfterTrigger(editor);\n setSelectedIndexOverride(null);\n }, [editor, navStore]);\n\n // Handle breadcrumb navigation\n const handleBreadcrumbNavigate = useCallback(\n (targetScopeId: string) => {\n // Navigate to specific scope in the stack\n const targetIdx = scopeStack.findIndex((entry) => entry.scope === targetScopeId);\n\n if (targetIdx >= 0) {\n // Pop stack down to the target\n const popsNeeded = scopeStack.length - 1 - targetIdx;\n for (let i = 0; i < popsNeeded; i++) {\n navStore.navigateBack();\n }\n clearTextAfterTrigger(editor);\n setSelectedIndexOverride(null);\n }\n },\n [editor, navStore, scopeStack],\n );\n\n // Keyboard navigation\n useKeyboardNavigation(ref, {\n items,\n selectedIndex,\n onSelect: handleSelect,\n onBack: currentScopeId !== \"root\" ? handleBack : undefined,\n onClose: () => closeMenu(true),\n setSelectedIndex: (idx: number) => {\n setSelectedIndexOverride(idx);\n },\n });\n\n return (\n <div className=\"bg-white border border-gray-300 rounded shadow-lg min-w-[280px] max-w-[380px] max-h-[320px] flex flex-col\">\n {/* Scrollable items */}\n <div className=\"flex-1 overflow-y-auto\">\n <MenuList\n items={items}\n selectedIndex={selectedIndex}\n isLoading={isFetching}\n hasMore={hasMore}\n onSelect={handleSelect}\n onMouseMove={(idx) => {\n setSelectedIndexOverride(idx);\n }}\n onLoadMore={loadMore}\n />\n </div>\n\n {/* Bottom summary with breadcrumbs + back */}\n <MenuSummary\n scopePath={scopePath}\n onNavigate={handleBreadcrumbNavigate}\n onBackClick={currentScopeId !== \"root\" ? handleBack : undefined}\n isFetching={isFetching}\n />\n </div>\n );\n});\n\nMentionSuggestionList.displayName = \"MentionSugg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