@nextclaw/ui 0.14.0 → 0.14.1-beta.0
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 +23 -0
- package/dist/assets/{api-B50yVdT8.js → api-C6EDHBDR.js} +1 -1
- package/dist/assets/channels-list-page-DKj6m1Hc.js +8 -0
- package/dist/assets/chat-page-BXngLJY6.js +105 -0
- package/dist/assets/config-split-page-CjlmJy8X.js +1 -0
- package/dist/assets/{confirm-dialog-DRSelLdI.js → confirm-dialog-B39X0pYp.js} +1 -1
- package/dist/assets/desktop-update-config-DfUQ8nly.js +1 -0
- package/dist/assets/{dist-NZRV-BxD.js → dist-BIYV2-Ia.js} +1 -1
- package/dist/assets/{dist-D19wiQwB.js → dist-CmMro3nV.js} +1 -1
- package/dist/assets/doc-browser-B6Wc_TIY.js +1 -0
- package/dist/assets/doc-browser-CDtUtcim.js +1 -0
- package/dist/assets/{doc-browser-context-C8KPbj-p.js → doc-browser-context-DZbC9zVB.js} +1 -1
- package/dist/assets/{ellipsis-BYy8TP0A.js → ellipsis-DDpgTzgx.js} +1 -1
- package/dist/assets/{external-link-528k6MDD.js → external-link-D2cBOCqn.js} +1 -1
- package/dist/assets/index-DTb_XVIH.js +103 -0
- package/dist/assets/index-ayiPYhf1.css +1 -0
- package/dist/assets/mcp-marketplace-page-DZ9H0v05.js +1 -0
- package/dist/assets/mcp-marketplace-page-cnVWf7QQ.js +40 -0
- package/dist/assets/model-config-page-Bcb35AVv.js +1 -0
- package/dist/assets/plus-CYE1onU2.js +1 -0
- package/dist/assets/provider-scoped-model-input-kdoNp4HG.js +1 -0
- package/dist/assets/providers-config-page-CQSibSwO.js +1 -0
- package/dist/assets/{react-Dsotw5vM.js → react-DYQXXGbH.js} +1 -1
- package/dist/assets/remote-BlJDbXOI.js +1 -0
- package/dist/assets/rotate-cw-BWbvFDAX.js +1 -0
- package/dist/assets/runtime-config-page-Tn2yLQ0c.js +1 -0
- package/dist/assets/{save-CHDnDTok.js → save-BNVTgBVn.js} +1 -1
- package/dist/assets/search-CKCzwLId.js +1 -0
- package/dist/assets/search-config-page-DG5Q2hF1.js +1 -0
- package/dist/assets/{secrets-config-page-95yaH1fa.js → secrets-config-page-BXn5Uuwp.js} +2 -2
- package/dist/assets/select-CIRwTNP4.js +41 -0
- package/dist/assets/{tag-chip-Cr8GwpRE.js → tag-chip-DKhVFtTE.js} +1 -1
- package/dist/assets/{use-config-TzwzTgg0.js → use-config-DgKM9VIU.js} +1 -1
- package/dist/assets/x-Cm3JjYut.js +1 -0
- package/dist/index.html +14 -27
- package/package.json +9 -9
- package/src/app/presenters/app.presenter.ts +2 -0
- package/src/features/account/components/account-panel.tsx +2 -2
- package/src/features/chat/components/conversation/chat-conversation-header-section.tsx +1 -0
- package/src/features/chat/features/input/components/chat-input-bar.container.tsx +39 -80
- package/src/features/chat/features/input/hooks/use-chat-input-bar-query-state.ts +118 -0
- package/src/features/chat/features/input/utils/__tests__/chat-input-bar.utils.test.ts +2 -17
- package/src/features/chat/features/input/utils/chat-input-bar.utils.ts +1 -24
- package/src/features/chat/features/input/utils/chat-input-toolbar.utils.ts +0 -27
- package/src/features/chat/features/message/components/__tests__/chat-inline-panel-app-card.test.tsx +89 -0
- package/src/features/chat/features/message/components/__tests__/chat-message-list.container.test.tsx +9 -1
- package/src/features/chat/features/message/components/chat-inline-panel-app-card.tsx +115 -0
- package/src/features/chat/features/message/components/chat-message-list.container.tsx +4 -0
- package/src/features/chat/features/message/utils/__tests__/chat-message-show-content-tool-card.utils.test.ts +119 -1
- package/src/features/chat/features/message/utils/chat-inline-panel-app-card.utils.ts +51 -0
- package/src/features/chat/features/message/utils/chat-message-show-content-tool-card.utils.ts +28 -5
- package/src/features/chat/features/message/utils/chat-message-tool-card.utils.ts +4 -0
- package/src/features/chat/features/ncp/hooks/__tests__/use-ui-show-content-event.test.tsx +1 -0
- package/src/features/chat/features/ncp/utils/ncp-chat-query-derived.utils.ts +11 -3
- package/src/features/chat/features/session/components/session-header/__tests__/chat-session-header-actions.test.tsx +27 -0
- package/src/features/chat/features/session/components/session-header/chat-session-header-actions.tsx +19 -1
- package/src/features/chat/features/session/components/session-header/chat-session-metadata-dialog.tsx +46 -0
- package/src/features/chat/features/session/hooks/__tests__/use-selected-session-context-window-indicator.test.tsx +63 -0
- package/src/features/chat/features/session/hooks/use-selected-session-context-window-indicator.ts +7 -10
- package/src/features/chat/features/session/utils/__tests__/ncp-session-adapter.utils.test.ts +8 -0
- package/src/features/chat/features/session/utils/ncp-session-adapter.utils.ts +2 -0
- package/src/features/chat/features/session-type/hooks/use-chat-session-type-state.ts +1 -0
- package/src/features/chat/features/session-type/utils/chat-session-type.utils.ts +4 -0
- package/src/features/chat/index.ts +1 -0
- package/src/features/chat/managers/__tests__/chat-input.manager.test.ts +28 -0
- package/src/features/chat/managers/__tests__/chat-run-snapshot.manager.test.ts +129 -0
- package/src/features/chat/managers/__tests__/chat-run.manager.test.ts +34 -0
- package/src/features/chat/managers/__tests__/chat-session-preference-sync.manager.test.ts +143 -1
- package/src/features/chat/managers/__tests__/chat-thread.manager.test.ts +30 -0
- package/src/features/chat/managers/__tests__/recent-selection.manager.test.ts +37 -14
- package/src/features/chat/managers/chat-draft-intent.manager.ts +46 -0
- package/src/features/chat/managers/chat-input.manager.ts +13 -13
- package/src/features/chat/managers/chat-run.manager.ts +3 -0
- package/src/features/chat/managers/chat-session-preference-sync.manager.ts +19 -2
- package/src/features/chat/managers/chat-thread.manager.ts +4 -0
- package/src/features/chat/managers/chat-ui.manager.ts +2 -6
- package/src/features/chat/managers/recent-selection.manager.ts +21 -67
- package/src/features/chat/pages/__tests__/ncp-chat-page.test.ts +47 -1
- package/src/features/chat/pages/ncp-chat-page.tsx +18 -0
- package/src/features/chat/stores/chat-input.store.ts +7 -1
- package/src/features/chat/stores/recent-selection.store.ts +85 -0
- package/src/features/chat/types/chat-input-bar.types.ts +0 -1
- package/src/features/panel-apps/components/__tests__/panel-apps-list.test.tsx +137 -0
- package/src/features/panel-apps/components/panel-apps-list.tsx +119 -5
- package/src/features/panel-apps/index.ts +2 -0
- package/src/features/panel-apps/utils/panel-app-entry-match.utils.ts +17 -0
- package/src/shared/lib/api/chat-session-type.types.ts +7 -0
- package/src/shared/lib/api/ncp-session.types.ts +1 -0
- package/src/shared/lib/api/types.ts +3 -0
- package/src/shared/lib/i18n/locales/en-US/chat.json +4 -0
- package/src/shared/lib/i18n/locales/en-US/doc-browser.json +10 -0
- package/src/shared/lib/i18n/locales/zh-CN/chat.json +4 -0
- package/src/shared/lib/i18n/locales/zh-CN/doc-browser.json +10 -0
- package/dist/assets/app-presenter-provider-BI-ewLbO.js +0 -3
- package/dist/assets/arrow-left-BOCJyLbQ.js +0 -1
- package/dist/assets/book-open-Bd2Xbrrc.js +0 -1
- package/dist/assets/channels-list-page-moJkpxtU.js +0 -8
- package/dist/assets/chat-page-CO27cl4v.js +0 -105
- package/dist/assets/config-split-page-CsQ2rIdq.js +0 -1
- package/dist/assets/desktop-update-config-qa-SynOc.js +0 -1
- package/dist/assets/doc-browser-2ddUJCA0.js +0 -1
- package/dist/assets/doc-browser-BjHUczQb.js +0 -1
- package/dist/assets/es2015-BUIIKCNh.js +0 -41
- package/dist/assets/host-capabilities-9bB_998Z.js +0 -1
- package/dist/assets/index-CMNrRhnG.js +0 -101
- package/dist/assets/index-UTmTW1eU.css +0 -1
- package/dist/assets/key-round-D3vD9dj7.js +0 -1
- package/dist/assets/loader-circle-DV9TSRns.js +0 -1
- package/dist/assets/mcp-marketplace-page-CS5Lh3oA.js +0 -1
- package/dist/assets/mcp-marketplace-page-DEOMcWb0.js +0 -40
- package/dist/assets/model-config-page-BSc4o7pb.js +0 -1
- package/dist/assets/notice-card-qqlbsOoR.js +0 -1
- package/dist/assets/plus-Bf9qhPDO.js +0 -1
- package/dist/assets/popover-BnmPOXe3.js +0 -1
- package/dist/assets/provider-scoped-model-input-Ca56s475.js +0 -1
- package/dist/assets/providers-config-page-D8Kf4U3u.js +0 -1
- package/dist/assets/refresh-cw-Bmx4wc9P.js +0 -1
- package/dist/assets/remote-DNMEy_c4.js +0 -1
- package/dist/assets/rotate-cw-CL0sVBel.js +0 -1
- package/dist/assets/runtime-config-page-CUFtKr0U.js +0 -1
- package/dist/assets/search-D7L-TCH-.js +0 -1
- package/dist/assets/search-config-page-CA3RVAef.js +0 -1
- package/dist/assets/status-dot-Dm4h-bjn.js +0 -1
- package/dist/assets/tabs-CJvw5Lqp.js +0 -1
- package/dist/assets/tooltip-Bxzi6aDL.js +0 -1
- package/dist/assets/trash-2-CSfX-BvU.js +0 -1
- package/dist/assets/x-fkIWvi07.js +0 -1
- package/src/features/chat/features/input/hooks/__tests__/use-chat-input-bar-controller.test.tsx +0 -152
- package/src/features/chat/features/input/hooks/use-chat-input-bar-controller.ts +0 -142
- /package/dist/assets/{config-hints-Cl2XAhzV.js → config-hints-CTqBnCDp.js} +0 -0
package/src/features/chat/features/input/hooks/__tests__/use-chat-input-bar-controller.test.tsx
DELETED
|
@@ -1,152 +0,0 @@
|
|
|
1
|
-
import type { KeyboardEvent as ReactKeyboardEvent } from 'react';
|
|
2
|
-
import { renderHook, act } from '@testing-library/react';
|
|
3
|
-
import { useChatInputBarController } from '@/features/chat/features/input/hooks/use-chat-input-bar-controller';
|
|
4
|
-
|
|
5
|
-
function createKeyEvent(
|
|
6
|
-
key: string,
|
|
7
|
-
overrides?: Partial<ReactKeyboardEvent<HTMLTextAreaElement>>
|
|
8
|
-
): ReactKeyboardEvent<HTMLTextAreaElement> {
|
|
9
|
-
return {
|
|
10
|
-
key,
|
|
11
|
-
code: key === ' ' ? 'Space' : key,
|
|
12
|
-
shiftKey: false,
|
|
13
|
-
nativeEvent: {
|
|
14
|
-
isComposing: false
|
|
15
|
-
},
|
|
16
|
-
preventDefault: vi.fn(),
|
|
17
|
-
...overrides
|
|
18
|
-
} as unknown as ReactKeyboardEvent<HTMLTextAreaElement>;
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
describe('useChatInputBarController', () => {
|
|
22
|
-
it('cycles slash items with arrow keys and selects the active item on enter', () => {
|
|
23
|
-
const onSelectSlashItem = vi.fn();
|
|
24
|
-
const { result } = renderHook(() =>
|
|
25
|
-
useChatInputBarController({
|
|
26
|
-
isSlashMode: true,
|
|
27
|
-
slashItems: [
|
|
28
|
-
{ key: 'one', title: 'One', subtitle: 'Skill', description: '', detailLines: [] },
|
|
29
|
-
{ key: 'two', title: 'Two', subtitle: 'Skill', description: '', detailLines: [] }
|
|
30
|
-
],
|
|
31
|
-
isSlashLoading: false,
|
|
32
|
-
onSelectSlashItem,
|
|
33
|
-
onSend: vi.fn(),
|
|
34
|
-
onStop: vi.fn(),
|
|
35
|
-
isSending: false,
|
|
36
|
-
canStopGeneration: false
|
|
37
|
-
})
|
|
38
|
-
);
|
|
39
|
-
|
|
40
|
-
act(() => {
|
|
41
|
-
result.current.onTextareaKeyDown(createKeyEvent('ArrowDown'));
|
|
42
|
-
});
|
|
43
|
-
expect(result.current.activeSlashIndex).toBe(1);
|
|
44
|
-
|
|
45
|
-
act(() => {
|
|
46
|
-
result.current.onTextareaKeyDown(createKeyEvent('Enter'));
|
|
47
|
-
});
|
|
48
|
-
expect(onSelectSlashItem).toHaveBeenCalledWith(
|
|
49
|
-
expect.objectContaining({
|
|
50
|
-
key: 'two'
|
|
51
|
-
})
|
|
52
|
-
);
|
|
53
|
-
});
|
|
54
|
-
|
|
55
|
-
it('dismisses the slash panel on space and triggers stop on escape outside slash mode', () => {
|
|
56
|
-
const onStop = vi.fn();
|
|
57
|
-
const { result, rerender } = renderHook(
|
|
58
|
-
(props: {
|
|
59
|
-
isSlashMode: boolean;
|
|
60
|
-
isSending: boolean;
|
|
61
|
-
canStopGeneration: boolean;
|
|
62
|
-
}) =>
|
|
63
|
-
useChatInputBarController({
|
|
64
|
-
isSlashMode: props.isSlashMode,
|
|
65
|
-
slashItems: [{ key: 'one', title: 'One', subtitle: 'Skill', description: '', detailLines: [] }],
|
|
66
|
-
isSlashLoading: false,
|
|
67
|
-
onSelectSlashItem: vi.fn(),
|
|
68
|
-
onSend: vi.fn(),
|
|
69
|
-
onStop,
|
|
70
|
-
isSending: props.isSending,
|
|
71
|
-
canStopGeneration: props.canStopGeneration
|
|
72
|
-
}),
|
|
73
|
-
{
|
|
74
|
-
initialProps: {
|
|
75
|
-
isSlashMode: true,
|
|
76
|
-
isSending: false,
|
|
77
|
-
canStopGeneration: false
|
|
78
|
-
}
|
|
79
|
-
}
|
|
80
|
-
);
|
|
81
|
-
|
|
82
|
-
act(() => {
|
|
83
|
-
result.current.onTextareaKeyDown(createKeyEvent(' '));
|
|
84
|
-
});
|
|
85
|
-
expect(result.current.isSlashPanelOpen).toBe(false);
|
|
86
|
-
|
|
87
|
-
rerender({
|
|
88
|
-
isSlashMode: false,
|
|
89
|
-
isSending: true,
|
|
90
|
-
canStopGeneration: true
|
|
91
|
-
});
|
|
92
|
-
|
|
93
|
-
act(() => {
|
|
94
|
-
result.current.onTextareaKeyDown(createKeyEvent('Escape'));
|
|
95
|
-
});
|
|
96
|
-
expect(onStop).toHaveBeenCalled();
|
|
97
|
-
});
|
|
98
|
-
|
|
99
|
-
it('supports Tab selection and Enter send when slash mode is not active', () => {
|
|
100
|
-
const onSelectSlashItem = vi.fn();
|
|
101
|
-
const onSend = vi.fn();
|
|
102
|
-
const { result, rerender } = renderHook(
|
|
103
|
-
(props: { isSlashMode: boolean }) =>
|
|
104
|
-
useChatInputBarController({
|
|
105
|
-
isSlashMode: props.isSlashMode,
|
|
106
|
-
slashItems: [{ key: 'one', title: 'One', subtitle: 'Skill', description: '', detailLines: [] }],
|
|
107
|
-
isSlashLoading: false,
|
|
108
|
-
onSelectSlashItem,
|
|
109
|
-
onSend,
|
|
110
|
-
onStop: vi.fn(),
|
|
111
|
-
isSending: false,
|
|
112
|
-
canStopGeneration: false
|
|
113
|
-
}),
|
|
114
|
-
{ initialProps: { isSlashMode: true } }
|
|
115
|
-
);
|
|
116
|
-
|
|
117
|
-
act(() => {
|
|
118
|
-
result.current.onTextareaKeyDown(createKeyEvent('Tab'));
|
|
119
|
-
});
|
|
120
|
-
expect(onSelectSlashItem).toHaveBeenCalledTimes(1);
|
|
121
|
-
|
|
122
|
-
rerender({ isSlashMode: false });
|
|
123
|
-
act(() => {
|
|
124
|
-
result.current.onTextareaKeyDown(createKeyEvent('Enter'));
|
|
125
|
-
});
|
|
126
|
-
expect(onSend).toHaveBeenCalledTimes(1);
|
|
127
|
-
});
|
|
128
|
-
|
|
129
|
-
it('does not send on enter while a response is still running', () => {
|
|
130
|
-
const onSend = vi.fn();
|
|
131
|
-
const event = createKeyEvent('Enter');
|
|
132
|
-
const { result } = renderHook(() =>
|
|
133
|
-
useChatInputBarController({
|
|
134
|
-
isSlashMode: false,
|
|
135
|
-
slashItems: [],
|
|
136
|
-
isSlashLoading: false,
|
|
137
|
-
onSelectSlashItem: vi.fn(),
|
|
138
|
-
onSend,
|
|
139
|
-
onStop: vi.fn(),
|
|
140
|
-
isSending: true,
|
|
141
|
-
canStopGeneration: true
|
|
142
|
-
})
|
|
143
|
-
);
|
|
144
|
-
|
|
145
|
-
act(() => {
|
|
146
|
-
result.current.onTextareaKeyDown(event);
|
|
147
|
-
});
|
|
148
|
-
|
|
149
|
-
expect(onSend).not.toHaveBeenCalled();
|
|
150
|
-
expect(event.preventDefault).toHaveBeenCalledTimes(1);
|
|
151
|
-
});
|
|
152
|
-
});
|
|
@@ -1,142 +0,0 @@
|
|
|
1
|
-
import { useCallback, useEffect, useState } from 'react';
|
|
2
|
-
import type { ChatSlashItem } from '@nextclaw/agent-chat-ui';
|
|
3
|
-
import type { KeyboardEvent } from 'react';
|
|
4
|
-
|
|
5
|
-
type UseChatInputBarControllerParams = {
|
|
6
|
-
isSlashMode: boolean;
|
|
7
|
-
slashItems: ChatSlashItem[];
|
|
8
|
-
isSlashLoading: boolean;
|
|
9
|
-
onSelectSlashItem: (item: ChatSlashItem) => void;
|
|
10
|
-
onSend: () => Promise<void> | void;
|
|
11
|
-
onStop: () => Promise<void> | void;
|
|
12
|
-
isSending: boolean;
|
|
13
|
-
canStopGeneration: boolean;
|
|
14
|
-
};
|
|
15
|
-
|
|
16
|
-
function isSubmitKey(event: Pick<KeyboardEvent<HTMLTextAreaElement>, 'key' | 'shiftKey'>): boolean {
|
|
17
|
-
return event.key === 'Enter' && !event.shiftKey;
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
function isSlashDismissKey(event: Pick<KeyboardEvent<HTMLTextAreaElement>, 'key' | 'code' | 'nativeEvent'>): boolean {
|
|
21
|
-
return !event.nativeEvent.isComposing && (event.key === ' ' || event.code === 'Space');
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
export function useChatInputBarController(params: UseChatInputBarControllerParams) {
|
|
25
|
-
const {
|
|
26
|
-
isSlashMode,
|
|
27
|
-
slashItems,
|
|
28
|
-
onSelectSlashItem,
|
|
29
|
-
onSend,
|
|
30
|
-
onStop,
|
|
31
|
-
isSending,
|
|
32
|
-
canStopGeneration
|
|
33
|
-
} = params;
|
|
34
|
-
const [activeSlashIndex, setActiveSlashIndex] = useState(0);
|
|
35
|
-
const [dismissedSlashPanel, setDismissedSlashPanel] = useState(false);
|
|
36
|
-
|
|
37
|
-
const isSlashPanelOpen = isSlashMode && !dismissedSlashPanel;
|
|
38
|
-
const activeSlashItem = slashItems[activeSlashIndex] ?? null;
|
|
39
|
-
|
|
40
|
-
useEffect(() => {
|
|
41
|
-
if (!isSlashPanelOpen || slashItems.length === 0) {
|
|
42
|
-
setActiveSlashIndex(0);
|
|
43
|
-
return;
|
|
44
|
-
}
|
|
45
|
-
setActiveSlashIndex((current) => {
|
|
46
|
-
if (current < 0) {
|
|
47
|
-
return 0;
|
|
48
|
-
}
|
|
49
|
-
if (current >= slashItems.length) {
|
|
50
|
-
return slashItems.length - 1;
|
|
51
|
-
}
|
|
52
|
-
return current;
|
|
53
|
-
});
|
|
54
|
-
}, [isSlashPanelOpen, slashItems.length]);
|
|
55
|
-
|
|
56
|
-
useEffect(() => {
|
|
57
|
-
if (!isSlashMode && dismissedSlashPanel) {
|
|
58
|
-
setDismissedSlashPanel(false);
|
|
59
|
-
}
|
|
60
|
-
}, [dismissedSlashPanel, isSlashMode]);
|
|
61
|
-
|
|
62
|
-
const handleSelectSlashItem = useCallback((item: ChatSlashItem) => {
|
|
63
|
-
onSelectSlashItem(item);
|
|
64
|
-
setDismissedSlashPanel(false);
|
|
65
|
-
}, [onSelectSlashItem]);
|
|
66
|
-
|
|
67
|
-
const handleSlashKeyDown = useCallback((event: KeyboardEvent<HTMLTextAreaElement>): boolean => {
|
|
68
|
-
if (!isSlashPanelOpen || slashItems.length === 0) {
|
|
69
|
-
return false;
|
|
70
|
-
}
|
|
71
|
-
if (event.key === 'ArrowDown') {
|
|
72
|
-
event.preventDefault();
|
|
73
|
-
setActiveSlashIndex((current) => (current + 1) % slashItems.length);
|
|
74
|
-
return true;
|
|
75
|
-
}
|
|
76
|
-
if (event.key === 'ArrowUp') {
|
|
77
|
-
event.preventDefault();
|
|
78
|
-
setActiveSlashIndex((current) => (current - 1 + slashItems.length) % slashItems.length);
|
|
79
|
-
return true;
|
|
80
|
-
}
|
|
81
|
-
if (!isSubmitKey(event) && event.key !== 'Tab') {
|
|
82
|
-
return false;
|
|
83
|
-
}
|
|
84
|
-
event.preventDefault();
|
|
85
|
-
const selected = slashItems[activeSlashIndex];
|
|
86
|
-
if (selected) {
|
|
87
|
-
handleSelectSlashItem(selected);
|
|
88
|
-
}
|
|
89
|
-
return true;
|
|
90
|
-
}, [activeSlashIndex, handleSelectSlashItem, isSlashPanelOpen, slashItems]);
|
|
91
|
-
|
|
92
|
-
const handleEscapeKeyDown = useCallback((event: KeyboardEvent<HTMLTextAreaElement>): boolean => {
|
|
93
|
-
if (event.key !== 'Escape') {
|
|
94
|
-
return false;
|
|
95
|
-
}
|
|
96
|
-
if (isSlashPanelOpen) {
|
|
97
|
-
event.preventDefault();
|
|
98
|
-
setDismissedSlashPanel(true);
|
|
99
|
-
return true;
|
|
100
|
-
}
|
|
101
|
-
if (!isSending || !canStopGeneration) {
|
|
102
|
-
return false;
|
|
103
|
-
}
|
|
104
|
-
event.preventDefault();
|
|
105
|
-
void onStop();
|
|
106
|
-
return true;
|
|
107
|
-
}, [canStopGeneration, isSlashPanelOpen, isSending, onStop]);
|
|
108
|
-
|
|
109
|
-
const onTextareaKeyDown = useCallback((event: KeyboardEvent<HTMLTextAreaElement>) => {
|
|
110
|
-
if (isSubmitKey(event) && isSending) {
|
|
111
|
-
event.preventDefault();
|
|
112
|
-
return;
|
|
113
|
-
}
|
|
114
|
-
if (isSlashPanelOpen && isSlashDismissKey(event)) {
|
|
115
|
-
setDismissedSlashPanel(true);
|
|
116
|
-
}
|
|
117
|
-
if (handleSlashKeyDown(event)) {
|
|
118
|
-
return;
|
|
119
|
-
}
|
|
120
|
-
if (handleEscapeKeyDown(event)) {
|
|
121
|
-
return;
|
|
122
|
-
}
|
|
123
|
-
if (isSubmitKey(event)) {
|
|
124
|
-
event.preventDefault();
|
|
125
|
-
void onSend();
|
|
126
|
-
}
|
|
127
|
-
}, [handleEscapeKeyDown, handleSlashKeyDown, isSending, isSlashPanelOpen, onSend]);
|
|
128
|
-
|
|
129
|
-
return {
|
|
130
|
-
isSlashPanelOpen,
|
|
131
|
-
activeSlashIndex,
|
|
132
|
-
activeSlashItem,
|
|
133
|
-
onSelectSlashItem: handleSelectSlashItem,
|
|
134
|
-
onSlashPanelOpenChange: (open: boolean) => {
|
|
135
|
-
if (!open) {
|
|
136
|
-
setDismissedSlashPanel(true);
|
|
137
|
-
}
|
|
138
|
-
},
|
|
139
|
-
onSetActiveSlashIndex: setActiveSlashIndex,
|
|
140
|
-
onTextareaKeyDown
|
|
141
|
-
};
|
|
142
|
-
}
|
|
File without changes
|