Skip to content

fix(sidebar): keep the tab color strip clear of the tab icon - #632

Merged
Kuddev merged 5 commits into
Kuddev:mainfrom
GuangminJu:fix/sidebar-tab-strip-gap
Oct 16, 2026
Merged

Kuddev merged 5 commits into
Kuddev:mainfrom
GuangminJu:fix/sidebar-tab-strip-gap

Conversation

@GuangminJu

@GuangminJu GuangminJu commented Oct 13, 2026 •

Copy link
Copy Markdown
Contributor

Result / 用户结果

给标签设置颜色后,侧栏标签行左侧的色条紧贴着标签图标(默认界面字号下,色条右缘距内容起点只有 0.5px),看起来像图标的一部分,而不是独立的标签色标记。修复后色条贴住标签行左缘,与内容之间的间隙等于行内边距减去色条宽度,随界面字号一起缩放。图标、标题的位置以及它们与 TABS 折叠箭头的对齐都不变。

修复前后对比

界面字号 行内边距(px_2 = 0.5rem) 色条 x 色条右缘到内容起点
修复前 · 14px(默认) 7px 4 0.5px
修复后 · 10px(最小) 5px 0 2.5px(按公式推算,未截图)
修复后 · 14px(默认) 7px 0 4.5px
修复后 · 24px(最大) 12px 0 9.5px

原始截图:修复前 14px · 修复后 14px · 修复后 24px

(Windows 11、100% 缩放、Nord 主题下的实际窗口像素,对比图为 4 倍最近邻放大。修复前截自已安装的 2.2.0(2fde458)。修复后 24px 截自本 PR 当前 head。修复后 14px 截自本分支的中间版本,那一版在 14px 下的色条位置同样解析为 0,与当前 head 像素一致。)

Design / 设计边界

  • Responsibility and affected modules:只改 nebula_app/src/gpui_shell/workspace/sidebar.rs 中侧栏标签色条的水平位置:.left(px(4.0)) → .left_0(),并更新对应注释。
  • Why this belongs here; interfaces that remain unchanged:
    • 原因:GPUI 侧栏照搬了旧壳 display/chrome.rs 的色条左内缩 4,但旧壳的内容起点是 tab_x + 14(chrome.rs 中的 text_x)。GPUI 标签行的内边距是 px_2() = rems(0.5),rem 由 gpui-component Root::render 按 theme.font_size 设置(root.rs:555),默认 14px(theme.rs:775),设置里限定为 10–24px(nebula_settings/src/lib.rs:1191),所以内边距在 5–12px 之间。左内缩 4 时,色条到内容的间隙是 0.5rem − 6.5px:默认字号只剩 0.5px,最小字号下变成 −1.5px,色条会压到图标上。
    • 修复:色条贴住行左缘,间隙变为 0.5rem − 2.5px,在整个字号范围内为 2.5–9.5px,也不需要在渲染时计算。
    • 不变的部分:行内边距、图标和标题的位置、它们与 TABS 折叠箭头的对齐;色条的颜色、垂直位置、高度、圆角;顶部标签栏(底部横条)。
  • Review history:
    • 本 PR 第一版把 px_2() 换成了固定 8px,把它当成了固定像素值。评审指出这是错的,已撤回,感谢。
    • 还试过用 window.rem_size() 推出色条位置,保持固定 4.5px 间隙。结果在 24px 下色条悬在内边距中间,看起来像标题前多了一个 | 字符,没有采用。
  • Dependency, data-format, threading, or lifetime changes:无。
  • Compatibility and migration/fallback behavior:无持久化或配置变化。

Evidence / 验证依据

  • Commands and actual results:
    • cargo build --locked -p nebula --bin pebrel --features gpui-shell:通过(Windows 11,dev profile)。
    • rustfmt --edition 2024 --check nebula_app/src/gpui_shell/workspace/sidebar.rs:通过。
    • python scripts/check_architecture.py --base origin/main:通过(exit 0,只有与本改动无关的既有 tighten NOTICE)。
    • 本地未运行:cargo test 各套件(含 file_line_budget)、cargo clippy、i18n 合同测试、非 Windows 平台。上一版 head 的 CI 全部通过,当前 head 的 CI 待跑。
  • Regression tests:没有新增自动化测试。现有的 status-probe 测试用的是一行复刻的探针,测不到真实标签行;照这个方式给色条写测试,只是把同一份样式再抄一遍,真实行改了它也发现不了。效果以上面两个字号的真实窗口截图验证。
  • UI changes:已在 Windows 11、100% 缩放、Nord(深色)主题下,对选中行在 14px 和 24px 界面字号下目视验证。未检查:10px 界面字号(只按公式推算)、浅色主题、高 DPI 缩放、未选中行的 hover 态。
  • Hot-path changes:不适用。

