Skip to content

Commit d2c8571

Browse files
committed
Merge pull request 'fix: chathistory starred, normal type and block UI' (#95) from historybar_UI into main
Reviewed-on: https://git.biggo.com/john/dive/pulls/95
2 parents ec7cf4e + 765d7ed commit d2c8571

File tree

10 files changed

+201
-137
lines changed

10 files changed

+201
-137
lines changed

src/atoms/historyState.ts

Lines changed: 9 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,22 @@
11
import { atom } from "jotai"
22

3-
interface ChatHistoryResponse {
4-
starred: ChatHistory[]
5-
normal: ChatHistory[]
3+
interface ChatHistory {
4+
starred: ChatHistoryItem[]
5+
normal: ChatHistoryItem[]
66
}
7-
export interface ChatHistory {
7+
export type ChatHistoryItem = {
88
id: string
99
title: string
1010
createdAt: string
1111
updatedAt: string
1212
starredAt: string
1313
user_id: string
14-
type: "normal" | "starred"
1514
}
1615

17-
export const historiesAtom = atom<ChatHistory[]>([])
16+
export const historiesAtom = atom<ChatHistory>({
17+
starred: [],
18+
normal: []
19+
})
1820

1921
export const loadHistoriesAtom = atom(
2022
null,
@@ -24,12 +26,7 @@ export const loadHistoriesAtom = atom(
2426
const data = await response.json()
2527

2628
if (data.success) {
27-
const response: ChatHistoryResponse = data.data
28-
const historyList: ChatHistory[] = []
29-
Object.entries(response).forEach(([key, value]) => {
30-
historyList.push(...value.map((item: ChatHistory) => ({ ...item, type: key })))
31-
})
32-
set(historiesAtom, historyList)
29+
set(historiesAtom, data.data as ChatHistory)
3330
}
3431
} catch (error) {
3532
console.warn("Failed to load chat history:", error)

src/components/Header.tsx

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import { sidebarVisibleAtom, toggleSidebarAtom } from "../atoms/sidebarState"
44
import { useTranslation } from "react-i18next"
55
import { keymapModalVisibleAtom } from "../atoms/modalState"
66
import ModelSelect from "./ModelSelect"
7+
import Tooltip from "./Tooltip"
78

89
type Props = {
910
showHelpButton?: boolean
@@ -25,14 +26,18 @@ const Header = ({ showHelpButton = false, showModelSelect = false }: Props) => {
2526
<div className="header-content">
2627
<div className="left-side">
2728
<div className="menu-container">
28-
<button
29-
className="menu-btn"
30-
onClick={onClose}
29+
<Tooltip
30+
content={isSidebarVisible ? t("header.closeSidebar") : t("header.openSidebar")}
3131
>
32-
<svg width="24" height="24" viewBox="0 0 24 24">
33-
<path d="M3 18h18v-2H3v2zm0-5h18v-2H3v2zm0-7v2h18V6H3z"/>
34-
</svg>
35-
</button>
32+
<button
33+
className="menu-btn"
34+
onClick={onClose}
35+
>
36+
<svg width="24" height="24" viewBox="0 0 24 24">
37+
<path d="M3 18h18v-2H3v2zm0-5h18v-2H3v2zm0-7v2h18V6H3z"/>
38+
</svg>
39+
</button>
40+
</Tooltip>
3641
<h1>{t("header.title")}</h1>
3742
{showModelSelect && <ModelSelect />}
3843
</div>

src/components/HistorySidebar.tsx

Lines changed: 145 additions & 102 deletions
Large diffs are not rendered by default.

src/locales/en/translation.json

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
{
22
"header": {
3-
"title": "Dive AI"
3+
"title": "Dive AI",
4+
"openSidebar": "Open sidebar",
5+
"closeSidebar": "Close sidebar"
46
},
57
"chat": {
68
"placeholder": "Send any message...",

src/locales/es/translation.json

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
{
22
"header": {
3-
"title": "Dive AI"
3+
"title": "Dive AI",
4+
"openSidebar": "Abrir lista de chats",
5+
"closeSidebar": "Cerrar lista de chats"
46
},
57
"chat": {
68
"placeholder": "Escribe un mensaje...",

src/locales/ja/translation.json

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
{
22
"header": {
3-
"title": "Dive AI"
3+
"title": "Dive AI",
4+
"openSidebar": "チャットリストを開く",
5+
"closeSidebar": "チャットリストを閉じる"
46
},
57
"chat": {
68
"placeholder": "メッセージを送信...",

src/locales/ko/translation.json

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
{
22
"header": {
3-
"title": "Dive AI"
3+
"title": "Dive AI",
4+
"openSidebar": "채팅 목록 열기",
5+
"closeSidebar": "채팅 목록 닫기"
46
},
57
"chat": {
68
"placeholder": "메시지를 입력하세요...",

src/locales/zh-CN/translation.json

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
{
22
"header": {
3-
"title": "Dive AI"
3+
"title": "Dive AI",
4+
"openSidebar": "打开侧边栏",
5+
"closeSidebar": "关闭侧边栏"
46
},
57
"chat": {
68
"placeholder": "发送任何消息...",

src/locales/zh-TW/translation.json

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
{
22
"header": {
3-
"title": "Dive AI"
3+
"title": "Dive AI",
4+
"openSidebar": "開啟側邊欄",
5+
"closeSidebar": "關閉側邊欄"
46
},
57
"chat": {
68
"placeholder": "傳送任何訊息...",

src/styles/components/_HistorySidebar.scss

Lines changed: 17 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,23 @@
4141
@include scrollbar;
4242
}
4343

44+
.history-star {
45+
display: flex;
46+
align-items: center;
47+
justify-content: flex-start;
48+
gap: 4px;
49+
padding: 6px 6px 6px 10px;
50+
font-size: 14px;
51+
font-weight: 500;
52+
}
53+
54+
.history-list-split {
55+
height: 1px;
56+
width: 100%;
57+
background: var(--bg-op-dark-mediumweak);
58+
margin: 16px 0;
59+
}
60+
4461
.history-item {
4562
display: flex;
4663
align-items: center;
@@ -68,16 +85,6 @@
6885
min-width: 0;
6986
margin-right: 8px;
7087

71-
.history-star {
72-
display: flex;
73-
align-items: center;
74-
justify-content: flex-start;
75-
gap: 4px;
76-
margin-bottom: 4px;
77-
font-size: 14px;
78-
font-weight: 500;
79-
}
80-
8188
.history-title {
8289
font-weight: 500;
8390
margin-bottom: 2px;

0 commit comments

Comments
 (0)