@kortix/ui 0.15.0 → 0.15.2

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 (220) hide show
  1. package/dist/_vendor/kortix-shared.js +233 -130
  2. package/dist/_vendor/shared/code-language.d.ts +2 -2
  3. package/dist/_vendor/shared/html.d.ts +7 -0
  4. package/dist/_vendor/shared/index.d.ts +1 -2
  5. package/dist/_vendor/shared/pixel-mark.d.ts +28 -0
  6. package/dist/_vendor/shared/runtime-versions.d.ts +2 -6
  7. package/dist/_vendor/shared/tool-output/media-path.d.ts +1 -6
  8. package/dist/_vendor/shared/tool-output/scan.d.ts +2 -0
  9. package/dist/_vendor/shared/utils/string.d.ts +6 -0
  10. package/dist/artifacts/artifact-frame.d.ts +0 -1
  11. package/dist/artifacts/artifact-frame.js +4 -10
  12. package/dist/artifacts/artifact-session.js +4 -7
  13. package/dist/artifacts/frame-policy.d.ts +1 -1
  14. package/dist/artifacts/frame-policy.js +2 -2
  15. package/dist/customize/agents/agent-page.js +5 -5
  16. package/dist/customize/agents/agent-status.js +1 -1
  17. package/dist/customize/agents/agents-page.js +3 -3
  18. package/dist/customize/connectors/use-agent-access.d.ts +3 -3
  19. package/dist/customize/sections/connectors-view.js +50 -37
  20. package/dist/customize/sections/llm-provider/chatgpt-subscription-connect.js +21 -18
  21. package/dist/customize/sections/llm-provider/device-grant.d.ts +15 -0
  22. package/dist/customize/sections/llm-provider/device-grant.js +27 -0
  23. package/dist/customize/sections/view/agent-editor-catalog.js +0 -5
  24. package/dist/customize/sections/view/agent-editor.d.ts +2 -2
  25. package/dist/customize/sections/view/agent-editor.js +2 -2
  26. package/dist/customize/sections/view/review-center-connected.js +37 -6
  27. package/dist/customize/sections/view/secret-delivery.d.ts +4 -5
  28. package/dist/customize/sections/view/secret-delivery.js +5 -4
  29. package/dist/customize/triggers/schedule/trigger-list.d.ts +2 -2
  30. package/dist/customize/triggers/schedule/trigger-list.js +12 -18
  31. package/dist/customize/triggers/schedule/trigger-runs-logic.d.ts +6 -0
  32. package/dist/customize/triggers/schedule/trigger-runs-logic.js +13 -0
  33. package/dist/customize/triggers/schedule/trigger-runs-panel.js +9 -2
  34. package/dist/files/project/api/runtime-files.d.ts +2 -2
  35. package/dist/files/project/api/runtime-files.js +2 -2
  36. package/dist/files/project/components/drive-explorer.js +1 -1
  37. package/dist/files/project/components/drive-grid-view.js +0 -1
  38. package/dist/files/project/components/drive-list-view.js +0 -1
  39. package/dist/files/project/components/file-explorer-page.js +1 -1
  40. package/dist/files/project/hooks/index.d.ts +1 -1
  41. package/dist/files/project/hooks/index.js +1 -1
  42. package/dist/files/project/hooks/use-server-health.d.ts +1 -1
  43. package/dist/files/project/hooks/use-server-health.js +1 -1
  44. package/dist/files/project/search/workspace-search-service.d.ts +1 -1
  45. package/dist/files/project/search/workspace-search-service.js +1 -1
  46. package/dist/files/runtime/hooks/index.d.ts +1 -1
  47. package/dist/files/runtime/hooks/index.js +1 -1
  48. package/dist/files/runtime/hooks/server-health-state.d.ts +2 -2
  49. package/dist/files/runtime/hooks/server-health-state.js +2 -2
  50. package/dist/files/runtime/hooks/system-dir.js +2 -2
  51. package/dist/files/runtime/hooks/use-file-content.d.ts +1 -1
  52. package/dist/files/runtime/hooks/use-file-content.js +1 -1
  53. package/dist/files/runtime/hooks/use-file-list.d.ts +1 -1
  54. package/dist/files/runtime/hooks/use-file-list.js +3 -3
  55. package/dist/files/runtime/hooks/use-server-health.d.ts +2 -2
  56. package/dist/files/runtime/hooks/use-server-health.js +3 -3
  57. package/dist/files/runtime/hooks/use-workspace-search.d.ts +1 -2
  58. package/dist/files/runtime/hooks/use-workspace-search.js +0 -1
  59. package/dist/files/runtime/index.d.ts +2 -2
  60. package/dist/files/runtime/index.js +2 -2
  61. package/dist/files/runtime/path-utils.d.ts +1 -1
  62. package/dist/files/runtime/path-utils.js +1 -1
  63. package/dist/files/runtime/sandbox-explorer-source.d.ts +1 -1
  64. package/dist/files/runtime/sandbox-explorer-source.js +1 -1
  65. package/dist/files/runtime/sandbox-file-explorer.d.ts +1 -1
  66. package/dist/files/runtime/sandbox-file-explorer.js +2 -2
  67. package/dist/files/tree/components/file-tree-item.js +0 -1
  68. package/dist/files/tree/hooks/use-file-events.d.ts +1 -1
  69. package/dist/files/tree/hooks/use-file-events.js +1 -1
  70. package/dist/i18n/en.d.ts +60 -175
  71. package/dist/i18n/en.js +71 -186
  72. package/dist/internal/components/agent-mark.js +6 -0
  73. package/dist/internal/components/clickable-path.d.ts +3 -0
  74. package/dist/internal/components/clickable-path.js +4 -1
  75. package/dist/internal/files/file-read-retry.js +1 -1
  76. package/dist/internal/files/types.d.ts +2 -2
  77. package/dist/internal/files/types.js +2 -2
  78. package/dist/internal/goals/goal-meta.d.ts +33 -14
  79. package/dist/internal/goals/goal-meta.js +55 -13
  80. package/dist/internal/layout/nav-hover-card.d.ts +1 -1
  81. package/dist/internal/layout/nav-hover-card.js +1 -1
  82. package/dist/internal/layout/project-capability-nav.d.ts +1 -1
  83. package/dist/internal/layout/project-capability-nav.js +1 -1
  84. package/dist/internal/lib/browser-error-noise.d.ts +1 -1
  85. package/dist/internal/lib/browser-error-noise.js +1 -1
  86. package/dist/internal/lib/browser-noise/rules/expected-states.js +1 -1
  87. package/dist/internal/lib/browser-noise/rules/injected-scripts.js +29 -0
  88. package/dist/internal/lib/browser-noise/rules/old-browsers.d.ts +1 -0
  89. package/dist/internal/lib/browser-noise/rules/old-browsers.js +1 -1
  90. package/dist/internal/lib/browser-noise/rules/rejections.d.ts +0 -9
  91. package/dist/internal/lib/browser-noise/rules/rejections.js +0 -14
  92. package/dist/internal/lib/delivered-but-disconnected.js +3 -5
  93. package/dist/internal/lib/error-handler.js +8 -3
  94. package/dist/internal/lib/pixel-mark.d.ts +4 -17
  95. package/dist/internal/lib/pixel-mark.js +5 -148
  96. package/dist/internal/lib/sounds.d.ts +4 -4
  97. package/dist/internal/lib/sounds.js +4 -4
  98. package/dist/internal/lib/trigger-clock.d.ts +5 -0
  99. package/dist/internal/lib/trigger-clock.js +15 -0
  100. package/dist/internal/lib/turn-broadcast.d.ts +0 -3
  101. package/dist/internal/lib/use-project-feature-flags.d.ts +2 -0
  102. package/dist/internal/lib/use-project-feature-flags.js +5 -5
  103. package/dist/internal/lib/web-notifications.d.ts +1 -8
  104. package/dist/internal/lib/web-notifications.js +12 -53
  105. package/dist/internal/notifications/notification-bell.d.ts +13 -33
  106. package/dist/internal/notifications/notification-bell.js +14 -117
  107. package/dist/internal/notifications/notification-inbox.d.ts +45 -0
  108. package/dist/internal/notifications/notification-inbox.js +119 -0
  109. package/dist/internal/notifications/notification-rows.d.ts +3 -4
  110. package/dist/internal/notifications/notification-rows.js +1 -4
  111. package/dist/internal/notifications/use-inbox-summary.d.ts +13 -0
  112. package/dist/internal/notifications/use-inbox-summary.js +22 -0
  113. package/dist/internal/notifications/web-push.d.ts +9 -10
  114. package/dist/internal/notifications/web-push.js +9 -10
  115. package/dist/internal/stores/composer-prefill-store.js +4 -1
  116. package/dist/internal/stores/sound-store.d.ts +4 -4
  117. package/dist/internal/stores/sound-store.js +10 -0
  118. package/dist/internal/stores/web-notification-store.d.ts +6 -9
  119. package/dist/internal/stores/web-notification-store.js +0 -4
  120. package/dist/lib/routes.d.ts +8 -0
  121. package/dist/lib/routes.js +4 -1
  122. package/dist/markdown/code/shiki-highlighter.js +14 -5
  123. package/dist/markdown/doc-editor/doc-menus.d.ts +1 -10
  124. package/dist/markdown/doc-editor/doc-menus.js +6 -69
  125. package/dist/markdown/file-links.js +33 -3
  126. package/dist/markdown/markdown-frontmatter.d.ts +6 -6
  127. package/dist/markdown/markdown-frontmatter.js +3 -3
  128. package/dist/primitives/button.d.ts +1 -1
  129. package/dist/primitives/button.js +2 -1
  130. package/dist/session/agents/held-messages.d.ts +1 -5
  131. package/dist/session/agents/held-messages.js +1 -21
  132. package/dist/session/composer/ComposerAboveCard.d.ts +4 -1
  133. package/dist/session/composer/ComposerAboveCard.js +2 -2
  134. package/dist/session/composer/composer-chat-input.d.ts +1 -1
  135. package/dist/session/composer/composer-chat-input.js +2 -2
  136. package/dist/session/composer/composer.js +16 -1
  137. package/dist/session/composer/hooks/use-file-search.d.ts +15 -15
  138. package/dist/session/composer/hooks/use-file-search.js +16 -16
  139. package/dist/session/composer/menus/mention-controller.js +1 -3
  140. package/dist/session/composer/menus/space-mentions.d.ts +14 -4
  141. package/dist/session/composer/menus/space-mentions.js +17 -1
  142. package/dist/session/composer/use-instant-session-send.js +2 -2
  143. package/dist/session/header/reminder-parts.d.ts +1 -1
  144. package/dist/session/header/session-goal-indicator.js +4 -4
  145. package/dist/session/header/session-site-header.js +2 -6
  146. package/dist/session/panel/easy/plan-card.d.ts +2 -2
  147. package/dist/session/panel/easy/plan-card.js +2 -2
  148. package/dist/session/panel/session-desktop.js +6 -0
  149. package/dist/session/panel/session-reminders-panel.js +4 -15
  150. package/dist/session/panel/use-session-panel-state.js +2 -2
  151. package/dist/session/status/sandbox-loading-boundary.js +2 -2
  152. package/dist/session/status/session-terminal-state.d.ts +47 -0
  153. package/dist/session/status/session-terminal-state.js +56 -0
  154. package/dist/session/thread/plan-surface.d.ts +1 -1
  155. package/dist/session/thread/plan-surface.js +1 -1
  156. package/dist/session/thread/session-chat.d.ts +1 -1
  157. package/dist/session/thread/session-chat.js +88 -99
  158. package/dist/session/thread/stop-sequence.d.ts +51 -0
  159. package/dist/session/thread/stop-sequence.js +55 -0
  160. package/dist/session/thread/transcript.d.ts +2 -2
  161. package/dist/session/thread/transcript.js +2 -2
  162. package/dist/session/tool/tools/apply-patch-tool.d.ts +1 -1
  163. package/dist/session/tool/tools/apply-patch-tool.js +1 -1
  164. package/dist/session/tool/tools/kortix-action-tool.js +1 -1
  165. package/dist/session/tool/tools/multi-agent-tool-bodies.d.ts +1 -1
  166. package/dist/session/tool/tools/multi-agent-tool-bodies.js +1 -1
  167. package/dist/session/tool/tools/multi-agent-tools.js +1 -1
  168. package/dist/session/tool/tools/pty-kill-tool.d.ts +1 -1
  169. package/dist/session/tool/tools/pty-kill-tool.js +1 -1
  170. package/dist/session/tool/tools/pty-read-tool.d.ts +2 -2
  171. package/dist/session/tool/tools/pty-read-tool.js +2 -2
  172. package/dist/session/tool/tools/pty-spawn-tool.d.ts +1 -1
  173. package/dist/session/tool/tools/pty-spawn-tool.js +1 -1
  174. package/dist/session/tool/tools/pty-write-tool.d.ts +1 -1
  175. package/dist/session/tool/tools/pty-write-tool.js +1 -1
  176. package/dist/session/tool/tools/session-spawn-tool.js +7 -4
  177. package/dist/session/tool/tools/task-tool.js +18 -4
  178. package/dist/session/tool/tools/todo-write-tool.d.ts +1 -1
  179. package/dist/session/tool/tools/todo-write-tool.js +1 -1
  180. package/dist/session/turn/peer-message-row.d.ts +1 -10
  181. package/dist/session/turn/peer-message-row.js +1 -18
  182. package/dist/session/turn/plan-anchor.d.ts +3 -3
  183. package/dist/session/turn/plan-anchor.js +3 -3
  184. package/dist/session/turn/plan-card.d.ts +7 -7
  185. package/dist/session/turn/plan-card.js +7 -7
  186. package/dist/styles.css +1 -1
  187. package/dist/terminal/terminal-card-gate.d.ts +6 -3
  188. package/dist/terminal/terminal-card-gate.js +21 -4
  189. package/dist/workspace/home/access-requests-bell.d.ts +6 -9
  190. package/dist/workspace/home/access-requests-bell.js +8 -10
  191. package/dist/workspace/index.d.ts +1 -1
  192. package/dist/workspace/index.js +1 -1
  193. package/dist/workspace/layout/project-home.js +1 -2
  194. package/dist/workspace/review/review-center.d.ts +8 -2
  195. package/dist/workspace/review/review-center.js +44 -13
  196. package/dist/workspace/review/review-reducer.d.ts +7 -0
  197. package/dist/workspace/review/review-reducer.js +11 -0
  198. package/dist/workspace/sidebar/footer/project-artifacts-nav.d.ts +6 -1
  199. package/dist/workspace/sidebar/footer/project-artifacts-nav.js +47 -4
  200. package/dist/workspace/sidebar/project-nav-items.js +11 -12
  201. package/dist/workspace/sidebar/project-sidebar.js +2 -6
  202. package/dist/workspace/spaces/principal-card.d.ts +3 -1
  203. package/dist/workspace/spaces/principal-card.js +3 -3
  204. package/dist/workspace/spaces/space-agent-ask.d.ts +14 -0
  205. package/dist/workspace/spaces/space-agent-ask.js +36 -0
  206. package/dist/workspace/spaces/space-details-dialog.js +1 -1
  207. package/dist/workspace/spaces/space-details-panel.d.ts +2 -1
  208. package/dist/workspace/spaces/space-details-panel.js +62 -8
  209. package/dist/workspace/spaces/space-mention-source.d.ts +3 -2
  210. package/dist/workspace/spaces/space-mention-source.js +12 -19
  211. package/dist/workspace/spaces/space-view.js +3 -2
  212. package/package.json +11 -7
  213. package/skills/kortix-ui/references/custom-dashboard.md +1 -1
  214. package/skills/kortix-ui/references/modules.md +1 -1
  215. package/dist/_vendor/shared/artifact-annotations.d.ts +0 -311
  216. package/dist/_vendor/shared/artifact-comments.d.ts +0 -155
  217. package/dist/internal/hooks/use-notification-center.d.ts +0 -50
  218. package/dist/internal/hooks/use-notification-center.js +0 -151
  219. package/dist/session/tool/tools/multi-agent-tool-data.d.ts +0 -63
  220. package/dist/session/tool/tools/multi-agent-tool-data.js +0 -118
