Skip to content

Commit 26e77ce

Browse files
committed
Merge pull request 'feat: support sidebar history item pin feature and show the version in settings page' (#93) from historybar_UI into main
Reviewed-on: https://git.biggo.com/john/dive/pulls/93
2 parents 75cce27 + e1833e6 commit 26e77ce

25 files changed

+646
-306
lines changed

src/atoms/historyState.ts

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,17 @@
1-
import { atom } from 'jotai'
1+
import { atom } from "jotai"
22

3+
interface ChatHistoryResponse {
4+
starred: ChatHistory[]
5+
normal: ChatHistory[]
6+
}
37
export interface ChatHistory {
48
id: string
59
title: string
610
createdAt: string
11+
updatedAt: string
12+
starredAt: string
13+
user_id: string
14+
type: "normal" | "starred"
715
}
816

917
export const historiesAtom = atom<ChatHistory[]>([])
@@ -16,7 +24,12 @@ export const loadHistoriesAtom = atom(
1624
const data = await response.json()
1725

1826
if (data.success) {
19-
set(historiesAtom, data.data)
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)
2033
}
2134
} catch (error) {
2235
console.warn("Failed to load chat history:", error)

src/atoms/sidebarState.ts

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

33
export const sidebarVisibleAtom = atom(false)
4+
const originalSidebarWidthAtom = atom(false)
45

56
export const toggleSidebarAtom = atom(
67
null,
78
(get, set) => {
89
set(sidebarVisibleAtom, !get(sidebarVisibleAtom))
10+
set(originalSidebarWidthAtom, get(sidebarVisibleAtom))
911
}
1012
)
1113

@@ -21,6 +23,8 @@ export const handleWindowResizeAtom = atom(
2123
(get, set) => {
2224
if (window.innerWidth < 900) {
2325
set(sidebarVisibleAtom, false)
26+
} else if (window.innerWidth > 900 && get(originalSidebarWidthAtom)) {
27+
set(sidebarVisibleAtom, true)
2428
}
2529
}
2630
)

src/components/HistorySidebar.tsx

Lines changed: 250 additions & 90 deletions
Large diffs are not rendered by default.

src/components/UpdateButton.tsx

Lines changed: 18 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@ import useUpdateProgress from "../hooks/useUpdateProgress"
33
import { memo, useCallback, useState } from "react"
44
import { useTranslation } from "react-i18next"
55
import { showToastAtom } from "../atoms/toastState"
6+
import Button from "./Button"
7+
import { version } from "../../package.json"
68

79
const AvailableButton = ({ newVersion }: { newVersion: string }) => {
810
const { t } = useTranslation()
@@ -14,7 +16,10 @@ const AvailableButton = ({ newVersion }: { newVersion: string }) => {
1416
<span className="update-btn-text">{t("sidebar.update")}</span>
1517
</div>
1618
<div className="update-btn-text">
17-
<span>v{newVersion} &gt;</span>
19+
<span>v{newVersion}</span>
20+
<svg xmlns="http://www.w3.org/2000/svg" fill="none" stroke="currentColor" strokeWidth="2" viewBox="0 0 24 24" width="18" height="18">
21+
<path strokeLinecap="round" strokeLinejoin="round" d="m8.25 4.5 7.5 7.5-7.5 7.5"></path>
22+
</svg>
1823
</div>
1924
</>
2025
)
@@ -64,18 +69,20 @@ const UpdateButton = () => {
6469
}, [showToast])
6570
)
6671

67-
if (!newVersion) {
68-
return null
69-
}
70-
7172
return (
7273
<div className="update-btn-container">
73-
<button
74-
className={`sidebar-footer-btn update-btn ${progress === 0 ? "available" : "downloading"}`}
75-
onClick={update}
76-
>
77-
{progress === 0 ? <AvailableButton newVersion={newVersion} /> : <DownloadingButton progress={progress} isCompleted={isCompleted} />}
78-
</button>
74+
<span className="update-version-text">Dive Version: v{version}</span>
75+
{newVersion &&
76+
<Button
77+
className={`update-btn ${progress === 0 ? "available" : "downloading"}`}
78+
size="fit"
79+
padding="xxs"
80+
minHeight="44px"
81+
onClick={update}
82+
>
83+
{progress === 0 ? <AvailableButton newVersion={newVersion} /> : <DownloadingButton progress={progress} isCompleted={isCompleted} />}
84+
</Button>
85+
}
7986
</div>
8087
)
8188
}

