[Feature] 整理共享布局的 Part/Key 身份归属以通过 Viva dev 检查

Open
#2,359 0 comments 0 reactions 0 assignees View on GitHub

Maintainers usually reply within 1 day

Nobody has claimed this yet.

Assessment

Difficulty
3/5
Estimated time
1-2 days
Newbie friendliness
50/100
Issue type
Refactor
Clarity
Mostly clear
Activity status
Active
Tech stack
go
Domain
desktop

Research direction

Start in desktop/internal/settingswindow/window_view.go (the breadcrumb function, where k.Part("sep") is passed to ui.Text) and in desktop/internal/workbench/chrome_view.go (stripe and stripeZone, where ui.Column receives a Key on a Spacer). Run TestGeneralAppearanceAppliesBeforeCloseAndRestore and TestThisWindowOpensTheProjectInAProjectTab with -tags dev to reproduce the identity panics. Done means both tests pass under -tags dev with the dev identity check still enabled, and real controls keep their identity.

Written by the indexing model from the issue text.

Description

refactor review: high
Problem to solve / 要解决的问题

当前 Viva dev 属性检查会拒绝没有身份的布局元素接收 Part/Key,宿主仍有既有布局调用不符合这个规则,导致受影响的无头开发测试在首次绘制时 panic,阻断功能验证。

可复核的两个位置:

  • desktop/internal/settingswindow/window_view.go 的 breadcrumb(面包屑绘制)将 k.Part("sep") 交给纯 ui.Text,触发 Part "sep" was given to a Text, which has no identity。
  • desktop/internal/workbench/chrome_view.go 的 stripe / stripeZone 复用上下文声明纯布局,在现有 TestThisWindowOpensTheProjectInAProjectTab 首帧触发 Key 3 was given to a Spacer, which has no identity;调用栈经过 stripeZone 的 ui.Column。

这些调用在源码基线 d8f55a50cc624ec4f928f7b6f5bbe731f147e351 已存在,文件关联新增控件之前即可触发。它们不是无用函数,需按 Viva 的身份契约整理布局调用,不能关闭开发检查掩盖。

Proposed solution / 建议方案

检查上述上下文的 Part/Key 归属,让身份只传给有身份的容器或控件;纯文本和占位布局使用不携带未消费命名的上下文。按相同模式检索设置和工作台,集中调整同因调用,并复用现有无头场景在 -tags dev 下验证。风险是错误地改变控件身份会丢失焦点、勾选、拖拽或滚动状态,需保留真实控件的稳定身份。

Target platform / 目标平台

Cross-platform / 跨平台

Area / 模块

UI / 界面

Priority / 优先级

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

Alternatives considered / 已考虑的替代方案

普通构建的受影响场景可通过,但不能代替 dev 属性检查。不采用关闭检查、扩大豁免或修改 Viva 来容忍宿主未消费身份的做法;本功能改动只修新增控件,既有布局适配独立处理。

Additional context / 补充信息

2026-11-23 在 macOS arm64 的源码构建中复现,使用宿主固定的 Viva v0.6.7-0.20261123062230-3c6c46081fe6。这是共享 Go 界面的适配建议,Windows 是否同样触发尚未原生运行;跨平台是建议修复范围,不代表已在 Windows 复现。

复现命令:

scripts/desktop/desktop-go.sh test -tags dev ./internal/settingswindow -run '^TestGeneralAppearanceAppliesBeforeCloseAndRestore$' -count=1 -timeout=30s
scripts/desktop/desktop-go.sh test -tags dev ./internal/workbench -run '^TestThisWindowOpensTheProjectInAProjectTab$' -count=1 -timeout=30s

已搜索 unusedName、has no identity、stripeZone 和 breadcrumb。已关闭的 #2285 涉及 Segmented.Label、Textarea.Mono、Row.Hover 与退出收尾,不包含本次纯布局 Part/Key 的触发点。

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.