[Feature] 清理插件视图渲染器中从未读取的 ui.C 字段

Open Beginner friendly
#2,365 0 comments 0 reactions 0 assignees View on GitHub

Maintainers usually reply within 1 day

Nobody has claimed this yet.

Assessment

Difficulty
1/5
Estimated time
Under an hour
Newbie friendliness
84/100
Issue type
Refactor
Clarity
Clearly specified
Activity status
Active
Tech stack
go
Domain
desktop

Research direction

Open desktop/internal/pluginview/render.go, find the renderer struct with the c ui.C field and the constructor that assigns it in Draw. Confirm no reads of r.c exist inside the desktop/internal/pluginview/ package, then delete the field and its assignment, leaving the per-frame c parameter passing untouched. Done looks like the package builds and its targeted tests plus Viva vet report no kept-context diagnostic for that field; leave the Host.Info func(c ui.C, text string) callback alone.

Written by the indexing model from the issue text.

Description

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

desktop/internal/pluginview/render.go 的 renderer.c ui.C 字段在 Draw 构造 renderer 时赋值,但没有读取方。绘制函数已经逐层传递当前帧的 c 参数。它让 Viva vet 产生 kept-context 诊断,也让维护者误以为渲染器需要保存当前绘制上下文。

判定依据:在基线 c086a0b1b2cb1ce231ee34e94f023a7078f5ab05 与当前工作区检查 renderer 的定义、构造以及整个 desktop/internal/pluginview/ 包的接收者方法,只有字段声明和构造赋值。全仓库检索 r.c 与 renderer{ 没有此字段的读取,也没有通过反射或字符串访问该字段的路径;字段和类型都未导出。

这是已有的无用字段,不是跨帧保存上下文已经造成运行崩溃的证据。每帧都会新建 renderer。

Proposed solution / 建议方案

移除 renderer.c 及构造中的赋值,保留现有按参数传递 ui.C 的方式。运行插件视图包的定向测试及 Viva vet,确认这一条诊断消失。

风险较低,但不要把同一文件的 Host.Info func(c ui.C, text string) 回调类型也当成保存了当前帧的上下文;它不持有某个 ui.C 实例,应单独识别扫描误报。

Target platform / 目标平台

Cross-platform / 跨平台

Area / 模块

UI / 界面

Priority / 优先级

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

Alternatives considered / 已考虑的替代方案

保留字段并忽略 vet 警告,会继续保留无用引用和误导。给 renderer 添加跨帧上下文语义没有需求,且违反 ui.C 的帧生命周期约束。不在这次 Key/Part 兼容修复中混入已有字段清理。

Additional context / 补充信息

在审计 #2285 后的 Viva API 迁移时发现。此为源码清理建议,目标是 macOS/Windows 共用的 Go Viva 渲染器;不依赖真实插件、系统配置或用户项目,不需要采集操作系统、硬件和个人日志,也没有声明目标平台的原生运行验收已完成。

当前 Viva 固定版本为 github.com/Lithe-IDEA/viva v0.6.8-0.20261123134538-bb85256c8ffa。本建议只涉及宿主内部渲染器,不改变插件契约。

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

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.