@@ -13,9 +13,8 @@ rewrote this to use the Antd dropdown, which is more dynamic.
13
13
import type { MenuProps } from "antd" ;
14
14
import { Dropdown } from "antd" ;
15
15
import { ReactNode , useCallback , useEffect , useRef , useState } from "react" ;
16
-
17
16
import { CSS , ReactDOM } from "@cocalc/frontend/app-framework" ;
18
- import { MenuItems } from "@cocalc/frontend/components" ;
17
+ import type { MenuItems } from "@cocalc/frontend/components" ;
19
18
import AIAvatar from "@cocalc/frontend/components/ai-avatar" ;
20
19
import { strictMod } from "@cocalc/util/misc" ;
21
20
import { COLORS } from "@cocalc/util/theme" ;
@@ -48,9 +47,13 @@ type Props = Props1 | Props2;
48
47
// WARNING: Complete closing when clicking outside the complete box
49
48
// is handled in cell-list on_click. This is ugly code (since not localized),
50
49
// but seems to work well for now. Could move.
51
- export function Complete ( props : Props ) {
52
- const { items, onSelect, onCancel, offset, position } = props ;
53
-
50
+ export function Complete ( {
51
+ items,
52
+ onSelect,
53
+ onCancel,
54
+ offset,
55
+ position,
56
+ } : Props ) {
54
57
const items_user = items . filter ( ( item ) => ! ( item . is_llm ?? false ) ) ;
55
58
56
59
// All other LLMs that should not show up in the main menu
@@ -174,8 +177,6 @@ export function Complete(props: Props) {
174
177
} ;
175
178
} , [ onKeyDown , onCancel ] ) ;
176
179
177
- if ( items . length === 0 ) return null ;
178
-
179
180
selected_key_ref . current = ( ( ) => {
180
181
if ( llm || onlyLLMs ) {
181
182
const len : number = items_llm . length ?? 1 ;
@@ -213,9 +214,10 @@ export function Complete(props: Props) {
213
214
menuItems . push ( {
214
215
key : "sub_llm" ,
215
216
label : (
216
- < span style = { style } >
217
- < AIAvatar size = { 22 } /> More AI Language Models
218
- </ span >
217
+ < div style = { { ...style , display : "flex" , alignItems : "center" } } >
218
+ < AIAvatar size = { 22 } /> { " " }
219
+ < span style = { { marginLeft : "5px" } } > More AI Language Models</ span >
220
+ </ div >
219
221
) ,
220
222
style,
221
223
children : items_llm . map ( ( { label, value } ) => {
@@ -228,6 +230,10 @@ export function Complete(props: Props) {
228
230
} ) ;
229
231
}
230
232
233
+ if ( menuItems . length == 0 ) {
234
+ menuItems . push ( { key : "nothing" , label : "No items found" , disabled : true } ) ;
235
+ }
236
+
231
237
// NOTE: the AI LLM sub-menu is either opened by hovering (clicking closes immediately) or by right-arrow key
232
238
const menu : MenuProps = {
233
239
selectedKeys : [ selected_key_ref . current ] ,
0 commit comments