Skip to content

Sidebar: collapsing a Repositories environment card leaves the open worktree visible #382

Closed

Description

@mubeda

Problem / summary

(measured) Owner report, 16 November 2026, 09:14 America/Buenos_Aires: some cards in the left panel do not collapse in the Repositories view.

(measured) The supplied screenshot shows a project / repository row with a downward (expanded) chevron, a local environment card on this device with a right-pointing (collapsed) chevron, and, still visible under it, a primary worktree card with a “1 more chat” row.

(inferred) Collapse is not a no-op. The header stores collapsed state and the chevron follows that flag. A shared “active card peeks through” rule then keeps the open chat’s worktree card visible. If that worktree is the only child — a common Repositories case, for example a local environment on this device with only its primary checkout — the card looks as if it did not collapse, except for the chevron. That is why only some cards appear to fail.

(measured) This peek is currently intentional: it is documented, tested, and was narrowed by an earlier fix. The owner’s report still treats the result as a bug. The proposed fix is to make an explicit collapse hide every descendant. That reverses the documented policy, so it needs a yes before implementation (Open question 1).

Area: apps/web. (measured) Evidence tags: (measured) means inspected source, test definitions, screenshot, the supplied report, or GitHub metadata; it does not mean the app or tests were run. (inferred) is a source-derived conclusion or a proposal. (guess) is unverified. No runtime reproduction was performed. Two independent read-only reviews (Codex and Claude) reached the same mechanism below unless a difference is called out.

Steps to reproduce

All steps are (inferred) from source. They were not run.

  1. Switch the left panel to Repositories.
  2. Expand a repository row and one of its environment cards. A typical case is a local environment card on this device that holds only its primary checkout.
  3. Open that checkout’s chat (click the primary worktree card). The same result applies if the open chat is a non-primary worktree.
  4. Click the environment card’s header or chevron to collapse it.

Expected vs actual

  • (inferred; proposed) Collapsing the environment card hides all of its worktree, more-chats, discovery, and overflow content. The header shows the collapsed chevron. The open chat in the center panel is unchanged.
  • (measured; screenshot and source) The chevron points right and aria-expanded is false, but the open worktree card stays on screen. When that card is the primary checkout, its “N more chats” row can stay too.
  • (measured) The outer repository row is a separate disclosure: collapsing it unmounts every environment child. (inferred) That is a workaround: collapse the repository row to hide the group. Another workaround is to switch to a chat in a different card, then collapse this one.

Current behavior

