feat: support for snapshot version updates (#480)

* feat: support for snapshot version updates

* docs: update changelog
This commit is contained in:
ayangweb
2025-05-07 16:43:44 +08:00
committed by GitHub
parent 326e161505
commit 8498578425
14 changed files with 105 additions and 15 deletions

View File

@@ -16,6 +16,7 @@ Information about release notes of Coco Server is provided here.
- feat: check or enter to close the list of assistants #469
- feat: add dimness settings for pinned window #470
- feat: supports Shift + Enter input box line feeds #472
- feat: support for snapshot version updates #480
### 🐛 Bug fix

View File

@@ -29,7 +29,7 @@
"@tauri-apps/plugin-os": "^2.2.1",
"@tauri-apps/plugin-process": "^2.2.0",
"@tauri-apps/plugin-shell": "^2.2.0",
"@tauri-apps/plugin-updater": "^2.6.1",
"@tauri-apps/plugin-updater": "github:infinilabs/tauri-plugin-updater#v2",
"@tauri-apps/plugin-websocket": "~2.3.0",
"@tauri-apps/plugin-window": "2.0.0-alpha.1",
"@wavesurfer/react": "^1.0.9",

11
pnpm-lock.yaml generated
View File

@@ -42,8 +42,8 @@ importers:
specifier: ^2.2.0
version: 2.2.0
'@tauri-apps/plugin-updater':
specifier: ^2.6.1
version: 2.6.1
specifier: github:infinilabs/tauri-plugin-updater#v2
version: https://codeload.github.com/infinilabs/tauri-plugin-updater/tar.gz/358e689c65e9943b53eff50bcb9dfd5b1cfc4072
'@tauri-apps/plugin-websocket':
specifier: ~2.3.0
version: 2.3.0
@@ -1248,8 +1248,9 @@ packages:
'@tauri-apps/plugin-shell@2.2.0':
resolution: {integrity: sha512-iC3Ic1hLmasoboG7BO+7p+AriSoqAwKrIk+Hpk+S/bjTQdXqbl2GbdclghI4gM32X0bls7xHzIFqhRdrlvJeaA==}
'@tauri-apps/plugin-updater@2.6.1':
resolution: {integrity: sha512-iiOevw4kc12Ok99J9KthXwUqwPv1sYjG+tNEDZqPmwvOmIq7s58nKMRz6NJPKXT4U16NzMPffFcP/LUOsz6c4A==}
'@tauri-apps/plugin-updater@https://codeload.github.com/infinilabs/tauri-plugin-updater/tar.gz/358e689c65e9943b53eff50bcb9dfd5b1cfc4072':
resolution: {tarball: https://codeload.github.com/infinilabs/tauri-plugin-updater/tar.gz/358e689c65e9943b53eff50bcb9dfd5b1cfc4072}
version: 2.7.1
'@tauri-apps/plugin-websocket@2.3.0':
resolution: {integrity: sha512-eAwRGe3tnqDeQYE0wq4g1PUKbam9tYvlC4uP/au12Y/z7MP4lrS4ylv+aoZ5Ly+hTlBdi7hDkhHomwF/UeBesA==}
@@ -4610,7 +4611,7 @@ snapshots:
dependencies:
'@tauri-apps/api': 2.4.0
'@tauri-apps/plugin-updater@2.6.1':
'@tauri-apps/plugin-updater@https://codeload.github.com/infinilabs/tauri-plugin-updater/tar.gz/358e689c65e9943b53eff50bcb9dfd5b1cfc4072':
dependencies:
'@tauri-apps/api': 2.4.0

5
src-tauri/Cargo.lock generated
View File

@@ -6167,9 +6167,8 @@ dependencies = [
[[package]]
name = "tauri-plugin-updater"
version = "2.6.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "a31bfcfb4a8318008d2108ccfba439d8263cf48867baabf372cb0e9f24771896"
version = "2.7.1"
source = "git+https://github.com/infinilabs/plugins-workspace?branch=v2#f0fa81f93438be2d53ce8bc3435a55e17ec971c7"
dependencies = [
"base64 0.22.1",
"dirs 6.0.0",

View File

@@ -37,7 +37,6 @@ tauri-plugin-store = "2.2.0"
tauri-plugin-os = "2"
tauri-plugin-dialog = "2"
tauri-plugin-fs = "2"
tauri-plugin-updater = "2"
tauri-plugin-process = "2"
tauri-plugin-drag = "2"
tauri-plugin-macos-permissions = "2"
@@ -96,4 +95,4 @@ strip = true # Ensures debug symbols are removed.
[target.'cfg(not(any(target_os = "android", target_os = "ios")))'.dependencies]
tauri-plugin-autostart = "^2.2"
tauri-plugin-global-shortcut = "2"
tauri-plugin-updater = "2"
tauri-plugin-updater = { git = "https://github.com/infinilabs/plugins-workspace", branch = "v2" }

View File

@@ -173,6 +173,7 @@ function SearchChat({
setIsPinned && setIsPinned(isPinned);
return platformAdapter.setAlwaysOnTop(isPinned);
}, []);
const snapshotUpdate = useAppearanceStore((state) => state.snapshotUpdate);
const getDataSourcesByServer = useCallback(
async (
@@ -315,6 +316,12 @@ function SearchChat({
}
}, []);
useEffect(() => {
if (!snapshotUpdate) return;
checkUpdate();
}, [snapshotUpdate]);
return (
<div
data-tauri-drag-region={isTauri}

View File

@@ -2,7 +2,7 @@ import SettingsInput from "@/components/Settings/SettingsInput";
import SettingsItem from "@/components/Settings/SettingsItem";
import { useAppearanceStore } from "@/stores/appearance";
import platformAdapter from "@/utils/platformAdapter";
import { Unplug } from "lucide-react";
import { AppWindowMac } from "lucide-react";
import { useEffect } from "react";
import { useTranslation } from "react-i18next";
@@ -26,7 +26,7 @@ const Appearance = () => {
</h2>
<SettingsItem
icon={Unplug}
icon={AppWindowMac}
title={t("settings.advanced.appearance.opacity.title")}
description={t("settings.advanced.appearance.opacity.description")}
>

View File

@@ -0,0 +1,39 @@
import SettingsItem from "@/components/Settings/SettingsItem";
import SettingsToggle from "@/components/Settings/SettingsToggle";
import { useAppearanceStore } from "@/stores/appearance";
import { FlaskConical } from "lucide-react";
import { useTranslation } from "react-i18next";
const UpdateSettings = () => {
const { t } = useTranslation();
const snapshotUpdate = useAppearanceStore((state) => state.snapshotUpdate);
const setSnapshotUpdate = useAppearanceStore((state) => {
return state.setSnapshotUpdate;
});
return (
<>
<h2 className="text-lg font-semibold text-gray-900 dark:text-white mb-4">
{t("settings.advanced.updateVersion.title")}
</h2>
<SettingsItem
icon={FlaskConical}
title={t("settings.advanced.updateVersion.snapshotUpdate.title")}
description={t(
"settings.advanced.updateVersion.snapshotUpdate.description"
)}
>
<SettingsToggle
label={t("settings.advanced.updateVersion.snapshotUpdate.title")}
checked={snapshotUpdate}
onChange={() => {
setSnapshotUpdate(!snapshotUpdate);
}}
/>
</SettingsItem>
</>
);
};
export default UpdateSettings;

View File

@@ -8,6 +8,7 @@ import { useConnectStore } from "@/stores/connectStore";
import Appearance from "./components/Appearance";
import SettingsInput from "../SettingsInput";
import platformAdapter from "@/utils/platformAdapter";
import UpdateSettings from "./components/UpdateSettings";
const Advanced = () => {
const { t } = useTranslation();
@@ -206,6 +207,8 @@ const Advanced = () => {
</div>
<Appearance />
<UpdateSettings />
</div>
);
};

View File

@@ -79,6 +79,9 @@ export const useSyncStore = () => {
return state.setQuerySourceTimeout;
});
const setOpacity = useAppearanceStore((state) => state.setOpacity);
const setSnapshotUpdate = useAppearanceStore((state) => {
return state.setSnapshotUpdate;
});
useEffect(() => {
if (!resetFixedWindow) {
@@ -145,9 +148,10 @@ export const useSyncStore = () => {
}),
platformAdapter.listenEvent("change-appearance-store", ({ payload }) => {
const { opacity } = payload;
const { opacity, snapshotUpdate } = payload;
setOpacity(opacity);
setSnapshotUpdate(snapshotUpdate);
}),
]);

View File

@@ -169,6 +169,13 @@
"title": "Pinned Window Dimness Setting",
"description": "Adjusts the opacity level of the Coco AI window when its pinned and not in focus. Set a value between 10% and 100%, where 100% means fully opaque (no dimming), and lower values increase transparency, allowing underlying content to show through."
}
},
"updateVersion": {
"title": "Version & Updates",
"snapshotUpdate": {
"title": "Snapshot Updates",
"description": "Get early access to new features. May be unstable."
}
}
},
"tabs": {

View File

@@ -169,6 +169,13 @@
"title": "置顶时失焦透明度",
"description": "设置 Coco AI 窗口在置顶且失去焦点时的不透明度10%100%100% 表示完全不透明)。"
}
},
"updateVersion": {
"title": "版本与更新",
"snapshotUpdate": {
"title": "快照版更新",
"description": "抢先体验新功能,可能不稳定。"
}
}
},
"tabs": {

View File

@@ -4,6 +4,8 @@ import { persist, subscribeWithSelector } from "zustand/middleware";
export type IAppearanceStore = {
opacity: number;
setOpacity: (opacity: number) => void;
snapshotUpdate: boolean;
setSnapshotUpdate: (snapshotUpdate: boolean) => void;
};
export const useAppearanceStore = create<IAppearanceStore>()(
@@ -14,11 +16,16 @@ export const useAppearanceStore = create<IAppearanceStore>()(
setOpacity: (opacity) => {
return set({ opacity });
},
snapshotUpdate: false,
setSnapshotUpdate: (snapshotUpdate) => {
return set({ snapshotUpdate });
},
}),
{
name: "startup-store",
partialize: (state) => ({
opacity: state.opacity,
snapshotUpdate: state.snapshotUpdate,
}),
}
)

View File

@@ -12,6 +12,7 @@ import {
import type { BasePlatformAdapter } from "@/types/platform";
import type { AppTheme } from "@/types/index";
import { useAppStore } from "@/stores/appStore";
import { useAppearanceStore } from "@/stores/appearance";
export interface TauriPlatformAdapter extends BasePlatformAdapter {
openFileDialog: (
@@ -116,7 +117,22 @@ export const createTauriAdapter = (): TauriPlatformAdapter => {
async checkUpdate() {
const { check } = await import("@tauri-apps/plugin-updater");
return check();
const { snapshotUpdate } = useAppearanceStore.getState();
const endpoints = [
"https://release.infinilabs.com/coco/app/.latest.json?target={{target}}&arch={{arch}}&current_version={{current_version}}",
];
if (snapshotUpdate) {
endpoints.unshift(
"https://release.infinilabs.com/coco/app/snapshot/.latest.json?target={{target}}&arch={{arch}}&current_version={{current_version}}"
);
}
return check({
endpoints,
});
},
async relaunchApp() {