@@ -0,0 +1,119 @@
1
+ 'use client';
2
+ import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
3
+ /**
4
+ * The Inbox (KRTX-1742): the person's notifications from every project, as a
5
+ * page. The project sidebar's Inbox row opens it inside the project shell
6
+ * (`uiRoutes().inbox`); `AccountTopBar` opens it on the account-level pages.
7
+ *
8
+ * A row opens its subject (its session, its Artifact, or the Loops or
9
+ * Triggers page for an alert) and marks itself read. The tabs split what
10
+ * waits on the person (Needs you) from the rest (Done). When this browser
11
+ * shows no notifications yet, the page offers to turn them on. The footer
12
+ * links to the per-kind Push and Email choices in Settings.
13
+ *
14
+ * `NotificationInboxView` is the props-only half: tests render it alone.
15
+ */
16
+ import { ProjectPageHeader } from '../layout/project-page-header.js';
17
+ import { HoverPrefetchLink } from '../components/hover-prefetch-link.js';
18
+ import { Button } from '../../primitives/button.js';
19
+ import { ButtonGroup } from '../../primitives/button-group.js';
20
+ import { CountBadge } from '../../primitives/count-badge.js';
21
+ import { EmptyArt } from '../../primitives/empty-art.js';
22
+ import { EmptyState } from '../../primitives/empty-state.js';
23
+ import { ErrorState } from '../../primitives/error-state.js';
24
+ import Hint from '../../primitives/hint.js';
25
+ import { InfoBanner } from '../../primitives/info-banner.js';
26
+ import { Skeleton } from '../../primitives/skeleton.js';
27
+ import { Tabs, TabsList, TabsTrigger } from '../../primitives/tabs.js';
28
+ import { SolidCheckIcon } from '../icons/solid-check-icon.js';
29
+ import { UiLink, useUiViewerId } from '../../providers/ui-provider.js';
30
+ import { useLocale, useTranslations } from '../../i18n/index.js';
31
+ import { relativeTime } from '../lib/relative-time.js';
32
+ import { cn } from '../lib/utils.js';
33
+ import { isNotificationSupported } from '../lib/web-notifications.js';
34
+ import { useSettingsPanelStore } from '../stores/settings-panel-store.js';
35
+ import { useWebNotificationStore } from '../stores/web-notification-store.js';
36
+ import { useNotificationInbox } from '@kortix/sdk/react';
37
+ import { BellIcon, ChecksIcon, GearSixIcon, QuestionIcon, ShareIcon, ShieldWarningIcon, WarningIcon, XCircleIcon, XIcon, } from '@phosphor-icons/react';
38
+ import { useState } from 'react';
39
+ import { tabRows, tabUnreadCount, withoutNotificationParam } from './notification-rows.js';
40
+ import { webPushSupported } from './web-push.js';
41
+ /** Every kind glyph is solid: Phosphor at `weight="fill"`, the done check is `SolidCheckIcon`. */
42
+ const solid = (Icon) => function SolidKindIcon(props) {
43
+ return _jsx(Icon, { weight: "fill", ...props });
44
+ };
45
+ const KIND_MARK = {
46
+ turn_done: { icon: SolidCheckIcon, className: 'text-kortix-green' },
47
+ turn_error: { icon: solid(XCircleIcon), className: 'text-kortix-red' },
48
+ question: { icon: solid(QuestionIcon), className: 'text-kortix-yellow' },
49
+ permission: { icon: solid(ShieldWarningIcon), className: 'text-kortix-yellow' },
50
+ shared: { icon: solid(ShareIcon), className: 'text-muted-foreground' },
51
+ automation_failed: { icon: solid(WarningIcon), className: 'text-kortix-red' },
52
+ automation_recovered: { icon: SolidCheckIcon, className: 'text-kortix-green' },
53
+ capture_device_down: { icon: solid(WarningIcon), className: 'text-kortix-red' },
54
+ capture_device_recovered: { icon: SolidCheckIcon, className: 'text-kortix-green' },
55
+ };
56
+ /**
57
+ * Props only: the page frame and header, the description, the All / Needs you
58
+ * / Done tabs with "Mark all as read", the offer, the rows and the settings
59
+ * footer. Inside a project the title is `ProjectPageHeader` (the Review,
60
+ * Goals and Artifacts pages' header: it owns the desktop title-bar band).
61
+ */
62
+ export function NotificationInboxView({ rows, state, unreadCount, prompt, settings, header, onOpenRow, onMarkAllRead, onRetry, onTurnOn, onDismissPrompt, }) {
63
+ const t = useTranslations('notifications');
64
+ const [tab, setTab] = useState('all');
65
+ const visible = tabRows(rows, tab);
66
+ const needsCount = tabUnreadCount(rows, 'needs');
67
+ const doneCount = tabUnreadCount(rows, 'done');
68
+ const settingsLabel = (_jsxs(_Fragment, { children: [_jsx(GearSixIcon, { className: "size-3.5 shrink-0" }), t('inbox.settings')] }));
69
+ return (
70
+ // `h-svh`: nothing above this box has a definite height (as the Review page).
71
+ _jsxs("div", { className: "flex h-svh min-h-0 flex-col overflow-hidden", children: [header ?? _jsx(ProjectPageHeader, { title: t('inbox.title') }), _jsx("div", { className: "min-h-0 flex-1 overflow-y-auto", children: _jsxs("div", { className: "mx-auto flex w-full max-w-4xl flex-col gap-4 px-4 py-6 pb-20 md:px-8", children: [_jsxs("div", { className: "flex flex-col gap-1.5", children: [header ? _jsx("h1", { className: "text-foreground text-xl font-medium text-balance", children: t('inbox.title') }) : null, _jsx("p", { className: "text-muted-foreground text-sm text-pretty", children: t('inbox.description') })] }), _jsxs("div", { className: "flex flex-wrap items-center justify-between gap-2", children: [_jsx(Tabs, { value: tab, onValueChange: (value) => setTab(value), children: _jsxs(TabsList, { children: [_jsxs(TabsTrigger, { value: "all", className: "gap-1.5", children: [t('inbox.tabAll'), unreadCount > 0 ? _jsx(CountBadge, { count: unreadCount }) : null] }), _jsxs(TabsTrigger, { value: "needs", className: "gap-1.5", children: [t('inbox.tabNeedsYou'), needsCount > 0 ? _jsx(CountBadge, { count: needsCount, tone: "waiting" }) : null] }), _jsxs(TabsTrigger, { value: "done", className: "gap-1.5", children: [t('inbox.tabDone'), doneCount > 0 ? _jsx(CountBadge, { count: doneCount }) : null] })] }) }), unreadCount > 0 ? (_jsxs(Button, { variant: "outline", size: "sm", className: "gap-1.5", onClick: onMarkAllRead, children: [_jsx(ChecksIcon, { className: "size-3.5 shrink-0" }), t('inbox.markAllRead')] })) : null] }), prompt ? (_jsx(InfoBanner, { icon: BellIcon, title: prompt, action: _jsxs(ButtonGroup, { children: [_jsx(Button, { variant: "secondary", size: "xs", onClick: onTurnOn, children: t('inbox.turnOn') }), _jsx(Hint, { label: t('inbox.dismiss'), side: "top", children: _jsx(Button, { variant: "secondary", size: "icon-sm", "aria-label": t('inbox.dismiss'), onClick: onDismissPrompt, children: _jsx(XIcon, { className: "size-3.5 shrink-0" }) }) })] }) })) : null, state === 'loading' ? (_jsx("div", { className: "space-y-0.5", children: [0, 1, 2].map((index) => (_jsx(Skeleton, { className: "h-14 w-full rounded-lg" }, index))) })) : state === 'error' ? (_jsx(ErrorState, { size: "sm", title: t('inbox.loadError'), action: _jsx(Button, { variant: "outline", size: "sm", onClick: onRetry, children: t('inbox.retry') }) })) : visible.length === 0 ? (_jsx(EmptyState, { size: "sm", media: _jsx(EmptyArt, { icon: BellIcon }), title: tab === 'needs' && rows.length > 0 ? t('inbox.emptyNeedsYou') : t('inbox.empty'), description: tab === 'needs' && rows.length > 0 ? t('inbox.emptyNeedsYouDescription') : t('inbox.emptyDescription') })) : (_jsx("ul", { className: "space-y-0.5", children: visible.map((row) => (_jsx("li", { children: _jsx(InboxRow, { row: row, onOpen: () => onOpenRow(row) }) }, row.id))) })), _jsxs("div", { className: "flex flex-col gap-2 pt-2 sm:flex-row sm:items-center sm:justify-between", children: [_jsx("p", { className: "text-muted-foreground text-sm text-pretty", children: t('inbox.emailOptIn') }), 'href' in settings ? (_jsx(Button, { asChild: true, variant: "outline", size: "sm", className: "gap-1.5 self-start sm:self-auto", children: _jsx(UiLink, { href: settings.href, children: settingsLabel }) })) : (_jsx(Button, { variant: "outline", size: "sm", className: "gap-1.5 self-start sm:self-auto", onClick: settings.onOpen, children: settingsLabel }))] })] }) })] }));
72
+ }
73
+ /** One notification: the kind glyph, its subject, its detail, then kind, project and age. */
74
+ function InboxRow({ row, onOpen }) {
75
+ const t = useTranslations('notifications');
76
+ const locale = useLocale();
77
+ const mark = KIND_MARK[row.kind] ?? KIND_MARK.shared;
78
+ const unread = !row.read;
79
+ return (_jsxs(HoverPrefetchLink, { href: withoutNotificationParam(row.url), onClick: onOpen, "data-unread": unread ? '' : undefined, className: "hover:bg-hover focus-visible:ring-ring flex items-start gap-3 rounded-lg px-3 py-2.5 outline-none focus-visible:ring-2", children: [_jsx(mark.icon, { className: cn('mt-0.5 size-4 shrink-0', mark.className, !unread && 'opacity-60'), "aria-hidden": true }), _jsxs("span", { className: "min-w-0 flex-1", children: [_jsx("span", { className: cn('block truncate text-sm', unread ? 'text-foreground font-medium' : 'text-muted-foreground'), children: row.title }), row.body ? _jsx("span", { className: "text-muted-foreground mt-0.5 block truncate text-sm", children: row.body }) : null, _jsxs("span", { className: "text-muted-foreground mt-0.5 flex min-w-0 items-center gap-1 text-xs", children: [_jsx("span", { className: "shrink-0", children: t(`kind.${row.kind}`) }), row.project_name ? (_jsxs(_Fragment, { children: [_jsx("span", { "aria-hidden": true, className: "shrink-0", children: "\u00B7" }), _jsx("span", { className: "min-w-0 truncate", children: row.project_name })] })) : null, _jsx("span", { "aria-hidden": true, className: "shrink-0", children: "\u00B7" }), _jsx("span", { className: "shrink-0 tabular-nums", children: relativeTime(row.created_at, locale) })] })] }), _jsx("span", { className: "flex h-5 w-2 shrink-0 items-center justify-end", children: unread ? (_jsxs(_Fragment, { children: [_jsx("span", { "aria-hidden": true, className: "bg-kortix-blue size-1.5 rounded-full" }), _jsx("span", { className: "sr-only", children: t('inbox.unread') })] })) : null })] }));
80
+ }
81
+ /**
82
+ * The Inbox page. Reads the inbox `NotificationHost` polls (one cache entry,
83
+ * so the sidebar count and the page agree), and renders nothing while signed
84
+ * out. `settingsHref`: the Settings page outside a project (`/settings/…`);
85
+ * without it, "Notification settings" opens the project's Settings overlay.
86
+ * `header` sits above the page (the account pages' top bar).
87
+ */
88
+ export function NotificationInbox({ settingsHref, header }) {
89
+ const t = useTranslations('notifications');
90
+ const viewerId = useUiViewerId();
91
+ const inbox = useNotificationInbox({ userId: viewerId });
92
+ const notificationsOn = useWebNotificationStore((s) => s.preferences.enabled);
93
+ const permission = useWebNotificationStore((s) => s.permission);
94
+ const promptDismissed = useWebNotificationStore((s) => s.promptDismissed);
95
+ const requestPermission = useWebNotificationStore((s) => s.requestPermission);
96
+ const setPreference = useWebNotificationStore((s) => s.setPreference);
97
+ const dismissPrompt = useWebNotificationStore((s) => s.dismissPrompt);
98
+ if (!viewerId)
99
+ return null;
100
+ // A fresh profile enables notifications before OS permission is granted.
101
+ const offerTurnOn = isNotificationSupported() &&
102
+ (!notificationsOn || permission === 'default') &&
103
+ permission !== 'denied' &&
104
+ !promptDismissed;
105
+ return (_jsx(NotificationInboxView, { rows: inbox.data?.notifications ?? [], state: inbox.data ? 'ready' : inbox.isError ? 'error' : 'loading', unreadCount: inbox.unreadCount, prompt: offerTurnOn ? (webPushSupported() ? t('inbox.promptPush') : t('inbox.promptBackground')) : null, settings: settingsHref
106
+ ? { href: settingsHref }
107
+ : { onOpen: () => useSettingsPanelStore.getState().openSettings('sessions') }, header: header, onOpenRow: (row) => {
108
+ if (!row.read)
109
+ inbox.markRead([row.id]).catch(() => { });
110
+ }, onMarkAllRead: () => {
111
+ inbox.markAllRead().catch(() => { });
112
+ }, onRetry: () => void inbox.refetch(),
113
+ // From the click itself: the browser asks for permission only
114
+ // inside a user gesture.
115
+ onTurnOn: async () => {
116
+ if ((await requestPermission()) === 'granted')
117
+ setPreference('enabled', true);
118
+ }, onDismissPrompt: dismissPrompt }));
119
+ }
@@ -59,10 +59,9 @@ export declare function webNotificationType(row: InboxNotification): WebNotifica
59
59
  export declare function notificationTag(row: InboxNotification): string;
60
60
  /**
61
61
  * Where a row's open action goes, named by the page its `url` opens: its
62
- * Artifact, its session, the Reminders page (a reminder
63
- * alert), or the Triggers page.
62
+ * session, the Reminders page (a reminder alert), or the Triggers page.
64
63
  */
65
- export declare function rowDestination(row: InboxNotification): 'artifact' | 'session' | 'reminders' | 'triggers';
64
+ export declare function rowDestination(row: InboxNotification): 'session' | 'reminders' | 'triggers';
66
65
  /** The message `public/sw.js` posts to a tab already on a clicked notification's page. */
67
66
  export declare const NOTIFICATION_OPEN_MESSAGE = "kortix:notification-open";
68
67
  /** The notification id a service-worker message says this tab opened, or null. */
@@ -81,7 +80,7 @@ export declare function pollsWhileHidden(input: {
81
80
  }): boolean;
82
81
  /** The id of the newest unread row of `sessionId` in `rows` (newest first), or null. */
83
82
  export declare function sessionUnreadRowId(rows: readonly InboxNotification[] | undefined, sessionId: string): string | null;
84
- /** The bell's tabs. `needs` holds the kinds that wait on the person: an answer, an approval, a failure to look at. */
83
+ /** The Inbox page's tabs. `needs` holds the kinds that wait on the person: an answer, an approval, a failure to look at. */
85
84
  export type NotificationTab = 'all' | 'needs' | 'done';