src/locales/en/translation.json

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
"deleteSuccess": "Chat deleted",
1717
"deleteFailed": "Delete failed",
1818
"confirmDelete": "Confirm Delete",
19+
"confirmDeleteDescription": "Once deleted, the chat cannot be recovered.",
1920
"tools": "Tools",
2021
"abort": "Stop Generating",
2122
"retry": "Retry",
@@ -71,7 +72,16 @@
7172
"system": "System Settings",
7273
"manageAndSettings": "Manage and Settings",
7374
"OAPhub": "OAPhub",
74-
"signOut": "Sign Out"
75+
"signOut": "Sign Out",
76+
"chat": {
77+
"starredChat": "Starred",
78+
"starChat": "Star",
79+
"unStarChat": "Unstar",
80+
"starFailed": "Star failed",
81+
"renameChat": "Rename",
82+
"renameFailed": "Rename failed",
83+
"deleteChat": "Delete"
84+
}
7585
},
7686
"tools": {
7787
"title": "Tools Management(MCP)",
@@ -214,7 +224,8 @@
214224
"downloadImage": "Download Image",
215225
"login": "Login",
216226
"signup": "Sign Up",
217-
"save": "Save"
227+
"save": "Save",
228+
"signout": "Sign Out"
218229
},
219230
"models": {
220231
"title": "Model Settings",
@@ -374,7 +385,7 @@
374385
}
375386
},
376387
"update": {
377-
"downloading": "Downloading",
388+
"downloading": "New Version Downloading",
378389
"readyToInstall": "Ready to Install",
379390
"clickToInstall": "Click to Install Update"
380391
},

src/locales/es/translation.json

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
"deleteSuccess": "Chat eliminado",
1717
"deleteFailed": "Error al eliminar",
1818
"confirmDelete": "Confirmar Eliminación",
19+
"confirmDeleteDescription": "El chat una vez eliminado no se puede recuperar.",
1920
"tools": "Herramientas",
2021
"abort": "Detener generación de respuesta",
2122
"retry": "Reintentar",
@@ -71,7 +72,16 @@
7172
"system": "Configuración del Sistema",
7273
"manageAndSettings": "Gestión y Configuración",
7374
"OAPhub": "OAPhub",
74-
"signOut": "Cerrar sesión"
75+
"signOut": "Cerrar sesión",
76+
"chat": {
77+
"starredChat": "Favorito",
78+
"starChat": "Marcar como favorito",
79+
"unStarChat": "Quitar de favoritos",
80+
"starFailed": "Error al marcar como favorito",
81+
"renameChat": "Renombrar",
82+
"renameFailed": "Error al renombrar",
83+
"deleteChat": "Eliminar"
84+
}
7585
},
7686
"tools": {
7787
"title": "Gestión de Herramientas (MCP)",
@@ -214,7 +224,8 @@
214224
"downloadImage": "Descargar imagen",
215225
"login": "Iniciar sesión",
216226
"signup": "Registrarse",
217-
"save": "Guardar"
227+
"save": "Guardar",
228+
"signout": "Cerrar sesión"
218229
},
219230
"models": {
220231
"title": "Configuración de Modelos",
@@ -374,7 +385,7 @@
374385
}
375386
},
376387
"update": {
377-
"downloading": "Descargando",
388+
"downloading": "Descargando nueva versión",
378389
"readyToInstall": "Descarga completada",
379390
"clickToInstall": "Haga clic para instalar la actualización"
380391
},

src/locales/ja/translation.json

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
"deleteSuccess": "チャットを削除しました",
1717
"deleteFailed": "削除に失敗しました",
1818
"confirmDelete": "削除の確認",
19+
"confirmDeleteDescription": "チャット一經削除即永久無法復原。",
1920
"tools": "ツール",
2021
"abort": "生成を停止",
2122
"retry": "再試行",
@@ -71,7 +72,16 @@
7172
"system": "システム設定",
7273
"manageAndSettings": "管理と設定",
7374
"OAPhub": "OAPhub",
74-
"signOut": "ログアウト"
75+
"signOut": "ログアウト",
76+
"chat": {
77+
"starredChat": "釘選済み",
78+
"starChat": "釘選",
79+
"unStarChat": "釘選解除",
80+
"starFailed": "釘選に失敗しました",
81+
"renameChat": "名前変更",
82+
"renameFailed": "名前変更失敗",
83+
"deleteChat": "削除"
84+
}
7585
},
7686
"tools": {
7787
"title": "ツール管理(MCP)",
@@ -214,7 +224,8 @@
214224
"downloadImage": "画像をダウンロード",
215225
"login": "ログイン",
216226
"signup": "サインアップ",
217-
"save": "保存"
227+
"save": "保存",
228+
"signout": "ログアウト"
218229
},
219230
"models": {
220231
"title": "モデル設定",
@@ -374,7 +385,7 @@
374385
}
375386
},
376387
"update": {
377-
"downloading": "ダウンロード中",
388+
"downloading": "新バージョンをダウンロード中",
378389
"readyToInstall": "インストール準備完了",
379390
"clickToInstall": "クリックしてアップデートをインストール"
380391
},

src/locales/ko/translation.json

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
"deleteSuccess": "채팅이 삭제되었습니다",
1717
"deleteFailed": "삭제에 실패했습니다",
1818
"confirmDelete": "삭제 확인",
19+
"confirmDeleteDescription": "채팅 삭제 후 복구가 불가능합니다.",
1920
"tools": "도구",
2021
"abort": "생성 중단",
2122
"retry": "다시 시도",
@@ -71,7 +72,16 @@
7172
"system": "시스템 설정",
7273
"manageAndSettings": "관리 및 설정",
7374
"OAPhub": "OAPhub",
74-
"signOut": "로그아웃"
75+
"signOut": "로그아웃",
76+
"chat": {
77+
"starredChat": "즐겨찾기",
78+
"starChat": "즐겨찾기",
79+
"unStarChat": "즐겨찾기 해제",
80+
"starFailed": "즐겨찾기 실패",
81+
"renameChat": "이름 변경",
82+
"renameFailed": "이름 변경 실패",
83+
"deleteChat": "삭제"
84+
}
7585
},
7686
"tools": {
7787
"title": "도구 관리 (MCP)",
@@ -214,7 +224,8 @@
214224
"downloadImage": "이미지 다운로드",
215225
"login": "로그인",
216226
"signup": "회원가입",
217-
"save": "저장"
227+
"save": "저장",
228+
"signout": "로그아웃"
218229
},
219230
"models": {
220231
"title": "모델 설정",
@@ -374,7 +385,7 @@
374385
}
375386
},
376387
"update": {
377-
"downloading": "다운로드 중",
388+
"downloading": "새 버전 다운로드 중",
378389
"readyToInstall": "설치 준비 완료",
379390
"clickToInstall": "업데이트 설치하려면 클릭하세요"
380391
},

src/locales/zh-CN/translation.json

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
"deleteSuccess": "对话已删除",
1717
"deleteFailed": "删除失败",
1818
"confirmDelete": "确认删除",
19+
"confirmDeleteDescription": "对话一经删除即永久无法恢复。",
1920
"tools": "工具",
2021
"abort": "停止生成回应",
2122
"retry": "重试",
@@ -71,7 +72,16 @@
7172
"system": "系统设置",
7273
"manageAndSettings": "管理与设置",
7374
"OAPhub": "OAPhub",
74-
"signOut": "登出"
75+
"signOut": "登出",
76+
"chat": {
77+
"starredChat": "已钉选",
78+
"starChat": "钉选",
79+
"unStarChat": "取消钉选",
80+
"starFailed": "钉选失败",
81+
"renameChat": "重新命名",
82+
"renameFailed": "重新命名失败",
83+
"deleteChat": "删除"
84+
}
7585
},
7686
"tools": {
7787
"title": "工具管理(MCP)",
@@ -214,7 +224,8 @@
214224
"downloadImage": "下载图片",
215225
"login": "登录",
216226
"signup": "注册",
217-
"save": "保存"
227+
"save": "保存",
228+
"signout": "登出"
218229
},
219230
"models": {
220231
"title": "模型设置",
@@ -374,7 +385,7 @@
374385
}
375386
},
376387
"update": {
377-
"downloading": "下载中",
388+
"downloading": "新版本下载中",
378389
"readyToInstall": "下载完成",
379390
"clickToInstall": "点击安装更新"
380391
},

src/locales/zh-TW/translation.json

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
"deleteSuccess": "對話已刪除",
1717
"deleteFailed": "刪除失敗",
1818
"confirmDelete": "確認刪除",
19+
"confirmDeleteDescription": "對話一經刪除即永久無法復原。",
1920
"tools": "工具",
2021
"abort": "停止生成回應",
2122
"retry": "重試",
@@ -71,7 +72,16 @@
7172
"system": "帳號與系統設定",
7273
"manageAndSettings": "管理與設定",
7374
"OAPhub": "OAPhub",
74-
"signOut": "登出"
75+
"signOut": "登出",
76+
"chat": {
77+
"starredChat": "已釘選",
78+
"starChat": "釘選",
79+
"unStarChat": "取消釘選",
80+
"starFailed": "釘選失敗",
81+
"renameChat": "重新命名",
82+
"renameFailed": "重新命名失敗",
83+
"deleteChat": "刪除"
84+
}
7585
},
7686
"tools": {
7787
"title": "工具管理(MCP)",
@@ -214,7 +224,8 @@
214224
"downloadImage": "下載圖片",
215225
"login": "登入",
216226
"signup": "註冊",
217-
"save": "儲存"
227+
"save": "儲存",
228+
"signout": "登出"
218229
},
219230
"models": {
220231
"title": "模型設定",
@@ -374,7 +385,7 @@
374385
}
375386
},
376387
"update": {
377-
"downloading": "下載中",
388+
"downloading": "新版本下載中",
378389
"readyToInstall": "下載完成",
379390
"clickToInstall": "點擊安裝更新"
380391
},

0 commit comments

Comments
 (0)