fix(sidebar): 展开态 touched 位、顶栏严格置顶 + draft 进左栏、模型弹层越界导致的整页横滚 - #68
Merged
Merged
Conversation
- shared UiState.expandedGroupsTouched(缺字段按记录非空推断,兼容旧文件) - main ui-state normalize:显式布尔优先,脏值/缺失才推断 - ui-preferences:init 读取;setExpandedGroups 一次 set + 单个补丁原子写两字段 - lib/sidebar-groups:derive 判据从「数组空不空」改为 touched;toggleExpandedGroup 以 touched 决定起点 - useExpandedGroups/Sidebar 接线(全部折叠后再点一个组只展开它,不回退默认集)
- selectBarSessions 去掉 draft 例外:顶栏严格 = 置顶表(SessionTabBar 删掉不可达的 draft 分支) - 新增纯函数 mergeSidebarSessions(历史 + 内存,按 id 去重、内存覆盖),Sidebar 用它同时驱动项目表与会话分组 - SessionRow:draft 行标题固定「新会话」 - session-menu:sidebarMenuKind 判定 + draftSessionMenuItems(仅「丢弃新会话」一项,走纯本地 closeSession) - i18n 双字典:+sidebar.newSession / +sessionMenu.discardDraft,删顶栏已无用的 tabbar.discardDraft
left-0 让 288px 弹层从按钮左缘向右展开:1100px 窗口就右越界 11.8px(900/700px 下 12px+), 搜索框 autoFocus 触发 Chromium 对 #root 的程序性横向滚动(overflow:hidden 拦不住)—— 实测 #root.scrollLeft 0→8/35.5、顶栏最左按钮 left 80→72/44.5,即左栏与顶栏被挤压。 改为 right-0(弹层右缘贴按钮右缘):弹层 left/right = 659/947(< innerWidth), #root.scrollLeft 恒 0,左栏宽度与顶栏按钮位置零偏移;bottom-full/w-72/autoFocus/键盘导航不变。
…,PITFALLS 补三条新坑 - INDEX:sidebar-groups(mergeSidebarSessions + touched 起点)、selectBarSessions 顶栏范围、 ui-preferences expandedGroupsTouched、session/ 与 sidebar/ 两行同步、模型弹层定位职责、 修正过期字段名 topBarVisible → barSessionsVisible - PITFALLS:空数组不能同时当「未初始化」与「有效空值」;absolute 弹层越界 + autoFocus 触发 #root 程序性横滚(overflow:hidden 拦不住,含量测三纪律:selector 限定作用域 / 扫多档窗口宽 / 侧栏行用行高而非标题分辨);renderer 单测跑 node 环境测不了 i18n 与 JSX - ModelPicker 注释量值表述修正(右越界约 12px;35.5px 是窄窗口的根横滚量)
…itest classic) - docs/INDEX.md:182:**…** 单层粗体(原来在粗体内嵌了 **严格置顶表**,Markdown 不支持重叠) - docs/PITFALLS.md:明确「应用构建/tsconfig 预期 automatic → 源码无 import React;Vitest 路径编成 classic → React is not defined」,删掉自相矛盾表述 - 纯文档,无业务代码改动
4 tasks done
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
问题(四个相关但独立的小毛病)
expandedGroups: []身兼两义——「还没初始化过」与「用户主动全折叠」。结果是当前项目最后一个展开组折不掉(切会话又被默认集复活)。ModelPicker弹层left-0在窄窗越过视口右缘 → Chromium 对#root程序性横滚(实测scrollLeft0→35.5),整页左移、顶栏最左按钮被裁掉。改动
UiState.expandedGroupsTouched(shared 类型 +main/ui-state.tsnormalize:显式布尔优先,缺字段按记录是否非空推断,脏值清洗);renderer 侧setExpandedGroups同一次 set 写两个字段 + 单补丁落盘;派生判据从「数组空不空」改为 touched,toggleExpandedGroup增touched参(否则「全折叠后点开一个组」会隐式复活默认集)。selectBarSessions删掉 draft 拼接与例外注释;删顶栏里不可达的 draft 分支(叉叉恒为取消置顶)与已无引用的tabbar.discardDraft键。mergeSidebarSessions(历史 + 内存,Map 保序去重、内存覆盖),合并结果同时驱动项目分组与会话分组;draft 行标题固定「新会话」/New session;右键菜单按sidebarMenuKind分支,draft 只有「丢弃新会话」(danger,纯本地closeSession;只读子会话仍无菜单)。right-0:ModelPicker弹层向左展开,不再越界(含注释记录越界/横滚量值)。zh/en同步(+sidebar.newSession、+sessionMenu.discardDraft)。docs/INDEX.md(顶栏严格置顶 / 左栏合并视图 / touched 语义 / ModelPicker 定位职责,修正过期字段名topBarVisible)、docs/PITFALLS.md(症状索引 +4 行;新增「空数组不能同时当未初始化与有效空值」「absolute 弹层越界 + autoFocus = 整页横向偷跑(含量测三纪律)」「renderer 单测跑 node 环境」)。验证
.local/debug/,已 gitignore)#root.scrollLeft0→8~35.5、顶栏最左按钮 left 80→72/44.5;修复后全部归零(弹层完整在视口内、滚动量 0、左栏 width 恒 240、顶栏按钮 left 恒 80、搜索框仍 activeElement、ArrowDown/Enter 键盘导航与提交换模型正常)。{expandedGroups: [], expandedGroupsTouched: true}→ 重启 dev → 仍全折叠(此时无活跃会话也没有默认展开源)。sidebar-groups+ui-preferences+main/ui-state三文件 49 passed。行为不变(回归面)
draft 不写盘、重启即消失;普通会话删除确认流程不变;未新增 IPC、未改 backend/SDK 生命周期(改动清单里无 backend/IPC 文件);draft 丢弃沿用既有
closeSession的纯本地分支。Checklist
npm run typecheckpassesnpm run testpasseszhandendictionaries