feat(sidebar): add per-folder color swatch with picker and neutral conversation rail

- Add `color` column to folder table with migration backfill and hash-based assignment on folder creation
- Expose `update_folder_color` via Tauri command and `/update_folder_color` HTTP route
- Render a color swatch before each folder name in the sidebar header; offer a 10-color palette (9 hues plus a theme-aware foreground sentinel) through the folder context menu
- Show the folder header "new conversation" button only on hover
- Drop the expanded-state tint on folder name and count badge; use a fixed neutral rail color for conversation items
This commit is contained in:
xintaofei
2026-04-23 23:02:58 +08:00
parent b7eeeb0be4
commit 1eeb5041a8
23 changed files with 300 additions and 31 deletions

View File

@@ -140,6 +140,25 @@ pub async fn reorder_folders(
Ok(Json(()))
}
#[derive(Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct UpdateFolderColorParams {
pub folder_id: i32,
pub color: String,
}
pub async fn update_folder_color(
Extension(state): Extension<Arc<AppState>>,
Json(params): Json<UpdateFolderColorParams>,
) -> Result<Json<FolderDetail>, AppCommandError> {
let db = &state.db;
let folder = folder_service::update_folder_color(&db.conn, params.folder_id, &params.color)
.await
.map_err(AppCommandError::from)?
.ok_or_else(|| AppCommandError::not_found("Folder not found"))?;
Ok(Json(folder))
}
#[derive(Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct PathParams {

View File

@@ -107,6 +107,10 @@ pub fn build_router(state: Arc<AppState>, token: String, static_dir: std::path::
post(handlers::folders::remove_folder_from_workspace),
)
.route("/reorder_folders", post(handlers::folders::reorder_folders))
.route(
"/update_folder_color",
post(handlers::folders::update_folder_color),
)
.route(
"/add_folder_to_history",
post(handlers::folders::add_folder_to_history),