86
85
  /**
87
86
  * The rows a tab shows: unread first, so an untouched row never sits between
@@ -73,12 +73,9 @@ export function notificationTag(row) {
73
73
  }
74
74
  /**
75
75
  * Where a row's open action goes, named by the page its `url` opens: its
76
- * Artifact, its session, the Reminders page (a reminder
77
- * alert), or the Triggers page.
76
+ * session, the Reminders page (a reminder alert), or the Triggers page.
78
77
  */
79
78
  export function rowDestination(row) {
80
- if (row.artifact_id)
81
- return 'artifact';
82
79
  if (row.session_id)
83
80
  return 'session';
84
81
  const path = new URL(row.url, 'http://kortix.invalid').pathname;
@@ -0,0 +1,13 @@
1
+ /** @internal Kortix apps only. No semver: it may change in any release. */
2
+ /**
3
+ * The Inbox entry point (KRTX-1742) in the workspace menu: the Inbox page's
4
+ * href, the server's unread count (99+ at most), and whether an unread
5
+ * question, permission request or failure waits ("needs you"). It reads the
6
+ * inbox `NotificationHost` polls, so it sends no request of its own. `href` is
7
+ * null when the host serves no Inbox page.
8
+ */
9
+ export declare function useInboxSummary(projectId: string): {
10
+ href: string | null;
11
+ count: number;
12
+ needsYou: boolean;
13
+ };
@@ -0,0 +1,22 @@
1
+ 'use client';
2
+ import { uiRoutes } from '../../lib/routes.js';
3
+ import { useUiViewerId } from '../../providers/ui-provider.js';
4
+ import { useNotificationInbox } from '@kortix/sdk/react';
5
+ import { tabUnreadCount } from './notification-rows.js';
6
+ /**
7
+ * The Inbox entry point (KRTX-1742) in the workspace menu: the Inbox page's
8
+ * href, the server's unread count (99+ at most), and whether an unread
9
+ * question, permission request or failure waits ("needs you"). It reads the
10
+ * inbox `NotificationHost` polls, so it sends no request of its own. `href` is
11
+ * null when the host serves no Inbox page.
12
+ */
13
+ export function useInboxSummary(projectId) {
14
+ const viewerId = useUiViewerId();
15
+ const inbox = useNotificationInbox({ userId: viewerId });
16
+ const href = uiRoutes().inbox?.(projectId) ?? null;
17
+ return {
18
+ href,
19
+ count: href ? inbox.unreadCount : 0,
20
+ needsYou: !!href && tabUnreadCount(inbox.data?.notifications ?? [], 'needs') > 0,
21
+ };
22
+ }
@@ -3,13 +3,12 @@
3
3
  * Web Push for this browser (KRTX-1742): the service worker (`public/sw.js`),
4
4
  * the push subscription, and its record on the API.
5
5
  *
6
- * `NotificationHost` drives it. While the `notification_center` flag is on it
7
- * subscribes (`ensureWebPush`). On any page it unsubscribes when browser
8
- * notifications are turned off (`syncWebPush(false)`), reads whether this
9
- * browser holds a subscription (`detectWebPush`), and registers it again after
10
- * the MFA step-up (`reregisterWebPush`). Sign-out calls `stopWebPush`. Nothing
11
- * here toasts: a failure is logged once, and the bell and in-page
12
- * notifications still work.
6
+ * `NotificationHost` drives it, on every page while signed in. It subscribes
7
+ * (`ensureWebPush`), unsubscribes when browser notifications are turned off
8
+ * (`syncWebPush(false)`), reads whether this browser holds a subscription
9
+ * (`detectWebPush`), and registers it again after the MFA step-up
10
+ * (`reregisterWebPush`). Sign-out calls `stopWebPush`. Nothing here toasts: a
11
+ * failure is logged once, and the Inbox and in-page notifications still work.
13
12
  */
14
13
  import { type WebPushSubscriptionInput } from '@kortix/sdk';
15
14
  /**
@@ -54,9 +53,9 @@ export declare function ensureWebPush(userId: string): Promise<void>;
54
53
  export declare function reregisterWebPush(): Promise<void>;
55
54
  /**
56
55
  * Whether this browser holds a deliverable subscription, read from the
57
- * browser alone (no request). A tab on a flag-off page never registers, but
58
- * its copy of a flag-on project's notification must still go through the
59
- * service worker. A registration in this page load wins.
56
+ * browser alone (no request), so this page's copy of a notification goes
57
+ * through the service worker before `ensureWebPush` has answered. A
58
+ * registration in this page load wins.
60
59
  */
61
60
  export declare function detectWebPush(): Promise<void>;
62
61
  /** Sign-out: the next person on this browser must not get this person's notifications. */
@@ -2,13 +2,12 @@
2
2
  * Web Push for this browser (KRTX-1742): the service worker (`public/sw.js`),
3
3
  * the push subscription, and its record on the API.
4
4
  *
5
- * `NotificationHost` drives it. While the `notification_center` flag is on it
6
- * subscribes (`ensureWebPush`). On any page it unsubscribes when browser
7
- * notifications are turned off (`syncWebPush(false)`), reads whether this
8
- * browser holds a subscription (`detectWebPush`), and registers it again after
9
- * the MFA step-up (`reregisterWebPush`). Sign-out calls `stopWebPush`. Nothing
10
- * here toasts: a failure is logged once, and the bell and in-page
11
- * notifications still work.
5
+ * `NotificationHost` drives it, on every page while signed in. It subscribes
6
+ * (`ensureWebPush`), unsubscribes when browser notifications are turned off
7
+ * (`syncWebPush(false)`), reads whether this browser holds a subscription
8
+ * (`detectWebPush`), and registers it again after the MFA step-up
9
+ * (`reregisterWebPush`). Sign-out calls `stopWebPush`. Nothing here toasts: a
10
+ * failure is logged once, and the Inbox and in-page notifications still work.
12
11
  */
13
12
  import { isDesktop } from '../lib/desktop.js';
14
13
  import { logger } from '../lib/logger.js';
@@ -170,9 +169,9 @@ export function reregisterWebPush() {
170
169
  }
171
170
  /**
172
171
  * Whether this browser holds a deliverable subscription, read from the
173
- * browser alone (no request). A tab on a flag-off page never registers, but
174
- * its copy of a flag-on project's notification must still go through the
175
- * service worker. A registration in this page load wins.
172
+ * browser alone (no request), so this page's copy of a notification goes
173
+ * through the service worker before `ensureWebPush` has answered. A
174
+ * registration in this page load wins.
176
175
  */
177
176
  export function detectWebPush() {
178
177
  queue = queue
@@ -7,7 +7,10 @@ export const useComposerPrefillStore = create((set, get) => ({
7
7
  ...s.prefillByProject,
8
8
  [projectId]: {
9
9
  text: prompt,
10
- ...(extras?.submit ? { submit: true } : {}),
10
+ // The value as given: `'when-ready'` must reach the composer, which
11
+ // waits for Send to be possible. Collapsed to `true` it sent while
12
+ // models and entitlements still loaded.
13
+ ...(extras?.submit ? { submit: extras.submit } : {}),
11
14
  ...(extras?.files?.length ? { files: extras.files } : {}),
12
15
  ...(extras?.options ? { options: extras.options } : {}),
13
16
  },
@@ -11,11 +11,11 @@ export type SoundEvent = 'completion' | 'error' | 'notification' | 'send';
11
11
  /**
12
12
  * Available sound packs.
13
13
  *
14
- * - `off` – all sounds disabled
15
- * - `opencode` – default sound pack (OpenCode style)
16
- * - `kortix` – Kortix branded sound pack
14
+ * - `off` – all sounds disabled
15
+ * - `classic` – default sound pack (synthesized tones)
16
+ * - `kortix` – Kortix branded sound pack
17
17
  */
18
- export type SoundPack = 'off' | 'opencode' | 'kortix';
18
+ export type SoundPack = 'off' | 'classic' | 'kortix';
19
19
  export interface SoundPreferences {
20
20
  /** Active sound pack — 'off' disables all sounds */
21
21
  pack: SoundPack;
@@ -35,6 +35,16 @@ export const useSoundStore = create()(persist((set, get) => ({
35
35
  },
36
36
  }), {
37
37
  name: 'kortix-sound-preferences',
38
+ // v1 renamed the default pack from 'opencode' to 'classic'. A saved
39
+ // 'opencode' keeps playing the same pack.
40
+ version: 1,
41
+ migrate: (persisted) => {
42
+ const state = persisted;
43
+ const preferences = { ...DEFAULT_PREFERENCES, ...state?.preferences };
44
+ if (preferences.pack === 'opencode')
45
+ preferences.pack = 'classic';
46
+ return { preferences };
47
+ },
38
48
  storage: createSafeJSONStorage(),
39
49
  partialize: (state) => ({
40
50
  preferences: state.preferences,
@@ -1,16 +1,13 @@
1
1
  /** @internal Kortix apps only. No semver: it may change in any release. */
2
2
  export type WebNotificationPermission = 'default' | 'granted' | 'denied';
3
3
  export interface WebNotificationPreferences {
4
- /** Master toggle for browser notifications */
4
+ /**
5
+ * Master toggle for browser notifications. Which kinds notify is the
6
+ * person's server record (Settings → Notifications), the same for every
7
+ * browser and phone. A profile saved before 2026-11-06 may still hold the
8
+ * four retired per-browser kind switches; nothing reads them.
9
+ */
5
10
  enabled: boolean;
6
- /** Notify when a session task completes (becomes idle after being busy) */
7
- onCompletion: boolean;
8
- /** Notify when a session error occurs */
9
- onError: boolean;
10
- /** Notify when Kortix asks a question that needs user input */
11
- onQuestion: boolean;
12
- /** Notify when Kortix requests a permission */
13
- onPermission: boolean;
14
11
  /** Only send browser notifications when the tab is not visible */
15
12
  onlyWhenHidden: boolean;
16
13
  /** Play a sound with notifications */
@@ -4,10 +4,6 @@ import { create } from 'zustand';
4
4
  import { persist } from 'zustand/middleware';
5
5
  const DEFAULT_PREFERENCES = {
6
6
  enabled: true,
7
- onCompletion: true,
8
- onError: true,
9
- onQuestion: true,
10
- onPermission: true,
11
7
  onlyWhenHidden: true,
12
8
  playSound: false,
13
9
  };
@@ -57,6 +57,14 @@ export interface UiRoutes {
57
57
  * inside its `customize` route.
58
58
  */
59
59
  review?: (projectId: string) => string | null;
60
+ /**
61
+ * The Inbox: the signed-in person's notifications from every project, as a
62
+ * page beside the project sidebar (KRTX-1742). Absent or null: the host
63
+ * serves no Inbox page and the sidebar has no Inbox row. It is new
64
+ * (2026-11-06), so a host that maps any route (its own router) gets no
65
+ * Inbox row until it routes `inbox` too: no host gets a link it does not serve.
66
+ */
67
+ inbox?: (projectId: string) => string | null;
60
68
  }
61
69
  export declare const defaultUiRoutes: UiRoutes;
62
70
  /**
@@ -16,6 +16,7 @@ const DEFAULT_ROUTES = {
16
16
  dm: (p, agentName) => `/projects/${p}/dm/${encodeURIComponent(agentName)}`,
17
17
  memory: (p) => `/projects/${p}/memory`,
18
18
  review: (p) => `/projects/${p}/review`,
19
+ inbox: (p) => `/projects/${p}/inbox`,
19
20
  };
20
21
  export const defaultUiRoutes = DEFAULT_ROUTES;
21
22
  let routes = DEFAULT_ROUTES;
@@ -29,7 +30,9 @@ export function setUiRoutes(overrides) {
29
30
  const admin = overrides.admin ?? overrides.customize;
30
31
  // A host that routes its own customize pages serves Review there unless it also routes `review`.
31
32
  const review = overrides.review ?? (overrides.customize ? undefined : DEFAULT_ROUTES.review);
32
- routes = { ...DEFAULT_ROUTES, ...overrides, ...(admin ? { admin } : {}), review };
33
+ // The Inbox page is new: only the default router (no override) serves it unasked.
34
+ const inbox = overrides.inbox ?? (Object.keys(overrides).length === 0 ? DEFAULT_ROUTES.inbox : undefined);
35
+ routes = { ...DEFAULT_ROUTES, ...overrides, ...(admin ? { admin } : {}), review, inbox };
33
36
  }
34
37
  export function uiRoutes() {
35
38
  return routes;
@@ -117,19 +117,26 @@ export function warmHighlighter() {
117
117
  else
118
118
  setTimeout(run, 1500);
119
119
  }
120
+ /**
121
+ * Resolves `false` for a hint Shiki has no grammar for (`conf`, a typo): an
122
+ * expected state, so no Error. A rejected promise here reached Sentry as an
123
+ * unhandled rejection from engines that report it before `await` attaches a
124
+ * handler (KRTX-4265). Rejects only when a real grammar chunk fails to load.
125
+ */
120
126
  function ensureLangLoaded(h, lang) {
121
127
  if (PLAIN_LANGS.has(lang) || loadedLangs.has(lang))
122
- return Promise.resolve();
128
+ return Promise.resolve(true);
123
129
  const existing = langLoadPromises.get(lang);
124
130
  if (existing)
125
131
  return existing;
126
132
  const importer = bundledLanguages[lang];
127
133
  if (!importer)
128
- return Promise.reject(new Error(`no bundled grammar for "${lang}"`));
134
+ return Promise.resolve(false);
129
135
  const p = h
130
136
  .loadLanguage(importer())
131
137
  .then(() => {
132
138
  loadedLangs.add(lang);
139
+ return true;
133
140
  })
134
141
  .finally(() => {
135
142
  langLoadPromises.delete(lang);
@@ -225,11 +232,13 @@ export function highlightAsync(code, language, theme, opts) {
225
232
  if (!h)
226
233
  return null;
227
234
  try {
228
- await ensureLangLoaded(h, lang);
235
+ // Unknown hint: plain text, quietly.
236
+ if (!(await ensureLangLoaded(h, lang)))
237
+ return null;
229
238
  }
230
239
  catch (err) {
231
- // Unknown hint or a grammar chunk that failed to load: plain text is
232
- // the honest rendering. Not cached, so a later mount can retry.
240
+ // A grammar chunk that failed to load: plain text is the honest
241
+ // rendering. Not cached, so a later mount can retry.
233
242
  console.warn(`[markdown-code] failed to load Shiki lang "${lang}":`, err?.message || err);
234
243
  return null;
235
244
  }
@@ -1,15 +1,6 @@
1
1
  import { type Editor } from '@tiptap/react';
2
- /**
3
- * ⌘⌥M on a Mac, Ctrl+Alt+M elsewhere: comment on the selected text (the
4
- * Google Docs key). Matched by the physical key too: ⌥M types `µ` on a Mac,
5
- * and Windows treats Ctrl+Alt as AltGr, so `key` is often not `m`.
6
- */
7
- export declare function isCommentShortcut(event: Pick<KeyboardEvent, 'key' | 'code' | 'metaKey' | 'ctrlKey' | 'altKey' | 'shiftKey' | 'repeat'>, mac: boolean): boolean;
8
- export declare function DocMenus({ editor, blockMenu, editable, canComment, commenting, onComment, }: {
2
+ export declare function DocMenus({ editor, blockMenu, editable, }: {
9
3
  editor: Editor;
10
4
  blockMenu?: boolean;
11
5
  editable?: boolean;
12
- canComment?: boolean;
13
- commenting?: boolean;
14
- onComment?: () => void;
15
6
  }): import("react").JSX.Element;
@@ -1,39 +1,20 @@
1
1
  'use client';
2
- import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
2
+ import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
3
3
  /**
4
4
  * The document editor's two menus: one over selected text (marks, headings,
5
5
  * quote, table rows) and a `+` menu on an empty line (blocks). Markdown
6
6
  * shortcuts (`# `, `- `, `1. `, `[ ] `, `> `, ``` ```) work without them.
7
7
  * `blockMenu={false}` drops the `+` menu, for an editor with a `/` block menu.
8
- * `canComment` puts a labeled Comment button first over selected text (with
9
- * `editable={false}` it is the only button) and turns on its shortcut, ⌘⌥M on
10
- * a Mac and Ctrl+Alt+M elsewhere.
11
8
  */
12
- import { ChatCircleIcon, CheckSquareIcon, CodeBlockIcon, CodeIcon, LinkSimpleIcon, ListBulletsIcon, ListNumbersIcon, MinusIcon, PlusIcon, QuotesIcon, TableIcon, TextBIcon, TextHOneIcon, TextHThreeIcon, TextHTwoIcon, TextItalicIcon, TextStrikethroughIcon, TrashIcon, } from '@phosphor-icons/react';
9
+ import { CheckSquareIcon, CodeBlockIcon, CodeIcon, LinkSimpleIcon, ListBulletsIcon, ListNumbersIcon, MinusIcon, PlusIcon, QuotesIcon, TableIcon, TextBIcon, TextHOneIcon, TextHThreeIcon, TextHTwoIcon, TextItalicIcon, TextStrikethroughIcon, TrashIcon, } from '@phosphor-icons/react';
13
10
  import { TextSelection } from '@tiptap/pm/state';
14
11
  import { useEditorState } from '@tiptap/react';
15
12
  import { BubbleMenu, FloatingMenu } from '@tiptap/react/menus';
16
- import { useEffect, useRef, useState } from 'react';
17
13
  import { useTranslations } from '../../i18n/index.js';
18
14
  import { Button } from '../../primitives/button.js';
19
15
  import Hint from '../../primitives/hint.js';
20
- import { Kbd, KbdGroup } from '../../primitives/kbd.js';
21
- import Loading from '../../primitives/loading.js';
22
- const isMac = () => typeof navigator !== 'undefined' && /Mac|iPhone|iPad/.test(navigator.platform);
23
- /**
24
- * ⌘⌥M on a Mac, Ctrl+Alt+M elsewhere: comment on the selected text (the
25
- * Google Docs key). Matched by the physical key too: ⌥M types `µ` on a Mac,
26
- * and Windows treats Ctrl+Alt as AltGr, so `key` is often not `m`.
27
- */
28
- export function isCommentShortcut(event, mac) {
29
- if (!event.altKey || event.shiftKey || event.repeat)
30
- return false;
31
- if (mac ? !event.metaKey || event.ctrlKey : !event.ctrlKey || event.metaKey)
32
- return false;
33
- return event.code === 'KeyM' || event.key.toLowerCase() === 'm';
34
- }
35
- /** Selected text a comment can quote: a non-blank text range, not an image or a video. */
36
- function commentableSelection(editor, state) {
16
+ /** Selected text to format: a non-blank text range, not an image or a video. */
17
+ function textSelected(editor, state) {
37
18
  const { selection } = state;
38
19
  return (selection instanceof TextSelection &&
39
20
  selection.from !== selection.to &&
@@ -44,21 +25,8 @@ function commentableSelection(editor, state) {
44
25
  function MenuButton({ icon: IconCmp, label, active, onClick, disabled, }) {
45
26
  return (_jsx(Hint, { label: label, side: "top", sideOffset: 6, children: _jsx(Button, { type: "button", size: "icon-sm", variant: "ghost", "aria-label": label, "aria-pressed": active, "aria-busy": disabled || undefined, disabled: disabled, onMouseDown: (e) => e.preventDefault(), onClick: onClick, className: "data-[active=true]:bg-active data-[active=true]:text-foreground text-muted-foreground", "data-active": active || undefined, children: _jsx(IconCmp, { className: "size-4" }) }) }));
46
27
  }
47
- /**
48
- * The first item over selected text: a labeled button, so a first-time reader
49
- * finds comments. Its hint closes with the menu: the shortcut hides the menu
50
- * under a still pointer, and an open hint would lose its anchor.
51
- */
52
- function CommentButton({ label, busy, shown, onClick, }) {
53
- const [mac] = useState(isMac);
54
- const [hint, setHint] = useState(false);
55
- if (hint && !shown)
56
- setHint(false);
57
- const keys = mac ? ['⌘', '⌥', 'M'] : ['Ctrl', 'Alt', 'M'];
58
- return (_jsx(Hint, { open: hint && shown && !busy, onOpenChange: setHint, side: "top", sideOffset: 6, label: _jsxs("span", { className: "flex items-center gap-1.5", children: [label, _jsx(KbdGroup, { children: keys.map((key) => (_jsx(Kbd, { className: "h-4 w-auto min-w-4", children: key }, key))) })] }), children: _jsxs(Button, { type: "button", size: "xs", variant: "ghost", "aria-keyshortcuts": mac ? 'Meta+Alt+M' : 'Control+Alt+M', "aria-busy": busy || undefined, disabled: busy, onMouseDown: (e) => e.preventDefault(), onClick: onClick, children: [busy ? _jsx(Loading, { className: "size-4" }) : _jsx(ChatCircleIcon, { className: "size-4" }), label] }) }));
59
- }
60
28
  const MENU = 'bg-popover text-popover-foreground flex items-center gap-0.5 rounded-lg border p-1 shadow-md';
61
- export function DocMenus({ editor, blockMenu = true, editable = true, canComment = false, commenting = false, onComment, }) {
29
+ export function DocMenus({ editor, blockMenu = true, editable = true, }) {
62
30
  const t = useTranslations('artifacts');
63
31
  const state = useEditorState({
64
32
  editor,
@@ -75,37 +43,6 @@ export function DocMenus({ editor, blockMenu = true, editable = true, canComment
75
43
  table: e.isActive('table'),
76
44
  }),
77
45
  });
78
- // ⌘⌥M / Ctrl+Alt+M comments on the selection in this editor, while comments are on.
79
- const comment = useRef({ onComment, commenting });
80
- useEffect(() => {
81
- comment.current = { onComment, commenting };
82
- });
83
- const commentsOn = canComment && !!onComment;
84
- // One options object for the menu's life: it reports when the menu shows and hides.
85
- const [bubbleShown, setBubbleShown] = useState(false);
86
- const [bubbleOptions] = useState(() => ({
87
- placement: 'top',
88
- onShow: () => setBubbleShown(true),
89
- onHide: () => setBubbleShown(false),
90
- }));
91
- useEffect(() => {
92
- if (!commentsOn)
93
- return;
94
- const mac = isMac();
95
- const onKey = (event) => {
96
- const { onComment: run, commenting: busy } = comment.current;
97
- if (event.defaultPrevented || !run || !isCommentShortcut(event, mac))
98
- return;
99
- const selected = editor.view.dom.ownerDocument.getSelection()?.anchorNode;
100
- if (!selected || !editor.view.dom.contains(selected) || !commentableSelection(editor, editor.state))
101
- return;
102
- event.preventDefault();
103
- if (!busy)
104
- run();
105
- };
106
- window.addEventListener('keydown', onKey);
107
- return () => window.removeEventListener('keydown', onKey);
108
- }, [editor, commentsOn]);
109
46
  const chain = () => editor.chain().focus();
110
47
  const setLink = () => {
111
48
  const previous = editor.getAttributes('link').href;
@@ -117,5 +54,5 @@ export function DocMenus({ editor, blockMenu = true, editable = true, canComment
117
54
  else
118
55
  chain().extendMarkRange('link').setLink({ href: url.trim() }).run();
119
56
  };
120
- return (_jsxs(_Fragment, { children: [_jsx(BubbleMenu, { editor: editor, options: bubbleOptions, shouldShow: ({ editor: e, state: s }) => (editable || canComment) && commentableSelection(e, s), children: _jsxs("div", { className: MENU, children: [canComment && onComment ? (_jsxs(_Fragment, { children: [_jsx(CommentButton, { label: t('discussion.commentSelection'), busy: commenting, shown: bubbleShown, onClick: onComment }), editable ? _jsx("span", { className: "bg-border mx-0.5 h-5 w-px" }) : null] })) : null, editable ? (_jsxs(_Fragment, { children: [_jsx(MenuButton, { icon: TextBIcon, label: t('bold'), active: state.bold, onClick: () => chain().toggleBold().run() }), _jsx(MenuButton, { icon: TextItalicIcon, label: t('italic'), active: state.italic, onClick: () => chain().toggleItalic().run() }), _jsx(MenuButton, { icon: TextStrikethroughIcon, label: t('strike'), active: state.strike, onClick: () => chain().toggleStrike().run() }), _jsx(MenuButton, { icon: CodeIcon, label: t('inlineCode'), active: state.code, onClick: () => chain().toggleCode().run() }), _jsx(MenuButton, { icon: LinkSimpleIcon, label: t('link'), active: state.link, onClick: setLink }), _jsx("span", { className: "bg-border mx-0.5 h-5 w-px" }), _jsx(MenuButton, { icon: TextHOneIcon, label: t('heading1'), active: state.h1, onClick: () => chain().toggleHeading({ level: 1 }).run() }), _jsx(MenuButton, { icon: TextHTwoIcon, label: t('heading2'), active: state.h2, onClick: () => chain().toggleHeading({ level: 2 }).run() }), _jsx(MenuButton, { icon: TextHThreeIcon, label: t('heading3'), active: state.h3, onClick: () => chain().toggleHeading({ level: 3 }).run() }), _jsx(MenuButton, { icon: QuotesIcon, label: t('quote'), active: state.quote, onClick: () => chain().toggleBlockquote().run() }), state.table ? (_jsxs(_Fragment, { children: [_jsx("span", { className: "bg-border mx-0.5 h-5 w-px" }), _jsx(MenuButton, { icon: PlusIcon, label: t('addRow'), onClick: () => chain().addRowAfter().run() }), _jsx(MenuButton, { icon: ListBulletsIcon, label: t('addColumn'), onClick: () => chain().addColumnAfter().run() }), _jsx(MenuButton, { icon: MinusIcon, label: t('deleteRow'), onClick: () => chain().deleteRow().run() }), _jsx(MenuButton, { icon: TrashIcon, label: t('deleteTable'), onClick: () => chain().deleteTable().run() })] })) : null] })) : null] }) }), editable && blockMenu ? (_jsx(FloatingMenu, { editor: editor, options: { placement: 'bottom-start', offset: 6 }, children: _jsxs("div", { className: MENU, children: [_jsx(MenuButton, { icon: TextHOneIcon, label: t('heading1'), onClick: () => chain().setHeading({ level: 1 }).run() }), _jsx(MenuButton, { icon: TextHTwoIcon, label: t('heading2'), onClick: () => chain().setHeading({ level: 2 }).run() }), _jsx(MenuButton, { icon: TextHThreeIcon, label: t('heading3'), onClick: () => chain().setHeading({ level: 3 }).run() }), _jsx(MenuButton, { icon: ListBulletsIcon, label: t('bulletList'), onClick: () => chain().toggleBulletList().run() }), _jsx(MenuButton, { icon: ListNumbersIcon, label: t('numberedList'), onClick: () => chain().toggleOrderedList().run() }), _jsx(MenuButton, { icon: CheckSquareIcon, label: t('taskList'), onClick: () => chain().toggleTaskList().run() }), _jsx(MenuButton, { icon: QuotesIcon, label: t('quote'), onClick: () => chain().toggleBlockquote().run() }), _jsx(MenuButton, { icon: CodeBlockIcon, label: t('codeBlock'), onClick: () => chain().toggleCodeBlock().run() }), _jsx(MenuButton, { icon: TableIcon, label: t('table'), onClick: () => chain().insertTable({ rows: 3, cols: 3, withHeaderRow: true }).run() }), _jsx(MenuButton, { icon: MinusIcon, label: t('divider'), onClick: () => chain().setHorizontalRule().run() })] }) })) : null] }));
57
+ return (_jsxs(_Fragment, { children: [_jsx(BubbleMenu, { editor: editor, options: { placement: 'top' }, shouldShow: ({ editor: e, state: s }) => editable && textSelected(e, s), children: _jsx("div", { className: MENU, children: editable ? (_jsxs(_Fragment, { children: [_jsx(MenuButton, { icon: TextBIcon, label: t('bold'), active: state.bold, onClick: () => chain().toggleBold().run() }), _jsx(MenuButton, { icon: TextItalicIcon, label: t('italic'), active: state.italic, onClick: () => chain().toggleItalic().run() }), _jsx(MenuButton, { icon: TextStrikethroughIcon, label: t('strike'), active: state.strike, onClick: () => chain().toggleStrike().run() }), _jsx(MenuButton, { icon: CodeIcon, label: t('inlineCode'), active: state.code, onClick: () => chain().toggleCode().run() }), _jsx(MenuButton, { icon: LinkSimpleIcon, label: t('link'), active: state.link, onClick: setLink }), _jsx("span", { className: "bg-border mx-0.5 h-5 w-px" }), _jsx(MenuButton, { icon: TextHOneIcon, label: t('heading1'), active: state.h1, onClick: () => chain().toggleHeading({ level: 1 }).run() }), _jsx(MenuButton, { icon: TextHTwoIcon, label: t('heading2'), active: state.h2, onClick: () => chain().toggleHeading({ level: 2 }).run() }), _jsx(MenuButton, { icon: TextHThreeIcon, label: t('heading3'), active: state.h3, onClick: () => chain().toggleHeading({ level: 3 }).run() }), _jsx(MenuButton, { icon: QuotesIcon, label: t('quote'), active: state.quote, onClick: () => chain().toggleBlockquote().run() }), state.table ? (_jsxs(_Fragment, { children: [_jsx("span", { className: "bg-border mx-0.5 h-5 w-px" }), _jsx(MenuButton, { icon: PlusIcon, label: t('addRow'), onClick: () => chain().addRowAfter().run() }), _jsx(MenuButton, { icon: ListBulletsIcon, label: t('addColumn'), onClick: () => chain().addColumnAfter().run() }), _jsx(MenuButton, { icon: MinusIcon, label: t('deleteRow'), onClick: () => chain().deleteRow().run() }), _jsx(MenuButton, { icon: TrashIcon, label: t('deleteTable'), onClick: () => chain().deleteTable().run() })] })) : null] })) : null }) }), editable && blockMenu ? (_jsx(FloatingMenu, { editor: editor, options: { placement: 'bottom-start', offset: 6 }, children: _jsxs("div", { className: MENU, children: [_jsx(MenuButton, { icon: TextHOneIcon, label: t('heading1'), onClick: () => chain().setHeading({ level: 1 }).run() }), _jsx(MenuButton, { icon: TextHTwoIcon, label: t('heading2'), onClick: () => chain().setHeading({ level: 2 }).run() }), _jsx(MenuButton, { icon: TextHThreeIcon, label: t('heading3'), onClick: () => chain().setHeading({ level: 3 }).run() }), _jsx(MenuButton, { icon: ListBulletsIcon, label: t('bulletList'), onClick: () => chain().toggleBulletList().run() }), _jsx(MenuButton, { icon: ListNumbersIcon, label: t('numberedList'), onClick: () => chain().toggleOrderedList().run() }), _jsx(MenuButton, { icon: CheckSquareIcon, label: t('taskList'), onClick: () => chain().toggleTaskList().run() }), _jsx(MenuButton, { icon: QuotesIcon, label: t('quote'), onClick: () => chain().toggleBlockquote().run() }), _jsx(MenuButton, { icon: CodeBlockIcon, label: t('codeBlock'), onClick: () => chain().toggleCodeBlock().run() }), _jsx(MenuButton, { icon: TableIcon, label: t('table'), onClick: () => chain().insertTable({ rows: 3, cols: 3, withHeaderRow: true }).run() }), _jsx(MenuButton, { icon: MinusIcon, label: t('divider'), onClick: () => chain().setHorizontalRule().run() })] }) })) : null] }));
121
58
  }