-
Notifications
You must be signed in to change notification settings - Fork 20
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* feat: check node status * fix: connect page ui * fix: external links * fix: agent list * fix: agent list * fix: eslint * feat: implement chat editor
- Loading branch information
1 parent
eeef181
commit 21e5022
Showing
20 changed files
with
637 additions
and
33 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
13 changes: 11 additions & 2 deletions
13
libs/shinkai-node-state/src/lib/queries/getHealth/types.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,13 +1,22 @@ | ||
import { UndefinedInitialDataOptions } from '@tanstack/react-query/src/queryOptions'; | ||
import { QueryObserverOptions } from '@tanstack/react-query'; | ||
|
||
import { FunctionKey } from '../../constants'; | ||
|
||
export type GetHealthInput = { | ||
node_address: string; | ||
}; | ||
export type UseGetHealth = [FunctionKey.GET_HEALTH, GetHealthInput]; | ||
export type GetHealthOutput = { | ||
is_pristine: boolean; | ||
node_name: string; | ||
status: string; | ||
version: string; | ||
}; | ||
|
||
export type Options = UndefinedInitialDataOptions<GetHealthOutput>; | ||
export type Options = QueryObserverOptions< | ||
GetHealthOutput, | ||
Error, | ||
GetHealthOutput, | ||
GetHealthOutput, | ||
UseGetHealth | ||
>; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,92 @@ | ||
import { Placeholder } from '@tiptap/extension-placeholder'; | ||
import { EditorContent, Extension, useEditor } from '@tiptap/react'; | ||
import { StarterKit } from '@tiptap/starter-kit'; | ||
import { useEffect, useLayoutEffect, useRef } from 'react'; | ||
import * as React from 'react'; | ||
import { Markdown } from 'tiptap-markdown'; | ||
|
||
import { DotsLoader } from './dots-loader'; | ||
|
||
export const MessageEditor = ({ | ||
value, | ||
onChange, | ||
onSubmit, | ||
setInitialValue, | ||
disabled, | ||
isLoading, | ||
placeholder, | ||
}: { | ||
value: string; | ||
onChange: (value: string) => void; | ||
onSubmit: () => void; | ||
setInitialValue?: string; | ||
disabled?: boolean; | ||
isLoading?: boolean; | ||
placeholder?: string; | ||
}) => { | ||
// onSubmitRef is used to keep the latest onSubmit function | ||
const onSubmitRef = useRef(onSubmit); | ||
useLayoutEffect(() => { | ||
onSubmitRef.current = onSubmit; | ||
}); | ||
|
||
const editor = useEditor( | ||
{ | ||
editorProps: { | ||
attributes: { | ||
class: 'prose prose-invert prose-sm mx-auto focus:outline-none', | ||
}, | ||
}, | ||
extensions: [ | ||
StarterKit, | ||
Placeholder.configure({ | ||
placeholder: placeholder ?? 'Enter message', | ||
}), | ||
Markdown, | ||
Extension.create({ | ||
addKeyboardShortcuts() { | ||
return { | ||
Enter: () => { | ||
onSubmitRef?.current?.(); | ||
return this.editor.commands.clearContent(); | ||
}, | ||
'Shift-Enter': ({ editor }) => | ||
editor.commands.first(({ commands }) => [ | ||
() => commands.newlineInCode(), | ||
() => commands.splitListItem('listItem'), | ||
() => commands.createParagraphNear(), | ||
() => commands.liftEmptyBlock(), | ||
() => commands.splitBlock(), | ||
]), | ||
}; | ||
}, | ||
}), | ||
], | ||
content: value, | ||
autofocus: true, | ||
onUpdate({ editor }) { | ||
onChange(editor.storage.markdown.getMarkdown()); | ||
}, | ||
editable: !disabled, | ||
}, | ||
[disabled], | ||
); | ||
|
||
useEffect(() => { | ||
setInitialValue === undefined | ||
? editor?.commands.setContent('') | ||
: editor?.commands.setContent(value); | ||
// eslint-disable-next-line react-hooks/exhaustive-deps | ||
}, [setInitialValue]); | ||
|
||
useEffect(() => { | ||
if (value === '') editor?.commands.setContent(''); | ||
}, [value, editor]); | ||
|
||
return ( | ||
<> | ||
{isLoading ? <DotsLoader className="absolute left-4 top-6 z-50" /> : null} | ||
<EditorContent editor={editor} /> | ||
</> | ||
); | ||
}; |
Oops, something went wrong.