@nextclaw/ui 0.12.3 → 0.12.5
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 +49 -0
- package/dist/assets/{ChannelsList-DZWam3Ob.js → ChannelsList-C6-lh55g.js} +2 -2
- package/dist/assets/ChatPage-DOW0gPc2.js +45 -0
- package/dist/assets/DocBrowser-CGyeswYP.js +1 -0
- package/dist/assets/{DocBrowser-C7-1sXqo.js → DocBrowser-QUZ3nfmH.js} +1 -1
- package/dist/assets/{DocBrowserContext-DN5tjUoS.js → DocBrowserContext-CpiIfhJO.js} +1 -1
- package/dist/assets/{LogoBadge-DDS1sU_U.js → LogoBadge-BUK13xK5.js} +1 -1
- package/dist/assets/MarketplacePage-BDVwhIYE.js +1 -0
- package/dist/assets/MarketplacePage-LnKKL3xK.js +49 -0
- package/dist/assets/McpMarketplacePage-BG4T_Pcx.js +40 -0
- package/dist/assets/ModelConfig-LtWuogIw.js +1 -0
- package/dist/assets/ProviderScopedModelInput-DGn6sFEN.js +1 -0
- package/dist/assets/ProvidersList-ma-_MlLo.js +1 -0
- package/dist/assets/{RemoteAccessPage-COnjm8_x.js → RemoteAccessPage-ff15qO-c.js} +1 -1
- package/dist/assets/RuntimeConfig-TgPandXF.js +1 -0
- package/dist/assets/SearchConfig-C9iBt7pl.js +1 -0
- package/dist/assets/{SecretsConfig-Cefg1LFJ.js → SecretsConfig-Bew4EF2A.js} +2 -2
- package/dist/assets/{SessionsConfig-BZnmVTIu.js → SessionsConfig-2r2yAGZg.js} +2 -2
- package/dist/assets/{book-open-DvWqOode.js → book-open-CJG8Yz3U.js} +1 -1
- package/dist/assets/{chat-session-display-D4bYa0b8.js → chat-session-display-DkAC5OMC.js} +1 -1
- package/dist/assets/{chunk-JZWAC4HX-CxfKRD7X.js → chunk-JZWAC4HX-D5b3Iyas.js} +1 -1
- package/dist/assets/{config-BeGwf2Ao.js → config-zvnxSXSP.js} +1 -1
- package/dist/assets/{createLucideIcon-C7MmdIX3.js → createLucideIcon-_FMJqZw2.js} +1 -1
- package/dist/assets/{dist-B6VMuIQN.js → dist-B1fpOuON.js} +1 -1
- package/dist/assets/{dist-RWNFhxvR.js → dist-BCXX7FD-.js} +2 -2
- package/dist/assets/{external-link-U86Acd1t.js → external-link-b7gAJWYY.js} +1 -1
- package/dist/assets/{hash-D-OVfV3Z.js → hash-Bhy4TwfZ.js} +1 -1
- package/dist/assets/i18n-DJg9BPYk.js +1 -0
- package/dist/assets/index-BoJbxdvZ.css +1 -0
- package/dist/assets/index-CtlT4E9Y.js +6 -0
- package/dist/assets/infiniteQueryBehavior-CTcVlD9s.js +1 -0
- package/dist/assets/loader-circle-B60I0hEk.js +1 -0
- package/dist/assets/{logos-U1_qDA3U.js → logos-GMeYU9vc.js} +1 -1
- package/dist/assets/{page-layout-Z1klaUFW.js → page-layout-C8UbWuMt.js} +1 -1
- package/dist/assets/plus-CR7RfK3H.js +1 -0
- package/dist/assets/{popover-xWbqMnIN.js → popover-8HSx9wQj.js} +1 -1
- package/dist/assets/react-BB4jko2M.js +1 -0
- package/dist/assets/{refresh-ccw-JQh1lwq-.js → refresh-ccw-CA4_C7Zg.js} +1 -1
- package/dist/assets/{save-4VRlzkii.js → save-BtvMy4lk.js} +1 -1
- package/dist/assets/search-C60UA27E.js +1 -0
- package/dist/assets/security-config-BkFDYZ6j.js +1 -0
- package/dist/assets/{select-DF-AUoie.js → select-xp_Ac8ip.js} +1 -1
- package/dist/assets/skeleton-uxz_5h3A.js +1 -0
- package/dist/assets/{status-dot-Bq_8Ojvv.js → status-dot-Cn4Pp7DZ.js} +1 -1
- package/dist/assets/{switch-D7JF_RZ-.js → switch-BTi6UOij.js} +1 -1
- package/dist/assets/{tabs-custom-CLksZ2bO.js → tabs-custom-BiiN8DME.js} +1 -1
- package/dist/assets/{trash-2-VV8jvziy.js → trash-2-BpsF0N-r.js} +1 -1
- package/dist/assets/use-infinite-scroll-loader-C8jBv11-.js +1 -0
- package/dist/assets/{useConfirmDialog-CuQqiPx7.js → useConfirmDialog-BJIwUZjH.js} +1 -1
- package/dist/assets/{useMutation-DBTWPbTg.js → useMutation-BjBOKHj_.js} +1 -1
- package/dist/assets/x-BfTu-g7D.js +1 -0
- package/dist/index.html +19 -18
- package/package.json +5 -5
- package/src/account/components/account-panel.tsx +46 -4
- package/src/account/managers/account.manager.ts +19 -4
- package/src/api/remote.ts +9 -0
- package/src/api/remote.types.ts +5 -0
- package/src/components/chat/ChatConversationPanel.test.tsx +183 -141
- package/src/components/chat/ChatSidebar.test.tsx +168 -28
- package/src/components/chat/ChatSidebar.tsx +103 -28
- package/src/components/chat/adapters/chat-message-tool-agent-id.test.ts +11 -11
- package/src/components/chat/adapters/chat-message.adapter.test.ts +43 -6
- package/src/components/chat/adapters/chat-message.session-request-tool-card.ts +182 -44
- package/src/components/chat/adapters/chat-message.session-spawn-tool-card.test.ts +104 -0
- package/src/components/chat/chat-child-session-panel.tsx +103 -45
- package/src/components/chat/chat-page-runtime.test.ts +16 -19
- package/src/components/chat/chat-session-preference-sync.test.ts +13 -0
- package/src/components/chat/chat-session-preference-sync.ts +9 -7
- package/src/components/chat/chat-sidebar-list-mode-switch.tsx +43 -0
- package/src/components/chat/chat-sidebar-project-groups.tsx +152 -0
- package/src/components/chat/hooks/use-chat-session-project.test.tsx +5 -5
- package/src/components/chat/hooks/use-chat-session-project.ts +0 -5
- package/src/components/chat/hooks/use-chat-session-update.test.tsx +75 -0
- package/src/components/chat/hooks/use-chat-session-update.ts +4 -2
- package/src/components/chat/managers/chat-session-list.manager.test.ts +46 -6
- package/src/components/chat/managers/chat-session-list.manager.ts +19 -6
- package/src/components/chat/ncp/NcpChatPage.tsx +33 -38
- package/src/components/chat/ncp/ncp-chat-input.manager.ts +3 -5
- package/src/components/chat/ncp/ncp-chat-page-data.ts +0 -1
- package/src/components/chat/ncp/ncp-chat.presenter.ts +2 -16
- package/src/components/chat/ncp/session-conversation/use-ncp-child-session-tabs-view.ts +20 -7
- package/src/components/chat/session-header/chat-session-project-badge.test.tsx +16 -0
- package/src/components/chat/session-header/chat-session-project-badge.tsx +2 -2
- package/src/components/chat/stores/chat-session-list.store.ts +3 -0
- package/src/components/chat/useChatSessionTypeState.test.tsx +0 -3
- package/src/components/chat/useChatSessionTypeState.ts +3 -5
- package/src/components/config/ChannelsList.test.tsx +68 -0
- package/src/components/config/ChannelsList.tsx +22 -4
- package/src/components/config/ProvidersList.tsx +17 -3
- package/src/components/config/providers-list.test.tsx +68 -0
- package/src/components/layout/Sidebar.tsx +13 -13
- package/src/components/layout/sidebar.layout.test.tsx +32 -1
- package/src/components/marketplace/MarketplacePage.tsx +30 -30
- package/src/components/marketplace/marketplace-page-parts.tsx +16 -24
- package/src/components/marketplace/mcp/McpMarketplacePage.tsx +28 -26
- package/src/hooks/marketplace-list-pages.ts +27 -0
- package/src/hooks/use-infinite-scroll-loader.ts +88 -0
- package/src/hooks/useMarketplace.ts +14 -3
- package/src/hooks/useMcpMarketplace.ts +14 -3
- package/src/lib/i18n.chat.ts +3 -0
- package/src/lib/i18n.remote.ts +15 -0
- package/dist/assets/ChatPage-YBL7iJ1X.js +0 -43
- package/dist/assets/DocBrowser-DQjtSsY3.js +0 -1
- package/dist/assets/MarketplacePage-2tWWgwAb.js +0 -49
- package/dist/assets/MarketplacePage-BorWJftJ.js +0 -1
- package/dist/assets/McpMarketplacePage-N-fB4HID.js +0 -40
- package/dist/assets/ModelConfig-DvsBTUiE.js +0 -1
- package/dist/assets/ProviderScopedModelInput-D9woCARc.js +0 -1
- package/dist/assets/ProvidersList-D-qPGgC4.js +0 -1
- package/dist/assets/RuntimeConfig-BHpqcaHm.js +0 -1
- package/dist/assets/SearchConfig-DIT6M65Q.js +0 -1
- package/dist/assets/i18n-hM3v-3YG.js +0 -1
- package/dist/assets/index-CpxuJa9o.css +0 -1
- package/dist/assets/index-DHmCjcxq.js +0 -6
- package/dist/assets/label-CHJ1ATds.js +0 -1
- package/dist/assets/loader-circle-C8cpaL0w.js +0 -1
- package/dist/assets/marketplace-localization-CxSTG9wr.js +0 -1
- package/dist/assets/plus-CrkO1kob.js +0 -1
- package/dist/assets/react-3YE87-lE.js +0 -1
- package/dist/assets/search-EX-Papzl.js +0 -1
- package/dist/assets/security-config-DEgOD4VX.js +0 -1
- package/dist/assets/skeleton-B0mmt1vo.js +0 -1
- package/dist/assets/x-B4sxJkGY.js +0 -1
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import { render, screen } from
|
|
2
|
-
import userEvent from
|
|
3
|
-
import { beforeEach, describe, expect, it, vi } from
|
|
4
|
-
import { ChatChildSessionPanel } from
|
|
5
|
-
import { ChatConversationPanel } from
|
|
6
|
-
import { useChatInputStore } from
|
|
7
|
-
import { useChatThreadStore } from
|
|
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 { ChatChildSessionPanel } from "@/components/chat/chat-child-session-panel";
|
|
5
|
+
import { ChatConversationPanel } from "@/components/chat/ChatConversationPanel";
|
|
6
|
+
import { useChatInputStore } from "@/components/chat/stores/chat-input.store";
|
|
7
|
+
import { useChatThreadStore } from "@/components/chat/stores/chat-thread.store";
|
|
8
8
|
|
|
9
9
|
const mocks = vi.hoisted(() => ({
|
|
10
10
|
deleteSession: vi.fn(),
|
|
@@ -12,41 +12,44 @@ const mocks = vi.hoisted(() => ({
|
|
|
12
12
|
createSession: vi.fn(),
|
|
13
13
|
setSelectedAgentId: vi.fn(),
|
|
14
14
|
setPendingSessionType: vi.fn(),
|
|
15
|
+
stickyBottomScroll: vi.fn(() => ({
|
|
16
|
+
onScroll: vi.fn(),
|
|
17
|
+
})),
|
|
15
18
|
resolvedChildTabs: [
|
|
16
19
|
{
|
|
17
|
-
sessionKey:
|
|
18
|
-
parentSessionKey:
|
|
19
|
-
title:
|
|
20
|
-
agentId:
|
|
21
|
-
|
|
22
|
-
|
|
20
|
+
sessionKey: "child-session-1",
|
|
21
|
+
parentSessionKey: "parent-session-1",
|
|
22
|
+
title: "北京天气",
|
|
23
|
+
agentId: "weather",
|
|
24
|
+
sessionTypeLabel: "Codex",
|
|
25
|
+
preferredModel: "openai/gpt-5.3-codex",
|
|
26
|
+
projectName: "project-alpha",
|
|
27
|
+
projectRoot: "/Users/demo/project-alpha",
|
|
23
28
|
},
|
|
24
29
|
],
|
|
25
30
|
}));
|
|
26
31
|
|
|
27
|
-
vi.mock(
|
|
32
|
+
vi.mock("@nextclaw/agent-chat-ui", async (importOriginal) => {
|
|
28
33
|
const actual = await importOriginal();
|
|
29
34
|
return {
|
|
30
35
|
...(actual as object),
|
|
31
|
-
useStickyBottomScroll:
|
|
32
|
-
onScroll: vi.fn()
|
|
33
|
-
})
|
|
36
|
+
useStickyBottomScroll: mocks.stickyBottomScroll,
|
|
34
37
|
};
|
|
35
38
|
});
|
|
36
39
|
|
|
37
|
-
vi.mock(
|
|
40
|
+
vi.mock("@/components/chat/nextclaw", () => ({
|
|
38
41
|
ChatInputBarContainer: () => <div data-testid="chat-input-bar" />,
|
|
39
|
-
ChatMessageListContainer: () => <div data-testid="chat-message-list"
|
|
42
|
+
ChatMessageListContainer: () => <div data-testid="chat-message-list" />,
|
|
40
43
|
}));
|
|
41
44
|
|
|
42
|
-
vi.mock(
|
|
45
|
+
vi.mock("@/components/chat/containers/chat-message-list.container", () => ({
|
|
43
46
|
ChatMessageListContainer: () => <div data-testid="child-chat-message-list" />,
|
|
44
47
|
}));
|
|
45
48
|
|
|
46
|
-
vi.mock(
|
|
49
|
+
vi.mock("@/components/chat/ChatWelcome", () => ({
|
|
47
50
|
ChatWelcome: ({
|
|
48
51
|
onCreateSession,
|
|
49
|
-
onSelectAgent
|
|
52
|
+
onSelectAgent,
|
|
50
53
|
}: {
|
|
51
54
|
onCreateSession: () => void;
|
|
52
55
|
onSelectAgent: (agentId: string) => void;
|
|
@@ -55,87 +58,102 @@ vi.mock('@/components/chat/ChatWelcome', () => ({
|
|
|
55
58
|
<button type="button" onClick={onCreateSession}>
|
|
56
59
|
create draft session
|
|
57
60
|
</button>
|
|
58
|
-
<button type="button" onClick={() => onSelectAgent(
|
|
61
|
+
<button type="button" onClick={() => onSelectAgent("engineer")}>
|
|
59
62
|
switch draft agent
|
|
60
63
|
</button>
|
|
61
64
|
</div>
|
|
62
|
-
)
|
|
65
|
+
),
|
|
63
66
|
}));
|
|
64
67
|
|
|
65
|
-
vi.mock(
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
68
|
+
vi.mock("@/components/chat/presenter/chat-presenter-context", () => ({
|
|
69
|
+
usePresenter: () => ({
|
|
70
|
+
chatThreadManager: {
|
|
71
|
+
deleteSession: mocks.deleteSession,
|
|
72
|
+
goToProviders: mocks.goToProviders,
|
|
73
|
+
openSessionFromToolAction: vi.fn(),
|
|
74
|
+
selectChildSessionDetail: vi.fn(),
|
|
75
|
+
closeChildSessionDetail: vi.fn(),
|
|
76
|
+
goToParentSession: vi.fn(),
|
|
77
|
+
},
|
|
75
78
|
chatSessionListManager: {
|
|
76
79
|
selectSession: vi.fn(),
|
|
77
80
|
createSession: mocks.createSession,
|
|
78
|
-
setSelectedAgentId: mocks.setSelectedAgentId
|
|
81
|
+
setSelectedAgentId: mocks.setSelectedAgentId,
|
|
79
82
|
},
|
|
80
83
|
chatInputManager: {
|
|
81
|
-
setPendingSessionType: mocks.setPendingSessionType
|
|
82
|
-
}
|
|
83
|
-
})
|
|
84
|
-
}));
|
|
85
|
-
|
|
86
|
-
vi.mock('@/components/chat/session-header/chat-session-header-actions', () => ({
|
|
87
|
-
ChatSessionHeaderActions: () => <button aria-label="More actions" />
|
|
84
|
+
setPendingSessionType: mocks.setPendingSessionType,
|
|
85
|
+
},
|
|
86
|
+
}),
|
|
88
87
|
}));
|
|
89
88
|
|
|
90
|
-
vi.mock(
|
|
91
|
-
|
|
89
|
+
vi.mock("@/components/chat/session-header/chat-session-header-actions", () => ({
|
|
90
|
+
ChatSessionHeaderActions: () => <button aria-label="More actions" />,
|
|
92
91
|
}));
|
|
93
92
|
|
|
94
|
-
vi.mock(
|
|
95
|
-
|
|
93
|
+
vi.mock("@/components/chat/session-header/chat-session-project-badge", () => ({
|
|
94
|
+
ChatSessionProjectBadge: ({ projectName }: { projectName: string }) => (
|
|
95
|
+
<button>{projectName}</button>
|
|
96
|
+
),
|
|
96
97
|
}));
|
|
97
98
|
|
|
98
|
-
vi.mock(
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
hydrateError: null,
|
|
103
|
-
isRunning: false,
|
|
99
|
+
vi.mock(
|
|
100
|
+
"@/components/chat/ncp/session-conversation/use-ncp-child-session-tabs-view",
|
|
101
|
+
() => ({
|
|
102
|
+
useNcpChildSessionTabsView: () => mocks.resolvedChildTabs,
|
|
104
103
|
}),
|
|
105
|
-
|
|
104
|
+
);
|
|
105
|
+
|
|
106
|
+
vi.mock(
|
|
107
|
+
"@/components/chat/ncp/session-conversation/use-ncp-session-conversation",
|
|
108
|
+
() => ({
|
|
109
|
+
useNcpSessionConversation: () => ({
|
|
110
|
+
visibleMessages: [],
|
|
111
|
+
isHydrating: false,
|
|
112
|
+
hydrateError: null,
|
|
113
|
+
isRunning: false,
|
|
114
|
+
}),
|
|
115
|
+
}),
|
|
116
|
+
);
|
|
106
117
|
|
|
107
|
-
vi.mock(
|
|
118
|
+
vi.mock("@/components/common/AgentAvatar", () => ({
|
|
108
119
|
AgentAvatar: ({ agentId }: { agentId: string }) => (
|
|
109
120
|
<div data-testid="agent-avatar">{agentId}</div>
|
|
110
121
|
),
|
|
111
122
|
}));
|
|
112
123
|
|
|
113
|
-
vi.mock(
|
|
124
|
+
vi.mock("@/components/common/agent-identity", () => ({
|
|
114
125
|
AgentIdentityAvatar: ({ agentId }: { agentId: string }) => (
|
|
115
126
|
<div data-testid="agent-identity-avatar">{agentId}</div>
|
|
116
127
|
),
|
|
117
128
|
}));
|
|
118
129
|
|
|
119
|
-
describe(
|
|
130
|
+
describe("ChatConversationPanel", () => {
|
|
120
131
|
beforeEach(() => {
|
|
121
132
|
mocks.deleteSession.mockReset();
|
|
122
133
|
mocks.goToProviders.mockReset();
|
|
123
134
|
mocks.createSession.mockReset();
|
|
124
135
|
mocks.setSelectedAgentId.mockReset();
|
|
125
136
|
mocks.setPendingSessionType.mockReset();
|
|
137
|
+
mocks.stickyBottomScroll.mockClear();
|
|
126
138
|
useChatInputStore.setState({
|
|
127
139
|
snapshot: {
|
|
128
140
|
...useChatInputStore.getState().snapshot,
|
|
129
|
-
defaultSessionType:
|
|
130
|
-
}
|
|
141
|
+
defaultSessionType: "native",
|
|
142
|
+
},
|
|
131
143
|
});
|
|
132
144
|
useChatThreadStore.setState({
|
|
133
145
|
snapshot: {
|
|
134
146
|
...useChatThreadStore.getState().snapshot,
|
|
135
147
|
isProviderStateResolved: true,
|
|
136
|
-
modelOptions: [
|
|
137
|
-
|
|
138
|
-
|
|
148
|
+
modelOptions: [
|
|
149
|
+
{
|
|
150
|
+
value: "openai/gpt-5.1",
|
|
151
|
+
modelLabel: "gpt-5.1",
|
|
152
|
+
providerLabel: "OpenAI",
|
|
153
|
+
} as never,
|
|
154
|
+
],
|
|
155
|
+
sessionTypeLabel: "Codex",
|
|
156
|
+
sessionKey: "draft-session-1",
|
|
139
157
|
sessionDisplayName: undefined,
|
|
140
158
|
agentId: null,
|
|
141
159
|
agentDisplayName: null,
|
|
@@ -150,121 +168,127 @@ describe('ChatConversationPanel', () => {
|
|
|
150
168
|
parentSessionKey: null,
|
|
151
169
|
parentSessionLabel: null,
|
|
152
170
|
availableAgents: [
|
|
153
|
-
{ id:
|
|
154
|
-
{ id:
|
|
171
|
+
{ id: "main", displayName: "Main", runtime: "native" },
|
|
172
|
+
{ id: "engineer", displayName: "Engineer", runtime: "codex" },
|
|
155
173
|
],
|
|
156
174
|
childSessionTabs: [],
|
|
157
175
|
activeChildSessionKey: null,
|
|
158
|
-
}
|
|
176
|
+
},
|
|
159
177
|
});
|
|
160
178
|
});
|
|
161
179
|
|
|
162
|
-
it(
|
|
180
|
+
it("shows the draft session type in the conversation header", () => {
|
|
163
181
|
render(<ChatConversationPanel />);
|
|
164
182
|
|
|
165
|
-
expect(screen.getByText(
|
|
166
|
-
expect(screen.getByText(
|
|
167
|
-
expect(screen.getByLabelText(
|
|
183
|
+
expect(screen.getByText("New Task")).toBeTruthy();
|
|
184
|
+
expect(screen.getByText("Codex")).toBeTruthy();
|
|
185
|
+
expect(screen.getByLabelText("More actions")).toBeTruthy();
|
|
168
186
|
});
|
|
169
187
|
|
|
170
|
-
it(
|
|
188
|
+
it("shows the selected session project badge and more actions trigger", () => {
|
|
171
189
|
useChatThreadStore.setState({
|
|
172
190
|
snapshot: {
|
|
173
191
|
...useChatThreadStore.getState().snapshot,
|
|
174
|
-
sessionKey:
|
|
175
|
-
sessionDisplayName:
|
|
176
|
-
sessionProjectRoot:
|
|
177
|
-
sessionProjectName:
|
|
192
|
+
sessionKey: "session-1",
|
|
193
|
+
sessionDisplayName: "Project Thread",
|
|
194
|
+
sessionProjectRoot: "/Users/demo/workspace/project-alpha",
|
|
195
|
+
sessionProjectName: "project-alpha",
|
|
178
196
|
canDeleteSession: true,
|
|
179
|
-
}
|
|
197
|
+
},
|
|
180
198
|
});
|
|
181
199
|
|
|
182
200
|
render(<ChatConversationPanel />);
|
|
183
201
|
|
|
184
|
-
expect(screen.getByText(
|
|
185
|
-
expect(screen.getByText(
|
|
186
|
-
expect(screen.getByLabelText(
|
|
202
|
+
expect(screen.getByText("Project Thread")).toBeTruthy();
|
|
203
|
+
expect(screen.getByText("project-alpha")).toBeTruthy();
|
|
204
|
+
expect(screen.getByLabelText("More actions")).toBeTruthy();
|
|
187
205
|
});
|
|
188
206
|
|
|
189
|
-
it(
|
|
207
|
+
it("does not show a header agent marker for the main agent", () => {
|
|
190
208
|
useChatThreadStore.setState({
|
|
191
209
|
snapshot: {
|
|
192
210
|
...useChatThreadStore.getState().snapshot,
|
|
193
|
-
agentId:
|
|
194
|
-
agentDisplayName:
|
|
195
|
-
}
|
|
211
|
+
agentId: "main",
|
|
212
|
+
agentDisplayName: "Main",
|
|
213
|
+
},
|
|
196
214
|
});
|
|
197
215
|
|
|
198
216
|
render(<ChatConversationPanel />);
|
|
199
217
|
|
|
200
|
-
expect(screen.queryByTestId(
|
|
218
|
+
expect(screen.queryByTestId("agent-avatar")).toBeNull();
|
|
201
219
|
});
|
|
202
220
|
|
|
203
|
-
it(
|
|
221
|
+
it("shows only a lightweight avatar marker for a specialist agent", () => {
|
|
204
222
|
useChatThreadStore.setState({
|
|
205
223
|
snapshot: {
|
|
206
224
|
...useChatThreadStore.getState().snapshot,
|
|
207
|
-
agentId:
|
|
208
|
-
agentDisplayName:
|
|
209
|
-
}
|
|
225
|
+
agentId: "engineer",
|
|
226
|
+
agentDisplayName: "Engineer",
|
|
227
|
+
},
|
|
210
228
|
});
|
|
211
229
|
|
|
212
230
|
render(<ChatConversationPanel />);
|
|
213
231
|
|
|
214
|
-
expect(screen.getByTestId(
|
|
215
|
-
expect(screen.queryByText(
|
|
232
|
+
expect(screen.getByTestId("agent-avatar").textContent).toBe("engineer");
|
|
233
|
+
expect(screen.queryByText("Engineer")).toBeNull();
|
|
216
234
|
});
|
|
217
235
|
|
|
218
|
-
it(
|
|
236
|
+
it("creates a draft session with the selected draft agent runtime", async () => {
|
|
219
237
|
const user = userEvent.setup();
|
|
220
238
|
|
|
221
239
|
useChatThreadStore.setState({
|
|
222
240
|
snapshot: {
|
|
223
241
|
...useChatThreadStore.getState().snapshot,
|
|
224
|
-
agentId:
|
|
225
|
-
agentDisplayName:
|
|
226
|
-
}
|
|
242
|
+
agentId: "engineer",
|
|
243
|
+
agentDisplayName: "Engineer",
|
|
244
|
+
},
|
|
227
245
|
});
|
|
228
246
|
|
|
229
247
|
render(<ChatConversationPanel />);
|
|
230
248
|
|
|
231
|
-
await user.click(
|
|
249
|
+
await user.click(
|
|
250
|
+
screen.getByRole("button", { name: "create draft session" }),
|
|
251
|
+
);
|
|
232
252
|
|
|
233
|
-
expect(mocks.createSession).toHaveBeenCalledWith(
|
|
253
|
+
expect(mocks.createSession).toHaveBeenCalledWith("codex");
|
|
234
254
|
});
|
|
235
255
|
|
|
236
|
-
it(
|
|
256
|
+
it("syncs the pending session type when switching the draft agent", async () => {
|
|
237
257
|
const user = userEvent.setup();
|
|
238
258
|
|
|
239
259
|
render(<ChatConversationPanel />);
|
|
240
260
|
|
|
241
|
-
await user.click(
|
|
261
|
+
await user.click(
|
|
262
|
+
screen.getByRole("button", { name: "switch draft agent" }),
|
|
263
|
+
);
|
|
242
264
|
|
|
243
|
-
expect(mocks.setSelectedAgentId).toHaveBeenCalledWith(
|
|
244
|
-
expect(mocks.setPendingSessionType).toHaveBeenCalledWith(
|
|
265
|
+
expect(mocks.setSelectedAgentId).toHaveBeenCalledWith("engineer");
|
|
266
|
+
expect(mocks.setPendingSessionType).toHaveBeenCalledWith("codex");
|
|
245
267
|
});
|
|
246
268
|
});
|
|
247
269
|
|
|
248
|
-
describe(
|
|
249
|
-
it(
|
|
270
|
+
describe("ChatChildSessionPanel", () => {
|
|
271
|
+
it("keeps the header compact for a single child session", () => {
|
|
250
272
|
mocks.resolvedChildTabs = [
|
|
251
273
|
{
|
|
252
|
-
sessionKey:
|
|
253
|
-
parentSessionKey:
|
|
254
|
-
title:
|
|
255
|
-
agentId:
|
|
256
|
-
|
|
257
|
-
|
|
274
|
+
sessionKey: "child-session-1",
|
|
275
|
+
parentSessionKey: "parent-session-1",
|
|
276
|
+
title: "北京天气",
|
|
277
|
+
agentId: "weather",
|
|
278
|
+
sessionTypeLabel: "Codex",
|
|
279
|
+
preferredModel: "openai/gpt-5.3-codex",
|
|
280
|
+
projectName: "project-alpha",
|
|
281
|
+
projectRoot: "/Users/demo/project-alpha",
|
|
258
282
|
},
|
|
259
283
|
];
|
|
260
284
|
render(
|
|
261
285
|
<ChatChildSessionPanel
|
|
262
286
|
tabs={[
|
|
263
287
|
{
|
|
264
|
-
sessionKey:
|
|
265
|
-
parentSessionKey:
|
|
266
|
-
label:
|
|
267
|
-
agentId:
|
|
288
|
+
sessionKey: "child-session-1",
|
|
289
|
+
parentSessionKey: "parent-session-1",
|
|
290
|
+
label: "北京天气",
|
|
291
|
+
agentId: "weather",
|
|
268
292
|
},
|
|
269
293
|
]}
|
|
270
294
|
activeSessionKey="child-session-1"
|
|
@@ -274,28 +298,42 @@ describe('ChatChildSessionPanel', () => {
|
|
|
274
298
|
/>,
|
|
275
299
|
);
|
|
276
300
|
|
|
277
|
-
expect(screen.getByText(
|
|
278
|
-
expect(screen.
|
|
279
|
-
expect(screen.
|
|
301
|
+
expect(screen.getByText("北京天气")).toBeTruthy();
|
|
302
|
+
expect(screen.getByText("Codex")).toBeTruthy();
|
|
303
|
+
expect(screen.getByText("openai/gpt-5.3-codex")).toBeTruthy();
|
|
304
|
+
expect(screen.getByText("project-alpha")).toBeTruthy();
|
|
305
|
+
expect(screen.getByText("/Users/demo/project-alpha")).toBeTruthy();
|
|
306
|
+
expect(screen.queryByText("Child Sessions")).toBeNull();
|
|
307
|
+
expect(screen.queryByText("child-session-1")).toBeNull();
|
|
308
|
+
expect(mocks.stickyBottomScroll).toHaveBeenCalledWith(
|
|
309
|
+
expect.objectContaining({
|
|
310
|
+
resetKey: "child-session-1",
|
|
311
|
+
stickyThresholdPx: 20,
|
|
312
|
+
}),
|
|
313
|
+
);
|
|
280
314
|
});
|
|
281
315
|
|
|
282
|
-
it(
|
|
316
|
+
it("uses tabs as the only title layer when multiple child sessions are open", () => {
|
|
283
317
|
mocks.resolvedChildTabs = [
|
|
284
318
|
{
|
|
285
|
-
sessionKey:
|
|
286
|
-
parentSessionKey:
|
|
287
|
-
title:
|
|
288
|
-
agentId:
|
|
289
|
-
|
|
290
|
-
|
|
319
|
+
sessionKey: "child-session-1",
|
|
320
|
+
parentSessionKey: "parent-session-1",
|
|
321
|
+
title: "北京天气",
|
|
322
|
+
agentId: "weather",
|
|
323
|
+
sessionTypeLabel: "Codex",
|
|
324
|
+
preferredModel: "openai/gpt-5.3-codex",
|
|
325
|
+
projectName: "project-alpha",
|
|
326
|
+
projectRoot: "/Users/demo/project-alpha",
|
|
291
327
|
},
|
|
292
328
|
{
|
|
293
|
-
sessionKey:
|
|
294
|
-
parentSessionKey:
|
|
295
|
-
title:
|
|
296
|
-
agentId:
|
|
297
|
-
|
|
298
|
-
|
|
329
|
+
sessionKey: "child-session-2",
|
|
330
|
+
parentSessionKey: "parent-session-1",
|
|
331
|
+
title: "上海天气",
|
|
332
|
+
agentId: "weather",
|
|
333
|
+
sessionTypeLabel: "Claude Code",
|
|
334
|
+
preferredModel: "anthropic/claude-sonnet-4",
|
|
335
|
+
projectName: "project-beta",
|
|
336
|
+
projectRoot: "/Users/demo/project-beta",
|
|
299
337
|
},
|
|
300
338
|
];
|
|
301
339
|
|
|
@@ -303,16 +341,16 @@ describe('ChatChildSessionPanel', () => {
|
|
|
303
341
|
<ChatChildSessionPanel
|
|
304
342
|
tabs={[
|
|
305
343
|
{
|
|
306
|
-
sessionKey:
|
|
307
|
-
parentSessionKey:
|
|
308
|
-
label:
|
|
309
|
-
agentId:
|
|
344
|
+
sessionKey: "child-session-1",
|
|
345
|
+
parentSessionKey: "parent-session-1",
|
|
346
|
+
label: "北京天气",
|
|
347
|
+
agentId: "weather",
|
|
310
348
|
},
|
|
311
349
|
{
|
|
312
|
-
sessionKey:
|
|
313
|
-
parentSessionKey:
|
|
314
|
-
label:
|
|
315
|
-
agentId:
|
|
350
|
+
sessionKey: "child-session-2",
|
|
351
|
+
parentSessionKey: "parent-session-1",
|
|
352
|
+
label: "上海天气",
|
|
353
|
+
agentId: "weather",
|
|
316
354
|
},
|
|
317
355
|
]}
|
|
318
356
|
activeSessionKey="child-session-1"
|
|
@@ -322,13 +360,17 @@ describe('ChatChildSessionPanel', () => {
|
|
|
322
360
|
/>,
|
|
323
361
|
);
|
|
324
362
|
|
|
325
|
-
expect(screen.getAllByText(
|
|
326
|
-
expect(screen.getByText(
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
);
|
|
363
|
+
expect(screen.getAllByText("北京天气")).toHaveLength(1);
|
|
364
|
+
expect(screen.getByText("上海天气")).toBeTruthy();
|
|
365
|
+
expect(screen.getByText("Codex")).toBeTruthy();
|
|
366
|
+
expect(screen.getByText("openai/gpt-5.3-codex")).toBeTruthy();
|
|
367
|
+
expect(screen.getByText("project-alpha")).toBeTruthy();
|
|
368
|
+
expect(screen.getByText("/Users/demo/project-alpha")).toBeTruthy();
|
|
369
|
+
const tabButtons = screen
|
|
370
|
+
.getAllByRole("button")
|
|
371
|
+
.filter((element) => element.getAttribute("aria-pressed") !== null);
|
|
330
372
|
expect(tabButtons).toHaveLength(2);
|
|
331
|
-
expect(tabButtons[0]?.getAttribute(
|
|
332
|
-
expect(tabButtons[1]?.getAttribute(
|
|
373
|
+
expect(tabButtons[0]?.getAttribute("aria-pressed")).toBe("true");
|
|
374
|
+
expect(tabButtons[1]?.getAttribute("aria-pressed")).toBe("false");
|
|
333
375
|
});
|
|
334
376
|
});
|