Skip to content

Workspace number follows creation order, but the sidebar renders grouped by space #2150

Description

@luis-barroso

Workspace number follows creation order, but the sidebar renders grouped by space

Version: herdr 0.7.5 (stable, Homebrew), macOS 15 (Darwin 25.5.0), Ghostty

Summary

number is assigned in workspace creation order, while the expanded sidebar
renders workspaces grouped by their worktree space. The two orderings only agree
when a user happens to create all of one repo's workspaces consecutively.
Interleave work across two repos and the numbers shown in the expanded sidebar
are no longer monotonic, so they stop being usable as positional identifiers —
which matters most when the sidebar is collapsed and the number is the primary
handle you have.

Reproduce

  1. Open a workspace in repo A (herdr worktree open).
  2. Open a plain workspace (herdr workspace create, no repo).
  3. Open a workspace in repo B.
  4. Open a second worktree workspace in repo A.
  5. Expand the sidebar and read the numbers top to bottom.

Expected: 1, 2, 3, 4.
Actual: 1, 4, 2, 3 — grouping reorders the rows, numbering does not follow.

Observed

Seven workspaces, created interleaved across two repos. herdr workspace list
returns identical output with the sidebar expanded and collapsed:

number id label worktree.repo_name
1 w1 intocare intocare
2 w4 portal portal
3 w6 intocare/ICP-19995-… intocare
4 w7 navigation (none)
5 w9 portal/ICP-20047-… portal
6 wA intocare/ICP-20009-… intocare
7 wB intocare/ICP-20006-… intocare

Grouped by space, as the expanded sidebar renders them:

intocare      →  1, 3, 6, 7
portal        →  2, 5
(ungrouped)   →  4

So the expanded sidebar reads 1, 3, 6, 7, 2, 5, 4 top to bottom, while the
collapsed rail reads 1, 2, 3, 4, 5, 6, 7. Same seven workspaces, two
orderings, never reconciled.

agent_panel_sort is at its default ("spaces"), and this is the workspace
section of the sidebar, not the agent panel.

number is clearly intended as positional rather than as a stable identifier:
closing a workspace renumbers every workspace after it (closing the workspace at
number: 2 moved the one at 3 to 2, 4 to 3, and so on). That's the right
behaviour for a positional index — it just tracks the wrong sequence.

Why it matters

switch_workspace is documented as an optional indexed binding
("prefix+shift+1..9"). Anyone who enables it and navigates by what they see in
the expanded sidebar will jump to the wrong workspace. Today the mismatch is
cosmetic only because that binding is unset by default.

Suggested fix

Assign number from the rendered order rather than creation order, so it always
matches what the sidebar shows, and renumber when grouping changes — the same
way it already renumbers when a workspace is closed.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions