Skip to content

fix(folder): support moving nested folders#547

Merged
Nagi-ovo merged 7 commits into
Nagi-ovo:mainfrom
chang-xinhai:main
Mar 30, 2026
Merged

fix(folder): support moving nested folders#547
Nagi-ovo merged 7 commits into
Nagi-ovo:mainfrom
chang-xinhai:main

Conversation

@chang-xinhai
Copy link
Copy Markdown
Contributor

@chang-xinhai chang-xinhai commented Mar 29, 2026

🚫 AI Policy / AI 政策

  • We explicitly reject AI-generated PRs that have not been manually verified.
  • 本项目拒绝接受任何未经人工复核的 AI 生成的 PR。
  • Low-quality AI PRs will be closed immediately. / 低质量的 AI PR 会被直接关闭。
  • You must understand and take responsibility for every line of code you submit. / 你必须理解并对
    你提交的每一行代码负责。
  • Workflow Proficiency / 协作能力: Ensure you are familiar with GitHub/Git workflows and
    maintain a clean Git history. Please learn the basics first if needed to avoid messy PR history. /
    请确保你熟悉 GitHub/Git 工作流并保持 Git 历史整洁。如有必要请先学习相关知识,避免 PR 历史过于混
    乱。

Description / 描述

本 PR 支持多层文件夹整体移动,补全了现有文件夹拖拽能力在嵌套结构下的限制。

主要改动:

  • 允许非 pinned 的文件夹在包含子文件夹时仍可被拖动
  • 支持将多层文件夹作为整棵树拖入其他文件夹
  • 支持将多层文件夹整体拖回根目录
  • 支持同级文件夹拖拽重排
  • 移动后保持子树结构不变,所有子文件夹的相对顺序不变
  • 移动后保持源父级和目标父级下的同级排序正确
  • 禁止将文件夹拖入自身或其后代节点下,避免形成循环
  • pinned 文件夹保持不可拖动

另外,本 PR 还补充了多层文件夹移动相关的回归测试,并修复了一些与本次改动相关的类型收窄问题,以确保
typecheck 可以通过。

Related Issue / 相关 Issue

Closes #546

Visual Proof / 可视化证据

已附上录屏 / 截图,展示以下场景:

  • 多层文件夹拖入其他文件夹
  • 多层文件夹拖回根目录
  • 同级文件夹重排
  • pinned 文件夹不可拖动

Browser Testing / 浏览器测试

  • Chrome / Edge (Chromium): Tested / 已测试
  • Firefox: Tested (Mandatory) / 已测试(必填)
  • Safari: Tested (Optional) or labeled as unsupported / 已测试(可选)或已标注为不支持

Checklist / 检查清单

  • I have manually verified that the feature works as intended. / 我已手动验证功能按预期工作。
  • I have confirmed that this PR does not break existing functionality. / 我已确认此 PR 不会破
    坏原有功能。
  • I have run bun run lint, bun run typecheck, bun run format and bun run build. / 我已
    运行代码校验、类型检查、格式化及构建。
  • I have added/updated necessary tests and they pass (bun run test). / 我已添加/更新了必要的
    测试并确保通过(bun run test)。
default.mov

Open with Devin

chang-xinhai and others added 2 commits March 29, 2026 11:40
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Entire-Checkpoint: 8498f007f19d
@Nagi-ovo
Copy link
Copy Markdown
Owner

@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 👍

@chang-xinhai
Copy link
Copy Markdown
Contributor Author

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! 🚀

@chang-xinhai chang-xinhai marked this pull request as ready for review March 29, 2026 15:54
Copilot AI review requested due to automatic review settings March 29, 2026 15:54
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 moveFolder operation to handle reparenting/reordering with cycle prevention and sibling sortIndex updates.
  • 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.

Comment thread src/pages/popup/components/CloudSyncSettings.tsx Outdated
Comment thread src/pages/popup/components/CloudSyncSettings.tsx Outdated
Comment thread src/pages/background/index.ts Outdated
Comment thread src/pages/background/index.ts Outdated
Comment on lines +327 to +330
const mergedFolders = this.mergeFolderData(
localData as FolderData,
syncData as FolderData,
);
Copy link

Copilot AI Mar 29, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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).

Copilot uses AI. Check for mistakes.
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@copilot apply changes based on this feedback

Copy link
Copy Markdown
Contributor

@devin-ai-integration devin-ai-integration Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

✅ Devin Review: No Issues Found

Devin Review analyzed this PR and found no potential bugs to report.

View in Devin Review to see 5 additional findings.

Open in Devin Review

chang-xinhai and others added 4 commits March 30, 2026 00:11
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>
devin-ai-integration[bot]

This comment was marked as resolved.

Co-authored-by: devin-ai-integration[bot] <158243242+devin-ai-integration[bot]@users.noreply.github.com>
@Nagi-ovo
Copy link
Copy Markdown
Owner

@codex review

@chatgpt-codex-connector
Copy link
Copy Markdown

Codex Review: Didn't find any major issues. Breezy!

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

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".

@Nagi-ovo
Copy link
Copy Markdown
Owner

@chang-xinhai LGTM

@Nagi-ovo Nagi-ovo merged commit d30bd4e into Nagi-ovo:main Mar 30, 2026
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Feature] 支持多层文件夹整体移动

3 participants