Repository navigation
fix(macos): 日志列宽保持松手位置,LSP 日志按记录增量生成文本 - #1712
Merged
Merged
Conversation
- 日志表拖动扩展列松手后,把松手宽度反推成基准宽度保存,适配视口、 缩窄再放大和重开窗口后列仍停在松手位置,不再保存自动扩张的部分; 反推低于最小列宽时按比例放大其余扩展列的基准 - LSP 日志标签页按记录身份缓存输出文本,实时批次只格式化新增记录并 从开头截掉被淘汰的行,记录不变的发布不再重建全文 - 新增列宽回归测试与 LanguageServerLogTextTests;同步 Agent Note 与功能矩阵
xiaoyumuxi
marked this pull request as ready for review
November 4, 2026 04:57
This was referenced Nov 4, 2026
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.
概要
修复 #1700 合入后 lithe-code-review 报告的两个 P2 问题:
改动
1. 手动列宽松手后保持在松手位置(
LogWindowTable.swift)问题:表格把视口剩余宽度按基准宽度的比例分给事件、消息、字段三个扩展列。原来松手时,把扩展列的显示宽度直接存成基准宽度,下一次适配视口时又在上面加一份剩余宽度。例如约 1900pt 视口里事件列自动扩到约 483pt,拖到 493pt 松手后变成约 750pt,而且自动扩张的部分也被保存进偏好。
修复:
LogTableView新增adoptResizedWidths(previous:),把表头拖动后的宽度换算成基准宽度:Coordinator.commitColumnWidths改为只保存上面返回的基准宽度,然后重新适配。fitColumnsToViewport抽出expandingColumns和base两个辅助方法,与反推共用,适配算法本身不变。LogWindowModel新增columnWidth(_:),把原来两处min(2000, max(40, …))收成一个函数;表格的基准宽度使用同一个范围,保证布局用的值就是重开窗口恢复的值。结果:松手后、窗口缩窄再放大后、重新打开窗口后,列都停在松手的位置;窗口缩窄到没有剩余宽度时,显示基准宽度并横向滚动;调整窗口大小不写偏好。
2. LSP 日志按记录增量生成文本(
LanguageServerLogText.swift,新文件)问题:
LanguageServerLogOutput.output在每次LogWindowModel.state发布时,对最多 20000 条记录都执行一次map+joined(),状态、摘要、选中这类不改变记录的发布也一样,全部在主线程上。修复:
@MainActor final class LanguageServerLogText,由视图通过@StateObject持有,按记录身份逐条缓存。记录身份与LogWindowModel.recordID相同(路径、seq、时间戳)。LanguageServerLogText.line,输出与原来逐字节一致([LEVEL] 时间 消息,有字段时换行显示按键排序的k=v);时间格式样式只创建一次。LanguageServerLogsView改为调用text.update(logs.state.records),其他不变。原生输出控件OutputTextView本来就会对追加和截头做增量更新,这次只是去掉了它上游的全量字符串拼接。结果:每批的格式化次数等于新增记录数,与缓冲大小无关;不改变记录的发布一次都不格式化。
全量准备没有移到后台线程:整份重建只在打开标签页、切换服务器或级别、新查询时发生,频率与应用日志窗口首次查询时在主线程逐条准备显示内容相同。后台准备需要额外处理取消和过期结果,这次没有引入。
3. 文档与功能矩阵
2026-11-03-structured-logging-log-window.md:lsp-status-logs:补充新文件和测试作为证据,追加这次修复的验证说明。测试
LogWindowTests.draggedColumnsKeepTheirReleasedWidth(新增,覆盖评审要求的“自动扩宽后拖动,再缩窄、重开窗口”):isResizingColumns期间改宽度后提交,拖宽 10pt;LanguageServerLogTextTests(新增):验证
.agents/skills/write-stable-tests/scripts/verify-test-stability.shnode scripts/i18n/verify-app-language-localization.mjsnode scripts/i18n/generate-i18n.mjs --checkscripts/platform-feature-matrix/verify-platform-feature-matrix.shscripts/agent-notes/verify-agent-notes.shgit diff --checktest-stability-macos.sh -- --filter 'LanguageServerLogTextTests|LogWindowTests')正在本地编译运行(这个工作树需要从头编译 Rust Core)。结果出来后补充到这里,再标记 ready。限制