Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feat/v2 Feat: Add the function of sending messages by hitting enter. #369

Closed
wants to merge 160 commits into from
Closed
Changes from 1 commit
Commits
Show all changes
160 commits
Select commit Hold shift + click to select a range
3b16bfe
feat: v2 ui frame
ddiu8081 Mar 11, 2023
2fe1315
Merge branch 'main' into feat/v2
ddiu8081 Mar 14, 2023
7e6ecad
chore: add `alpinejs`, `nanostores`
ddiu8081 Mar 14, 2023
bc914b4
chore: add store for ui
ddiu8081 Mar 15, 2023
73fbc37
feat: v2 header, sidebar
ddiu8081 Mar 15, 2023
3b680d9
feat(ui): empty state for send component
ddiu8081 Mar 16, 2023
bd24e81
fix(ui): set site height to `100svh`
ddiu8081 Mar 16, 2023
1515c53
feat(ui): use unocss to detect dark mode
ddiu8081 Mar 16, 2023
c5ca7c8
fix(ui): border color in light mode
ddiu8081 Mar 16, 2023
22950f8
feat(ui): fix header, footer and modal
ddiu8081 Mar 16, 2023
30a5dc6
feat(ui): textarea editing state
ddiu8081 Mar 16, 2023
cc3da42
feat: send prompt from single chat
ddiu8081 Mar 16, 2023
d512df8
Merge branch 'main' into feat/v2
ddiu8081 Mar 18, 2023
4321972
chore: lint fix on v2
ddiu8081 Mar 18, 2023
449b127
chore: rename dir to stores
ddiu8081 Mar 18, 2023
bd2e771
feat: conversations sidebar
ddiu8081 Mar 18, 2023
0b696d5
refactor: chatList manage logics
ddiu8081 Mar 18, 2023
e65d1bf
feat: chat edit modal
ddiu8081 Mar 18, 2023
1779db5
fix: clear editingChatId when click add new chat
ddiu8081 Mar 18, 2023
abd4d4c
fix: judge `crypto` exists using `typeof`
ddiu8081 Mar 19, 2023
2f178be
chore: code style in `Layout.astro`
ddiu8081 Mar 20, 2023
4e1a504
feat(ui): set styles for scrollbar
ddiu8081 Mar 20, 2023
2635ec8
fix(ui): overflow scroll for sidebar
ddiu8081 Mar 20, 2023
8a21227
feat: remove support for `HTTPS_PROXY`
ddiu8081 Mar 20, 2023
fee6b8e
feat: usage api
ddiu8081 Mar 20, 2023
59edc89
Merge branch 'main' into feat/v2
ddiu8081 Mar 21, 2023
ff65b89
Merge branch 'main' into feat/v2
yzh990918 Mar 22, 2023
bbaa19f
refactor: move currentChat logic to `stores`
ddiu8081 Mar 22, 2023
9f9f1a0
feat: provider template
ddiu8081 Mar 22, 2023
6b071fa
Merge remote-tracking branch 'origin/feat/v2' into feat/v2
ddiu8081 Mar 22, 2023
3e2d24f
chore: move providers to /src
ddiu8081 Mar 22, 2023
fc29610
feat: add settings store
yzh990918 Mar 22, 2023
5569757
chore: lint code
yzh990918 Mar 22, 2023
b2af5b6
chore: update
yzh990918 Mar 22, 2023
8b82ef7
chore: type declaration of `Provider`
ddiu8081 Mar 22, 2023
7501249
fix: focus on textarea when clicking empty-state
ddiu8081 Mar 22, 2023
dcfdf50
refactor: rename `chat` to `conversation`
ddiu8081 Mar 22, 2023
4a3a7cb
refactor: store conversationTabs as object
ddiu8081 Mar 22, 2023
c001679
feat: bind conversationType config with providers
ddiu8081 Mar 23, 2023
4c11416
fix: show previous conversationType when editing
ddiu8081 Mar 23, 2023
92ce091
feat: disable selecting type in edit mode
ddiu8081 Mar 23, 2023
6b09858
feat: connect to provider
ddiu8081 Mar 23, 2023
1db3f7e
feat: send single message
ddiu8081 Mar 25, 2023
be0a4fd
chore: move provider registration to store
ddiu8081 Mar 25, 2023
79e1614
feat: continuous conversation
ddiu8081 Mar 25, 2023
a6fdf5b
feat: quick create conversation when push a prompt
ddiu8081 Mar 25, 2023
f56a3dc
fix(ui): handle overflow scrolling
ddiu8081 Mar 25, 2023
a9e47fa
fix(ui): clear output on sending, single chats
ddiu8081 Mar 25, 2023
0823051
feat(ui): max width for main area
ddiu8081 Mar 25, 2023
9fd1ac1
chore: move currentEditingId store to conversation
ddiu8081 Mar 26, 2023
fd35a7e
Merge branch 'main' into feat/v2
ddiu8081 Mar 26, 2023
157992f
chore: move interface to `./types`
ddiu8081 Mar 26, 2023
9d224b2
chore: add conversation mock data file
ddiu8081 Mar 26, 2023
8794d97
chore: remove vercelDisableBlocks
ddiu8081 Mar 26, 2023
2adc783
refactor: adjust directory structures
ddiu8081 Mar 26, 2023
4d68ec8
Merge branch 'main' into feat/v2
ddiu8081 Mar 26, 2023
b50eeb5
feat: settings sidebar basic ui
ddiu8081 Mar 26, 2023
04f5559
feat: markdown parse in v2
ddiu8081 Mar 27, 2023
fd652a3
chore: back to markdown-it temporarily
ddiu8081 Mar 27, 2023
5c41a29
fix: set overflow behavior to messageItem
ddiu8081 Mar 27, 2023
e13e617
feat(ui): adjust sidebar header ui
ddiu8081 Mar 28, 2023
1a39409
chore: remove alpine dependencies
ddiu8081 Mar 28, 2023
9e0f590
feat: provider icon definition
ddiu8081 Mar 28, 2023
e2f8a53
feat(ui): api-key settings ui
ddiu8081 Mar 28, 2023
438c380
fix: include provider icon in unocss scanning
ddiu8081 Mar 28, 2023
7fedc03
Merge branch 'main' into feat/v2
yzh990918 Mar 29, 2023
7e660f3
feat: add ThemeToogle component
yzh990918 Mar 29, 2023
934553f
chore: add `idb` dependency
ddiu8081 Mar 29, 2023
1b35ca9
feat: store conversation information in indexedDB
ddiu8081 Mar 30, 2023
cf2f49f
refactor: separate`messages` from `conversation`
ddiu8081 Mar 30, 2023
178b56b
chore: add `HandlerPayload` interface
ddiu8081 Mar 30, 2023
dc375c6
fix: refactor themeToogle
yzh990918 Apr 1, 2023
434c9d1
refactor: rename `platformSettings` to `globalSettings`
ddiu8081 Apr 1, 2023
1baa3af
feat: read provider global settings
ddiu8081 Apr 1, 2023
00ffaea
feat: store settings to indexedDB
ddiu8081 Apr 1, 2023
b92d405
refactor: fetch api logic
ddiu8081 Apr 1, 2023
3fe1735
chore: remove debug `console.log`
ddiu8081 Apr 1, 2023
791a4cf
chore: push single message to store
ddiu8081 Apr 1, 2023
04895ae
chore: test stream output
ddiu8081 Apr 1, 2023
33c2038
feat: stream output
ddiu8081 Apr 2, 2023
ab5a18d
feat: clear message db after delete conversation
ddiu8081 Apr 2, 2023
205c31b
feat(ui): use 100dvh
ddiu8081 Apr 2, 2023
a3fda82
fix(ui): set sideber height
ddiu8081 Apr 2, 2023
f0a272e
chore: move v2 pages to base dir
ddiu8081 Apr 3, 2023
06e9408
fix: skip storage building in server-rendering
ddiu8081 Apr 3, 2023
7dc19d0
feat: add currentChat info & clear to header
ddiu8081 Apr 3, 2023
488583f
fix: clear currentConversationId when deleting
ddiu8081 Apr 3, 2023
19f7b69
fix(ui): match theme toggle button to global style
ddiu8081 Apr 3, 2023
33260e9
feat: image generation
ddiu8081 Apr 4, 2023
0340ea0
feat: stable-diffusion image generation
ddiu8081 Apr 5, 2023
14939d4
chore: add kobalte dependency
ddiu8081 Apr 5, 2023
649cc6d
feat(ui): use `zag` to build ui components
ddiu8081 Apr 6, 2023
d04e63c
chore: hide `Select` component import
ddiu8081 Apr 6, 2023
33a6dc7
feat: add some zag components
yzh990918 Apr 7, 2023
fb85148
feat: add some model settings
yzh990918 Apr 7, 2023
017c360
chore: update
yzh990918 Apr 7, 2023
1dd46c9
feat(store): read default settings
ddiu8081 Apr 8, 2023
a0a2b46
feat: add more model settings, add settings's init value
yzh990918 Apr 9, 2023
db7967c
fix: onChange error in select component
ddiu8081 Apr 9, 2023
0ec6cc0
Merge branch 'feat/v2-model' into feat/v2
ddiu8081 Apr 9, 2023
04f5e8b
fix(stable-diffusion): adjust settings description
ddiu8081 Apr 9, 2023
cd2dcb5
feat(ui): Simplify ui of settings
ddiu8081 Apr 9, 2023
b4e79bb
feat(ui): select hover ui
ddiu8081 Apr 9, 2023
8e5b314
chore: set modalsLayer to clientOnly
ddiu8081 Apr 9, 2023
90edaf8
feat(ui): use zag to build drawers; add transition
ddiu8081 Apr 9, 2023
124b20d
fix(ui): disable close model on outside click
ddiu8081 Apr 9, 2023
458b07a
feat(ui): show non-full-screen modal on lg devices
ddiu8081 Apr 9, 2023
a91b9a8
feat: adjust ui of base components
ddiu8081 Apr 9, 2023
221b541
fix(ui): adjust accent color
ddiu8081 Apr 9, 2023
1545d1c
feat: add conversation icons
ddiu8081 Apr 9, 2023
8e51473
fix: set default conversationType to continuous
ddiu8081 Apr 9, 2023
5c958b1
fix(ui): adjust markdown styles
ddiu8081 Apr 9, 2023
b3b9f41
feat: use `remark` to parse markdown
ddiu8081 Apr 9, 2023
409d724
chore: set Conversation client only
ddiu8081 Apr 9, 2023
f8cf2c5
chore: remove mock data
ddiu8081 Apr 9, 2023
2531fc5
feat: send message by `command+enter`
ddiu8081 Apr 10, 2023
b2d23b7
fix: apply default values when rebuilding data
ddiu8081 Apr 10, 2023
242c8d2
fix: return when no input
ddiu8081 Apr 10, 2023
18d5291
feat(ui): scroll to top when dblClick header
ddiu8081 Apr 10, 2023
eaa6398
feat(ui): adapt for safe-area
ddiu8081 Apr 10, 2023
cde427b
fix: listen keyboard event after mount
ddiu8081 Apr 10, 2023
f656a65
feat(ui): adapt multi-line scrollbar in textarea
ddiu8081 Apr 11, 2023
c11d184
feat(ui): adjust background colors
ddiu8081 Apr 11, 2023
b972131
feat: show error message
ddiu8081 Apr 11, 2023
5a161e2
feat(ui): adjust border radius of modal
ddiu8081 Apr 12, 2023
fb50f55
chore: add todo on model
ddiu8081 Apr 12, 2023
57c5436
feat(ui): add icon in provider select component
ddiu8081 Apr 12, 2023
65ce312
feat: sort conversation tabs by message time
ddiu8081 Apr 12, 2023
b3eb3ce
feat: scroll to bottom ui
ddiu8081 Apr 12, 2023
f74d514
feat(ui): hide scroll banner when focus on input
ddiu8081 Apr 12, 2023
8a1991d
fix(ui): padding of sendBox edit state
ddiu8081 Apr 12, 2023
f5307cb
chore: code style fix
ddiu8081 Apr 12, 2023
32e8722
fix: set settings sidebar render client only
ddiu8081 Apr 12, 2023
fc49e52
feat: pin to bottom when streaming
ddiu8081 Apr 12, 2023
2d9ca0b
fix: move ui logic to client components, fix ssr
ddiu8081 Apr 12, 2023
ac35301
feat: add ctrl + enter keyCode send message
yzh990918 Apr 13, 2023
31b33f0
feat: add send button background color
yzh990918 Apr 13, 2023
39ead54
chore: update send icon opacity
yzh990918 Apr 13, 2023
8f0a639
chore: add modal close btn hover style, add closeBtnStyle
yzh990918 Apr 13, 2023
669faa1
feat(ui): adjust text & bg colors in dark mode
ddiu8081 Apr 13, 2023
3a4f2ce
fix(ui): adjust bg colors
ddiu8081 Apr 13, 2023
c49e0d2
fix(ui): adjust click-area of buttons in header
ddiu8081 Apr 13, 2023
c839591
feat: support math
ddiu8081 Apr 13, 2023
74f5285
fix(ui): adjust header components' gap
ddiu8081 Apr 13, 2023
1c4c781
fix(ui): hide scroll banner when clear message
ddiu8081 Apr 13, 2023
0e2d7dc
chore: move scrollBottom judge info throttle
ddiu8081 Apr 13, 2023
faa5693
feat(ui): add Tooltip componet, add send tips
yzh990918 Apr 14, 2023
7cb1387
feat(ui): add message sendTime
yzh990918 Apr 14, 2023
e4d93ca
chore: remove timeText
yzh990918 Apr 14, 2023
f251852
feat(ui): add messge item options menu
yzh990918 Apr 14, 2023
4e0a08c
fix(ui): layout error in send component, error state
ddiu8081 Apr 14, 2023
ae231a0
fix(ui): layout error in messageItem
ddiu8081 Apr 14, 2023
8c95926
fix: temporarily fix the unclickable send button
ddiu8081 Apr 14, 2023
ff45004
refactor: move ReadableStream to separate store
ddiu8081 Apr 14, 2023
50af82e
feat: loading state
ddiu8081 Apr 14, 2023
ced99fb
fix(ui): set `shrink-0` in header and send com
ddiu8081 Apr 16, 2023
e1a95bf
fix(ui): set width of message-item
ddiu8081 Apr 16, 2023
9fa7460
fix(ui): light mode of progress-bg
ddiu8081 Apr 16, 2023
b72fd91
refactor: remove reactivity store of providers
ddiu8081 Apr 16, 2023
b4cc56b
Update Send.tsx
GalaxySciTech Apr 16, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
feat: sort conversation tabs by message time
  • Loading branch information
