Skip to content

feat(editor): 文件窗口与资源管理器二合一 + 声明式设置 select 行 - #151

Merged
Menghuan1918 merged 5 commits into
mainfrom
feat/editor-explorer-merge
Aug 17, 2026
Merged

feat(editor): 文件窗口与资源管理器二合一 + 声明式设置 select 行#151
Menghuan1918 merged 5 commits into
mainfrom
feat/editor-explorer-merge

Conversation

@Menghuan1918

@Menghuan1918 Menghuan1918 commented Aug 16, 2026

Copy link
Copy Markdown
Collaborator

概述

编辑器与资源管理器合并为单一「文件」窗口(explorer descriptor 移除),附带声明式设置的 select 行类型扩展。

行为

单一文件窗口(editor tab,+ 菜单 order 10,title「Files」)

  • 头部合并 chrome:路径输入框(Enter 打开,Esc/blur 还原)+ 上移的预览/编辑/保存工具栏 + 文件树开关;内嵌树面板停靠右缘(全局文件名搜索走 host fs.search 路由,左缘 pointer-capture 拖拽调宽),状态存 tab.meta.treeOpen / tab.meta.treeWidth 随布局持久化
  • editorExplorer 模式(默认合并):
    • 合并:树点击/输入框 Enter 原地切换当前 tab(updateTab 重写 path/title,id 与 meta 保留)
    • 独立:走 openSidebarFile 按 path 新开(树默认收起);无路径窗口即独立资源管理器——只渲染文件树面板(TreePanel 全窗形态,无编辑器 chrome)
  • 树右键菜单:「在新 Tab 中打开」「在侧边打开」(右侧 split 新 editor tab)
  • 新会话 seed 空文件窗口替代旧 explorer tab;持久化的旧 explorer tab 经 sanitizeState 迁移
  • 默认值调整:openByDefault 默认关、侧边栏默认宽度 35%

声明式设置 select 行

  • settings.toggles / pluginToggles 新增 type: 'select':options 声明 { value, title, desc?, icon? },带图标时渲染大图标选项卡(收起态同样显示图标),否则单行文本;multi: true 多选存 value 数组
  • editorExplorer 改为带图标的 select

实现

  • FileTree.tsx / TreePanel.tsx 抽为受控组件(EditorHost 内嵌 dock 与独立资源管理器两处复用)
  • EditorHost.tsx 单文件窗口宿主;ExplorerView.tsx 删除
  • host 侧 fs-search.ts:递归名称搜索(200 匹配 / 10 万节点预算,跳过 .git 与 symlink 目录)
  • e2e 加固:mount lane 提前挂 editor chunk 等待、行左缘点击避开悬停 @ 引用按钮、draggable 限定 tab 断言;drag lane 先展开面板(收起时 push 变量写 0px)+ 等滑入动画落定 + 取最左 col-resize

验证

  • pnpm typecheck ✅ / pnpm test ✅(579 通过)
  • pnpm test:mount ✅(真实 DSH 挂载无头渲染 2/2)
  • scripts/check-consumer-types.sh

…obal name search

New editorExplorer pref (default on, editor card gear): the editor tab gains
a path-input header and a toggleable right-docked tree panel (per-tab state
in tab.meta.treeOpen; file tabs default closed, the seeded path-less home
tab defaults open). Fresh sessions seed that empty editor tab instead of
the explorer tab when merged mode is on; the standalone explorer tab stays
in the + menu unchanged.

- Extract FileTree.tsx from ExplorerView (shared by both hosts)
- Host fs.search route: recursive case-insensitive name search rooted at
  the session cwd, budget-capped (200 matches / 100k visited), skips .git,
  never descends symlink dirs
- EditorHost reads the pref reactively (boolean snapshot) and keeps the
  pre-merge layout verbatim when off
…rer as iconed select

- SidebarSettingToggle gains type 'select' with options {value,title,desc,icon}
  and multi (default false; stores the picked values as an array in options
  order). Any option carrying an icon renders big-icon option cards in the
  dropdown and the icon in the closed anchor; icon-less rows are one-line text.
- SelectRow in SideCardSection rides the primitives Menu (portal); single-pick
  commits and closes, multi toggles and stays open. Wired for both host-prefs
  toggles and plugin-owned pluginToggles via the new onSelectValue seam.
- The editorExplorer merged-mode pref is now an iconed select (merged vs
  separate) instead of a switch; the stored value stays boolean.
- Advertise the capability as 'settingSelect' in SIDEBAR_FEATURES.
…dock, hoisted toolbar

- One tree implementation, two presentations: the shared TreePanel (global
  name search + refresh + FileTree) docks as the editor tab's right panel
  and — in merged mode — fills the explorer tab's window; the pref-off
  explorer keeps its legacy header shell.
- The docked panel drag-resizes from its left edge (160-480px clamp),
  persisted as tab.meta.treeWidth alongside treeOpen.
- The text editor's preview/edit/save toolbar moves into the path-input
  header row: FileViewerProps gains internal toolbar fields ('host' mode
  skips the viewer's own row, reports EditorToolbarState and registers
  EditorToolbarControls); non-merged mode is byte-identical to before.
…escriptor removed

- editor tab replaces explorer on the + menu (order 10, Files); persisted
  explorer tabs migrate to the editor home tab via sanitizeState
- editorExplorer now only controls open behavior: merged = in-place
  updateTab, independent = openSidebarFile; both modes share the merged
  chrome (path input + hoisted preview/edit/save toolbar + tree toggle)
- file tree context menu gains 'open in new tab' / 'open to the side'
  (mintTabId avoids the id safety net; insertLeafAt splits right)
- tree dock resize uses pointer capture (touch-action none, 6px handle)
- defaults: openByDefault off, sidebar width 35%
- file tree clips horizontal overflow (no sideways scroll)
- e2e: mount lane arms the editor-chunk wait before goto and clicks the
  tree row's left edge (hover @-reference button sits mid-row); drag lane
  expands the panel first (collapsed push writes 0px), waits for the
  slide-in to settle, and picks the leftmost col-resize strip; 'Files'
  title assertions require draggable to skip the bottom panel's welcome
  cards
…ne explorer

In independent (split) mode a path-less files window renders ONLY the
tree panel (search + FileTree, full-window form) — no path input, no
hoisted toolbar, no tree toggle. File clicks open per-path editor tabs
(full chrome, tree docked closed by default) through openSidebarFile,
unchanged. Merged mode is untouched (chrome + docked tree, in-place
switching). TreePanel's previously reserved 'full' prop now has its
consumer.
@Menghuan1918 Menghuan1918 changed the title feat(editor): 文件预览与资源管理器二合一(editorExplorer 合并模式) feat(editor): 文件窗口与资源管理器二合一 + 声明式设置 select 行 Aug 17, 2026
@Menghuan1918
Menghuan1918 merged commit 6ee1ba1 into main Aug 17, 2026
2 checks 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.

1 participant