Skip to content

fix(sidebar): keep Hide default branch on when adding a project - #20393

Closed
jeongph wants to merge 2 commits into
stablyai:mainfrom
jeongph:feature/fix-keep-hide-default
Closed

jeongph wants to merge 2 commits into
stablyai:mainfrom
jeongph:feature/fix-keep-hide-default

Conversation

@jeongph

@jeongph jeongph commented Sep 12, 2026 •

Copy link
Copy Markdown
Contributor

ELI5

If you tell the sidebar to hide default-branch workspaces, adding a new project used to quietly switch that filter back off and open the new project's main at the bottom of the list. Now the filter stays exactly as you set it: the new project shows up as a project header (with its + to create a workspace), and its hidden main row stays hidden.

What Changed

  • Placeholder rule (empty-project-placeholder-repos.ts): a repo whose only live rows are default checkouts keeps its header while Hide default branch is on, the same way empty projects and filtered Project Group members ([Bug]: Project Group hides member projects when Hide sleeping filters their workspaces #8865) already do. Rows hidden by any other filter (Hide sleeping, host scope) do not earn a placeholder, so the [Bug]: Project Group hides member projects when Hide sleeping filters their workspaces #8865 policy for ungrouped projects is unchanged.
  • Add-project handoff (project-added-default-checkout.ts): when the default checkout is hidden by that filter, the handoff no longer flips the filter. It selects the project and issues revealSidebarRow for its header, so under Status / PR / None grouping the existing reveal hook switches to project grouping and scrolls there (same path as Cmd+J project selection). Telemetry: revealed_project with new reason default_checkout_hidden. A folder the user explicitly picked inside the checkout was their real target, so it still opens, with the existing "hidden by sidebar filters" toast.
  • Skip finalizer (add-repo-skip-finalization.ts): never resets the filter. The Hide-sleeping exemption flip is skipped only for imports the filter actually hides (isDefaultBranchWorkspace), so a detached-HEAD or provisioned-root main still gets the exemption instead of vanishing.
  • Removed the now-dead setHideDefaultBranchWorkspace parameter from the handoff and its callers; threaded hideDefaultBranchWorkspace into useSidebarSectionRows; dropped a stale doc comment whose rationale this change falsified.

Why

The filter is a row filter, but the handoff treated it as something it had to override to make the new project visible, because an ungrouped project whose only worktree is the default checkout had no sidebar presence under it. Keeping a header for that project (like an empty project) removes the reason to touch the user's setting at all, and unifies grouped vs. ungrouped behavior. Opening the hidden checkout with a toast was considered, but a user who hides default branches did not ask to land on one; the header with its create-workspace button is the natural next step.

Linked Issue

Fixes #20394

Visual Proof

Same flow in both: Hide default branch on, then add hidden-default-source (a repo whose only checkout is main) via the folder dialog. Headless Electron build driven over CDP (tests/e2e/add-project-hide-default-branch.spec.ts with a screenshot step).

Before After
before after
  • Before: the filter badge is gone (filter switched off), every project's main row is back, and the new project's main is opened.
  • After: the filter badge still shows 1 active filter, hidden-default-source lands as a header with no rows, the seeded project's main stays hidden, and the active workspace is unchanged.

Testing

Platform: macOS (local host). SSH / runtime hosts are covered by unit tests on the host-qualified handoff (colliding repo IDs across local and runtime:*), not by a live SSH session.

  • I manually tested these changes locally — headless Electron over CDP (screenshots above), plus the new E2E spec.
  • Automated tests added/updated:
    • empty-project-placeholder-repos.test.ts — default-checkout-only repo keeps its header under the filter; archived rows ignored; no placeholder when a non-default row is hidden by another filter, when a row is visible, outside repo grouping, or for a provisioned-root checkout; repo filter still applies.
    • add-repo-skip-finalization.test.ts — filter never reset; sleeping exemption skipped only for filter-hidden imports (branchless main still exempted).
    • project-added-default-checkout.test.ts — hidden checkout reveals the header (revealSidebarRow('repo:…'), no activation, no filter flip, no exemption flip); explicit subfolder still opens with toast; detached-HEAD and provisioned-root mains still open; colliding host IDs reveal once.
    • WorktreeList.empty-project-rows.test.ts — real render: header present, no card, no empty state.
    • telemetry-events.test.ts — new reason accepted by the strict schema.
    • tests/e2e/add-project-hide-default-branch.spec.ts — end-to-end: filter stays on, header renders, checkout row hidden and not activated.
  • pnpm typecheck, the changed-file code-quality gate, and the sidebar / telemetry / cmd-j suites (319 files, 2775 tests) pass locally.

AI Disclosure

Written with Claude Code (Claude Fable 5.1); reviewed with opus-model review agents (code, test coverage, comment accuracy). Their two real findings — the finalizer guard dropping detached-HEAD mains, and no landing spot outside project grouping — are fixed and covered by the tests above. All code was read and verified by me.

Review

  • Cross-platform: renderer-only; no paths, shortcuts, or process handling touched.
  • SSH / remote / local: the handoff keeps its executionHostId filtering; the hidden-checkout branch runs after host-qualified default-checkout selection, and the colliding-ID test proves one reveal per add. The placeholder reads worktreesByRepo across hosts, same as the existing zero-worktree rule.
  • Folder workspaces: not in the worktree filter pipeline; isDefaultBranchWorkspace is false for branchless rows, so they keep the old activation path.
  • Agents / integrations / git providers: not involved.
  • Performance: the placeholder check is one extra pass over repos inside an existing useMemo, keyed on the new flag.
  • UI: no new components or copy; the header and toast are existing surfaces. Users who keep the filter on now see headers for default-checkout-only projects instead of the "No workspaces found / Clear Filters" empty state (Clear Filters stays in the filter menu).
  • Security: none; no new IPC, storage, or network paths. The telemetry reason is an enum value under the existing .strict() schema.

Agent skill upstream boundary

  • Not applicable, or this change follows docs/reference/agent-skill-sharing-upstream-boundary.md and copies or mechanically translates no upstream skill-installer source, tests, fixtures, registry entries, path tables, comments, or documentation.

Notes

  • Revealing the header outside project grouping switches the sidebar to project grouping; that is the existing useSidebarRevealRequests behavior for project targets, not new logic.
  • Mobile has its own workspace list and no empty-project headers; untouched.
  • Backwards compatibility: add_repo_default_checkout_handoff gains one enum reason; no wire or persisted-state changes.

Checklist

  • This PR is small and focused
  • I explained what changed and why (including ELI5)
  • Before/after screenshots or videos attached for UI changes, or N/A with reason
  • Self-reviewed for correctness, security, and performance
  • Cross-platform, SSH/remote, and path/shortcut impact considered (or N/A)
  • pnpm lint, pnpm typecheck, pnpm test, and pnpm build pass (or CI will cover; local preferred)

🤖 Generated with Claude Code

Adding a project while "Hide default branch" was on silently turned the
filter off, because an ungrouped project whose only worktree is the
default checkout had no sidebar presence under that filter.

Treat the filter as hiding rows, not projects: a repo whose only live
rows are default checkouts keeps its header like an empty project, and
the add-project handoff reveals that header (revealSidebarRow, which
also switches non-repo groupings) instead of flipping the filter. An
explicitly picked folder inside the checkout still opens, with the
existing "hidden by sidebar filters" toast. The skip finalizer no
longer resets the filter and only skips the sleeping exemption flip
for imports the filter actually hides. The dead
setHideDefaultBranchWorkspace handoff parameter is removed.

Telemetry: new add_repo_default_checkout_handoff reason
default_checkout_hidden.
@coderabbitai

coderabbitai Bot commented Sep 12, 2026 •

Copy link
Copy Markdown
Contributor

Review Change StackReview Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Advanced

Run ID: c85f03aa-5b05-477b-9b1f-58b78f2557a4

📥 Commits

Reviewing files that changed from the base of the PR and between 3e50a08 and ef782c4.

📒 Files selected for processing (1)
  • tests/e2e/add-project-hide-default-branch.spec.ts
🚧 Files skipped from review as they are similar to previous changes (1)
  • tests/e2e/add-project-hide-default-branch.spec.ts

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


📝 Walkthrough

Walkthrough

The project-add flow no longer changes the default-branch filter during import. Sidebar row construction preserves project headers when hidden default checkouts are the only rows. Project-add handoff logic reveals project headers or opens selected hidden checkouts without changing filters. Tests cover import finalization, sidebar placeholders, telemetry, and end-to-end project creation.

Priority: ➖ Normal

Severity of issue fixed: Medium

Merge Risk: ⚪ Minimal · up to ef782

The reviewed change introduces no identified merge-blocking risk.

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 22.22% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 18 functions across 18 files. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description check ✅ Passed The description follows the required template and clearly explains the problem, changes, rationale, linked issue, visual proof, testing, AI disclosure, review considerations, and checklist status.
Title check ✅ Passed The title clearly and concisely describes the main change: keeping the Hide default branch filter enabled when adding a project.
Linked Issues check ✅ Passed Issue #20394 requires the Hide default branch filter to remain enabled when adding an ungrouped project whose only checkout is the default branch. The handoff now reveals the project header instead of…
Out of Scope Changes check ✅ Passed The changes stay within issue #20394. The telemetry reason, parameter removal, finalization changes, placeholder tests, handoff tests, and E2E cleanup support the add-project behavior or its test reli…
  • Fix all pre-merge checks with AI

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.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Actionable comments posted: 1


ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Advanced

Run ID: 42e12065-ef0d-411c-8d97-fef37f1e6c2d

📥 Commits

Reviewing files that changed from the base of the PR and between 403b62a and 3e50a08.

📒 Files selected for processing (20)
  • src/renderer/src/components/sidebar/AddProjectFromFolderDialog.test.tsx
  • src/renderer/src/components/sidebar/AddProjectFromFolderDialog.tsx
  • src/renderer/src/components/sidebar/AddRepoDialog.tsx
  • src/renderer/src/components/sidebar/ProjectAddedDialog.test.tsx
  • src/renderer/src/components/sidebar/ProjectAddedDialog.tsx
  • src/renderer/src/components/sidebar/WorktreeList.empty-project-rows.test.ts
  • src/renderer/src/components/sidebar/WorktreeList.tsx
  • src/renderer/src/components/sidebar/add-repo-skip-finalization.test.ts
  • src/renderer/src/components/sidebar/add-repo-skip-finalization.ts
  • src/renderer/src/components/sidebar/empty-project-placeholder-repos.test.ts
  • src/renderer/src/components/sidebar/empty-project-placeholder-repos.ts
  • src/renderer/src/components/sidebar/project-added-default-checkout.test.ts
  • src/renderer/src/components/sidebar/project-added-default-checkout.ts
  • src/renderer/src/components/sidebar/sidebar-filter-actions.ts
  • src/renderer/src/components/sidebar/use-complete-git-repo-add.ts
  • src/renderer/src/components/sidebar/visible-worktree-kinds.ts
  • src/renderer/src/components/sidebar/worktree-list/listing/use-section-rows.ts
  • src/shared/telemetry-events.test.ts
  • src/shared/telemetry-property-schemas.ts
  • tests/e2e/add-project-hide-default-branch.spec.ts
💤 Files with no reviewable changes (2)
  • src/renderer/src/components/sidebar/visible-worktree-kinds.ts
  • src/renderer/src/components/sidebar/AddRepoDialog.tsx

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

@pullfrog pullfrog Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

✅ No new issues found.

Reviewed changes

  • Placeholder scope — empty-project-placeholder-repos.ts keeps a Project header under repo grouping when hideDefaultBranchWorkspace is on and the repo's only live rows are default checkouts (hasOnlyDefaultCheckoutRows, which ignores archived rows). The new arg is threaded through use-section-rows.ts / WorktreeList.tsx with correct memo deps.
  • Handoff behavior — project-added-default-checkout.ts adds revealImportedProject and, when the found default checkout is hidden by the filter and no in-checkout path was picked, reveals the header (default_checkout_hidden) instead of flipping the filter. An explicit in-checkout subfolder still opens, with the existing filtered-notice toast.
  • Skip finalizer — add-repo-skip-finalization.ts no longer resets hideDefaultBranchWorkspace; it skips the sleeping-exemption flip only when the default filter already hides the import. setHideDefaultBranchWorkspace is removed from the contract and all prop plumbing.
  • Telemetry — default_checkout_hidden added to the reason enum, with schema coverage.
  • Tests — unit coverage for the placeholder rule, finalizer guards, handoff branches (reveal / subfolder / host collision / provisioned-root / detached-HEAD / hide-sleeping), WorktreeList rows, and a headless-Electron E2E that asserts the filter survives and the row stays hidden.

The load-bearing invariant holds: the placeholder header key matches getProjectHeaderRevealTarget(...).key, so the reveal does not fall through to useSidebarRevealRequests → clearFilters() and silently revert the filter. shouldFiltersHideAllRows also suppresses the empty state once a placeholder exists. The sleeping-exemption branch is correct because hideDefaultBranchWorkspace filters independently of isSleepingSweepExemptWorkspace, and branchless / provisioned-root mains are not hidden by it.

Pullfrog  | View workflow run | Using openrouter/deepseek/deepseek-v4.1-flash (free via Pullfrog for OSS) | 𝕏

…exits

afterEach runs before the electronApp fixture tears down, so removing the
temp repo could race Electron's watchers; on Windows that surfaces as an
EPERM that masks the real assertion. Register the removal with
registerPostElectronShutdownCleanup instead.

@pullfrog pullfrog Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

✅ No new issues found.

Reviewed changes (since the prior pullfrog review at 3e50a08)

  • E2E teardown hardening — tests/e2e/add-project-hide-default-branch.spec.ts now registers its temp-repo cleanup through the registerPostElectronShutdownCleanup fixture and awaits rm(root, { recursive: true, force: true, maxRetries: 5 }) instead of a synchronous test.afterEach + rmSync. That runs the deletion after the electronApp fixture releases watchers/daemons, which is the codebase-wide pattern, and avoids the Windows EPERM lock that could otherwise mask the real assertion. The fixture's electronApp-dependency ordering guarantees teardown order, and tempRoots.splice(0) makes the callback idempotent. Test-only; no product behavior touched.

Pullfrog  | View workflow run | Using openrouter/deepseek/deepseek-v4.1-flash (free via Pullfrog for OSS) | 𝕏

@OrcaWin

OrcaWin commented Sep 16, 2026

Copy link
Copy Markdown
Collaborator

Thanks @jeongph — we appreciate the work here.

We'll give you author credit for the commit. Closing this community PR in favor of the internal change: #20987

@OrcaWin OrcaWin closed this Sep 16, 2026
@cbrandao18

Copy link
Copy Markdown

@OrcaWin #20987 doesn't solve the original issue:
expected: when I toggle on "hide default branch", my local folders stay visible
actual: when I toggle on "hide default branch", my local folders get hidden

@jeongph
jeongph deleted the feature/fix-keep-hide-default branch October 17, 2026 13:13
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]: Adding a project silently turns off the "Hide default branch" sidebar filter

3 participants