@nextclaw/ui 0.15.20 → 0.15.22
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/CHANGELOG.md +42 -0
- package/dist/assets/{api-tWUa6l9J.js → api-B1yHQYs-.js} +6 -6
- package/dist/assets/app-presenter-provider-uP9waOzv.js +108 -0
- package/dist/assets/appearance-settings-page-C9Zq3hP9.js +1 -0
- package/dist/assets/{book-open-BQ29ZmDE.js → book-open-oSmyVXea.js} +1 -1
- package/dist/assets/{card-CtKueklV.js → card-CGvJZTZp.js} +1 -1
- package/dist/assets/{channels-list-page-C8y3rqYt.js → channels-list-page-5BTxpQHw.js} +2 -2
- package/dist/assets/chat-page-jTvli8Jp.js +1 -0
- package/dist/assets/config-split-page-BgBsUmp1.js +1 -0
- package/dist/assets/confirm-dialog-h849QRWO.js +5 -0
- package/dist/assets/desktop-update-config-BGGHxClR.js +1 -0
- package/dist/assets/{dist-rYHnBo8t.js → dist-CxUhurq9.js} +1 -1
- package/dist/assets/doc-browser-0eL8AX42.js +1 -0
- package/dist/assets/{doc-browser-D8ng4EUc.js → doc-browser-DEqE9lsh.js} +1 -1
- package/dist/assets/{doc-browser-context-CPHNzQ8m.js → doc-browser-context-DkzFIUoK.js} +1 -1
- package/dist/assets/{eye-CiJz3ODY.js → eye-gOWQGt8N.js} +1 -1
- package/dist/assets/{form-actions-BnZVzLZf.js → form-actions-CgjYZUzM.js} +1 -1
- package/dist/assets/index-DSAUWCfl.js +2 -0
- package/dist/assets/index-G7cBryJ4.css +1 -0
- package/dist/assets/loader-circle-BAuycGf6.js +1 -0
- package/dist/assets/{logo-badge-BXI-Kdhd.js → logo-badge-BNcsDsUM.js} +1 -1
- package/dist/assets/{mcp-marketplace-page-CxNe-Q9Q.js → mcp-marketplace-page-BX39MtPa.js} +3 -3
- package/dist/assets/mcp-marketplace-page-CkDtOEA4.js +1 -0
- package/dist/assets/{model-config-page-CR_mgEVp.js → model-config-page-7MIXg2fQ.js} +1 -1
- package/dist/assets/{navigation-link-C1cvB7y4.js → navigation-link-B3iFOdxx.js} +1 -1
- package/dist/assets/plus-yvhFgfal.js +1 -0
- package/dist/assets/{popover-ZoDwVwwd.js → popover-Cpep_rJe.js} +1 -1
- package/dist/assets/{provider-models-CXUgDxGR.js → provider-models-CUrptZ-o.js} +1 -1
- package/dist/assets/provider-scoped-model-input-CHmOzz7x.js +1 -0
- package/dist/assets/providers-config-page-A6J7Y0II.js +1 -0
- package/dist/assets/react-BCJGCjrP.js +8 -0
- package/dist/assets/{refresh-cw-DKewcdAl.js → refresh-cw-CkKwPztT.js} +1 -1
- package/dist/assets/remote-FD-ZfSIn.js +1 -0
- package/dist/assets/rotate-cw-DrJMfHhp.js +1 -0
- package/dist/assets/runtime-config-page-DwjO-Vs6.js +1 -0
- package/dist/assets/{save-BrckuAXY.js → save-BINMWate.js} +1 -1
- package/dist/assets/{search-BhXQB2TO.js → search-7M38azRp.js} +1 -1
- package/dist/assets/{search-config-page-DFOQ6SDJ.js → search-config-page-T6tMhXbP.js} +1 -1
- package/dist/assets/{secrets-config-page-BqqeClqE.js → secrets-config-page-2mVejXf2.js} +2 -2
- package/dist/assets/security-config-DD5RrjDe.js +1 -0
- package/dist/assets/{select-CVzGGT38.js → select-BvidP5Oa.js} +1 -1
- package/dist/assets/{settings-2-BP6L2enG.js → settings-2-DqZstREV.js} +1 -1
- package/dist/assets/skeleton-BEQW2Dva.js +1 -0
- package/dist/assets/{tabs-B-QWjKCL.js → tabs-BeLxVmkt.js} +1 -1
- package/dist/assets/{tag-chip-C88mxjwx.js → tag-chip-BoDaLnWt.js} +1 -1
- package/dist/assets/{trash-2-ck3t33I3.js → trash-2-CYUskMMN.js} +1 -1
- package/dist/assets/{use-config-BAr5bH2c.js → use-config-CxKRXXCl.js} +1 -1
- package/dist/assets/use-confirm-dialog-HASTvOP2.js +1 -0
- package/dist/assets/{use-viewport-layout-k1isXfNm.js → use-viewport-layout-CJxkjoRz.js} +1 -1
- package/dist/assets/x-DdUwjre5.js +1 -0
- package/dist/index.html +29 -29
- package/package.json +8 -8
- package/src/app/components/__tests__/app-notification-runtime.test.tsx +32 -0
- package/src/app/components/app-notification-runtime.tsx +15 -0
- package/src/app/components/layout/sidebar-items.tsx +23 -9
- package/src/app/components/layout/sidebar-rail.styles.ts +0 -2
- package/src/app/components/layout/sidebar.tsx +2 -2
- package/src/app/configs/app-navigation.config.ts +21 -0
- package/src/app/index.tsx +22 -2
- package/src/app/presenters/app.presenter.ts +8 -0
- package/src/app/styles/design-system.css +12 -0
- package/src/features/chat/components/chat-sidebar-list-mode-switch.tsx +2 -2
- package/src/features/chat/components/conversation/__tests__/chat-conversation-content.test.tsx +19 -1
- package/src/features/chat/components/conversation/__tests__/chat-conversation-header-section.test.tsx +1 -1
- package/src/features/chat/components/conversation/chat-conversation-content.tsx +5 -6
- package/src/features/chat/components/conversation/chat-conversation-header.tsx +1 -1
- package/src/features/chat/components/layout/__tests__/chat-sidebar-read-state.test.tsx +1 -1
- package/src/features/chat/components/layout/__tests__/chat-sidebar-session-area.test.tsx +52 -0
- package/src/features/chat/components/layout/__tests__/chat-sidebar.test.tsx +11 -17
- package/src/features/chat/components/layout/chat-page-shell.tsx +9 -13
- package/src/features/chat/components/layout/chat-sidebar-desktop-layout.tsx +40 -38
- package/src/features/chat/components/layout/chat-sidebar-toolbar.tsx +13 -64
- package/src/features/chat/components/layout/chat-sidebar-utility-menu.tsx +1 -4
- package/src/features/chat/features/conversation/components/__tests__/session-conversation-area.test.tsx +1 -1
- package/src/features/chat/features/conversation/components/__tests__/session-conversation-input.streaming.test.tsx +15 -4
- package/src/features/chat/features/conversation/components/session-conversation-area.tsx +7 -7
- package/src/features/chat/features/conversation/components/session-conversation-input.tsx +4 -2
- package/src/features/chat/features/conversation/hooks/use-session-conversation-input-attachments.ts +1 -0
- package/src/features/chat/features/conversation/utils/session-conversation-input-toolbar.utils.ts +1 -0
- package/src/features/chat/features/conversation/utils/session-queued-input.utils.ts +1 -0
- package/src/features/chat/features/input/utils/__tests__/chat-input-bar.utils.test.ts +3 -0
- package/src/features/chat/features/input/utils/chat-input-bar.utils.ts +0 -1
- package/src/features/chat/features/input/utils/chat-input-toolbar.utils.ts +3 -0
- package/src/features/chat/features/message/utils/__tests__/chat-message-timeline.utils.test.ts +29 -0
- package/src/features/chat/features/message/utils/chat-message-timeline.utils.ts +4 -1
- package/src/features/chat/features/session/components/chat-sidebar-session-item.tsx +10 -10
- package/src/features/chat/features/session/components/chat-sidebar-session-list.tsx +2 -2
- package/src/features/chat/features/session/components/session-header/chat-session-header-menu-item.tsx +1 -1
- package/src/features/chat/features/session/components/session-header/chat-session-project-badge.tsx +1 -1
- package/src/features/chat/features/session/components/session-header/chat-session-switcher-groups.tsx +1 -1
- package/src/features/chat/features/session/components/session-header/chat-session-title-switcher.tsx +1 -1
- package/src/features/chat/features/session/utils/__tests__/chat-session-display.utils.test.ts +26 -0
- package/src/features/chat/features/session/utils/__tests__/ncp-session-adapter.utils.test.ts +4 -2
- package/src/features/chat/features/session/utils/chat-session-display.utils.ts +48 -12
- package/src/features/chat/features/session/utils/ncp-session-adapter.utils.ts +13 -4
- package/src/features/chat/features/welcome/components/__tests__/chat-conversation-welcome.test.tsx +6 -0
- package/src/features/chat/features/welcome/components/__tests__/chat-welcome.test.tsx +10 -7
- package/src/features/chat/features/welcome/components/chat-welcome-agent-picker.tsx +1 -1
- package/src/features/chat/features/welcome/components/chat-welcome-project-picker.tsx +3 -14
- package/src/features/chat/features/welcome/components/chat-welcome-prompt-suggestions.tsx +37 -0
- package/src/features/chat/features/welcome/components/chat-welcome-session-type-picker.tsx +1 -1
- package/src/features/chat/features/welcome/components/chat-welcome.tsx +33 -31
- package/src/features/chat/features/workspace/components/__tests__/chat-session-workspace-panel-content.test.tsx +1 -1
- package/src/features/chat/features/workspace/components/__tests__/chat-session-workspace-panel.test.tsx +1 -1
- package/src/features/chat/index.ts +1 -0
- package/src/features/chat/managers/__tests__/chat-completion-notification.manager.test.ts +177 -0
- package/src/features/chat/managers/__tests__/chat-session-list.manager.test.ts +15 -3
- package/src/features/chat/managers/__tests__/chat-thread.manager.test.ts +3 -10
- package/src/features/chat/managers/chat-completion-notification.manager.ts +146 -0
- package/src/features/chat/managers/chat-session-list.manager.ts +3 -23
- package/src/features/chat/managers/chat-thread.manager.ts +2 -5
- package/src/features/chat/pages/__tests__/ncp-chat-page.test.tsx +32 -11
- package/src/features/chat/pages/ncp-chat-page.tsx +9 -1
- package/src/features/chat/types/chat-input-bar.types.ts +1 -0
- package/src/features/cron/components/cron-task-discovery.tsx +1 -1
- package/src/features/inbox/components/inbox-delivery-content.test.tsx +57 -0
- package/src/features/inbox/components/inbox-delivery-content.tsx +118 -0
- package/src/features/inbox/components/inbox-reader-dialog.test.tsx +77 -0
- package/src/features/inbox/components/inbox-reader-dialog.tsx +224 -0
- package/src/features/inbox/components/inbox-runtime.tsx +14 -0
- package/src/features/inbox/hooks/use-inbox-deliveries.ts +14 -0
- package/src/features/inbox/index.ts +7 -0
- package/src/features/inbox/managers/inbox.manager.test.ts +86 -0
- package/src/features/inbox/managers/inbox.manager.ts +178 -0
- package/src/features/inbox/pages/inbox-page.test.ts +28 -0
- package/src/features/inbox/pages/inbox-page.tsx +385 -0
- package/src/features/inbox/stores/inbox.store.ts +23 -0
- package/src/features/marketplace/components/marketplace-page-parts.tsx +1 -1
- package/src/features/notifications/components/__tests__/app-notification-toast.test.tsx +51 -0
- package/src/features/notifications/components/app-notification-toast.tsx +80 -0
- package/src/features/notifications/index.ts +8 -0
- package/src/features/notifications/managers/__tests__/app-notification.manager.test.ts +75 -0
- package/src/features/notifications/managers/app-notification.manager.ts +41 -0
- package/src/features/panel-apps/components/panel-app-list-item.tsx +1 -1
- package/src/features/panel-apps/components/panel-app-toolbar.tsx +2 -2
- package/src/features/panel-apps/components/panel-apps-list.tsx +4 -4
- package/src/features/service-apps/components/service-apps-panel.tsx +1 -1
- package/src/features/settings/components/config/provider-auth-section.tsx +90 -59
- package/src/features/settings/components/config/provider-form.tsx +10 -17
- package/src/features/settings/components/config/provider-status-badge.tsx +4 -2
- package/src/features/settings/pages/__tests__/providers-config-page.test.tsx +12 -0
- package/src/features/settings/pages/providers-config-page.tsx +2 -1
- package/src/platforms/mobile/components/__tests__/mobile-app-shell.test.tsx +13 -7
- package/src/platforms/mobile/components/__tests__/mobile-bottom-nav.test.tsx +18 -20
- package/src/platforms/mobile/components/mobile-bottom-nav.tsx +14 -7
- package/src/shared/components/doc-browser/doc-browser-panel-parts.tsx +1 -1
- package/src/shared/components/path-picker/server-path-picker-directory-list.tsx +1 -1
- package/src/shared/components/path-picker/server-path-picker-locations.tsx +1 -1
- package/src/shared/components/path-picker/server-path-picker-navigation-bar.tsx +3 -3
- package/src/shared/components/ui/actions/__tests__/icon-action-button.test.tsx +1 -1
- package/src/shared/components/ui/actions/icon-action-button.tsx +1 -1
- package/src/shared/components/ui/button.tsx +4 -4
- package/src/shared/components/ui/dialog.tsx +1 -1
- package/src/shared/components/ui/input.tsx +1 -1
- package/src/shared/components/ui/scroll-area.tsx +2 -0
- package/src/shared/components/ui/select.tsx +1 -1
- package/src/shared/components/ui/switch.tsx +1 -1
- package/src/shared/components/ui/tabs.tsx +1 -1
- package/src/shared/components/ui/textarea.tsx +1 -1
- package/src/shared/lib/api/ncp-session.types.ts +1 -0
- package/src/shared/lib/api/types.ts +2 -0
- package/src/shared/lib/i18n/index.ts +4 -0
- package/src/shared/lib/i18n/locales/en-US/chat.json +16 -14
- package/src/shared/lib/i18n/locales/en-US/inbox.json +30 -0
- package/src/shared/lib/i18n/locales/zh-CN/chat.json +16 -14
- package/src/shared/lib/i18n/locales/zh-CN/inbox.json +30 -0
- package/src/shared/lib/provider-models/__tests__/anonymous-provider-configuration.test.ts +40 -0
- package/src/shared/lib/provider-models/index.ts +4 -3
- package/dist/assets/app-presenter-provider-s-FrOinZ.js +0 -106
- package/dist/assets/appearance-settings-page-dMRBD7ni.js +0 -1
- package/dist/assets/chat-page-MXBltS3G.js +0 -1
- package/dist/assets/config-split-page-uC6d_r9c.js +0 -1
- package/dist/assets/confirm-dialog-C1pbqHZX.js +0 -5
- package/dist/assets/desktop-update-config-DssP8LCk.js +0 -1
- package/dist/assets/doc-browser-AXF1zRsM.js +0 -1
- package/dist/assets/index-CocHWEsI.js +0 -2
- package/dist/assets/index-DN6KM7WD.css +0 -1
- package/dist/assets/loader-circle-AOpK5kkW.js +0 -1
- package/dist/assets/mcp-marketplace-page-5ogeBHnl.js +0 -1
- package/dist/assets/plus-DI37QuHc.js +0 -1
- package/dist/assets/provider-scoped-model-input-DIL6Ex_d.js +0 -1
- package/dist/assets/providers-config-page-D2NXVctW.js +0 -1
- package/dist/assets/react-39CDNZlM.js +0 -8
- package/dist/assets/remote-DYOOO1YG.js +0 -1
- package/dist/assets/rotate-cw-PmqA8LQT.js +0 -1
- package/dist/assets/runtime-config-page-0lb5NyKc.js +0 -1
- package/dist/assets/security-config-13AtPIlm.js +0 -1
- package/dist/assets/skeleton-OwCNQJ7M.js +0 -1
- package/dist/assets/use-confirm-dialog-C4e0nG_4.js +0 -1
- package/dist/assets/x-C1ijNWcE.js +0 -1
- package/src/features/chat/features/welcome/components/chat-welcome-capability-grid.tsx +0 -59
|
@@ -0,0 +1,178 @@
|
|
|
1
|
+
import type { QueryClient } from "@tanstack/react-query";
|
|
2
|
+
import type {
|
|
3
|
+
InboxDelivery,
|
|
4
|
+
InboxDeliveryListView,
|
|
5
|
+
InboxDeliveryStateAction,
|
|
6
|
+
} from "@nextclaw/shared";
|
|
7
|
+
import { eventKeys } from "@nextclaw/shared";
|
|
8
|
+
import { appQueryClient } from "@/app-query-client";
|
|
9
|
+
import { useInboxStore } from "@/features/inbox/stores/inbox.store";
|
|
10
|
+
import { nextclawClient } from "@/shared/lib/api";
|
|
11
|
+
|
|
12
|
+
export const INBOX_DELIVERIES_QUERY_KEY = ["inbox-deliveries"] as const;
|
|
13
|
+
|
|
14
|
+
function buildListView(deliveries: InboxDelivery[]): InboxDeliveryListView {
|
|
15
|
+
return {
|
|
16
|
+
deliveries,
|
|
17
|
+
total: deliveries.length,
|
|
18
|
+
unreadCount: deliveries.filter((delivery) => !delivery.readAt && !delivery.archivedAt).length,
|
|
19
|
+
unpresentedCount: deliveries.filter((delivery) =>
|
|
20
|
+
!delivery.presentedAt && !delivery.readAt && !delivery.archivedAt
|
|
21
|
+
).length,
|
|
22
|
+
};
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
export class InboxManager {
|
|
26
|
+
private readonly cleanups: Array<() => void> = [];
|
|
27
|
+
private offerPromise: Promise<void> | null = null;
|
|
28
|
+
private started = false;
|
|
29
|
+
|
|
30
|
+
constructor(private readonly queryClient: QueryClient = appQueryClient) {}
|
|
31
|
+
|
|
32
|
+
start = (): void => {
|
|
33
|
+
if (this.started) {
|
|
34
|
+
return;
|
|
35
|
+
}
|
|
36
|
+
this.started = true;
|
|
37
|
+
this.cleanups.push(
|
|
38
|
+
nextclawClient.eventBus.on(
|
|
39
|
+
eventKeys.inboxDeliveryChanged,
|
|
40
|
+
this.handleDeliveryChanged,
|
|
41
|
+
),
|
|
42
|
+
);
|
|
43
|
+
if (typeof document !== "undefined") {
|
|
44
|
+
document.addEventListener("visibilitychange", this.handleVisibilityChange);
|
|
45
|
+
this.cleanups.push(() =>
|
|
46
|
+
document.removeEventListener("visibilitychange", this.handleVisibilityChange)
|
|
47
|
+
);
|
|
48
|
+
}
|
|
49
|
+
this.offerPendingDelivery();
|
|
50
|
+
};
|
|
51
|
+
|
|
52
|
+
stop = (): void => {
|
|
53
|
+
if (!this.started) {
|
|
54
|
+
return;
|
|
55
|
+
}
|
|
56
|
+
this.started = false;
|
|
57
|
+
while (this.cleanups.length > 0) {
|
|
58
|
+
this.cleanups.pop()?.();
|
|
59
|
+
}
|
|
60
|
+
};
|
|
61
|
+
|
|
62
|
+
closeReader = (): void => {
|
|
63
|
+
useInboxStore.getState().setSnapshot({ readerOpen: false });
|
|
64
|
+
};
|
|
65
|
+
|
|
66
|
+
selectInReader = async (deliveryId: string): Promise<InboxDelivery> => {
|
|
67
|
+
const delivery = await this.updateState(deliveryId, "present");
|
|
68
|
+
useInboxStore.getState().setSnapshot({
|
|
69
|
+
activeDeliveryId: delivery.id,
|
|
70
|
+
readerOpen: true,
|
|
71
|
+
});
|
|
72
|
+
return delivery;
|
|
73
|
+
};
|
|
74
|
+
|
|
75
|
+
markRead = async (deliveryId: string): Promise<InboxDelivery> =>
|
|
76
|
+
await this.updateState(deliveryId, "read");
|
|
77
|
+
|
|
78
|
+
markUnread = async (deliveryId: string): Promise<InboxDelivery> =>
|
|
79
|
+
await this.updateState(deliveryId, "mark_unread");
|
|
80
|
+
|
|
81
|
+
archive = async (deliveryId: string): Promise<InboxDelivery> =>
|
|
82
|
+
await this.updateState(deliveryId, "archive");
|
|
83
|
+
|
|
84
|
+
restore = async (deliveryId: string): Promise<InboxDelivery> =>
|
|
85
|
+
await this.updateState(deliveryId, "restore");
|
|
86
|
+
|
|
87
|
+
delete = async (deliveryId: string): Promise<boolean> => {
|
|
88
|
+
const deleted = await nextclawClient.inboxDeliveries.delete(deliveryId);
|
|
89
|
+
if (deleted) {
|
|
90
|
+
this.queryClient.setQueryData<InboxDeliveryListView>(
|
|
91
|
+
INBOX_DELIVERIES_QUERY_KEY,
|
|
92
|
+
(current) => current
|
|
93
|
+
? buildListView(current.deliveries.filter(({ id }) => id !== deliveryId))
|
|
94
|
+
: current,
|
|
95
|
+
);
|
|
96
|
+
const { snapshot } = useInboxStore.getState();
|
|
97
|
+
if (snapshot.activeDeliveryId === deliveryId) {
|
|
98
|
+
useInboxStore.getState().setSnapshot({
|
|
99
|
+
activeDeliveryId: null,
|
|
100
|
+
readerOpen: false,
|
|
101
|
+
});
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
return deleted;
|
|
105
|
+
};
|
|
106
|
+
|
|
107
|
+
continueInChat = async (deliveryId: string) => {
|
|
108
|
+
const result = await nextclawClient.inboxDeliveries.continueInChat(deliveryId);
|
|
109
|
+
this.replaceCachedDelivery(result.delivery);
|
|
110
|
+
this.closeReader();
|
|
111
|
+
return result;
|
|
112
|
+
};
|
|
113
|
+
|
|
114
|
+
private updateState = async (
|
|
115
|
+
deliveryId: string,
|
|
116
|
+
action: InboxDeliveryStateAction,
|
|
117
|
+
): Promise<InboxDelivery> => {
|
|
118
|
+
const delivery = await nextclawClient.inboxDeliveries.updateState(deliveryId, action);
|
|
119
|
+
this.replaceCachedDelivery(delivery);
|
|
120
|
+
return delivery;
|
|
121
|
+
};
|
|
122
|
+
|
|
123
|
+
private replaceCachedDelivery = (delivery: InboxDelivery): void => {
|
|
124
|
+
this.queryClient.setQueryData<InboxDeliveryListView>(
|
|
125
|
+
INBOX_DELIVERIES_QUERY_KEY,
|
|
126
|
+
(current) => {
|
|
127
|
+
if (!current) {
|
|
128
|
+
return current;
|
|
129
|
+
}
|
|
130
|
+
const deliveries = current.deliveries.some(({ id }) => id === delivery.id)
|
|
131
|
+
? current.deliveries.map((item) => item.id === delivery.id ? delivery : item)
|
|
132
|
+
: [delivery, ...current.deliveries];
|
|
133
|
+
return buildListView(deliveries);
|
|
134
|
+
},
|
|
135
|
+
);
|
|
136
|
+
};
|
|
137
|
+
|
|
138
|
+
private handleDeliveryChanged = (): void => {
|
|
139
|
+
void this.queryClient.invalidateQueries({ queryKey: INBOX_DELIVERIES_QUERY_KEY });
|
|
140
|
+
this.offerPendingDelivery();
|
|
141
|
+
};
|
|
142
|
+
|
|
143
|
+
private handleVisibilityChange = (): void => {
|
|
144
|
+
if (document.visibilityState === "visible") {
|
|
145
|
+
this.offerPendingDelivery();
|
|
146
|
+
}
|
|
147
|
+
};
|
|
148
|
+
|
|
149
|
+
private offerPendingDelivery = (): void => {
|
|
150
|
+
if (this.offerPromise || !this.isVisible() || useInboxStore.getState().snapshot.readerOpen) {
|
|
151
|
+
return;
|
|
152
|
+
}
|
|
153
|
+
this.offerPromise = this.openOldestPendingDelivery()
|
|
154
|
+
.catch(() => undefined)
|
|
155
|
+
.finally(() => {
|
|
156
|
+
this.offerPromise = null;
|
|
157
|
+
});
|
|
158
|
+
};
|
|
159
|
+
|
|
160
|
+
private openOldestPendingDelivery = async (): Promise<void> => {
|
|
161
|
+
const view = await this.queryClient.fetchQuery({
|
|
162
|
+
queryKey: INBOX_DELIVERIES_QUERY_KEY,
|
|
163
|
+
queryFn: () => nextclawClient.inboxDeliveries.list(),
|
|
164
|
+
staleTime: 0,
|
|
165
|
+
});
|
|
166
|
+
const pending = view.deliveries.filter((delivery) =>
|
|
167
|
+
!delivery.presentedAt && !delivery.readAt && !delivery.archivedAt
|
|
168
|
+
);
|
|
169
|
+
const delivery = pending[pending.length - 1];
|
|
170
|
+
if (!delivery || !this.isVisible() || useInboxStore.getState().snapshot.readerOpen) {
|
|
171
|
+
return;
|
|
172
|
+
}
|
|
173
|
+
await this.selectInReader(delivery.id);
|
|
174
|
+
};
|
|
175
|
+
|
|
176
|
+
private isVisible = (): boolean =>
|
|
177
|
+
typeof document === "undefined" || document.visibilityState === "visible";
|
|
178
|
+
}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { describe, expect, it } from "vitest";
|
|
2
|
+
import { resolveInboxFilter } from "@/features/inbox/pages/inbox-page";
|
|
3
|
+
|
|
4
|
+
const readDelivery = {
|
|
5
|
+
archivedAt: null,
|
|
6
|
+
readAt: "2026-08-06T08:30:00.000Z",
|
|
7
|
+
};
|
|
8
|
+
const unreadDelivery = {
|
|
9
|
+
archivedAt: null,
|
|
10
|
+
readAt: null,
|
|
11
|
+
};
|
|
12
|
+
|
|
13
|
+
describe("resolveInboxFilter", () => {
|
|
14
|
+
it("defaults to all when there is no unread delivery", () => {
|
|
15
|
+
expect(resolveInboxFilter([], null)).toBe("all");
|
|
16
|
+
expect(resolveInboxFilter([readDelivery], null)).toBe("all");
|
|
17
|
+
expect(resolveInboxFilter([{ ...unreadDelivery, archivedAt: readDelivery.readAt }], null))
|
|
18
|
+
.toBe("all");
|
|
19
|
+
});
|
|
20
|
+
|
|
21
|
+
it("defaults to unread when actionable unread deliveries exist", () => {
|
|
22
|
+
expect(resolveInboxFilter([readDelivery, unreadDelivery], null)).toBe("unread");
|
|
23
|
+
});
|
|
24
|
+
|
|
25
|
+
it("preserves the user's explicit filter", () => {
|
|
26
|
+
expect(resolveInboxFilter([unreadDelivery], "archived")).toBe("archived");
|
|
27
|
+
});
|
|
28
|
+
});
|
|
@@ -0,0 +1,385 @@
|
|
|
1
|
+
import { useEffect, useMemo, useState } from "react";
|
|
2
|
+
import type { InboxDelivery } from "@nextclaw/shared";
|
|
3
|
+
import { Archive, ArrowLeft, Inbox, MessageCircle, RotateCcw, Trash2 } from "lucide-react";
|
|
4
|
+
import { Link, useNavigate, useParams } from "react-router-dom";
|
|
5
|
+
import { useAppPresenter } from "@/app/components/app-presenter-provider";
|
|
6
|
+
import { useViewportLayout } from "@/app/hooks/use-viewport-layout";
|
|
7
|
+
import { InboxDeliveryContent } from "@/features/inbox/components/inbox-delivery-content";
|
|
8
|
+
import { useInboxDeliveries } from "@/features/inbox/hooks/use-inbox-deliveries";
|
|
9
|
+
import { Button } from "@/shared/components/ui/button";
|
|
10
|
+
import { useConfirmDialog } from "@/shared/hooks/use-confirm-dialog";
|
|
11
|
+
import { formatDateTime, t } from "@/shared/lib/i18n";
|
|
12
|
+
import { cn } from "@/shared/lib/utils";
|
|
13
|
+
|
|
14
|
+
type InboxFilter = "unread" | "all" | "archived";
|
|
15
|
+
|
|
16
|
+
export function resolveInboxFilter(
|
|
17
|
+
deliveries: readonly Pick<InboxDelivery, "archivedAt" | "readAt">[],
|
|
18
|
+
selectedFilter: InboxFilter | null,
|
|
19
|
+
): InboxFilter {
|
|
20
|
+
if (selectedFilter) {
|
|
21
|
+
return selectedFilter;
|
|
22
|
+
}
|
|
23
|
+
return deliveries.some((delivery) => !delivery.readAt && !delivery.archivedAt)
|
|
24
|
+
? "unread"
|
|
25
|
+
: "all";
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
function filterDeliveries(deliveries: InboxDelivery[], filter: InboxFilter): InboxDelivery[] {
|
|
29
|
+
if (filter === "unread") {
|
|
30
|
+
return deliveries.filter((delivery) => !delivery.readAt && !delivery.archivedAt);
|
|
31
|
+
}
|
|
32
|
+
if (filter === "archived") {
|
|
33
|
+
return deliveries.filter((delivery) => Boolean(delivery.archivedAt));
|
|
34
|
+
}
|
|
35
|
+
return deliveries.filter((delivery) => !delivery.archivedAt);
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
function InboxEmptyState({ selection = false }: { selection?: boolean }) {
|
|
39
|
+
return (
|
|
40
|
+
<div className="flex h-full min-h-56 flex-col items-center justify-center px-8 text-center">
|
|
41
|
+
<span className="mb-4 flex h-12 w-12 items-center justify-center rounded-2xl bg-muted text-muted-foreground">
|
|
42
|
+
<Inbox className="h-5 w-5" />
|
|
43
|
+
</span>
|
|
44
|
+
<h2 className="text-base font-semibold text-foreground">
|
|
45
|
+
{t(selection ? "inboxSelectTitle" : "inboxEmptyTitle")}
|
|
46
|
+
</h2>
|
|
47
|
+
<p className="mt-2 max-w-sm text-sm leading-6 text-muted-foreground">
|
|
48
|
+
{t(selection ? "inboxSelectDescription" : "inboxEmptyDescription")}
|
|
49
|
+
</p>
|
|
50
|
+
</div>
|
|
51
|
+
);
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
function InboxPageHeader({ unreadCount }: { unreadCount: number }) {
|
|
55
|
+
return (
|
|
56
|
+
<header className="shrink-0 px-4 pb-4 pt-1 sm:px-0">
|
|
57
|
+
<div className="flex items-end justify-between gap-4">
|
|
58
|
+
<div>
|
|
59
|
+
<h1 className="text-xl font-semibold tracking-tight text-foreground sm:text-2xl">
|
|
60
|
+
{t("inboxTitle")}
|
|
61
|
+
</h1>
|
|
62
|
+
<p className="mt-1 text-sm text-muted-foreground">{t("inboxDescription")}</p>
|
|
63
|
+
</div>
|
|
64
|
+
{unreadCount > 0 ? (
|
|
65
|
+
<span className="shrink-0 rounded-full bg-primary/10 px-2.5 py-1 text-xs font-medium text-primary">
|
|
66
|
+
{t("inboxUnreadCount").replace("{count}", String(unreadCount))}
|
|
67
|
+
</span>
|
|
68
|
+
) : null}
|
|
69
|
+
</div>
|
|
70
|
+
</header>
|
|
71
|
+
);
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
function InboxListPane({
|
|
75
|
+
activeDeliveryId,
|
|
76
|
+
deliveries,
|
|
77
|
+
filter,
|
|
78
|
+
onFilterChange,
|
|
79
|
+
}: {
|
|
80
|
+
activeDeliveryId: string | null;
|
|
81
|
+
deliveries: InboxDelivery[];
|
|
82
|
+
filter: InboxFilter;
|
|
83
|
+
onFilterChange: (filter: InboxFilter) => void;
|
|
84
|
+
}) {
|
|
85
|
+
const filterItems: Array<{ id: InboxFilter; label: string }> = [
|
|
86
|
+
{ id: "unread", label: t("inboxUnread") },
|
|
87
|
+
{ id: "all", label: t("inboxAll") },
|
|
88
|
+
{ id: "archived", label: t("inboxArchived") },
|
|
89
|
+
];
|
|
90
|
+
const filteredDeliveries = filterDeliveries(deliveries, filter);
|
|
91
|
+
return (
|
|
92
|
+
<aside className="flex min-h-0 flex-col border-border/60 md:border-r">
|
|
93
|
+
<div className="flex shrink-0 gap-1 border-b border-border/60 p-3">
|
|
94
|
+
{filterItems.map((item) => (
|
|
95
|
+
<button
|
|
96
|
+
key={item.id}
|
|
97
|
+
type="button"
|
|
98
|
+
onClick={() => onFilterChange(item.id)}
|
|
99
|
+
className={cn(
|
|
100
|
+
"rounded-full px-3 py-1.5 text-xs font-medium transition-colors focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-border",
|
|
101
|
+
filter === item.id
|
|
102
|
+
? "bg-foreground text-background"
|
|
103
|
+
: "text-muted-foreground hover:bg-muted hover:text-foreground",
|
|
104
|
+
)}
|
|
105
|
+
>
|
|
106
|
+
{item.label}
|
|
107
|
+
</button>
|
|
108
|
+
))}
|
|
109
|
+
</div>
|
|
110
|
+
<div className="custom-scrollbar min-h-0 flex-1 overflow-y-auto p-2">
|
|
111
|
+
{filteredDeliveries.length > 0 ? (
|
|
112
|
+
<ul className="space-y-1">
|
|
113
|
+
{filteredDeliveries.map((delivery) => (
|
|
114
|
+
<li key={delivery.id}>
|
|
115
|
+
<Link
|
|
116
|
+
to={`/inbox/${encodeURIComponent(delivery.id)}`}
|
|
117
|
+
className={cn(
|
|
118
|
+
"block rounded-xl px-3 py-3 transition-colors focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-border",
|
|
119
|
+
activeDeliveryId === delivery.id ? "bg-muted" : "hover:bg-muted/70",
|
|
120
|
+
)}
|
|
121
|
+
>
|
|
122
|
+
<div className="flex items-start gap-2">
|
|
123
|
+
<span
|
|
124
|
+
className={cn(
|
|
125
|
+
"mt-1.5 h-2 w-2 shrink-0 rounded-full",
|
|
126
|
+
!delivery.readAt && "bg-primary",
|
|
127
|
+
)}
|
|
128
|
+
aria-label={!delivery.readAt ? t("inboxUnread") : undefined}
|
|
129
|
+
aria-hidden={delivery.readAt ? "true" : undefined}
|
|
130
|
+
/>
|
|
131
|
+
<div className="min-w-0 flex-1">
|
|
132
|
+
<h2 className={cn(
|
|
133
|
+
"line-clamp-2 text-sm leading-5 text-foreground",
|
|
134
|
+
!delivery.readAt && "font-semibold",
|
|
135
|
+
)}>
|
|
136
|
+
{delivery.title}
|
|
137
|
+
</h2>
|
|
138
|
+
<p className="mt-1 line-clamp-2 text-xs leading-5 text-muted-foreground">
|
|
139
|
+
{delivery.summary ?? t("inboxNoSummary")}
|
|
140
|
+
</p>
|
|
141
|
+
<time
|
|
142
|
+
className="mt-2 block text-[11px] text-muted-foreground/80"
|
|
143
|
+
dateTime={delivery.createdAt}
|
|
144
|
+
>
|
|
145
|
+
{formatDateTime(delivery.createdAt)}
|
|
146
|
+
</time>
|
|
147
|
+
</div>
|
|
148
|
+
</div>
|
|
149
|
+
</Link>
|
|
150
|
+
</li>
|
|
151
|
+
))}
|
|
152
|
+
</ul>
|
|
153
|
+
) : <InboxEmptyState />}
|
|
154
|
+
</div>
|
|
155
|
+
</aside>
|
|
156
|
+
);
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
function InboxDetailPane({
|
|
160
|
+
delivery,
|
|
161
|
+
error,
|
|
162
|
+
isMobile,
|
|
163
|
+
pending,
|
|
164
|
+
onArchiveToggle,
|
|
165
|
+
onBack,
|
|
166
|
+
onContinue,
|
|
167
|
+
onDelete,
|
|
168
|
+
onReadToggle,
|
|
169
|
+
}: {
|
|
170
|
+
delivery: InboxDelivery | null;
|
|
171
|
+
error: string | null;
|
|
172
|
+
isMobile: boolean;
|
|
173
|
+
pending: boolean;
|
|
174
|
+
onArchiveToggle: () => void;
|
|
175
|
+
onBack: () => void;
|
|
176
|
+
onContinue: () => void;
|
|
177
|
+
onDelete: () => void;
|
|
178
|
+
onReadToggle: () => void;
|
|
179
|
+
}) {
|
|
180
|
+
if (!delivery) {
|
|
181
|
+
return <main className="flex min-h-0 flex-col"><InboxEmptyState selection /></main>;
|
|
182
|
+
}
|
|
183
|
+
const isHtml = delivery.contentType === "html";
|
|
184
|
+
return (
|
|
185
|
+
<main className="flex min-h-0 flex-col">
|
|
186
|
+
<div className={cn(
|
|
187
|
+
"shrink-0 border-b border-border/60 px-5 sm:px-8",
|
|
188
|
+
isHtml ? "py-3 sm:py-4" : "py-4 sm:py-6",
|
|
189
|
+
)}>
|
|
190
|
+
{isMobile ? (
|
|
191
|
+
<button
|
|
192
|
+
type="button"
|
|
193
|
+
onClick={onBack}
|
|
194
|
+
className="mb-4 inline-flex items-center gap-1.5 text-sm text-muted-foreground hover:text-foreground"
|
|
195
|
+
>
|
|
196
|
+
<ArrowLeft className="h-4 w-4" />
|
|
197
|
+
{t("inboxTitle")}
|
|
198
|
+
</button>
|
|
199
|
+
) : null}
|
|
200
|
+
<div className="text-xs text-muted-foreground">
|
|
201
|
+
{t("inboxDeliveredBy")} · {formatDateTime(delivery.createdAt)}
|
|
202
|
+
</div>
|
|
203
|
+
<h2 className={cn(
|
|
204
|
+
"text-balance font-semibold leading-tight tracking-[-0.02em] text-foreground",
|
|
205
|
+
isHtml ? "mt-2 text-lg sm:text-xl" : "mt-3 text-2xl",
|
|
206
|
+
)}>
|
|
207
|
+
{delivery.title}
|
|
208
|
+
</h2>
|
|
209
|
+
{delivery.summary && !isHtml ? (
|
|
210
|
+
<p className="mt-2 max-w-3xl text-sm leading-6 text-muted-foreground">
|
|
211
|
+
{delivery.summary}
|
|
212
|
+
</p>
|
|
213
|
+
) : null}
|
|
214
|
+
</div>
|
|
215
|
+
<div className={cn(
|
|
216
|
+
"min-h-0 flex-1",
|
|
217
|
+
isHtml
|
|
218
|
+
? "p-4 sm:p-5"
|
|
219
|
+
: "custom-scrollbar overflow-y-auto px-5 py-6 sm:px-8 sm:py-8",
|
|
220
|
+
)}>
|
|
221
|
+
<div className={cn("mx-auto", isHtml ? "h-full max-w-5xl" : "max-w-3xl")}>
|
|
222
|
+
<InboxDeliveryContent
|
|
223
|
+
className={isHtml ? "h-full" : undefined}
|
|
224
|
+
content={delivery.content}
|
|
225
|
+
contentType={delivery.contentType}
|
|
226
|
+
fillHeight={isHtml}
|
|
227
|
+
title={delivery.title}
|
|
228
|
+
/>
|
|
229
|
+
</div>
|
|
230
|
+
</div>
|
|
231
|
+
<div className="shrink-0 border-t border-border/60 px-5 py-3 sm:px-8">
|
|
232
|
+
{error ? <p role="alert" className="mb-2 text-sm text-destructive">{error}</p> : null}
|
|
233
|
+
<div className="flex flex-wrap items-center gap-2">
|
|
234
|
+
<Button disabled={pending} onClick={onContinue}>
|
|
235
|
+
<MessageCircle className="mr-2 h-4 w-4" />
|
|
236
|
+
{t("inboxContinueChat")}
|
|
237
|
+
</Button>
|
|
238
|
+
<Button variant="outline" disabled={pending} onClick={onReadToggle}>
|
|
239
|
+
{delivery.readAt ? t("inboxMarkUnread") : t("inboxMarkRead")}
|
|
240
|
+
</Button>
|
|
241
|
+
<Button variant="ghost" disabled={pending} onClick={onArchiveToggle}>
|
|
242
|
+
{delivery.archivedAt
|
|
243
|
+
? <RotateCcw className="mr-2 h-4 w-4" />
|
|
244
|
+
: <Archive className="mr-2 h-4 w-4" />}
|
|
245
|
+
{delivery.archivedAt ? t("inboxRestore") : t("inboxArchive")}
|
|
246
|
+
</Button>
|
|
247
|
+
<Button variant="ghost" disabled={pending} onClick={onDelete}>
|
|
248
|
+
<Trash2 className="mr-2 h-4 w-4" />
|
|
249
|
+
{t("inboxDelete")}
|
|
250
|
+
</Button>
|
|
251
|
+
</div>
|
|
252
|
+
</div>
|
|
253
|
+
</main>
|
|
254
|
+
);
|
|
255
|
+
}
|
|
256
|
+
|
|
257
|
+
export function InboxPage() {
|
|
258
|
+
const navigate = useNavigate();
|
|
259
|
+
const { deliveryId } = useParams<{ deliveryId?: string }>();
|
|
260
|
+
const { isMobile } = useViewportLayout();
|
|
261
|
+
const { inboxManager } = useAppPresenter();
|
|
262
|
+
const deliveriesQuery = useInboxDeliveries();
|
|
263
|
+
const { confirm, ConfirmDialog } = useConfirmDialog();
|
|
264
|
+
const [selectedFilter, setSelectedFilter] = useState<InboxFilter | null>(null);
|
|
265
|
+
const [pendingAction, setPendingAction] = useState<string | null>(null);
|
|
266
|
+
const [error, setError] = useState<string | null>(null);
|
|
267
|
+
const deliveries = useMemo(
|
|
268
|
+
() => deliveriesQuery.data?.deliveries ?? [],
|
|
269
|
+
[deliveriesQuery.data?.deliveries],
|
|
270
|
+
);
|
|
271
|
+
const activeDelivery = useMemo(
|
|
272
|
+
() => deliveryId
|
|
273
|
+
? deliveries.find(({ id }) => id === deliveryId) ?? null
|
|
274
|
+
: null,
|
|
275
|
+
[deliveries, deliveryId],
|
|
276
|
+
);
|
|
277
|
+
const filter = resolveInboxFilter(deliveries, selectedFilter);
|
|
278
|
+
|
|
279
|
+
useEffect(() => {
|
|
280
|
+
if (activeDelivery && !activeDelivery.readAt) {
|
|
281
|
+
void inboxManager.markRead(activeDelivery.id).catch(() => setError(t("inboxActionError")));
|
|
282
|
+
}
|
|
283
|
+
}, [activeDelivery, inboxManager]);
|
|
284
|
+
|
|
285
|
+
const runAction = async (name: string, action: () => Promise<void>) => {
|
|
286
|
+
setPendingAction(name);
|
|
287
|
+
setError(null);
|
|
288
|
+
try {
|
|
289
|
+
await action();
|
|
290
|
+
} catch {
|
|
291
|
+
setError(t("inboxActionError"));
|
|
292
|
+
} finally {
|
|
293
|
+
setPendingAction(null);
|
|
294
|
+
}
|
|
295
|
+
};
|
|
296
|
+
|
|
297
|
+
const continueInChat = () => {
|
|
298
|
+
if (!activeDelivery) {
|
|
299
|
+
return;
|
|
300
|
+
}
|
|
301
|
+
void runAction("continue", async () => {
|
|
302
|
+
const result = await inboxManager.continueInChat(activeDelivery.id);
|
|
303
|
+
navigate(`/chat/${encodeURIComponent(result.sessionId)}`);
|
|
304
|
+
});
|
|
305
|
+
};
|
|
306
|
+
|
|
307
|
+
const deleteDelivery = async () => {
|
|
308
|
+
if (!activeDelivery || !await confirm({
|
|
309
|
+
title: t("inboxDeleteTitle"),
|
|
310
|
+
description: t("inboxDeleteDescription"),
|
|
311
|
+
confirmLabel: t("inboxDeleteConfirm"),
|
|
312
|
+
variant: "destructive",
|
|
313
|
+
})) {
|
|
314
|
+
return;
|
|
315
|
+
}
|
|
316
|
+
void runAction("delete", async () => {
|
|
317
|
+
await inboxManager.delete(activeDelivery.id);
|
|
318
|
+
navigate("/inbox", { replace: true });
|
|
319
|
+
});
|
|
320
|
+
};
|
|
321
|
+
|
|
322
|
+
const toggleRead = () => {
|
|
323
|
+
if (!activeDelivery) {
|
|
324
|
+
return;
|
|
325
|
+
}
|
|
326
|
+
void runAction("read", async () => {
|
|
327
|
+
if (activeDelivery.readAt) {
|
|
328
|
+
await inboxManager.markUnread(activeDelivery.id);
|
|
329
|
+
navigate("/inbox", { replace: true });
|
|
330
|
+
return;
|
|
331
|
+
}
|
|
332
|
+
await inboxManager.markRead(activeDelivery.id);
|
|
333
|
+
});
|
|
334
|
+
};
|
|
335
|
+
|
|
336
|
+
const toggleArchive = () => {
|
|
337
|
+
if (!activeDelivery) {
|
|
338
|
+
return;
|
|
339
|
+
}
|
|
340
|
+
void runAction("archive", async () => {
|
|
341
|
+
if (activeDelivery.archivedAt) {
|
|
342
|
+
await inboxManager.restore(activeDelivery.id);
|
|
343
|
+
return;
|
|
344
|
+
}
|
|
345
|
+
await inboxManager.archive(activeDelivery.id);
|
|
346
|
+
navigate("/inbox", { replace: true });
|
|
347
|
+
});
|
|
348
|
+
};
|
|
349
|
+
|
|
350
|
+
const showList = !isMobile || !activeDelivery;
|
|
351
|
+
const showDetail = !isMobile || Boolean(activeDelivery);
|
|
352
|
+
|
|
353
|
+
return (
|
|
354
|
+
<div className="flex h-full min-h-0 flex-col">
|
|
355
|
+
<InboxPageHeader unreadCount={deliveriesQuery.data?.unreadCount ?? 0} />
|
|
356
|
+
|
|
357
|
+
<div className="min-h-0 flex-1 overflow-hidden border-y border-border/60 bg-background sm:rounded-2xl sm:border">
|
|
358
|
+
{deliveriesQuery.isError ? (
|
|
359
|
+
<div role="alert" className="p-6 text-sm text-destructive">{t("inboxLoadError")}</div>
|
|
360
|
+
) : (
|
|
361
|
+
<div className="grid h-full min-h-0 grid-cols-1 md:grid-cols-[320px_minmax(0,1fr)]">
|
|
362
|
+
{showList ? <InboxListPane
|
|
363
|
+
activeDeliveryId={activeDelivery?.id ?? null}
|
|
364
|
+
deliveries={deliveries}
|
|
365
|
+
filter={filter}
|
|
366
|
+
onFilterChange={setSelectedFilter}
|
|
367
|
+
/> : null}
|
|
368
|
+
{showDetail ? <InboxDetailPane
|
|
369
|
+
delivery={activeDelivery}
|
|
370
|
+
error={error}
|
|
371
|
+
isMobile={isMobile}
|
|
372
|
+
pending={pendingAction !== null}
|
|
373
|
+
onArchiveToggle={toggleArchive}
|
|
374
|
+
onBack={() => navigate("/inbox")}
|
|
375
|
+
onContinue={continueInChat}
|
|
376
|
+
onDelete={() => void deleteDelivery()}
|
|
377
|
+
onReadToggle={toggleRead}
|
|
378
|
+
/> : null}
|
|
379
|
+
</div>
|
|
380
|
+
)}
|
|
381
|
+
</div>
|
|
382
|
+
<ConfirmDialog />
|
|
383
|
+
</div>
|
|
384
|
+
);
|
|
385
|
+
}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { create } from "zustand";
|
|
2
|
+
|
|
3
|
+
export type InboxSnapshot = {
|
|
4
|
+
readerOpen: boolean;
|
|
5
|
+
activeDeliveryId: string | null;
|
|
6
|
+
};
|
|
7
|
+
|
|
8
|
+
type InboxStore = {
|
|
9
|
+
snapshot: InboxSnapshot;
|
|
10
|
+
setSnapshot: (patch: Partial<InboxSnapshot>) => void;
|
|
11
|
+
};
|
|
12
|
+
|
|
13
|
+
const initialSnapshot: InboxSnapshot = {
|
|
14
|
+
readerOpen: false,
|
|
15
|
+
activeDeliveryId: null,
|
|
16
|
+
};
|
|
17
|
+
|
|
18
|
+
export const useInboxStore = create<InboxStore>((set) => ({
|
|
19
|
+
snapshot: initialSnapshot,
|
|
20
|
+
setSnapshot: (patch) => set((state) => ({
|
|
21
|
+
snapshot: { ...state.snapshot, ...patch },
|
|
22
|
+
})),
|
|
23
|
+
}));
|
|
@@ -37,7 +37,7 @@ export function FilterPanel({
|
|
|
37
37
|
value={searchText}
|
|
38
38
|
onChange={(event) => onSearchTextChange(event.target.value)}
|
|
39
39
|
placeholder={searchPlaceholder}
|
|
40
|
-
className="h-9 w-full rounded-xl border border-border/75 bg-card pl-9 pr-9 text-sm transition-colors focus:outline-none focus:ring-0
|
|
40
|
+
className="h-9 w-full rounded-xl border border-border/75 bg-card pl-9 pr-9 text-sm transition-colors focus:outline-none focus:ring-0"
|
|
41
41
|
/>
|
|
42
42
|
{isRefreshing && (
|
|
43
43
|
<Loader2
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import { render, screen } from "@testing-library/react";
|
|
2
|
+
import userEvent from "@testing-library/user-event";
|
|
3
|
+
import { MemoryRouter } from "react-router-dom";
|
|
4
|
+
import { describe, expect, it, vi } from "vitest";
|
|
5
|
+
import { AppNotificationToast } from "@/features/notifications";
|
|
6
|
+
|
|
7
|
+
describe("AppNotificationToast", () => {
|
|
8
|
+
it("renders a keyboard-accessible route notification and dismisses it on activation", async () => {
|
|
9
|
+
const onDismiss = vi.fn();
|
|
10
|
+
const user = userEvent.setup();
|
|
11
|
+
render(
|
|
12
|
+
<MemoryRouter>
|
|
13
|
+
<AppNotificationToast
|
|
14
|
+
title="Background task"
|
|
15
|
+
description="The requested summary is ready."
|
|
16
|
+
href="/chat/session-1"
|
|
17
|
+
ariaLabel="Open the background task reply"
|
|
18
|
+
onDismiss={onDismiss}
|
|
19
|
+
/>
|
|
20
|
+
</MemoryRouter>,
|
|
21
|
+
);
|
|
22
|
+
|
|
23
|
+
const notification = screen.getByRole("link", {
|
|
24
|
+
name: "Open the background task reply",
|
|
25
|
+
});
|
|
26
|
+
expect(notification.getAttribute("href")).toBe("/chat/session-1");
|
|
27
|
+
expect(notification.className).not.toMatch(
|
|
28
|
+
/(?:hover|active):bg-\S*\/\d+/,
|
|
29
|
+
);
|
|
30
|
+
expect(screen.getByText("Background task")).toBeTruthy();
|
|
31
|
+
expect(screen.getByText("The requested summary is ready.")).toBeTruthy();
|
|
32
|
+
|
|
33
|
+
await user.click(notification);
|
|
34
|
+
expect(onDismiss).toHaveBeenCalledOnce();
|
|
35
|
+
});
|
|
36
|
+
|
|
37
|
+
it("keeps informational notifications non-interactive when no route exists", () => {
|
|
38
|
+
render(
|
|
39
|
+
<MemoryRouter>
|
|
40
|
+
<AppNotificationToast
|
|
41
|
+
title="All caught up"
|
|
42
|
+
description="There is nothing else to review."
|
|
43
|
+
onDismiss={vi.fn()}
|
|
44
|
+
/>
|
|
45
|
+
</MemoryRouter>,
|
|
46
|
+
);
|
|
47
|
+
|
|
48
|
+
expect(screen.getByRole("status")).toBeTruthy();
|
|
49
|
+
expect(screen.queryByRole("link")).toBeNull();
|
|
50
|
+
});
|
|
51
|
+
});
|