feat(settings): add quick messages management with drag-and-drop sorting
Adds a new "Quick Messages" settings page below Experts for managing reusable title/content snippets, backed by SQLite via SeaORM and exposed through both Tauri commands and the Axum web router. The list supports drag-to-reorder using the same motion/react Reorder pattern as the agent list, with translations provided across all 10 supported locales.
This commit is contained in:
@@ -10,6 +10,7 @@ pub mod git;
|
||||
pub mod mcp;
|
||||
pub mod model_provider;
|
||||
pub mod project_boot;
|
||||
pub mod quick_messages;
|
||||
pub mod system_settings;
|
||||
pub mod terminal;
|
||||
pub mod version_control;
|
||||
|
||||
86
src-tauri/src/web/handlers/quick_messages.rs
Normal file
86
src-tauri/src/web/handlers/quick_messages.rs
Normal file
@@ -0,0 +1,86 @@
|
||||
use std::sync::Arc;
|
||||
|
||||
use axum::{extract::Extension, Json};
|
||||
use serde::Deserialize;
|
||||
|
||||
use crate::app_error::AppCommandError;
|
||||
use crate::app_state::AppState;
|
||||
use crate::db::service::quick_message_service;
|
||||
use crate::models::QuickMessageInfo;
|
||||
|
||||
#[derive(Deserialize)]
|
||||
#[serde(rename_all = "camelCase")]
|
||||
pub struct CreateQuickMessageParams {
|
||||
pub title: String,
|
||||
pub content: String,
|
||||
}
|
||||
|
||||
#[derive(Deserialize)]
|
||||
#[serde(rename_all = "camelCase")]
|
||||
pub struct UpdateQuickMessageParams {
|
||||
pub id: i32,
|
||||
pub title: Option<String>,
|
||||
pub content: Option<String>,
|
||||
}
|
||||
|
||||
#[derive(Deserialize)]
|
||||
#[serde(rename_all = "camelCase")]
|
||||
pub struct DeleteQuickMessageParams {
|
||||
pub id: i32,
|
||||
}
|
||||
|
||||
#[derive(Deserialize)]
|
||||
#[serde(rename_all = "camelCase")]
|
||||
pub struct ReorderQuickMessagesParams {
|
||||
pub ids: Vec<i32>,
|
||||
}
|
||||
|
||||
pub async fn quick_messages_list(
|
||||
Extension(state): Extension<Arc<AppState>>,
|
||||
) -> Result<Json<Vec<QuickMessageInfo>>, AppCommandError> {
|
||||
let result = quick_message_service::list(&state.db.conn)
|
||||
.await
|
||||
.map_err(AppCommandError::from)?;
|
||||
Ok(Json(result))
|
||||
}
|
||||
|
||||
pub async fn quick_messages_create(
|
||||
Extension(state): Extension<Arc<AppState>>,
|
||||
Json(params): Json<CreateQuickMessageParams>,
|
||||
) -> Result<Json<QuickMessageInfo>, AppCommandError> {
|
||||
let result = quick_message_service::create(&state.db.conn, ¶ms.title, ¶ms.content)
|
||||
.await
|
||||
.map_err(AppCommandError::from)?;
|
||||
Ok(Json(result))
|
||||
}
|
||||
|
||||
pub async fn quick_messages_update(
|
||||
Extension(state): Extension<Arc<AppState>>,
|
||||
Json(params): Json<UpdateQuickMessageParams>,
|
||||
) -> Result<Json<QuickMessageInfo>, AppCommandError> {
|
||||
let result =
|
||||
quick_message_service::update(&state.db.conn, params.id, params.title, params.content)
|
||||
.await
|
||||
.map_err(AppCommandError::from)?;
|
||||
Ok(Json(result))
|
||||
}
|
||||
|
||||
pub async fn quick_messages_delete(
|
||||
Extension(state): Extension<Arc<AppState>>,
|
||||
Json(params): Json<DeleteQuickMessageParams>,
|
||||
) -> Result<Json<()>, AppCommandError> {
|
||||
quick_message_service::delete(&state.db.conn, params.id)
|
||||
.await
|
||||
.map_err(AppCommandError::from)?;
|
||||
Ok(Json(()))
|
||||
}
|
||||
|
||||
pub async fn quick_messages_reorder(
|
||||
Extension(state): Extension<Arc<AppState>>,
|
||||
Json(params): Json<ReorderQuickMessagesParams>,
|
||||
) -> Result<Json<()>, AppCommandError> {
|
||||
quick_message_service::reorder(&state.db.conn, params.ids)
|
||||
.await
|
||||
.map_err(AppCommandError::from)?;
|
||||
Ok(Json(()))
|
||||
}
|
||||
@@ -631,6 +631,27 @@ pub fn build_router(state: Arc<AppState>, token: String, static_dir: std::path::
|
||||
"/delete_model_provider",
|
||||
post(handlers::model_provider::delete_model_provider),
|
||||
)
|
||||
// ─── Quick Messages ───
|
||||
.route(
|
||||
"/quick_messages_list",
|
||||
post(handlers::quick_messages::quick_messages_list),
|
||||
)
|
||||
.route(
|
||||
"/quick_messages_create",
|
||||
post(handlers::quick_messages::quick_messages_create),
|
||||
)
|
||||
.route(
|
||||
"/quick_messages_update",
|
||||
post(handlers::quick_messages::quick_messages_update),
|
||||
)
|
||||
.route(
|
||||
"/quick_messages_delete",
|
||||
post(handlers::quick_messages::quick_messages_delete),
|
||||
)
|
||||
.route(
|
||||
"/quick_messages_reorder",
|
||||
post(handlers::quick_messages::quick_messages_reorder),
|
||||
)
|
||||
// ─── Terminal ───
|
||||
.route("/terminal_spawn", post(handlers::terminal::terminal_spawn))
|
||||
.route("/terminal_write", post(handlers::terminal::terminal_write))
|
||||
|
||||
Reference in New Issue
Block a user