Skip to content

fix(win32): hide the tab-strip chrome when the tab bar is disabled (#244) - #245

Merged
amanthanvi merged 2 commits into
mainfrom
fix/win32-hidden-tab-bar-residue
Sep 16, 2026
Merged

amanthanvi merged 2 commits into
mainfrom
fix/win32-hidden-tab-bar-residue

Conversation

@amanthanvi

@amanthanvi amanthanvi commented Sep 16, 2026

Copy link
Copy Markdown
Owner

Summary

With window-show-tab-bar = never, the tab strip's chrome children stayed
visible as 1 px windows at the top of the client area and painted themselves
over the terminal from the second tab onwards. This hides them, and keeps the
hide/re-show correct across a runtime config reload.

Fixes #244

Root cause

Host.tabBarHeight() returns 0 for .never, but the tab strip is made of
real child HWNDs and Host.layoutChromeForRect laid every one of them out
visible regardless. With a zero-height strip that means
button_height = @max(1, tabBarHeight() - scaled(6)) == 1 and
action_y = @max(0, ...) == 0, so each tab button, the UIA Selection
container and the [+] / [▾] cluster became a one-pixel-tall window at
y = scaled(3) and owner-drew itself there — the active tab button's border
is theme.accent, which is the blue line in the report. The host carries
WS_CLIPCHILDREN, so the parent's band paint can never erase a child rect,
and the existing tab_h > 0 gate in paintChromeTabBar only covers what the
parent paints.

It looks tab-dependent because of z-order. Measured live with
EnumChildWindows (topmost first): the first tab's noctty.win32 surface is
at z=0, above all of the chrome, so it covers the residue; the second tab's
surface lands at z=6, below the chrome children at z=1..5, so from the second
tab on the residue shows.

Two consequences beyond the pixels: focusableHwnd keys off
IsWindowVisible, so the strip's tab buttons and [+] / [▾] were live
F6 focus targets, and UIA exposed them as TabItem / Button
elements with the tab bar off.

Fix

  • layoutChromeForRect decides the strip's visibility once
    (tab_strip_visible = shouldShowTabBar()) and gates every strip child on
    it through a new pure tabStripChildVisible(tab_bar_visible, in_strip):
    tab buttons, the Selection container, [+] and [▾]. A hidden strip also
    leaves active_tab_left null, so a tab switch no longer retargets the
    focused-tab underline or arms its 16 ms slide heartbeat for a line that is
    never painted.
  • shouldShowTabBar now shares tabBarVisibleForConfig with
    App.reconfigureTheme, which relayouts a host when the tab-bar visibility
    changes and not only when the integrated-titlebar frame mode flips. On
    Win11 the two always coincide for this setting; below build 22000 the
    frame mode never moves, so the reload path needed its own trigger.
  • Second commit, from review: a hidden strip is alive but not on screen, so
    ChromeControlProvider now requires IsWindowVisible before claiming
    IsKeyboardFocusable (the painted caption buttons already reason this
    way), and notifyActiveTabUiaSelectionChanged plus the NameChanged
    raise in syncTabButtons are gated on shouldShowTabBar() rather than
    doing cross-process COM raises for elements that are not in the UIA tree.
    The [+] / [▾] rect keeps being applied while hidden -- the visibility
    gate alone fixes the residue, and showOverflowMenu anchors its popup to
    GetWindowRect(overflow_hwnd) -- and both buttons go through
    tabStripChildVisible like the rest of the strip.

How verified

Built with zig build -Demit-exe=true and driven headlessly (no foreground
stealing) with a Python + ctypes harness: launch with --config-file holding
the reporter's config, WM_COMMAND 1904 / 1907 / 1908 for new tab / previous
tab / next tab, EnumChildWindows for the objective state, PrintWindow and a
screen BitBlt for pixels.

Before (05a9c47), never, two tabs, tab 2 active — every strip child
visible at 1 px:

z=1 id=1912 Static visible=1 rect=(0,4)-(660,5)      size=660x1
z=2 id=1904 Button visible=1 rect=(1460,4)-(1511,5)  size=51x1   text='+'
z=3 id=1911 Button visible=1 rect=(1517,4)-(1568,5)  size=51x1   text='▾'
z=5 id=1000 Button visible=1 rect=(0,4)-(330,5)      size=330x1  text='1: …cmd.exe'
z=7 id=1001 Button visible=1 rect=(330,4)-(660,5)    size=330x1  text='* 2: …cmd.exe'

The screen capture of that state shows the reported artifacts: a thin line
across the top-left of the terminal content and two short dashes at the top
right where [+] and [▾] are.

After, same steps (single tab, two tabs, both switch directions, and
maximized + switch): every one of ids 1000/1001/1904/1911/1912 reports
visible=0 at every stage, the only visible children are the terminal
surfaces, and the screen capture of the top band is clean.

Tab bar still works (window-show-tab-bar = auto, same harness): tab
buttons 330x51, [+] / [▾] 48x48, all visible, and the screenshot shows
the normal strip with the focused-tab underline.

Runtime config reload (Reload Config from the command palette, config
file rewritten between reloads, two tabs open):

start (never):            id=1000 visible=0, id=1001 visible=0, id=1904 visible=0, id=1911 visible=0, id=1912 visible=0
after reload -> auto:     id=1000 visible=1 h=51, id=1001 visible=1 h=51, id=1904 visible=1 h=48, id=1911 visible=1 h=48, id=1912 visible=1 h=51
after reload -> never:    id=1000 visible=0, id=1001 visible=0, id=1904 visible=0, id=1911 visible=0, id=1912 visible=0

UI Automation (raw view walk of the host element, two tabs open): with
never the tree now holds only the terminal Text element and the stock
caption; with auto it holds Tab "Tabs", Button "New tab",
Button "More tabs" and both TabItems, all still reporting
IsKeyboardFocusable = 1 (the never run has no such elements left to
report on). (The before-fix UIA tree was not captured; that the hidden HWNDs
used to be exposed is inference from the auto control plus the measured
visible=1 above.)

All of the live runs above were repeated on the review follow-up commit with
the same results; the [+] / [▾] rects now read as the current right-edge
position while hidden instead of the creation rect.

Tests — two added to src/apprt/win32.zig:

  • win32 tabStripChildVisible hides strip chrome when the tab bar is off
    (pure predicate, including tabBarVisibleForConfig).
  • win32 layoutChromeForRect hides tab-strip chrome when the tab bar is off
    — a live-HWND regression test: real tab-button / container / [+] / [▾]
    children under a real host window, layoutChromeForRect run with .never
    then .always, asserting IsWindowVisible, tabStripFocusHwnd(), the
    live [▾] rect and the restored button height. Verified it fails on the
    pre-fix behaviour (expected 0, found 1).
  • ChromeControlProvider hidden chrome is not keyboard focusable in
    src/apprt/win32_uia/widgets.zig — a real hidden window, asserting
    IsKeyboardFocusable false while hidden and true once shown. Also verified
    to fail without the provider change.

zig build test -Dtest-filter=ConPTY -Dtest-filter=strip → 92 passed, 4
skipped, 0 failed; -Dtest-filter=ChromeControlProvider → 80 passed, 4
skipped; wider sweeps -Dtest-filter=win32 → 1485 passed, 5 skipped and
-Dtest-filter=tab → 364 passed, 4 skipped, all with 0 failures (79 passed
with the ConPTY filter alone).

Not verified: anything on Windows 10 / builds below 22000, where the new
reconfigureTheme relayout trigger is the only thing that applies a
window-show-tab-bar reload — this machine is Windows 11 26200, where the
frame-mode flip already covered it.

AI assistance

Per AI_POLICY.md: this change was authored by an AI agent (Claude Code)
operating the maintainer's account with authorization. The agent reproduced
the bug on a build of main, diagnosed it, wrote the fix and the tests, and
collected all of the evidence above on Windows 11 26200. A separate
adversarial review pass (also AI) was run against the diff independently of
the author. Maintainer review of the diff, the root-cause explanation and the
before/after evidence is still to come; nothing here should be merged on the
strength of the agent's own account of it.

Summary by CodeRabbit

  • Bug Fixes
    • Fixed thin tab-bar artifacts appearing when the tab bar was configured to be hidden.
    • Tab buttons, overflow controls, and the new-tab button now hide and reappear consistently with the configured visibility.
    • Configuration reloads now immediately update the tab-bar layout, including on Windows 10.
    • Hidden tab-bar controls are no longer reported as keyboard-focusable, improving accessibility behavior.

)

