Repository navigation
fix(settings): 设置窗口记住调整后的尺寸,默认尺寸改为 1270×700 - #2248
Merged
Merged
Conversation
- 默认尺寸由 900×700 改为 1270×700,最小尺寸仍为 900×668 - 接上 Viva OnFrameChange,拖动时只在内存记尺寸;窗口关闭时尺寸与打开时 不同才写入应用设置 settingsWindowWidth/settingsWindowHeight - 工作台退出或关闭项目标签页连带关闭设置窗口时,先用 ResizedWindow 同步 取走尺寸再关闭,避免尺寸丢失 - 同一窗口的各项目标签页共用这个尺寸,其他标签页整份保存设置时不写回旧值 (各标签页设置副本的既有债见 #1851) - 新增窗口尺寸单测、工作台持久化与跨标签页测试;更新功能矩阵与前后截图
xiaoyumuxi
marked this pull request as ready for review
November 20, 2026 21:35
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.
关联 Issue / Linked issue
PR 类型 / Type
改动说明 / What changes
背景 / Why
设置窗口每次打开都是写死的 900×700:用户把窗口拖大后关闭,下次打开又回到 900×700,调整过的尺寸不会被记住。900 宽度下插件详情的标题被截断(“Editor Shortcut Im…”),常用页面也比较挤。用户要求两件事:
改动 / Changes
设置窗口(
desktop/internal/settingswindow/)window.goopeningSize:有记住的尺寸就按它打开;没有记住的尺寸、某一边 ≤ 0 时回到默认值;小于最小尺寸的值抬到最小尺寸。app.Config.OnFrameChange(官方用于保存窗口几何的回调,报逻辑像素)。ctrl.mu保护),拖动过程中不写盘。Options.WindowResized报告一次;只移动窗口、或改回打开时的尺寸,都不报告。reportFrame、macOSreportFrameChange、Linux 最大化都会跳过),这些状态下的尺寸自然不被记住,下次按进入这些状态之前的尺寸打开。controller.goValues新增WindowWidth/WindowHeight:打开时的尺寸,0 表示用默认值。它是布局偏好,不属于设置草稿。Options新增WindowResized func(width, height int):在设置窗口线程上、窗口关闭时最多调用一次。Controller.ResizedWindow():同步取出当前打开窗口被调整后的尺寸,供“自己关闭时连带关闭设置窗口”的调用方使用。工作台(
desktop/internal/workbench/)app.go:应用设置新增settingsWindowWidth/settingsWindowHeight两个字段(omitempty,旧文件没有这两个键时按默认值打开)。settings.goWindowResized把尺寸投递回工作台线程,由setSettingsWindowSize保存;尺寸没变时不重复写文件。closeSettingsWindow:工作台退出或关闭项目标签页时会连带关闭设置窗口。窗口要等关闭后才报告尺寸,而那时工作台已不再处理自己的队列,所以先用ResizedWindow()同步取走尺寸,再关闭窗口;否则“调整尺寸后直接退出应用”会丢掉尺寸。setSettingsWindowSize因此把尺寸写进同一窗口所有标签页的副本,带来两点:openSettings把记住的尺寸传给Values。app.go:closed、window_sessions.go(关闭标签页):原来直接调用a.settingsWindow.Close()的两处,改为调用a.closeSettingsWindow()。测试
settingswindow/window_size_test.go:TestWindowOpensAtTheSizeTheUserLastGaveIt:无记住尺寸 → 1270×700;记住 1100×760 → 1100×760;一边缺失或为负 → 默认值;640×480 → 抬到最小尺寸 900×668。TestClosingKeepsTheSizeTheUserGaveTheWindow:TestResizedWindowGivesTheSizeBeforeTheWindowCloses:未调整时不返回尺寸;调整后在关闭前返回 1150×780;关闭后不再返回。workbench/app_test.go新增TestSettingsWindowSizePersistsWithOtherSettings:workbench/window_sessions_test.go新增TestSettingsWindowSizeIsEveryProjectTabs:在 alpha 标签页调整尺寸后,beta 标签页的副本也是新尺寸;beta 随后保存语言,文件里的尺寸仍是新值。settingswindow/ui_baseline_test.go:TestBaselineSettingsControlsFitReferenceWindow的参考窗口改为 1270×700。功能矩阵与截图
shared/platform-feature-matrix/features/application-settings.json:controller.go、window_size_test.go、app.go、window_sessions_test.go;partial/pending。docs/assets/settings-window-size/:改动前后的无头截图各 2 张,见下方“UI 验证”。不在本 PR 范围内 / Out of scope
refactorIssue):每个项目标签页各持一份设置并整份保存,一个标签页改了语言、主题等,另一个标签页之后保存别的设置时会写回旧值。本 PR 只让新增的窗口尺寸字段在各标签页间同步,没有处理其他字段。类型专属:fix
复现与根因
0faecba49)起,尺寸在window.go写死为windowWidth, windowHeight = 900, 700,没有接OnFrameChange,也没有任何持久化;feat(desktop): 按 macOS 基线对齐 Viva 工作台与设置界面 #1849(90d816dd6)只调整了最小高度(668)。desktop/internal/settingswindow与desktop/internal/workbench的 Go 实现)。检查项
Values.WindowWidth/WindowHeight、Options.WindowResized和Controller.ResizedWindow,在修复前的代码上编译不过;修复前的行为是无论传什么都按写死的 900×700 打开(旧版TestBaselineSettingsControlsFitReferenceWindow断言的正是 900x700)。测试路径见上方“测试”。settingsWindow.Close()原有 2 处调用全部改为closeSettingsWindow();Values/Options新字段都是可选的,其他构造处不受影响;没有插件、SDK、脚本或按字符串分发的调用。Options.WindowResized、closeSettingsWindow的文档注释里,并由上述测试锁住,不构成需要单独记录的架构决策。范围检查 / Scope checks
功能矩阵 / Feature matrix
shared/platform-feature-matrix/features/application-settings.json:两端状态保持partial/pending,证据路径和验证动作已补充。./scripts/platform-feature-matrix/verify-platform-feature-matrix.sh和./scripts/platform-feature-matrix/verify-platform-feature-matrix-change.sh origin/main HEAD。.artifacts/下生成的矩阵视图。插件归属 / Plugin ownership
develop-lithe第三节的自查命令,结果为空。UI 验证 / UI evidence
LITHE_VISUAL_OUTPUT_DIR=<dir> scripts/desktop/desktop-go.sh test -tags 'vivahead lithevisual' ./internal/settingswindow -run 'TestVisualSettings/(20-settings-general|28-plugins-installed)-(dark|light)' -count=1,中文,2× 渲染。改动前截图是把默认尺寸临时改回 900×700 生成的(1800×1400 px),改动后是 1270×700(2540×1400 px)。docs/assets/settings-window-size/并嵌入下表。改动前插件详情标题被截断为“Editor Shortcut Im…”,改动后完整显示。
统一日志系统 / Structured logging
N/A:没有新增生命周期里程碑、操作终态或失败路径。尺寸经已有的
saveSettings保存,保存失败仍由它记录settings_save并提示用户。界面文案 / i18n
node scripts/i18n/verify-app-language-localization.mjs和node scripts/i18n/generate-i18n.mjs --check,均通过。逻辑归属 / Logic placement
性能与内存 / Performance and memory
saveSettings;它在 UI 线程同步写settings.json,这是既有问题 [Feature] Viva 工作台保存设置时在 UI 线程同步写 settings.json,改为后台串行写入 #2021,本 PR 没有新增写入路径。设置 / Settings
N/A:没有新增或修改设置项和设置页。窗口尺寸是布局偏好,存在应用设置文件里,不在设置页显示,也不对应任何外部工具的配置。
插件契约 / Plugin contract
N/A:不涉及插件契约、能力版本或宿主方法。
发行包与资源 / Bundle and resources
./scripts/desktop/verify/verify-runtime-bundle-immutability.sh,通过。无用代码与重构 / Dead code and refactoring
refactor标签的 Issue:[Feature] 统一 Viva 应用偏好所有权与多窗口发布,避免独立快照继续使用或覆盖旧设置 #1851(未重复建单)。验证 / Verification
scripts/desktop/desktop-go.sh test ./... -count=1(在加入标签页同步之前跑的全量)scripts/desktop/desktop-go.sh test ./internal/settingswindow ./internal/workbench -count=1(加入标签页同步之后)scripts/desktop/desktop-go.sh test -race ./internal/settingswindow -run 'TestWindowOpensAtTheSizeTheUserLastGaveIt|TestClosingKeepsTheSizeTheUserGaveTheWindow|TestResizedWindowGivesTheSizeBeforeTheWindowCloses|TestBaselineSettings|TestGeneralNarrowWindow'scripts/desktop/desktop-go.sh test -race ./internal/workbench -run 'TestSettingsWindowSizeIsEveryProjectTabs|TestSettingsWindowSizePersistsWithOtherSettings|TestMarketplaceWidthPersistsWithOtherSettings|TestThisWindowOpensTheProjectInAProjectTab|TestClosingAProjectTabShowsTheNextTab|TestClosingTheWindowClosesEveryProjectTab' -count=3TestVisualSettings(见 UI 验证)./scripts/platform-feature-matrix/verify-platform-feature-matrix.sh./scripts/platform-feature-matrix/verify-platform-feature-matrix-change.sh origin/main HEADnode scripts/i18n/verify-app-language-localization.mjs、node scripts/i18n/generate-i18n.mjs --check./.agents/skills/write-stable-tests/scripts/verify-test-stability.sh(含--base origin/main)rg(develop-lithe 第三节)./scripts/desktop/verify/verify-runtime-bundle-immutability.shgofmt -l未能执行的检查和原因:
app.Driver模拟 Resize、MoveWindow 和 Close,不等于原生窗口验收。提交前确认 / Final checks
main创建,目标分支为main。