(measured) Verified at be03142dcd9f14378d4357d83ad65d2cf5af513a (current main, merge of PR #379). Every path:line below refers to this SHA.

The header collapse works

  • In Repositories, each environment entry (local or remote) is a SidebarProjectItem with an environmentCard header (Sidebar.tsx:4573–4597, EnvironmentCardHeader.tsx). (measured)
  • Clicking the header, or pressing Enter or Space, selects the project and calls setProjectExpanded(projectToggleKeys, !projectExpanded) (Sidebar.tsx:2245–2292, :3414–3436). The chevron is inside that button, not a separate control. (measured)
  • aria-expanded and chevron rotation follow projectExpanded only. ChevronRightIcon gets rotate-90 when expanded, and stays unrotated when collapsed (Sidebar.tsx:3416, :3445–3449). The screenshot’s right-pointing chevron on the environment card matches the collapsed flag. (measured)
  • The keys written on toggle and the keys read for projectExpanded agree (Sidebar.tsx:631–651, uiStateStore.ts:372–383). (measured)
  • Nothing in the environment header swallows the click. Collapsed children are unmounted, not hidden with CSS. (measured)

The open worktree still renders

  • The primary worktree card renders when projectExpanded || primaryThreadActive (Sidebar.tsx:1724). (measured)
  • A non-primary worktree stays visible through pinnedCollapsedThread when the route matches that thread (Sidebar.tsx:2161–2172, used at :2211–2231). (measured)
  • isPrimaryThreadActiveWhileCollapsed covers the primary-thread case, because the primary thread is split out of visibleProjectThreads and would otherwise disappear (Sidebar.tsx:2173–2190). The in-source comment records that this peek was added after collapsing a project while routed to its default thread hid the primary row entirely. (measured)
  • When the retained card is the primary checkout, its “N more chats” row is part of that same card (Sidebar.tsx:1618–1627). That matches the screenshot. (measured)
  • Only the environment card that owns the current route receives activeRouteThreadKey (Sidebar.tsx:4579–4581). (inferred) Sibling environment cards without the open chat collapse fully. Local versus remote identity, and having only one worktree, are not a separate code path; one worktree just makes the peek fill the whole group.

The peek is documented and tested

  • User docs: “A collapsed project keeps only the card you are viewing visible; its other cards and discovered worktrees appear again when you expand it.” (docs/user/workspace-ui.md:232–235). (measured)
  • Sidebar.test.tsx:737–746 asserts that a collapsed project still shows the active worktree row and hides the inactive primary card. (measured) There is no test that the primary card itself stays visible when it is the active route. (measured)
  • Commit dd243f0df narrowed an earlier, broader peek: collapsing a project had also kept the discovered-worktrees section and the inactive primary card, “so projects with discovered worktrees looked uncollapsible. Only the active card now peeks through.” (measured)

What is not broken

  • The outer repository row (SidebarRepositoryGroup) toggles repositoryGroupExpandedById and, when collapsed, does not render its children (SidebarRepositoryGroup.tsx:38–57, :67–70; default expanded unless the key is explicitly false, Sidebar.tsx:4559). (measured)
  • Individual worktree cards are not themselves collapsible disclosures. (measured)
  • The Environments view uses the same SidebarProjectItem path (Sidebar.tsx:4619–4672) and therefore the same peek. (measured) The report is about Repositories; the mechanism is not limited to that view.

Root cause

(inferred) Supported, not runtime-confirmed. The collapse control and the chevron are consistent with stored projectExpanded. The children that remain are the active-route exception in Sidebar.tsx:1724 and :2161–2232. The screenshot is consistent with that exception on a collapsed environment card whose open chat is the primary checkout, but the crop does not show the current route or the click that produced the state.

(measured) Ruled out by source: a mismatched collapse key, a click swallowed by the environment header, a CSS-only chevron/visibility desync, and a failure of the outer repository row.

Proposed fix

(inferred; agent’s call) Make an explicit collapse authoritative: a collapsed environment card (and, unless Open question 2 says otherwise, a collapsed Environments-view project row) hides every descendant, including the open chat’s worktree card and its more-chats row. Keep the existing preference keys and the current center-panel route. Align the visible-thread jump-label list, which currently mirrors the peek (Sidebar.tsx:5295–5335). Invert or replace Sidebar.test.tsx:737 and update docs/user/workspace-ui.md:232–235.

(inferred) After the peek is gone, the collapsed header should still make it possible to tell that this card holds the open chat. The header already sets aria-current and isActive when the module route is active (Sidebar.tsx:3416–3423); whether that is enough, or a clearer cue is needed, is Open question 3 / P1.

Goals and non-goals

Goals:

  • Collapsing any Repositories environment card hides all of its descendant cards, including the open worktree.
  • Expanding restores the previous descendant content.
  • Pointer and keyboard disclosure produce the same visibility.

Non-goals:

  • Changing how the outer repository row collapses (it already hides all entries).
  • Changing how expansion state is keyed or persisted.
  • Adding collapse controls to individual worktree cards.
  • Changing more-chats popovers, discovery policy, server connectivity, or grouping identities.
  • Auto-expanding a collapsed card when a chat inside it is opened from elsewhere (Open question 4).

Requirements and acceptance criteria

P0/P1/P2 below rank work inside this issue. The proposed issue priority is P2.

P0 — Collapse hides every descendant in Repositories

WHEN a user collapses a Repositories environment card, the sidebar SHALL hide all descendants of that card and present the disclosure as collapsed, including when the open chat belongs to that card.

  • Given a local or remote environment whose primary checkout is the open chat, when the header is collapsed by chevron click, header click, Enter, or Space, then the primary card, its more-chats row, other worktrees, discovery content, and overflow rows are not rendered, and aria-expanded is false.
  • Given an open non-primary worktree in that environment, when the card is collapsed, then that worktree row is also absent.
  • Given one visible worktree or several, when the card is collapsed and then expanded, then all descendants hide and the appropriate content returns.
  • Negative: collapse does not navigate away, close the center workspace, alter chats, or collapse a sibling environment.

Tests: invert or replace apps/web/src/components/Sidebar.test.tsx:737 and add a primary-card case (that peek is currently untested). Extend Sidebar.browser.test.tsx with a mounted collapse/expand transition. The current harness can spy on setProjectExpanded; asserting only that the setter was called does not prove the children disappeared.

P1 — Same policy in Environments, jump labels, and a collapsed-header cue

  • Given the Environments view and a collapsed project that holds the open chat, then no worktree card is rendered. Test: a it.each(["environments", "repositories"]) case in Sidebar.test.tsx, following the existing view-matrix pattern. Skip or rewrite this item if Open question 2 keeps the documented peek in Environments.
  • Given a collapsed card that holds the open chat, when thread jump hints are shown, then no hint targets that hidden chat. Test: add a case in Sidebar.test.tsx; existing jump-label tests do not set a collapsed project.
  • Given a collapsed card that holds the open chat, including an idle one, the header still indicates that this is the open workspace, with an accessible name or state. Test: a case in Sidebar.test.tsx, plus a UI.md review of the cue (Open question 3).
  • GIVEN a collapsed card, WHEN its data rerenders or saved UI state is restored, THEN it stays collapsed and its descendants stay hidden. Extend uiStateStore.test.ts / Sidebar.test.tsx if a gap remains.

P2 — Docs

Repo gates

(measured) From AGENTS.md: focused tests for every changed behavior; vp check and vp run typecheck; a vercel-react-best-practices review of changed components and hooks; a UI.md review of the interaction; a final git diff / git status --short review; and a profiler coverage line in the final report. Rust gates (cargo fmt --all --check, Clippy -D warnings, Rust tests) apply only if Rust changes, which this issue does not propose.

(measured) None of these checks ran in this static-only diagnosis.

Open questions

  1. Decided (owner, 16 November 2026): drop the active-card peek. An explicit collapse hides every descendant.
  2. Decided (owner, 16 November 2026): same rule in both views. Should Environments use the same rule? Codex recommended keeping the documented peek there and scoping the fix to Repositories. Claude recommended one policy, because both views share SidebarProjectItem. Agent’s call: same policy in both views. A Repositories-only exception would add branching in a shared component, and a project with only its primary checkout can look just as uncollapsible in Environments.
  3. If the peek is dropped, is the existing active header (isActive / aria-current) enough to show that the collapsed card holds the open chat, or is a stronger visual cue required? Decide in the UI.md review. Can wait: it is P1, not P0.
  4. Should opening a chat inside a collapsed card from elsewhere (Inbox, jump keys, a link) expand that card? Today nothing auto-expands, apart from bootstrap. Can wait: it does not change P0.

Duplicate check

(measured) Searched open and closed issues, including a wontfix-label query that returned no issues, for: collapse, chevron, sidebar, Repositories, environment group, “do not collapse”, expand, fold, left panel, peek, uncollapsible.

No duplicate.

Issue Why it is not a duplicate
#378 (open) — Environments: server icons get Open terminal and Dashboard actions Same environment-card surface; different request (commands, not collapse).
#290 (closed) — Settings: create, edit and select custom color themes alongside six built-in themes Sidebar hierarchy/theming, not disclosure visibility.
#311 (closed) — Chat: changed-files tree at the end of a turn opens fully expanded; it should start collapsed Similar vocabulary, different surface and default-state problem.
#186 (closed) — Sidebar: add "Inbox" view with agent category tiles Third-view feature, not this disclosure.
#187 (closed) — Left panel: agent activity status is unreliable Status accuracy, not collapse.
#375, #376, #377, #380, #381, #374, #371 Unrelated (Source Control, loading, model default, hang, auth, build).

Related history, not an issue: commit dd243f0df fixed an earlier “looked uncollapsible” case by narrowing the peek to the active card only.

Triage proposal

(inferred; agent’s call) Labels: bug, needs-triage, size:S. Priority P2: the disclosure is misleading, but there is no evidence of data loss or blocked work, and collapsing the outer repository row hides the group.

(measured) The original screenshot is not included here; it contains a local path and a project name. A cropped crop with those removed can be attached on filing if wanted. No issue or PR was created, edited, commented on, or closed.

Activity

  1. added
    bugSomething is broken or behaving incorrectly.
    needs-triageIssue needs maintainer review and initial categorization.
    on Nov 16, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething is broken or behaving incorrectly.needs-triageIssue needs maintainer review and initial categorization.size:S

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions