Skip to content

Commit

Permalink
Release 0.2.3 (#142)
Browse files Browse the repository at this point in the history
* Create rust-clippy.yml

* Remove double builds when creating release packages

* Refactor CI workflow: Simplify test and publish jobs

- Removed the matrix strategy from the test-tauri job which included multiple platforms.
- Consolidated steps in the publish-tauri job to improve clarity and maintainability.
- Introduced Rust caching using Swatinem/rust-cache@v2 for faster builds.
- Ensured dependencies are installed consistently across jobs with less redundancy.

* Improve rust-clippy workflow configuration

- Updated cron schedule syntax for consistency
- Cleaned up run command formatting for better readability
- Added working-directory specification for SARIF processing

* Refactor GitHub Actions workflow for Rust Clippy

- Moved the installation of required cargo dependencies (clippy-sarif, sarif-fmt) to the src-tauri directory for better organization.
- Updated the path for the SARIF file upload to ensure it points to the correct location within the src-tauri directory.
- Removed redundant installation steps in the workflow.

* Improved installation instructions in README.md (#114)

- Restructured the installation section for clarity.
- Added a sequential list of steps for downloading/building the Cuuri binary.
- Clarified the process for registering the OpenAI API key.

* Update README.md to include npm install step and change repository directory (#115)

* build(deps): bump chrono from 0.4.38 to 0.4.39 in /src-tauri (#116)

Bumps [chrono](https://github.com/chronotope/chrono) from 0.4.38 to 0.4.39.
- [Release notes](https://github.com/chronotope/chrono/releases)
- [Changelog](https://github.com/chronotope/chrono/blob/main/CHANGELOG.md)
- [Commits](chronotope/chrono@v0.4.38...v0.4.39)

---
updated-dependencies:
- dependency-name: chrono
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <[email protected]>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>

* build(deps-dev): bump @vue/devtools from 7.6.7 to 7.6.8 (#120)

Bumps [@vue/devtools](https://github.com/vuejs/devtools/tree/HEAD/packages/devtools) from 7.6.7 to 7.6.8.
- [Release notes](https://github.com/vuejs/devtools/releases)
- [Commits](https://github.com/vuejs/devtools/commits/v7.6.8/packages/devtools)

---
updated-dependencies:
- dependency-name: "@vue/devtools"
  dependency-type: direct:development
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <[email protected]>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>

* build(deps): bump marked from 15.0.3 to 15.0.4 (#119)

Bumps [marked](https://github.com/markedjs/marked) from 15.0.3 to 15.0.4.
- [Release notes](https://github.com/markedjs/marked/releases)
- [Changelog](https://github.com/markedjs/marked/blob/master/.releaserc.json)
- [Commits](markedjs/marked@v15.0.3...v15.0.4)

---
updated-dependencies:
- dependency-name: marked
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <[email protected]>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>

* build(deps): bump tauri-plugin-shell from 2.0.2 to 2.2.0 in /src-tauri (#122)

Bumps [tauri-plugin-shell](https://github.com/tauri-apps/plugins-workspace) from 2.0.2 to 2.2.0.
- [Release notes](https://github.com/tauri-apps/plugins-workspace/releases)
- [Commits](tauri-apps/plugins-workspace@fs-v2.0.2...os-v2.2.0)

---
updated-dependencies:
- dependency-name: tauri-plugin-shell
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <[email protected]>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>

* build(deps-dev): bump vite from 6.0.2 to 6.0.3 (#117)

Bumps [vite](https://github.com/vitejs/vite/tree/HEAD/packages/vite) from 6.0.2 to 6.0.3.
- [Release notes](https://github.com/vitejs/vite/releases)
- [Changelog](https://github.com/vitejs/vite/blob/main/packages/vite/CHANGELOG.md)
- [Commits](https://github.com/vitejs/vite/commits/v6.0.3/packages/vite)

---
updated-dependencies:
- dependency-name: vite
  dependency-type: direct:development
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <[email protected]>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>

* build(deps): bump serde from 1.0.215 to 1.0.216 in /src-tauri (#121)

Bumps [serde](https://github.com/serde-rs/serde) from 1.0.215 to 1.0.216.
- [Release notes](https://github.com/serde-rs/serde/releases)
- [Commits](serde-rs/serde@v1.0.215...v1.0.216)

---
updated-dependencies:
- dependency-name: serde
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <[email protected]>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>

* build(deps): bump @tauri-apps/plugin-shell from 2.0.1 to 2.2.0 (#118)

Bumps [@tauri-apps/plugin-shell](https://github.com/tauri-apps/plugins-workspace) from 2.0.1 to 2.2.0.
- [Release notes](https://github.com/tauri-apps/plugins-workspace/releases)
- [Commits](tauri-apps/plugins-workspace@os-v2.0.1...os-v2.2.0)

---
updated-dependencies:
- dependency-name: "@tauri-apps/plugin-shell"
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <[email protected]>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>

* build(deps-dev): bump nanoid in the npm_and_yarn group (#123)

Bumps the npm_and_yarn group with 1 update: [nanoid](https://github.com/ai/nanoid).


Updates `nanoid` from 3.3.7 to 3.3.8
- [Release notes](https://github.com/ai/nanoid/releases)
- [Changelog](https://github.com/ai/nanoid/blob/main/CHANGELOG.md)
- [Commits](ai/nanoid@3.3.7...3.3.8)

---
updated-dependencies:
- dependency-name: nanoid
  dependency-type: indirect
  dependency-group: npm_and_yarn
...

Signed-off-by: dependabot[bot] <[email protected]>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>

* Bug/112  cant input openai api key on gui (#124)

* Improved installation instructions in README.md

- Restructured the installation section for clarity.
- Added a sequential list of steps for downloading/building the Cuuri binary.
- Clarified the process for registering the OpenAI API key.

* feat: Implement router-based navigation and settings management

- Added vue-router for managing application routes.
- Removed the API key dialog component; API key management is now done from the Settings view.
- Created HomeView and SettingsView components to handle chat functionalities and API key input.
- Updated App.vue to utilize <RouterView> for dynamic routing.
- Enhanced the set_openai_api_key function to return an error if the API key is empty.
- Updated documentation in README.md to reflect changes in API key registration and installation instructions.
- Added dev dependencies for vue-router.

* Fix: Adjust button layout in SettingsView

- Changed the alignment of the "Save API Key" button to be right-aligned and added margin.
- Improved button layout for better user experience.

* feat: Introduce Diesel Migrations and Refactor Database Connection (#111)

- Added `diesel_migrations` dependency to manage database migrations.
- Created initial migration for `chat_histories` table to track chat records.
- Refactored database connection handling:
  - Removed `Database` struct and associated connection pooling code.
  - Introduced `establish_connection` function for direct database connections.
  - Replaced all calls to the old connection method with the new approach.
- Enhanced SQL queries to operate on the new `chat_histories` table.
- Implemented a configuration file initializer for storing API keys and settings.
- Streamlined code for managing database path and creation of necessary directories.
- Added migration management to the application startup process.

* Bump version from 0.2.1 to 0.2.2 (#126)

- Updated version number in package.json, package-lock.json, Cargo.toml, Cargo.lock, and tauri.conf.json from 0.2.1 to 0.2.2.
- Includes updates to dependencies in the project.

* fix(ChatSessions.vue): improve session initialization logic (#130)

- Refactored `currentSessionId` watcher to be asynchronous for better handling of session updates.
- Enhanced `mounted` lifecycle hook to check if there are any existing sessions and create a new session if none exist.

* Improve error handling for database path retrieval across Tauri components (#133)

- Refactored `get_database_path` function to return a `Result<String, io::Error>` for better error management.
- Updated calls to `get_database_path` in `get_chat_history`, `get_chat_history_by_session`, `get_chatgpt_response`, `get_session_id_list`, and `lib.rs` to handle potential errors gracefully.
- Removed direct panics from database path retrieval and directory creation by incorporating proper error handling.
- Ensured that the application can gracefully handle scenarios when the database path cannot be determined, improving overall robustness.

This update enhances the reliability of database-related operations within the application.

* Refactor database connection and configuration handling (#135)

- Updated `establish_connection` to return a Result, handling errors gracefully.
- Modified `get_chat_history`, `get_chat_history_by_session`, `get_chatgpt_response`, `get_session_id_list` to handle potential errors from `establish_connection`.
- Improved error handling in `get_config` with clearer error messages.
- Refactored `init_config_file` to return a Result, improving error reporting on config file creation.
- Enhanced `run` function to handle errors from initialization and database connection properly.
- Updated `run_migrations` to return a Result for better error handling.
- Improved error messages when loading or writing configuration.

* Remove unused 'dirs' dependency in get_database_path.rs (#138)

This commit eliminates the import of the 'dirs' crate in the get_database_path.rs file, as it was not being utilized. This cleanup helps to improve code readability and reduce unnecessary dependencies.

* Remove unnecessary PathBuf usage in set_openai_api_key.rs (#139)

- Changed the way the configuration path is constructed by directly using the home directory.
- Removed the import of PathBuf as it is no longer needed, simplifying the code.

* Version update: Upgrade Cuuri to 0.2.3 (#141)

- Updated version to 0.2.3 in package.json and package-lock.json.
- Updated Cuuri version to 0.2.3 in Cargo.toml and Cargo.lock.
- Updated version to 0.2.3 in tauri.conf.json.

This update includes new features and fixes.

---------

Signed-off-by: dependabot[bot] <[email protected]>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
  • Loading branch information
takanotume24 and dependabot[bot] authored Dec 19, 2024
1 parent aa75743 commit b32c69d
Show file tree
Hide file tree
Showing 17 changed files with 87 additions and 44 deletions.
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "cuuri",
"private": true,
"version": "0.2.2",
"version": "0.2.3",
"type": "module",
"scripts": {
"dev": "vite",
Expand Down
2 changes: 1 addition & 1 deletion src-tauri/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion src-tauri/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "Cuuri"
version = "0.2.2"
version = "0.2.3"
description = "Cuuri is a GUI client for ChatGPT built with Tauri, Vue, and TypeScript. "
authors = ["takanotume24 <[email protected]>"]
edition = "2021"
Expand Down
6 changes: 3 additions & 3 deletions src-tauri/src/establish_connection.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use diesel::prelude::*;
use std::result::Result;

pub fn establish_connection(database_path: &String) -> SqliteConnection {
SqliteConnection::establish(&database_path)
.unwrap_or_else(|_| panic!("Error connecting to {}", database_path))
pub fn establish_connection(database_path: &str) -> Result<SqliteConnection, diesel::ConnectionError> {
SqliteConnection::establish(database_path)
}
4 changes: 2 additions & 2 deletions src-tauri/src/get_chat_history.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@ use tauri::async_runtime::block_on;
pub fn get_chat_history() -> Result<Vec<RawDatabaseChatEntry>, String> {
// Use block_on to run the async code synchronously
block_on(async {
let database_path = get_database_path();
let mut conn = establish_connection(&database_path);
let database_path = get_database_path().map_err(|e| e.to_string())?;
let mut conn = establish_connection(&database_path).map_err(|e| e.to_string())?;

// Pass the mutable reference to Diesel operations
let results = chat_histories
Expand Down
4 changes: 2 additions & 2 deletions src-tauri/src/get_chat_history_by_session.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@ pub fn get_chat_history_by_session(
// Use block_on to run the async code synchronously
block_on(async {
// Use the helper function to get a mutable connection
let database_path = get_database_path();
let mut conn = establish_connection(&database_path);
let database_path = get_database_path().map_err(|e| e.to_string())?;
let mut conn = establish_connection(&database_path).map_err(|e| e.to_string())?;

// Filter the chat history by the specific session_id
let results = chat_histories
Expand Down
4 changes: 2 additions & 2 deletions src-tauri/src/get_chatgpt_response.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@ pub async fn get_chatgpt_response(
model: String,
api_key: String,
) -> Result<ChatResponse, String> {
let database_path = get_database_path();
let mut conn = establish_connection(&database_path);
let database_path = get_database_path().map_err(|e| e.to_string())?;
let mut conn = establish_connection(&database_path).map_err(|e| e.to_string())?;

let session_history = chat_histories
.filter(session_id.eq(&input_session_id))
Expand Down
14 changes: 11 additions & 3 deletions src-tauri/src/get_config.rs
Original file line number Diff line number Diff line change
@@ -1,15 +1,23 @@
use crate::config::Config;
use std::path::PathBuf;

pub async fn get_config() -> Result<Config, String> {
let mut config_path = dirs::home_dir().expect("Failed to get home directory");
// Attempt to get the home directory
let mut config_path: PathBuf = dirs::home_dir().ok_or("Failed to get home directory".to_string())?;

config_path.push(".cuuri/config.toml");

// Check if the config file exists
if !config_path.exists() {
return Err("Configuration file does not exist".to_string());
}

let config = Config::from_file(config_path.to_str().unwrap())
// Convert the path to a string and handle possible error
let config_path_str = config_path.to_str().ok_or("Failed to convert config path to string".to_string())?;

// Load the configuration from file and handle potential errors
let config = Config::from_file(config_path_str)
.map_err(|e| format!("Failed to load configuration: {}", e))?;

Ok(config)
}
}
13 changes: 9 additions & 4 deletions src-tauri/src/get_database_path.rs
Original file line number Diff line number Diff line change
@@ -1,14 +1,19 @@
use std::fs;
use std::io;

pub fn get_database_path() -> String {
let mut db_path = dirs::home_dir().expect("Failed to get home directory");
pub fn get_database_path() -> Result<String, io::Error> {
// ホームディレクトリの取得
let mut db_path = dirs::home_dir()
.ok_or_else(|| io::Error::new(io::ErrorKind::NotFound, "Failed to get home directory"))?;
db_path.push(".cuuri/chat.db");

// 親ディレクトリの作成
if let Some(parent) = db_path.parent() {
fs::create_dir_all(parent).expect("Failed to create directories for database file");
fs::create_dir_all(parent)?;
}

// データベースURLの生成
let database_url = format!("sqlite://{}", db_path.to_string_lossy());

return database_url;
Ok(database_url) // 成功時はOkを返す
}
4 changes: 2 additions & 2 deletions src-tauri/src/get_session_id_list.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ use tauri::async_runtime::block_on;
#[tauri::command]
pub fn get_session_id_list() -> Result<Vec<SessionId>, String> {
block_on(async {
let database_path = get_database_path();
let mut conn = establish_connection(&database_path);
let database_path = get_database_path().map_err(|e| e.to_string())?;
let mut conn = establish_connection(&database_path).map_err(|e| e.to_string())?;

let results = chat_histories
.select(session_id)
Expand Down
18 changes: 9 additions & 9 deletions src-tauri/src/init_config_file.rs
Original file line number Diff line number Diff line change
@@ -1,20 +1,20 @@
use std::fs;
use std::io::Write;
use std::io::{self, Write};

pub fn init_config_file() {
let mut config_path = dirs::home_dir().expect("Failed to get home directory");
pub fn init_config_file() -> Result<(), io::Error> {
let mut config_path = dirs::home_dir().ok_or_else(|| io::Error::new(io::ErrorKind::NotFound, "Failed to get home directory"))?;
config_path.push(".cuuri/config.toml");

if !config_path.exists() {
if let Some(parent) = config_path.parent() {
fs::create_dir_all(parent).expect("Failed to create directories for config file");
fs::create_dir_all(parent)?;
}
let mut file = fs::File::create(&config_path).expect("Failed to create config file");

writeln!(file, "openai_api_key = \"\"").expect("Failed to write default API key");
writeln!(file, "default_model = \"gpt-3.5-turbo\"").expect("Failed to write default model");


let mut file = fs::File::create(&config_path)?;
writeln!(file, "openai_api_key = \"\"")?;
writeln!(file, "default_model = \"gpt-3.5-turbo\"")?;
println!("Configuration file created at {:?}", config_path);
}

Ok(())
}
28 changes: 24 additions & 4 deletions src-tauri/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -33,11 +33,31 @@ use set_openai_api_key::set_openai_api_key;
use std::env;

pub fn run() {
init_config_file();
if let Err(e) = init_config_file() {
eprintln!("Failed to initialize config file: {}", e);
return;
}

let database_url = get_database_path();
let mut connection: diesel::SqliteConnection = establish_connection(&database_url);
run_migrations(&mut connection);
let database_path = match get_database_path() {
Ok(path) => path,
Err(e) => {
eprintln!("Failed to get database path: {}", e);
return;
}
};

let mut connection = match establish_connection(&database_path) {
Ok(conn) => conn,
Err(e) => {
eprintln!("Failed to establish connection: {}", e);
return;
}
};

if let Err(e) = run_migrations(&mut connection) {
eprintln!("Failed to run migrations: {}", e);
return;
}

tauri::Builder::default()
.invoke_handler(tauri::generate_handler![
Expand Down
5 changes: 3 additions & 2 deletions src-tauri/src/run_migrations.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
use diesel::prelude::SqliteConnection;
use diesel_migrations::{embed_migrations, EmbeddedMigrations, MigrationHarness};

pub const MIGRATIONS: EmbeddedMigrations = embed_migrations!();

pub fn run_migrations(connection: &mut SqliteConnection) {
connection.run_pending_migrations(MIGRATIONS).unwrap();
pub fn run_migrations(connection: &mut SqliteConnection) -> Result<(), Box<dyn std::error::Error + Send + Sync + 'static>> {
connection.run_pending_migrations(MIGRATIONS).map(|_| ())
}
14 changes: 10 additions & 4 deletions src-tauri/src/set_openai_api_key.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,17 +8,23 @@ pub async fn set_openai_api_key(api_key: String) -> Result<(), String> {
return Err("API key cannot be empty".to_string());
}

let mut config_path = dirs::home_dir().expect("Failed to get home directory");
// Attempt to get the home directory, returning an error if it fails
let home_dir = dirs::home_dir()
.ok_or_else(|| "Failed to get home directory".to_string())?;

let mut config_path = home_dir;
config_path.push(".cuuri/config.toml");

let mut config = Config::from_file(config_path.to_str().unwrap())
// Attempt to load the configuration from the file
let mut config = Config::from_file(config_path.to_str().ok_or_else(|| "Invalid config path".to_string())?)
.map_err(|e| format!("Failed to load configuration: {}", e))?;

config.openai_api_key = api_key;

let content =
toml::to_string(&config).map_err(|e| format!("Failed to serialize config: {}", e))?;
// Serialize the config and check for errors
let content = toml::to_string(&config).map_err(|e| format!("Failed to serialize config: {}", e))?;

// Write the serialized config to a file
fs::write(&config_path, content)
.map_err(|e| format!("Failed to write to config file: {}", e))?;

Expand Down
2 changes: 1 addition & 1 deletion src-tauri/tauri.conf.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"$schema": "https://schema.tauri.app/config/2",
"productName": "Cuuri",
"version": "0.2.2",
"version": "0.2.3",
"identifier": "com.takanotume24.cuuri",
"build": {
"beforeDevCommand": "npm run dev",
Expand Down
5 changes: 4 additions & 1 deletion src/components/ChatSessions.vue
Original file line number Diff line number Diff line change
Expand Up @@ -37,12 +37,15 @@ export default defineComponent({
};
},
watch: {
currentSessionId(newVal: SessionId, _: SessionId) {
async currentSessionId(newVal: SessionId, _: SessionId) {
this.localCurrentSessionId = newVal;
},
},
async mounted() {
await this.fetchSessionIdList();
if (this.localCurrentSessionId == null && this.sessionIdList.length == 0) {
await this.createNewSession();
}
},
methods: {
selectSession(sessionId: SessionId) {
Expand Down

0 comments on commit b32c69d

Please sign in to comment.