@agent-native/core 0.189.0 → 0.190.0-nightly-20260925211446

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 (233) hide show
  1. package/corpus/README.md +1 -1
  2. package/corpus/templates/analytics/.agents/skills/analysis-workspace/SKILL.md +10 -0
  3. package/corpus/templates/analytics/.agents/skills/data-querying/SKILL.md +1 -1
  4. package/corpus/templates/analytics/AGENTS.md +11 -22
  5. package/corpus/templates/analytics/actions/list-data-dictionary.ts +7 -9
  6. package/corpus/templates/analytics/actions/search-analytics-query-catalog.ts +1 -1
  7. package/corpus/templates/analytics/app/components/AnalyticsReviewArtifactPreview.tsx +201 -0
  8. package/corpus/templates/analytics/app/i18n/en-US.ts +2 -0
  9. package/corpus/templates/analytics/app/pages/Settings.tsx +50 -3
  10. package/corpus/templates/analytics/changelog/2026-09-25-first-run-onboarding-records-setup-choices-and-builder-conne.md +6 -0
  11. package/corpus/templates/analytics/changelog/2026-09-25-human-review-previews-analytics-dashboards-as-real-charts.md +6 -0
  12. package/corpus/templates/analytics/changelog/2026-09-25-org-admins-can-review-agent-runs-from-settings.md +6 -0
  13. package/corpus/templates/analytics/changelog/2026-09-25-proactive-query-context.md +6 -0
  14. package/corpus/templates/analytics/seeds/dashboards/agent-native-templates-first-party.json +98 -2
  15. package/corpus/templates/analytics/server/lib/analytics-agent-context.ts +557 -0
  16. package/corpus/templates/analytics/server/lib/analytics-query-catalog.ts +217 -46
  17. package/corpus/templates/analytics/server/lib/dashboard-catalog.ts +2 -2
  18. package/corpus/templates/analytics/server/lib/dashboards-store.ts +39 -5
  19. package/corpus/templates/analytics/server/lib/data-dictionary-context.ts +4 -0
  20. package/corpus/templates/analytics/server/lib/first-party-metric-catalog.ts +268 -2
  21. package/corpus/templates/analytics/server/plugins/agent-chat.ts +44 -9
  22. package/corpus/templates/calendar/AGENTS.md +5 -0
  23. package/corpus/templates/calendar/CHANGELOG.md +6 -0
  24. package/corpus/templates/calendar/actions/get-event-rules-status.ts +47 -0
  25. package/corpus/templates/calendar/actions/list-events.ts +50 -4
  26. package/corpus/templates/calendar/actions/undo-calendar-event-rule.ts +229 -0
  27. package/corpus/templates/calendar/actions/update-settings.ts +8 -0
  28. package/corpus/templates/calendar/app/i18n/en-US.ts +27 -0
  29. package/corpus/templates/calendar/app/pages/Settings.tsx +196 -1
  30. package/corpus/templates/calendar/changelog/2026-09-25-calendar-feeds-with-the-same-url-keep-their-own-names-and-co.md +6 -0
  31. package/corpus/templates/calendar/changelog/2026-09-25-calendar-invitation-rules-surface-expired-connections-and-un.md +6 -0
  32. package/corpus/templates/calendar/changelog/2026-09-25-restore-locally-hidden-events-from-activity-after-disconnect.md +6 -0
  33. package/corpus/templates/calendar/server/lib/calendar-settings.ts +44 -10
  34. package/corpus/templates/calendar/server/lib/google-api.ts +15 -1
  35. package/corpus/templates/calendar/server/lib/google-calendar.ts +1 -1
  36. package/corpus/templates/calendar/server/plugins/event-rules.ts +628 -0
  37. package/corpus/templates/calendar/shared/api.ts +13 -0
  38. package/corpus/templates/calendar/shared/settings.ts +71 -1
  39. package/corpus/templates/clips/actions/create-recording.ts +83 -2
  40. package/corpus/templates/clips/actions/finalize-recording.ts +610 -110
  41. package/corpus/templates/clips/actions/get-recording-player-data.ts +6 -0
  42. package/corpus/templates/clips/actions/import-loom-recording.ts +2 -0
  43. package/corpus/templates/clips/actions/lib/create-recording-schema.ts +7 -0
  44. package/corpus/templates/clips/actions/lib/loom-import-job.ts +15 -1
  45. package/corpus/templates/clips/app/components/recorder/recorder-engine.ts +126 -26
  46. package/corpus/templates/clips/app/hooks/use-drop-video-upload.ts +75 -15
  47. package/corpus/templates/clips/app/routes/_app.r.$recordingId.tsx +5 -1
  48. package/corpus/templates/clips/app/routes/record.tsx +134 -40
  49. package/corpus/templates/clips/chrome-extension/src/background.ts +3 -0
  50. package/corpus/templates/clips/chrome-extension/src/offscreen.ts +73 -16
  51. package/corpus/templates/clips/desktop/src/lib/recorder.ts +188 -18
  52. package/corpus/templates/clips/desktop/src/lib/recording-request.ts +1 -0
  53. package/corpus/templates/clips/server/db/schema.ts +4 -0
  54. package/corpus/templates/clips/server/jobs/media-verification.ts +78 -4
  55. package/corpus/templates/clips/server/jobs/recording-failure-backfill.ts +142 -0
  56. package/corpus/templates/clips/server/lib/media-verification-state.ts +29 -0
  57. package/corpus/templates/clips/server/lib/post-finalize-dispatch.ts +2 -0
  58. package/corpus/templates/clips/server/lib/recording-failures.ts +111 -0
  59. package/corpus/templates/clips/server/lib/recordings.ts +6 -1
  60. package/corpus/templates/clips/server/lib/s3-upload-provider.ts +8 -3
  61. package/corpus/templates/clips/server/lib/upload-lease.ts +25 -6
  62. package/corpus/templates/clips/server/plugins/calendar-jobs.ts +2 -0
  63. package/corpus/templates/clips/server/plugins/db.ts +18 -0
  64. package/corpus/templates/clips/server/routes/api/_agent-native-background/post-finalize-worker.post.ts +48 -5
  65. package/corpus/templates/clips/server/routes/api/uploads/[recordingId]/abort.post.ts +322 -31
  66. package/corpus/templates/clips/server/routes/api/uploads/[recordingId]/chunk.post.ts +223 -61
  67. package/corpus/templates/clips/server/routes/api/uploads/[recordingId]/interrupt.post.ts +62 -4
  68. package/corpus/templates/clips/server/routes/api/uploads/[recordingId]/reset-chunks.post.ts +74 -7
  69. package/corpus/templates/clips/shared/recording-core.ts +27 -0
  70. package/corpus/templates/design/actions/get-design.ts +35 -6
  71. package/corpus/templates/mail/.agents/skills/inbox-automations/SKILL.md +4 -0
  72. package/corpus/templates/mail/actions/consolidate-ai-filter-rules.ts +41 -0
  73. package/corpus/templates/mail/actions/get-ai-priority.ts +48 -8
  74. package/corpus/templates/mail/actions/record-ai-priority-feedback.ts +69 -0
  75. package/corpus/templates/mail/actions/update-mail-preferences.ts +2 -0
  76. package/corpus/templates/mail/app/components/email/EmailList.tsx +179 -32
  77. package/corpus/templates/mail/app/components/email/EmailListItem.tsx +97 -9
  78. package/corpus/templates/mail/app/components/email/EmailThread.tsx +55 -1
  79. package/corpus/templates/mail/app/components/email/ImportanceFeedbackMenu.tsx +52 -0
  80. package/corpus/templates/mail/app/components/email/compose-autocomplete.ts +2 -1
  81. package/corpus/templates/mail/app/components/layout/AppLayout.tsx +219 -188
  82. package/corpus/templates/mail/app/components/onboarding/AiInboxSetup.tsx +338 -0
  83. package/corpus/templates/mail/app/components/settings/AiFilterSection.tsx +597 -781
  84. package/corpus/templates/mail/app/components/settings/AiRulePromptField.tsx +37 -0
  85. package/corpus/templates/mail/app/global.css +42 -26
  86. package/corpus/templates/mail/app/hooks/use-ai-priority-feedback.ts +43 -0
  87. package/corpus/templates/mail/app/hooks/use-automations.ts +23 -0
  88. package/corpus/templates/mail/app/i18n/en-US.ts +58 -3
  89. package/corpus/templates/mail/app/pages/InboxPage.tsx +47 -10
  90. package/corpus/templates/mail/changelog/2026-09-25-editing-importance-rules-preserves-disabled-instructions-and.md +6 -0
  91. package/corpus/templates/mail/changelog/2026-09-25-handle-astral-unicode-letters-in-autocomplete-word-boundarie.md +6 -0
  92. package/corpus/templates/mail/changelog/2026-09-25-jev-priority-feedback-and-inbox-settings.md +6 -0
  93. package/corpus/templates/mail/changelog/2026-09-25-keep-existing-ai-filter-rules-intact-when-saving-a-prompt.md +6 -0
  94. package/corpus/templates/mail/server/lib/automation-engine.ts +21 -12
  95. package/corpus/templates/mail/server/lib/automations.ts +100 -1
  96. package/corpus/templates/mail/shared/types.ts +3 -0
  97. package/corpus/templates/plan/app/i18n/en-US.ts +6 -0
  98. package/corpus/templates/plan/app/lib/plan-invite-suggestion.ts +43 -0
  99. package/corpus/templates/plan/app/pages/PlansPage.tsx +249 -4
  100. package/corpus/templates/slides/actions/create-deck.ts +11 -1
  101. package/corpus/templates/slides/app/components/deck/SlideRenderer.tsx +117 -1
  102. package/corpus/templates/slides/app/components/design-system/DesignSystemSetup.tsx +373 -330
  103. package/corpus/templates/slides/app/components/design-system/builder-index-response.ts +36 -5
  104. package/corpus/templates/slides/app/components/editor/BlockBubbleMenu.tsx +21 -53
  105. package/corpus/templates/slides/app/components/editor/SlideEditor.tsx +347 -671
  106. package/corpus/templates/slides/app/components/editor/bullet-editing.ts +55 -8
  107. package/corpus/templates/slides/app/components/editor/in-place-text-session.ts +2082 -0
  108. package/corpus/templates/slides/app/components/editor/list-editing.ts +174 -16
  109. package/corpus/templates/slides/app/components/editor/rich-text-selection.ts +497 -62
  110. package/corpus/templates/slides/app/components/editor/slide-text-targets.ts +102 -20
  111. package/corpus/templates/slides/app/context/DeckContext.tsx +9 -4
  112. package/corpus/templates/slides/app/global.css +7 -219
  113. package/corpus/templates/slides/app/i18n/en-US.ts +3 -0
  114. package/corpus/templates/slides/app/lib/sanitize-slide-html.ts +7 -0
  115. package/corpus/templates/slides/app/lib/slide-image-replacement.ts +203 -1
  116. package/corpus/templates/slides/app/lib/slide-source-map.ts +43 -0
  117. package/corpus/templates/slides/app/pages/DeckEditor.tsx +182 -4
  118. package/corpus/templates/slides/app/routes/settings.tsx +33 -2
  119. package/corpus/templates/slides/changelog/2026-09-25-improve-slides-design-system-setup-feedback.md +6 -0
  120. package/corpus/templates/slides/changelog/2026-09-25-org-admins-can-review-agent-runs-from-settings.md +6 -0
  121. package/corpus/templates/slides/changelog/2026-09-25-text-on-a-slide-is-now-edited-in-place-clicking-into-it-chan.md +6 -0
  122. package/corpus/templates/slides/package.json +0 -12
  123. package/corpus/templates/slides/scripts/edit-fidelity/README.md +4 -2
  124. package/corpus/templates/slides/scripts/edit-fidelity/run.ts +12 -3
  125. package/corpus/templates/slides/vite.config.ts +1 -10
  126. package/dist/agent/jev-tool-prefetch.d.ts +29 -3
  127. package/dist/agent/jev-tool-prefetch.js +161 -34
  128. package/dist/agent/production-agent.d.ts +11 -0
  129. package/dist/agent/production-agent.js +39 -8
  130. package/dist/app-config/runtime.d.ts +1 -0
  131. package/dist/app-config/runtime.js +4 -0
  132. package/dist/app-config/schema.d.ts +1 -0
  133. package/dist/client/AgentSidebar.d.ts +3 -1
  134. package/dist/client/AgentSidebar.js +8 -12
  135. package/dist/client/analytics/index.d.ts +1 -1
  136. package/dist/client/analytics/index.js +1 -1
  137. package/dist/client/analytics.d.ts +2 -0
  138. package/dist/client/analytics.js +9 -0
  139. package/dist/client/api-path.js +5 -2
  140. package/dist/client/chat/run-recovery.d.ts +0 -3
  141. package/dist/client/chat/run-recovery.js +13 -23
  142. package/dist/client/index.d.ts +1 -1
  143. package/dist/client/index.js +1 -1
  144. package/dist/client/observability/ObservabilityDashboard.d.ts +3 -0
  145. package/dist/client/observability/ObservabilityDashboard.js +366 -71
  146. package/dist/client/observability/ObservabilityReviewSummaryButton.d.ts +4 -1
  147. package/dist/client/observability/ObservabilityReviewSummaryButton.js +13 -9
  148. package/dist/client/observability/OutputPreview.d.ts +9 -4
  149. package/dist/client/observability/OutputPreview.js +230 -52
  150. package/dist/client/onboarding/FirstRunOnboarding.js +67 -4
  151. package/dist/client/onboarding/use-onboarding.js +2 -0
  152. package/dist/client/sharing/ShareButton.d.ts +2 -0
  153. package/dist/client/sharing/ShareButton.js +1 -0
  154. package/dist/client/sharing/useShareButtonController.d.ts +1 -0
  155. package/dist/client/sharing/useShareButtonController.js +29 -8
  156. package/dist/collab/awareness.d.ts +2 -2
  157. package/dist/collab/struct-routes.d.ts +1 -1
  158. package/dist/deploy/build.js +9 -1
  159. package/dist/embeddings/index.d.ts +3 -1
  160. package/dist/embeddings/index.js +20 -10
  161. package/dist/jobs/sweep-hooks.d.ts +7 -0
  162. package/dist/jobs/sweep-hooks.js +28 -0
  163. package/dist/localization/default-messages.d.ts +1 -0
  164. package/dist/localization/default-messages.js +1 -0
  165. package/dist/mcp/screen-memory-stdio.d.ts +7 -7
  166. package/dist/notifications/routes.d.ts +1 -1
  167. package/dist/observability/actions/authorization.d.ts +1 -0
  168. package/dist/observability/actions/authorization.js +22 -0
  169. package/dist/observability/actions/get-observability-review-detail.d.ts +5 -0
  170. package/dist/observability/actions/get-observability-review-detail.js +10 -2
  171. package/dist/observability/actions/get-observability-review-summary-source.d.ts +2 -0
  172. package/dist/observability/actions/get-observability-review-summary-source.js +3 -2
  173. package/dist/observability/actions/save-observability-instruction-update.js +2 -1
  174. package/dist/observability/actions/save-observability-review-summary.js +21 -10
  175. package/dist/observability/migrations.js +25 -0
  176. package/dist/observability/reviews.d.ts +3 -1
  177. package/dist/observability/reviews.js +410 -53
  178. package/dist/observability/routes.d.ts +6 -6
  179. package/dist/observability/store.d.ts +15 -0
  180. package/dist/observability/store.js +131 -11
  181. package/dist/observability/types.d.ts +18 -0
  182. package/dist/org/handlers.d.ts +1 -1
  183. package/dist/org/index.d.ts +1 -1
  184. package/dist/progress/routes.d.ts +1 -1
  185. package/dist/provider-api/actions/custom-provider-registration.d.ts +5 -5
  186. package/dist/provider-api/actions/provider-api.d.ts +8 -8
  187. package/dist/secrets/routes.d.ts +3 -3
  188. package/dist/server/agent-chat/plugin-options.d.ts +4 -20
  189. package/dist/server/agent-chat/prompt-resources.d.ts +16 -0
  190. package/dist/server/agent-chat/prompt-resources.js +385 -22
  191. package/dist/server/agent-chat-plugin.d.ts +3 -1
  192. package/dist/server/agent-chat-plugin.js +149 -27
  193. package/dist/server/agent-engine-ollama-models-route.d.ts +1 -1
  194. package/dist/server/index.d.ts +3 -0
  195. package/dist/server/index.js +3 -0
  196. package/dist/server/prompts/framework-core-compact.js +1 -1
  197. package/dist/server/prompts/framework-core.js +1 -1
  198. package/dist/server/realtime-token.d.ts +1 -1
  199. package/dist/server/request-context.d.ts +6 -3
  200. package/dist/server/transcribe-voice.d.ts +1 -1
  201. package/dist/settings/org-settings.d.ts +4 -2
  202. package/dist/settings/org-settings.js +3 -3
  203. package/dist/settings/store.d.ts +3 -1
  204. package/dist/settings/store.js +8 -3
  205. package/dist/styles/agent-native.css +5 -0
  206. package/dist/templates/default/app/i18n/ar-SA.ts +1 -0
  207. package/dist/templates/default/app/i18n/de-DE.ts +1 -0
  208. package/dist/templates/default/app/i18n/en-US.ts +1 -0
  209. package/dist/templates/default/app/i18n/es-ES.ts +1 -0
  210. package/dist/templates/default/app/i18n/fr-FR.ts +1 -0
  211. package/dist/templates/default/app/i18n/hi-IN.ts +1 -0
  212. package/dist/templates/default/app/i18n/ja-JP.ts +1 -0
  213. package/dist/templates/default/app/i18n/ko-KR.ts +1 -0
  214. package/dist/templates/default/app/i18n/pt-BR.ts +1 -0
  215. package/dist/templates/default/app/i18n/zh-CN.ts +1 -0
  216. package/dist/templates/default/app/i18n/zh-TW.ts +1 -0
  217. package/dist/tracking/registry.js +11 -4
  218. package/package.json +4 -3
  219. package/src/templates/default/app/i18n/ar-SA.ts +1 -0
  220. package/src/templates/default/app/i18n/de-DE.ts +1 -0
  221. package/src/templates/default/app/i18n/en-US.ts +1 -0
  222. package/src/templates/default/app/i18n/es-ES.ts +1 -0
  223. package/src/templates/default/app/i18n/fr-FR.ts +1 -0
  224. package/src/templates/default/app/i18n/hi-IN.ts +1 -0
  225. package/src/templates/default/app/i18n/ja-JP.ts +1 -0
  226. package/src/templates/default/app/i18n/ko-KR.ts +1 -0
  227. package/src/templates/default/app/i18n/pt-BR.ts +1 -0
  228. package/src/templates/default/app/i18n/zh-CN.ts +1 -0
  229. package/src/templates/default/app/i18n/zh-TW.ts +1 -0
  230. package/corpus/templates/slides/app/components/editor/SlideBubbleMenu.tsx +0 -488
  231. package/corpus/templates/slides/app/components/editor/SlideInlineEditor.tsx +0 -589
  232. package/corpus/templates/slides/app/components/editor/SlideRichTextEditor.tsx +0 -1347
  233. package/corpus/templates/slides/app/components/editor/SlideSlashMenu.tsx +0 -373
@@ -0,0 +1,43 @@
1
+ export function hasSameDomainCoworker(
2
+ ownerEmail: string,
3
+ memberEmails: string[],
4
+ ): boolean {
5
+ const owner = ownerEmail.trim().toLowerCase();
6
+ const separator = owner.lastIndexOf("@");
7
+ if (separator <= 0 || separator !== owner.indexOf("@")) return false;
8
+
9
+ const domain = owner.slice(separator + 1);
10
+ return memberEmails.some((email) => {
11
+ const member = email.trim().toLowerCase();
12
+ return (
13
+ member !== owner && member.slice(member.lastIndexOf("@") + 1) === domain
14
+ );
15
+ });
16
+ }
17
+
18
+ export async function hasSameDomainCoworkerInPages(
19
+ ownerEmail: string,
20
+ fetchPage: (offset: number) => Promise<{
21
+ members: Array<{ email: string }>;
22
+ hasMore: boolean;
23
+ nextOffset: number | null;
24
+ }>,
25
+ ): Promise<boolean> {
26
+ let offset = 0;
27
+ while (true) {
28
+ const page = await fetchPage(offset);
29
+ if (
30
+ hasSameDomainCoworker(
31
+ ownerEmail,
32
+ page.members.map((member) => member.email),
33
+ )
34
+ ) {
35
+ return true;
36
+ }
37
+ if (!page.hasMore) return false;
38
+ if (page.nextOffset === null || page.nextOffset <= offset) {
39
+ throw new Error("Organization member search returned an invalid offset");
40
+ }
41
+ offset = page.nextOffset;
42
+ }
43
+ }
@@ -5,7 +5,11 @@ import {
5
5
  useAgentEngineConfigured,
6
6
  type AgentSidebarStateChangeDetail,
7
7
  } from "@agent-native/core/client/agent-chat";
8
- import { track, trackEvent } from "@agent-native/core/client/analytics";
8
+ import {
9
+ track,
10
+ trackAnonymousEvent,
11
+ trackEvent,
12
+ } from "@agent-native/core/client/analytics";
9
13
  import { appPath, agentNativePath } from "@agent-native/core/client/api-path";
10
14
  import { writeClipboardText } from "@agent-native/core/client/clipboard";
11
15
  import { emailToColor, emailToName } from "@agent-native/core/client/collab";
@@ -24,13 +28,19 @@ import {
24
28
  useAcceptInvitation,
25
29
  useJoinByDomain,
26
30
  useOrg,
31
+ useOrgRole,
32
+ useSetOrgDomain,
27
33
  } from "@agent-native/core/client/org";
28
- import { ShareButton } from "@agent-native/core/client/sharing";
34
+ import {
35
+ fetchOrgMemberPage,
36
+ ShareButton,
37
+ } from "@agent-native/core/client/sharing";
29
38
  import {
30
39
  buildSignInReturnHref,
31
40
  ErrorReportActions,
32
41
  type ErrorReportDebugItem,
33
42
  } from "@agent-native/core/client/ui";
43
+ import { isFreeEmailProvider } from "@agent-native/core/org/free-email-providers";
34
44
  import { docsUrl } from "@agent-native/core/shared";
