@nextclaw/ui 0.15.23 → 0.15.24
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 +17 -0
- package/dist/assets/{api-Glw2OGXK.js → api-BxPNDp30.js} +3 -3
- package/dist/assets/appearance-settings-page-DpVJjvkB.js +1 -0
- package/dist/assets/{channels-list-page-C7E4Sxwd.js → channels-list-page-DRaNWAxC.js} +2 -2
- package/dist/assets/chat-page-BuFDmG5_.js +1 -0
- package/dist/assets/config-split-page-BVWVDbvG.js +1 -0
- package/dist/assets/confirm-dialog-mA2iVzxh.js +5 -0
- package/dist/assets/{desktop-update-config-BwuyBPJb.js → desktop-update-config-DyQb1LXr.js} +1 -1
- package/dist/assets/{dist-dv_SUR54.js → dist-B4Pf5X3Q.js} +1 -1
- package/dist/assets/{dist-CtLyEJeO.js → dist-DHEWkGWX.js} +1 -1
- package/dist/assets/{doc-browser-DlOOhBxI.js → doc-browser-CtO_HtRy.js} +1 -1
- package/dist/assets/{doc-browser-context-BIBjkwfV.js → doc-browser-context-CuGI6PQc.js} +1 -1
- package/dist/assets/doc-browser-eMUagyBV.js +1 -0
- package/dist/assets/form-actions-BOfIyG3O.js +1 -0
- package/dist/assets/index-BjBdWHV1.js +107 -0
- package/dist/assets/index-DmpmjAGQ.css +1 -0
- package/dist/assets/loader-circle-Df8wF2Pr.js +1 -0
- package/dist/assets/mcp-marketplace-page-DI49IKxp.js +1 -0
- package/dist/assets/{mcp-marketplace-page-ByhvQQj5.js → mcp-marketplace-page-ofDqbOIF.js} +3 -3
- package/dist/assets/{model-config-page-bgEx3MjQ.js → model-config-page-D73Tu3jW.js} +1 -1
- package/dist/assets/{navigation-link-CB0OQbnY.js → navigation-link-CAFOcXNg.js} +2 -2
- package/dist/assets/plus-DVU5RLCS.js +1 -0
- package/dist/assets/provider-scoped-model-input-BaJJJYMX.js +1 -0
- package/dist/assets/providers-config-page-BL6IRVBm.js +1 -0
- package/dist/assets/react-BC_orpAj.js +8 -0
- package/dist/assets/{refresh-cw-Ba0LZou4.js → refresh-cw-CWDp_JnN.js} +1 -1
- package/dist/assets/remote-T24O58lH.js +1 -0
- package/dist/assets/rotate-cw-BqhwSV5p.js +1 -0
- package/dist/assets/{runtime-config-page-C0ByyUVr.js → runtime-config-page-CXUx017t.js} +1 -1
- package/dist/assets/{save-DTOAvqzt.js → save-Cnr71JON.js} +1 -1
- package/dist/assets/{search-D4X5DNMe.js → search-CCX11X2m.js} +1 -1
- package/dist/assets/{search-config-page-Cr6254K5.js → search-config-page-BB6d5gT7.js} +1 -1
- package/dist/assets/{secrets-config-page-W2Hx332d.js → secrets-config-page-DYsDeT9K.js} +2 -2
- package/dist/assets/security-config-CVPgqL7G.js +1 -0
- package/dist/assets/{select-CDv0g2Pj.js → select-DvwBu99K.js} +2 -2
- package/dist/assets/{settings-2-CoxzNABp.js → settings-2-Dmv6zMne.js} +1 -1
- package/dist/assets/skeleton-C5tWata3.js +1 -0
- package/dist/assets/{tag-chip-CjkZEoS2.js → tag-chip-gMPvx7n_.js} +1 -1
- package/dist/assets/use-confirm-dialog-D_3-QpZU.js +1 -0
- package/dist/assets/x-BEWSqeux.js +1 -0
- package/dist/index.html +20 -20
- package/package.json +7 -7
- package/src/features/chat/features/conversation/hooks/__tests__/use-session-provider-model-catalog.test.tsx +54 -2
- package/src/features/chat/features/conversation/hooks/use-chat-composer-reference-intent.ts +10 -1
- package/src/features/chat/features/conversation/hooks/use-session-provider-model-catalog.ts +76 -1
- package/src/features/chat/features/conversation/utils/session-conversation-input-toolbar.utils.ts +6 -1
- package/src/features/chat/features/input/utils/__tests__/chat-inline-token.utils.test.ts +29 -0
- package/src/features/chat/features/input/utils/__tests__/chat-input-bar.utils.test.ts +12 -3
- package/src/features/chat/features/input/utils/chat-composer-token-protocol.utils.ts +5 -0
- package/src/features/chat/features/input/utils/chat-conversation-excerpt-token.utils.ts +59 -0
- package/src/features/chat/features/input/utils/chat-inline-token.utils.ts +42 -16
- package/src/features/chat/features/input/utils/chat-input-toolbar.utils.ts +50 -14
- package/src/features/chat/features/message/components/chat-message-list.container.tsx +40 -0
- package/src/features/chat/features/message/utils/chat-message-texts.utils.ts +5 -0
- package/src/features/chat/features/workspace/components/__tests__/workspace-text-selection-menu.test.tsx +11 -4
- package/src/features/chat/features/workspace/components/workspace-text-selection-menu.tsx +17 -195
- package/src/features/chat/managers/__tests__/chat-composer-intent.manager.test.ts +23 -0
- package/src/features/chat/managers/chat-composer-intent.manager.ts +54 -9
- package/src/features/chat/types/chat-input-bar.types.ts +3 -0
- package/src/features/side-dock/components/__tests__/side-dock.test.tsx +1 -0
- package/src/features/side-dock/configs/side-dock-built-in-items.config.ts +0 -9
- package/src/shared/lib/i18n/locales/en-US/chat.json +7 -1
- package/src/shared/lib/i18n/locales/zh-CN/chat.json +7 -1
- package/dist/assets/appearance-settings-page-Bl_W_9m7.js +0 -1
- package/dist/assets/chat-page-BT6dNI-4.js +0 -1
- package/dist/assets/config-split-page-D5BgtKrm.js +0 -1
- package/dist/assets/confirm-dialog-Bf907Azu.js +0 -5
- package/dist/assets/doc-browser-C23NDGh5.js +0 -1
- package/dist/assets/form-actions-DAzi68Cn.js +0 -1
- package/dist/assets/index-BLNg2yg0.css +0 -1
- package/dist/assets/index-D3EKjEyK.js +0 -107
- package/dist/assets/loader-circle-BSg5u0r4.js +0 -1
- package/dist/assets/mcp-marketplace-page-CytXwnUs.js +0 -1
- package/dist/assets/plus-CNjWdLhZ.js +0 -1
- package/dist/assets/provider-scoped-model-input-8F6JMd2n.js +0 -1
- package/dist/assets/providers-config-page-CxpTjR81.js +0 -1
- package/dist/assets/react-Bk2ydNTe.js +0 -8
- package/dist/assets/remote-Dv38PuMV.js +0 -1
- package/dist/assets/rotate-cw-IkYVk9JX.js +0 -1
- package/dist/assets/security-config-1E8OF4kR.js +0 -1
- package/dist/assets/skeleton-DW018fJv.js +0 -1
- package/dist/assets/use-confirm-dialog-CavtY1vJ.js +0 -1
- package/dist/assets/x-PTXYTEwz.js +0 -1
|
@@ -1,12 +1,5 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
useEffect,
|
|
4
|
-
useRef,
|
|
5
|
-
useState,
|
|
6
|
-
type ReactNode,
|
|
7
|
-
} from "react";
|
|
8
|
-
import { createPortal } from "react-dom";
|
|
9
|
-
import { MessageSquarePlus } from "lucide-react";
|
|
1
|
+
import type { ReactNode } from "react";
|
|
2
|
+
import { ChatTextSelectionAction } from "@nextclaw/agent-chat-ui";
|
|
10
3
|
import {
|
|
11
4
|
buildWorkspaceTextExcerpt,
|
|
12
5
|
WORKSPACE_TEXT_EXCERPT_MAX_CHARACTERS,
|
|
@@ -14,44 +7,6 @@ import {
|
|
|
14
7
|
} from "@/features/chat/features/workspace/utils/workspace-text-excerpt.utils";
|
|
15
8
|
import { t } from "@/shared/lib/i18n";
|
|
16
9
|
|
|
17
|
-
type SelectionMenuState = {
|
|
18
|
-
anchorBottom: number;
|
|
19
|
-
anchorCenter: number;
|
|
20
|
-
anchorTop: number;
|
|
21
|
-
excerpt: WorkspaceTextExcerpt;
|
|
22
|
-
tooLong: boolean;
|
|
23
|
-
};
|
|
24
|
-
|
|
25
|
-
type SelectionMenuPosition = {
|
|
26
|
-
left: number;
|
|
27
|
-
top: number;
|
|
28
|
-
};
|
|
29
|
-
|
|
30
|
-
const SELECTION_MENU_VIEWPORT_GAP = 12;
|
|
31
|
-
const SELECTION_MENU_ANCHOR_GAP = 10;
|
|
32
|
-
|
|
33
|
-
function containsSelection(
|
|
34
|
-
root: HTMLElement,
|
|
35
|
-
selection: Selection,
|
|
36
|
-
): selection is Selection & { rangeCount: number } {
|
|
37
|
-
if (selection.rangeCount === 0 || selection.isCollapsed) {
|
|
38
|
-
return false;
|
|
39
|
-
}
|
|
40
|
-
const range = selection.getRangeAt(0);
|
|
41
|
-
return root.contains(range.commonAncestorContainer);
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
function getSelectionAnchorRect(range: Range): DOMRect {
|
|
45
|
-
const rects = typeof range.getClientRects === "function"
|
|
46
|
-
? Array.from(range.getClientRects()).filter((rect) => rect.width > 0 || rect.height > 0)
|
|
47
|
-
: [];
|
|
48
|
-
return rects.at(-1) ?? range.getBoundingClientRect();
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
function clamp(value: number, minimum: number, maximum: number): number {
|
|
52
|
-
return Math.min(Math.max(value, minimum), Math.max(minimum, maximum));
|
|
53
|
-
}
|
|
54
|
-
|
|
55
10
|
export function WorkspaceTextSelectionMenu({
|
|
56
11
|
children,
|
|
57
12
|
fileLabel,
|
|
@@ -67,157 +22,24 @@ export function WorkspaceTextSelectionMenu({
|
|
|
67
22
|
sourceStartLine?: number | null;
|
|
68
23
|
sourceText: string;
|
|
69
24
|
}) {
|
|
70
|
-
const rootRef = useRef<HTMLDivElement>(null);
|
|
71
|
-
const menuButtonRef = useRef<HTMLButtonElement | null>(null);
|
|
72
|
-
const selectionReadFrameRef = useRef<number | null>(null);
|
|
73
|
-
const [menu, setMenu] = useState<SelectionMenuState | null>(null);
|
|
74
|
-
const [menuPosition, setMenuPosition] = useState<SelectionMenuPosition | null>(null);
|
|
75
|
-
|
|
76
|
-
const readSelection = useCallback(() => {
|
|
77
|
-
const root = rootRef.current;
|
|
78
|
-
const selection = window.getSelection();
|
|
79
|
-
if (!root || !selection || !containsSelection(root, selection)) {
|
|
80
|
-
setMenu(null);
|
|
81
|
-
return;
|
|
82
|
-
}
|
|
83
|
-
const excerpt = buildWorkspaceTextExcerpt({
|
|
84
|
-
path: filePath,
|
|
85
|
-
label: fileLabel,
|
|
86
|
-
selectedText: selection.toString(),
|
|
87
|
-
sourceText,
|
|
88
|
-
sourceStartLine,
|
|
89
|
-
});
|
|
90
|
-
if (!excerpt) {
|
|
91
|
-
setMenu(null);
|
|
92
|
-
return;
|
|
93
|
-
}
|
|
94
|
-
const rect = getSelectionAnchorRect(selection.getRangeAt(0));
|
|
95
|
-
setMenuPosition(null);
|
|
96
|
-
setMenu({
|
|
97
|
-
anchorBottom: rect.bottom,
|
|
98
|
-
anchorCenter: rect.left + rect.width / 2,
|
|
99
|
-
anchorTop: rect.top,
|
|
100
|
-
excerpt,
|
|
101
|
-
tooLong: excerpt.excerpt.length > WORKSPACE_TEXT_EXCERPT_MAX_CHARACTERS,
|
|
102
|
-
});
|
|
103
|
-
}, [fileLabel, filePath, sourceStartLine, sourceText]);
|
|
104
|
-
|
|
105
|
-
const scheduleSelectionRead = useCallback(() => {
|
|
106
|
-
if (selectionReadFrameRef.current !== null) {
|
|
107
|
-
window.cancelAnimationFrame(selectionReadFrameRef.current);
|
|
108
|
-
}
|
|
109
|
-
selectionReadFrameRef.current = window.requestAnimationFrame(() => {
|
|
110
|
-
selectionReadFrameRef.current = null;
|
|
111
|
-
readSelection();
|
|
112
|
-
});
|
|
113
|
-
}, [readSelection]);
|
|
114
|
-
|
|
115
|
-
const captureMenuButton = useCallback((button: HTMLButtonElement | null) => {
|
|
116
|
-
menuButtonRef.current = button;
|
|
117
|
-
if (!menu || !button) {
|
|
118
|
-
return;
|
|
119
|
-
}
|
|
120
|
-
const buttonRect = button.getBoundingClientRect();
|
|
121
|
-
const left = clamp(
|
|
122
|
-
menu.anchorCenter - buttonRect.width / 2,
|
|
123
|
-
SELECTION_MENU_VIEWPORT_GAP,
|
|
124
|
-
window.innerWidth - SELECTION_MENU_VIEWPORT_GAP - buttonRect.width,
|
|
125
|
-
);
|
|
126
|
-
const belowTop = menu.anchorBottom + SELECTION_MENU_ANCHOR_GAP;
|
|
127
|
-
const aboveTop = menu.anchorTop - SELECTION_MENU_ANCHOR_GAP - buttonRect.height;
|
|
128
|
-
const fitsBelow = belowTop + buttonRect.height <= window.innerHeight - SELECTION_MENU_VIEWPORT_GAP;
|
|
129
|
-
const preferredTop = fitsBelow ? belowTop : aboveTop;
|
|
130
|
-
const top = clamp(
|
|
131
|
-
preferredTop,
|
|
132
|
-
SELECTION_MENU_VIEWPORT_GAP,
|
|
133
|
-
window.innerHeight - SELECTION_MENU_VIEWPORT_GAP - buttonRect.height,
|
|
134
|
-
);
|
|
135
|
-
setMenuPosition({ left, top });
|
|
136
|
-
}, [menu]);
|
|
137
|
-
|
|
138
|
-
useEffect(() => {
|
|
139
|
-
const handleSelectionChange = () => {
|
|
140
|
-
const selection = window.getSelection();
|
|
141
|
-
if (!selection || selection.isCollapsed) {
|
|
142
|
-
setMenu(null);
|
|
143
|
-
return;
|
|
144
|
-
}
|
|
145
|
-
scheduleSelectionRead();
|
|
146
|
-
};
|
|
147
|
-
const handlePointerUp = (event: PointerEvent) => {
|
|
148
|
-
if (menuButtonRef.current?.contains(event.target as Node)) {
|
|
149
|
-
return;
|
|
150
|
-
}
|
|
151
|
-
scheduleSelectionRead();
|
|
152
|
-
};
|
|
153
|
-
const handleKeyDown = (event: KeyboardEvent) => {
|
|
154
|
-
if (event.key === "Escape") {
|
|
155
|
-
setMenu(null);
|
|
156
|
-
}
|
|
157
|
-
};
|
|
158
|
-
const closeMenu = () => setMenu(null);
|
|
159
|
-
document.addEventListener("selectionchange", handleSelectionChange);
|
|
160
|
-
document.addEventListener("pointerup", handlePointerUp, true);
|
|
161
|
-
document.addEventListener("keydown", handleKeyDown);
|
|
162
|
-
document.addEventListener("scroll", closeMenu, true);
|
|
163
|
-
window.addEventListener("resize", closeMenu);
|
|
164
|
-
return () => {
|
|
165
|
-
document.removeEventListener("selectionchange", handleSelectionChange);
|
|
166
|
-
document.removeEventListener("pointerup", handlePointerUp, true);
|
|
167
|
-
document.removeEventListener("keydown", handleKeyDown);
|
|
168
|
-
document.removeEventListener("scroll", closeMenu, true);
|
|
169
|
-
window.removeEventListener("resize", closeMenu);
|
|
170
|
-
if (selectionReadFrameRef.current !== null) {
|
|
171
|
-
window.cancelAnimationFrame(selectionReadFrameRef.current);
|
|
172
|
-
}
|
|
173
|
-
};
|
|
174
|
-
}, [scheduleSelectionRead]);
|
|
175
|
-
|
|
176
|
-
const addSelectionToChat = () => {
|
|
177
|
-
if (!menu || menu.tooLong) {
|
|
178
|
-
return;
|
|
179
|
-
}
|
|
180
|
-
onAddToChat?.(menu.excerpt);
|
|
181
|
-
window.getSelection()?.removeAllRanges();
|
|
182
|
-
setMenu(null);
|
|
183
|
-
};
|
|
184
|
-
|
|
185
|
-
const menuNode = menu && onAddToChat
|
|
186
|
-
? createPortal(
|
|
187
|
-
<button
|
|
188
|
-
ref={captureMenuButton}
|
|
189
|
-
type="button"
|
|
190
|
-
className="fixed z-[var(--z-popover,10100)] inline-flex max-w-[calc(100vw-24px)] items-center gap-1.5 overflow-hidden whitespace-nowrap rounded-xl border border-border bg-popover px-3 py-2 text-xs font-medium text-popover-foreground shadow-lg transition-colors hover:bg-[var(--interaction-hover)] hover:text-accent-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary/30 disabled:cursor-not-allowed disabled:text-muted-foreground"
|
|
191
|
-
style={{
|
|
192
|
-
left: menuPosition?.left ?? 0,
|
|
193
|
-
top: menuPosition?.top ?? 0,
|
|
194
|
-
visibility: menuPosition ? "visible" : "hidden",
|
|
195
|
-
}}
|
|
196
|
-
disabled={menu.tooLong}
|
|
197
|
-
onMouseDown={(event) => event.preventDefault()}
|
|
198
|
-
onClick={addSelectionToChat}
|
|
199
|
-
>
|
|
200
|
-
<MessageSquarePlus aria-hidden="true" className="h-3.5 w-3.5 shrink-0" />
|
|
201
|
-
<span className="truncate">
|
|
202
|
-
{menu.tooLong
|
|
203
|
-
? t("chatWorkspaceExcerptSelectionTooLong")
|
|
204
|
-
: t("chatWorkspaceAddToChat")}
|
|
205
|
-
</span>
|
|
206
|
-
</button>,
|
|
207
|
-
document.body,
|
|
208
|
-
)
|
|
209
|
-
: null;
|
|
210
|
-
|
|
211
25
|
return (
|
|
212
|
-
<
|
|
213
|
-
|
|
26
|
+
<ChatTextSelectionAction
|
|
27
|
+
actionLabel={t("chatWorkspaceAddToChat")}
|
|
214
28
|
className="h-full min-h-0"
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
29
|
+
maxCharacters={WORKSPACE_TEXT_EXCERPT_MAX_CHARACTERS}
|
|
30
|
+
selectionTooLongLabel={t("chatWorkspaceExcerptSelectionTooLong")}
|
|
31
|
+
onAddToChat={({ text }) => {
|
|
32
|
+
const excerpt = buildWorkspaceTextExcerpt({
|
|
33
|
+
path: filePath,
|
|
34
|
+
label: fileLabel,
|
|
35
|
+
selectedText: text,
|
|
36
|
+
sourceText,
|
|
37
|
+
sourceStartLine,
|
|
38
|
+
});
|
|
39
|
+
if (excerpt) onAddToChat?.(excerpt);
|
|
40
|
+
}}
|
|
218
41
|
>
|
|
219
42
|
{children}
|
|
220
|
-
|
|
221
|
-
</div>
|
|
43
|
+
</ChatTextSelectionAction>
|
|
222
44
|
);
|
|
223
45
|
}
|
|
@@ -103,4 +103,27 @@ describe("ChatComposerIntentManager", () => {
|
|
|
103
103
|
excerpt: '"name": "nextclaw"',
|
|
104
104
|
}));
|
|
105
105
|
});
|
|
106
|
+
|
|
107
|
+
it("publishes a conversation excerpt with its source message identity", () => {
|
|
108
|
+
const manager = new ChatComposerIntentManager();
|
|
109
|
+
const listener = vi.fn();
|
|
110
|
+
manager.subscribe("session-1", listener);
|
|
111
|
+
|
|
112
|
+
manager.requestConversationExcerptReference({
|
|
113
|
+
targetSessionKey: "session-1",
|
|
114
|
+
messageId: "assistant-message-1",
|
|
115
|
+
role: "assistant",
|
|
116
|
+
label: "AI reply",
|
|
117
|
+
excerpt: "Keep the visible tag concise.",
|
|
118
|
+
});
|
|
119
|
+
|
|
120
|
+
expect(listener).toHaveBeenCalledWith(expect.objectContaining({
|
|
121
|
+
kind: "conversation_excerpt",
|
|
122
|
+
messageId: "assistant-message-1",
|
|
123
|
+
role: "assistant",
|
|
124
|
+
label: "AI reply",
|
|
125
|
+
excerpt: "Keep the visible tag concise.",
|
|
126
|
+
tokenKey: expect.stringMatching(/^assistant-message-1#excerpt-/),
|
|
127
|
+
}));
|
|
128
|
+
});
|
|
106
129
|
});
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import {
|
|
2
|
+
CHAT_CONVERSATION_EXCERPT_TOKEN_KIND,
|
|
2
3
|
CHAT_WORKSPACE_EXCERPT_TOKEN_KIND,
|
|
3
4
|
CHAT_WORKSPACE_FILE_TOKEN_KIND,
|
|
4
5
|
} from "@nextclaw/shared";
|
|
@@ -22,13 +23,31 @@ export type ChatComposerExcerptReferenceIntent = ChatComposerReferenceIntentBase
|
|
|
22
23
|
endLine: number | null;
|
|
23
24
|
};
|
|
24
25
|
|
|
26
|
+
export type ChatComposerConversationExcerptIntent = ChatComposerReferenceIntentBase & {
|
|
27
|
+
kind: typeof CHAT_CONVERSATION_EXCERPT_TOKEN_KIND;
|
|
28
|
+
messageId: string;
|
|
29
|
+
role: "assistant" | "user";
|
|
30
|
+
excerpt: string;
|
|
31
|
+
};
|
|
32
|
+
|
|
25
33
|
export type ChatComposerReferenceIntent =
|
|
26
34
|
| ChatComposerFileReferenceIntent
|
|
27
|
-
| ChatComposerExcerptReferenceIntent
|
|
35
|
+
| ChatComposerExcerptReferenceIntent
|
|
36
|
+
| ChatComposerConversationExcerptIntent;
|
|
28
37
|
|
|
29
38
|
type ChatComposerReferenceRequest =
|
|
30
39
|
| Omit<ChatComposerFileReferenceIntent, "id">
|
|
31
|
-
| Omit<ChatComposerExcerptReferenceIntent, "id"
|
|
40
|
+
| Omit<ChatComposerExcerptReferenceIntent, "id">
|
|
41
|
+
| Omit<ChatComposerConversationExcerptIntent, "id">;
|
|
42
|
+
|
|
43
|
+
function createExcerptTokenKey(prefix: string, identity: string): string {
|
|
44
|
+
let hash = 2166136261;
|
|
45
|
+
for (let index = 0; index < identity.length; index += 1) {
|
|
46
|
+
hash ^= identity.charCodeAt(index);
|
|
47
|
+
hash = Math.imul(hash, 16777619);
|
|
48
|
+
}
|
|
49
|
+
return `${prefix}#excerpt-${(hash >>> 0).toString(36)}`;
|
|
50
|
+
}
|
|
32
51
|
|
|
33
52
|
type ChatComposerIntentListener = (intent: ChatComposerReferenceIntent) => void;
|
|
34
53
|
|
|
@@ -97,16 +116,13 @@ export class ChatComposerIntentManager {
|
|
|
97
116
|
if (!path || !label || !excerpt) {
|
|
98
117
|
return;
|
|
99
118
|
}
|
|
100
|
-
const identity = `${path}:${startLine ?? "x"}:${endLine ?? "x"}:${excerpt}`;
|
|
101
|
-
let hash = 2166136261;
|
|
102
|
-
for (let index = 0; index < identity.length; index += 1) {
|
|
103
|
-
hash ^= identity.charCodeAt(index);
|
|
104
|
-
hash = Math.imul(hash, 16777619);
|
|
105
|
-
}
|
|
106
119
|
this.publish({
|
|
107
120
|
kind: CHAT_WORKSPACE_EXCERPT_TOKEN_KIND,
|
|
108
121
|
targetSessionKey,
|
|
109
|
-
tokenKey:
|
|
122
|
+
tokenKey: createExcerptTokenKey(
|
|
123
|
+
path,
|
|
124
|
+
`${path}:${startLine ?? "x"}:${endLine ?? "x"}:${excerpt}`,
|
|
125
|
+
),
|
|
110
126
|
path,
|
|
111
127
|
label,
|
|
112
128
|
excerpt,
|
|
@@ -115,6 +131,35 @@ export class ChatComposerIntentManager {
|
|
|
115
131
|
});
|
|
116
132
|
};
|
|
117
133
|
|
|
134
|
+
requestConversationExcerptReference = (params: {
|
|
135
|
+
targetSessionKey: string | null;
|
|
136
|
+
messageId: string;
|
|
137
|
+
role: "assistant" | "user";
|
|
138
|
+
label: string;
|
|
139
|
+
excerpt: string;
|
|
140
|
+
}) => {
|
|
141
|
+
const {
|
|
142
|
+
targetSessionKey,
|
|
143
|
+
messageId: requestedMessageId,
|
|
144
|
+
role,
|
|
145
|
+
label: requestedLabel,
|
|
146
|
+
excerpt: requestedExcerpt,
|
|
147
|
+
} = params;
|
|
148
|
+
const messageId = requestedMessageId.trim();
|
|
149
|
+
const label = requestedLabel.trim();
|
|
150
|
+
const excerpt = requestedExcerpt.trim();
|
|
151
|
+
if (!messageId || !label || !excerpt) return;
|
|
152
|
+
this.publish({
|
|
153
|
+
kind: CHAT_CONVERSATION_EXCERPT_TOKEN_KIND,
|
|
154
|
+
targetSessionKey,
|
|
155
|
+
tokenKey: createExcerptTokenKey(messageId, `${messageId}:${excerpt}`),
|
|
156
|
+
messageId,
|
|
157
|
+
role,
|
|
158
|
+
label,
|
|
159
|
+
excerpt,
|
|
160
|
+
});
|
|
161
|
+
};
|
|
162
|
+
|
|
118
163
|
consumePending = (
|
|
119
164
|
targetSessionKey: string | null,
|
|
120
165
|
): ChatComposerReferenceIntent | null => {
|
|
@@ -49,7 +49,10 @@ export type ChatInputBarAdapterTexts = {
|
|
|
49
49
|
discoveredModelsViewLabel: string;
|
|
50
50
|
discoveredModelsGroupLabel: string;
|
|
51
51
|
discoveredModelAddLabel: string;
|
|
52
|
+
discoveredModelAddedLabel: string;
|
|
52
53
|
discoveredModelsDismissLabel: string;
|
|
54
|
+
discoveredModelsDoneLabel: string;
|
|
55
|
+
discoveredModelsCloseLabel: string;
|
|
53
56
|
thinkingLabels: Record<ChatThinkingLevel, string>;
|
|
54
57
|
noModelOptionsLabel: string;
|
|
55
58
|
configureProviderLabel: string;
|
|
@@ -36,6 +36,7 @@ describe('SideDock', () => {
|
|
|
36
36
|
builtInItems.forEach((item) => {
|
|
37
37
|
expect(document.querySelector(`[data-side-dock-item-id="${item.id}"]`)).toBeTruthy();
|
|
38
38
|
});
|
|
39
|
+
expect(document.querySelector('[data-side-dock-item-id="service-apps"]')).toBeNull();
|
|
39
40
|
|
|
40
41
|
const appsButton = document.querySelector('[data-side-dock-item-id="apps"]');
|
|
41
42
|
expect(appsButton).toBeTruthy();
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import {
|
|
2
2
|
RIGHT_PANEL_APPS_URL,
|
|
3
3
|
RIGHT_PANEL_HOME_URL,
|
|
4
|
-
RIGHT_PANEL_SERVICE_APPS_URL,
|
|
5
4
|
} from '@/features/right-panel-resources';
|
|
6
5
|
import type { SideDockItem } from '@/features/side-dock/types/side-dock.types';
|
|
7
6
|
import { t } from '@/shared/lib/i18n';
|
|
@@ -20,14 +19,6 @@ export function getSideDockBuiltInItems(): SideDockItem[] {
|
|
|
20
19
|
removable: false,
|
|
21
20
|
target: { type: 'right-panel-resource', uri: RIGHT_PANEL_APPS_URL },
|
|
22
21
|
},
|
|
23
|
-
{
|
|
24
|
-
builtIn: true,
|
|
25
|
-
icon: { type: 'builtin', name: 'service-apps' },
|
|
26
|
-
id: 'service-apps',
|
|
27
|
-
label: t('serviceAppsTitle'),
|
|
28
|
-
removable: false,
|
|
29
|
-
target: { type: 'right-panel-resource', uri: RIGHT_PANEL_SERVICE_APPS_URL },
|
|
30
|
-
},
|
|
31
22
|
{
|
|
32
23
|
builtIn: true,
|
|
33
24
|
icon: { type: 'builtin', name: 'docs' },
|
|
@@ -296,8 +296,11 @@
|
|
|
296
296
|
"chatDiscoveredModelsSummary": "{count} new models available",
|
|
297
297
|
"chatDiscoveredModelsView": "View",
|
|
298
298
|
"chatDiscoveredModelsGroup": "New models",
|
|
299
|
-
"chatDiscoveredModelsDismiss": "
|
|
299
|
+
"chatDiscoveredModelsDismiss": "Dismiss this batch",
|
|
300
|
+
"chatDiscoveredModelsDone": "Done",
|
|
301
|
+
"chatDiscoveredModelsClose": "Close new models",
|
|
300
302
|
"chatDiscoveredModelAdd": "Add",
|
|
303
|
+
"chatDiscoveredModelAddedShort": "Added",
|
|
301
304
|
"chatDiscoveredModelAdded": "Added {model}",
|
|
302
305
|
"chatDiscoveredModelUnavailable": "This model is no longer available. Reopen the model selector.",
|
|
303
306
|
"chatPickerAllSkills": "All skills",
|
|
@@ -429,6 +432,9 @@
|
|
|
429
432
|
"chatMermaidExpand": "Expand diagram",
|
|
430
433
|
"chatMermaidLoading": "Rendering diagram…",
|
|
431
434
|
"chatMermaidRenderError": "Diagram could not be rendered; showing source instead",
|
|
435
|
+
"chatPreviewZoomIn": "Zoom in",
|
|
436
|
+
"chatPreviewZoomOut": "Zoom out",
|
|
437
|
+
"chatPreviewResetZoom": "Reset zoom",
|
|
432
438
|
"chatSidebarNewTask": "New Task",
|
|
433
439
|
"chatSidebarSearchPlaceholder": "Search conversations...",
|
|
434
440
|
"chatSidebarScheduledTasks": "Scheduled Tasks",
|
|
@@ -296,8 +296,11 @@
|
|
|
296
296
|
"chatDiscoveredModelsSummary": "发现 {count} 个可添加的新模型",
|
|
297
297
|
"chatDiscoveredModelsView": "查看",
|
|
298
298
|
"chatDiscoveredModelsGroup": "新模型",
|
|
299
|
-
"chatDiscoveredModelsDismiss": "
|
|
299
|
+
"chatDiscoveredModelsDismiss": "忽略这批提醒",
|
|
300
|
+
"chatDiscoveredModelsDone": "完成",
|
|
301
|
+
"chatDiscoveredModelsClose": "关闭新模型窗口",
|
|
300
302
|
"chatDiscoveredModelAdd": "添加",
|
|
303
|
+
"chatDiscoveredModelAddedShort": "已添加",
|
|
301
304
|
"chatDiscoveredModelAdded": "已添加 {model}",
|
|
302
305
|
"chatDiscoveredModelUnavailable": "这个模型已不可用,请重新打开模型选择器",
|
|
303
306
|
"chatPickerAllSkills": "全部技能",
|
|
@@ -429,6 +432,9 @@
|
|
|
429
432
|
"chatMermaidExpand": "放大图表",
|
|
430
433
|
"chatMermaidLoading": "正在渲染图表…",
|
|
431
434
|
"chatMermaidRenderError": "图表无法渲染,已显示源代码",
|
|
435
|
+
"chatPreviewZoomIn": "放大",
|
|
436
|
+
"chatPreviewZoomOut": "缩小",
|
|
437
|
+
"chatPreviewResetZoom": "重置缩放",
|
|
432
438
|
"chatSidebarNewTask": "新任务",
|
|
433
439
|
"chatSidebarSearchPlaceholder": "搜索对话...",
|
|
434
440
|
"chatSidebarScheduledTasks": "定时任务",
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{i as e}from"./chunk-DseTPa7n.js";import{M as t,P as n,a as r,i,k as a}from"./react-Bk2ydNTe.js";import{Et as o,Gt as s,Ht as c,Ut as l,Wt as u}from"./api-Glw2OGXK.js";import{a as d,i as f,n as p,r as m,t as h,w as g}from"./select-CDv0g2Pj.js";import{r as _}from"./use-confirm-dialog-CavtY1vJ.js";import{f as v,m as y,q as b,r as x}from"./index-D3EKjEyK.js";var S=e(n(),1);function C(){let{language:e,setLanguage:t}=_();return{currentLanguage:e,currentLanguageLabel:r.find(t=>t.value===e)?.label??e,languageOptions:r,selectLanguage:(0,S.useCallback)(n=>{e!==n&&(t(n),window.location.reload())},[e,t])}}var w=t(),T=[{value:`card`,labelKey:`chatMessageLayoutCard`,descriptionKey:`chatMessageLayoutCardDescription`},{value:`flat`,labelKey:`chatMessageLayoutFlat`,descriptionKey:`chatMessageLayoutFlatDescription`}];function E(){let{theme:e,setTheme:t}=v(),{currentLanguage:n,languageOptions:r,selectLanguage:_}=C(),S=b(e=>e.layout),E=b(e=>e.setLayout),D=x(e=>e.isVisible),O=x(e=>e.setVisible);return(0,w.jsx)(s,{title:i(`appearance`),children:(0,w.jsx)(u,{children:(0,w.jsxs)(l,{children:[(0,w.jsx)(c,{title:i(`theme`),control:(0,w.jsxs)(h,{value:e,onValueChange:e=>t(e),children:[(0,w.jsx)(f,{"aria-label":i(`theme`),className:`w-36 sm:w-44`,children:(0,w.jsx)(d,{})}),(0,w.jsx)(p,{children:y.map(e=>(0,w.jsx)(m,{value:e.value,children:i(e.labelKey)},e.value))})]})}),(0,w.jsx)(c,{title:i(`language`),control:(0,w.jsxs)(h,{value:n,onValueChange:e=>_(e),children:[(0,w.jsx)(f,{"aria-label":i(`language`),className:`w-36 sm:w-44`,children:(0,w.jsx)(d,{})}),(0,w.jsx)(p,{children:r.map(e=>(0,w.jsx)(m,{value:e.value,children:e.label},e.value))})]})}),(0,w.jsx)(c,{title:i(`chatMessageLayoutTitle`),description:i(`chatMessageLayoutDescription`),layout:`stacked`,children:(0,w.jsx)(`div`,{role:`radiogroup`,"aria-label":i(`chatMessageLayoutTitle`),className:`grid gap-1 rounded-xl bg-background/65 p-1 sm:grid-cols-2`,children:T.map(e=>{let t=e.value===S;return(0,w.jsxs)(`button`,{type:`button`,role:`radio`,"aria-checked":t,onClick:()=>E(e.value),className:a(`flex min-w-0 items-start gap-3 rounded-lg px-3 py-2.5 text-left transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring/40`,t?`bg-card text-foreground shadow-sm`:`text-muted-foreground hover:bg-card/60 hover:text-foreground`),children:[(0,w.jsx)(`span`,{className:a(`mt-0.5 flex h-4 w-4 shrink-0 items-center justify-center rounded-full ring-1`,t?`bg-primary text-primary-foreground ring-primary`:`bg-background ring-border`),children:t?(0,w.jsx)(g,{className:`h-2.5 w-2.5`,strokeWidth:3}):null}),(0,w.jsxs)(`span`,{className:`min-w-0`,children:[(0,w.jsx)(`span`,{className:`block text-sm font-medium`,children:i(e.labelKey)}),(0,w.jsx)(`span`,{className:`mt-1 block text-xs leading-5 text-muted-foreground`,children:i(e.descriptionKey)})]})]},e.value)})})}),(0,w.jsx)(c,{title:i(`sideDockVisibilityTitle`),description:i(`sideDockVisibilityDescription`),control:(0,w.jsx)(o,{id:`appearance-side-dock-visible`,"aria-label":i(`sideDockVisibilityTitle`),checked:D,onCheckedChange:O})})]})})})}export{E as AppearanceSettingsPage};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{i as e}from"./chunk-DseTPa7n.js";import{D as t,M as n,P as r,i,k as a}from"./react-Bk2ydNTe.js";import{d as o,f as s,u as c}from"./navigation-link-CB0OQbnY.js";import{Kt as l,Xt as u,Yt as d,bt as f,qt as p,tn as m}from"./api-Glw2OGXK.js";import{c as h}from"./dist-dv_SUR54.js";import{C as g,a as _,i as v,n as y,r as b,t as x}from"./select-CDv0g2Pj.js";import{a as S,c as C,i as w,n as T,o as E,r as D,s as O}from"./confirm-dialog-Bf907Azu.js";import{t as ee}from"./provider-scoped-model-input-8F6JMd2n.js";import{a as te,t as ne}from"./use-confirm-dialog-CavtY1vJ.js";import{t as k}from"./plus-CNjWdLhZ.js";import{t as re}from"./settings-2-CoxzNABp.js";import{t as ie}from"./tag-chip-CjkZEoS2.js";import{$ as ae,Gt as oe,It as se,Kt as ce,O as A,Pt as le,Q as ue,Ut as de,Vt as fe,Xt as j,Yt as pe,_ as me,_t as M,a as he,at as N,c as ge,ct as _e,d as ve,dt as P,et as ye,ft as be,g as xe,h as Se,ht as Ce,i as F,it as we,k as I,lt as Te,mt as Ee,n as L,o as De,ot as Oe,s as ke,st as R,t as Ae,tt as z,ut as je,v as B,vt as V,z as Me,zt as H}from"./index-D3EKjEyK.js";var Ne=h(`Gauge`,[[`path`,{d:`m12 14 4-4`,key:`9kzdfg`}],[`path`,{d:`M3.34 19a10 10 0 1 1 17.32 0`,key:`19p75a`}]]),U=e(r(),1),W=n(),G=new Intl.NumberFormat;function Pe({agent:e,defaults:t,runtimeOptions:n,defaultRuntime:r,defaultRuntimeLabel:a,onOpenChange:o,onEdit:s}){if(!e)return null;let c=K(e.model,t?.model),l=Fe({agent:e,defaults:t,runtimeOptions:n,defaultRuntime:r,defaultRuntimeLabel:a}),d=q(e.contextTokens,t?.contextTokens??2e5),f=q(e.reservedContextTokens,t?.reservedContextTokens),p=q(e.maxToolIterations,t?.maxToolIterations??1e3),m=K(e.thinkingDefault,t?.thinkingDefault??`off`),h=Y(e.runtimeConfig??e.engineConfig,t?.engineConfig),g=Y(e.models,t?.models);return(0,W.jsx)(T,{open:e!==null,onOpenChange:o,children:(0,W.jsxs)(D,{className:`flex max-h-[calc(100vh-2rem)] flex-col overflow-hidden border-none bg-popover p-0 sm:max-h-[720px] sm:max-w-2xl`,children:[(0,W.jsx)(`div`,{className:`shrink-0 px-5 pb-3 pt-5`,children:(0,W.jsx)(E,{className:`text-left`,children:(0,W.jsxs)(`div`,{className:`flex min-w-0 items-center gap-3`,children:[(0,W.jsx)(z,{agentId:e.id,displayName:e.displayName,avatarUrl:e.avatarUrl,className:`h-10 w-10 shrink-0`}),(0,W.jsxs)(`div`,{className:`min-w-0`,children:[(0,W.jsx)(O,{className:`truncate text-base`,children:e.displayName?.trim()||e.id}),(0,W.jsxs)(w,{className:`truncate text-xs`,children:[`@`,e.id]})]})]})})}),(0,W.jsxs)(`div`,{className:`min-h-0 flex-1 space-y-4 overflow-y-auto overscroll-contain px-5 py-3`,children:[(0,W.jsxs)(X,{icon:j,title:i(`agentsDetailsIdentitySection`),children:[(0,W.jsx)(Z,{label:i(`agentsDetailsFieldDisplayName`),value:e.displayName?.trim()||e.id}),(0,W.jsx)(Z,{label:i(`agentsDetailsFieldId`),value:e.id,mono:!0}),(0,W.jsx)(Z,{label:i(`agentsDetailsFieldDescription`),value:e.description?.trim()||i(`agentsDetailsEmptyValue`),wide:!0}),(0,W.jsx)(Z,{label:i(`agentsDetailsFieldWorkspace`),value:e.workspace??i(`agentsDetailsUnsetValue`),mono:!0,wide:!0})]}),(0,W.jsxs)(X,{icon:C,title:i(`agentsDetailsRuntimeSection`),children:[(0,W.jsx)(Z,{label:i(`agentsDetailsFieldModel`),value:c.value,source:c.source}),(0,W.jsx)(Z,{label:i(`agentsDetailsFieldRuntime`),value:l.value,source:l.source}),(0,W.jsx)(Z,{label:i(`agentsDetailsFieldRuntimeConfig`),value:h.value,source:h.source,mono:!0,prewrap:!0})]}),(0,W.jsxs)(X,{icon:Ne,title:i(`agentsDetailsContextSection`),children:[(0,W.jsx)(Z,{label:i(`agentsDetailsFieldContextTokens`),value:d.value,source:d.source}),(0,W.jsx)(Z,{label:i(`agentsDetailsFieldReservedContextTokens`),value:f.value,source:f.source}),(0,W.jsx)(Z,{label:i(`agentsDetailsFieldMaxToolIterations`),value:p.value,source:p.source})]}),(0,W.jsxs)(X,{icon:pe,title:i(`agentsDetailsBehaviorSection`),children:[(0,W.jsx)(Z,{label:i(`agentsDetailsFieldThinkingDefault`),value:m.value,source:m.source}),(0,W.jsx)(Z,{label:i(`agentsDetailsFieldModelOverrides`),value:g.value,source:g.source,mono:!0,prewrap:!0}),(0,W.jsx)(Z,{label:i(`agentsDetailsFieldAvatar`),value:e.avatar??i(`agentsDetailsUnsetValue`),mono:!0})]})]}),(0,W.jsxs)(S,{className:`shrink-0 px-5 pb-4 pt-2`,children:[(0,W.jsx)(u,{type:`button`,variant:`ghost`,onClick:()=>o(!1),children:i(`cancel`)}),(0,W.jsxs)(u,{type:`button`,variant:`primary`,className:`px-4`,onClick:()=>s(e),children:[(0,W.jsx)(H,{className:`mr-2 h-4 w-4`}),i(`agentsDetailsEditAction`)]})]})]})})}function K(e,t){let n=e?.trim();return n?{value:n,source:`override`}:{value:t?.trim()||i(`agentsDetailsUnsetValue`),source:`default`}}function q(e,t){return typeof e==`number`?{value:G.format(e),source:`override`}:{value:typeof t==`number`?G.format(t):i(`agentsDetailsUnsetValue`),source:`default`}}function Fe(e){let{agent:t,defaults:n,runtimeOptions:r,defaultRuntime:i,defaultRuntimeLabel:a}=e,o=t.runtime?.trim()||t.engine?.trim();if(o)return{value:J(o,r,a),source:`override`};let s=n?.engine?.trim()||i;return{value:s?J(s,r,a):a,source:`default`}}function J(e,t,n){let r=N(e);return r?t.find(e=>e.value===r)?.label??R(r):n}function Y(e,t){return Ie(e)?{value:JSON.stringify(e,null,2),source:`override`}:{value:Ie(t)?JSON.stringify(t,null,2):i(`agentsDetailsUnsetValue`),source:`default`}}function Ie(e){return!!(e&&typeof e==`object`&&!Array.isArray(e)&&Object.keys(e).length>0)}function X(e){let{icon:t,title:n,children:r}=e;return(0,W.jsxs)(`section`,{className:`space-y-2 border-t border-border/60 pt-3 first:border-t-0 first:pt-0`,children:[(0,W.jsxs)(`h3`,{className:`flex items-center gap-1.5 text-xs font-semibold leading-5 text-foreground`,children:[(0,W.jsx)(t,{className:`h-3.5 w-3.5 text-muted-foreground`}),n]}),(0,W.jsx)(`dl`,{className:`grid min-w-0 gap-x-6 gap-y-2.5 pl-5 sm:grid-cols-2`,children:r})]})}function Z(e){let{label:t,value:n,source:r,mono:i=!1,prewrap:o=!1,wide:s=!1}=e,c=o&&n.trim().startsWith(`{`),l=i&&(!o||c);return(0,W.jsxs)(`div`,{className:a(`grid min-w-0 grid-cols-[10rem_minmax(0,1fr)] items-baseline gap-x-2`,(s||c)&&`sm:col-span-2`),children:[(0,W.jsx)(`dt`,{className:`flex min-w-0 items-baseline leading-5`,children:(0,W.jsx)(`span`,{className:`whitespace-nowrap text-xs font-medium text-muted-foreground`,children:t})}),(0,W.jsxs)(`dd`,{className:a(`min-w-0 break-words text-xs leading-5 text-foreground`,c?`max-h-28 overflow-auto whitespace-pre-wrap rounded bg-muted/50 px-2 py-1.5 text-left`:``),children:[(0,W.jsx)(`span`,{className:l?`font-mono`:void 0,children:n}),r?(0,W.jsx)(Le,{source:r}):null]})]})}function Le({source:e}){return(0,W.jsxs)(`span`,{className:a(`ml-1 whitespace-nowrap text-xs font-normal leading-5`,e===`override`?`text-blue-500`:`text-muted-foreground`),children:[`(`,i(e===`override`?`agentsDetailsAgentOverride`:`agentsDetailsInheritedDefault`),`)`]})}function Re({form:e,disabled:t=!1,onChange:n}){return(0,W.jsxs)(`details`,{className:`group rounded-2xl border border-border bg-card`,children:[(0,W.jsxs)(`summary`,{className:`flex cursor-pointer list-none items-center justify-between gap-3 px-4 py-3 text-sm font-semibold text-foreground [&::-webkit-details-marker]:hidden`,children:[(0,W.jsxs)(`span`,{className:`flex min-w-0 items-center gap-2`,children:[(0,W.jsx)(re,{className:`h-4 w-4 shrink-0 text-muted-foreground`}),(0,W.jsx)(`span`,{className:`truncate`,children:i(`agentsAdvancedConfigToggle`)})]}),(0,W.jsx)(g,{className:`h-4 w-4 shrink-0 text-muted-foreground transition-transform group-open:rotate-180`})]}),(0,W.jsxs)(`div`,{className:`space-y-4 border-t border-border/60 px-4 py-4`,children:[(0,W.jsx)(`p`,{className:`text-xs leading-5 text-muted-foreground`,children:i(`agentsAdvancedConfigDescription`)}),(0,W.jsx)(`div`,{className:`grid gap-4 md:grid-cols-2`,children:(0,W.jsx)(ze,{label:i(`agentsAdvancedContextTokensLabel`),value:e.contextTokens,min:1e3,step:1e3,disabled:t,onChange:e=>n({contextTokens:e})})})]})]})}function ze(e){let{label:t,value:n,min:r,step:a,disabled:o,onChange:s}=e;return(0,W.jsxs)(`label`,{className:`space-y-2 text-sm font-medium text-foreground`,children:[(0,W.jsx)(`span`,{children:t}),(0,W.jsx)(d,{type:`number`,min:r,step:a,value:n,disabled:o,placeholder:i(`agentsAdvancedInheritPlaceholder`),"aria-label":t,onChange:e=>s(e.target.value)})]})}function Be(e){return{displayName:e.displayName??``,description:e.description??``,avatar:e.avatar??``,model:e.model??``,runtime:e.runtime??e.engine??``,contextTokens:Ve(e.contextTokens)}}function Ve(e){return typeof e==`number`?String(e):``}var He=U.forwardRef(({className:e,...t},n)=>(0,W.jsx)(`textarea`,{className:a(`flex min-h-28 w-full rounded-xl border border-border/75 bg-card px-3.5 py-2.5 text-sm text-foreground placeholder:text-muted-foreground/55 placeholder:font-normal transition-colors focus:outline-none focus:ring-0 disabled:cursor-not-allowed disabled:opacity-50`,e),ref:n,...t}));He.displayName=`Textarea`;function Ue(e){let{runtimeOptions:t,currentRuntime:n}=e,r=n.trim();if(!r)return t;let i=N(r);return t.some(e=>e.value===i)?t:[...t,{value:i,label:R(i),icon:null,ready:!1,reason:`unavailable`,reasonMessage:null,supportedModels:void 0,recommendedModel:null,cta:null}].sort((e,t)=>e.value===`native`?-1:t.value===`native`?1:e.value.localeCompare(t.value))}function We({value:e,disabled:t=!1,runtimeOptions:n,defaultRuntime:r,onChange:a}){let o=e.trim()?N(e):``,s=Ue({runtimeOptions:n,currentRuntime:e}),c=s.find(e=>e.value===o)??null,l=c?.reasonMessage?.trim()||(c?.ready===!1?i(`agentsRuntimeUnavailableHelp`):``);return(0,W.jsxs)(`div`,{className:`space-y-2`,children:[(0,W.jsxs)(x,{value:o||r,onValueChange:e=>a(e===r?``:e),disabled:t,children:[(0,W.jsx)(v,{"aria-label":i(`agentsCardRuntimeLabel`),className:`rounded-xl`,children:(0,W.jsx)(_,{placeholder:i(`agentsRuntimeSelectPlaceholder`)})}),(0,W.jsx)(y,{className:`rounded-xl`,children:s.map(e=>(0,W.jsx)(b,{value:e.value,disabled:e.ready===!1&&e.value!==o,className:`rounded-lg`,children:e.label},e.value))})]}),l?(0,W.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:l}):null]})}function Ge({agent:e,pending:t,providerCatalog:n,runtimeOptions:r,defaultRuntime:i,onOpenChange:a,onSubmit:o}){return(0,W.jsx)(T,{open:e!==null,onOpenChange:a,children:e?(0,W.jsx)(Ke,{agent:e,pending:t,providerCatalog:n,runtimeOptions:r,defaultRuntime:i,onOpenChange:a,onSubmit:o},e.id):null})}function Ke(e){let{agent:t,pending:n,providerCatalog:r,runtimeOptions:a,defaultRuntime:o,onOpenChange:s,onSubmit:c}=e,[l,f]=(0,U.useState)(Be(t));return(0,W.jsxs)(D,{className:`flex max-h-[calc(100vh-2rem)] flex-col overflow-hidden border-none bg-popover p-0 sm:max-h-[760px] sm:max-w-xl`,children:[(0,W.jsx)(`div`,{className:`shrink-0 border-b border-border px-6 py-6`,children:(0,W.jsxs)(E,{className:`text-left`,children:[(0,W.jsx)(O,{children:i(`agentsEditDialogTitle`)}),(0,W.jsx)(w,{children:i(`agentsEditDialogDescription`)})]})}),(0,W.jsx)(`div`,{className:`min-h-0 flex-1 overflow-y-auto overscroll-contain px-6 py-6`,children:(0,W.jsxs)(`div`,{className:`space-y-4`,children:[(0,W.jsx)(te,{tone:`warning`,title:i(`agentsEditHomeReadonly`),description:i(`agentsEditHomeReadonlyHint`),children:(0,W.jsx)(`div`,{className:`break-all text-sm text-amber-950`,children:t.workspace??`-`})}),(0,W.jsxs)(`div`,{className:`grid gap-4 md:grid-cols-2`,children:[(0,W.jsx)(d,{value:l.displayName,onChange:e=>f(t=>({...t,displayName:e.target.value})),placeholder:i(`agentsFormNamePlaceholder`)}),(0,W.jsx)(He,{value:l.description,onChange:e=>f(t=>({...t,description:e.target.value})),placeholder:i(`agentsFormDescriptionPlaceholder`),rows:4,className:`md:col-span-2`}),(0,W.jsx)(d,{value:l.avatar,onChange:e=>f(t=>({...t,avatar:e.target.value})),placeholder:i(`agentsFormAvatarPlaceholder`)}),(0,W.jsx)(ee,{value:l.model,onChange:e=>f(t=>({...t,model:e})),providerCatalog:r,disabled:n,className:`md:col-span-2`}),(0,W.jsx)(We,{value:l.runtime,onChange:e=>f(t=>({...t,runtime:e})),runtimeOptions:a,defaultRuntime:o,disabled:n})]}),(0,W.jsx)(Re,{form:l,disabled:n,onChange:e=>f(t=>({...t,...e}))})]})}),(0,W.jsxs)(S,{className:`shrink-0 border-t border-border px-6 py-5`,children:[(0,W.jsx)(u,{type:`button`,variant:`ghost`,onClick:()=>s(!1),disabled:n,children:i(`cancel`)}),(0,W.jsxs)(u,{type:`button`,variant:`primary`,className:`rounded-2xl px-5`,onClick:()=>c(t.id,l),disabled:n,children:[(0,W.jsx)(H,{className:`mr-2 h-4 w-4`}),i(`agentsEditSaveAction`)]})]})]})}var qe=`请直接创建一个默认示例 Agent,不要问我问题。创建完成后,简单告诉我它能做什么。`;function Je(e){let t=e.trim();if(!t)return null;let n=Number(t);if(!Number.isFinite(n))throw Error(i(`agentsAdvancedInvalidNumberError`));return Math.trunc(n)}function Ye(e){return{displayName:e.displayName,description:e.description,avatar:e.avatar,model:e.model,...e.runtime.trim()?{runtime:e.runtime.trim()}:{runtime:``},contextTokens:Je(e.contextTokens)}}function Q(e){let{icon:t,label:n,disabled:r=!1,destructive:i=!1,onClick:o}=e;return(0,W.jsxs)(`button`,{type:`button`,className:a(`flex w-full items-center gap-2 rounded-lg px-3 py-2 text-left text-sm transition-colors disabled:cursor-not-allowed disabled:opacity-50`,i?`text-destructive hover:bg-destructive/10`:`text-foreground hover:bg-muted`),onClick:o,disabled:r,children:[(0,W.jsx)(t,{className:`h-4 w-4 shrink-0`}),(0,W.jsx)(`span`,{children:n})]})}function Xe(e){let{agent:t,runtimeOptions:n,defaultRuntimeLabel:r,updatePending:a,deletePending:o,onStartChat:s,onView:c,onEdit:l,onDelete:d}=e,f=t.runtime?.trim()||t.engine?.trim()||``,p=f?n.find(e=>e.value===N(f))?.label??R(f):r;return(0,W.jsx)(M,{className:`group overflow-hidden border border-border bg-card shadow-none transition-colors duration-200 hover:border-border/80`,children:(0,W.jsxs)(V,{className:`relative flex h-full flex-col gap-3 px-3.5 py-3.5`,children:[(0,W.jsxs)(`div`,{className:`flex items-start gap-2.5 pr-16`,children:[(0,W.jsx)(z,{agentId:t.id,displayName:t.displayName,avatarUrl:t.avatarUrl,className:`h-9 w-9 shrink-0`}),(0,W.jsxs)(`div`,{className:`min-w-0 flex-1 space-y-0.5`,children:[(0,W.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2`,children:[(0,W.jsx)(`div`,{className:`truncate text-sm font-semibold text-foreground`,children:t.displayName?.trim()||t.id}),t.builtIn?(0,W.jsxs)(ie,{tone:`warning`,className:`h-5 gap-1 border-amber-200 bg-amber-50 px-1.5 text-[10px] text-amber-700`,children:[(0,W.jsx)(se,{className:`h-3 w-3`}),i(`agentsCardBuiltInTag`)]}):null]}),(0,W.jsxs)(`div`,{className:`truncate text-xs text-muted-foreground`,children:[`@`,t.id]})]})]}),(0,W.jsxs)(`div`,{className:`absolute right-2.5 top-2.5 flex items-center gap-1 opacity-100 transition-opacity md:opacity-0 md:group-hover:opacity-100 md:group-focus-within:opacity-100`,children:[(0,W.jsx)(u,{type:`button`,variant:`ghost`,size:`icon`,className:`h-8 w-8 rounded-lg text-muted-foreground hover:text-foreground`,"aria-label":i(`agentsCardStartChat`),title:i(`agentsCardStartChat`),onClick:s,children:(0,W.jsx)(fe,{className:`h-4 w-4`})}),(0,W.jsxs)(be,{children:[(0,W.jsx)(Ce,{asChild:!0,children:(0,W.jsx)(u,{type:`button`,variant:`ghost`,size:`icon`,className:`h-8 w-8 rounded-lg text-muted-foreground hover:text-foreground`,"aria-label":i(`chatSessionMoreActions`),title:i(`chatSessionMoreActions`),children:(0,W.jsx)(ce,{className:`h-4 w-4`})})}),(0,W.jsxs)(Ee,{align:`end`,className:`w-44 p-1.5`,children:[(0,W.jsx)(Q,{icon:oe,label:i(`agentsViewDetailsAction`),onClick:c}),(0,W.jsx)(Q,{icon:H,label:i(`agentsEditAction`),onClick:l,disabled:a}),t.builtIn?null:(0,W.jsx)(Q,{icon:le,label:i(`agentsRemoveAction`),onClick:d,disabled:o,destructive:!0})]})]})]}),(0,W.jsx)(`p`,{className:`line-clamp-2 min-h-10 text-sm leading-5 text-muted-foreground`,children:t.description?.trim()||(t.builtIn?i(`agentsCardBuiltInSummary`):i(`agentsCardCustomSummary`))}),(0,W.jsxs)(`div`,{className:`mt-auto grid gap-2 border-t border-border/60 pt-2 text-xs text-muted-foreground`,children:[(0,W.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2`,children:[(0,W.jsx)(C,{className:`h-3.5 w-3.5 shrink-0 text-muted-foreground/60`}),(0,W.jsx)(`span`,{className:`truncate`,children:p})]}),(0,W.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2`,children:[(0,W.jsx)(de,{className:`h-3.5 w-3.5 shrink-0 text-muted-foreground/60`}),(0,W.jsx)(`span`,{className:`truncate`,children:t.workspace??`-`})]})]})]})})}function Ze(){let e=P(),t=ue(),n=B(),r=I(),a=A(),o=F(),s=ye(),c=ae(),[d,f]=(0,U.useState)(null),[h,g]=(0,U.useState)(null),_=(0,U.useMemo)(()=>t.data?.agents??[],[t.data?.agents]),v=(0,U.useMemo)(()=>[..._].sort((e,t)=>Number(!!t.builtIn)-Number(!!e.builtIn)||e.id.localeCompare(t.id)),[_]),y=(0,U.useMemo)(()=>Me({config:n.data,providersView:r.data,templatesView:a.data,onlyConfigured:!0}),[n.data,r.data,a.data]),b=(0,U.useMemo)(()=>we(o.data?.options??[]),[o.data?.options]),x=(0,U.useMemo)(()=>N(o.data?.defaultType??`native`),[o.data?.defaultType]),S=(0,U.useMemo)(()=>b.find(e=>e.value===x)?.label??R(x),[x,b]),C=n.data?.agents.defaults,w=e=>{f(e)},T=e=>{g(e)},E=async(e,t)=>{let n;try{n=Ye(t)}catch(e){m.error(e instanceof Error?e.message:i(`agentsAdvancedParseFailed`));return}await s.mutateAsync({agentId:e,data:n}),g(null)},D=t=>{e.chatSessionListManager.startAgentDraftChat(t.id,Oe(t,x))},O=()=>{e.chatSessionListManager.startAgentDraftChat(`main`,x,qe)};return(0,W.jsxs)(p,{className:`space-y-6`,children:[(0,W.jsx)(l,{headingLevel:1,title:i(`agentsHeroEyebrow`),description:i(`agentsHeroDescription`),actions:(0,W.jsxs)(u,{type:`button`,variant:`primary`,className:`h-9 shrink-0 rounded-xl px-4 text-sm font-semibold`,onClick:O,children:[(0,W.jsx)(k,{className:`mr-2 h-4 w-4`}),i(`agentsCreateButton`)]})}),(0,W.jsx)(`div`,{className:`grid gap-4 md:grid-cols-2 xl:grid-cols-3`,children:t.isLoading?(0,W.jsx)(M,{className:`md:col-span-2 xl:col-span-3 border-dashed border-border bg-card/70`,children:(0,W.jsx)(V,{className:`py-14 text-center text-sm text-muted-foreground`,children:i(`agentsLoading`)})}):v.length===0?(0,W.jsx)(M,{className:`md:col-span-2 xl:col-span-3 overflow-hidden border-dashed border-border bg-gradient-subtle`,children:(0,W.jsxs)(V,{className:`flex min-h-[240px] flex-col items-center justify-center px-6 py-14 text-center`,children:[(0,W.jsx)(`div`,{className:`mb-4 flex h-16 w-16 items-center justify-center rounded-full bg-card/80 shadow-[0_18px_44px_rgba(0,0,0,0.08)]`,children:(0,W.jsx)(j,{className:`h-8 w-8 text-warning`})}),(0,W.jsx)(`div`,{className:`text-lg font-semibold text-foreground`,children:i(`agentsEmpty`)}),(0,W.jsx)(`p`,{className:`mt-2 max-w-md text-sm leading-6 text-muted-foreground`,children:i(`agentsEmptyDescription`)}),(0,W.jsxs)(u,{type:`button`,variant:`primary`,className:`mt-5 rounded-2xl px-5`,onClick:O,children:[(0,W.jsx)(k,{className:`mr-2 h-4 w-4`}),i(`agentsCreateButton`)]})]})}):v.map(e=>(0,W.jsx)(Xe,{agent:e,runtimeOptions:b,defaultRuntimeLabel:S,updatePending:s.isPending,deletePending:c.isPending,onStartChat:()=>D(e),onView:()=>w(e),onEdit:()=>T(e),onDelete:()=>c.mutate({agentId:e.id})},e.id))}),(0,W.jsx)(Pe,{agent:d,defaults:C,runtimeOptions:b,defaultRuntime:x,defaultRuntimeLabel:S,onOpenChange:e=>{e||f(null)},onEdit:e=>{f(null),g(e)}}),(0,W.jsx)(Ge,{agent:h,pending:s.isPending,providerCatalog:y,runtimeOptions:b,defaultRuntime:x,onOpenChange:e=>{!e&&!s.isPending&&g(null)},onSubmit:E})]})}var $=`max-w-[min(1180px,100%)]`;function Qe(e){let{routeSessionKey:t,syncRouteSessionSelection:n}=e;(0,U.useLayoutEffect)(()=>{n(t)},[t,n])}function $e({view:e,confirmDialog:t}){let{isMobile:n}=me();return(0,W.jsxs)(`div`,{className:`h-full flex`,children:[n?null:(0,W.jsx)(ke,{}),e===`chat`?n?(0,W.jsx)(ge,{}):(0,W.jsx)(Se,{}):(0,W.jsx)(`section`,{className:`flex-1 min-h-0 overflow-hidden bg-background`,children:e===`inbox`?(0,W.jsx)(`div`,{className:`mx-auto flex h-full min-h-0 w-full flex-col py-4 sm:px-6 sm:py-5 ${$}`,children:(0,W.jsx)(ve,{})}):e===`cron`?(0,W.jsx)(`div`,{className:`h-full overflow-auto custom-scrollbar`,children:(0,W.jsx)(`div`,{className:`mx-auto w-full px-4 py-4 sm:px-6 sm:py-5 ${$}`,children:(0,W.jsx)(xe,{})})}):e===`agents`?(0,W.jsx)(`div`,{className:`h-full overflow-auto custom-scrollbar`,children:(0,W.jsx)(`div`,{className:`mx-auto w-full px-4 py-4 sm:px-6 sm:py-5 ${$}`,children:(0,W.jsx)(Ze,{})})}):(0,W.jsx)(`div`,{className:`h-full overflow-hidden`,children:(0,W.jsx)(`div`,{className:`mx-auto flex h-full min-h-0 w-full flex-col px-4 py-4 sm:px-6 sm:py-5 ${$}`,children:(0,W.jsx)(Ae,{forcedType:`skills`})})})}),t]})}function et(e){let t=P(),n=B(),r=I(),i=A(),a=Te({limit:200}),o=F(),s=e.sessionKey?.trim()||`draft-session`,c=_e({sessionId:s});(0,U.useEffect)(()=>{t.chatQueryManager.syncSnapshot({configQuery:n,providersQuery:r,providerTemplatesQuery:i,sessionsQuery:a,sessionTypesQuery:o,sessionSkillsSessionId:s,sessionSkillsQuery:c})},[n,t.chatQueryManager,r,s,c,a,o,i])}function tt(){let e=P();(0,U.useEffect)(()=>f.eventBus.on(t.uiShowContent,t=>{e.chatThreadManager.handleUiShowContentEvent(t)}),[e])}function nt(){let{sessionId:e}=s(),t=(0,U.useMemo)(()=>De(e),[e]);return{routeSessionKey:t,sessionKey:t??void 0}}function rt(){let e=P(),{confirm:t,ConfirmDialog:n}=ne(),r=c(),i=o();return(0,U.useEffect)(()=>{e.chatUiManager.syncState({pathname:r.pathname}),e.chatUiManager.bindActions({navigate:i,confirm:t})},[t,r.pathname,i,e]),(0,W.jsx)(n,{})}function it({view:e}){let t=L();return(0,W.jsx)(je,{presenter:(0,U.useMemo)(()=>new he(t),[t]),children:(0,W.jsx)(at,{view:e})})}function at({view:e}){let t=L(),n=P(),r=rt(),{routeSessionKey:i,sessionKey:a}=nt();return(0,U.useEffect)(()=>(t.chatCompletionNotificationManager.syncActiveSession(a??null),()=>{t.chatCompletionNotificationManager.syncActiveSession(null)}),[t.chatCompletionNotificationManager,a]),et({sessionKey:a??null}),Qe({routeSessionKey:i,syncRouteSessionSelection:n.chatSessionListManager.syncRouteSessionSelection}),tt(),(0,W.jsx)($e,{view:e,confirmDialog:r})}function ot({view:e}){return(0,W.jsx)(it,{view:e})}export{ot as ChatPage};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{i as e}from"./chunk-DseTPa7n.js";import{M as t,P as n,i as r,k as i}from"./react-Bk2ydNTe.js";import{n as a}from"./search-D4X5DNMe.js";var o=e(n(),1),s=t(),c=`min-w-0 overflow-hidden bg-card/70 text-card-foreground md:h-[calc(100vh-180px)] md:max-h-[860px]`,l=`min-h-0 overflow-hidden rounded-2xl bg-muted/30 ring-1 ring-border/45`,u=640;function d({className:e,children:t,compactView:n,onMobileBack:c,mobileListLabel:d,...f}){let p=(0,o.useRef)(null),[m,h]=(0,o.useState)(!1),[g,_,...v]=o.Children.toArray(t);(0,o.useEffect)(()=>{let e=p.current;if(!e||!n||typeof ResizeObserver>`u`)return;let t=()=>h(e.clientWidth>0&&e.clientWidth<u),r=new ResizeObserver(t);return r.observe(e),t(),()=>r.disconnect()},[n]);let y=!!(m&&n&&g&&_);return(0,s.jsx)(`div`,{ref:p,className:i(`min-h-0 md:flex-1`,e),...f,children:y?(0,s.jsxs)(`div`,{className:`space-y-3`,children:[n===`detail`?(0,s.jsxs)(s.Fragment,{children:[(0,s.jsxs)(`button`,{type:`button`,onClick:c,className:`inline-flex items-center gap-2 rounded-lg px-2 py-1.5 text-sm font-medium text-muted-foreground transition-colors hover:bg-muted hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring/40`,children:[(0,s.jsx)(a,{className:`h-4 w-4`}),(0,s.jsx)(`span`,{children:d??r(`backToMain`)})]}),(0,s.jsx)(`div`,{className:l,children:_})]}):(0,s.jsx)(`div`,{className:l,children:g}),v]}):(0,s.jsx)(`div`,{className:i(l,`grid grid-cols-1 md:grid-cols-[minmax(240px,30%)_minmax(0,1fr)]`),children:t})})}function f({className:e,...t}){return(0,s.jsx)(`section`,{className:i(c,`flex flex-col md:border-r md:border-border/55`,e),...t})}function p({className:e,...t}){return(0,s.jsx)(`section`,{className:i(c,`flex flex-col`,e),...t})}function m({className:e,...t}){return(0,s.jsx)(`section`,{className:i(c,`flex items-center justify-center px-6 py-12 text-center`,e),...t})}function h({className:e,...t}){return(0,s.jsx)(`div`,{className:i(`shrink-0 border-b border-border/70`,e),...t})}function g({className:e,scrollOnDesktop:t=!0,...n}){return(0,s.jsx)(`div`,{className:i(`min-h-0 flex-1`,t&&`overflow-visible md:overflow-y-auto md:overscroll-contain`,e),...n})}function _({className:e,...t}){return(0,s.jsx)(`div`,{className:i(`shrink-0 border-t border-border/70 px-4 py-2.5`,e),...t})}function v({active:e=!1,className:t,type:n=`button`,...r}){return(0,s.jsx)(`button`,{type:n,className:i(`w-full rounded-xl p-2.5 text-left transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring/40`,e?`bg-background/95 text-foreground shadow-sm`:`bg-transparent text-muted-foreground hover:bg-background/65 hover:text-foreground`,t),...r})}function y({icon:e,title:t,description:n,className:r,...a}){return(0,s.jsxs)(`div`,{className:i(`flex min-h-[220px] flex-col items-center justify-center rounded-xl bg-background/55 px-4 py-10 text-center`,r),...a,children:[(0,s.jsx)(`div`,{className:`mb-3 flex h-10 w-10 items-center justify-center rounded-lg bg-card`,children:(0,s.jsx)(e,{className:`h-5 w-5 text-muted-foreground/45`})}),(0,s.jsx)(`p`,{className:`text-sm font-medium text-foreground`,children:t}),n?(0,s.jsx)(`p`,{className:`mt-2 text-xs text-muted-foreground`,children:n}):null]})}export{d as a,h as c,y as i,f as l,p as n,g as o,m as r,_ as s,v as t};
|
|
@@ -1,5 +0,0 @@
|
|
|
1
|
-
import{i as e}from"./chunk-DseTPa7n.js";import{M as t,P as n,i as r,k as i}from"./react-Bk2ydNTe.js";import{Xt as a}from"./api-Glw2OGXK.js";import{b as o,c as s,f as c,g as l,h as u,l as d,p as f,u as ee,v as te,x as p,y as ne}from"./dist-dv_SUR54.js";import{D as re,E as ie,O as ae,T as oe}from"./select-CDv0g2Pj.js";import{t as m}from"./dist-CtLyEJeO.js";import{t as se}from"./x-PTXYTEwz.js";var h=e(n(),1),g=t(),_=`Dialog`,[v,ce]=ne(_),[le,y]=v(_),b=e=>{let{__scopeDialog:t,children:n,open:r,defaultOpen:i,onOpenChange:a,modal:o=!0}=e,s=h.useRef(null),c=h.useRef(null),[d,f]=u({prop:r,defaultProp:i??!1,onChange:a,caller:_});return(0,g.jsx)(le,{scope:t,triggerRef:s,contentRef:c,contentId:l(),titleId:l(),descriptionId:l(),open:d,onOpenChange:f,onOpenToggle:h.useCallback(()=>f(e=>!e),[f]),modal:o,children:n})};b.displayName=_;var x=`DialogTrigger`,S=h.forwardRef((e,t)=>{let{__scopeDialog:n,...r}=e,i=y(x,n),a=o(t,i.triggerRef);return(0,g.jsx)(c.button,{type:`button`,"aria-haspopup":`dialog`,"aria-expanded":i.open,"aria-controls":i.contentId,"data-state":L(i.open),...r,ref:a,onClick:p(e.onClick,i.onOpenToggle)})});S.displayName=x;var C=`DialogPortal`,[ue,w]=v(C,{forceMount:void 0}),T=e=>{let{__scopeDialog:t,forceMount:n,children:r,container:i}=e,a=y(C,t);return(0,g.jsx)(ue,{scope:t,forceMount:n,children:h.Children.map(r,e=>(0,g.jsx)(m,{present:n||a.open,children:(0,g.jsx)(d,{asChild:!0,container:i,children:e})}))})};T.displayName=C;var E=`DialogOverlay`,D=h.forwardRef((e,t)=>{let n=w(E,e.__scopeDialog),{forceMount:r=n.forceMount,...i}=e,a=y(E,e.__scopeDialog);return a.modal?(0,g.jsx)(m,{present:r||a.open,children:(0,g.jsx)(fe,{...i,ref:t})}):null});D.displayName=E;var de=f(`DialogOverlay.RemoveScroll`),fe=h.forwardRef((e,t)=>{let{__scopeDialog:n,...r}=e,i=y(E,n);return(0,g.jsx)(ie,{as:de,allowPinchZoom:!0,shards:[i.contentRef],children:(0,g.jsx)(c.div,{"data-state":L(i.open),...r,ref:t,style:{pointerEvents:`auto`,...r.style}})})}),O=`DialogContent`,k=h.forwardRef((e,t)=>{let n=w(O,e.__scopeDialog),{forceMount:r=n.forceMount,...i}=e,a=y(O,e.__scopeDialog);return(0,g.jsx)(m,{present:r||a.open,children:a.modal?(0,g.jsx)(pe,{...i,ref:t}):(0,g.jsx)(me,{...i,ref:t})})});k.displayName=O;var pe=h.forwardRef((e,t)=>{let n=y(O,e.__scopeDialog),r=h.useRef(null),i=o(t,n.contentRef,r);return h.useEffect(()=>{let e=r.current;if(e)return oe(e)},[]),(0,g.jsx)(A,{...e,ref:i,trapFocus:n.open,disableOutsidePointerEvents:!0,onCloseAutoFocus:p(e.onCloseAutoFocus,e=>{e.preventDefault(),n.triggerRef.current?.focus()}),onPointerDownOutside:p(e.onPointerDownOutside,e=>{let t=e.detail.originalEvent,n=t.button===0&&t.ctrlKey===!0;(t.button===2||n)&&e.preventDefault()}),onFocusOutside:p(e.onFocusOutside,e=>e.preventDefault())})}),me=h.forwardRef((e,t)=>{let n=y(O,e.__scopeDialog),r=h.useRef(!1),i=h.useRef(!1);return(0,g.jsx)(A,{...e,ref:t,trapFocus:!1,disableOutsidePointerEvents:!1,onCloseAutoFocus:t=>{e.onCloseAutoFocus?.(t),t.defaultPrevented||(r.current||n.triggerRef.current?.focus(),t.preventDefault()),r.current=!1,i.current=!1},onInteractOutside:t=>{e.onInteractOutside?.(t),t.defaultPrevented||(r.current=!0,t.detail.originalEvent.type===`pointerdown`&&(i.current=!0));let a=t.target;n.triggerRef.current?.contains(a)&&t.preventDefault(),t.detail.originalEvent.type===`focusin`&&i.current&&t.preventDefault()}})}),A=h.forwardRef((e,t)=>{let{__scopeDialog:n,trapFocus:r,onOpenAutoFocus:i,onCloseAutoFocus:a,...s}=e,c=y(O,n),l=h.useRef(null),u=o(t,l);return re(),(0,g.jsxs)(g.Fragment,{children:[(0,g.jsx)(ae,{asChild:!0,loop:!0,trapped:r,onMountAutoFocus:i,onUnmountAutoFocus:a,children:(0,g.jsx)(ee,{role:`dialog`,id:c.contentId,"aria-describedby":c.descriptionId,"aria-labelledby":c.titleId,"data-state":L(c.open),...s,ref:u,onDismiss:()=>c.onOpenChange(!1)})}),(0,g.jsxs)(g.Fragment,{children:[(0,g.jsx)(ge,{titleId:c.titleId}),(0,g.jsx)(ve,{contentRef:l,descriptionId:c.descriptionId})]})]})}),j=`DialogTitle`,M=h.forwardRef((e,t)=>{let{__scopeDialog:n,...r}=e,i=y(j,n);return(0,g.jsx)(c.h2,{id:i.titleId,...r,ref:t})});M.displayName=j;var N=`DialogDescription`,P=h.forwardRef((e,t)=>{let{__scopeDialog:n,...r}=e,i=y(N,n);return(0,g.jsx)(c.p,{id:i.descriptionId,...r,ref:t})});P.displayName=N;var F=`DialogClose`,I=h.forwardRef((e,t)=>{let{__scopeDialog:n,...r}=e,i=y(F,n);return(0,g.jsx)(c.button,{type:`button`,...r,ref:t,onClick:p(e.onClick,()=>i.onOpenChange(!1))})});I.displayName=F;function L(e){return e?`open`:`closed`}var R=`DialogTitleWarning`,[he,z]=te(R,{contentName:O,titleName:j,docsSlug:`dialog`}),ge=({titleId:e})=>{let t=z(R),n=`\`${t.contentName}\` requires a \`${t.titleName}\` for the component to be accessible for screen reader users.
|
|
2
|
-
|
|
3
|
-
If you want to hide the \`${t.titleName}\`, you can wrap it with our VisuallyHidden component.
|
|
4
|
-
|
|
5
|
-
For more information, see https://radix-ui.com/primitives/docs/components/${t.docsSlug}`;return h.useEffect(()=>{e&&(document.getElementById(e)||console.error(n))},[n,e]),null},_e=`DialogDescriptionWarning`,ve=({contentRef:e,descriptionId:t})=>{let n=`Warning: Missing \`Description\` or \`aria-describedby={undefined}\` for {${z(_e).contentName}}.`;return h.useEffect(()=>{let r=e.current?.getAttribute(`aria-describedby`);t&&r&&(document.getElementById(t)||console.warn(n))},[n,e,t]),null},B=b,ye=S,V=T,H=D,U=k,W=M,G=P,K=I,be=s(`CircleAlert`,[[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}],[`line`,{x1:`12`,x2:`12`,y1:`8`,y2:`12`,key:`1pkeuh`}],[`line`,{x1:`12`,x2:`12.01`,y1:`16`,y2:`16`,key:`4dfq90`}]]),xe=s(`Sparkles`,[[`path`,{d:`M9.937 15.5A2 2 0 0 0 8.5 14.063l-6.135-1.582a.5.5 0 0 1 0-.962L8.5 9.936A2 2 0 0 0 9.937 8.5l1.582-6.135a.5.5 0 0 1 .963 0L14.063 8.5A2 2 0 0 0 15.5 9.937l6.135 1.581a.5.5 0 0 1 0 .964L15.5 14.063a2 2 0 0 0-1.437 1.437l-1.582 6.135a.5.5 0 0 1-.963 0z`,key:`4pj2yx`}],[`path`,{d:`M20 3v4`,key:`1olli1`}],[`path`,{d:`M22 5h-4`,key:`1gvqau`}],[`path`,{d:`M4 17v2`,key:`vumght`}],[`path`,{d:`M5 18H3`,key:`zchphs`}]]),q=B,Se=V,J=h.forwardRef(({className:e,...t},n)=>(0,g.jsx)(H,{ref:n,className:i(`fixed inset-0 z-[var(--z-modal-backdrop,10000)] bg-black/40 backdrop-blur-sm data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0`,e),...t}));J.displayName=H.displayName;var Y=h.forwardRef(({className:e,children:t,...n},r)=>(0,g.jsxs)(Se,{children:[(0,g.jsx)(J,{}),(0,g.jsxs)(U,{ref:r,className:i(`fixed left-[50%] top-[50%] z-[var(--z-modal,10050)] grid w-full max-w-lg translate-x-[-50%] translate-y-[-50%] gap-4 rounded-2xl border border-border bg-popover p-6 text-popover-foreground shadow-xl duration-base data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[state=closed]:slide-out-to-left-1/2 data-[state=closed]:slide-out-to-top-[48%] data-[state=open]:slide-in-from-left-1/2 data-[state=open]:slide-in-from-top-[48%]`,e),...n,children:[t,(0,g.jsxs)(K,{className:`absolute right-4 top-4 rounded-lg p-1 opacity-70 transition-all duration-fast hover:bg-[var(--interaction-hover)] hover:text-accent-foreground hover:opacity-100 focus:outline-none focus-visible:ring-1 focus-visible:ring-border disabled:pointer-events-none`,children:[(0,g.jsx)(se,{className:`h-4 w-4 text-muted-foreground`}),(0,g.jsx)(`span`,{className:`sr-only`,children:`Close`})]})]})]}));Y.displayName=U.displayName;var X=({className:e,...t})=>(0,g.jsx)(`div`,{className:i(`flex flex-col space-y-2 text-center sm:text-left`,e),...t});X.displayName=`DialogHeader`;var Z=({className:e,...t})=>(0,g.jsx)(`div`,{className:i(`flex flex-col-reverse sm:flex-row sm:justify-end sm:gap-3`,e),...t});Z.displayName=`DialogFooter`;var Q=h.forwardRef(({className:e,...t},n)=>(0,g.jsx)(W,{ref:n,className:i(`text-lg font-semibold leading-tight tracking-tight text-foreground`,e),...t}));Q.displayName=W.displayName;var $=h.forwardRef(({className:e,...t},n)=>(0,g.jsx)(G,{ref:n,className:i(`text-sm text-muted-foreground leading-relaxed`,e),...t}));$.displayName=G.displayName;var Ce=({open:e,onOpenChange:t,title:n,description:i,confirmLabel:o=r(`confirm`),cancelLabel:s=r(`cancel`),variant:c=`default`,onConfirm:l,onCancel:u})=>(0,g.jsx)(q,{open:e,onOpenChange:t,children:(0,g.jsxs)(Y,{className:`[&>:last-child]:hidden`,onCloseAutoFocus:e=>e.preventDefault(),children:[(0,g.jsxs)(X,{children:[(0,g.jsx)(Q,{children:n}),i?(0,g.jsx)($,{children:i}):null]}),(0,g.jsxs)(Z,{className:`gap-2 sm:gap-0`,children:[(0,g.jsx)(a,{type:`button`,variant:`outline`,onClick:()=>{u(),t(!1)},children:s}),(0,g.jsx)(a,{type:`button`,variant:c===`destructive`?`destructive`:`default`,onClick:()=>{l(),t(!1)},children:o})]})]})});export{ye as _,Z as a,xe as c,U as d,G as f,W as g,B as h,$ as i,be as l,V as m,q as n,X as o,H as p,Y as r,Q as s,Ce as t,K as u};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{t as e}from"./doc-browser-DlOOhBxI.js";export{e as DocBrowser};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{M as e,k as t}from"./react-Bk2ydNTe.js";var n=e();function r({align:e=`end`,className:r,...i}){return(0,n.jsx)(`div`,{className:t(`flex flex-wrap items-center gap-2`,e===`start`&&`justify-start`,e===`end`&&`justify-end`,e===`between`&&`justify-between`,r),...i})}export{r as t};
|