@nextclaw/ui 0.12.24 → 0.12.25
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 +68 -29
- package/dist/assets/api-DGD9_Bg4.js +15 -0
- package/dist/assets/app-manager-provider-oYdeYPSv.js +1 -0
- package/dist/assets/{book-open-DDlN5MvX.js → book-open-BcnAiKde.js} +1 -1
- package/dist/assets/channels-list-page-FJDuPwU6.js +8 -0
- package/dist/assets/chat-page-D1fMNBrT.js +1 -0
- package/dist/assets/config-split-page-CcrEUtwu.js +1 -0
- package/dist/assets/cpu-DPPwMzoC.js +3 -0
- package/dist/assets/{createLucideIcon-BLMK3QUd.js → createLucideIcon-DzY6wN61.js} +1 -1
- package/dist/assets/desktop-kk7qvZ-v.js +3 -0
- package/dist/assets/desktop-update-config-CP8dFYXK.js +1 -0
- package/dist/assets/{dialog-C3D7Be0p.js → dialog-BKo0RItd.js} +1 -1
- package/dist/assets/{dist-CPlbUgwU.js → dist-CFiwgaLs.js} +1 -1
- package/dist/assets/doc-browser-CAhfnm0D.js +1 -0
- package/dist/assets/{doc-browser-context-BJuMaI3o.js → doc-browser-context-FukQHvyo.js} +1 -1
- package/dist/assets/doc-browser-p9DDNPWB.js +1 -0
- package/dist/assets/doc-browser-rZIQIjuw.js +1 -0
- package/dist/assets/download-CMM8po31.js +1 -0
- package/dist/assets/{es2015-xqN1slyW.js → es2015-BhznEEyJ.js} +1 -1
- package/dist/assets/{external-link-DwfSfTLB.js → external-link-CpEvG65F.js} +1 -1
- package/dist/assets/i18n-D1144VAA.js +1 -0
- package/dist/assets/index-D-AAMKCt.js +103 -0
- package/dist/assets/index-DnBeV2Xm.css +1 -0
- package/dist/assets/{key-round-CJ5gDAAG.js → key-round-DUq47t0P.js} +1 -1
- package/dist/assets/marketplace-page-BrCLRIc4.js +105 -0
- package/dist/assets/marketplace-page-odDpPYEs.js +1 -0
- package/dist/assets/mcp-marketplace-page-CfbOBgKK.js +1 -0
- package/dist/assets/mcp-marketplace-page-DIq_SpMe.js +40 -0
- package/dist/assets/model-config-Bc6VVnxy.js +1 -0
- package/dist/assets/{notice-card-BFDbKQDA.js → notice-card-Dr6xCwva.js} +1 -1
- package/dist/assets/play-AqrNslHI.js +1 -0
- package/dist/assets/plus-B-YHtTNC.js +1 -0
- package/dist/assets/{popover-B86Dbfhf.js → popover-BDFNiLlg.js} +1 -1
- package/dist/assets/provider-scoped-model-input-BMTp4BEH.js +1 -0
- package/dist/assets/providers-list-DN0tvISH.js +1 -0
- package/dist/assets/refresh-cw-CrbD8EkT.js +1 -0
- package/dist/assets/remote-Dr3jcfWP.js +1 -0
- package/dist/assets/{rotate-cw-BZ2JObNs.js → rotate-cw-BN9yjccP.js} +1 -1
- package/dist/assets/runtime-config-page-CRWOwBbl.js +1 -0
- package/dist/assets/{save-euRxl8pI.js → save-CO_4qf6b.js} +1 -1
- package/dist/assets/{search-CLd7m0M7.js → search-CRtQwr-h.js} +1 -1
- package/dist/assets/search-config-C4c1yZSP.js +1 -0
- package/dist/assets/secrets-config-zAF30YfO.js +3 -0
- package/dist/assets/{select-CJ0wbo3D.js → select-BUTwE_lC.js} +1 -1
- package/dist/assets/{setting-row-D1Yygqp7.js → setting-row-BavcnXw1.js} +1 -1
- package/dist/assets/settings-MWL2SMyk.js +1 -0
- package/dist/assets/{sparkles-DVfeSVJQ.js → sparkles-BmgOD4nY.js} +1 -1
- package/dist/assets/{status-dot-ChvPCib9.js → status-dot-l3kPFdq_.js} +1 -1
- package/dist/assets/{tabs-custom-Hia_ong0.js → tabs-custom-D48zdZoc.js} +1 -1
- package/dist/assets/{tag-chip-FrkmkT8r.js → tag-chip-Dm2Lqnpu.js} +1 -1
- package/dist/assets/use-config-Cyv5IuSt.js +1 -0
- package/dist/assets/use-infinite-scroll-loader-Cvz8ZteY.js +1 -0
- package/dist/assets/x-BeyYA_h6.js +1 -0
- package/dist/index.html +29 -40
- package/package.json +9 -9
- package/src/app/components/layout/sidebar.layout.test.tsx +2 -4
- package/src/app/components/theme-provider.tsx +1 -0
- package/src/app/configs/app-navigation.config.ts +0 -6
- package/src/app/index.tsx +4 -7
- package/src/features/agents/components/agents-page.test.tsx +25 -15
- package/src/features/agents/components/agents-page.tsx +133 -172
- package/src/features/channels/components/config/channel-form.test.tsx +1 -0
- package/src/features/channels/components/config/channel-form.tsx +4 -3
- package/src/features/channels/components/config/weixin-channel-auth-section.test.tsx +38 -1
- package/src/features/channels/components/config/weixin-channel-auth-section.tsx +137 -40
- package/src/features/channels/index.ts +1 -1
- package/src/features/channels/utils/channel-form-fields.utils.test.ts +26 -0
- package/src/features/channels/utils/channel-form-fields.utils.ts +32 -18
- package/src/features/chat/components/chat-session-workspace-panel-nav.tsx +23 -4
- package/src/features/chat/components/chat-session-workspace-panel.tsx +34 -2
- package/src/features/chat/components/chat-sidebar-session-item.tsx +9 -3
- package/src/features/chat/components/conversation/chat-conversation-header.test.tsx +71 -0
- package/src/features/chat/components/conversation/chat-conversation-header.tsx +6 -0
- package/src/features/chat/components/conversation/chat-conversation-panel.test.tsx +181 -61
- package/src/features/chat/components/conversation/chat-conversation-panel.tsx +54 -23
- package/src/features/chat/components/conversation/session-header/chat-session-header-actions.test.tsx +24 -0
- package/src/features/chat/components/conversation/session-header/chat-session-header-actions.tsx +26 -5
- package/src/features/chat/components/layout/chat-sidebar-utility-menu.tsx +174 -0
- package/src/features/chat/components/layout/chat-sidebar.test.tsx +45 -8
- package/src/features/chat/components/layout/chat-sidebar.tsx +29 -46
- package/src/features/chat/components/providers/chat-presenter.provider.tsx +2 -0
- package/src/features/chat/components/workspace/session-cron-job-content.tsx +103 -0
- package/src/features/chat/hooks/use-ncp-agent-runtime.test.tsx +14 -0
- package/src/features/chat/hooks/use-ncp-chat-page-data.test.tsx +70 -0
- package/src/features/chat/hooks/use-ncp-chat-page-data.ts +1 -1
- package/src/features/chat/hooks/use-ncp-child-session-tabs-view.ts +2 -8
- package/src/features/chat/hooks/use-ncp-session-list-view.ts +1 -2
- package/src/features/chat/managers/chat-session-list.manager.test.ts +7 -9
- package/src/features/chat/managers/chat-session-list.manager.ts +5 -10
- package/src/features/chat/managers/ncp-chat-input.manager.test.ts +0 -2
- package/src/features/chat/managers/ncp-chat-presenter.manager.ts +6 -0
- package/src/features/chat/managers/ncp-chat-thread.manager.test.ts +52 -1
- package/src/features/chat/managers/ncp-chat-thread.manager.ts +21 -0
- package/src/features/chat/pages/ncp-chat-page.tsx +5 -4
- package/src/features/chat/stores/chat-session-list.store.ts +0 -2
- package/src/features/chat/stores/chat-thread.store.ts +4 -0
- package/src/features/chat/utils/chat-session-display.utils.test.ts +83 -1
- package/src/features/chat/utils/chat-session-display.utils.ts +73 -0
- package/src/features/chat/utils/ncp-session-adapter.utils.test.ts +22 -0
- package/src/features/chat/utils/ncp-session-adapter.utils.ts +32 -0
- package/src/features/marketplace/components/curated-shelves/marketplace-curated-scene-route.test.tsx +235 -0
- package/src/features/marketplace/components/curated-shelves/marketplace-curated-shelves.config.ts +162 -0
- package/src/features/marketplace/components/curated-shelves/marketplace-curated-shelves.tsx +355 -0
- package/src/features/marketplace/components/curated-shelves/marketplace-shelf-card.tsx +118 -0
- package/src/features/marketplace/components/detail-doc/marketplace-detail-doc-renderer.ts +201 -0
- package/src/features/marketplace/components/detail-doc/marketplace-detail-doc.test.ts +40 -0
- package/src/features/marketplace/components/marketplace-catalog-grid.tsx +114 -0
- package/src/features/marketplace/components/marketplace-detail-doc.ts +73 -24
- package/src/features/marketplace/components/marketplace-item-icon.tsx +45 -0
- package/src/features/marketplace/components/marketplace-list-card.tsx +177 -93
- package/src/features/marketplace/components/marketplace-page-detail.test.tsx +9 -2
- package/src/features/marketplace/components/marketplace-page-parts.tsx +1 -1
- package/src/features/marketplace/components/marketplace-page.test.tsx +25 -6
- package/src/features/marketplace/components/marketplace-page.tsx +154 -132
- package/src/features/marketplace/hooks/use-marketplace-curated-scene-route.ts +97 -0
- package/src/features/marketplace/hooks/use-marketplace.ts +59 -3
- package/src/features/system-status/components/config/runtime-agent-list-card.tsx +4 -8
- package/src/features/system-status/components/config/runtime-binding-list-card.tsx +5 -7
- package/src/features/system-status/components/config/runtime-config-editor.tsx +1 -19
- package/src/features/system-status/components/config/runtime-entry-list-card.tsx +10 -11
- package/src/features/system-status/components/config/runtime-settings-card.tsx +15 -23
- package/src/features/system-status/components/runtime-control-card.test.tsx +8 -6
- package/src/features/system-status/components/runtime-control-card.tsx +7 -6
- package/src/features/system-status/pages/runtime-config-page.test.tsx +19 -9
- package/src/features/system-status/pages/runtime-config-page.tsx +2 -3
- package/src/features/system-status/utils/runtime-config-agent.utils.ts +4 -4
- package/src/features/system-status/utils/system-status.utils.ts +31 -6
- package/src/index.css +8 -0
- package/src/platforms/desktop/components/desktop-app-shell.test.tsx +67 -0
- package/src/platforms/desktop/components/desktop-app-shell.tsx +46 -18
- package/src/platforms/desktop/components/desktop-window-chrome.tsx +30 -0
- package/src/platforms/desktop/index.ts +6 -0
- package/src/platforms/desktop/types/desktop-update.types.ts +3 -0
- package/src/platforms/desktop/utils/desktop-host.utils.ts +56 -0
- package/src/shared/components/common/brand-header.tsx +36 -16
- package/src/shared/components/config/provider-form-support.ts +2 -22
- package/src/shared/components/cron-config.tsx +12 -58
- package/src/shared/components/doc-browser/doc-browser.tsx +4 -4
- package/src/shared/components/ui/select.tsx +19 -7
- package/src/shared/lib/api/channel-auth.types.ts +1 -0
- package/src/shared/lib/api/ncp-session.types.ts +9 -0
- package/src/shared/lib/api/types.ts +12 -1
- package/src/shared/lib/api/utils/marketplace.utils.ts +7 -1
- package/src/shared/lib/cron/cron-job-view.utils.ts +59 -0
- package/src/shared/lib/cron/index.ts +1 -0
- package/src/shared/lib/i18n/{channel-auth.ts → channel-auth.constants.ts} +31 -0
- package/src/shared/lib/i18n/chat-labels.utils.ts +3 -2
- package/src/shared/lib/i18n/index.ts +20 -59
- package/src/shared/lib/i18n/{runtime-control.ts → runtime-control-labels.utils.ts} +30 -1
- package/src/shared/lib/provider-models/index.test.ts +39 -0
- package/src/shared/lib/provider-models/index.ts +1 -3
- package/src/shared/lib/ui-document-title/index.ts +0 -1
- package/tsconfig.json +1 -0
- package/vite.config.ts +1 -1
- package/vitest.config.ts +1 -1
- package/dist/assets/api-D2xRKmZd.js +0 -15
- package/dist/assets/app-manager-provider-CNaZboG4.js +0 -1
- package/dist/assets/app-navigation.config-Ihhrrt--.js +0 -1
- package/dist/assets/channels-list-page-p26lgxLk.js +0 -8
- package/dist/assets/chat-Dkh2qtuz.js +0 -61
- package/dist/assets/chat-page-DoTmE2wx.js +0 -1
- package/dist/assets/chunk-JZWAC4HX-Kydj4yEz.js +0 -3
- package/dist/assets/config-split-page-DIOCjj2Q.js +0 -1
- package/dist/assets/desktop-update-config-DlpzDfKM.js +0 -1
- package/dist/assets/doc-browser-C8FM5fC0.js +0 -1
- package/dist/assets/doc-browser-RJUOL_GO.js +0 -1
- package/dist/assets/doc-browser-p82AdNO-.js +0 -1
- package/dist/assets/folder-CeJKPx5P.js +0 -1
- package/dist/assets/hash-BqxRTZW5.js +0 -1
- package/dist/assets/i18n-DnTGDIRw.js +0 -1
- package/dist/assets/index-D8MKmXtO.css +0 -1
- package/dist/assets/index-pBvbJ5Mt.js +0 -2
- package/dist/assets/loader-circle-fd-vQKtW.js +0 -1
- package/dist/assets/logo-badge-KAe-7d8c.js +0 -1
- package/dist/assets/logos-C4sYP1Vl.js +0 -1
- package/dist/assets/marketplace-page-Cql0kDi-.js +0 -1
- package/dist/assets/marketplace-page-m4P5g_Ht.js +0 -49
- package/dist/assets/mcp-marketplace-page-9WVKl1m1.js +0 -1
- package/dist/assets/mcp-marketplace-page-ByzBQZcx.js +0 -40
- package/dist/assets/message-square-z_osm9c0.js +0 -1
- package/dist/assets/model-config-Dbr_0APb.js +0 -1
- package/dist/assets/play-Dv6Nr1Ew.js +0 -1
- package/dist/assets/plus-D8eKFY7h.js +0 -1
- package/dist/assets/provider-scoped-model-input-DFm6N2f7.js +0 -1
- package/dist/assets/providers-list-BJcLOjun.js +0 -1
- package/dist/assets/refresh-ccw-ByVwmnN_.js +0 -1
- package/dist/assets/refresh-cw-PcqoYB3K.js +0 -1
- package/dist/assets/remote-BOxo9iwd.js +0 -1
- package/dist/assets/runtime-config-page-CjLhnbSl.js +0 -1
- package/dist/assets/search-config-J4Htco-P.js +0 -1
- package/dist/assets/secrets-config-CUdERjco.js +0 -3
- package/dist/assets/sessions-config-page-DpK991fs.js +0 -2
- package/dist/assets/settings-drbWqzA4.js +0 -1
- package/dist/assets/skeleton-BK1SOSRA.js +0 -1
- package/dist/assets/theme-provider-0hxjiPc_.js +0 -2
- package/dist/assets/tooltip-Cj4yA0gH.js +0 -1
- package/dist/assets/trash-2-CBsHCfqq.js +0 -1
- package/dist/assets/use-config-38Ur-89i.js +0 -1
- package/dist/assets/use-confirm-dialog-DPQThaeU.js +0 -1
- package/dist/assets/use-infinite-scroll-loader-5Gf1xQi7.js +0 -1
- package/dist/assets/use-viewport-layout-D1XzKeip.js +0 -1
- package/dist/assets/x-CM-XDMpk.js +0 -1
- package/src/features/chat/components/config/sessions-config-detail-pane.tsx +0 -244
- package/src/features/chat/pages/sessions-config-page.test.tsx +0 -152
- package/src/features/chat/pages/sessions-config-page.tsx +0 -192
- /package/dist/assets/{config-hints-MogHYQ8G.js → config-hints-BNfpOL4J.js} +0 -0
|
@@ -1,152 +0,0 @@
|
|
|
1
|
-
import { render, screen } from '@testing-library/react';
|
|
2
|
-
import userEvent from '@testing-library/user-event';
|
|
3
|
-
import { beforeEach, describe, expect, it, vi } from 'vitest';
|
|
4
|
-
import { SessionsConfig } from '@/features/chat/pages/sessions-config-page';
|
|
5
|
-
import type { NcpMessageView, NcpSessionMessagesView, NcpSessionsListView } from '@/shared/lib/api';
|
|
6
|
-
import { setLanguage } from '@/shared/lib/i18n';
|
|
7
|
-
|
|
8
|
-
const mocks = vi.hoisted(() => ({
|
|
9
|
-
confirm: vi.fn(),
|
|
10
|
-
refetch: vi.fn(),
|
|
11
|
-
updateMutate: vi.fn(),
|
|
12
|
-
deleteMutate: vi.fn(),
|
|
13
|
-
sessionsQuery: null as unknown as {
|
|
14
|
-
data?: NcpSessionsListView;
|
|
15
|
-
isLoading: boolean;
|
|
16
|
-
isFetching: boolean;
|
|
17
|
-
refetch: () => void;
|
|
18
|
-
},
|
|
19
|
-
messagesQuery: null as unknown as {
|
|
20
|
-
data?: NcpSessionMessagesView;
|
|
21
|
-
isLoading: boolean;
|
|
22
|
-
error: Error | null;
|
|
23
|
-
}
|
|
24
|
-
}));
|
|
25
|
-
|
|
26
|
-
vi.mock('@/shared/hooks/use-confirm-dialog', () => ({
|
|
27
|
-
useConfirmDialog: () => ({
|
|
28
|
-
confirm: mocks.confirm,
|
|
29
|
-
ConfirmDialog: () => null
|
|
30
|
-
})
|
|
31
|
-
}));
|
|
32
|
-
|
|
33
|
-
vi.mock('@/shared/hooks/use-config', () => ({
|
|
34
|
-
useNcpSessions: () => mocks.sessionsQuery,
|
|
35
|
-
useNcpSessionMessages: () => mocks.messagesQuery,
|
|
36
|
-
useUpdateNcpSession: () => ({
|
|
37
|
-
mutate: mocks.updateMutate,
|
|
38
|
-
isPending: false
|
|
39
|
-
}),
|
|
40
|
-
useDeleteNcpSession: () => ({
|
|
41
|
-
mutate: mocks.deleteMutate,
|
|
42
|
-
isPending: false
|
|
43
|
-
})
|
|
44
|
-
}));
|
|
45
|
-
|
|
46
|
-
function createSessionSummary(overrides: Partial<NcpSessionsListView['sessions'][number]> = {}) {
|
|
47
|
-
return {
|
|
48
|
-
sessionId: 'discord:session-1',
|
|
49
|
-
messageCount: 2,
|
|
50
|
-
updatedAt: '2026-04-20T20:00:00.000Z',
|
|
51
|
-
status: 'running' as const,
|
|
52
|
-
metadata: {
|
|
53
|
-
label: 'Release 42',
|
|
54
|
-
preferredModel: 'gpt-4.1'
|
|
55
|
-
},
|
|
56
|
-
...overrides
|
|
57
|
-
};
|
|
58
|
-
}
|
|
59
|
-
|
|
60
|
-
function createMessage(overrides: Partial<NcpMessageView> = {}): NcpMessageView {
|
|
61
|
-
return {
|
|
62
|
-
id: 'message-1',
|
|
63
|
-
sessionId: 'discord:session-1',
|
|
64
|
-
role: 'assistant',
|
|
65
|
-
status: 'final',
|
|
66
|
-
timestamp: '2026-04-20T20:00:00.000Z',
|
|
67
|
-
parts: [{ type: 'text', text: 'History payload' }],
|
|
68
|
-
...overrides
|
|
69
|
-
};
|
|
70
|
-
}
|
|
71
|
-
|
|
72
|
-
describe('SessionsConfig', () => {
|
|
73
|
-
beforeEach(() => {
|
|
74
|
-
setLanguage('en');
|
|
75
|
-
mocks.confirm.mockReset();
|
|
76
|
-
mocks.refetch.mockReset();
|
|
77
|
-
mocks.updateMutate.mockReset();
|
|
78
|
-
mocks.deleteMutate.mockReset();
|
|
79
|
-
mocks.confirm.mockResolvedValue(true);
|
|
80
|
-
mocks.sessionsQuery = {
|
|
81
|
-
data: {
|
|
82
|
-
total: 1,
|
|
83
|
-
sessions: [createSessionSummary()]
|
|
84
|
-
},
|
|
85
|
-
isLoading: false,
|
|
86
|
-
isFetching: false,
|
|
87
|
-
refetch: mocks.refetch
|
|
88
|
-
};
|
|
89
|
-
mocks.messagesQuery = {
|
|
90
|
-
data: {
|
|
91
|
-
sessionId: 'discord:session-1',
|
|
92
|
-
status: 'idle',
|
|
93
|
-
total: 1,
|
|
94
|
-
messages: [createMessage()]
|
|
95
|
-
},
|
|
96
|
-
isLoading: false,
|
|
97
|
-
error: null
|
|
98
|
-
};
|
|
99
|
-
if (!HTMLElement.prototype.hasPointerCapture) {
|
|
100
|
-
HTMLElement.prototype.hasPointerCapture = () => false;
|
|
101
|
-
}
|
|
102
|
-
if (!HTMLElement.prototype.setPointerCapture) {
|
|
103
|
-
HTMLElement.prototype.setPointerCapture = () => {};
|
|
104
|
-
}
|
|
105
|
-
if (!HTMLElement.prototype.releasePointerCapture) {
|
|
106
|
-
HTMLElement.prototype.releasePointerCapture = () => {};
|
|
107
|
-
}
|
|
108
|
-
});
|
|
109
|
-
|
|
110
|
-
it('saves session metadata through the feature-root page', async () => {
|
|
111
|
-
const user = userEvent.setup();
|
|
112
|
-
|
|
113
|
-
render(<SessionsConfig />);
|
|
114
|
-
|
|
115
|
-
expect(screen.getByText('No Session Selected')).toBeTruthy();
|
|
116
|
-
|
|
117
|
-
await user.click(screen.getByRole('button', { name: /Release 42/i }));
|
|
118
|
-
expect(screen.getByText('History payload')).toBeTruthy();
|
|
119
|
-
|
|
120
|
-
await user.click(screen.getByRole('button', { name: 'Metadata' }));
|
|
121
|
-
await user.clear(screen.getByPlaceholderText('Session label (optional)'));
|
|
122
|
-
await user.type(screen.getByPlaceholderText('Session label (optional)'), ' Batch 30 ');
|
|
123
|
-
await user.clear(screen.getByPlaceholderText('Preferred model (optional)'));
|
|
124
|
-
await user.type(screen.getByPlaceholderText('Preferred model (optional)'), ' gpt-5.4 ');
|
|
125
|
-
await user.click(screen.getByRole('button', { name: 'Save metadata' }));
|
|
126
|
-
|
|
127
|
-
expect(mocks.updateMutate).toHaveBeenCalledWith({
|
|
128
|
-
sessionId: 'discord:session-1',
|
|
129
|
-
data: {
|
|
130
|
-
label: 'Batch 30',
|
|
131
|
-
preferredModel: 'gpt-5.4'
|
|
132
|
-
}
|
|
133
|
-
});
|
|
134
|
-
});
|
|
135
|
-
|
|
136
|
-
it('deletes the selected session after confirmation', async () => {
|
|
137
|
-
const user = userEvent.setup();
|
|
138
|
-
|
|
139
|
-
render(<SessionsConfig />);
|
|
140
|
-
|
|
141
|
-
await user.click(screen.getByRole('button', { name: /Release 42/i }));
|
|
142
|
-
await user.click(screen.getByRole('button', { name: 'Delete' }));
|
|
143
|
-
|
|
144
|
-
expect(mocks.confirm).toHaveBeenCalledTimes(1);
|
|
145
|
-
expect(mocks.deleteMutate).toHaveBeenCalledWith(
|
|
146
|
-
{ sessionId: 'discord:session-1' },
|
|
147
|
-
expect.objectContaining({
|
|
148
|
-
onSuccess: expect.any(Function)
|
|
149
|
-
})
|
|
150
|
-
);
|
|
151
|
-
});
|
|
152
|
-
});
|
|
@@ -1,192 +0,0 @@
|
|
|
1
|
-
import { useMemo, useState } from 'react';
|
|
2
|
-
import type { NcpSessionSummaryView, SessionEntryView } from '@/shared/lib/api';
|
|
3
|
-
import { useNcpSessions } from '@/shared/hooks/use-config';
|
|
4
|
-
import { Button } from '@/shared/components/ui/button';
|
|
5
|
-
import { Input } from '@/shared/components/ui/input';
|
|
6
|
-
import { Select, SelectContent, SelectItem, SelectTrigger, SelectValue } from '@/shared/components/ui/select';
|
|
7
|
-
import { SessionRunBadge } from '@/features/chat/components/session/session-run-badge';
|
|
8
|
-
import { adaptNcpSessionSummaries, sessionDisplayName, sessionMatchesQuery } from '@/features/chat';
|
|
9
|
-
import { cn } from '@/shared/lib/utils';
|
|
10
|
-
import { formatDateShort, t } from '@/shared/lib/i18n';
|
|
11
|
-
import { PageHeader, PageLayout } from '@/app/components/layout/page-layout';
|
|
12
|
-
import { Clock, Inbox, MessageCircle, RefreshCw, Search } from 'lucide-react';
|
|
13
|
-
import { SessionsConfigDetailPane } from '@/features/chat/components/config/sessions-config-detail-pane';
|
|
14
|
-
import { ConfigSplitPage, ConfigSplitSidebar, ConfigSplitPaneBody, ConfigSplitPaneHeader } from '@/shared/components/config-split-page';
|
|
15
|
-
import { useViewportLayout } from '@/app/hooks/use-viewport-layout';
|
|
16
|
-
const UNKNOWN_CHANNEL_KEY = '__unknown_channel__';
|
|
17
|
-
function resolveChannelFromSessionKey(key: string): string {
|
|
18
|
-
const separator = key.indexOf(':');
|
|
19
|
-
if (separator <= 0) {
|
|
20
|
-
return UNKNOWN_CHANNEL_KEY;
|
|
21
|
-
}
|
|
22
|
-
return key.slice(0, separator).trim() || UNKNOWN_CHANNEL_KEY;
|
|
23
|
-
}
|
|
24
|
-
function displayChannelName(channel: string): string {
|
|
25
|
-
return channel === UNKNOWN_CHANNEL_KEY ? t('sessionsUnknownChannel') : channel;
|
|
26
|
-
}
|
|
27
|
-
function SessionListItem(props: {
|
|
28
|
-
session: SessionEntryView;
|
|
29
|
-
summary: NcpSessionSummaryView;
|
|
30
|
-
channelLabel: string;
|
|
31
|
-
isSelected: boolean;
|
|
32
|
-
onSelect: () => void;
|
|
33
|
-
}) {
|
|
34
|
-
return (
|
|
35
|
-
<button
|
|
36
|
-
onClick={props.onSelect}
|
|
37
|
-
className={cn(
|
|
38
|
-
'w-full text-left p-3.5 rounded-xl transition-all duration-200 outline-none focus:outline-none focus:ring-0 group',
|
|
39
|
-
props.isSelected ? 'bg-brand-50 border border-brand-100/50' : 'bg-transparent border border-transparent hover:bg-gray-50/80'
|
|
40
|
-
)}
|
|
41
|
-
>
|
|
42
|
-
<div className="flex items-start justify-between mb-1.5">
|
|
43
|
-
<div
|
|
44
|
-
className={cn('font-semibold truncate pr-2 flex-1 text-sm', props.isSelected ? 'text-brand-800' : 'text-gray-900')}
|
|
45
|
-
>
|
|
46
|
-
{sessionDisplayName(props.session)}
|
|
47
|
-
</div>
|
|
48
|
-
<div
|
|
49
|
-
className={cn(
|
|
50
|
-
'text-[10px] font-bold px-2 py-0.5 rounded-full shrink-0 capitalize',
|
|
51
|
-
props.isSelected ? 'bg-white text-brand-600 shadow-[0_1px_2px_rgba(0,0,0,0.02)]' : 'bg-gray-100 text-gray-500'
|
|
52
|
-
)}
|
|
53
|
-
>
|
|
54
|
-
{props.channelLabel}
|
|
55
|
-
</div>
|
|
56
|
-
</div>
|
|
57
|
-
<div
|
|
58
|
-
className={cn('flex items-center text-xs justify-between mt-2 font-medium', props.isSelected ? 'text-brand-600/80' : 'text-gray-400')}
|
|
59
|
-
>
|
|
60
|
-
<div className="flex items-center gap-1.5">
|
|
61
|
-
<span className="inline-flex h-3.5 w-3.5 shrink-0 items-center justify-center">
|
|
62
|
-
{props.summary.status === 'running' ? <SessionRunBadge status="running" /> : null}
|
|
63
|
-
</span>
|
|
64
|
-
<Clock className="w-3.5 h-3.5 opacity-70" />
|
|
65
|
-
<span className="truncate max-w-[100px]">{formatDateShort(props.summary.updatedAt)}</span>
|
|
66
|
-
</div>
|
|
67
|
-
<div className="flex items-center gap-1">
|
|
68
|
-
<MessageCircle className="w-3.5 h-3.5 opacity-70" />
|
|
69
|
-
<span>{props.summary.messageCount}</span>
|
|
70
|
-
</div>
|
|
71
|
-
</div>
|
|
72
|
-
</button>
|
|
73
|
-
);
|
|
74
|
-
}
|
|
75
|
-
export function SessionsConfig() {
|
|
76
|
-
const { isMobile } = useViewportLayout();
|
|
77
|
-
const [query, setQuery] = useState('');
|
|
78
|
-
const [selectedSessionId, setSelectedSessionId] = useState<string | null>(null);
|
|
79
|
-
const [selectedChannel, setSelectedChannel] = useState('all');
|
|
80
|
-
const sessionsQuery = useNcpSessions({ limit: 100 });
|
|
81
|
-
const sessionSummaries = useMemo(() => sessionsQuery.data?.sessions ?? [], [sessionsQuery.data?.sessions]);
|
|
82
|
-
const sessionEntries = useMemo(() => adaptNcpSessionSummaries(sessionSummaries), [sessionSummaries]);
|
|
83
|
-
const sessionSummaryById = useMemo(() => new Map(sessionSummaries.map((session) => [session.sessionId, session])), [
|
|
84
|
-
sessionSummaries
|
|
85
|
-
]);
|
|
86
|
-
const filteredSessions = useMemo(
|
|
87
|
-
() =>
|
|
88
|
-
sessionEntries.filter((session) => {
|
|
89
|
-
if (selectedChannel !== 'all' && resolveChannelFromSessionKey(session.key) !== selectedChannel) {
|
|
90
|
-
return false;
|
|
91
|
-
}
|
|
92
|
-
return sessionMatchesQuery(session, query);
|
|
93
|
-
}),
|
|
94
|
-
[query, selectedChannel, sessionEntries]
|
|
95
|
-
);
|
|
96
|
-
const channels = useMemo(() => {
|
|
97
|
-
const set = new Set<string>();
|
|
98
|
-
for (const session of sessionEntries) {
|
|
99
|
-
set.add(resolveChannelFromSessionKey(session.key));
|
|
100
|
-
}
|
|
101
|
-
return Array.from(set).sort((a, b) => {
|
|
102
|
-
if (a === UNKNOWN_CHANNEL_KEY) {
|
|
103
|
-
return 1;
|
|
104
|
-
}
|
|
105
|
-
if (b === UNKNOWN_CHANNEL_KEY) {
|
|
106
|
-
return -1;
|
|
107
|
-
}
|
|
108
|
-
return a.localeCompare(b);
|
|
109
|
-
});
|
|
110
|
-
}, [sessionEntries]);
|
|
111
|
-
const selectedSessionKey = selectedSessionId && sessionSummaryById.has(selectedSessionId) ? selectedSessionId : null;
|
|
112
|
-
const selectedSession = useMemo(() => sessionEntries.find((session) => session.key === selectedSessionKey) ?? null, [
|
|
113
|
-
selectedSessionKey,
|
|
114
|
-
sessionEntries
|
|
115
|
-
]);
|
|
116
|
-
const selectedSummary = selectedSessionKey ? sessionSummaryById.get(selectedSessionKey) ?? null : null;
|
|
117
|
-
const selectedChannelLabel = selectedSession ? displayChannelName(resolveChannelFromSessionKey(selectedSession.key)) : null;
|
|
118
|
-
return (
|
|
119
|
-
<PageLayout className="pb-0 xl:flex xl:h-full xl:min-h-0 xl:flex-col">
|
|
120
|
-
<PageHeader title={t('sessionsPageTitle')} description={t('sessionsPageDescription')} />
|
|
121
|
-
<ConfigSplitPage
|
|
122
|
-
className="xl:min-h-0"
|
|
123
|
-
mobileView={isMobile ? (selectedSessionKey ? 'detail' : 'list') : undefined}
|
|
124
|
-
onMobileBack={() => setSelectedSessionId(null)}
|
|
125
|
-
mobileListLabel={t('sessionsPageTitle')}
|
|
126
|
-
>
|
|
127
|
-
<ConfigSplitSidebar className="xl:w-[320px] xl:flex-none">
|
|
128
|
-
<ConfigSplitPaneHeader className="space-y-3 px-4 py-4">
|
|
129
|
-
<div className="flex items-center justify-between">
|
|
130
|
-
<span className="text-[11px] font-semibold text-gray-400 uppercase tracking-wider">{sessionEntries.length} {t('sessionsListTitle')}</span>
|
|
131
|
-
<Button
|
|
132
|
-
variant="ghost"
|
|
133
|
-
size="icon"
|
|
134
|
-
className="h-7 w-7 rounded-lg text-gray-400 hover:text-gray-700 hover:bg-gray-100"
|
|
135
|
-
onClick={() => sessionsQuery.refetch()}
|
|
136
|
-
>
|
|
137
|
-
<RefreshCw className={cn('h-3.5 w-3.5', sessionsQuery.isFetching && 'animate-spin')} />
|
|
138
|
-
</Button>
|
|
139
|
-
</div>
|
|
140
|
-
<Select value={selectedChannel} onValueChange={setSelectedChannel}>
|
|
141
|
-
<SelectTrigger className="w-full h-8.5 rounded-lg bg-gray-50/50 hover:bg-gray-100 border-gray-200 focus:ring-0 shadow-none text-xs font-medium text-gray-700">
|
|
142
|
-
<SelectValue placeholder={t('sessionsAllChannels')} />
|
|
143
|
-
</SelectTrigger>
|
|
144
|
-
<SelectContent className="rounded-xl shadow-lg border-gray-100 max-w-[280px]">
|
|
145
|
-
<SelectItem value="all" className="rounded-lg text-xs">{t('sessionsAllChannels')}</SelectItem>
|
|
146
|
-
{channels.map((channel) => (
|
|
147
|
-
<SelectItem key={channel} value={channel} className="rounded-lg text-xs truncate pr-6">
|
|
148
|
-
{displayChannelName(channel)}
|
|
149
|
-
</SelectItem>
|
|
150
|
-
))}
|
|
151
|
-
</SelectContent>
|
|
152
|
-
</Select>
|
|
153
|
-
<div className="relative w-full">
|
|
154
|
-
<Search className="h-3.5 w-3.5 absolute left-3 top-2.5 text-gray-400" />
|
|
155
|
-
<Input
|
|
156
|
-
value={query}
|
|
157
|
-
onChange={(event) => setQuery(event.target.value)}
|
|
158
|
-
placeholder={t('sessionsSearchPlaceholder')}
|
|
159
|
-
className="pl-8 h-8.5 rounded-lg bg-gray-50/50 border-gray-200 focus-visible:bg-white text-xs"
|
|
160
|
-
/>
|
|
161
|
-
</div>
|
|
162
|
-
</ConfigSplitPaneHeader>
|
|
163
|
-
<ConfigSplitPaneBody className="space-y-1 p-3 pb-10">
|
|
164
|
-
{sessionsQuery.isLoading ? (
|
|
165
|
-
<div className="text-sm text-gray-400 p-4 text-center">{t('sessionsLoading')}</div>
|
|
166
|
-
) : filteredSessions.length === 0 ? (
|
|
167
|
-
<div className="text-sm text-gray-400 p-4 text-center border-2 border-dashed border-gray-100 rounded-xl mt-4">
|
|
168
|
-
<Inbox className="w-8 h-8 mx-auto mb-2 text-gray-300" />
|
|
169
|
-
{t('sessionsEmpty')}
|
|
170
|
-
</div>
|
|
171
|
-
) : (
|
|
172
|
-
filteredSessions.map((session) => {
|
|
173
|
-
const summary = sessionSummaryById.get(session.key);
|
|
174
|
-
if (!summary) {
|
|
175
|
-
return null;
|
|
176
|
-
}
|
|
177
|
-
return <SessionListItem key={session.key} session={session} summary={summary} channelLabel={displayChannelName(resolveChannelFromSessionKey(session.key))} isSelected={selectedSessionKey === session.key} onSelect={() => setSelectedSessionId(session.key)} />;
|
|
178
|
-
})
|
|
179
|
-
)}
|
|
180
|
-
</ConfigSplitPaneBody>
|
|
181
|
-
</ConfigSplitSidebar>
|
|
182
|
-
<SessionsConfigDetailPane
|
|
183
|
-
sessionKey={selectedSessionKey}
|
|
184
|
-
session={selectedSession}
|
|
185
|
-
summary={selectedSummary}
|
|
186
|
-
channelLabel={selectedChannelLabel}
|
|
187
|
-
onClearSelection={() => setSelectedSessionId(null)}
|
|
188
|
-
/>
|
|
189
|
-
</ConfigSplitPage>
|
|
190
|
-
</PageLayout>
|
|
191
|
-
);
|
|
192
|
-
}
|
|
File without changes
|