@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.
- package/dist/_vendor/kortix-shared.js +233 -130
- package/dist/_vendor/shared/code-language.d.ts +2 -2
- package/dist/_vendor/shared/html.d.ts +7 -0
- package/dist/_vendor/shared/index.d.ts +1 -2
- package/dist/_vendor/shared/pixel-mark.d.ts +28 -0
- package/dist/_vendor/shared/runtime-versions.d.ts +2 -6
- package/dist/_vendor/shared/tool-output/media-path.d.ts +1 -6
- package/dist/_vendor/shared/tool-output/scan.d.ts +2 -0
- package/dist/_vendor/shared/utils/string.d.ts +6 -0
- package/dist/artifacts/artifact-frame.d.ts +0 -1
- package/dist/artifacts/artifact-frame.js +4 -10
- package/dist/artifacts/artifact-session.js +4 -7
- package/dist/artifacts/frame-policy.d.ts +1 -1
- package/dist/artifacts/frame-policy.js +2 -2
- package/dist/customize/agents/agent-page.js +5 -5
- package/dist/customize/agents/agent-status.js +1 -1
- package/dist/customize/agents/agents-page.js +3 -3
- package/dist/customize/connectors/use-agent-access.d.ts +3 -3
- package/dist/customize/sections/connectors-view.js +50 -37
- package/dist/customize/sections/llm-provider/chatgpt-subscription-connect.js +21 -18
- package/dist/customize/sections/llm-provider/device-grant.d.ts +15 -0
- package/dist/customize/sections/llm-provider/device-grant.js +27 -0
- package/dist/customize/sections/view/agent-editor-catalog.js +0 -5
- package/dist/customize/sections/view/agent-editor.d.ts +2 -2
- package/dist/customize/sections/view/agent-editor.js +2 -2
- package/dist/customize/sections/view/review-center-connected.js +37 -6
- package/dist/customize/sections/view/secret-delivery.d.ts +4 -5
- package/dist/customize/sections/view/secret-delivery.js +5 -4
- package/dist/customize/triggers/schedule/trigger-list.d.ts +2 -2
- package/dist/customize/triggers/schedule/trigger-list.js +12 -18
- package/dist/customize/triggers/schedule/trigger-runs-logic.d.ts +6 -0
- package/dist/customize/triggers/schedule/trigger-runs-logic.js +13 -0
- package/dist/customize/triggers/schedule/trigger-runs-panel.js +9 -2
- package/dist/files/project/api/runtime-files.d.ts +2 -2
- package/dist/files/project/api/runtime-files.js +2 -2
- package/dist/files/project/components/drive-explorer.js +1 -1
- package/dist/files/project/components/drive-grid-view.js +0 -1
- package/dist/files/project/components/drive-list-view.js +0 -1
- package/dist/files/project/components/file-explorer-page.js +1 -1
- package/dist/files/project/hooks/index.d.ts +1 -1
- package/dist/files/project/hooks/index.js +1 -1
- package/dist/files/project/hooks/use-server-health.d.ts +1 -1
- package/dist/files/project/hooks/use-server-health.js +1 -1
- package/dist/files/project/search/workspace-search-service.d.ts +1 -1
- package/dist/files/project/search/workspace-search-service.js +1 -1
- package/dist/files/runtime/hooks/index.d.ts +1 -1
- package/dist/files/runtime/hooks/index.js +1 -1
- package/dist/files/runtime/hooks/server-health-state.d.ts +2 -2
- package/dist/files/runtime/hooks/server-health-state.js +2 -2
- package/dist/files/runtime/hooks/system-dir.js +2 -2
- package/dist/files/runtime/hooks/use-file-content.d.ts +1 -1
- package/dist/files/runtime/hooks/use-file-content.js +1 -1
- package/dist/files/runtime/hooks/use-file-list.d.ts +1 -1
- package/dist/files/runtime/hooks/use-file-list.js +3 -3
- package/dist/files/runtime/hooks/use-server-health.d.ts +2 -2
- package/dist/files/runtime/hooks/use-server-health.js +3 -3
- package/dist/files/runtime/hooks/use-workspace-search.d.ts +1 -2
- package/dist/files/runtime/hooks/use-workspace-search.js +0 -1
- package/dist/files/runtime/index.d.ts +2 -2
- package/dist/files/runtime/index.js +2 -2
- package/dist/files/runtime/path-utils.d.ts +1 -1
- package/dist/files/runtime/path-utils.js +1 -1
- package/dist/files/runtime/sandbox-explorer-source.d.ts +1 -1
- package/dist/files/runtime/sandbox-explorer-source.js +1 -1
- package/dist/files/runtime/sandbox-file-explorer.d.ts +1 -1
- package/dist/files/runtime/sandbox-file-explorer.js +2 -2
- package/dist/files/tree/components/file-tree-item.js +0 -1
- package/dist/files/tree/hooks/use-file-events.d.ts +1 -1
- package/dist/files/tree/hooks/use-file-events.js +1 -1
- package/dist/i18n/en.d.ts +60 -175
- package/dist/i18n/en.js +71 -186
- 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/files/file-read-retry.js +1 -1
- package/dist/internal/files/types.d.ts +2 -2
- package/dist/internal/files/types.js +2 -2
- package/dist/internal/goals/goal-meta.d.ts +33 -14
- package/dist/internal/goals/goal-meta.js +55 -13
- package/dist/internal/layout/nav-hover-card.d.ts +1 -1
- package/dist/internal/layout/nav-hover-card.js +1 -1
- package/dist/internal/layout/project-capability-nav.d.ts +1 -1
- package/dist/internal/layout/project-capability-nav.js +1 -1
- package/dist/internal/lib/browser-error-noise.d.ts +1 -1
- package/dist/internal/lib/browser-error-noise.js +1 -1
- package/dist/internal/lib/browser-noise/rules/expected-states.js +1 -1
- package/dist/internal/lib/browser-noise/rules/injected-scripts.js +29 -0
- package/dist/internal/lib/browser-noise/rules/old-browsers.d.ts +1 -0
- package/dist/internal/lib/browser-noise/rules/old-browsers.js +1 -1
- package/dist/internal/lib/browser-noise/rules/rejections.d.ts +0 -9
- package/dist/internal/lib/browser-noise/rules/rejections.js +0 -14
- package/dist/internal/lib/delivered-but-disconnected.js +3 -5
- package/dist/internal/lib/error-handler.js +8 -3
- package/dist/internal/lib/pixel-mark.d.ts +4 -17
- package/dist/internal/lib/pixel-mark.js +5 -148
- package/dist/internal/lib/sounds.d.ts +4 -4
- package/dist/internal/lib/sounds.js +4 -4
- 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 +5 -5
- 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/composer-prefill-store.js +4 -1
- package/dist/internal/stores/sound-store.d.ts +4 -4
- package/dist/internal/stores/sound-store.js +10 -0
- 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/code/shiki-highlighter.js +14 -5
- 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 +33 -3
- package/dist/markdown/markdown-frontmatter.d.ts +6 -6
- package/dist/markdown/markdown-frontmatter.js +3 -3
- package/dist/primitives/button.d.ts +1 -1
- package/dist/primitives/button.js +2 -1
- package/dist/session/agents/held-messages.d.ts +1 -5
- package/dist/session/agents/held-messages.js +1 -21
- package/dist/session/composer/ComposerAboveCard.d.ts +4 -1
- package/dist/session/composer/ComposerAboveCard.js +2 -2
- package/dist/session/composer/composer-chat-input.d.ts +1 -1
- package/dist/session/composer/composer-chat-input.js +2 -2
- package/dist/session/composer/composer.js +16 -1
- package/dist/session/composer/hooks/use-file-search.d.ts +15 -15
- package/dist/session/composer/hooks/use-file-search.js +16 -16
- package/dist/session/composer/menus/mention-controller.js +1 -3
- package/dist/session/composer/menus/space-mentions.d.ts +14 -4
- package/dist/session/composer/menus/space-mentions.js +17 -1
- package/dist/session/composer/use-instant-session-send.js +2 -2
- package/dist/session/header/reminder-parts.d.ts +1 -1
- package/dist/session/header/session-goal-indicator.js +4 -4
- package/dist/session/header/session-site-header.js +2 -6
- package/dist/session/panel/easy/plan-card.d.ts +2 -2
- package/dist/session/panel/easy/plan-card.js +2 -2
- package/dist/session/panel/session-desktop.js +6 -0
- package/dist/session/panel/session-reminders-panel.js +4 -15
- package/dist/session/panel/use-session-panel-state.js +2 -2
- package/dist/session/status/sandbox-loading-boundary.js +2 -2
- package/dist/session/status/session-terminal-state.d.ts +47 -0
- package/dist/session/status/session-terminal-state.js +56 -0
- package/dist/session/thread/plan-surface.d.ts +1 -1
- package/dist/session/thread/plan-surface.js +1 -1
- package/dist/session/thread/session-chat.d.ts +1 -1
- package/dist/session/thread/session-chat.js +88 -99
- package/dist/session/thread/stop-sequence.d.ts +51 -0
- package/dist/session/thread/stop-sequence.js +55 -0
- package/dist/session/thread/transcript.d.ts +2 -2
- package/dist/session/thread/transcript.js +2 -2
- package/dist/session/tool/tools/apply-patch-tool.d.ts +1 -1
- package/dist/session/tool/tools/apply-patch-tool.js +1 -1
- package/dist/session/tool/tools/kortix-action-tool.js +1 -1
- package/dist/session/tool/tools/multi-agent-tool-bodies.d.ts +1 -1
- package/dist/session/tool/tools/multi-agent-tool-bodies.js +1 -1
- package/dist/session/tool/tools/multi-agent-tools.js +1 -1
- package/dist/session/tool/tools/pty-kill-tool.d.ts +1 -1
- package/dist/session/tool/tools/pty-kill-tool.js +1 -1
- package/dist/session/tool/tools/pty-read-tool.d.ts +2 -2
- package/dist/session/tool/tools/pty-read-tool.js +2 -2
- package/dist/session/tool/tools/pty-spawn-tool.d.ts +1 -1
- package/dist/session/tool/tools/pty-spawn-tool.js +1 -1
- package/dist/session/tool/tools/pty-write-tool.d.ts +1 -1
- package/dist/session/tool/tools/pty-write-tool.js +1 -1
- package/dist/session/tool/tools/session-spawn-tool.js +7 -4
- package/dist/session/tool/tools/task-tool.js +18 -4
- package/dist/session/tool/tools/todo-write-tool.d.ts +1 -1
- package/dist/session/tool/tools/todo-write-tool.js +1 -1
- package/dist/session/turn/peer-message-row.d.ts +1 -10
- package/dist/session/turn/peer-message-row.js +1 -18
- package/dist/session/turn/plan-anchor.d.ts +3 -3
- package/dist/session/turn/plan-anchor.js +3 -3
- package/dist/session/turn/plan-card.d.ts +7 -7
- package/dist/session/turn/plan-card.js +7 -7
- package/dist/styles.css +1 -1
- package/dist/terminal/terminal-card-gate.d.ts +6 -3
- package/dist/terminal/terminal-card-gate.js +21 -4
- package/dist/workspace/home/access-requests-bell.d.ts +6 -9
- package/dist/workspace/home/access-requests-bell.js +8 -10
- package/dist/workspace/index.d.ts +1 -1
- package/dist/workspace/index.js +1 -1
- package/dist/workspace/layout/project-home.js +1 -2
- package/dist/workspace/review/review-center.d.ts +8 -2
- package/dist/workspace/review/review-center.js +44 -13
- package/dist/workspace/review/review-reducer.d.ts +7 -0
- package/dist/workspace/review/review-reducer.js +11 -0
- package/dist/workspace/sidebar/footer/project-artifacts-nav.d.ts +6 -1
- package/dist/workspace/sidebar/footer/project-artifacts-nav.js +47 -4
- package/dist/workspace/sidebar/project-nav-items.js +11 -12
- package/dist/workspace/sidebar/project-sidebar.js +2 -6
- package/dist/workspace/spaces/principal-card.d.ts +3 -1
- package/dist/workspace/spaces/principal-card.js +3 -3
- package/dist/workspace/spaces/space-agent-ask.d.ts +14 -0
- package/dist/workspace/spaces/space-agent-ask.js +36 -0
- package/dist/workspace/spaces/space-details-dialog.js +1 -1
- package/dist/workspace/spaces/space-details-panel.d.ts +2 -1
- package/dist/workspace/spaces/space-details-panel.js +62 -8
- package/dist/workspace/spaces/space-mention-source.d.ts +3 -2
- package/dist/workspace/spaces/space-mention-source.js +12 -19
- package/dist/workspace/spaces/space-view.js +3 -2
- package/package.json +11 -7
- package/skills/kortix-ui/references/custom-dashboard.md +1 -1
- package/skills/kortix-ui/references/modules.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
- package/dist/session/tool/tools/multi-agent-tool-data.d.ts +0 -63
- package/dist/session/tool/tools/multi-agent-tool-data.js +0 -118
|
@@ -32,3 +32,18 @@ export function lastRunLabel(trigger, t, locale, now = Date.now()) {
|
|
|
32
32
|
return rtf.format(-Math.floor(min / (24 * 60)), 'day');
|
|
33
33
|
return rtf.format(-Math.floor(min / (7 * 24 * 60)), 'week');
|
|
34
34
|
}
|
|
35
|
+
/**
|
|
36
|
+
* A future run in whole minutes, hours or days, worded by `rtf`: "in 25m"
|
|
37
|
+
* (narrow), "in 25 minutes" (long). A past time reads as now; "—" with no time.
|
|
38
|
+
*/
|
|
39
|
+
export function nextRunIn(iso, rtf, now = Date.now()) {
|
|
40
|
+
const at = iso ? Date.parse(iso) : Number.NaN;
|
|
41
|
+
if (!Number.isFinite(at))
|
|
42
|
+
return '—';
|
|
43
|
+
const min = Math.max(0, Math.round((at - now) / 60_000));
|
|
44
|
+
if (min < 60)
|
|
45
|
+
return rtf.format(min, 'minute');
|
|
46
|
+
if (min < 24 * 60)
|
|
47
|
+
return rtf.format(Math.round(min / 60), 'hour');
|
|
48
|
+
return rtf.format(Math.round(min / (24 * 60)), 'day');
|
|
49
|
+
}
|
|
@@ -19,9 +19,6 @@ export interface TurnCompleteMsg {
|
|
|
19
19
|
/** Project the session belongs to, captured on the publishing tab's URL —
|
|
20
20
|
* a receiving tab may be on a page where the project is not in the path. */
|
|
21
21
|
projectId?: string | null;
|
|
22
|
-
/** That project's `notification_center` flag in the publishing tab's cache.
|
|
23
|
-
* A receiving tab often never loaded the project. Absent: no answer. */
|
|
24
|
-
notificationCenter?: boolean;
|
|
25
22
|
at: number;
|
|
26
23
|
}
|
|
27
24
|
export declare function noteTurnCompleteShown(sessionId: string, at?: number): void;
|
|
@@ -17,6 +17,8 @@ import type { FeatureFlagKey } from '@kortix/sdk';
|
|
|
17
17
|
* The map is `Partial` because `FeatureFlagKey` still carries deprecated
|
|
18
18
|
* graduated keys that the API no longer serves; they have no member here, and
|
|
19
19
|
* `requiresFlag` may only name a served key (pinned by the same test).
|
|
20
|
+
* `volumes`, `drives` and `artifacts` graduated but are still served: each
|
|
21
|
+
* reads whether the platform stores Files (Platinum).
|
|
20
22
|
*
|
|
21
23
|
* Fail-closed: every member is `false` until the project detail resolves.
|
|
22
24
|
*/
|
|
@@ -17,6 +17,8 @@ import { useFeatureFlag } from '@kortix/sdk/react';
|
|
|
17
17
|
* The map is `Partial` because `FeatureFlagKey` still carries deprecated
|
|
18
18
|
* graduated keys that the API no longer serves; they have no member here, and
|
|
19
19
|
* `requiresFlag` may only name a served key (pinned by the same test).
|
|
20
|
+
* `volumes`, `drives` and `artifacts` graduated but are still served: each
|
|
21
|
+
* reads whether the platform stores Files (Platinum).
|
|
20
22
|
*
|
|
21
23
|
* Fail-closed: every member is `false` until the project detail resolves.
|
|
22
24
|
*/
|
|
@@ -27,7 +29,6 @@ export function useProjectFeatureFlags(projectId) {
|
|
|
27
29
|
const pooledProviderSecrets = useFeatureFlag(projectId, 'pooled_provider_secrets');
|
|
28
30
|
const usRegion = useFeatureFlag(projectId, 'us_region');
|
|
29
31
|
const eventTriggers = useFeatureFlag(projectId, 'event_triggers');
|
|
30
|
-
const notificationCenter = useFeatureFlag(projectId, 'notification_center');
|
|
31
32
|
const volumes = useFeatureFlag(projectId, 'volumes');
|
|
32
33
|
const drives = useFeatureFlag(projectId, 'drives');
|
|
33
34
|
const sessionLog = useFeatureFlag(projectId, 'session_log');
|
|
@@ -35,7 +36,6 @@ export function useProjectFeatureFlags(projectId) {
|
|
|
35
36
|
const sharedDrives = useFeatureFlag(projectId, 'shared_drives');
|
|
36
37
|
const goals = useFeatureFlag(projectId, 'goals');
|
|
37
38
|
const artifacts = useFeatureFlag(projectId, 'artifacts');
|
|
38
|
-
const artifactComments = useFeatureFlag(projectId, 'artifact_comments');
|
|
39
39
|
const emailChannel = useFeatureFlag(projectId, 'email_channel');
|
|
40
40
|
const workspaceVolume = useFeatureFlag(projectId, 'workspace_volume');
|
|
41
41
|
const sessionGroups = useFeatureFlag(projectId, 'session_groups');
|
|
@@ -44,6 +44,7 @@ export function useProjectFeatureFlags(projectId) {
|
|
|
44
44
|
const voiceCall = useFeatureFlag(projectId, 'voice_call');
|
|
45
45
|
const chatInput = useFeatureFlag(projectId, 'chat_input');
|
|
46
46
|
const chatFront = useFeatureFlag(projectId, 'chat_front');
|
|
47
|
+
const spacesProactive = useFeatureFlag(projectId, 'spaces_proactive');
|
|
47
48
|
return {
|
|
48
49
|
flags: {
|
|
49
50
|
marketplace: marketplace.enabled,
|
|
@@ -52,7 +53,6 @@ export function useProjectFeatureFlags(projectId) {
|
|
|
52
53
|
pooled_provider_secrets: pooledProviderSecrets.enabled,
|
|
53
54
|
us_region: usRegion.enabled,
|
|
54
55
|
event_triggers: eventTriggers.enabled,
|
|
55
|
-
notification_center: notificationCenter.enabled,
|
|
56
56
|
volumes: volumes.enabled,
|
|
57
57
|
drives: drives.enabled,
|
|
58
58
|
session_log: sessionLog.enabled,
|
|
@@ -60,7 +60,6 @@ export function useProjectFeatureFlags(projectId) {
|
|
|
60
60
|
shared_drives: sharedDrives.enabled,
|
|
61
61
|
goals: goals.enabled,
|
|
62
62
|
artifacts: artifacts.enabled,
|
|
63
|
-
artifact_comments: artifactComments.enabled,
|
|
64
63
|
email_channel: emailChannel.enabled,
|
|
65
64
|
workspace_volume: workspaceVolume.enabled,
|
|
66
65
|
session_groups: sessionGroups.enabled,
|
|
@@ -69,8 +68,9 @@ export function useProjectFeatureFlags(projectId) {
|
|
|
69
68
|
voice_call: voiceCall.enabled,
|
|
70
69
|
chat_input: chatInput.enabled,
|
|
71
70
|
chat_front: chatFront.enabled,
|
|
71
|
+
spaces_proactive: spacesProactive.enabled,
|
|
72
72
|
},
|
|
73
73
|
// The trailing hook's loading state — keep this on the LAST hook above.
|
|
74
|
-
isLoading:
|
|
74
|
+
isLoading: spacesProactive.isLoading,
|
|
75
75
|
};
|
|
76
76
|
}
|
|
@@ -50,13 +50,6 @@ export interface WebNotificationPayload {
|
|
|
50
50
|
};
|
|
51
51
|
/** Localized "{count} tasks finished" for the stack several turns collapse into. */
|
|
52
52
|
stackTitle?: (count: number) => string;
|
|
53
|
-
/** A row of the notification inbox. Inbox rows exist only for projects with `notification_center` on. */
|
|
54
|
-
fromInbox?: boolean;
|
|
55
|
-
/**
|
|
56
|
-
* The project's `notification_center` flag as the tab that raised the event
|
|
57
|
-
* knew it (a relayed completion). Absent: this tab's query cache decides.
|
|
58
|
-
*/
|
|
59
|
-
notificationCenter?: boolean;
|
|
60
53
|
}
|
|
61
54
|
export declare function setServerPushPreferences(kinds: NotificationPreferences['kinds'] | null | undefined): void;
|
|
62
55
|
/**
|
|
@@ -191,7 +184,7 @@ extra?: {
|
|
|
191
184
|
* shape the broadcast receiver runs so a relayed completion cannot re-broadcast
|
|
192
185
|
* and loop. It takes the relayed message whole, so no field gets lost.
|
|
193
186
|
*/
|
|
194
|
-
export declare function notifyTaskCompleteFor({ sessionId, sessionTitle, projectId
|
|
187
|
+
export declare function notifyTaskCompleteFor({ sessionId, sessionTitle, projectId }: Omit<TurnCompleteMsg, 'at'>, tI18nComplete: UiTranslator): void;
|
|
195
188
|
/**
|
|
196
189
|
* Notify that a session encountered an error.
|
|
197
190
|
*/
|
|
@@ -14,21 +14,17 @@ import { createElement } from 'react';
|
|
|
14
14
|
* 1. Browser support for the Notification API
|
|
15
15
|
* 2. Permission is granted
|
|
16
16
|
* 3. Master enable toggle is on
|
|
17
|
-
* 4. The kind:
|
|
18
|
-
* session of a project with `notification_center` on), the person's
|
|
19
|
-
* server-side Push choice; otherwise the per-browser kind switch
|
|
17
|
+
* 4. The kind: the person's server-side Push choice for it
|
|
20
18
|
* 5. Optionally skips if tab is visible (onlyWhenHidden preference)
|
|
21
19
|
*
|
|
22
20
|
* Every OS notification carries the tag of the Web Push message for the same
|
|
23
21
|
* event: `<type>:<sessionId>`, or `<type>:<projectId>:<triggerSlug>` for an
|
|
24
22
|
* alert (`notificationTag`). Only two service-worker notifications with one
|
|
25
23
|
* tag replace each other: a `new Notification` never replaces one. So while
|
|
26
|
-
* this browser holds a Web Push subscription, the service worker shows
|
|
27
|
-
*
|
|
28
|
-
*
|
|
29
|
-
* the notification center (KRTX-1742).
|
|
24
|
+
* this browser holds a Web Push subscription, the service worker shows this
|
|
25
|
+
* page's copy too, and whichever copy arrives second replaces the first
|
|
26
|
+
* (KRTX-1742).
|
|
30
27
|
*/
|
|
31
|
-
import { cachedNotificationCenter, cachedNotificationCenterAnswer, } from '../hooks/use-notification-center.js';
|
|
32
28
|
import { hasWebPushSubscription } from '../notifications/web-push.js';
|
|
33
29
|
import { customToast, dismissToast, ToastCard, toastIcon, errorToast, infoToast, successToast, warningToast, } from '../../primitives/toast.js';
|
|
34
30
|
import { ClockIcon, GitPullRequestIcon } from '@phosphor-icons/react';
|
|
@@ -75,27 +71,6 @@ export function setServerPushPreferences(kinds) {
|
|
|
75
71
|
function serverPushAllows(type) {
|
|
76
72
|
return serverPush[TYPE_TO_KIND[type]] !== false;
|
|
77
73
|
}
|
|
78
|
-
/**
|
|
79
|
-
* The per-browser switch of each session kind: the kind gate for a payload of
|
|
80
|
-
* a project with `notification_center` off. The other kinds come only from
|
|
81
|
-
* the inbox.
|
|
82
|
-
*/
|
|
83
|
-
const TYPE_TO_PREF = {
|
|
84
|
-
completion: 'onCompletion',
|
|
85
|
-
error: 'onError',
|
|
86
|
-
question: 'onQuestion',
|
|
87
|
-
permission: 'onPermission',
|
|
88
|
-
};
|
|
89
|
-
/**
|
|
90
|
-
* An inbox row, or a session of a project with `notification_center` on: by
|
|
91
|
-
* the raising tab's answer, else by this tab's cached detail or project list.
|
|
92
|
-
* Fail-closed: no project id or nothing cached takes the path from before
|
|
93
|
-
* the notification center.
|
|
94
|
-
*/
|
|
95
|
-
function fromNotificationCenter(payload) {
|
|
96
|
-
return (payload.fromInbox === true ||
|
|
97
|
-
(payload.notificationCenter ?? cachedNotificationCenter(getSharedQueryClient(), payload.projectId)));
|
|
98
|
-
}
|
|
99
74
|
/** Map notification types to sound events */
|
|
100
75
|
const TYPE_TO_SOUND = {
|
|
101
76
|
completion: 'completion',
|
|
@@ -318,7 +293,6 @@ export function sendWebNotification(payload,
|
|
|
318
293
|
/** Skip all preference/permission gates (used for test notifications) */
|
|
319
294
|
force = false) {
|
|
320
295
|
const { preferences } = useWebNotificationStore.getState();
|
|
321
|
-
const notificationCenter = fromNotificationCenter(payload);
|
|
322
296
|
// `force` (the settings test button) never counts as on screen, focused or
|
|
323
297
|
// another project: it exists to prove the channels work.
|
|
324
298
|
const { sessionId } = payload;
|
|
@@ -357,16 +331,9 @@ force = false) {
|
|
|
357
331
|
// Preferences check
|
|
358
332
|
if (!preferences.enabled)
|
|
359
333
|
return null;
|
|
360
|
-
// Kind check: the person's Push choice,
|
|
361
|
-
if (
|
|
362
|
-
|
|
363
|
-
return null;
|
|
364
|
-
}
|
|
365
|
-
else {
|
|
366
|
-
const prefKey = TYPE_TO_PREF[payload.type];
|
|
367
|
-
if (prefKey && !preferences[prefKey])
|
|
368
|
-
return null;
|
|
369
|
-
}
|
|
334
|
+
// Kind check: the person's Push choice, the same one the phone obeys.
|
|
335
|
+
if (!serverPushAllows(payload.type))
|
|
336
|
+
return null;
|
|
370
337
|
// On-screen and other-project check: see `notificationChannels`.
|
|
371
338
|
if (!channels.os)
|
|
372
339
|
return null;
|
|
@@ -378,9 +345,8 @@ force = false) {
|
|
|
378
345
|
}
|
|
379
346
|
// With Web Push on, the service worker also shows this event's push, and a
|
|
380
347
|
// `new Notification` would never replace it: hand this copy to the worker.
|
|
381
|
-
// `force` (the settings test button) keeps the in-page notification.
|
|
382
|
-
|
|
383
|
-
if (!force && notificationCenter && hasWebPushSubscription() && 'serviceWorker' in navigator) {
|
|
348
|
+
// `force` (the settings test button) keeps the in-page notification.
|
|
349
|
+
if (!force && hasWebPushSubscription() && 'serviceWorker' in navigator) {
|
|
384
350
|
void showWorkerNotification(payload);
|
|
385
351
|
return null;
|
|
386
352
|
}
|
|
@@ -730,15 +696,9 @@ extra) {
|
|
|
730
696
|
if (since !== undefined && turnCompleteShownSince(sessionId, since))
|
|
731
697
|
return;
|
|
732
698
|
// Resolved here and relayed whole: a receiving tab may be on a page whose
|
|
733
|
-
// path holds no project id
|
|
734
|
-
// `notification_center` flag.
|
|
699
|
+
// path holds no project id.
|
|
735
700
|
const projectId = extra?.projectId ?? currentProjectId();
|
|
736
|
-
const msg = {
|
|
737
|
-
sessionId,
|
|
738
|
-
sessionTitle,
|
|
739
|
-
projectId,
|
|
740
|
-
notificationCenter: cachedNotificationCenterAnswer(getSharedQueryClient(), projectId),
|
|
741
|
-
};
|
|
701
|
+
const msg = { sessionId, sessionTitle, projectId };
|
|
742
702
|
broadcastTurnComplete(msg);
|
|
743
703
|
notifyTaskCompleteFor(msg, tI18nComplete);
|
|
744
704
|
}
|
|
@@ -747,7 +707,7 @@ extra) {
|
|
|
747
707
|
* shape the broadcast receiver runs so a relayed completion cannot re-broadcast
|
|
748
708
|
* and loop. It takes the relayed message whole, so no field gets lost.
|
|
749
709
|
*/
|
|
750
|
-
export function notifyTaskCompleteFor({ sessionId, sessionTitle, projectId
|
|
710
|
+
export function notifyTaskCompleteFor({ sessionId, sessionTitle, projectId }, tI18nComplete) {
|
|
751
711
|
noteTurnCompleteShown(sessionId);
|
|
752
712
|
// On a channel or DM page the turn is a thread: it says "thread" and opens
|
|
753
713
|
// in the page's panel. A default title ("New session - <time>") names nothing.
|
|
@@ -775,7 +735,6 @@ export function notifyTaskCompleteFor({ sessionId, sessionTitle, projectId, noti
|
|
|
775
735
|
// page — reinterpreting it as THIS tab's project would build a wrong
|
|
776
736
|
// deep link (the same rule the click-time path documents above).
|
|
777
737
|
projectId,
|
|
778
|
-
notificationCenter,
|
|
779
738
|
};
|
|
780
739
|
if (!projectId) {
|
|
781
740
|
sendWebNotification(payload);
|
|
@@ -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;
|