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

@@ -0,0 +1,60 @@
use sea_orm_migration::prelude::*;
use sea_orm_migration::sea_orm::{ConnectionTrait, DbBackend, Statement};
#[derive(DeriveMigrationName)]
pub struct Migration;
#[async_trait::async_trait]
impl MigrationTrait for Migration {
async fn up(&self, manager: &SchemaManager) -> Result<(), DbErr> {
manager
.alter_table(
Table::alter()
.table(Folder::Table)
.add_column(
ColumnDef::new(Folder::Color)
.string()
.not_null()
.default("#22c55e"),
)
.to_owned(),
)
.await?;
// Backfill existing rows with a palette color chosen by (id - 1) mod N,
// so existing workspaces get visually distinct swatches after migration.
let conn = manager.get_connection();
let sql = "UPDATE folder SET color = CASE ((id - 1) % 9) \
WHEN 0 THEN '#ef4444' \
WHEN 1 THEN '#f97316' \
WHEN 2 THEN '#eab308' \
WHEN 3 THEN '#84cc16' \
WHEN 4 THEN '#22c55e' \
WHEN 5 THEN '#06b6d4' \
WHEN 6 THEN '#8b5cf6' \
WHEN 7 THEN '#d946ef' \
WHEN 8 THEN '#ec4899' \
END";
conn.execute(Statement::from_string(DbBackend::Sqlite, sql.to_string()))
.await?;
Ok(())
}
async fn down(&self, manager: &SchemaManager) -> Result<(), DbErr> {
manager
.alter_table(
Table::alter()
.table(Folder::Table)
.drop_column(Folder::Color)
.to_owned(),
)
.await
}
}
#[derive(DeriveIden)]
enum Folder {
Table,
Color,
}

View File

@@ -12,6 +12,7 @@ mod m20260406_000001_agent_setting_model_provider;
mod m20260420_000001_opened_tabs;
mod m20260422_000001_folder_sort_order;
mod m20260423_000001_drop_folder_parent_branch;
mod m20260424_000001_folder_color;
pub struct Migrator;
#[async_trait::async_trait]
@@ -30,6 +31,7 @@ impl MigratorTrait for Migrator {
Box::new(m20260420_000001_opened_tabs::Migration),
Box::new(m20260422_000001_folder_sort_order::Migration),
Box::new(m20260423_000001_drop_folder_parent_branch::Migration),
Box::new(m20260424_000001_folder_color::Migration),
]
}
}