[Feature] Viva LSP 日志页签自存 500 行并在 Go 里筛选:改为通过 Core 查询统一 v2 日志,删除平台层缓冲与 filterLogLines

Open
#1,869 0 comments 0 reactions 0 assignees View on GitHub

Maintainers usually reply within 1 day

Nobody has claimed this yet.

Assessment

Difficulty
4/5
Estimated time
3-5 days
Newbie friendliness
25/100
Issue type
Refactor
Clarity
Mostly clear
Activity status
Active
Tech stack
go, rust
Domain
desktop, devtools

Research direction

Start in desktop/internal/workbench/lsp_status.go (recordServerEvent, filterLogLines) and pluginbackends.go (pluginServer.logs), then read desktop/internal/logstore/query.go for Store.QueryWindow and Subscribe. First confirm whether Core already writes plugin language-server log events to v2 logs with a per-server channel; if not, that Core work comes first. Done means the LSP tab reads through the log store, the buffer and filterLogLines are removed, and the tab still colors lines by level.

Written by the indexing model from the issue text.

Description

area:language enhancement P2 platform:cross-platform refactor review: high Rust Core
Problem to solve / 要解决的问题

Viva 桌面端(desktop/)的“LSP 日志”页签不读统一日志,而是在平台层自己保存一份日志并自己筛选,违反 develop-lithe 第三节“过滤、匹配、限额归 Core”的规则:

  • desktop/internal/workbench/lsp_status.go 的 recordServerEvent:收到 core.BackendEvent{Type: "log"} 后,在 Go 里拼接 Message/Detail、按 lspLogLineBytes 截断、把级别转成大写前缀,并维护每个服务器 500 行(lspLogLines)的环形缓冲(pluginServer.logs,定义在 pluginbackends.go)。
  • 同文件的 filterLogLines:页签的文本筛选在 Go 里做(去空格、忽略大小写的子串匹配)。
  • 桌面端日志窗口(desktop/internal/logwindow)已经通过 desktop/internal/logstore/query.go 的 Store.QueryWindow / Subscribe,把表达式、级别、通道前缀交给 Core 查询。LSP 页签没有走这条路径,等于同一类日志有两套存储和两套筛选规则。

判定依据:

  • 在 desktop/ 全仓库搜索 filterLogLines、lspLogLines、logsAdded,只命中 lsp_status.go 和 pluginbackends.go,没有走 Core 的版本。
  • origin/preview(540ca9eeb)上的 lsp_status.go 已经包含上述缓冲、截断和 filterLogLines,不是某个新 PR 引入的。
  • 旧 macOS 客户端(legacy 5a54c41aa)的 LSP 日志页签读取同一份脱敏 v2 记录,按 Core 解析的通道显示一个服务器,并且支持最低级别筛选(见 shared/platform-feature-matrix/features/lsp-status-logs.json 的 verification 记录)。

保留的代价:

  • 页签只能看到本次进程内存里最近 500 行,看不到已写入 v2 日志的历史,也不能按级别筛选。
  • 页签的文本筛选和日志窗口的过滤语言结果不一致。
  • 以后换 UI 壳子时还要重写这套缓冲和筛选。
Proposed solution / 建议方案
  1. 先确认 Core 是否已把插件语言服务器的日志事件写进 v2 日志,并给出能按服务器区分的通道,对应旧客户端的 diagnostics.resolveEngineLogSubject。缺这一项就先在 Lithe-core-rust 补上,并配好契约和 fixture。
  2. 把 LSP 日志页签改成用 logstore.Store.QueryWindow 读取当前会话、当前服务器通道的记录,再用 Subscribe 接收实时批次。
    • 文本筛选交给 Query.Expression。
    • 新增最低级别下拉框,交给 Query.Levels。
    • “清空视图”按服务器记录 AfterSequences 水位,不删文件。
  3. 删除 pluginServer.logs、logsAdded、lspLogLines、lspLogLineBytes 和 filterLogLines。recordServerEvent 只保留 stateChanged 的处理。
    • 页签按级别着色的逻辑保留在视图层,改为读取记录的级别。

风险:

  • 实时批次的格式化要做成增量,不能每次重新格式化全部记录(旧客户端 #1700 已经修过同类问题)。
  • 切换服务器、清空视图、停止和重启服务器后,水位要保持隔离。
  • Windows 上的日志目录要走平台存储 adapter,不能写安装目录。
Target platform / 目标平台

Cross-platform / 跨平台

Area / 模块

Language support / 语言服务

Priority / 优先级

P2 / 后续考虑:目前不着急,可安排到后续版本

Alternatives considered / 已考虑的替代方案

在平台层的 filterLogLines 里继续加级别筛选。这会扩大平台层逻辑,develop-lithe 第三节不允许,因此不采用。

Additional context / 补充信息

把 LSP 日志从弹窗改为普通编辑器页签的 PR 中发现了这个问题。那个 PR 只把 filterLogLines 的元素从字符串改成带级别的行,用来给行着色,匹配规则没变,也没有扩大平台层逻辑。相关跟踪单:#1662(Rust Core 下沉清单,覆盖旧双端,不含 Viva 桌面端这一处)。

Checklist / 提交前检查
  • I searched existing issues for duplicates. / 我已搜索现有 Issue,确认没有重复建议。
Dominant language
TypeScript
Stars
1.8k
Forks
151
Avg merge
3h 48m
Merged PRs (30d)
571

Getting set up

This project ships no dev container, Dockerfile or contributing guide, so setting up is up to you: start from its README, and see our first-contribution guide for the general steps.

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from 1lck/Lithe-IDEA

All issues in 1lck/Lithe-IDEA

Similar issues

More TypeScript issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.