fix(folder): support moving nested folders#547
Conversation
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com> Entire-Checkpoint: 8498f007f19d
|
@chang-xinhai CI is green now (I pushed a formatting fix). When you're ready, feel free to mark it as ready for review and we can merge 👍 |
|
Thank you so much for the quick response and the formatting fix! I'm super excited about this. It's marked as ready for review now! 🚀 |
There was a problem hiding this comment.
Pull request overview
This PR extends the folder drag-and-drop system to support moving entire nested folder subtrees (while preventing cycles), and adds regression tests to cover the new behavior. It also includes several storage/type-narrowing hardening changes to keep runtime behavior safer and satisfy typecheck.
Changes:
- Allow non-pinned folders (including those with descendants) to be draggable, while keeping pinned folders fixed.
- Introduce a centralized
moveFolderoperation to handle reparenting/reordering with cycle prevention and siblingsortIndexupdates. - Add regression tests for multi-level folder moves and pinned/descendant-move restrictions; add several storage/type guards in sync-related codepaths.
Reviewed changes
Copilot reviewed 7 out of 7 changed files in this pull request and generated 5 comments.
Show a summary per file
| File | Description |
|---|---|
| src/pages/popup/components/ContextSyncSettings.tsx | Hardens stored port loading by accepting only numeric values. |
| src/pages/popup/components/CloudSyncSettings.tsx | Adds runtime validators/type guards when loading folders/prompts/starred data from storage. |
| src/pages/content/folder/manager.ts | Enables dragging for non-pinned folders; adds moveFolder and routes folder moves/reorders through it; tightens starred-message shape checks. |
| src/pages/content/folder/aistudio.ts | Adds casts after validation to satisfy TS in folder data migration/loading paths. |
| src/pages/content/folder/tests/folderMove.test.ts | Adds regression tests for nested folder move/reorder behaviors, pinned restrictions, and cycle prevention. |
| src/pages/background/index.ts | Adds runtime type guards for starred messages and fork nodes loaded from storage. |
| src/core/services/GoogleDriveSyncService.ts | Adds small helpers to validate cached token/state values read from storage. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| const mergedFolders = this.mergeFolderData( | ||
| localData as FolderData, | ||
| syncData as FolderData, | ||
| ); |
There was a problem hiding this comment.
These as FolderData casts are only needed because validateFolderData returns boolean, so TypeScript can’t narrow after the check. Consider changing validateFolderData to a type guard (data is FolderData) so callers can rely on narrowing without assertions (this also avoids accidentally masking a future mismatch if FolderData shape changes).
There was a problem hiding this comment.
@copilot apply changes based on this feedback
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: devin-ai-integration[bot] <158243242+devin-ai-integration[bot]@users.noreply.github.com>
|
@codex review |
|
Codex Review: Didn't find any major issues. Breezy! ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
If Codex has suggestions, it will comment; otherwise it will react with 👍. Codex can also answer questions or update the PR. Try commenting "@codex address that feedback". |
|
@chang-xinhai LGTM |
🚫 AI Policy / AI 政策
你提交的每一行代码负责。
maintain a clean Git history. Please learn the basics first if needed to avoid messy PR history. /
请确保你熟悉 GitHub/Git 工作流并保持 Git 历史整洁。如有必要请先学习相关知识,避免 PR 历史过于混
乱。
Description / 描述
本 PR 支持多层文件夹整体移动,补全了现有文件夹拖拽能力在嵌套结构下的限制。
主要改动:
另外,本 PR 还补充了多层文件夹移动相关的回归测试,并修复了一些与本次改动相关的类型收窄问题,以确保
typecheck可以通过。Related Issue / 相关 Issue
Closes #546
Visual Proof / 可视化证据
已附上录屏 / 截图,展示以下场景:
Browser Testing / 浏览器测试
Checklist / 检查清单
坏原有功能。
bun run lint,bun run typecheck,bun run formatandbun run build. / 我已运行代码校验、类型检查、格式化及构建。
bun run test). / 我已添加/更新了必要的测试并确保通过(
bun run test)。default.mov