35
45
  import {
36
46
  useSetHeaderActions,
@@ -190,6 +200,7 @@ import { Input } from "@/components/ui/input";
190
200
  import { Label } from "@/components/ui/label";
191
201
  import {
192
202
  Popover,
203
+ PopoverAnchor,
193
204
  PopoverContent,
194
205
  PopoverTrigger,
195
206
  } from "@/components/ui/popover";
@@ -285,6 +296,7 @@ import {
285
296
  type CommentDraft,
286
297
  } from "@/lib/plan-comment-editor-helpers";
287
298
  import { planDocumentTitle } from "@/lib/plan-document-title";
299
+ import { hasSameDomainCoworkerInPages } from "@/lib/plan-invite-suggestion";
288
300
  import {
289
301
  fetchLocalPlanBridgeComments,
290
302
  fetchLocalPlanBridgeBundle,
@@ -2022,6 +2034,9 @@ export function PlansPage({ localPlanSlug }: { localPlanSlug?: string } = {}) {
2022
2034
  );
2023
2035
  const [agentSidebarOpen, setAgentSidebarOpen] = useState(false);
2024
2036
  const [sendingFeedback, setSendingFeedback] = useState(false);
2037
+ const [planShareSucceededId, setPlanShareSucceededId] = useState<
2038
+ string | null
2039
+ >(null);
2025
2040
  const [localBridgeCommentPending, setLocalBridgeCommentPending] =
2026
2041
  useState(false);
2027
2042
  const [pendingAnnotation, setPendingAnnotation] =
@@ -5041,6 +5056,10 @@ export function PlansPage({ localPlanSlug }: { localPlanSlug?: string } = {}) {
5041
5056
  localShareUrl={planShareUrl}
5042
5057
  hostedPlanId={bundle.plan.hostedPlanId}
5043
5058
  hostedPlanUrl={bundle.plan.hostedPlanUrl}
5059
+ firstShare={planShareSucceededId === bundle.plan.id}
5060
+ onShareSuccess={() =>
5061
+ setPlanShareSucceededId(bundle.plan.id)
5062
+ }
5044
5063
  onOpenChange={(open) => {
5045
5064
  if (open) closeInlineComment();
5046
5065
  }}
@@ -6152,6 +6171,8 @@ function PlanShareControl({
6152
6171
  localShareUrl,
6153
6172
  hostedPlanId,
6154
6173
  hostedPlanUrl,
6174
+ firstShare = false,
6175
+ onShareSuccess,
6155
6176
  onOpenChange,
6156
6177
  }: {
6157
6178
  planId: string;
@@ -6160,6 +6181,8 @@ function PlanShareControl({
6160
6181
  localShareUrl?: string;
6161
6182
  hostedPlanId?: string | null;
6162
6183
  hostedPlanUrl?: string | null;
6184
+ firstShare?: boolean;
6185
+ onShareSuccess?: () => void;
6163
6186
  onOpenChange?: (open: boolean) => void;
6164
6187
  }) {
6165
6188
  const t = useT();
@@ -6254,6 +6277,7 @@ function PlanShareControl({
6254
6277
  url: result.hostedPlanUrl ?? result.url,
6255
6278
  hostedPlanId: result.hostedPlanId,
6256
6279
  });
6280
+ onShareSuccess?.();
6257
6281
  setAuthPrompt(null);
6258
6282
  // Tag the freshly-minted public link so signups from it are
6259
6283
  // attributed. The publisher is the owner, so `via` is their userId.
@@ -6268,12 +6292,12 @@ function PlanShareControl({
6268
6292
  },
6269
6293
  },
6270
6294
  );
6271
- }, [copyPublishedUrl, planId, publishPlan, session?.userId]);
6295
+ }, [copyPublishedUrl, onShareSuccess, planId, publishPlan, session?.userId]);
6272
6296
 
6273
6297
  // Logged-in / local-dev: manage shares for the plan in this app instance.
6274
6298
  if (canManageLocalShares) {
6275
6299
  if (!managedShareUrl) return null;
6276
- return (
6300
+ const shareButton = (
6277
6301
  <ShareButton
6278
6302
  resourceType="plan"
6279
6303
  resourceId={managedShareResourceId}
@@ -6294,8 +6318,20 @@ function PlanShareControl({
6294
6318
  visibilityCopy={buildShareVisibilityCopy(t, noun)}
6295
6319
  triggerClassName="pointer-events-auto h-8 px-2"
6296
6320
  onOpenChange={onOpenChange}
6321
+ onShareSuccess={onShareSuccess}
6297
6322
  />
6298
6323
  );
6324
+ return session?.userId ? (
6325
+ <PlanInviteSuggestion
6326
+ key={session.userId}
6327
+ userId={session.userId}
6328
+ firstShare={firstShare}
6329
+ >
6330
+ {shareButton}
6331
+ </PlanInviteSuggestion>
6332
+ ) : (
6333
+ shareButton
6334
+ );
6299
6335
  }
6300
6336
 
6301
6337
  // No account yet: publish-to-share step, anchored to the Share button.
@@ -6427,6 +6463,215 @@ function PlanShareControl({
6427
6463
  );
6428
6464
  }
6429
6465
 
6466
+ function PlanInviteSuggestion({
6467
+ userId,
6468
+ firstShare,
6469
+ children,
6470
+ }: {
6471
+ userId: string;
6472
+ firstShare: boolean;
6473
+ children: ReactNode;
6474
+ }) {
6475
+ const { org, isOwner, canInviteMembers, isLoading } = useOrgRole();
6476
+ const email = org?.email ?? "";
6477
+ const emailParts = email.trim().toLowerCase().split("@");
6478
+ const domain = emailParts[emailParts.length - 1] ?? "";
6479
+ const canOfferDomainJoin =
6480
+ isOwner &&
6481
+ !org?.allowedDomain &&
6482
+ domain.length > 0 &&
6483
+ !isFreeEmailProvider(domain);
6484
+
6485
+ if (isLoading) return <div className="inline-flex">{children}</div>;
6486
+ if (!canInviteMembers) return <div className="inline-flex">{children}</div>;
6487
+
6488
+ if (canOfferDomainJoin) {
6489
+ return (
6490
+ <PlanDomainInviteSuggestion
6491
+ userId={userId}
6492
+ orgId={org?.orgId ?? ""}
6493
+ email={email}
6494
+ domain={domain}
6495
+ firstShare={firstShare}
6496
+ >
6497
+ {children}
6498
+ </PlanDomainInviteSuggestion>
6499
+ );
6500
+ }
6501
+
6502
+ return (
6503
+ <PlanInviteSuggestionCard
6504
+ userId={userId}
6505
+ firstShare={firstShare}
6506
+ domain={null}
6507
+ >
6508
+ {children}
6509
+ </PlanInviteSuggestionCard>
6510
+ );
6511
+ }
6512
+
6513
+ function PlanDomainInviteSuggestion({
6514
+ userId,
6515
+ orgId,
6516
+ email,
6517
+ domain,
6518
+ firstShare,
6519
+ children,
6520
+ }: {
6521
+ userId: string;
6522
+ orgId: string;
6523
+ email: string;
6524
+ domain: string;
6525
+ firstShare: boolean;
6526
+ children: ReactNode;
6527
+ }) {
6528
+ const membersQuery = useQuery({
6529
+ queryKey: ["plan-domain-coworker", orgId, email.toLowerCase(), domain],
6530
+ queryFn: ({ signal }) =>
6531
+ hasSameDomainCoworkerInPages(email, (offset) =>
6532
+ fetchOrgMemberPage({ search: domain, limit: 100, offset, signal }),
6533
+ ),
6534
+ enabled: Boolean(orgId),
6535
+ });
6536
+
6537
+ return (
6538
+ <PlanInviteSuggestionCard
6539
+ userId={userId}
6540
+ firstShare={firstShare}
6541
+ domain={membersQuery.data ? domain : null}
6542
+ >
6543
+ {children}
6544
+ </PlanInviteSuggestionCard>
6545
+ );
6546
+ }
6547
+
6548
+ function PlanInviteSuggestionCard({
6549
+ userId,
6550
+ firstShare,
6551
+ domain,
6552
+ children,
6553
+ }: {
6554
+ userId: string;
6555
+ firstShare: boolean;
6556
+ domain: string | null;
6557
+ children: ReactNode;
6558
+ }) {
6559
+ const t = useT();
6560
+ const navigate = useNavigate();
6561
+ const setOrgDomain = useSetOrgDomain();
6562
+ const reason = firstShare
6563
+ ? "first_share"
6564
+ : domain
6565
+ ? "same_domain_coworkers"
6566
+ : null;
6567
+ const storageKey = `plan.invite-suggestion.shown.v1.${userId}`;
6568
+ const shownRef = useRef(false);
6569
+ const actionCloseRef = useRef(false);
6570
+ const [visible, setVisible] = useState(false);
6571
+
6572
+ useEffect(() => {
6573
+ if (typeof window === "undefined" || shownRef.current || !reason) return;
6574
+ try {
6575
+ if (window.localStorage.getItem(storageKey)) {
6576
+ shownRef.current = true;
6577
+ return;
6578
+ }
6579
+ window.localStorage.setItem(storageKey, "1");
6580
+ } catch (error) {
6581
+ console.warn(
6582
+ "Plan invite suggestion skipped because local storage is unavailable.",
6583
+ error,
6584
+ );
6585
+ return;
6586
+ }
6587
+ shownRef.current = true;
6588
+ setVisible(true);
6589
+ trackAnonymousEvent("plan_invite_suggestion_shown", { trigger: reason });
6590
+ }, [reason, storageKey]);
6591
+
6592
+ const trackAction = (event: string, action?: string) => {
6593
+ if (!reason) return;
6594
+ trackAnonymousEvent(event, {
6595
+ trigger: reason,
6596
+ ...(action ? { action } : {}),
6597
+ });
6598
+ };
6599
+
6600
+ const inviteTeammates = () => {
6601
+ trackAction("plan_invite_suggestion_clicked", "invite_teammates");
6602
+ trackAction("plan_invite_suggestion_accepted", "invite_teammates");
6603
+ actionCloseRef.current = true;
6604
+ setVisible(false);
6605
+ navigate("/settings#team");
6606
+ };
6607
+
6608
+ const enableDomainJoin = async () => {
6609
+ if (!domain || setOrgDomain.isPending) return;
6610
+ trackAction("plan_invite_suggestion_clicked", "enable_domain_join");
6611
+ try {
6612
+ await setOrgDomain.mutateAsync(domain);
6613
+ } catch {
6614
+ toast.error(t("plansPage.share.teammateSuggestion.enableFailed"));
6615
+ return;
6616
+ }
6617
+ trackAction("plan_invite_suggestion_accepted", "enable_domain_join");
6618
+ actionCloseRef.current = true;
6619
+ setVisible(false);
6620
+ };
6621
+
6622
+ return (
6623
+ <Popover
6624
+ open={visible}
6625
+ onOpenChange={(open) => {
6626
+ if (!open && visible) {
6627
+ if (!actionCloseRef.current) {
6628
+ trackAction("plan_invite_suggestion_dismissed");
6629
+ }
6630
+ actionCloseRef.current = false;
6631
+ }
6632
+ setVisible(open);
6633
+ }}
6634
+ >
6635
+ <PopoverAnchor asChild>
6636
+ <div className="inline-flex">{children}</div>
6637
+ </PopoverAnchor>
6638
+ {visible && (
6639
+ <PopoverContent
6640
+ align="end"
6641
+ side="bottom"
6642
+ sideOffset={8}
6643
+ className="flex w-[min(360px,calc(100vw-1.5rem))] flex-wrap items-center gap-2"
6644
+ >
6645
+ <p className="px-1 text-xs text-muted-foreground">
6646
+ {t("plansPage.share.teammateSuggestion.message")}
6647
+ </p>
6648
+ <Button
6649
+ type="button"
6650
+ size="sm"
6651
+ variant="ghost"
6652
+ onClick={inviteTeammates}
6653
+ >
6654
+ {t("plansPage.share.teammateSuggestion.invite")}
6655
+ </Button>
6656
+ {domain && (
6657
+ <Button
6658
+ type="button"
6659
+ size="sm"
6660
+ variant="outline"
6661
+ onClick={enableDomainJoin}
6662
+ disabled={setOrgDomain.isPending}
6663
+ >
6664
+ {t("plansPage.share.teammateSuggestion.enableDomain", {
6665
+ domain,
6666
+ })}
6667
+ </Button>
6668
+ )}
6669
+ </PopoverContent>
6670
+ )}
6671
+ </Popover>
6672
+ );
6673
+ }
6674
+
6430
6675
  function PlanSkeleton({ isRecap = false }: { isRecap?: boolean }) {
6431
6676
  const t = useT();
6432
6677
  const loadingLabel = isRecap
@@ -440,6 +440,16 @@ export default defineAction({
440
440
  aspectRatio: aspectRatio ?? prevData.aspectRatio,
441
441
  designSystemId: designSystemId ?? prevData.designSystemId,
442
442
  creativeContext: creativeContextProvenance,
443
+ ...(actionOwnsGenerationLifecycle
444
+ ? {
445
+ generationContext: incrementalGeneration
446
+ ? {
447
+ generationAttemptId,
448
+ generationMode: "action",
449
+ }
450
+ : undefined,
451
+ }
452
+ : {}),
443
453
  };
444
454
  await db.transaction(async (tx: any) => {
445
455
  await createDeckVersionSnapshot(
@@ -584,7 +594,7 @@ export default defineAction({
584
594
  slides,
585
595
  createdAt: now,
586
596
  updatedAt: now,
587
- ...(incrementalGeneration
597
+ ...(actionOwnsGenerationLifecycle && incrementalGeneration
588
598
  ? {
589
599
  generationContext: {
590
600
  generationAttemptId,
@@ -1,3 +1,4 @@
1
+ import { captureError } from "@agent-native/core/client/analytics";
1
2
  import { useT } from "@agent-native/core/client/i18n";
2
3
  import {
3
4
  useState,
@@ -22,7 +23,11 @@ import {
22
23
  sanitizeSlideHtml,
23
24
  sanitizeSlideUrl,
24
25
  } from "@/lib/sanitize-slide-html";
25
- import { swapImageSourcesInPlace } from "@/lib/slide-image-replacement";
26
+ import {
27
+ swapImageSourcesInPlace,
28
+ takeSlideImageUploadProvenance,
29
+ updateLiveImagesUnderEdit,
30
+ } from "@/lib/slide-image-replacement";
26
31
  import {
27
32
  stampSlideSource,
28
33
  type RenderedSlideSource,
@@ -863,6 +868,42 @@ function loadImportedFonts(hrefs: string[]) {
863
868
  }
864
869
 
865
870
  const renderedSlideSources = new WeakMap<HTMLElement, RenderedSlideSource>();
871
+ const pendingSlideEditDrafts = new WeakMap<
872
+ HTMLElement,
873
+ Array<{ nonce: string; content: string }>
874
+ >();
875
+ const MAX_PENDING_SLIDE_EDIT_DRAFTS = 8;
876
+
877
+ // ponytail: cap delayed echoes at 8 drafts per canvas; raise it only if ordering proves insufficient.
878
+ export function noteSlideEditDraft(
879
+ root: HTMLElement,
880
+ nonce: string,
881
+ content: string,
882
+ ) {
883
+ const drafts = pendingSlideEditDrafts.get(root) ?? [];
884
+ const duplicate = drafts.findIndex(
885
+ (draft) => draft.nonce === nonce && draft.content === content,
886
+ );
887
+ if (duplicate !== -1) drafts.splice(duplicate, 1);
888
+ drafts.push({ nonce, content });
889
+ if (drafts.length > MAX_PENDING_SLIDE_EDIT_DRAFTS) drafts.shift();
890
+ pendingSlideEditDrafts.set(root, drafts);
891
+ }
892
+
893
+ function consumeSlideEditDraft(
894
+ root: HTMLElement,
895
+ nonce: string,
896
+ content: string,
897
+ ) {
898
+ const drafts = pendingSlideEditDrafts.get(root);
899
+ const index =
900
+ drafts?.findIndex(
901
+ (draft) => draft.nonce === nonce && draft.content === content,
902
+ ) ?? -1;
903
+ if (!drafts || index < 0) return false;
904
+ drafts.splice(index, 1);
905
+ return true;
906
+ }
866
907
 
867
908
  /**
868
909
  * What a stamped `.slide-content` root was rendered from. Undefined for roots
@@ -874,6 +915,24 @@ export function getRenderedSlideSource(
874
915
  return renderedSlideSources.get(root);
875
916
  }
876
917
 
918
+ /**
919
+ * Dispatched (bubbling) on a `.slide-content` root that holds an open text
920
+ * edit, right before other HTML replaces it: another slide's, or a newer
921
+ * version of this one. The editor must end and save the edit synchronously;
922
+ * a root still being edited is not replaced.
923
+ */
924
+ export const SLIDE_CONTENT_REPLACE_EVENT = "slides:before-content-replace";
925
+
926
+ /**
927
+ * The event's detail when the incoming HTML is a newer version of the edited
928
+ * slide: its stored source, which the edit must be saved on top of.
929
+ */
930
+ export interface SlideContentReplaceDetail {
931
+ content: string;
932
+ }
933
+
934
+ const EDITING_SELECTOR = '[contenteditable="true"]';
935
+
877
936
  function registerRenderedSlideSource(
878
937
  root: HTMLElement,
879
938
  source: RenderedSlideSource | null,
@@ -950,11 +1009,13 @@ export function renderRawSlideHtml(
950
1009
  function RawSlideHtmlContent({
951
1010
  html,
952
1011
  scopeId,
1012
+ slideId,
953
1013
  source,
954
1014
  mermaidBlocks,
955
1015
  }: {
956
1016
  html: string;
957
1017
  scopeId: string;
1018
+ slideId: string;
958
1019
  source: RenderedSlideSource | null;
959
1020
  mermaidBlocks: string[];
960
1021
  }) {
@@ -967,6 +1028,57 @@ function RawSlideHtmlContent({
967
1028
  const root = contentRef.current;
968
1029
  if (!root) return;
969
1030
  if (renderedHtmlRef.current !== html) {
1031
+ const currentSource = getRenderedSlideSource(root);
1032
+ const sameSlide = currentSource?.nonce === source?.nonce;
1033
+ const isEditorDraftEcho =
1034
+ sameSlide &&
1035
+ source &&
1036
+ consumeSlideEditDraft(root, source.nonce, source.stored);
1037
+ if (isEditorDraftEcho && source && root.querySelector(EDITING_SELECTOR)) {
1038
+ renderedHtmlRef.current = html;
1039
+ registerRenderedSlideSource(root, source);
1040
+ return;
1041
+ }
1042
+ const uploadProvenance = source
1043
+ ? takeSlideImageUploadProvenance(slideId, source.stored)
1044
+ : null;
1045
+ if (root.querySelector(EDITING_SELECTOR)) {
1046
+ // Preserve the live draft only for this upload's exact edited-node
1047
+ // snapshot; a newer same-slide write must commit and rebase the edit.
1048
+ if (
1049
+ sameSlide &&
1050
+ source &&
1051
+ updateLiveImagesUnderEdit(
1052
+ root,
1053
+ renderedHtmlRef.current,
1054
+ html,
1055
+ uploadProvenance,
1056
+ )
1057
+ ) {
1058
+ renderedHtmlRef.current = html;
1059
+ registerRenderedSlideSource(root, source);
1060
+ return;
1061
+ }
1062
+ const detail: SlideContentReplaceDetail | null =
1063
+ sameSlide && source ? { content: source.stored } : null;
1064
+ root.dispatchEvent(
1065
+ new CustomEvent(SLIDE_CONTENT_REPLACE_EVENT, {
1066
+ bubbles: true,
1067
+ detail,
1068
+ }),
1069
+ );
1070
+ }
1071
+ if (root.querySelector(EDITING_SELECTOR)) {
1072
+ // Rewriting the root would destroy the live edit's DOM and its caret.
1073
+ // Every content write during an edit commits the edit first, so this
1074
+ // is a missed commit, not something to paper over.
1075
+ const error = new Error(
1076
+ "[slides] refused to re-render a slide while its text is being edited",
1077
+ );
1078
+ console.error(error);
1079
+ captureError(error, { tags: { area: "slides-save-boundary" } });
1080
+ return;
1081
+ }
970
1082
  // Keep the live image node for upload-only changes so pointer-driven transforms survive.
971
1083
  if (!swapImageSourcesInPlace(root, renderedHtmlRef.current, html)) {
972
1084
  root.innerHTML = html;
@@ -1017,9 +1129,11 @@ function RawSlideHtmlContent({
1017
1129
 
1018
1130
  function BlankSlideContent({
1019
1131
  content,
1132
+ slideId,
1020
1133
  stampNonce,
1021
1134
  }: {
1022
1135
  content: string;
1136
+ slideId: string;
1023
1137
  stampNonce?: string;
1024
1138
  }) {
1025
1139
  const scopeId = `slide-${useId().replace(/[^a-zA-Z0-9_-]/g, "")}`;
@@ -1054,6 +1168,7 @@ function BlankSlideContent({
1054
1168
  <RawSlideHtmlContent
1055
1169
  html={htmlWithPlaceholders}
1056
1170
  scopeId={scopeId}
1171
+ slideId={slideId}
1057
1172
  source={source}
1058
1173
  mermaidBlocks={mermaidBlocks}
1059
1174
  />
@@ -1320,6 +1435,7 @@ export function SlideInner({
1320
1435
  >
1321
1436
  <BlankSlideContent
1322
1437
  content={content}
1438
+ slideId={slide.id}
1323
1439
  stampNonce={stampSource ? slide.id : undefined}
1324
1440
  />
1325
1441
  </AutoFitContent>