@kortix/ui 0.15.1 → 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.
- package/dist/_vendor/shared/index.d.ts +0 -2
- package/dist/artifacts/artifact-frame.d.ts +0 -1
- package/dist/artifacts/artifact-frame.js +4 -10
- package/dist/artifacts/artifact-session.js +2 -6
- package/dist/artifacts/frame-policy.d.ts +1 -1
- package/dist/artifacts/frame-policy.js +2 -2
- package/dist/customize/sections/view/agent-editor-catalog.js +0 -5
- package/dist/customize/triggers/schedule/trigger-list.d.ts +2 -2
- package/dist/customize/triggers/schedule/trigger-list.js +12 -18
- package/dist/i18n/en.d.ts +8 -185
- package/dist/i18n/en.js +13 -190
- package/dist/internal/components/agent-mark.js +6 -0
- package/dist/internal/components/clickable-path.d.ts +3 -0
- package/dist/internal/components/clickable-path.js +4 -1
- package/dist/internal/lib/browser-noise/rules/injected-scripts.js +11 -0
- package/dist/internal/lib/trigger-clock.d.ts +5 -0
- package/dist/internal/lib/trigger-clock.js +15 -0
- package/dist/internal/lib/turn-broadcast.d.ts +0 -3
- package/dist/internal/lib/use-project-feature-flags.d.ts +2 -0
- package/dist/internal/lib/use-project-feature-flags.js +2 -4
- package/dist/internal/lib/web-notifications.d.ts +1 -8
- package/dist/internal/lib/web-notifications.js +12 -53
- package/dist/internal/notifications/notification-bell.d.ts +13 -33
- package/dist/internal/notifications/notification-bell.js +14 -117
- package/dist/internal/notifications/notification-inbox.d.ts +45 -0
- package/dist/internal/notifications/notification-inbox.js +119 -0
- package/dist/internal/notifications/notification-rows.d.ts +3 -4
- package/dist/internal/notifications/notification-rows.js +1 -4
- package/dist/internal/notifications/use-inbox-summary.d.ts +13 -0
- package/dist/internal/notifications/use-inbox-summary.js +22 -0
- package/dist/internal/notifications/web-push.d.ts +9 -10
- package/dist/internal/notifications/web-push.js +9 -10
- package/dist/internal/stores/web-notification-store.d.ts +6 -9
- package/dist/internal/stores/web-notification-store.js +0 -4
- package/dist/lib/routes.d.ts +8 -0
- package/dist/lib/routes.js +4 -1
- package/dist/markdown/doc-editor/doc-menus.d.ts +1 -10
- package/dist/markdown/doc-editor/doc-menus.js +6 -69
- package/dist/markdown/file-links.js +21 -0
- package/dist/primitives/button.d.ts +1 -1
- package/dist/session/header/reminder-parts.d.ts +1 -1
- package/dist/session/header/session-site-header.js +2 -6
- package/dist/session/panel/session-reminders-panel.js +4 -15
- package/dist/session/tool/tools/session-spawn-tool.js +7 -4
- package/dist/session/tool/tools/task-tool.js +18 -4
- package/dist/styles.css +1 -1
- package/dist/workspace/home/access-requests-bell.d.ts +6 -9
- package/dist/workspace/home/access-requests-bell.js +8 -10
- package/dist/workspace/layout/project-home.js +1 -2
- package/dist/workspace/sidebar/project-sidebar.js +2 -6
- package/package.json +11 -7
- package/skills/kortix-ui/references/custom-dashboard.md +1 -1
- package/dist/_vendor/shared/artifact-annotations.d.ts +0 -311
- package/dist/_vendor/shared/artifact-comments.d.ts +0 -155
- package/dist/internal/hooks/use-notification-center.d.ts +0 -50
- package/dist/internal/hooks/use-notification-center.js +0 -151
|
@@ -1,33 +1,25 @@
|
|
|
1
1
|
/** @internal Kortix apps only. No semver: it may change in any release. */
|
|
2
|
-
import type { InboxNotification } from '@kortix/sdk';
|
|
3
|
-
import { BellIcon } from '@phosphor-icons/react';
|
|
4
|
-
export interface NotificationPanelProps {
|
|
5
|
-
rows: readonly InboxNotification[];
|
|
6
|
-
state: 'loading' | 'error' | 'ready';
|
|
7
|
-
unreadCount: number;
|
|
8
|
-
/** The footer offer to turn browser notifications on; null hides it. */
|
|
9
|
-
prompt: string | null;
|
|
10
|
-
onOpenRow: (row: InboxNotification) => void;
|
|
11
|
-
onMarkAllRead: () => void;
|
|
12
|
-
onRetry: () => void;
|
|
13
|
-
onTurnOn: () => void;
|
|
14
|
-
onDismissPrompt: () => void;
|
|
15
|
-
}
|
|
16
|
-
/** Props only: the header, the All / Needs you / Done tabs, the rows, and the footer offer. */
|
|
17
|
-
export declare function NotificationPanel({ rows, state, unreadCount, prompt, onOpenRow, onMarkAllRead, onRetry, onTurnOn, onDismissPrompt, }: NotificationPanelProps): import("react").JSX.Element;
|
|
18
2
|
/**
|
|
19
|
-
*
|
|
20
|
-
*
|
|
21
|
-
*
|
|
22
|
-
*
|
|
23
|
-
*
|
|
3
|
+
* `BellMark`: a glyph with a count disc off its bottom-right corner, in the
|
|
4
|
+
* toast's badge-glow style. The account pages' Inbox button (KRTX-1742) and the
|
|
5
|
+
* project home's access-requests control draw their counts with it. The inbox
|
|
6
|
+
* itself is a page:
|
|
7
|
+
* `notification-inbox.tsx`.
|
|
24
8
|
*/
|
|
9
|
+
import { BellIcon } from '@phosphor-icons/react';
|
|
25
10
|
/**
|
|
26
11
|
* The toast's `REFLECTION_MASK` scaled from its 20px icon to the 16px bell
|
|
27
12
|
* (16px → 12px), centred on the glyph's bottom-right corner where the count
|
|
28
13
|
* sits. At full size it would tint the whole bell.
|
|
29
14
|
*/
|
|
30
15
|
export declare const BELL_REFLECTION_MASK = "radial-gradient(circle 12px at 100% 100%, #000 35%, transparent 100%)";
|
|
16
|
+
/**
|
|
17
|
+
* The bell (Paper B12 in the toast's badge-glow style): the glyph muted, then
|
|
18
|
+
* again in the badge's colour under `BELL_REFLECTION_MASK`, so the
|
|
19
|
+
* colour reaches in from the corner the count sits on, as `EntityTile` in
|
|
20
|
+
* `components/ui/toast.tsx` and `TriggerTile` draw it. Yellow when something
|
|
21
|
+
* waits on the person (the Needs you tab), blue otherwise.
|
|
22
|
+
*/
|
|
31
23
|
export declare function BellMark({ count, needsYou, surface, icon: Glyph, }: {
|
|
32
24
|
count: number;
|
|
33
25
|
needsYou: boolean;
|
|
@@ -35,15 +27,3 @@ export declare function BellMark({ count, needsYou, surface, icon: Glyph, }: {
|
|
|
35
27
|
/** The glyph under the count: the bell, or another control's own mark. */
|
|
36
28
|
icon?: typeof BellIcon;
|
|
37
29
|
}): import("react").JSX.Element;
|
|
38
|
-
/**
|
|
39
|
-
* The bell and its popover. Renders nothing, and reads no inbox, while signed
|
|
40
|
-
* out or while the flag is off for `projectId` (without one: for every cached
|
|
41
|
-
* project). `onNavigate` runs when a row opens its subject (the mobile sidebar
|
|
42
|
-
* closes its sheet).
|
|
43
|
-
*/
|
|
44
|
-
export declare function NotificationBell({ projectId, onNavigate, surface, }: {
|
|
45
|
-
projectId?: string;
|
|
46
|
-
onNavigate?: () => void;
|
|
47
|
-
/** The surface the bell sits on: the count disc paints it, so the disc reads as cut out. */
|
|
48
|
-
surface?: 'bg-background' | 'bg-sidebar';
|
|
49
|
-
}): import("react").JSX.Element | null;
|
|
@@ -1,70 +1,20 @@
|
|
|
1
|
-
|
|
2
|
-
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
|
1
|
+
import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
|
|
3
2
|
/**
|
|
4
|
-
*
|
|
5
|
-
*
|
|
6
|
-
*
|
|
7
|
-
*
|
|
8
|
-
*
|
|
9
|
-
* Triggers page for an alert) and marks itself read. When this browser shows
|
|
10
|
-
* no notifications yet, the panel's footer offers to turn them on.
|
|
11
|
-
*
|
|
12
|
-
* `NotificationPanel` is the props-only half: the popover content renders
|
|
13
|
-
* through a portal, so tests render the panel itself.
|
|
3
|
+
* `BellMark`: a glyph with a count disc off its bottom-right corner, in the
|
|
4
|
+
* toast's badge-glow style. The account pages' Inbox button (KRTX-1742) and the
|
|
5
|
+
* project home's access-requests control draw their counts with it. The inbox
|
|
6
|
+
* itself is a page:
|
|
7
|
+
* `notification-inbox.tsx`.
|
|
14
8
|
*/
|
|
15
|
-
import { HoverPrefetchLink } from '../components/hover-prefetch-link.js';
|
|
16
|
-
import { Button } from '../../primitives/button.js';
|
|
17
|
-
import { CountBadge } from '../../primitives/count-badge.js';
|
|
18
|
-
import Hint from '../../primitives/hint.js';
|
|
19
|
-
import { Popover, PopoverContent, PopoverTrigger } from '../../primitives/popover.js';
|
|
20
|
-
import { Skeleton } from '../../primitives/skeleton.js';
|
|
21
|
-
import { Tabs, TabsList, TabsTrigger } from '../../primitives/tabs.js';
|
|
22
|
-
import { ButtonGroup } from '../../primitives/button-group.js';
|
|
23
|
-
import { EmptyState } from '../../primitives/empty-state.js';
|
|
24
|
-
import { SolidCheckIcon } from '../icons/solid-check-icon.js';
|
|
25
|
-
import { ErrorState } from '../../primitives/error-state.js';
|
|
26
|
-
import { useUiViewerId } from '../../providers/ui-provider.js';
|
|
27
|
-
import { useLocale, useTranslations } from '../../i18n/index.js';
|
|
28
|
-
import { relativeTime } from '../lib/relative-time.js';
|
|
29
9
|
import { cn } from '../lib/utils.js';
|
|
30
|
-
import {
|
|
31
|
-
import {
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
/** Every kind glyph is solid: Phosphor at `weight="fill"`, the done check is `SolidCheckIcon`. */
|
|
39
|
-
const solid = (Icon) => function SolidKindIcon(props) {
|
|
40
|
-
return _jsx(Icon, { weight: "fill", ...props });
|
|
41
|
-
};
|
|
42
|
-
const KIND_MARK = {
|
|
43
|
-
turn_done: { icon: SolidCheckIcon, className: 'text-kortix-green' },
|
|
44
|
-
turn_error: { icon: solid(XCircleIcon), className: 'text-kortix-red' },
|
|
45
|
-
question: { icon: solid(QuestionIcon), className: 'text-kortix-yellow' },
|
|
46
|
-
permission: { icon: solid(ShieldWarningIcon), className: 'text-kortix-yellow' },
|
|
47
|
-
shared: { icon: solid(ShareIcon), className: 'text-muted-foreground' },
|
|
48
|
-
automation_failed: { icon: solid(WarningIcon), className: 'text-kortix-red' },
|
|
49
|
-
automation_recovered: { icon: SolidCheckIcon, className: 'text-kortix-green' },
|
|
50
|
-
capture_device_down: { icon: solid(WarningIcon), className: 'text-kortix-red' },
|
|
51
|
-
capture_device_recovered: { icon: SolidCheckIcon, className: 'text-kortix-green' },
|
|
52
|
-
artifact_comment: { icon: solid(ChatCircleIcon), className: 'text-muted-foreground' },
|
|
53
|
-
};
|
|
54
|
-
/** Props only: the header, the All / Needs you / Done tabs, the rows, and the footer offer. */
|
|
55
|
-
export function NotificationPanel({ rows, state, unreadCount, prompt, onOpenRow, onMarkAllRead, onRetry, onTurnOn, onDismissPrompt, }) {
|
|
56
|
-
const t = useTranslations('notifications');
|
|
57
|
-
const locale = useLocale();
|
|
58
|
-
const [tab, setTab] = useState('all');
|
|
59
|
-
const visible = tabRows(rows, tab);
|
|
60
|
-
const needsCount = tabUnreadCount(rows, 'needs');
|
|
61
|
-
const doneCount = tabUnreadCount(rows, 'done');
|
|
62
|
-
return (_jsxs(_Fragment, { children: [_jsxs("div", { className: "flex items-center justify-between gap-2 px-4 pt-2", children: [_jsx("h3", { className: "text-foreground text-sm font-medium", children: t('bell.label') }), unreadCount > 0 ? (_jsx(Button, { variant: "ghost", size: "xs", className: "text-muted-foreground -mr-2.5", onClick: onMarkAllRead, children: t('bell.markAllRead') })) : null] }), _jsx(Tabs, { value: tab, onValueChange: (value) => setTab(value), children: _jsxs(TabsList, { type: "underline", size: "sm", className: "w-full justify-start gap-4 px-4", children: [_jsx(TabsTrigger, { value: "all", className: "w-fit flex-none", children: t('bell.tabAll') }), _jsxs(TabsTrigger, { value: "needs", className: "w-fit flex-none gap-1.5", children: [t('bell.tabNeedsYou'), needsCount > 0 ? _jsx(CountBadge, { count: needsCount, tone: "waiting" }) : null] }), _jsxs(TabsTrigger, { value: "done", className: "w-fit flex-none gap-1.5", children: [t('bell.tabDone'), doneCount > 0 ? _jsx(CountBadge, { count: doneCount }) : null] })] }) }), state === 'loading' ? (_jsx("div", { className: "space-y-1 p-2", children: [0, 1, 2].map((index) => (_jsx(Skeleton, { className: "h-11 py-0" }, index))) })) : state === 'error' ? (_jsx(ErrorState, { size: "sm", title: t('bell.loadError'), action: _jsx(Button, { variant: "outline", size: "sm", onClick: onRetry, children: t('bell.retry') }) })) : visible.length === 0 ? (_jsx(EmptyState, { size: "sm", title: tab === 'needs' && rows.length > 0 ? t('bell.emptyNeedsYou') : t('bell.empty') })) : (_jsx("ul", { className: "max-h-96 space-y-0.5 overflow-y-auto p-1.5", children: visible.map((row) => {
|
|
63
|
-
const mark = KIND_MARK[row.kind] ?? KIND_MARK.shared;
|
|
64
|
-
const unread = !row.read;
|
|
65
|
-
return (_jsx("li", { children: _jsxs(HoverPrefetchLink, { href: withoutNotificationParam(row.url), onClick: () => onOpenRow(row), "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 }), _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('bell.unread') })] })) : null })] }) }, row.id));
|
|
66
|
-
}) })), prompt ? (_jsxs("div", { className: "flex items-center gap-2 border-t px-4 py-2", children: [_jsx("p", { className: "text-muted-foreground min-w-0 flex-1 text-xs text-pretty", children: prompt }), _jsxs(ButtonGroup, { children: [_jsx(Button, { variant: "secondary", size: "xs", onClick: onTurnOn, children: t('bell.turnOn') }), _jsx(Hint, { label: t('bell.dismiss'), side: "top", children: _jsx(Button, { variant: "secondary", size: "icon-sm", "aria-label": t('bell.dismiss'), onClick: onDismissPrompt, children: _jsx(XIcon, { className: "size-3.5 shrink-0" }) }) })] })] })) : null] }));
|
|
67
|
-
}
|
|
10
|
+
import { BellIcon } from '@phosphor-icons/react';
|
|
11
|
+
import { badgeCount } from './notification-rows.js';
|
|
12
|
+
/**
|
|
13
|
+
* The toast's `REFLECTION_MASK` scaled from its 20px icon to the 16px bell
|
|
14
|
+
* (16px → 12px), centred on the glyph's bottom-right corner where the count
|
|
15
|
+
* sits. At full size it would tint the whole bell.
|
|
16
|
+
*/
|
|
17
|
+
export const BELL_REFLECTION_MASK = 'radial-gradient(circle 12px at 100% 100%, #000 35%, transparent 100%)';
|
|
68
18
|
/**
|
|
69
19
|
* The bell (Paper B12 in the toast's badge-glow style): the glyph muted, then
|
|
70
20
|
* again in the badge's colour under `BELL_REFLECTION_MASK`, so the
|
|
@@ -72,12 +22,6 @@ export function NotificationPanel({ rows, state, unreadCount, prompt, onOpenRow,
|
|
|
72
22
|
* `components/ui/toast.tsx` and `TriggerTile` draw it. Yellow when something
|
|
73
23
|
* waits on the person (the Needs you tab), blue otherwise.
|
|
74
24
|
*/
|
|
75
|
-
/**
|
|
76
|
-
* The toast's `REFLECTION_MASK` scaled from its 20px icon to the 16px bell
|
|
77
|
-
* (16px → 12px), centred on the glyph's bottom-right corner where the count
|
|
78
|
-
* sits. At full size it would tint the whole bell.
|
|
79
|
-
*/
|
|
80
|
-
export const BELL_REFLECTION_MASK = 'radial-gradient(circle 12px at 100% 100%, #000 35%, transparent 100%)';
|
|
81
25
|
export function BellMark({ count, needsYou, surface = 'bg-background', icon: Glyph = BellIcon, }) {
|
|
82
26
|
const tone = needsYou
|
|
83
27
|
? { reflection: 'text-kortix-yellow', disc: 'bg-kortix-yellow' }
|
|
@@ -85,50 +29,3 @@ export function BellMark({ count, needsYou, surface = 'bg-background', icon: Gly
|
|
|
85
29
|
return (_jsxs("span", { className: "relative size-4 shrink-0", children: [_jsx(Glyph, { className: "size-4" }), count > 0 ? (_jsxs(_Fragment, { children: [_jsx(Glyph, { "aria-hidden": true, className: cn('absolute inset-0 size-4', tone.reflection), style: { maskImage: BELL_REFLECTION_MASK, WebkitMaskImage: BELL_REFLECTION_MASK } }), _jsx("span", { "aria-hidden": true, className: cn('absolute -right-2.5 -bottom-2 flex rounded-full p-px', surface), children: _jsx("span", { "data-slot": "bell-count", className: cn('text-background flex h-3.5 min-w-3.5 items-center justify-center rounded-full px-0.5 text-[9px] leading-none font-semibold tabular-nums', // audit:allow a numeral in a 13px disc on a 16px glyph; no type rung fits
|
|
86
30
|
tone.disc), children: badgeCount(count) }) })] })) : null] }));
|
|
87
31
|
}
|
|
88
|
-
/**
|
|
89
|
-
* The bell and its popover. Renders nothing, and reads no inbox, while signed
|
|
90
|
-
* out or while the flag is off for `projectId` (without one: for every cached
|
|
91
|
-
* project). `onNavigate` runs when a row opens its subject (the mobile sidebar
|
|
92
|
-
* closes its sheet).
|
|
93
|
-
*/
|
|
94
|
-
export function NotificationBell({ projectId, onNavigate, surface = 'bg-background', }) {
|
|
95
|
-
const t = useTranslations('notifications');
|
|
96
|
-
const viewerId = useUiViewerId();
|
|
97
|
-
const [open, setOpen] = useState(false);
|
|
98
|
-
const notificationCenter = useNotificationInboxEnabled(projectId);
|
|
99
|
-
const inbox = useNotificationInbox({ userId: viewerId, enabled: notificationCenter });
|
|
100
|
-
const notificationsOn = useWebNotificationStore((s) => s.preferences.enabled);
|
|
101
|
-
const permission = useWebNotificationStore((s) => s.permission);
|
|
102
|
-
const promptDismissed = useWebNotificationStore((s) => s.promptDismissed);
|
|
103
|
-
const requestPermission = useWebNotificationStore((s) => s.requestPermission);
|
|
104
|
-
const setPreference = useWebNotificationStore((s) => s.setPreference);
|
|
105
|
-
const dismissPrompt = useWebNotificationStore((s) => s.dismissPrompt);
|
|
106
|
-
if (!viewerId || !notificationCenter)
|
|
107
|
-
return null;
|
|
108
|
-
const count = inbox.unreadCount;
|
|
109
|
-
const needsYou = tabUnreadCount(inbox.data?.notifications ?? [], 'needs') > 0;
|
|
110
|
-
const label = count > 0 ? t('bell.unreadLabel', { count }) : t('bell.label');
|
|
111
|
-
// A fresh profile enables notifications before OS permission is granted.
|
|
112
|
-
const offerTurnOn = isNotificationSupported() &&
|
|
113
|
-
(!notificationsOn || permission === 'default') &&
|
|
114
|
-
permission !== 'denied' &&
|
|
115
|
-
!promptDismissed;
|
|
116
|
-
return (_jsxs(Popover, { open: open, onOpenChange: setOpen, children: [_jsx(Hint, { side: "bottom", label: t('bell.label'), children: _jsx(PopoverTrigger, { asChild: true, children: _jsx(Button, { type: "button", variant: "ghost", size: "icon", "aria-label": label, className: "relative shrink-0", children: _jsx(BellMark, { count: count, needsYou: needsYou, surface: surface }) }) }) }), _jsx(PopoverContent, { align: "start", sideOffset: 8, className: "w-96 overflow-hidden p-0", children: _jsx(NotificationPanel, { rows: inbox.data?.notifications ?? [], state: inbox.data ? 'ready' : inbox.isError ? 'error' : 'loading', unreadCount: count, prompt: offerTurnOn
|
|
117
|
-
? webPushSupported()
|
|
118
|
-
? t('bell.promptPush')
|
|
119
|
-
: t('bell.promptBackground')
|
|
120
|
-
: null, onOpenRow: (row) => {
|
|
121
|
-
setOpen(false);
|
|
122
|
-
onNavigate?.();
|
|
123
|
-
if (!row.read)
|
|
124
|
-
inbox.markRead([row.id]).catch(() => { });
|
|
125
|
-
}, onMarkAllRead: () => {
|
|
126
|
-
inbox.markAllRead().catch(() => { });
|
|
127
|
-
}, onRetry: () => void inbox.refetch(),
|
|
128
|
-
// From the click itself: the browser asks for permission only
|
|
129
|
-
// inside a user gesture.
|
|
130
|
-
onTurnOn: async () => {
|
|
131
|
-
if ((await requestPermission()) === 'granted')
|
|
132
|
-
setPreference('enabled', true);
|
|
133
|
-
}, onDismissPrompt: dismissPrompt }) })] }));
|
|
134
|
-
}
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
/** @internal Kortix apps only. No semver: it may change in any release. */
|
|
2
|
+
import type { InboxNotification } from '@kortix/sdk';
|
|
3
|
+
import { type ReactNode } from 'react';
|
|
4
|
+
/** Where "Notification settings" goes: a page (outside a project) or the Settings overlay (inside one). */
|
|
5
|
+
export type InboxSettingsTarget = {
|
|
6
|
+
href: string;
|
|
7
|
+
} | {
|
|
8
|
+
onOpen: () => void;
|
|
9
|
+
};
|
|
10
|
+
export interface NotificationInboxViewProps {
|
|
11
|
+
rows: readonly InboxNotification[];
|
|
12
|
+
state: 'loading' | 'error' | 'ready';
|
|
13
|
+
unreadCount: number;
|
|
14
|
+
/** The offer to turn browser notifications on; null hides it. */
|
|
15
|
+
prompt: string | null;
|
|
16
|
+
settings: InboxSettingsTarget;
|
|
17
|
+
/**
|
|
18
|
+
* The row above the page outside a project (the account pages' top bar).
|
|
19
|
+
* Then the title is the column's heading. Absent: the project page header.
|
|
20
|
+
*/
|
|
21
|
+
header?: ReactNode;
|
|
22
|
+
onOpenRow: (row: InboxNotification) => void;
|
|
23
|
+
onMarkAllRead: () => void;
|
|
24
|
+
onRetry: () => void;
|
|
25
|
+
onTurnOn: () => void;
|
|
26
|
+
onDismissPrompt: () => void;
|
|
27
|
+
}
|
|
28
|
+
/**
|
|
29
|
+
* Props only: the page frame and header, the description, the All / Needs you
|
|
30
|
+
* / Done tabs with "Mark all as read", the offer, the rows and the settings
|
|
31
|
+
* footer. Inside a project the title is `ProjectPageHeader` (the Review,
|
|
32
|
+
* Goals and Artifacts pages' header: it owns the desktop title-bar band).
|
|
33
|
+
*/
|
|
34
|
+
export declare function NotificationInboxView({ rows, state, unreadCount, prompt, settings, header, onOpenRow, onMarkAllRead, onRetry, onTurnOn, onDismissPrompt, }: NotificationInboxViewProps): import("react").JSX.Element;
|
|
35
|
+
/**
|
|
36
|
+
* The Inbox page. Reads the inbox `NotificationHost` polls (one cache entry,
|
|
37
|
+
* so the sidebar count and the page agree), and renders nothing while signed
|
|
38
|
+
* out. `settingsHref`: the Settings page outside a project (`/settings/…`);
|
|
39
|
+
* without it, "Notification settings" opens the project's Settings overlay.
|
|
40
|
+
* `header` sits above the page (the account pages' top bar).
|
|
41
|
+
*/
|
|
42
|
+
export declare function NotificationInbox({ settingsHref, header }: {
|
|
43
|
+
settingsHref?: string;
|
|
44
|
+
header?: ReactNode;
|
|
45
|
+
}): import("react").JSX.Element | null;
|
|
@@ -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
|
-
*
|
|
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): '
|
|
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
|
|
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
|
-
*
|
|
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
|
|
7
|
-
*
|
|
8
|
-
*
|
|
9
|
-
*
|
|
10
|
-
*
|
|
11
|
-
*
|
|
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)
|
|
58
|
-
*
|
|
59
|
-
*
|
|
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
|
|
6
|
-
*
|
|
7
|
-
*
|
|
8
|
-
*
|
|
9
|
-
*
|
|
10
|
-
*
|
|
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)
|
|
174
|
-
*
|
|
175
|
-
*
|
|
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
|
|
@@ -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
|
-
/**
|
|
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
|
};
|
package/dist/lib/routes.d.ts
CHANGED
|
@@ -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
|
/**
|
package/dist/lib/routes.js
CHANGED
|
@@ -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
|
-
|
|
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;
|