Skip to content

feat(editor): Viva 右键复制符号与代码行引用 (#2015) - #2043

Closed
lithe-support[bot] wants to merge 6 commits into
mainfrom
lithe-support/issue-2015-copy-reference-viva
Closed

lithe-support[bot] wants to merge 6 commits into
mainfrom
lithe-support/issue-2015-copy-reference-viva

Conversation

@lithe-support

@lithe-support lithe-support Bot commented Nov 16, 2026

Copy link
Copy Markdown
Contributor

关联 Issue / Linked issue

PR 类型 / Type

  • feat:新功能或用户可见的改进

改动说明 / What changes

背景 / Why

编辑器右键原先缺少复制当前代码引用的入口。Core #70 新增通用符号引用格式化接口;本 PR 将它接入 macOS/Windows 共用的 Viva 编辑器。

改动 / Changes

  • 编辑器右键添加共享 i18n「复制源码位置 / Copy Source Location」入口,使用右键实际落点而非旧光标。
  • 同步的 documentSymbols 返回包、类、方法、签名时生成 com.example.DemoClass#goHome(String,Integer)#L137;没有可靠符号时返回 文件路径#L137。
  • 优先使用当前修订的 Structure 符号缓存;否则走已有 LSP 请求及取消机制;无服务、同步未完成时回退。
  • 只在请求的项目、文档、文本修订仍有效时写入剪贴板;用新操作 token 抑制旧答复。
  • 新增 desktop/internal/core/reference_location.go 作为 Rust Core JSON 桥接;固定依赖 Core lithe 0.2.1 #70 的 7836c6c(在 Core 合入后必须换成 main 上的正式 SHA)。
  • 添加 Go 测试、Viva Headless 测试(深/浅 × 中文/英文;右键菜单及通过快捷键真实粘贴的截图)、跨平台功能矩阵和中文 Agent Note。

不在本 PR 范围内 / Out of scope

不引入语言专用源码分析器、不修改 LSP 插件协议、不改变现有标签页的复制路径子菜单。


类型专属:feat

多平台对齐

  • 两端都具备:Viva/macOS 与 Viva/Windows 使用同一份实现(原生整机待验)。

范围检查 / Scope checks

功能矩阵 / Feature matrix

  • 新增 shared/platform-feature-matrix/features/editor-copy-reference-location.json,两端实现状态和验证状态分别列示;原生均为 pending。
  • 完整矩阵和变更门禁尚待 CI 确认。
  • 无 .artifacts 产物提交。

插件归属 / Plugin ownership

  • 没有特定插件 ID、插件包或插件实现依赖,复用现有通用 LSP documentSymbols 事件和合成测试会话。
  • 归属静态脚本待 CI 确认。

UI 验证 / UI evidence

  • 增加 TestVisualCopyReferenceLocation,覆盖 dark/light × zh-Hans/en,真实菜单及粘贴行为。
  • 实际 Headless 截图尚未生成和上传:当前执行环境无法编译/运行仓库,不能把新增测试源码当成执行证据;运行后应将 8 张 PNG 上传到 PR。
  • macOS/Windows 原生窗口验收尚未执行。

统一日志系统 / Structured logging

  • 复用 performed、backgroundFailed、operationFailed 的既有事件边界,不记录源码、引用内容或私密路径。
  • 完整日志门禁待执行。

界面文案 / i18n

  • 复用现有已生成的 native.copySourceLocation 中英文翻译,不硬编码或手动修改生成资源。

逻辑归属 / Logic placement

  • 引用格式规则在 Rust Core lithe 0.2.1 #70;Viva 只负责输入位置、LSP 调度、生命周期与平台剪贴板。
  • 不含特定语言/插件分支。

性能与内存 / Performance and memory

  • 按用户菜单操作按需执行,无常驻轮询/新依赖;不在 UI 线程同步执行 Core。

设置 / Settings

N/A:无新增设置。

插件契约 / Plugin contract

N/A:不修改插件契约、宿主方法或通知;独立的共享 Core 编辑器命令新增于 #70。

发行包与资源 / Bundle and resources

  • 没有运行时资源写入、缓存或额外下载物;截图仅测试运行时生成到 .artifacts。

无用代码与重构 / Dead code and refactoring

  • 未作无关重构。

验证 / Verification

命令或操作 平台 结果
Core #70 的 Rust Linux、Core gate、契约及 SDK CI Linux 最新 Core HEAD 7836c6c 均通过
scripts/desktop/desktop-go.sh test ./internal/workbench -run 'TestCopyReferenceLocation|TestEditorContextMenuCopiesReference' Linux 待桌面 CI 验证
LITHE_VISUAL_OUTPUT_DIR=.artifacts/issue-2015 scripts/desktop/desktop-go.sh test -tags 'vivahead lithevisual' ./internal/workbench -run '^TestVisualCopyReferenceLocation$' Linux Headless 未执行;截图未生成
node scripts/i18n/generate-i18n.mjs --check、功能矩阵门禁、插件归属门禁 Linux 待 CI
macOS / Windows 原生验收 原生 尚未执行

未能执行的检查和原因: 机器人仅有仓库文件写入及 CI 只读能力,运行环境的 GitHub DNS 不可达且未安装 Rust 工具链,因此不能本地克隆运行 Viva;Linux CI 是这次能得到的真实构建验证,不能冒充原生验收。

提交前确认 / Final checks

  • 从当时最新 main(7899acad)创建单独开发分支;目标 main。
  • Draft PR;未合并、未将用户账号用于写入。
  • 不含凭据、构建产物或原始用户代码。
  • 未启动任何 Lithe 应用进程,因而无残留待清理。

@ghfind-review ghfind-review Bot added the review: no-score ghfind author score missing (not zero) label Nov 16, 2026
@lithe-support

lithe-support Bot commented Nov 16, 2026

Copy link
Copy Markdown
Contributor Author

已由无冲突的替代 PR 接续

本 PR 创建时基于旧 main,与后续主分支在 scripts/desktop/build-desktop-core.sh 的 PINNED_CORE_REVISION 上发生冲突:主分支升级了工具链 Core,#2015 升级了复制引用 Core。仅选择其中一个 SHA 会丢掉另一项能力。

已使用 Lithe-Support Bot 从最新 main@c3e19dc 重新移植完整 #2015 改动,保留主分支工具链逻辑,并把 Rust Core #70 接口与当前 Core main 组合为 d00bc9f 供集成测试:替代 PR #2046 #2046 。GitHub 已确认该新 PR 可无冲突合并(mergeable=true)。

后续以 #2046 为准,本旧 PR 不再追加提交,以免重复 CI。新 PR 仍需通过自己的 CI 与无头截图验收;不自动合并。Lithe-Support 当前没有关闭旧 PR、更新分支基线或改 Draft/Ready 状态的写入动作,所以此处只标记为被替代,不把它误报为已关闭。

@1lck 1lck closed this Nov 16, 2026
xiaoyumuxi added a commit that referenced this pull request Nov 17, 2026
* feat(editor): port #2015 Viva copy-reference feature onto current main, preserving toolchain Core changes

* fix(editor): pin integrated Core with nullable symbol children support (#2015)

* chore(editor): pin formatted Core integration SHA for #2015

* fix(editor): 复制源码位置在文档已修改时清掉过期请求,去掉测试里的调试日志 (#2015)

符号回复到达时文档已改或已关,原来只清 pending 不清请求本身,过期请求一直挂着;
现在同时清掉,测试断言它不再残留。删掉 TestCopyReferenceLocationUsesLanguageSymbols
里排查用的 t.Cleanup 日志。

* fix(editor): 复制源码位置等待语言服务器符号设上限,右键位置随菜单关闭失效 (#2015)

- 语言服务器一直不回答时,最多等 3 秒(referenceSymbolsTimeout),之后取消请求、
  记录 editor_copy_reference_symbols 日志,按没有服务器时的规则复制文件路径和行号;
  回答到达或被新一次复制替换时停止计时。
- 右键坐标只属于它打开的那一次菜单:菜单画出后没选这一项就关闭,坐标丢弃,
  之后 Shift+F10 打开的菜单读取光标位置。
- 新增两个回归测试,修复前失败、修复后通过;更新 Agent Note 与功能矩阵说明,
  矩阵备注不再写 Core PR 待配套合入。

---------

Co-authored-by: lithe-support[bot] <356900028+lithe-support[bot]@users.noreply.github.com>
Co-authored-by: Yao Jingxi <23722032@bjtu.edu.cn>
@xiaoyumuxi
xiaoyumuxi deleted the lithe-support/issue-2015-copy-reference-viva branch November 20, 2026 01:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

review: no-score ghfind author score missing (not zero)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Feature] 复制当前类、方法、代码行的引用

1 participant