ci: add GitHub Actions workflows with semantic-release auto-versioning

chore: fix all 702 clippy warnings across codebase
- auto-fix 475 via cargo clippy --fix
- fix remaining 227 manually: uninlined_format_args, redundant_closure, match_same_arms,
  underscore_binding, format_push_string, items_after_statements, needless_pass_by_value,
  clone_on_copy, case_sensitive_extension, single_match/let-else, write_with_newline,
  and other clippy lints
This commit is contained in:
asepharyana
2026-07-13 08:12:12 +07:00
parent be921d6836
commit 29a9fae3f6
79 changed files with 826 additions and 904 deletions
+2 -2
View File
@@ -66,7 +66,7 @@ impl EditorState {
self.cursor_line += 1;
}
self.cursor_col = self.cursor_col.min(
self.content.get(self.cursor_line).map(|l| l.len()).unwrap_or(0),
self.content.get(self.cursor_line).map_or(0, std::string::String::len),
);
}
@@ -112,7 +112,7 @@ impl EditorState {
/// Flow: no-op if no editor is open → for each char: `\n`/`\r` inserts a
/// line and moves down, `\t` inserts two spaces, everything else inserts
/// the char directly → mark state dirty.
pub fn handle_editor_input(state: &mut AppStateRest, text: String) {
pub fn handle_editor_input(state: &mut AppStateRest, text: &str) {
let editor = &mut state.misc.editor;
if editor.is_none() {
return;
+3 -2
View File
@@ -1,5 +1,6 @@
#![allow(clippy::cast_possible_truncation, clippy::cast_sign_loss, clippy::cast_precision_loss, clippy::cast_possible_wrap)]
//! Effort mode: cycles the agent's reasoning effort level, which scales the
//! LLM's temperature and max_tokens for subsequent turns.
//! LLM's temperature and `max_tokens` for subsequent turns.
use crate::app::state::rest::AppStateRest;
@@ -44,7 +45,7 @@ pub fn cycle_effort(state: &mut AppStateRest) {
let label = current_effort_str(state);
state.push_toast(crate::app::state::types::Toast::new(
crate::app::state::types::ToastKind::Info,
format!("Effort: {}", label),
format!("Effort: {label}"),
));
state.dirty = true;
}
+11 -14
View File
@@ -1,23 +1,20 @@
#![allow(clippy::cast_possible_truncation, clippy::cast_sign_loss, clippy::cast_precision_loss, clippy::cast_possible_wrap)]
//! Rewind mode: restores a file to a pre-edit snapshot stored in the
//! session's SQLite blob store.
//! session's `SQLite` blob store.
use crate::app::state::rest::AppStateRest;
use sha2::Digest;
/// Returns the number of stored pre-edit blobs (snapshots) for this session.
pub fn rewind_count(state: &AppStateRest) -> usize {
let conn = match open_session_db(&state.session_dir) {
Ok(c) => c,
Err(_) => return 0,
};
let Ok(conn) = open_session_db(&state.session_dir) else { return 0 };
crate::model::msglog::blobs::list_blob_keys(&conn, &state.session_id)
.ok()
.map(|keys| keys.len())
.unwrap_or(0)
.map_or(0, |keys| keys.len())
}
/// Restores a file to its pre-edit state by retrieving the blob stored under index
/// `index` (0 = oldest). Opens a fresh SQLite connection so this works outside
/// `index` (0 = oldest). Opens a fresh `SQLite` connection so this works outside
/// of a running turn (e.g. from the Rewind overlay).
pub fn rewind_to(state: &mut AppStateRest, index: usize) {
let conn = match open_session_db(&state.session_dir) {
@@ -25,7 +22,7 @@ pub fn rewind_to(state: &mut AppStateRest, index: usize) {
Err(e) => {
state.push_toast(crate::app::state::types::Toast::new(
crate::app::state::types::ToastKind::Error,
format!("Failed to open session DB: {}", e),
format!("Failed to open session DB: {e}"),
));
state.dirty = true;
return;
@@ -37,7 +34,7 @@ pub fn rewind_to(state: &mut AppStateRest, index: usize) {
Err(e) => {
state.push_toast(crate::app::state::types::Toast::new(
crate::app::state::types::ToastKind::Error,
format!("Failed to list snapshots: {}", e),
format!("Failed to list snapshots: {e}"),
));
state.dirty = true;
return;
@@ -67,7 +64,7 @@ pub fn rewind_to(state: &mut AppStateRest, index: usize) {
Err(e) => {
state.push_toast(crate::app::state::types::Toast::new(
crate::app::state::types::ToastKind::Error,
format!("Failed to retrieve snapshot: {}", e),
format!("Failed to retrieve snapshot: {e}"),
));
state.dirty = true;
return;
@@ -81,7 +78,7 @@ pub fn rewind_to(state: &mut AppStateRest, index: usize) {
.unwrap_or_else(|| state.session_dir.join("snapshot.dat"));
match std::fs::write(&restore_path, &bytes) {
Ok(_) => {
Ok(()) => {
state.push_toast(crate::app::state::types::Toast::new(
crate::app::state::types::ToastKind::Success,
format!("Restored {} from snapshot", restore_path.display()),
@@ -90,7 +87,7 @@ pub fn rewind_to(state: &mut AppStateRest, index: usize) {
Err(e) => {
state.push_toast(crate::app::state::types::Toast::new(
crate::app::state::types::ToastKind::Error,
format!("Failed to write restored file: {}", e),
format!("Failed to write restored file: {e}"),
));
}
}
@@ -101,7 +98,7 @@ pub fn rewind_to(state: &mut AppStateRest, index: usize) {
ts: chrono::Utc::now().timestamp_millis(),
tool: "rewind".to_string(),
path: restore_path.to_string_lossy().to_string(),
reason: format!("rewind_to({})", index),
reason: format!("rewind_to({index})"),
content_sha256: format!("{:x}", sha2::Sha256::digest(&bytes)),
bytes_delta: bytes.len() as i64,
origin: crate::app::state::types::Origin::Main.tag(),
+1 -1
View File
@@ -8,7 +8,7 @@ use crate::model::settings::{Settings, InternetMode};
/// Advance the internet access mode to the next value in the cycle.
///
/// Flow: Off -> ReadOnly -> Full -> Off, wrapping around.
/// Flow: Off -> `ReadOnly` -> Full -> Off, wrapping around.
///
/// Why: used by a settings-toggle keybinding to step through modes
/// without needing a dropdown/menu.