@nextclaw/ui 0.14.1 → 0.14.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/CHANGELOG.md +29 -0
- package/dist/assets/{api-DPcvCLfa.js → api-a14tR_z1.js} +7 -7
- package/dist/assets/channels-list-page-CFGkm4DT.js +8 -0
- package/dist/assets/chat-page-CEdavJXc.js +105 -0
- package/dist/assets/{config-split-page-BCJhqdK9.js → config-split-page-B5b9B0uE.js} +1 -1
- package/dist/assets/{confirm-dialog-CWh5FfK2.js → confirm-dialog-ClH_Ec7n.js} +1 -1
- package/dist/assets/{desktop-update-config-DsRhBizi.js → desktop-update-config-DPNDnVpk.js} +1 -1
- package/dist/assets/{dist-DPrgcEC0.js → dist-BtCS2Ucq.js} +1 -1
- package/dist/assets/{dist-DsE4OsSS.js → dist-CLGGLm8b.js} +1 -1
- package/dist/assets/doc-browser-5nMWYKBD.js +1 -0
- package/dist/assets/doc-browser-BJRLhztv.js +1 -0
- package/dist/assets/doc-browser-context-D4JwMMxK.js +1 -0
- package/dist/assets/{ellipsis-B81FStLm.js → ellipsis-CtJXjIol.js} +1 -1
- package/dist/assets/{external-link-C_dmG-WJ.js → external-link-CdJiG13p.js} +1 -1
- package/dist/assets/index-BDN1zzMQ.js +105 -0
- package/dist/assets/index-g3uSZXoc.css +1 -0
- package/dist/assets/mcp-marketplace-page-BU0kIjhR.js +40 -0
- package/dist/assets/mcp-marketplace-page-sMNFSq_T.js +1 -0
- package/dist/assets/middleware-CkFT3R4v.js +1 -0
- package/dist/assets/model-config-page-D6hYXROd.js +1 -0
- package/dist/assets/plus-DPjb0piO.js +1 -0
- package/dist/assets/provider-scoped-model-input-DAX2HgmR.js +1 -0
- package/dist/assets/providers-config-page-BzAeaACA.js +1 -0
- package/dist/assets/{react-sZz5HSCm.js → react-C6cZgP44.js} +1 -1
- package/dist/assets/remote-B0G80uPr.js +1 -0
- package/dist/assets/rotate-cw-DnEB1Rju.js +1 -0
- package/dist/assets/runtime-config-page-C5xKaV3i.js +1 -0
- package/dist/assets/{save-MzjoiHri.js → save-DKA0x4zk.js} +1 -1
- package/dist/assets/{search-B29dE4GN.js → search-BNlcoj5c.js} +1 -1
- package/dist/assets/{search-config-page-Dl5sZzob.js → search-config-page-Cq9uJ-N8.js} +1 -1
- package/dist/assets/{secrets-config-page-C_l-IFCK.js → secrets-config-page-CxSbZLBo.js} +2 -2
- package/dist/assets/{select-BKmh05hd.js → select-CvTlDZTQ.js} +1 -1
- package/dist/assets/{tag-chip-BS_7Ueom.js → tag-chip-8ffF2y2C.js} +1 -1
- package/dist/assets/use-config-DmT0o1gv.js +1 -0
- package/dist/assets/x-BiSSpgqB.js +1 -0
- package/dist/index.html +15 -14
- package/package.json +9 -9
- package/src/app/components/app-presenter-provider.tsx +11 -2
- package/src/app/components/layout/__tests__/app-layout.test.tsx +11 -2
- package/src/app/components/layout/__tests__/sidebar.layout.test.tsx +110 -79
- package/src/app/components/layout/app-layout.tsx +18 -4
- package/src/app/components/layout/sidebar-items.tsx +194 -71
- package/src/app/components/layout/sidebar-rail.styles.ts +15 -0
- package/src/app/components/layout/sidebar.tsx +340 -83
- package/src/app/managers/viewport-layout.manager.ts +10 -0
- package/src/app/stores/viewport-layout.store.ts +39 -3
- package/src/features/agents/components/__tests__/agents-page.test.tsx +62 -39
- package/src/features/agents/components/agents-page.tsx +10 -6
- package/src/features/chat/components/conversation/__tests__/chat-conversation-header-section.test.tsx +145 -0
- package/src/features/chat/components/conversation/__tests__/chat-conversation-panel.test.tsx +69 -762
- package/src/features/chat/components/conversation/__tests__/chat-conversation-workspace-section.test.tsx +132 -0
- package/src/features/chat/components/conversation/chat-conversation-content.tsx +22 -15
- package/src/features/chat/components/conversation/chat-conversation-header-section.tsx +14 -15
- package/src/features/chat/components/conversation/chat-conversation-panel.tsx +18 -18
- package/src/features/chat/components/conversation/chat-conversation-workspace-section.tsx +10 -4
- package/src/features/chat/components/layout/__tests__/chat-sidebar-read-state.test.tsx +52 -11
- package/src/features/chat/components/layout/__tests__/chat-sidebar.test.tsx +16 -14
- package/src/features/chat/components/layout/chat-sidebar-desktop-layout.tsx +247 -0
- package/src/features/chat/components/layout/chat-sidebar-toolbar.tsx +80 -7
- package/src/features/chat/components/layout/chat-sidebar-utility-menu.tsx +82 -25
- package/src/features/chat/components/layout/chat-sidebar.tsx +59 -92
- package/src/features/chat/components/providers/chat-presenter.provider.tsx +0 -6
- package/src/features/chat/features/conversation/components/session-conversation-area.tsx +289 -0
- package/src/features/chat/features/conversation/components/session-conversation-input.tsx +427 -0
- package/src/features/chat/features/conversation/hooks/use-session-conversation-controller.ts +204 -0
- package/src/features/chat/features/conversation/hooks/use-session-conversation-input-attachments.ts +66 -0
- package/src/features/chat/features/{input/hooks/use-chat-input-bar-query-state.ts → conversation/hooks/use-session-conversation-input-query.ts} +32 -17
- package/src/features/chat/features/conversation/hooks/use-session-conversation-input-state.ts +281 -0
- package/src/features/chat/features/conversation/utils/session-conversation-input-toolbar.utils.ts +158 -0
- package/src/features/chat/features/input/hooks/__tests__/use-chat-input-surface-state.test.tsx +56 -0
- package/src/features/chat/features/input/hooks/use-chat-input-surface-state.ts +117 -0
- package/src/features/chat/features/input/input-surface-plugins/__tests__/panel-app-reference-plugin.test.ts +77 -0
- package/src/features/chat/features/input/input-surface-plugins/__tests__/slash-command-plugin.test.ts +108 -0
- package/src/features/chat/features/input/input-surface-plugins/chat-input-product-plugin-adapters.types.ts +10 -0
- package/src/features/chat/features/input/input-surface-plugins/input-surface-search.utils.ts +108 -0
- package/src/features/chat/features/input/input-surface-plugins/panel-app-reference-plugin.utils.ts +108 -0
- package/src/features/chat/features/input/input-surface-plugins/slash-command-plugin.utils.ts +161 -0
- package/src/features/chat/features/input/utils/__tests__/chat-composer-state.utils.test.ts +22 -1
- package/src/features/chat/features/input/utils/__tests__/chat-inline-token.utils.test.ts +26 -13
- package/src/features/chat/features/input/utils/__tests__/ncp-chat-input-availability.utils.test.ts +7 -28
- package/src/features/chat/features/input/utils/chat-composer-state.utils.ts +6 -0
- package/src/features/chat/features/input/utils/chat-inline-token.utils.ts +26 -51
- package/src/features/chat/features/input/utils/chat-input-bar.utils.ts +2 -0
- package/src/features/chat/features/input/utils/ncp-chat-input-availability.utils.ts +5 -6
- package/src/features/chat/features/message/components/__tests__/chat-message-list.container.test.tsx +47 -12
- package/src/features/chat/features/message/components/chat-message-list.container.tsx +93 -12
- package/src/features/chat/features/message/utils/__tests__/chat-message.utils.test.ts +31 -12
- package/src/features/chat/features/message/utils/chat-message-markdown-part.utils.ts +38 -0
- package/src/features/chat/features/message/utils/chat-message-part.utils.ts +1 -1
- package/src/features/chat/features/session/components/chat-sidebar-project-groups.tsx +2 -2
- package/src/features/chat/features/session/components/chat-sidebar-session-list.tsx +2 -2
- package/src/features/chat/features/session/hooks/__tests__/use-chat-session-project.test.tsx +3 -30
- package/src/features/chat/features/session/hooks/use-chat-session-project.ts +0 -5
- package/src/features/chat/features/session/utils/chat-run-metadata.utils.ts +8 -0
- package/src/features/chat/features/session-type/components/__tests__/chat-session-type-menu.test.tsx +2 -2
- package/src/features/chat/features/session-type/components/__tests__/chat-session-type-option-item.test.tsx +2 -0
- package/src/features/chat/features/session-type/components/chat-session-type-menu.tsx +2 -2
- package/src/features/chat/features/session-type/components/chat-session-type-option-item.tsx +2 -2
- package/src/features/chat/features/welcome/components/__tests__/chat-conversation-welcome.test.tsx +49 -31
- package/src/features/chat/features/welcome/components/__tests__/chat-welcome.test.tsx +2 -2
- package/src/features/chat/features/welcome/components/chat-conversation-welcome.tsx +21 -10
- package/src/features/chat/features/welcome/components/chat-welcome-session-type-picker.tsx +2 -2
- package/src/features/chat/features/welcome/components/chat-welcome.tsx +2 -2
- package/src/features/chat/features/workspace/components/__tests__/chat-session-workspace-panel-content.test.tsx +54 -0
- package/src/features/chat/features/workspace/components/chat-session-workspace-panel-content.tsx +44 -76
- package/src/features/chat/features/workspace/components/chat-session-workspace-panel-nav.tsx +5 -1
- package/src/features/chat/features/workspace/components/chat-session-workspace-panel.tsx +7 -1
- package/src/features/chat/features/workspace/hooks/use-chat-conversation-workspace-state.ts +40 -31
- package/src/features/chat/features/workspace/utils/__tests__/chat-workspace-panel-view-model.utils.test.ts +59 -1
- package/src/features/chat/features/workspace/utils/chat-thread-workspace-session.utils.ts +109 -0
- package/src/features/chat/features/workspace/utils/chat-workspace-panel-view-model.utils.ts +44 -4
- package/src/features/chat/index.ts +0 -1
- package/src/features/chat/managers/__tests__/chat-session-list.manager.test.ts +51 -99
- package/src/features/chat/managers/__tests__/chat-thread.manager.test.ts +135 -21
- package/src/features/chat/managers/chat-session-list.manager.ts +12 -43
- package/src/features/chat/managers/chat-thread.manager.ts +108 -34
- package/src/features/chat/pages/__tests__/ncp-chat-page.test.ts +48 -1
- package/src/features/chat/pages/__tests__/ncp-chat-page.test.tsx +72 -0
- package/src/features/chat/pages/ncp-chat-page.tsx +0 -122
- package/src/features/chat/presenters/chat.presenter.ts +2 -19
- package/src/features/chat/stores/__tests__/chat-thread.store.test.ts +31 -0
- package/src/features/chat/stores/chat-thread.store.ts +42 -26
- package/src/features/panel-apps/hooks/use-panel-apps.ts +2 -1
- package/src/platforms/desktop/components/__tests__/desktop-app-shell.test.tsx +50 -10
- package/src/platforms/desktop/components/desktop-app-shell.tsx +34 -10
- package/src/platforms/desktop/components/desktop-window-chrome.tsx +41 -16
- package/src/shared/components/ui/tab-strip/__tests__/compact-tab-strip.test.tsx +24 -1
- package/src/shared/components/ui/tab-strip/compact-tab-strip.tsx +8 -4
- package/src/shared/lib/i18n/locales/en-US/chat.json +20 -2
- package/src/shared/lib/i18n/locales/en-US/core.json +2 -0
- package/src/shared/lib/i18n/locales/zh-CN/chat.json +20 -2
- package/src/shared/lib/i18n/locales/zh-CN/core.json +2 -0
- package/src/shared/lib/ui-document-title/__tests__/ui-document-title.test.ts +49 -0
- package/src/shared/lib/ui-document-title/index.ts +50 -21
- package/dist/assets/channels-list-page-D6jtziu4.js +0 -8
- package/dist/assets/chat-page-BBnNJoKG.js +0 -105
- package/dist/assets/doc-browser-C8xOF_9F.js +0 -1
- package/dist/assets/doc-browser-DgQedeAn.js +0 -1
- package/dist/assets/doc-browser-context-B46tQGmO.js +0 -1
- package/dist/assets/index-7o1WdUbU.js +0 -103
- package/dist/assets/index-DQWmEWzk.css +0 -1
- package/dist/assets/mcp-marketplace-page-CWZN7ohK.js +0 -1
- package/dist/assets/mcp-marketplace-page-Dzull_4-.js +0 -40
- package/dist/assets/model-config-page-Cv0O3BIj.js +0 -1
- package/dist/assets/plus-Bnt56oqG.js +0 -1
- package/dist/assets/provider-scoped-model-input-Duuh7i3h.js +0 -1
- package/dist/assets/providers-config-page-CPDz0Lxc.js +0 -1
- package/dist/assets/remote-B0LMs8u7.js +0 -1
- package/dist/assets/rotate-cw-BfyG_KEF.js +0 -1
- package/dist/assets/runtime-config-page-q0fvv8ME.js +0 -1
- package/dist/assets/use-config-DZkBWIdL.js +0 -1
- package/dist/assets/x-CW2KO-Hz.js +0 -1
- package/src/features/chat/components/conversation/chat-conversation-alerts.tsx +0 -37
- package/src/features/chat/features/input/components/__tests__/chat-attachment-upload-limit.test.ts +0 -38
- package/src/features/chat/features/input/components/chat-input-bar.container.tsx +0 -496
- package/src/features/chat/features/message/utils/chat-message-inline-content.utils.ts +0 -95
- package/src/features/chat/managers/__tests__/chat-input.manager.test.ts +0 -448
- package/src/features/chat/managers/__tests__/chat-run-snapshot.manager.test.ts +0 -129
- package/src/features/chat/managers/__tests__/chat-run.manager.test.ts +0 -236
- package/src/features/chat/managers/__tests__/chat-session-preference-sync.manager.test.ts +0 -219
- package/src/features/chat/managers/chat-input.manager.ts +0 -430
- package/src/features/chat/managers/chat-run.manager.ts +0 -110
- package/src/features/chat/managers/chat-session-preference-sync.manager.ts +0 -142
- package/src/features/chat/stores/chat-input.store.ts +0 -104
- /package/dist/assets/{config-hints-CTqBnCDp.js → config-hints-BkYBc7z0.js} +0 -0
|
@@ -1,8 +1,10 @@
|
|
|
1
|
-
import { render, screen, within } from
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import
|
|
1
|
+
import { render, screen, within } from "@testing-library/react";
|
|
2
|
+
import { fireEvent } from "@testing-library/react";
|
|
3
|
+
import { MemoryRouter } from "react-router-dom";
|
|
4
|
+
import { beforeEach, describe, expect, it, vi } from "vitest";
|
|
5
|
+
import { Sidebar } from "@/app/components/layout/sidebar";
|
|
6
|
+
import { viewportLayoutManager } from "@/app/managers/viewport-layout.manager";
|
|
7
|
+
import type * as RemoteFeature from "@/features/remote";
|
|
6
8
|
|
|
7
9
|
const mocks = vi.hoisted(() => ({
|
|
8
10
|
openAccountPanel: vi.fn(),
|
|
@@ -11,133 +13,162 @@ const mocks = vi.hoisted(() => ({
|
|
|
11
13
|
data: {
|
|
12
14
|
account: {
|
|
13
15
|
loggedIn: true,
|
|
14
|
-
email:
|
|
15
|
-
}
|
|
16
|
-
}
|
|
17
|
-
}
|
|
16
|
+
email: "user@example.com",
|
|
17
|
+
},
|
|
18
|
+
},
|
|
19
|
+
},
|
|
18
20
|
}));
|
|
19
21
|
|
|
20
|
-
vi.mock(
|
|
22
|
+
vi.mock("@/shared/components/doc-browser", () => ({
|
|
21
23
|
useDocBrowser: () => ({
|
|
22
|
-
open: mocks.docOpen
|
|
23
|
-
})
|
|
24
|
+
open: mocks.docOpen,
|
|
25
|
+
}),
|
|
24
26
|
}));
|
|
25
27
|
|
|
26
|
-
vi.mock(
|
|
28
|
+
vi.mock("@/app/components/app-presenter-provider", () => ({
|
|
27
29
|
useAppPresenter: () => ({
|
|
28
30
|
accountManager: {
|
|
29
|
-
openAccountPanel: mocks.openAccountPanel
|
|
30
|
-
}
|
|
31
|
-
})
|
|
31
|
+
openAccountPanel: mocks.openAccountPanel,
|
|
32
|
+
},
|
|
33
|
+
}),
|
|
32
34
|
}));
|
|
33
35
|
|
|
34
|
-
vi.mock(
|
|
35
|
-
const actual =
|
|
36
|
+
vi.mock("@/features/remote", async () => {
|
|
37
|
+
const actual =
|
|
38
|
+
await vi.importActual<typeof RemoteFeature>("@/features/remote");
|
|
36
39
|
return {
|
|
37
40
|
...actual,
|
|
38
|
-
useRemoteStatus: () => mocks.remoteStatus
|
|
41
|
+
useRemoteStatus: () => mocks.remoteStatus,
|
|
39
42
|
};
|
|
40
43
|
});
|
|
41
44
|
|
|
42
|
-
vi.mock(
|
|
45
|
+
vi.mock("@/app/components/i18n-provider", () => ({
|
|
43
46
|
useI18n: () => ({
|
|
44
|
-
language:
|
|
45
|
-
setLanguage: vi.fn()
|
|
46
|
-
})
|
|
47
|
+
language: "en",
|
|
48
|
+
setLanguage: vi.fn(),
|
|
49
|
+
}),
|
|
47
50
|
}));
|
|
48
51
|
|
|
49
|
-
vi.mock(
|
|
52
|
+
vi.mock("@/app/components/theme-provider", () => ({
|
|
50
53
|
useTheme: () => ({
|
|
51
|
-
theme:
|
|
52
|
-
setTheme: vi.fn()
|
|
53
|
-
})
|
|
54
|
+
theme: "warm",
|
|
55
|
+
setTheme: vi.fn(),
|
|
56
|
+
}),
|
|
54
57
|
}));
|
|
55
58
|
|
|
56
|
-
describe(
|
|
57
|
-
|
|
59
|
+
describe("Sidebar", () => {
|
|
60
|
+
beforeEach(() => {
|
|
61
|
+
window.localStorage.clear();
|
|
62
|
+
viewportLayoutManager.resetForTests();
|
|
63
|
+
});
|
|
64
|
+
|
|
65
|
+
it("keeps the settings sidebar bounded and lets the navigation scroll independently", () => {
|
|
58
66
|
const { container } = render(
|
|
59
|
-
<MemoryRouter initialEntries={[
|
|
67
|
+
<MemoryRouter initialEntries={["/model"]}>
|
|
60
68
|
<Sidebar mode="settings" />
|
|
61
|
-
</MemoryRouter
|
|
69
|
+
</MemoryRouter>,
|
|
62
70
|
);
|
|
63
71
|
|
|
64
|
-
const aside = container.querySelector(
|
|
65
|
-
const nav = container.querySelector(
|
|
66
|
-
|
|
67
|
-
expect(aside?.className).toContain(
|
|
68
|
-
expect(aside?.className).toContain(
|
|
69
|
-
expect(
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
expect(
|
|
73
|
-
expect(nav?.className).toContain(
|
|
74
|
-
expect(
|
|
72
|
+
const aside = container.querySelector("aside");
|
|
73
|
+
const nav = container.querySelector("nav");
|
|
74
|
+
|
|
75
|
+
expect(aside?.className).toContain("min-h-0");
|
|
76
|
+
expect(aside?.className).toContain("overflow-hidden");
|
|
77
|
+
expect(
|
|
78
|
+
screen.getByTestId("settings-sidebar-header").parentElement?.className,
|
|
79
|
+
).toMatch(/(?:^|\s)py-2(?:\s|$)/);
|
|
80
|
+
expect(aside?.className).not.toContain("py-6");
|
|
81
|
+
expect(nav?.className).toContain("flex-1");
|
|
82
|
+
expect(nav?.className).toContain("min-h-0");
|
|
83
|
+
expect(nav?.className).toContain("overflow-y-auto");
|
|
84
|
+
expect(
|
|
85
|
+
screen.getByRole("link", { current: "page" }).className,
|
|
86
|
+
).not.toContain("font-semibold");
|
|
75
87
|
});
|
|
76
88
|
|
|
77
|
-
it(
|
|
89
|
+
it("keeps the original compact single-row header in settings mode", () => {
|
|
78
90
|
render(
|
|
79
|
-
<MemoryRouter initialEntries={[
|
|
91
|
+
<MemoryRouter initialEntries={["/model"]}>
|
|
80
92
|
<Sidebar mode="settings" />
|
|
81
|
-
</MemoryRouter
|
|
93
|
+
</MemoryRouter>,
|
|
82
94
|
);
|
|
83
95
|
|
|
84
|
-
const header = screen.getByTestId(
|
|
85
|
-
const backLink = screen.getByRole(
|
|
96
|
+
const header = screen.getByTestId("settings-sidebar-header");
|
|
97
|
+
const backLink = screen.getByRole("link", { name: "Back to Main" });
|
|
86
98
|
|
|
87
99
|
expect(header).toBeTruthy();
|
|
88
|
-
expect(screen.getByRole(
|
|
100
|
+
expect(screen.getByRole("heading", { name: "Settings" })).toBeTruthy();
|
|
89
101
|
expect(backLink).toBeTruthy();
|
|
90
|
-
expect(header.className).not.toContain(
|
|
91
|
-
expect(header.className).not.toContain(
|
|
92
|
-
expect(backLink.className).toContain(
|
|
102
|
+
expect(header.className).not.toContain("bg-white");
|
|
103
|
+
expect(header.className).not.toContain("rounded-2xl");
|
|
104
|
+
expect(backLink.className).toContain("hover:bg-gray-200/60");
|
|
93
105
|
});
|
|
94
106
|
|
|
95
|
-
it(
|
|
107
|
+
it("keeps the settings navigation in the expected product order", () => {
|
|
96
108
|
const { container } = render(
|
|
97
|
-
<MemoryRouter initialEntries={[
|
|
109
|
+
<MemoryRouter initialEntries={["/model"]}>
|
|
98
110
|
<Sidebar mode="settings" />
|
|
99
|
-
</MemoryRouter
|
|
111
|
+
</MemoryRouter>,
|
|
100
112
|
);
|
|
101
113
|
|
|
102
|
-
const nav = container.querySelector(
|
|
114
|
+
const nav = container.querySelector("nav");
|
|
103
115
|
if (!(nav instanceof HTMLElement)) {
|
|
104
|
-
throw new Error(
|
|
116
|
+
throw new Error("settings nav not found");
|
|
105
117
|
}
|
|
106
118
|
|
|
107
119
|
const linkTexts = within(nav)
|
|
108
|
-
.getAllByRole(
|
|
109
|
-
.map((link) => link.textContent?.trim() ||
|
|
120
|
+
.getAllByRole("link")
|
|
121
|
+
.map((link) => link.textContent?.trim() || "");
|
|
110
122
|
|
|
111
123
|
expect(linkTexts).toEqual([
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
124
|
+
"Model",
|
|
125
|
+
"Providers",
|
|
126
|
+
"Channels",
|
|
127
|
+
"Search Channels",
|
|
128
|
+
"Routing & Runtime",
|
|
129
|
+
"Updates",
|
|
130
|
+
"Remote Access",
|
|
131
|
+
"Security",
|
|
132
|
+
"Secrets",
|
|
133
|
+
"MCP",
|
|
122
134
|
]);
|
|
123
135
|
});
|
|
124
136
|
|
|
125
|
-
it(
|
|
137
|
+
it("keeps the footer utilities compact without changing the top header structure", () => {
|
|
126
138
|
render(
|
|
127
|
-
<MemoryRouter initialEntries={[
|
|
139
|
+
<MemoryRouter initialEntries={["/model"]}>
|
|
128
140
|
<Sidebar mode="settings" />
|
|
129
|
-
</MemoryRouter
|
|
141
|
+
</MemoryRouter>,
|
|
130
142
|
);
|
|
131
143
|
|
|
132
|
-
const accountEntry = screen.getByTestId(
|
|
133
|
-
const accountStatus = screen.getByTestId(
|
|
144
|
+
const accountEntry = screen.getByTestId("settings-sidebar-account-entry");
|
|
145
|
+
const accountStatus = screen.getByTestId("settings-sidebar-account-status");
|
|
134
146
|
|
|
135
147
|
expect(accountEntry).toBeTruthy();
|
|
136
|
-
expect(accountEntry.textContent).toContain(
|
|
137
|
-
expect(screen.getByText(
|
|
138
|
-
expect(accountEntry.className).toContain(
|
|
139
|
-
expect(accountEntry.className).toContain(
|
|
140
|
-
expect(accountEntry.className).toContain(
|
|
141
|
-
expect(accountStatus.className).toContain(
|
|
148
|
+
expect(accountEntry.textContent).toContain("Account");
|
|
149
|
+
expect(screen.getByText("user@example.com")).toBeTruthy();
|
|
150
|
+
expect(accountEntry.className).toContain("py-2");
|
|
151
|
+
expect(accountEntry.className).toContain("text-gray-600");
|
|
152
|
+
expect(accountEntry.className).toContain("hover:bg-gray-200/60");
|
|
153
|
+
expect(accountStatus.className).toContain("text-[11px]");
|
|
154
|
+
});
|
|
155
|
+
|
|
156
|
+
it("persists the shared sidebar collapsed state through the viewport layout store", () => {
|
|
157
|
+
const { container } = render(
|
|
158
|
+
<MemoryRouter initialEntries={["/model"]}>
|
|
159
|
+
<Sidebar mode="settings" />
|
|
160
|
+
</MemoryRouter>,
|
|
161
|
+
);
|
|
162
|
+
|
|
163
|
+
fireEvent.click(screen.getByRole("button", { name: "Collapse sidebar" }));
|
|
164
|
+
|
|
165
|
+
const aside = container.querySelector("aside");
|
|
166
|
+
const persistedState = JSON.parse(
|
|
167
|
+
window.localStorage.getItem("nextclaw.app.viewport-layout") ?? "{}",
|
|
168
|
+
) as { state?: { isSidebarCollapsed?: boolean } };
|
|
169
|
+
|
|
170
|
+
expect(aside?.getAttribute("data-sidebar-collapsed")).toBe("true");
|
|
171
|
+
expect(persistedState.state?.isSidebarCollapsed).toBe(true);
|
|
172
|
+
expect(screen.getByRole("button", { name: "Expand sidebar" })).toBeTruthy();
|
|
142
173
|
});
|
|
143
174
|
});
|
|
@@ -10,7 +10,11 @@ import { useViewportLayout } from "@/app/hooks/use-viewport-layout";
|
|
|
10
10
|
import { DesktopAppShell, getDesktopHostPlatform } from "@/platforms/desktop";
|
|
11
11
|
import { MobileAppShell } from "@/platforms/mobile";
|
|
12
12
|
import { PANEL_APPS_DOC_BROWSER_RENDERERS } from "@/features/panel-apps";
|
|
13
|
-
import {
|
|
13
|
+
import {
|
|
14
|
+
SideDock,
|
|
15
|
+
type SideDockManager,
|
|
16
|
+
useSideDockStore,
|
|
17
|
+
} from "@/features/side-dock";
|
|
14
18
|
import { getPresenter } from "@/app/presenters/app.presenter";
|
|
15
19
|
import { resolveUiDocumentTitle } from "@/shared/lib/ui-document-title";
|
|
16
20
|
import type { DocBrowserDockControls } from "@/shared/components/doc-browser/doc-browser-context";
|
|
@@ -37,12 +41,20 @@ function AppLayoutInner({
|
|
|
37
41
|
};
|
|
38
42
|
|
|
39
43
|
useEffect(() => {
|
|
40
|
-
document.title = resolveUiDocumentTitle(pathname);
|
|
44
|
+
document.title = resolveUiDocumentTitle(pathname, window.location);
|
|
41
45
|
}, [pathname, language]);
|
|
42
46
|
|
|
43
47
|
if (isMobile && desktopHostPlatform !== "win32") {
|
|
44
48
|
return (
|
|
45
|
-
<MobileAppShell
|
|
49
|
+
<MobileAppShell
|
|
50
|
+
pathname={pathname}
|
|
51
|
+
isDocBrowserOpen={isOpen}
|
|
52
|
+
docBrowserDockControls={docBrowserDockControls}
|
|
53
|
+
docBrowserRenderers={PANEL_APPS_DOC_BROWSER_RENDERERS}
|
|
54
|
+
topbarLeadingInset={
|
|
55
|
+
desktopHostPlatform === "darwin" ? "4.75rem" : undefined
|
|
56
|
+
}
|
|
57
|
+
>
|
|
46
58
|
{children}
|
|
47
59
|
</MobileAppShell>
|
|
48
60
|
);
|
|
@@ -68,7 +80,9 @@ export function AppLayout({ children }: AppLayoutProps) {
|
|
|
68
80
|
|
|
69
81
|
return (
|
|
70
82
|
<DocBrowserProvider manager={presenter.docBrowserManager}>
|
|
71
|
-
<AppLayoutInner sideDockManager={presenter.sideDockManager}>
|
|
83
|
+
<AppLayoutInner sideDockManager={presenter.sideDockManager}>
|
|
84
|
+
{children}
|
|
85
|
+
</AppLayoutInner>
|
|
72
86
|
</DocBrowserProvider>
|
|
73
87
|
);
|
|
74
88
|
}
|
|
@@ -1,10 +1,26 @@
|
|
|
1
|
-
import type { ComponentType, ReactNode } from
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
|
|
1
|
+
import type { ComponentType, ReactNode } from "react";
|
|
2
|
+
import { Link, useLocation } from "react-router-dom";
|
|
3
|
+
import {
|
|
4
|
+
Select,
|
|
5
|
+
SelectContent,
|
|
6
|
+
SelectTrigger,
|
|
7
|
+
} from "@/shared/components/ui/select";
|
|
8
|
+
import {
|
|
9
|
+
Tooltip,
|
|
10
|
+
TooltipContent,
|
|
11
|
+
TooltipProvider,
|
|
12
|
+
TooltipTrigger,
|
|
13
|
+
} from "@/shared/components/ui/tooltip";
|
|
14
|
+
import { cn } from "@/shared/lib/utils";
|
|
15
|
+
import {
|
|
16
|
+
SIDEBAR_RAIL_ACTIVE_SURFACE_CLASS,
|
|
17
|
+
SIDEBAR_RAIL_CONTROL_CLASS,
|
|
18
|
+
SIDEBAR_RAIL_ICON_CLASS,
|
|
19
|
+
SIDEBAR_RAIL_SURFACE_CLASS,
|
|
20
|
+
} from "@/app/components/layout/sidebar-rail.styles";
|
|
5
21
|
|
|
6
22
|
type SidebarIcon = ComponentType<{ className?: string }>;
|
|
7
|
-
type SidebarItemDensity =
|
|
23
|
+
type SidebarItemDensity = "default" | "compact";
|
|
8
24
|
|
|
9
25
|
type SidebarItemTone = {
|
|
10
26
|
row: string;
|
|
@@ -15,72 +31,117 @@ type SidebarItemTone = {
|
|
|
15
31
|
|
|
16
32
|
const SIDEBAR_ITEM_TONES: Record<SidebarItemDensity, SidebarItemTone> = {
|
|
17
33
|
default: {
|
|
18
|
-
row:
|
|
19
|
-
icon:
|
|
20
|
-
value:
|
|
21
|
-
gap:
|
|
34
|
+
row: "gap-3 px-3 py-2.5 text-[14px]",
|
|
35
|
+
icon: "h-[17px] w-[17px]",
|
|
36
|
+
value: "text-xs",
|
|
37
|
+
gap: "gap-3",
|
|
22
38
|
},
|
|
23
39
|
compact: {
|
|
24
|
-
row:
|
|
25
|
-
icon:
|
|
26
|
-
value:
|
|
27
|
-
gap:
|
|
28
|
-
}
|
|
40
|
+
row: "gap-2.5 px-3 py-2 text-[13px]",
|
|
41
|
+
icon: "h-4 w-4",
|
|
42
|
+
value: "text-[11px]",
|
|
43
|
+
gap: "gap-2.5",
|
|
44
|
+
},
|
|
29
45
|
};
|
|
30
46
|
|
|
31
47
|
function getSidebarItemTone(density: SidebarItemDensity): SidebarItemTone {
|
|
32
48
|
return SIDEBAR_ITEM_TONES[density];
|
|
33
49
|
}
|
|
34
50
|
|
|
51
|
+
function isSidebarRouteActive(pathname: string, target: string): boolean {
|
|
52
|
+
const normalizedPathname = pathname.toLowerCase();
|
|
53
|
+
const normalizedTarget = target.toLowerCase();
|
|
54
|
+
return (
|
|
55
|
+
normalizedPathname === normalizedTarget ||
|
|
56
|
+
normalizedPathname.startsWith(`${normalizedTarget}/`)
|
|
57
|
+
);
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
function SidebarItemTooltip({
|
|
61
|
+
children,
|
|
62
|
+
label,
|
|
63
|
+
side = "right",
|
|
64
|
+
}: {
|
|
65
|
+
children: ReactNode;
|
|
66
|
+
label: ReactNode;
|
|
67
|
+
side?: "right" | "bottom";
|
|
68
|
+
}) {
|
|
69
|
+
return (
|
|
70
|
+
<TooltipProvider delayDuration={250}>
|
|
71
|
+
<Tooltip>
|
|
72
|
+
<TooltipTrigger asChild>{children}</TooltipTrigger>
|
|
73
|
+
<TooltipContent side={side} className="text-xs">
|
|
74
|
+
{label}
|
|
75
|
+
</TooltipContent>
|
|
76
|
+
</Tooltip>
|
|
77
|
+
</TooltipProvider>
|
|
78
|
+
);
|
|
79
|
+
}
|
|
80
|
+
|
|
35
81
|
type SidebarNavLinkItemProps = {
|
|
36
82
|
to: string;
|
|
37
|
-
label:
|
|
83
|
+
label: string;
|
|
38
84
|
icon: SidebarIcon;
|
|
39
85
|
density?: SidebarItemDensity;
|
|
40
86
|
className?: string;
|
|
87
|
+
collapsed?: boolean;
|
|
41
88
|
};
|
|
42
89
|
|
|
43
90
|
export function SidebarNavLinkItem({
|
|
44
91
|
to,
|
|
45
92
|
label,
|
|
46
93
|
icon: Icon,
|
|
47
|
-
density =
|
|
48
|
-
className
|
|
94
|
+
density = "default",
|
|
95
|
+
className,
|
|
96
|
+
collapsed = false,
|
|
49
97
|
}: SidebarNavLinkItemProps) {
|
|
50
98
|
const tone = getSidebarItemTone(density);
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
99
|
+
const { pathname } = useLocation();
|
|
100
|
+
const isActive = isSidebarRouteActive(pathname, to);
|
|
101
|
+
const link = (
|
|
102
|
+
<Link
|
|
54
103
|
to={to}
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
tone.icon,
|
|
71
|
-
'transition-colors',
|
|
72
|
-
isActive ? 'text-gray-900' : 'text-gray-500 group-hover:text-gray-800'
|
|
73
|
-
)}
|
|
74
|
-
/>
|
|
75
|
-
<span className="min-w-0 flex-1 text-left">{label}</span>
|
|
76
|
-
</>
|
|
104
|
+
aria-label={label}
|
|
105
|
+
aria-current={isActive ? "page" : undefined}
|
|
106
|
+
className={cn(
|
|
107
|
+
"group flex w-full items-center rounded-xl font-medium transition-colors duration-base focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary/35",
|
|
108
|
+
collapsed
|
|
109
|
+
? cn(SIDEBAR_RAIL_CONTROL_CLASS, "justify-center px-0 py-0")
|
|
110
|
+
: tone.row,
|
|
111
|
+
isActive
|
|
112
|
+
? collapsed
|
|
113
|
+
? SIDEBAR_RAIL_ACTIVE_SURFACE_CLASS
|
|
114
|
+
: "bg-gray-200 text-gray-900 shadow-sm"
|
|
115
|
+
: collapsed
|
|
116
|
+
? SIDEBAR_RAIL_SURFACE_CLASS
|
|
117
|
+
: "text-gray-600 hover:bg-gray-200/60 hover:text-gray-900",
|
|
118
|
+
className,
|
|
77
119
|
)}
|
|
78
|
-
|
|
120
|
+
>
|
|
121
|
+
<Icon
|
|
122
|
+
className={cn(
|
|
123
|
+
collapsed ? SIDEBAR_RAIL_ICON_CLASS : tone.icon,
|
|
124
|
+
"shrink-0 transition-colors",
|
|
125
|
+
isActive
|
|
126
|
+
? "text-gray-900"
|
|
127
|
+
: "text-gray-500 group-hover:text-gray-800",
|
|
128
|
+
)}
|
|
129
|
+
/>
|
|
130
|
+
<span className={collapsed ? "sr-only" : "min-w-0 flex-1 text-left"}>
|
|
131
|
+
{label}
|
|
132
|
+
</span>
|
|
133
|
+
</Link>
|
|
134
|
+
);
|
|
135
|
+
|
|
136
|
+
return collapsed ? (
|
|
137
|
+
<SidebarItemTooltip label={label}>{link}</SidebarItemTooltip>
|
|
138
|
+
) : (
|
|
139
|
+
link
|
|
79
140
|
);
|
|
80
141
|
}
|
|
81
142
|
|
|
82
143
|
type SidebarActionItemProps = {
|
|
83
|
-
label:
|
|
144
|
+
label: string;
|
|
84
145
|
icon: SidebarIcon;
|
|
85
146
|
onClick: () => void;
|
|
86
147
|
density?: SidebarItemDensity;
|
|
@@ -90,38 +151,62 @@ type SidebarActionItemProps = {
|
|
|
90
151
|
trailingClassName?: string;
|
|
91
152
|
testId?: string;
|
|
92
153
|
trailingTestId?: string;
|
|
154
|
+
collapsed?: boolean;
|
|
93
155
|
};
|
|
94
156
|
|
|
95
157
|
export function SidebarActionItem({
|
|
96
158
|
label,
|
|
97
159
|
icon: Icon,
|
|
98
160
|
onClick,
|
|
99
|
-
density =
|
|
161
|
+
density = "default",
|
|
100
162
|
className,
|
|
101
163
|
labelClassName,
|
|
102
164
|
trailing,
|
|
103
165
|
trailingClassName,
|
|
104
166
|
testId,
|
|
105
|
-
trailingTestId
|
|
167
|
+
trailingTestId,
|
|
168
|
+
collapsed = false,
|
|
106
169
|
}: SidebarActionItemProps) {
|
|
107
170
|
const tone = getSidebarItemTone(density);
|
|
108
|
-
|
|
109
|
-
return (
|
|
171
|
+
const button = (
|
|
110
172
|
<button
|
|
111
173
|
type="button"
|
|
112
174
|
onClick={onClick}
|
|
175
|
+
aria-label={label}
|
|
113
176
|
className={cn(
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
177
|
+
"group flex w-full items-center rounded-xl font-medium text-gray-600 transition-all duration-base hover:bg-gray-200/60 hover:text-gray-800 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary/35",
|
|
178
|
+
collapsed
|
|
179
|
+
? cn(
|
|
180
|
+
SIDEBAR_RAIL_CONTROL_CLASS,
|
|
181
|
+
"justify-center px-0 py-0",
|
|
182
|
+
SIDEBAR_RAIL_SURFACE_CLASS,
|
|
183
|
+
)
|
|
184
|
+
: tone.row,
|
|
185
|
+
className,
|
|
117
186
|
)}
|
|
118
187
|
data-testid={testId}
|
|
119
188
|
>
|
|
120
|
-
<Icon
|
|
121
|
-
|
|
122
|
-
|
|
189
|
+
<Icon
|
|
190
|
+
className={cn(
|
|
191
|
+
collapsed ? SIDEBAR_RAIL_ICON_CLASS : tone.icon,
|
|
192
|
+
"shrink-0 text-gray-500 transition-colors group-hover:text-gray-800",
|
|
193
|
+
)}
|
|
194
|
+
/>
|
|
195
|
+
<span
|
|
196
|
+
className={cn(
|
|
197
|
+
collapsed ? "sr-only" : "min-w-0 flex-1 text-left",
|
|
198
|
+
labelClassName,
|
|
199
|
+
)}
|
|
200
|
+
>
|
|
201
|
+
{label}
|
|
202
|
+
</span>
|
|
203
|
+
{!collapsed && trailing ? (
|
|
123
204
|
<span
|
|
124
|
-
className={cn(
|
|
205
|
+
className={cn(
|
|
206
|
+
"shrink-0 text-gray-500",
|
|
207
|
+
tone.value,
|
|
208
|
+
trailingClassName,
|
|
209
|
+
)}
|
|
125
210
|
data-testid={trailingTestId}
|
|
126
211
|
>
|
|
127
212
|
{trailing}
|
|
@@ -129,16 +214,23 @@ export function SidebarActionItem({
|
|
|
129
214
|
) : null}
|
|
130
215
|
</button>
|
|
131
216
|
);
|
|
217
|
+
|
|
218
|
+
return collapsed ? (
|
|
219
|
+
<SidebarItemTooltip label={label}>{button}</SidebarItemTooltip>
|
|
220
|
+
) : (
|
|
221
|
+
button
|
|
222
|
+
);
|
|
132
223
|
}
|
|
133
224
|
|
|
134
225
|
type SidebarSelectItemProps = {
|
|
135
|
-
label:
|
|
226
|
+
label: string;
|
|
136
227
|
icon: SidebarIcon;
|
|
137
228
|
value: string;
|
|
138
|
-
valueLabel:
|
|
229
|
+
valueLabel: string;
|
|
139
230
|
onValueChange: (value: string) => void;
|
|
140
231
|
density?: SidebarItemDensity;
|
|
141
232
|
children: ReactNode;
|
|
233
|
+
collapsed?: boolean;
|
|
142
234
|
};
|
|
143
235
|
|
|
144
236
|
export function SidebarSelectItem({
|
|
@@ -147,25 +239,56 @@ export function SidebarSelectItem({
|
|
|
147
239
|
value,
|
|
148
240
|
valueLabel,
|
|
149
241
|
onValueChange,
|
|
150
|
-
density =
|
|
151
|
-
children
|
|
242
|
+
density = "default",
|
|
243
|
+
children,
|
|
244
|
+
collapsed = false,
|
|
152
245
|
}: SidebarSelectItemProps) {
|
|
153
246
|
const tone = getSidebarItemTone(density);
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
247
|
+
const trigger = (
|
|
248
|
+
<SelectTrigger
|
|
249
|
+
aria-label={label}
|
|
250
|
+
className={cn(
|
|
251
|
+
"group h-auto w-full rounded-xl border-0 bg-transparent font-medium text-gray-600 shadow-none hover:bg-gray-200/60 focus:ring-0 focus-visible:ring-2 focus-visible:ring-primary/35",
|
|
252
|
+
collapsed
|
|
253
|
+
? cn(
|
|
254
|
+
SIDEBAR_RAIL_CONTROL_CLASS,
|
|
255
|
+
"justify-center px-0 py-0",
|
|
256
|
+
SIDEBAR_RAIL_SURFACE_CLASS,
|
|
257
|
+
)
|
|
258
|
+
: tone.row,
|
|
259
|
+
)}
|
|
260
|
+
>
|
|
261
|
+
<div
|
|
158
262
|
className={cn(
|
|
159
|
-
|
|
160
|
-
tone.
|
|
263
|
+
"flex min-w-0 items-center",
|
|
264
|
+
collapsed ? "justify-center" : tone.gap,
|
|
161
265
|
)}
|
|
162
266
|
>
|
|
163
|
-
<
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
267
|
+
<Icon
|
|
268
|
+
className={cn(
|
|
269
|
+
collapsed ? SIDEBAR_RAIL_ICON_CLASS : tone.icon,
|
|
270
|
+
"shrink-0 text-gray-500 transition-colors group-hover:text-gray-800",
|
|
271
|
+
)}
|
|
272
|
+
/>
|
|
273
|
+
<span className={collapsed ? "sr-only" : "text-left"}>{label}</span>
|
|
274
|
+
</div>
|
|
275
|
+
{!collapsed ? (
|
|
276
|
+
<span className={cn("ml-auto text-gray-500", tone.value)}>
|
|
277
|
+
{valueLabel}
|
|
278
|
+
</span>
|
|
279
|
+
) : null}
|
|
280
|
+
</SelectTrigger>
|
|
281
|
+
);
|
|
282
|
+
|
|
283
|
+
return (
|
|
284
|
+
<Select value={value} onValueChange={onValueChange}>
|
|
285
|
+
{collapsed ? (
|
|
286
|
+
<SidebarItemTooltip label={`${label}: ${valueLabel}`}>
|
|
287
|
+
{trigger}
|
|
288
|
+
</SidebarItemTooltip>
|
|
289
|
+
) : (
|
|
290
|
+
trigger
|
|
291
|
+
)}
|
|
169
292
|
<SelectContent>{children}</SelectContent>
|
|
170
293
|
</Select>
|
|
171
294
|
);
|