Skip to content

test(tui): stop sidebar tests from reading the checkout's git branch - #4231

Merged
aheritier merged 1 commit into
mainfrom
test/sidebar-git-seam
Sep 11, 2026
Merged

test(tui): stop sidebar tests from reading the checkout's git branch#4231
aheritier merged 1 commit into
mainfrom
test/sidebar-git-seam

Conversation

@aheritier

Copy link
Copy Markdown
Collaborator

Why

The first merge-queue run (34500467587) failed TestSidebar_HandleClickType_Usage_Collapsed_SharedLine and TestRoutedTimerExpiryDrivesSidebarOnOwnerPage on Linux and Windows. sidebar.New reads os.Getwd() and the git branch of that directory; in CI that is the repository checkout. On PR runs HEAD is detached (short commit), on main the branch is main, and in the merge queue it is the 60-character gh-readonly-queue/main/pr-4218-<sha>, which wraps the collapsed sidebar over a dozen lines and shifts every row the two tests assume. They had been passing by luck of a short branch name.

What

  • sidebar.SetWorkingDirectoryForTesting(dir, branch) swaps the three process reads (os.Getwd, gitbranch.Current, gitbranch.Watch) for fixed values and disables the branch watcher; it returns a restore function.
  • TestMain in pkg/tui/components/sidebar, pkg/tui/page/chat and pkg/tui (the three packages that construct a sidebar) pins /work/app with no branch.
  • TestNewIgnoresProcessGitState documents the pin.

Verified locally: injecting the merge-queue branch name through the seam reproduces the sidebar click failure; with the pin, go test ./pkg/tui/... passes, task lint is clean.

Not in this PR: a long branch name still wraps the collapsed sidebar for real users. Truncating it to the available width is a product change worth its own issue.

@aheritier
aheritier requested a review from a team as a code owner September 10, 2026 16:48
@aheritier
aheritier enabled auto-merge September 10, 2026 16:56
@aheritier aheritier added area/tui For features/issues/fixes related to the TUI kind/test Test-only changes labels Sep 10, 2026
sidebar.New reads os.Getwd() and that directory's git branch. In CI that is
the repository checkout, and in the merge queue the branch is the 60-char
gh-readonly-queue/main/pr-<n>-<sha>, which wraps the collapsed sidebar and
shifts every row two layout tests assume (they passed on PRs and main only
because the branch there was short).

SetWorkingDirectoryForTesting swaps the three process reads for fixed values
and disables the branch watcher; TestMain in the three packages that build a
sidebar pins /work/app with no branch. A regression test documents the pin.
@aheritier
aheritier force-pushed the test/sidebar-git-seam branch from 6e085d1 to caee81a Compare September 10, 2026 17:02
@aheritier
aheritier added this pull request to the merge queue Sep 11, 2026
@github-merge-queue
github-merge-queue Bot removed this pull request from the merge queue due to Branch Protection failures Sep 11, 2026
You're not authorized to push to this branch. Visit "About protected branches" for more information.
@dgageot
dgageot added this pull request to the merge queue Sep 11, 2026
@github-merge-queue
github-merge-queue Bot removed this pull request from the merge queue due to Branch Protection failures Sep 11, 2026
You're not authorized to push to this branch. Visit "About protected branches" for more information.
@aheritier
aheritier added this pull request to the merge queue Sep 11, 2026
Merged via the queue into main with commit df8fc88 Sep 11, 2026
14 checks passed
@aheritier
aheritier deleted the test/sidebar-git-seam branch September 11, 2026 08:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area/tui For features/issues/fixes related to the TUI kind/test Test-only changes

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants