Repository navigation
Conversation
… breakpoint The chat history rail only resolved its open state once, at module load. Narrowing the window below 1200px kept the 248px rail open and squeezed the conversation; widening again did not reopen it. Listen for window resize at module level and, only when the viewport crosses CHAT_SIDEBAR_WIDE_BREAKPOINT, open (wide) or close (narrow) the rail. Resizes that stay on one side keep the current state, including a manual toggle. The breakpoint-driven change is not written to localStorage, so the stored manual preference still decides the state on the next page load. Fixes TencentCloud#2784 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This branch has not been deployed
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.
Fixes #2784
问题
对话页中间栏(会话历史)的开合状态只在模块加载时根据
window.innerWidth算一次。宽屏(≥1200px)进入后把窗口拖窄(分屏、拉宽 DevTools 等),248px 的中间栏仍然展开,正文和输入框被挤压;反过来从窄屏拖回宽屏也不会自动展开。改动
只改
dashboard/src/pages/Chat/hooks/useChatSidebarState.ts:resolveChatSidebarOpenOnResize(prevWidth, nextWidth, open):只有跨过CHAT_SIDEBAR_WIDE_BREAKPOINT(1200)时才改变状态(变宽 → 展开,变窄 → 收起),同侧内的 resize 保持当前状态(包括用户手动开合的结果)。resize监听(passive)调用它,状态变化时通知useSyncExternalStore订阅者。notifySidebarListeners(),供手动切换和 resize 两处复用;更新了resolveChatSidebarDefaultOpen上"Does not react to resize"的过时注释。不涉及 React 层、样式、后端。
截图(真实运行,本地
octop run+ Vite dev server,Playwright 1440 → 1000 → 1440 视口)中间栏实际宽度(
[class*=sidebarWrapper]的getBoundingClientRect().width):三个阶段
localStorage["octop:chat-sidebar:open"]均为null,即断点变化未写入用户偏好。1000px 视口 · 修复前:中间栏仍占 248px
1000px 视口 · 修复后:中间栏自动收起,正文占满
拖回 1440px · 修复后:中间栏自动重新展开
测试
新增
dashboard/src/pages/Chat/hooks/chatSidebarResize.test.ts(5 个用例):renderHook(useChatSidebarOpen)+ 派发resize):1440 → 1000 → 1300 依次为 展开 / 收起 / 展开,且 localStorage 未被写入;窄屏下手动展开后在同侧 resize 仍保持展开。把源码还原为修复前的版本时,其中 3 个用例失败;修复后全部通过。
本地验证:
npx vitest run src/pages/Chat/hooks/→ 35 files / 256 tests passednpx tsc -b、eslint(改动文件)→ 通过make all(format-all + ruff + mypy --strict + pytest:5441 passed)+ dashboardnpm run buildChecklist
🤖 Generated with Claude Code