`window-show-tab-bar = never` makes `Host.tabBarHeight()` return 0, but the
tab strip's chrome are real child HWNDs and `layoutChromeForRect` laid every
one of them out visible anyway. With a zero-height strip the tab buttons, the
UIA Selection container and the [+] / [v] cluster collapsed to
`button_height = @max(1, 0 - scaled(6))` -- one pixel -- at the top of the
client area and owner-drew themselves there; the active tab's accent border
is the blue line in the report. The host carries `WS_CLIPCHILDREN`, so the
parent's own band paint can never erase a child rect, and the already-correct
`tab_h > 0` gate in `paintChromeTabBar` only covers what the parent paints.
It looks tab-dependent because of z-order: the first tab's terminal surface
sits above all of the chrome and covers the residue, while every later tab's
surface lands below it.

Decide the strip's visibility once per layout and gate its children on it:
tab buttons, the Selection container and the [+] / [v] buttons are hidden
when the tab bar is off, which also drops them out of the F6 focus cycle
(`focusableHwnd` keys off `IsWindowVisible`) and out of the UIA tree, and a
hidden strip no longer retargets the focused-tab underline or arms its 16 ms
slide heartbeat. `App.reconfigureTheme` relayouts on a tab-bar visibility
change as well as on an integrated-titlebar frame-mode flip, so a config
reload that turns the strip on or off applies on builds where the frame mode
does not move.

@sourcery-ai sourcery-ai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Sorry @amanthanvi, you've used your own review budget of 250,000 diff characters for the last 7 days.

You can request another review in 21 hours and 43 minutes by commenting @sourcery-ai review. Upgrade to get a review now.

@coderabbitai

coderabbitai Bot commented Sep 16, 2026

Copy link
Copy Markdown

Review Change StackReview Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: ASSERTIVE

Plan: Advanced

Run ID: 94535ef3-dfbd-4907-bccf-420cc26f2661

📥 Commits

Reviewing files that changed from the base of the PR and between 1d3f6e3 and c2147f1.

📒 Files selected for processing (2)
  • src/apprt/win32.zig
  • src/apprt/win32_uia/widgets.zig

Included review availability: Your plan provides up to 2 included reviews per hour; 0 remain after this review.


📝 Walkthrough

Walkthrough

The Windows implementation tracks tab bar visibility, relayouts chrome after configuration changes, hides tab-strip child windows when disabled, updates UIA state, and adds Windows-only regression tests. AGENTS.md records the defect cause and investigation findings.

Changes

Tab bar visibility correction

Layer / File(s) Summary
Visibility state and helpers
src/apprt/win32.zig
Shared helpers map configuration values to tab bar and child visibility. Host stores the applied state. Tests cover the helper combinations.
Chrome relayout and child window gating
src/apprt/win32.zig
Theme reconfiguration relayouts chrome when visibility changes. Tab buttons, the tab container, overflow controls, and the new-tab button are hidden when the tab bar is disabled. Tests cover reload behavior and the 1 px residue regression.
UIA visibility and event gating
src/apprt/win32.zig, src/apprt/win32_uia/widgets.zig, AGENTS.md
Hidden controls no longer report keyboard focusability or emit tab-related UIA events. The self-correction log records the defect cause and investigation findings.

Priority: ➖ Normal

Estimated code review effort: 3 (Moderate) | ~25 minutes

Change: Bug fix · Severity of issue fixed: Medium

Suggested reviewers: nanasess

Merge Risk: ⚪ Minimal · up to c2147

The tab-strip controls now follow the disabled tab-bar configuration, including runtime restoration, without an identified merge-blocking regression.

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Linked Issues check ✅ Passed Issue #244 requires no visible tab-bar residue when window-show-tab-bar = never. src/apprt/win32.zig hides tab buttons, the tab container, overflow, and new-tab controls when the shared visibility…
Out of Scope Changes check ✅ Passed The changes stay within issue #244. The implementation, UI Automation and focus handling, configuration-reload handling, regression tests, and AGENTS.md documentation all support removal of tab-bar …
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check. Docstring coverage is scoped to functions touched by this diff. Analyzed 0 functions across 0…
Title check ✅ Passed The title clearly and concisely describes the main change: hiding Windows tab-strip chrome when the tab bar is disabled.
Description check ✅ Passed The description is detailed and directly addresses the bug, root cause, fix, validation evidence, tests, and known follow-up coverage. It does not use the template's exact Validation checklist or Risk…
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/win32-hidden-tab-bar-residue

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@sourcery-ai

sourcery-ai Bot commented Sep 16, 2026

Copy link
Copy Markdown

Reviewer's Guide

The PR fixes Win32 tab-bar-off rendering and accessibility artifacts by explicitly hiding every tab-strip child HWND, updating host layout on runtime visibility changes, and adding pure and live-window regression tests for hide/show and focus behavior.

Sequence diagram for tab-bar visibility during layout

sequenceDiagram
    participant Config as Runtime config
    participant App
    participant Host
    participant HWNDs as Tab-strip child HWNDs

    Config->>App: reconfigureTheme()
    App->>App: tabBarVisibleForConfig()
    App->>Host: layout()
    Host->>Host: shouldShowTabBar()
    Host->>Host: tabStripChildVisible(tab_bar_visible, in_strip)
    Host->>HWNDs: applyChildVisibility(visible)
    alt tab bar disabled
        Host->>Host: leave active_tab_left null
        Host->>HWNDs: Hide tab buttons, Selection, [+], [▾]
    else tab bar enabled
        Host->>HWNDs: Position and show strip children
    end
Loading

File-Level Changes

Change Details Files
Gate all tab-strip child HWNDs on the configured tab-bar visibility instead of relying on the strip's zero height.
  • Added shared configuration visibility helpers and applied them to tab buttons, the selection container, and new/overflow controls.
  • Avoided retargeting the active-tab underline when the strip is hidden, preventing unnecessary slide-heartbeat work.
  • Preserved normal child placement and visibility when the tab bar is enabled.
src/apprt/win32.zig
Relayout hosts when a runtime configuration reload changes tab-bar visibility.
  • Tracked the last applied tab-bar visibility in App.
  • Included tab-bar visibility changes in the chrome-layout reload trigger, including platforms where frame mode does not change.
src/apprt/win32.zig
Added regression coverage for hidden and restored tab-strip HWND state.
  • Tested the pure visibility predicates for always, auto, and never configurations.
  • Added a live HWND test asserting hidden children and no tab-strip focus target, then asserting visibility and dimensions are restored.
src/apprt/win32.zig
Documented the HWND visibility, z-order, focus, UIA, and reload-related root causes and validation traps.
  • Recorded the one-pixel child-window failure mechanism and the platform-specific reload consideration in the self-correction log.
AGENTS.md

Assessment against linked issues

Issue Objective Addressed Explanation
#244 Prevent tab-bar child controls, including tab buttons, the tab container, new-tab button, and overflow menu button, from leaving visible 1-pixel chrome or painting artifacts when window-show-tab-bar = never.
#244 Ensure the hidden tab-bar controls are not exposed as focusable or UI Automation targets, and avoid tab underline updates when the tab bar is disabled.
#244 Correctly restore tab-bar visibility and layout when the window-show-tab-bar setting changes through a runtime configuration reload.

