Skip to content

Pin folders in the session drawer so they don't reshuffle on every session switch #18

@goyamegh

Description

@goyamegh

Summary

Let users pin folders (cwd groups) in the session drawer so they stay at a fixed position and don't reshuffle every time the user switches sessions.

Today, folders are ordered implicitly by the most-recent activity inside them — when you switch to a session in folder X, folder X bubbles up; when you flip to a session in folder Y, folder Y bubbles up. For users who actively rotate between many folders this means the drawer is in motion almost constantly and "muscle memory" for finding a folder never has a chance to form.

Why this matters

  • Spatial stability beats recency for navigation. The drawer is the workspace map. Ordering by recency makes it a log instead of a map. Most navigation in the drawer is not "go to where I just was" (the current-session highlight already covers that); it's "go to that other folder I keep coming back to". A stable position makes that scan a sub-second visual pattern-match instead of a fresh read every time.
  • Pinned tabs already exist for sessions. There's a strong precedent in the same drawer: pinned tabs / pinned sessions stay put while everything else moves around them. Pinned folders are the same idea one level up the hierarchy.
  • Compounds with marker buckets. When you filter by a marker color, the surviving folders also reshuffle (see #13 for the related papercut). Pinned folders give the drawer two stable axes — color filter for "what to show" and pin order for "where to show it".

Proposed UX

  • Each folder header gets a small pin/unpin affordance (icon button), mirroring the existing per-session pin control.
  • Pinned folders sort to the top of the drawer in the order they were pinned, above all unpinned folders.
  • Within the pinned region, order is stable — pinning a folder appends to the end of the pinned list, the user can drag to reorder, but switching sessions never reorders pinned folders.
  • Unpinned folders below continue to use the existing recency-based ordering.
  • Pin state persists per-device. (Whether to also sync via the existing pi-web-session-ui-state.json mechanism is up to the maintainer; either works.)
  • A small visual treatment on pinned folder headers (e.g. a subtle accent border or a filled pin icon) makes the two regions distinguishable at a glance.

Where it would live

  • src/sessions/sessionDrawer.ts — extend the folder grouping pass to partition folders into pinned[] and rest[], then concatenate. The grouping pass currently iterates visibleSessions (~line 1140); a small additional pass over a pinnedFolderCwds set is enough.
  • Storage: extend pi-web-session-ui-state.json with a pinnedFolders: string[] (cwds, in pin order), or use localStorage if the maintainer prefers per-device.
  • Server: a tiny POST /api/session-ui-state patch (already exists for pinned sessions / markers) to round-trip the field.
  • Reuse the existing bookmark / pin icon set; no new icons needed.

Edge cases

  • Renamed / removed folder: if a pinned cwd no longer has any sessions, render a placeholder ghost row (related to #13 which already argues for keeping empty folders visible) so the user can unpin it. Alternatively, auto-unpin after N days of zero activity.
  • Pinned folder under a non-matching color filter: still render the folder header (consistent with #13) — pinning shouldn't be undone by an active filter.
  • Drag-to-reorder: nice-to-have, not required for v1. Add-pin order is fine for an MVP.

Non-goals

  • Folder grouping by anything other than cwd (e.g. by repo, by branch). Out of scope here.
  • Nested folders / tree view. Out of scope.

Acceptance criteria

  • Each folder header has a pin/unpin affordance.
  • Pinned folders render above unpinned folders in a stable order across session switches.
  • Pin state survives reloads.
  • Pinning is independent of the active marker-color / search filter (a pinned folder remains pinned even when its sessions are all filtered out).
  • No regressions to the existing per-session pin behaviour.

Related

  • #13 — keep folders visible under filters / empty states.
  • #15 — open the drawer on new-session creation (also about preserving spatial perspective).

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions