@flamingo-stack/openframe-frontend-core 0.0.816 → 0.0.818

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.
Files changed (203) hide show
  1. package/dist/build/export-map.json +1 -1
  2. package/dist/{case-study-card-NLT2JVI7.cjs → case-study-card-IZBMHA6R.cjs} +3 -3
  3. package/dist/{chunk-VDXI26G7.cjs → chunk-4XASD2TL.cjs} +81 -78
  4. package/dist/{chunk-5TUR7O7H.cjs → chunk-5AIOYEXW.cjs} +90 -90
  5. package/dist/{chunk-RYJJHSHV.cjs → chunk-5VRSUEC5.cjs} +23 -23
  6. package/dist/{chunk-633NTKO2.cjs → chunk-6QT5K5I5.cjs} +31 -53
  7. package/dist/{chunk-CNTBGJA7.cjs → chunk-A34UNP5V.cjs} +65 -1
  8. package/dist/{chunk-3ELDGEM2.cjs → chunk-AE22KOW3.cjs} +87 -84
  9. package/dist/{chunk-EJCUAADF.cjs → chunk-BD42NMCT.cjs} +4 -4
  10. package/dist/{chunk-7NYWHEQM.cjs → chunk-DGAX5WG2.cjs} +15 -15
  11. package/dist/{chunk-L7W4455K.cjs → chunk-DL4HWYIB.cjs} +3 -3
  12. package/dist/chunk-DVHSYPDB.cjs +471 -0
  13. package/dist/{chunk-GAR2IIU6.cjs → chunk-IM366HS6.cjs} +105 -157
  14. package/dist/{chunk-7ERD34HQ.cjs → chunk-IQCHV7Z2.cjs} +571 -823
  15. package/dist/{chunk-3E4FIJAM.cjs → chunk-JTBJB4JF.cjs} +15 -15
  16. package/dist/{chunk-PAI4A3UM.cjs → chunk-K5IICQNF.cjs} +61 -54
  17. package/dist/{chunk-JOKOQOLJ.cjs → chunk-LUID2IB3.cjs} +2 -2
  18. package/dist/{chunk-JOOZTRXQ.cjs → chunk-NEXMK6OP.cjs} +4 -4
  19. package/dist/{chunk-4PMD3JUC.cjs → chunk-NPNZAAOB.cjs} +2 -2
  20. package/dist/{chunk-JH65CEO4.cjs → chunk-NWIEZUM7.cjs} +36 -36
  21. package/dist/{chunk-HM7VCQSX.cjs → chunk-SBFBNOKU.cjs} +4 -4
  22. package/dist/{chunk-7O7EX7HQ.cjs → chunk-T266OITJ.cjs} +28 -20
  23. package/dist/{chunk-SWBLTIN4.cjs → chunk-U2THWP25.cjs} +54 -52
  24. package/dist/{chunk-F4ZJRMMM.cjs → chunk-UDLDXVY4.cjs} +8 -8
  25. package/dist/{chunk-Y6MJMPHV.cjs → chunk-UEULXVW2.cjs} +32 -84
  26. package/dist/{chunk-O6VWD2SB.cjs → chunk-VGZXB3SY.cjs} +3 -3
  27. package/dist/{chunk-ZAWHRYJZ.cjs → chunk-VRXDTRIY.cjs} +45 -45
  28. package/dist/{chunk-EB7YAUER.cjs → chunk-YHPUD4PM.cjs} +19 -19
  29. package/dist/{chunk-FUEK43FL.cjs → chunk-YMPPE322.cjs} +206 -200
  30. package/dist/{chunk-IKB6AZPV.cjs → chunk-ZECG6GU5.cjs} +2 -2
  31. package/dist/{chunk-53JJLHJM.cjs → chunk-ZWAVMZIF.cjs} +20 -20
  32. package/dist/{cloud-tenants-SRTX2FZC.cjs → cloud-tenants-V6EV4OGK.cjs} +11 -11
  33. package/dist/components/announcement-bar.d.ts.map +1 -1
  34. package/dist/components/announcement-bar.js +5 -5
  35. package/dist/components/case-studies/index.cjs +26 -26
  36. package/dist/components/chat/chat-markdown-link.d.ts +15 -0
  37. package/dist/components/chat/chat-markdown-link.d.ts.map +1 -0
  38. package/dist/components/chat/chat-markdown-link.js +22 -0
  39. package/dist/components/chat/chat-message-enhanced.d.ts.map +1 -1
  40. package/dist/components/chat/chat-message-enhanced.js +3 -9
  41. package/dist/components/chat/embeddable-chat.d.ts +4 -8
  42. package/dist/components/chat/embeddable-chat.d.ts.map +1 -1
  43. package/dist/components/chat/embeddable-chat.js +31 -125
  44. package/dist/components/chat/entity-cards/chat-card-disclosure.d.ts.map +1 -1
  45. package/dist/components/chat/entity-cards/chat-card-disclosure.js +8 -11
  46. package/dist/components/chat/entity-cards/dispatch.d.ts +8 -15
  47. package/dist/components/chat/entity-cards/dispatch.d.ts.map +1 -1
  48. package/dist/components/chat/entity-cards/dispatch.js +22 -40
  49. package/dist/components/chat/entity-cards/github-activity-card.d.ts +1 -1
  50. package/dist/components/chat/entity-cards/use-entity-card-link.d.ts +3 -2
  51. package/dist/components/chat/entity-cards/use-entity-card-link.d.ts.map +1 -1
  52. package/dist/components/chat/entity-cards/use-entity-card-link.js +6 -4
  53. package/dist/components/chat/index.cjs +28 -21
  54. package/dist/components/chat/index.d.ts +2 -2
  55. package/dist/components/chat/index.d.ts.map +1 -1
  56. package/dist/components/chat/index.js +4 -3
  57. package/dist/components/chat/{inline-app-link-chip.d.ts → inline-chip.d.ts} +1 -14
  58. package/dist/components/chat/inline-chip.d.ts.map +1 -0
  59. package/dist/components/chat/inline-chip.js +27 -0
  60. package/dist/components/chat/nav-link-anchor-via-runtime.d.ts +45 -11
  61. package/dist/components/chat/nav-link-anchor-via-runtime.d.ts.map +1 -1
  62. package/dist/components/chat/nav-link-anchor-via-runtime.js +32 -24
  63. package/dist/components/chat/source-action-button.d.ts +12 -3
  64. package/dist/components/chat/source-action-button.d.ts.map +1 -1
  65. package/dist/components/chat/source-action-button.js +41 -26
  66. package/dist/components/chat/types/component.types.d.ts +1 -1
  67. package/dist/components/chat/types/entities/data-room-doc.d.ts +0 -12
  68. package/dist/components/chat/types/entities/data-room-doc.d.ts.map +1 -1
  69. package/dist/components/chat/types/message.types.d.ts +1 -1
  70. package/dist/components/chat/types/message.types.d.ts.map +1 -1
  71. package/dist/components/chat/utils/chat-nav-resolution.d.ts +1 -6
  72. package/dist/components/chat/utils/chat-nav-resolution.d.ts.map +1 -1
  73. package/dist/components/chat/utils/chat-nav-resolution.js +2 -3
  74. package/dist/components/chat/utils/decide-new-tab.d.ts +0 -3
  75. package/dist/components/chat/utils/decide-new-tab.d.ts.map +1 -1
  76. package/dist/components/chat/utils/decide-new-tab.js +0 -1
  77. package/dist/components/chat/utils/execute-navigation.d.ts +36 -34
  78. package/dist/components/chat/utils/execute-navigation.d.ts.map +1 -1
  79. package/dist/components/chat/utils/execute-navigation.js +23 -19
  80. package/dist/components/chat/utils/index.d.ts +5 -5
  81. package/dist/components/chat/utils/index.d.ts.map +1 -1
  82. package/dist/components/chat/utils/index.js +14 -6
  83. package/dist/components/chat/utils/nav-anchor-props.d.ts +35 -8
  84. package/dist/components/chat/utils/nav-anchor-props.d.ts.map +1 -1
  85. package/dist/components/chat/utils/nav-anchor-props.js +14 -5
  86. package/dist/components/chat/utils/new-tab-rel.d.ts +15 -0
  87. package/dist/components/chat/utils/new-tab-rel.d.ts.map +1 -0
  88. package/dist/components/chat/utils/new-tab-rel.js +25 -0
  89. package/dist/components/chat/utils/source-row-cta.d.ts +9 -48
  90. package/dist/components/chat/utils/source-row-cta.d.ts.map +1 -1
  91. package/dist/components/chat/utils/source-row-cta.js +7 -32
  92. package/dist/components/contact/index.cjs +12 -12
  93. package/dist/components/docs/index.cjs +15 -15
  94. package/dist/components/embeds/index.cjs +12 -12
  95. package/dist/components/faq/index.cjs +13 -13
  96. package/dist/components/features/devices/devices-table-columns.d.ts.map +1 -1
  97. package/dist/components/features/devices/devices-table-columns.js +4 -1
  98. package/dist/components/features/index.cjs +11 -11
  99. package/dist/components/help-center-pages/index.cjs +105 -105
  100. package/dist/components/index.cjs +91 -83
  101. package/dist/components/meeting-scheduler/index.cjs +50 -50
  102. package/dist/components/navigation/app-header.d.ts +1 -4
  103. package/dist/components/navigation/app-header.d.ts.map +1 -1
  104. package/dist/components/navigation/app-header.js +0 -2
  105. package/dist/components/navigation/index.cjs +14 -14
  106. package/dist/components/navigation/ticket-alerts-button.d.ts +1 -4
  107. package/dist/components/navigation/ticket-alerts-button.d.ts.map +1 -1
  108. package/dist/components/navigation/ticket-alerts-button.js +5 -5
  109. package/dist/components/onboarding-guides/index.cjs +14 -14
  110. package/dist/components/product-demo/index.cjs +20 -20
  111. package/dist/components/related-content/card-registry.d.ts +1 -1
  112. package/dist/components/related-content/index.cjs +7 -7
  113. package/dist/components/related-content/related-content-section.d.ts +3 -3
  114. package/dist/components/related-content/related-content-section.d.ts.map +1 -1
  115. package/dist/components/related-content/related-content-section.js +5 -3
  116. package/dist/components/shared/doc-search/resolve-search-result-action.d.ts +10 -3
  117. package/dist/components/shared/doc-search/resolve-search-result-action.d.ts.map +1 -1
  118. package/dist/components/shared/doc-search/resolve-search-result-action.js +8 -17
  119. package/dist/components/shared/doc-search/use-doc-search.d.ts.map +1 -1
  120. package/dist/components/shared/doc-search/use-doc-search.js +15 -27
  121. package/dist/components/shared/product-release/product-release-card.d.ts +2 -2
  122. package/dist/components/shared/product-release/product-releases-view.d.ts.map +1 -1
  123. package/dist/components/shared/product-release/product-releases-view.js +1 -3
  124. package/dist/components/tickets/index.cjs +18 -18
  125. package/dist/components/tickets/ticket-detail-drawer.d.ts.map +1 -1
  126. package/dist/components/tickets/ticket-detail-drawer.js +6 -3
  127. package/dist/components/tickets/types.d.ts +1 -1
  128. package/dist/components/ui/button/button.d.ts +1 -1
  129. package/dist/components/ui/hover-dropdown.d.ts +2 -2
  130. package/dist/components/ui/index.cjs +31 -23
  131. package/dist/components/ui/service-card.d.ts.map +1 -1
  132. package/dist/components/ui/service-card.js +4 -1
  133. package/dist/components/vendor-display-button.d.ts.map +1 -1
  134. package/dist/components/vendor-display-button.js +4 -1
  135. package/dist/contexts/chat-runtime-context.d.ts +14 -25
  136. package/dist/contexts/chat-runtime-context.d.ts.map +1 -1
  137. package/dist/{devices-DL4YU64N.cjs → devices-6KZAJAAS.cjs} +12 -12
  138. package/dist/{embeddable-chat-YRKMPFDY.cjs → embeddable-chat-5IHA5SUZ.cjs} +95 -193
  139. package/dist/hooks/index.cjs +5 -5
  140. package/dist/hooks/use-contact-submission.d.ts.map +1 -1
  141. package/dist/hooks/use-contact-submission.js +11 -8
  142. package/dist/index.cjs +40 -34
  143. package/dist/{knowledge-VQW5JL2Z.cjs → knowledge-I7FDQQYJ.cjs} +12 -12
  144. package/dist/{logs-IY3WBLMW.cjs → logs-Q7PAVJUG.cjs} +19 -19
  145. package/dist/{policies-IXWTWMJO.cjs → policies-C3DW5CHS.cjs} +15 -15
  146. package/dist/{scripts-D5CLO5EG.cjs → scripts-BET663HD.cjs} +16 -16
  147. package/dist/{software-update-ULNP6CKJ.cjs → software-update-W7ZQXEPK.cjs} +14 -14
  148. package/dist/utils/index.cjs +116 -89
  149. package/dist/utils/open-in-new-tab.d.ts +2 -1
  150. package/dist/utils/open-in-new-tab.d.ts.map +1 -1
  151. package/dist/utils/open-in-new-tab.js +2 -1
  152. package/dist/utils/scroll-into-view.d.ts +1 -1
  153. package/dist/utils/source-grouping.d.ts +2 -2
  154. package/eslint-config/base.js +11 -0
  155. package/eslint-config/navigation.js +142 -0
  156. package/package.json +1 -1
  157. package/src/components/announcement-bar.tsx +8 -6
  158. package/src/components/chat/chat-markdown-link.tsx +42 -0
  159. package/src/components/chat/chat-message-enhanced.tsx +10 -36
  160. package/src/components/chat/embeddable-chat.tsx +66 -173
  161. package/src/components/chat/entity-cards/chat-card-disclosure.tsx +9 -13
  162. package/src/components/chat/entity-cards/data-room-doc-card.tsx +1 -1
  163. package/src/components/chat/entity-cards/dispatch.tsx +51 -66
  164. package/src/components/chat/entity-cards/github-activity-card.tsx +1 -1
  165. package/src/components/chat/entity-cards/use-entity-card-link.ts +11 -16
  166. package/src/components/chat/index.ts +3 -1
  167. package/src/components/chat/{inline-app-link-chip.tsx → inline-chip.tsx} +1 -27
  168. package/src/components/chat/nav-link-anchor-via-runtime.tsx +73 -33
  169. package/src/components/chat/source-action-button.tsx +57 -33
  170. package/src/components/chat/types/component.types.ts +1 -1
  171. package/src/components/chat/types/entities/data-room-doc.ts +0 -12
  172. package/src/components/chat/types/message.types.ts +1 -1
  173. package/src/components/chat/utils/chat-nav-resolution.ts +3 -8
  174. package/src/components/chat/utils/decide-new-tab.ts +0 -3
  175. package/src/components/chat/utils/execute-navigation.ts +58 -58
  176. package/src/components/chat/utils/index.ts +13 -6
  177. package/src/components/chat/utils/nav-anchor-props.ts +56 -9
  178. package/src/components/chat/utils/new-tab-rel.ts +39 -0
  179. package/src/components/chat/utils/source-row-cta.ts +21 -102
  180. package/src/components/features/devices/devices-table-columns.tsx +4 -1
  181. package/src/components/navigation/app-header.tsx +0 -5
  182. package/src/components/navigation/ticket-alerts-button.tsx +7 -8
  183. package/src/components/related-content/card-registry.tsx +1 -1
  184. package/src/components/related-content/related-content-section.tsx +10 -10
  185. package/src/components/shared/doc-search/resolve-search-result-action.ts +19 -33
  186. package/src/components/shared/doc-search/use-doc-search.ts +21 -44
  187. package/src/components/shared/product-release/product-release-card.tsx +4 -4
  188. package/src/components/shared/product-release/product-releases-view.tsx +2 -5
  189. package/src/components/tickets/ticket-detail-drawer.tsx +7 -4
  190. package/src/components/tickets/types.ts +1 -1
  191. package/src/components/ui/button/button.tsx +2 -2
  192. package/src/components/ui/hover-dropdown.tsx +2 -2
  193. package/src/components/ui/service-card.tsx +4 -1
  194. package/src/components/vendor-display-button.tsx +5 -2
  195. package/src/contexts/chat-runtime-context.tsx +18 -23
  196. package/src/hooks/use-contact-submission.ts +13 -8
  197. package/src/utils/index.ts +1 -1
  198. package/src/utils/open-in-new-tab.ts +4 -2
  199. package/src/utils/scroll-into-view.ts +1 -1
  200. package/src/utils/source-grouping.ts +2 -2
  201. package/dist/chunk-RD66AGUI.cjs +0 -156
  202. package/dist/components/chat/inline-app-link-chip.d.ts.map +0 -1
  203. package/dist/components/chat/inline-app-link-chip.js +0 -37
@@ -5,9 +5,9 @@
5
5
  *
6
6
  * Lib-portable refactor of the hub's `components/shared/entity-card-dispatch.tsx`.
7
7
  * Drops the hub-only imports:
8
- * - `useNavLink` → click routing flows through `<NavLinkAnchorViaRuntime>`
8
+ * - `useNavLinkViaRuntime` → click routing flows through `<NavLinkAnchorViaRuntime>`
9
9
  * (reads `useRequiredChatRuntime` internally) or
10
- * the chat-runtime's `handleChatNavClick` helper.
10
+ * the chat-runtime's `executeNavigation` helper.
11
11
  * - `currentPlatform` → runtime.source supplies the identifier.
12
12
  * - `buildContentURL` → URLs arrive pre-composed by the server's
13
13
  * RAG mapper (`ref.url`); the card just renders.
@@ -33,7 +33,6 @@ import type React from 'react';
33
33
  import type { ReactNode } from 'react';
34
34
  import { useRequiredChatRuntime } from '../../../contexts/chat-runtime-context';
35
35
  import Image from '../../../embed-shims/next-image';
36
- import { useRouter } from '../../../embed-shims/next-navigation';
37
36
  import { IMAGE_FIXED_PX } from '../../../styles/image-sizes';
38
37
  import type { DesignDoc } from '../../../types/design-doc';
39
38
  import {
@@ -100,10 +99,10 @@ import { formatInvestorUpdatePeriod } from '../types/entities/investor-update';
100
99
  import type { BaseProgramItem, ProgramConfig } from '../types/entities/program-types';
101
100
  import { getStatusColorScheme } from '../utils/agent-status-message';
102
101
  import { resolveCardDestination } from '../utils/card-destination';
103
- import { resolveHrefForRuntime } from '../utils/chat-nav-resolution';
104
102
  import { executeNavigation } from '../utils/execute-navigation';
105
103
  import { clickupTaskUrl } from '../utils/external-app-urls';
106
- import { computeIsNewTab, buildAnchorProps } from '../utils/nav-anchor-props';
104
+ import { buildAnchorProps, navLinkTarget } from '../utils/nav-anchor-props';
105
+ import { isRelativeHref } from '../utils/new-tab-rel';
107
106
  import { readFetchedCardTitle } from '../utils/resolve-fetched-card-href';
108
107
  import { resolveSourceIcon, sourceRowCtxFromRuntime } from '../utils/source-row-cta';
109
108
  import { BlockCard } from './block-card';
@@ -242,8 +241,6 @@ export interface ChatCardDispatchExtras {
242
241
 
243
242
  /** Per-card render options threaded through from the chat shell. */
244
243
  export interface ChatCardRenderOptions {
245
- baseRoute?: string;
246
- chipBasePlatform?: string;
247
244
  /** Host-supplied builders for cards whose derived props live in hub
248
245
  * land (programs + product_release). When omitted, these card types
249
246
  * render `null` and the shell falls back to title text. */
@@ -251,7 +248,7 @@ export interface ChatCardRenderOptions {
251
248
  /** Pre-computed new-tab decision for the inner anchor's `target`
252
249
  * attribute. Required — always computed by `ChatCardLoader` via the
253
250
  * same rule source chips use, so the rendered `<a target>` matches
254
- * whatever `ChatCardNavWrap` + `handleChatNavClick` decide at click
251
+ * whatever `ChatCardNavWrap` + `executeNavigation` decide at click
255
252
  * time. */
256
253
  isNewTab: boolean;
257
254
  /** Host-provided "Ask Mingo"/"Display" affordance for this card, resolved
@@ -264,9 +261,9 @@ export interface ChatCardRenderOptions {
264
261
  // =============================================================================
265
262
  // Per-type "no-fetch" wrapper components (ChatRef carries everything).
266
263
  // Each wrapper receives `isNewTab` as a prop — `ChatCardLoader` computes
267
- // it ONCE via `computeIsNewTab` against the resolved `chatRef.url` and
268
- // threads it through `renderOpts`. Wrappers must NOT call
269
- // `computeIsNewTab` themselves; the parent's decision is the single
264
+ // it ONCE via `navLinkTarget` against the resolved `chatRef.url` and
265
+ // threads it through `renderOpts`. Wrappers must NOT decide
266
+ // themselves; the parent's decision is the single
270
267
  // source of truth for the rendered `<a target>` AND `ChatCardNavWrap`'s
271
268
  // close-on-nav gate.
272
269
  // =============================================================================
@@ -333,7 +330,7 @@ function GitHubChatCard({
333
330
  description={description}
334
331
  icon={githubKindIcon(kind)}
335
332
  status={status}
336
- anchorProps={buildAnchorProps(chatRef.url, isNewTab)}
333
+ anchorProps={buildAnchorProps(chatRef.url, isNewTab, chatRef.targetPlatform)}
337
334
  menuGroups={cardMenuGroups(chatRef.url, discuss)}
338
335
  menuAriaLabel="Activity actions"
339
336
  />
@@ -539,7 +536,7 @@ function HubspotTicketChatCard({
539
536
  description={chatRef.preview ?? undefined}
540
537
  icon={<TagIcon size={24} />}
541
538
  status={statusText ? { label: statusText, variant: hubspotStatusToVariant(status) } : undefined}
542
- anchorProps={buildAnchorProps(chatRef.url, isNewTab)}
539
+ anchorProps={buildAnchorProps(chatRef.url, isNewTab, chatRef.targetPlatform)}
543
540
  menuGroups={cardMenuGroups(chatRef.url, discuss, {
544
541
  label: 'Open Ticket Details',
545
542
  icon: <TagIcon size={20} />,
@@ -572,7 +569,7 @@ function FaqChatCard({
572
569
  description={chatRef.preview ?? undefined}
573
570
  icon={<QuestionCircleIcon size={24} />}
574
571
  status={{ label: statusLabel, variant: 'grey' }}
575
- anchorProps={buildAnchorProps(chatRef.url, isNewTab)}
572
+ anchorProps={buildAnchorProps(chatRef.url, isNewTab, chatRef.targetPlatform)}
576
573
  menuGroups={cardMenuGroups(chatRef.url, discuss)}
577
574
  menuAriaLabel="FAQ actions"
578
575
  />
@@ -599,7 +596,7 @@ function SlackChatCard({
599
596
  title={title}
600
597
  description={chatRef.preview ?? undefined}
601
598
  icon={<SlackLogoGreyIcon size={24} />}
602
- anchorProps={buildAnchorProps(chatRef.url, isNewTab)}
599
+ anchorProps={buildAnchorProps(chatRef.url, isNewTab, chatRef.targetPlatform)}
603
600
  menuGroups={cardMenuGroups(chatRef.url, discuss)}
604
601
  menuAriaLabel="Message actions"
605
602
  />
@@ -627,7 +624,7 @@ function GlyphChatCard({
627
624
  title={chatRef.title}
628
625
  description={chatRef.preview ?? undefined}
629
626
  icon={icon}
630
- anchorProps={buildAnchorProps(chatRef.url, isNewTab)}
627
+ anchorProps={buildAnchorProps(chatRef.url, isNewTab, chatRef.targetPlatform)}
631
628
  menuGroups={cardMenuGroups(chatRef.url, discuss)}
632
629
  menuAriaLabel="Card actions"
633
630
  />
@@ -672,7 +669,7 @@ function TrustCenterChatCard({
672
669
  description={summary || TRUST_CENTER_TAGLINE}
673
670
  icon={<ShieldCheckIcon size={24} />}
674
671
  status={lead ? { label: lead.label, variant: TRUST_STATUS_TAG_VARIANT[lead.color] } : undefined}
675
- anchorProps={buildAnchorProps(chatRef.url, isNewTab)}
672
+ anchorProps={buildAnchorProps(chatRef.url, isNewTab, chatRef.targetPlatform)}
676
673
  menuGroups={cardMenuGroups(chatRef.url, discuss, {
677
674
  label: 'View trust center',
678
675
  icon: <ShieldCheckIcon size={20} />,
@@ -703,7 +700,7 @@ function DataRoomDocChatCard({
703
700
  description={chatRef.preview ?? undefined}
704
701
  icon={<FileContentIcon size={24} />}
705
702
  status={{ label: badgeText, variant: 'grey' }}
706
- anchorProps={buildAnchorProps(chatRef.url, isNewTab)}
703
+ anchorProps={buildAnchorProps(chatRef.url, isNewTab, chatRef.targetPlatform)}
707
704
  menuGroups={cardMenuGroups(chatRef.url, discuss)}
708
705
  menuAriaLabel="Document actions"
709
706
  />
@@ -727,7 +724,7 @@ function GenericFinancialChatCard({
727
724
  title={chatRef.title}
728
725
  description={subtitle}
729
726
  icon={icon}
730
- anchorProps={buildAnchorProps(chatRef.url, isNewTab)}
727
+ anchorProps={buildAnchorProps(chatRef.url, isNewTab, chatRef.targetPlatform)}
731
728
  menuGroups={cardMenuGroups(chatRef.url, discuss)}
732
729
  menuAriaLabel="Document actions"
733
730
  />
@@ -920,7 +917,7 @@ function EntityMingoCard({
920
917
  imageAlt={typeof title === 'string' ? title : undefined}
921
918
  icon={fallbackIcon}
922
919
  status={status}
923
- anchorProps={buildAnchorProps(chatRef.url, isNewTab)}
920
+ anchorProps={buildAnchorProps(chatRef.url, isNewTab, chatRef.targetPlatform)}
924
921
  menuGroups={cardMenuGroups(chatRef.url, discuss, openDetails, externalLink)}
925
922
  menuAriaLabel={menuAriaLabel}
926
923
  />
@@ -1081,7 +1078,7 @@ function DesignDocChatCard({
1081
1078
  ? { label: readiness.label, variant: readiness.scheme === 'success' ? 'success' : 'grey' }
1082
1079
  : { label: 'Design doc', variant: 'grey' }
1083
1080
  }
1084
- anchorProps={buildAnchorProps(displayRef.url, isNewTab)}
1081
+ anchorProps={buildAnchorProps(displayRef.url, isNewTab, displayRef.targetPlatform)}
1085
1082
  menuGroups={cardMenuGroups(displayRef.url, discuss)}
1086
1083
  menuAriaLabel="Design doc actions"
1087
1084
  />
@@ -1324,7 +1321,7 @@ interface ChatCardRegistryEntry {
1324
1321
  * for ChatRef-shaped items). Result is validated via `safeHref`
1325
1322
  * before being attached to the resolved ref — so the wrapper sees a
1326
1323
  * non-null `href`, the pre-computed `isNewTab` reflects the actual
1327
- * destination, and the click goes through `handleChatNavClick` (no
1324
+ * destination, and the click goes through `executeNavigation` (no
1328
1325
  * silent bypass of embed-mode / close-on-nav). Takes precedence over
1329
1326
  * the `composeContentUrl` fallback below — but NOT over an explicit
1330
1327
  * host `override` for the type (see `pickFetchedCardHref`). */
@@ -1905,20 +1902,20 @@ export function chatCardLabel(docType: string): string | undefined {
1905
1902
  // card body provides its own `<a href={absolute}>` (per the
1906
1903
  // pure-presentation contract) — this wrapper intercepts the primary
1907
1904
  // click via `onClickCapture` BEFORE the browser's default navigation
1908
- // fires, and routes through `handleChatNavClick` to apply runtime nav
1905
+ // fires, and routes through `executeNavigation` to apply runtime nav
1909
1906
  // rules (embed-mode `window.open` / cross-platform new-tab / host
1910
1907
  // `runtime.navigation.navigate`). Modifier / non-primary clicks pass
1911
- // through (`handleChatNavClick` returns early so the browser opens
1908
+ // through (`executeNavigation` returns early so the browser opens
1912
1909
  // the inner anchor's href naturally).
1913
1910
  //
1914
- // Same click model as source chips — chips use `<a onClick={handleChatNavClick}>`
1915
- // directly; cards use `<span onClickCapture={→handleChatNavClick}>` outside
1916
- // the card's own anchor. Both ultimately call `handleChatNavClick` with
1911
+ // Same click model as source chips — chips use `<a onClick={executeNavigation}>`
1912
+ // directly; cards use `<span onClickCapture={→executeNavigation}>` outside
1913
+ // the card's own anchor. Both ultimately call `executeNavigation` with
1917
1914
  // the same `{href, targetPlatform}` resolved at `ChatCardLoader` via
1918
1915
  // `resolveSourceRowCTA`. The unification:
1919
1916
  // - Same URL composition (`resolveSourceRowCTA`)
1920
- // - Same embed-mode prefix (`resolveHrefForRuntime`)
1921
- // - Same click router (`handleChatNavClick`)
1917
+ // - Same navigation decision (`navLinkTarget`)
1918
+ // - Same click router (`executeNavigation`)
1922
1919
  // - Same conditional close (`ChatPanelContext.closeChat` on same-tab only)
1923
1920
  // =============================================================================
1924
1921
 
@@ -1930,7 +1927,7 @@ export function chatCardLabel(docType: string): string | undefined {
1930
1927
  * new-tab decision applied (via `opts.isNewTab` from ChatCardLoader).
1931
1928
  *
1932
1929
  * Job:
1933
- * - PRIMARY clicks → preventDefault + route through `handleChatNavClick`
1930
+ * - PRIMARY clicks → preventDefault + route through `executeNavigation`
1934
1931
  * - Modifier-clicks → pass through to the browser's native handling
1935
1932
  * - Same-tab nav → close the chat panel (so the panel doesn't linger
1936
1933
  * over the now-current-page content). New-tab nav leaves it open.
@@ -1945,13 +1942,14 @@ function ChatCardNavWrap({
1945
1942
  path,
1946
1943
  targetPlatform,
1947
1944
  isNewTab,
1945
+ hostRoute,
1948
1946
  children,
1949
1947
  }: {
1950
1948
  href: string | null;
1951
1949
  /** In-app doc-tree path for `markdown` / `data_room_doc` refs. The
1952
1950
  * runtime's `navigate({path})` opportunistically swaps the active
1953
1951
  * documentation section without a full page nav; null for everything
1954
- * else. Threaded straight through to `handleChatNavClick` so chips
1952
+ * else. Threaded straight through to `executeNavigation` so chips
1955
1953
  * and inline cards apply the same routing rule. */
1956
1954
  path: string | null;
1957
1955
  targetPlatform: string | null;
@@ -1959,10 +1957,12 @@ function ChatCardNavWrap({
1959
1957
  * same value the card's `<a target>` already renders with.
1960
1958
  * Consumed here ONLY to decide whether to close the panel. */
1961
1959
  isNewTab: boolean;
1960
+ /** `href` is the host's own relative route (see `navLinkTarget`), handed to the executor so the click decides as
1961
+ * the render did. */
1962
+ hostRoute: boolean;
1962
1963
  children: ReactNode;
1963
1964
  }) {
1964
1965
  const runtime = useRequiredChatRuntime();
1965
- const router = useRouter();
1966
1966
  const panel = useChatPanel();
1967
1967
  const onClickCapture = (e: React.MouseEvent<HTMLElement>) => {
1968
1968
  if (!href) return;
@@ -1987,7 +1987,7 @@ function ChatCardNavWrap({
1987
1987
  if (targetEl?.closest?.('button')) return;
1988
1988
  if (!targetEl?.closest?.('a')) return;
1989
1989
 
1990
- const handled = executeNavigation({ event: e, runtime, href, path, targetPlatform, fallbackNavigate: router.push });
1990
+ const handled = executeNavigation({ event: e, runtime, href, path, targetPlatform, hostRoute });
1991
1991
  if (!handled) return;
1992
1992
  // Modifier-clicks fall through (handled=false) without stopPropagation
1993
1993
  // so ancestor telemetry handlers still see the bubble.
@@ -2009,8 +2009,6 @@ interface ChatCardLoaderProps {
2009
2009
  chatRef: ChatRef;
2010
2010
  onDiscuss?: (ref: ChatRef) => void;
2011
2011
  onDisplay?: (ref: ChatRef) => void;
2012
- baseRoute?: string;
2013
- chipBasePlatform?: string;
2014
2012
  extras?: ChatCardDispatchExtras;
2015
2013
  }
2016
2014
 
@@ -2047,27 +2045,19 @@ function CardWithDisclosure({
2047
2045
  * SINGLE URL-RESOLUTION POINT — same code path source chips already
2048
2046
  * had. Before render dispatch:
2049
2047
  * - Pass the ref through `resolveSourceRowCTA` to compute the
2050
- * canonical `{href, targetPlatform}` (externalUrl → in-app path
2051
- * fallback → null, with embedder `baseRoute` / `chipBasePlatform`
2052
- * awareness).
2048
+ * canonical `{href, targetPlatform}` through the host's composer
2049
+ * (`composeContentUrl`), the one address rule.
2053
2050
  * - Pre-resolve href against `runtime.navigation.defaultContentOrigin`
2054
2051
  * in embed mode (so modifier-click + copy-link land on the hub).
2055
2052
  * - Re-attach the resolved values onto the ref so EVERY downstream
2056
2053
  * card — whether it renders an inner `<a>` from `href` prop
2057
2054
  * (BlogCard, ProgramCard, …) or pulls `anchorProps` from
2058
- * `computeIsNewTab` — sees the SAME canonical URL the
2055
+ * `navLinkTarget` — sees the SAME canonical URL the
2059
2056
  * chip would render.
2060
2057
  *
2061
2058
  * Eliminates the entire "chip works, inline card doesn't" class of bug.
2062
2059
  */
2063
- export function ChatCardLoader({
2064
- chatRef,
2065
- onDiscuss,
2066
- onDisplay,
2067
- baseRoute,
2068
- chipBasePlatform,
2069
- extras,
2070
- }: ChatCardLoaderProps) {
2060
+ export function ChatCardLoader({ chatRef, onDiscuss, onDisplay, extras }: ChatCardLoaderProps) {
2071
2061
  const runtime = useRequiredChatRuntime();
2072
2062
  const entry = CHAT_CARD_REGISTRY[chatRef.type];
2073
2063
  // Hook order MUST be stable across renders — call the data hook
@@ -2090,9 +2080,9 @@ export function ChatCardLoader({
2090
2080
  chatRef,
2091
2081
  item: fetchEntry ? item : undefined,
2092
2082
  entry: fetchEntry,
2093
- ctx: sourceRowCtxFromRuntime(runtime, { baseRoute, chipBasePlatform }),
2083
+ ctx: sourceRowCtxFromRuntime(runtime),
2094
2084
  composeContentUrl: runtime.composeContentUrl,
2095
- resolveHref: href => resolveHrefForRuntime(href, runtime),
2085
+ resolveHref: href => navLinkTarget(runtime, href).href,
2096
2086
  });
2097
2087
  const hrefResolvedChatRef: ChatRef = {
2098
2088
  ...chatRef,
@@ -2117,8 +2107,15 @@ export function ChatCardLoader({
2117
2107
  // Pre-compute new-tab decision ONCE here (the same rule chips use).
2118
2108
  // Render branches that pass `target` / `rel` to their card pull this
2119
2109
  // via `renderOpts.isNewTab` so the inner `<a>` agrees with the
2120
- // runtime nav decision in `ChatCardNavWrap` + `handleChatNavClick`.
2121
- const isNewTab = computeIsNewTab(runtime, finalChatRef.url, finalChatRef.targetPlatform ?? null);
2110
+ // runtime nav decision in `ChatCardNavWrap` + `executeNavigation`.
2111
+ // A url the host composed (`composed`, `hostOverride`) as a relative route of its own is the host's page.
2112
+ const hostRoute =
2113
+ (destination.source === 'composed' || destination.source === 'hostOverride') &&
2114
+ !!finalChatRef.url &&
2115
+ isRelativeHref(finalChatRef.url);
2116
+ const isNewTab = finalChatRef.url
2117
+ ? navLinkTarget(runtime, finalChatRef.url, finalChatRef.targetPlatform, { hostRoute }).isNewTab
2118
+ : false;
2122
2119
 
2123
2120
  // Resolve the "Ask Mingo"/"Display" affordance ONCE — same precedence as the
2124
2121
  // legacy `ChatCardWithDiscuss` (displayAction + onDisplay → "Display",
@@ -2134,8 +2131,6 @@ export function ChatCardLoader({
2134
2131
  : undefined;
2135
2132
 
2136
2133
  const renderOpts: ChatCardRenderOptions = {
2137
- baseRoute,
2138
- chipBasePlatform,
2139
2134
  extras,
2140
2135
  isNewTab,
2141
2136
  discuss,
@@ -2153,6 +2148,7 @@ export function ChatCardLoader({
2153
2148
  path={path}
2154
2149
  targetPlatform={finalChatRef.targetPlatform ?? null}
2155
2150
  isNewTab={isNewTab}
2151
+ hostRoute={hostRoute}
2156
2152
  >
2157
2153
  {children}
2158
2154
  </ChatCardNavWrap>
@@ -2255,23 +2251,12 @@ export function renderChatInlineEntityCard(
2255
2251
  options: {
2256
2252
  onDiscuss?: (ref: ChatRef) => void;
2257
2253
  onDisplay?: (ref: ChatRef) => void;
2258
- baseRoute?: string;
2259
- chipBasePlatform?: string;
2260
2254
  extras?: ChatCardDispatchExtras;
2261
2255
  } = {},
2262
2256
  ): React.ReactNode {
2263
- const { onDiscuss, onDisplay, baseRoute, chipBasePlatform, extras } = options;
2257
+ const { onDiscuss, onDisplay, extras } = options;
2264
2258
 
2265
- const loader = (
2266
- <ChatCardLoader
2267
- chatRef={chatRef}
2268
- onDiscuss={onDiscuss}
2269
- onDisplay={onDisplay}
2270
- baseRoute={baseRoute}
2271
- chipBasePlatform={chipBasePlatform}
2272
- extras={extras}
2273
- />
2274
- );
2259
+ const loader = <ChatCardLoader chatRef={chatRef} onDiscuss={onDiscuss} onDisplay={onDisplay} extras={extras} />;
2275
2260
 
2276
2261
  // Embedded videos are SELF-DESCRIBING: the marker id alone recovers the
2277
2262
  // playable URL (`decodeVideoMarkerId`), so the player renders on ANY
@@ -182,7 +182,7 @@ export interface GitHubActivityCardProps {
182
182
  item: GitHubActivityItem;
183
183
  variant?: 'row' | 'compact';
184
184
  className?: string;
185
- /** Pre-composed `<Link>` prop bundle (typically from a `useNavLink` hook in
185
+ /** Pre-composed `<Link>` prop bundle (typically from a `useNavLinkViaRuntime` hook in
186
186
  * the consumer). When provided, the outer renders as a real `<Link>`. */
187
187
  anchorProps?: GitHubActivityCardAnchorProps;
188
188
  }
@@ -5,7 +5,7 @@
5
5
  *
6
6
  * Pure-presentation cards (BlogCard, OnboardingGuideCard, etc.)
7
7
  * historically required callers to pre-compute `target`/`rel` via a
8
- * hub-side `useNavLink` wrapper because the same-tab-vs-new-tab
8
+ * `useNavLinkViaRuntime` because the same-tab-vs-new-tab
9
9
  * decision depends on `currentPlatform()` and the cross-platform
10
10
  * URL topology — neither of which the lib knows.
11
11
  *
@@ -25,7 +25,8 @@
25
25
 
26
26
  import { useMemo } from 'react';
27
27
  import { useChatRuntime } from '../../../contexts/chat-runtime-context';
28
- import { computeIsNewTab } from '../utils/nav-anchor-props';
28
+ import { navLinkTarget, newTabAnchorAttrs } from '../utils/nav-anchor-props';
29
+ import { type NewTabRel, newTabRel } from '../utils/new-tab-rel';
29
30
 
30
31
  export interface UseEntityCardLinkArgs {
31
32
  href: string;
@@ -33,12 +34,12 @@ export interface UseEntityCardLinkArgs {
33
34
  /** Explicit override. When set, runtime decision is skipped. */
34
35
  target?: '_blank';
35
36
  /** Explicit override. When set, runtime decision is skipped. */
36
- rel?: 'noopener' | 'noopener noreferrer';
37
+ rel?: NewTabRel;
37
38
  }
38
39
 
39
40
  export interface EntityCardLinkProps {
40
41
  target: '_blank' | undefined;
41
- rel: 'noopener' | 'noopener noreferrer' | undefined;
42
+ rel: NewTabRel | undefined;
42
43
  }
43
44
 
44
45
  export function useEntityCardLink({ href, targetPlatform, target, rel }: UseEntityCardLinkArgs): EntityCardLinkProps {
@@ -50,19 +51,13 @@ export function useEntityCardLink({ href, targetPlatform, target, rel }: UseEnti
50
51
  // to close the tabnabbing vector (window.opener access from the
51
52
  // new tab back to the parent).
52
53
  if (target !== undefined || rel !== undefined) {
53
- const safeRel = rel ?? (target === '_blank' ? 'noopener noreferrer' : undefined);
54
+ const safeRel = rel ?? (target === '_blank' ? newTabRel(href, targetPlatform) : undefined);
54
55
  return { target, rel: safeRel };
55
56
  }
56
- // Use the UNIFIED new-tab decision so the rendered anchor's target/rel ALWAYS
57
- // agrees with the click handler (executeNavigation also calls computeIsNewTab) —
58
- // including the embed-mode short-circuit + the origin/platform fallback.
59
- // Previously this used `decideNewTab ?? false`, which diverged from the click
60
- // when decideNewTab was unwired (embed mode rendered a same-tab anchor that
61
- // clicked into a new tab). Hub behavior is unchanged: it wires decideNewTab,
62
- // which computeIsNewTab consumes identically.
63
- const newTab = runtime ? computeIsNewTab(runtime, href, targetPlatform ?? null) : false;
64
- return newTab
65
- ? { target: '_blank' as const, rel: 'noopener noreferrer' as const }
66
- : { target: undefined, rel: undefined };
57
+ // THE navigation decision (`navLinkTarget`), the one the click handler executes by, so the rendered anchor's
58
+ // target/rel always agrees with the click; `rel` is the one referrer rule.
59
+ const resolved = navLinkTarget(runtime, href, targetPlatform);
60
+ const attrs = newTabAnchorAttrs(resolved.isNewTab, resolved.href, targetPlatform);
61
+ return { target: attrs.target, rel: attrs.rel };
67
62
  }, [target, rel, href, targetPlatform, runtime]);
68
63
  }
@@ -70,6 +70,8 @@ export {
70
70
  type NavLinkAnchorViaRuntimeProps,
71
71
  type NavLinkViaRuntimeInput,
72
72
  type NavLinkViaRuntimeProps,
73
+ type NavigateViaRuntimeInput,
74
+ useNavigateViaRuntime,
73
75
  useNavLinkViaRuntime,
74
76
  } from './nav-link-anchor-via-runtime';
75
77
  export { SourceActionButton, type SourceActionButtonProps, type SourceActionDensity } from './source-action-button';
@@ -145,4 +147,4 @@ export {
145
147
  ASK_AI_TRIGGER_ATTRIBUTE,
146
148
  } from './utils/ask-ai-events';
147
149
  export * from './proxy-credentials-panel';
148
- export { InlineAppLinkChip, InlineChip } from './inline-app-link-chip';
150
+ export { InlineChip } from './inline-chip';
@@ -12,9 +12,7 @@
12
12
  */
13
13
 
14
14
  import type React from 'react';
15
- import Link from '../../embed-shims/next-link';
16
15
  import { cn } from '../../utils/cn';
17
- import { BrowserWindowIcon } from '../icons-v2-generated/coding/browser-window-icon';
18
16
  import { Tag } from '../ui/tag';
19
17
 
20
18
  /**
@@ -49,31 +47,7 @@ export function InlineChip({
49
47
  label={label}
50
48
  loading={loading}
51
49
  className={cn(INLINE_CHIP_CLASS, className)}
50
+ data-testid="inline-chip"
52
51
  />
53
52
  );
54
53
  }
55
-
56
- /**
57
- * A link that stays in this app (the runtime's `computeIsNewTab` keeps it in this window), drawn as an inline box. `anchor` is the host's link element (its
58
- * `NavLinkAnchor`, so the click follows the host's routing rule), else the lib's boxed `Link`.
59
- */
60
- export function InlineAppLinkChip({
61
- href,
62
- children,
63
- anchor: Anchor,
64
- }: {
65
- href: string;
66
- children: React.ReactNode;
67
- anchor?: React.ComponentType<{ href: string; className?: string; children?: React.ReactNode }>;
68
- }): React.ReactElement {
69
- const chip = <InlineChip icon={<BrowserWindowIcon />} label={children} className="hover:bg-ods-bg-hover" />;
70
- return Anchor ? (
71
- <Anchor href={href} className="no-underline">
72
- {chip}
73
- </Anchor>
74
- ) : (
75
- <Link href={href} className="no-underline">
76
- {chip}
77
- </Link>
78
- );
79
- }
@@ -5,10 +5,10 @@
5
5
  * source-chip drill-ins, inline references).
6
6
  *
7
7
  * Reads the active `ChatRuntime` and routes clicks through
8
- * `handleChatNavClick`. Same single-source rules as source chips and
8
+ * `executeNavigation`. Same single-source rules as source chips and
9
9
  * inline cards:
10
- * - new-tab decision via `computeIsNewTab` (embed-mode short-circuit
11
- * + `runtime.navigation.decideNewTab` + lib fallback)
10
+ * - new-tab decision via `navLinkTarget` (the embed rule, then the host's
11
+ * `runtime.navigation.decideNewTab` when it wires one, else the lib's rule)
12
12
  * - `target` / `rel` via `newTabAnchorAttrs`
13
13
  * - same-tab click → close the chat panel (via `ChatPanelContext`);
14
14
  * new-tab click → leave panel open while the new tab loads
@@ -25,13 +25,13 @@
25
25
  * plain anchor attributes (`aria-*`, `title`, `data-*`, `style`, `rel`).
26
26
  */
27
27
 
28
- import type { AnchorHTMLAttributes, ReactNode, MouseEvent } from 'react';
28
+ import { type AnchorHTMLAttributes, type MouseEvent, type ReactNode, useCallback } from 'react';
29
29
  import { useRequiredChatRuntime } from '../../contexts/chat-runtime-context';
30
- import { useRouter } from '../../embed-shims/next-navigation';
31
30
  import { useChatPanel } from './chat-panel-context';
32
- import { resolveHrefForRuntime } from './utils/chat-nav-resolution';
33
- import { executeNavigation } from './utils/execute-navigation';
34
- import { computeIsNewTab, newTabAnchorAttrs } from './utils/nav-anchor-props';
31
+ import { isModifierClick } from './utils/chat-nav-resolution';
32
+ import { executeNavigation, executeNavigationImperative, executeNewTabNavigation } from './utils/execute-navigation';
33
+ import { type NavLinkTarget, type NavOpenIn, navLinkTarget, newTabAnchorAttrs } from './utils/nav-anchor-props';
34
+ import type { NewTabRel } from './utils/new-tab-rel';
35
35
 
36
36
  export interface NavLinkAnchorViaRuntimeProps extends Omit<
37
37
  AnchorHTMLAttributes<HTMLAnchorElement>,
@@ -40,6 +40,8 @@ export interface NavLinkAnchorViaRuntimeProps extends Omit<
40
40
  href: string;
41
41
  path?: string | null;
42
42
  targetPlatform?: string | null;
43
+ /** The caller's explicit tab (an "open in new tab" control); absent = the rule decides. */
44
+ openIn?: NavOpenIn;
43
45
  className?: string;
44
46
  /** Optional — matches `NavLinkAnchorComponent`'s contract so the
45
47
  * markdown-anchor slot can render an empty anchor (rare but legal). */
@@ -49,10 +51,14 @@ export interface NavLinkAnchorViaRuntimeProps extends Omit<
49
51
  }
50
52
 
51
53
  export interface NavLinkViaRuntimeInput {
52
- href: string;
54
+ /** The destination. A string always gets a link (as before); `null` / `undefined` means there is none and the hook
55
+ * returns null, so the caller draws no link. */
56
+ href: string | null | undefined;
53
57
  path?: string | null;
54
58
  /** The platform that owns `href`, by name. */
55
59
  targetPlatform?: string | null;
60
+ /** The caller's explicit tab (an admin preview always opens a new one); absent = the rule decides. */
61
+ openIn?: NavOpenIn;
56
62
  /** Runs before the navigation; `preventDefault()` cancels it. */
57
63
  onClick?: (event: MouseEvent<HTMLAnchorElement>) => void;
58
64
  }
@@ -60,63 +66,97 @@ export interface NavLinkViaRuntimeInput {
60
66
  export interface NavLinkViaRuntimeProps {
61
67
  href: string;
62
68
  target?: '_blank';
63
- rel?: 'noopener' | 'noopener noreferrer';
69
+ rel?: NewTabRel;
64
70
  onClick: (event: MouseEvent<HTMLAnchorElement>) => void;
65
71
  }
66
72
 
73
+ /** The navigation decision ({@link navLinkTarget}) for a link rendered inside the chat runtime. */
74
+ export function useNavLinkTarget(href: string, targetPlatform?: string | null, openIn?: NavOpenIn): NavLinkTarget {
75
+ return navLinkTarget(useRequiredChatRuntime(), href, targetPlatform, { openIn });
76
+ }
77
+
67
78
  /**
68
79
  * The anchor props of {@link NavLinkAnchorViaRuntime}, for an element that is
69
80
  * not a bare `<a>` (a `Button`'s `linkProps`). ONE decision and ONE click
70
81
  * handler for both forms.
71
82
  *
72
- * A new-tab link to a NAMED platform is one of our own sites and keeps the
73
- * Referer (`noopener` alone: the cross-domain analytics attribute the visit by
74
- * it); any other new-tab link also gets `noreferrer`.
83
+ * A new-tab link to one of our own sites keeps the Referer (`newTabRel`: the
84
+ * cross-domain analytics attribute the visit by it); any other gets `noreferrer`.
75
85
  */
86
+ export function useNavLinkViaRuntime(input: NavLinkViaRuntimeInput & { href: string }): NavLinkViaRuntimeProps;
87
+ export function useNavLinkViaRuntime(input: NavLinkViaRuntimeInput): NavLinkViaRuntimeProps | null;
76
88
  export function useNavLinkViaRuntime({
77
89
  href,
78
90
  path,
79
91
  targetPlatform,
92
+ openIn,
80
93
  onClick: onClickProp,
81
- }: NavLinkViaRuntimeInput): NavLinkViaRuntimeProps {
94
+ }: NavLinkViaRuntimeInput): NavLinkViaRuntimeProps | null {
82
95
  const runtime = useRequiredChatRuntime();
83
- const router = useRouter();
84
96
  const panel = useChatPanel();
85
- const resolvedHref = resolveHrefForRuntime(href, runtime);
86
- const isNewTab = computeIsNewTab(runtime, resolvedHref, targetPlatform ?? null);
97
+ const { href: resolvedHref, isNewTab } = useNavLinkTarget(href ?? '', targetPlatform, openIn);
98
+ if (href == null) return null;
87
99
 
88
100
  const onClick = (e: MouseEvent<HTMLAnchorElement>) => {
89
101
  onClickProp?.(e);
90
102
  if (e.defaultPrevented) return;
91
- const handled = executeNavigation({
92
- event: e,
93
- runtime,
94
- href: resolvedHref,
95
- path,
96
- targetPlatform,
97
- fallbackNavigate: router.push,
98
- });
103
+ const handled = executeNavigation({ event: e, runtime, href: resolvedHref, path, targetPlatform, openIn });
99
104
  if (handled && !isNewTab && panel?.closeChat) panel.closeChat();
100
105
  };
101
- const attrs = newTabAnchorAttrs(isNewTab);
102
- return {
103
- href: resolvedHref,
104
- ...attrs,
105
- ...(isNewTab && targetPlatform && { rel: 'noopener' as const }),
106
- onClick,
107
- };
106
+ return { href: resolvedHref, ...newTabAnchorAttrs(isNewTab, resolvedHref, targetPlatform), onClick };
107
+ }
108
+
109
+ /** What {@link useNavigateViaRuntime}'s function is told to follow. */
110
+ export interface NavigateViaRuntimeInput {
111
+ href: string | null | undefined;
112
+ path?: string | null;
113
+ /** The platform that owns `href`, by name. */
114
+ targetPlatform?: string | null;
115
+ /** The caller's explicit tab; absent = the rule decides. */
116
+ openIn?: NavOpenIn;
117
+ /** The click that asked, when there was one: a modifier click or a middle click opens a new tab, as on a link. */
118
+ modifierEvent?: {
119
+ button?: number;
120
+ metaKey?: boolean;
121
+ ctrlKey?: boolean;
122
+ shiftKey?: boolean;
123
+ altKey?: boolean;
124
+ } | null;
125
+ }
126
+
127
+ /**
128
+ * Follow a link from code (a button, a card's click, a redirect after a save): the same decision and the same executor
129
+ * as {@link useNavLinkViaRuntime}, for an element that is not an anchor.
130
+ */
131
+ export function useNavigateViaRuntime(): (input: NavigateViaRuntimeInput) => void {
132
+ const runtime = useRequiredChatRuntime();
133
+ return useCallback(
134
+ ({ href, path, targetPlatform, openIn, modifierEvent }: NavigateViaRuntimeInput) => {
135
+ if (!href) return;
136
+ if (modifierEvent && isModifierClick(modifierEvent)) {
137
+ // Not an anchor, so the browser opens nothing itself: a modifier or middle click asks for a new tab, as it
138
+ // does on a link. Another button (a right click) navigates nowhere.
139
+ const button = modifierEvent.button ?? 0;
140
+ if (button === 0 || button === 1) executeNewTabNavigation({ runtime, href, targetPlatform });
141
+ return;
142
+ }
143
+ executeNavigationImperative({ runtime, href, path, targetPlatform, openIn });
144
+ },
145
+ [runtime],
146
+ );
108
147
  }
109
148
 
110
149
  export function NavLinkAnchorViaRuntime({
111
150
  href,
112
151
  path,
113
152
  targetPlatform,
153
+ openIn,
114
154
  className,
115
155
  children,
116
156
  onClick,
117
157
  ...anchorAttrs
118
158
  }: NavLinkAnchorViaRuntimeProps) {
119
- const linkProps = useNavLinkViaRuntime({ href, path, targetPlatform, onClick });
159
+ const linkProps = useNavLinkViaRuntime({ href, path, targetPlatform, openIn, onClick });
120
160
  return (
121
161
  <a {...linkProps} {...anchorAttrs} className={className}>
122
162
  {children}