refactor(workspace): migrate from per-folder windows to single-window workspace
Replace the legacy folder + welcome routes with a unified /workspace route that hosts all folders, conversations, tabs, and terminals in one window. - Persist opened tabs to the database (opened_tabs entity + migration) so tab layout survives restarts and deep-link bootstrap restores state - Replace FolderContext shim with AppWorkspaceProvider, ActiveFolderProvider, and TabProvider; expose both opened (folders) and full DB (allFolders) listings via list_all_folder_details - Return conversations across all non-deleted folders from list_all when no folder filter is given, so the sidebar can show every folder's history - Add ConversationContextBar above the chat input with folder picker (auto-opens unopened folders on select), branch picker, and commit / push / merge / stash entries to restore BranchDropdown functionality - Rework sidebar with stats header, search, flat / folder-grouped view modes (localStorage-persisted), reveal-in-sidebar event subscriber, and per-folder context menu (focus, close tabs, remove from workspace); indent conversations under folder headers in grouped mode - Gate terminal creation on active folder and show folder context - Remove deprecated BranchDropdown, FolderNameDropdown, welcome route, and per-folder window commands - Localize all new strings across 10 locales
This commit is contained in:
132
src-tauri/src/db/migration/m20260420_000001_opened_tabs.rs
Normal file
132
src-tauri/src/db/migration/m20260420_000001_opened_tabs.rs
Normal file
@@ -0,0 +1,132 @@
|
||||
use sea_orm_migration::prelude::*;
|
||||
|
||||
#[derive(DeriveMigrationName)]
|
||||
pub struct Migration;
|
||||
|
||||
#[async_trait::async_trait]
|
||||
impl MigrationTrait for Migration {
|
||||
async fn up(&self, manager: &SchemaManager) -> Result<(), DbErr> {
|
||||
manager
|
||||
.drop_table(
|
||||
Table::drop()
|
||||
.table(FolderOpenedConversation::Table)
|
||||
.if_exists()
|
||||
.to_owned(),
|
||||
)
|
||||
.await?;
|
||||
|
||||
manager
|
||||
.create_table(
|
||||
Table::create()
|
||||
.table(OpenedTab::Table)
|
||||
.if_not_exists()
|
||||
.col(
|
||||
ColumnDef::new(OpenedTab::Id)
|
||||
.integer()
|
||||
.not_null()
|
||||
.auto_increment()
|
||||
.primary_key(),
|
||||
)
|
||||
.col(ColumnDef::new(OpenedTab::FolderId).integer().not_null())
|
||||
.col(ColumnDef::new(OpenedTab::ConversationId).integer().null())
|
||||
.col(ColumnDef::new(OpenedTab::AgentType).string().not_null())
|
||||
.col(ColumnDef::new(OpenedTab::Position).integer().not_null())
|
||||
.col(
|
||||
ColumnDef::new(OpenedTab::IsActive)
|
||||
.boolean()
|
||||
.not_null()
|
||||
.default(false),
|
||||
)
|
||||
.col(
|
||||
ColumnDef::new(OpenedTab::IsPinned)
|
||||
.boolean()
|
||||
.not_null()
|
||||
.default(false),
|
||||
)
|
||||
.col(
|
||||
ColumnDef::new(OpenedTab::CreatedAt)
|
||||
.timestamp_with_time_zone()
|
||||
.not_null(),
|
||||
)
|
||||
.col(
|
||||
ColumnDef::new(OpenedTab::UpdatedAt)
|
||||
.timestamp_with_time_zone()
|
||||
.not_null(),
|
||||
)
|
||||
.foreign_key(
|
||||
ForeignKey::create()
|
||||
.from(OpenedTab::Table, OpenedTab::FolderId)
|
||||
.to(Folder::Table, Folder::Id)
|
||||
.on_delete(ForeignKeyAction::Cascade),
|
||||
)
|
||||
.foreign_key(
|
||||
ForeignKey::create()
|
||||
.from(OpenedTab::Table, OpenedTab::ConversationId)
|
||||
.to(Conversation::Table, Conversation::Id)
|
||||
.on_delete(ForeignKeyAction::Cascade),
|
||||
)
|
||||
.to_owned(),
|
||||
)
|
||||
.await?;
|
||||
|
||||
manager
|
||||
.create_index(
|
||||
Index::create()
|
||||
.name("idx_opened_tabs_folder_id")
|
||||
.table(OpenedTab::Table)
|
||||
.col(OpenedTab::FolderId)
|
||||
.to_owned(),
|
||||
)
|
||||
.await?;
|
||||
|
||||
manager
|
||||
.create_index(
|
||||
Index::create()
|
||||
.name("idx_opened_tabs_position")
|
||||
.table(OpenedTab::Table)
|
||||
.col(OpenedTab::Position)
|
||||
.to_owned(),
|
||||
)
|
||||
.await?;
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
||||
async fn down(&self, manager: &SchemaManager) -> Result<(), DbErr> {
|
||||
manager
|
||||
.drop_table(Table::drop().table(OpenedTab::Table).if_exists().to_owned())
|
||||
.await?;
|
||||
Ok(())
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(DeriveIden)]
|
||||
enum OpenedTab {
|
||||
Table,
|
||||
Id,
|
||||
FolderId,
|
||||
ConversationId,
|
||||
AgentType,
|
||||
Position,
|
||||
IsActive,
|
||||
IsPinned,
|
||||
CreatedAt,
|
||||
UpdatedAt,
|
||||
}
|
||||
|
||||
#[derive(DeriveIden)]
|
||||
enum FolderOpenedConversation {
|
||||
Table,
|
||||
}
|
||||
|
||||
#[derive(DeriveIden)]
|
||||
enum Folder {
|
||||
Table,
|
||||
Id,
|
||||
}
|
||||
|
||||
#[derive(DeriveIden)]
|
||||
enum Conversation {
|
||||
Table,
|
||||
Id,
|
||||
}
|
||||
@@ -9,6 +9,7 @@ mod m20260330_000001_chat_channel;
|
||||
mod m20260401_000001_chat_channel_sender_context;
|
||||
mod m20260404_000001_model_provider;
|
||||
mod m20260406_000001_agent_setting_model_provider;
|
||||
mod m20260420_000001_opened_tabs;
|
||||
pub struct Migrator;
|
||||
|
||||
#[async_trait::async_trait]
|
||||
@@ -24,6 +25,7 @@ impl MigratorTrait for Migrator {
|
||||
Box::new(m20260401_000001_chat_channel_sender_context::Migration),
|
||||
Box::new(m20260404_000001_model_provider::Migration),
|
||||
Box::new(m20260406_000001_agent_setting_model_provider::Migration),
|
||||
Box::new(m20260420_000001_opened_tabs::Migration),
|
||||
]
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user