Required Review / 必须确认

  • I followed CONTRIBUTING.md, docs/architecture.md, and docs/project-constraints.md.
  • I split responsibilities, not arbitrary line ranges; no duplicate behavior authority was added.
  • python3 scripts/check_architecture.py --base <PR-base-commit> passes; budgets were not inflated to fit the change.
  • Tests cover success and failure; platform/feature coverage limitations are stated. (未新增测试,原因与覆盖范围见上文 Evidence)
  • New messages use typed i18n IDs and matching placeholders; untranslated content has an explicit fallback. (不适用:没有新增文案)
  • Governance changes include a counterexample, corrected contract, tests, and a maintainer-reviewed decision. (不适用:没有治理改动)

🤖 Generated with Claude Code

The GPUI sidebar copied the legacy shell's color strip offset (left 4,
width 2.5), which the legacy shell paired with a 14px content inset. The
GPUI row pads its content by only 8px, so the strip ended 1.5px from the
tab icon and read as part of it.

Derive the strip offset from the row padding so the strip always keeps a
4.5px gap to the icon, and the two values cannot drift apart again. The
icon column and its alignment with the TABS disclosure arrow are unchanged.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@GuangminJu
GuangminJu requested a review from Kuddev as a code owner October 13, 2026 16:54

@Kuddev Kuddev left a comment

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Found a font-scaling regression in the otherwise focused strip-spacing fix. Reviewed the supplied Windows/Nord comparison and the exact pinned GPUI implementations; the screenshot covers one font size and does not establish that the icon/title positions remain unchanged. Please preserve the existing row-padding units before merging.

.overflow_hidden()
.gap_2()
.px_2()
.px(px(TAB_ROW_PAD_X))

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[P2] Preserve the existing rem-based row padding. In pinned GPUI a71e175, px_2() is generated as rems(0.5), not an unconditional 8 logical pixels (gpui_macros/src/styles.rs:948-951). Pinned gpui-component e95f47d sets each window's rem size from cx.theme().font_size in Root::render, and this application's theme.rs:775 uses the configured UI font size with a 14px default. Consequently this replacement moves the icon/title start from 7px to 8px at the default size, and from 12px to 8px at a 24px UI size, while the TABS/header padding still scales. This contradicts the stated unchanged-column scope and breaks alignment for custom font sizes. Keep the existing padding unit and derive the strip geometry from the actual resolved padding, including small-font bounds; check at least the default and an enlarged UI font size. This finding is from the actual style/Root/theme code, not an additional visual run.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, confirmed: px_2() is rems(0.5) and Root sets the rem size from theme.font_size, so the fixed 8px was wrong.

Fixed in 0102365. px_2() is restored and unchanged. The strip now sits at the row's left edge (.left_0()) instead of the legacy 4px inset, so its gap to the content is 0.5rem − 2.5px and scales with the UI font: 2.5 / 4.5 / 9.5px at 10 / 14 / 24px. I checked 14px and 24px in a real window; screenshots are in the updated description.

I also tried keeping a fixed 4.5px gap derived from window.rem_size(). At 24px the strip then floats inside the padding and reads like a glyph in front of the title, so I dropped that approach.

GuangminJu and others added 3 commits October 14, 2026 15:20
…row edge

The previous commit replaced `px_2()` with a fixed 8px padding on the
assumption that px_2 resolves to 8px. In pinned GPUI it is `rems(0.5)`,
and gpui-component's Root sets the rem size from the UI font size (14px
by default, clamped to 10-24px), so the padding is 7px at the default
size. The fixed value moved the icon column by 1px at the default size
and broke its alignment with the scaling TABS header at other sizes.

Restore `px_2()` and drop the legacy 4px inset: the strip sits at the
row's left edge, so its gap to the content is padding minus strip width
and scales with the UI font: 2.5px at 10px, 4.5px at 14px, 9.5px at
24px. A fixed gap was tried and rejected: at 24px the strip floated in
the padding and read as a glyph in front of the title.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@GuangminJu
GuangminJu requested a review from Kuddev October 15, 2026 07:05
Kuddev
Kuddev previously approved these changes Oct 16, 2026

@Kuddev Kuddev left a comment

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

复审已撤回旧版固定像素 padding 的问题。当前实现保留 px_2 的 rem 缩放,仅把色条锚定行左缘,10–24px 字号下几何间隙为 2.5–9.5px,图标和标题位置不移动。已检查作者提供的 Nord 14/24px 窗口对比图;独立高 DPI/浅色验收不在本次结论内。同步已审查的主线、#654 和 #658 后,该精确 head 的十项必需检查及已选 Native tests 均成功。采用清晰单一提交整合这项局部修复。

@GuangminJu
GuangminJu dismissed Kuddev’s stale review October 16, 2026 09:55

The merge-base changed after approval.

@Kuddev
Kuddev merged commit e73be0d into Kuddev:main Oct 16, 2026
16 checks passed
@GuangminJu
GuangminJu deleted the fix/sidebar-tab-strip-gap branch October 16, 2026 10:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants