Skip to content

feat(sessions): pin folders to the top of the session drawer#36

Open
goyamegh wants to merge 1 commit into
ashwin-pc:mainfrom
goyamegh:feat/pin-session-folders
Open

feat(sessions): pin folders to the top of the session drawer#36
goyamegh wants to merge 1 commit into
ashwin-pc:mainfrom
goyamegh:feat/pin-session-folders

Conversation

@goyamegh

Copy link
Copy Markdown

What

Adds the ability to pin folders (cwd groups) to the top of the session drawer. Each folder header gets a small pin/unpin button; pinned folders sort to the top in pin order and stay there across session switches, filter changes, and reloads — so the drawer behaves like a stable spatial map instead of a recency-ordered log.

Why

With many concurrent sessions across several repos, the recency-ordered drawer constantly reshuffles, making it hard to find the folder you care about. Pinning lets you keep your active repos anchored at the top.

Behaviour

  • Each folder header gets a pin/unpin icon button (lucide pin).
  • State persists per-device via the existing pi-web-session-ui-state.json round-trip (new pinnedFolders: string[] field) — same mechanism as pinned sessions and markers, so it survives reloads and syncs through the server.
  • Pinned folders render above unpinned folders in pin order; unpinned folders keep the existing recency-based order.
  • A pinned folder whose sessions are hidden by an active marker-color/search filter still keeps its header (and unpin affordance) visible.
  • A pinned folder with no sessions left renders a small placeholder row so it can still be unpinned.
  • Touch devices keep the pin button visible (it doesn't rely on hover).

Implementation

  • server/sessionUiState.tspinnedFolders added to the state shape, normalizer, and PATCH handler.
  • src/app/types.tspinnedFolders in SessionUiState + AppState, with normalize/legacy-read helpers.
  • src/sessions/sessionDrawer.ts — pin/unpin/toggle helpers, partition-by-pinned render ordering, pin button + ghost-row placeholder.
  • src/styles/sessions.css — pin button + pinned-group separator styles.

Tests

  • tests/api.test.ts — round-trips pinnedFolders through the /api/session-ui-state PATCH (dedupe + trim + reset).
  • tests/e2e/session-bar.spec.ts — e2e coverage for pin/unpin + ordering.

Verification output (typecheck / build / unit tests green) posted as a PR comment.

Folders (cwd groups) in the session drawer can now be pinned via a
small pin button in the folder header. Pinned folders sort to the top
of the drawer in pin order and stay there across session switches,
filter changes, and reloads — so the drawer behaves like a stable
spatial map instead of a recency-ordered log.

Behaviour:
- Each folder header gets a pin/unpin icon button. State is persisted
  per-device via the existing pi-web-session-ui-state.json round-trip
  (new `pinnedFolders: string[]` field).
- Pinned folders render above unpinned folders in pin order. Unpinned
  folders keep the existing recency-based order.
- A pinned folder whose sessions are hidden by an active marker-color
  or search filter still keeps its header (and unpin affordance)
  visible.
- A pinned folder with no sessions left renders a small placeholder
  row so the user can still unpin it.

Signed-off-by: goyamegh <goyamegh@amazon.com>
Copilot AI review requested due to automatic review settings June 23, 2026 05:55
@goyamegh

Copy link
Copy Markdown
Author

Verification

Branch builds on current origin/main (3453ef1); feature commit bc6c47e.

typecheck

> @ashwin-pc/pi-web@0.3.0 typecheck
> tsc --noEmit
exit=0

build

✓ 3853 modules transformed.
✓ built in 8.95s
precache  17 entries (444.93 KiB)
exit=0

unit tests (tests/api.test.ts — exercises pinnedFolders round-trip)

 Test Files  1 passed (1)
      Tests  38 passed (38)
   Duration  20.70s (transform 69ms, setup 0ms, import 118ms, tests 20.44s, environment 0ms)

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Pull request overview

Adds folder-level pinning to the sessions drawer by persisting a new pinnedFolders array in session UI state and updating the drawer rendering to keep pinned folders stable at the top (including placeholder rows when needed).

Changes:

  • Extend session UI state (client + server) with pinnedFolders, including normalization/dedupe/trim and PATCH round-tripping.
  • Update session drawer rendering to partition pinned vs unpinned folder groups, add a pin/unpin button in folder headers, and render placeholders for pinned-but-empty folders.
  • Add API + E2E tests covering persistence, ordering, and filter interactions.

Reviewed changes

Copilot reviewed 6 out of 6 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
server/sessionUiState.ts Adds pinnedFolders to the server-side session UI state model, normalization, and PATCH application.
src/app/types.ts Adds pinnedFolders to shared client types/defaults and client-side normalization + legacy read helper.
src/sessions/sessionDrawer.ts Implements folder pin/unpin behavior, pinned ordering, pin button UI, and ghost-row rendering for empty pinned folders.
src/styles/sessions.css Styles the folder pin button and visual separation between pinned and unpinned groups.
tests/api.test.ts Adds coverage for pinnedFolders round-trip, trimming, and deduplication.
tests/e2e/session-bar.spec.ts Adds E2E coverage for pin/unpin + ordering behavior under marker filter changes.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +367 to +371
await page.locator(".sessionColorFilterButton").click();
await page.locator(".sessionColorFilterMenuItem.all").click();
await page.locator(".sessionColorFilterButton").click({ force: true });
// Close any lingering menu by pressing Escape.
await page.keyboard.press("Escape");
Comment on lines 372 to +377
if (!elements.sessionDrawer.hidden) renderSessionList(cachedSessions);
renderSessionBar();
updateSessionButtonUnread();
updateCurrentSessionPinButton();
renderCurrentSessionBucketButton();
if (state.pinnedSessions.length > 0 && cachedSessions.length === 0) refreshSessions().catch(() => undefined);
if ((state.pinnedSessions.length > 0 || state.pinnedFolders.length > 0) && cachedSessions.length === 0) refreshSessions().catch(() => undefined);
Comment thread tests/api.test.ts
Comment on lines 246 to +256
const current = await (await fetch(`${baseUrl}/api/session-ui-state`)).json();
expect(current.sessionUiState.selectedMarkerColor).toBe("green");
expect(current.sessionUiState.sessionUnreadStates).toEqual([]);
expect(current.sessionUiState.pinnedFolders).toEqual(["/work/repo-a", "/work/repo-b"]);

// Reset for downstream tests.
await fetch(`${baseUrl}/api/session-ui-state`, {
method: "PATCH",
headers: { "content-type": "application/json" },
body: JSON.stringify({ pinnedFolders: [] }),
});
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.

2 participants