ddiu8081 committed Apr 12, 2023
commit 65ce3127ff409839f822e1f620a8897abea4c336
3 changes: 2 additions & 1 deletion src/components/conversations/ConversationSidebar.tsx
Original file line number Diff line number Diff line change
@@ -6,14 +6,15 @@ import ConversationSidebarAdd from './ConversationSidebarAdd'

export default () => {
const $conversationMap = useStore(conversationMap)
const conversationMapSortList = () => Object.values($conversationMap()).sort((a, b) => b.lastUseTime - a.lastUseTime)

return (
<div class="h-full flex flex-col bg-sidebar">
<div class="h-14 fi border-b border-base px-4 text-xs uppercase pl-6">
Conversations
</div>
<div class="flex-1 overflow-auto">
<For each={Object.values($conversationMap())}>
<For each={conversationMapSortList()}>
{instance => (
<ConversationSidebarItem instance={instance} />
)}
3 changes: 2 additions & 1 deletion src/stores/conversation.ts
Original file line number Diff line number Diff line change
@@ -26,6 +26,7 @@ export const addConversation = action(conversationMap, 'addConversation', (map,
conversationType: instance?.conversationType || providerMetaList.get()[0]?.supportConversationType?.[0],
name: instance?.name || '',
icon: instance?.icon || 'i-carbon-chat',
lastUseTime: Date.now(),
}
map.setKey(instanceId, conversation)
db.setItem(instanceId, conversation)
@@ -44,5 +45,5 @@ export const updateConversationById = action(conversationMap, 'updateConversatio
export const deleteConversationById = action(conversationMap, 'deleteConversationById', (map, id: string) => {
map.set(Object.fromEntries(Object.entries(map.get()).filter(([key]) => key !== id)))
db.deleteItem(id)
clearMessagesByConversationId(id)
clearMessagesByConversationId(id, true)
})
9 changes: 8 additions & 1 deletion src/stores/messages.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { action, map } from 'nanostores'
import { conversationMessagesMapData } from './tests/message.mock'
import { db } from './storage/message'
import { updateConversationById } from './conversation'
import type { MessageInstance } from '@/types/message'

export const conversationMessagesMap = map<Record<string, MessageInstance[]>>({})
@@ -47,14 +48,20 @@ export const pushMessageByConversationId = action(
role: payload.role,
content: payload.content,
}])
updateConversationById(id, {
lastUseTime: Date.now(),
})
},
)

export const clearMessagesByConversationId = action(
conversationMessagesMap,
'clearMessagesByConversationId',
(map, id: string) => {
(map, id: string, deleteChat?: boolean) => {
map.setKey(id, [])
db.deleteItem(id)
!deleteChat && updateConversationById(id, {
lastUseTime: Date.now(),
})
},
)
1 change: 1 addition & 0 deletions src/types/conversation.ts
Original file line number Diff line number Diff line change
@@ -6,4 +6,5 @@ export interface Conversation {
conversationType: ConversationType
name: string
icon: string
lastUseTime: number
}