Possibly linked issues


Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it. You can also reply to a
    review comment with @sourcery-ai issue to create an issue from it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time. You can also comment
    @sourcery-ai title on the pull request to (re-)generate the title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time exactly where you
    want it. You can also comment @sourcery-ai summary on the pull request to
    (re-)generate the summary at any time.
  • Generate reviewer's guide: Comment @sourcery-ai guide on the pull
    request to (re-)generate the reviewer's guide at any time.
  • Resolve all Sourcery comments: Comment @sourcery-ai resolve on the
    pull request to resolve all Sourcery comments. Useful if you've already
    addressed all the comments and don't want to see them anymore.
  • Dismiss all Sourcery reviews: Comment @sourcery-ai dismiss on the pull
    request to dismiss all existing Sourcery reviews. Especially useful if you
    want to start fresh with a new review - don't forget to comment
    @sourcery-ai review to trigger a new review!

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

@greptile-apps

greptile-apps Bot commented Sep 16, 2026

Copy link
Copy Markdown

RetriggerConfidence Score: 5/5

The PR appears safe to merge; no actionable regression or outstanding blocking issue was identified.

Summary

This PR fixes hidden Win32 tab-strip controls remaining active and painting one-pixel artifacts when window-show-tab-bar is disabled.

  • Gates tab buttons, the selection container, and tab actions on tab-bar visibility.
  • Relayouts hosts when a runtime configuration reload changes tab-bar visibility, including where integrated-titlebar mode remains unchanged.
  • Aligns keyboard focus and UI Automation state with actual child-HWND visibility.
  • Adds focused Win32 regression coverage for hiding and restoring the strip.
Diagram
%%{init: {'theme': 'neutral'}}%%
flowchart LR
    C[Tab-bar configuration] --> V[Compute strip visibility]
    V --> L[Relayout host chrome]
    L --> T[Tab buttons and selection container]
    L --> A[New-tab and overflow controls]
    V --> U[UI Automation and focus eligibility]
    T -->|hidden| H[No child-window paint]
    A -->|hidden| H
Loading

Reviews (2) · Last reviewed commit: "fix(win32): stop announcing and focusing..."

Review follow-up to hiding the tab-strip chrome. The HWNDs are hidden but
still alive, and three things kept treating them as live UI.

`ChromeControlProvider` reported `IsKeyboardFocusable` from the role alone,
so the hidden tab buttons and the [+] / [v] cluster still claimed to be
keyboard focus targets while the host's focus-region cycle -- which filters
candidates through `focusableHwnd`, i.e. `IsWindowVisible` -- would never
land on them. It now requires the HWND to be visible, matching the reasoning
already applied to the painted caption buttons.

`notifyActiveTabUiaSelectionChanged` and the `NameChanged` raise in
`syncTabButtons` fired on every tab switch and every retitle with the strip
hidden: cross-process COM raises for elements that are not in the UIA tree.
Both are gated on `shouldShowTabBar()`; the label and name caches are still
committed, so the strip is correct the moment it comes back.

`layoutChromeForRect` also keeps applying the [+] / [v] rect while the
cluster is hidden -- the visibility gate alone fixes the residue, and
`showOverflowMenu` anchors its popup to `GetWindowRect(overflow_hwnd)`, so
the rect must not fall behind the window. Both buttons now go through
`tabStripChildVisible` like the rest of the strip.

@sourcery-ai sourcery-ai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Sourcery assessment

Approved.

@amanthanvi
amanthanvi merged commit d29ba22 into main Sep 16, 2026
7 checks passed
@amanthanvi
amanthanvi deleted the fix/win32-hidden-tab-bar-residue branch September 16, 2026 03:28
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.

bug: residue from tab bar exist even though it's disable

1 participant