Repository navigation
feat(app): session management primitives (pin, archive, groups, manual order) - #2035
Conversation
…l order)
Adds four user-controllable, unopinionated session-management primitives to
the workspace sidebar, per the team discussion:
- Pin session: pinned roots float to the top (global, localStorage).
- Manual ordering: drag-reorder root sessions per workspace (localStorage).
- Custom separators/groups: user-defined buckets ('Done', 'In progress',
...) with per-session assignment via a submenu (localStorage).
- Archive session: non-destructive, backed by OpenCode's native
session.time.archived. Archived sessions move to a collapsible 'Archived'
section instead of being deleted - important for audit/retention policies.
Pin/order/groups are pure client-side view state (mirrors the existing
workspace-order pattern in session-memory.ts); archive is server-persisted
via session.update. Sidebar actions are exposed in both the '...' dropdown
and the right-click context menu.
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
There was a problem hiding this comment.
3 issues found across 9 files
Prompt for AI agents (unresolved issues)
Check if these issues are valid — if so, understand the root cause of each and fix them. If appropriate, use sub-agents to investigate and fix each issue separately.
<file name="apps/app/src/react-app/domains/session/sidebar/app-sidebar.tsx">
<violation number="1" location="apps/app/src/react-app/domains/session/sidebar/app-sidebar.tsx:1023">
P2: Reordering with a truncated preview overwrites manual order with only visible root IDs, causing hidden sessions to lose their saved order.</violation>
</file>
<file name="apps/app/src/react-app/shell/session-route.tsx">
<violation number="1" location="apps/app/src/react-app/shell/session-route.tsx:2723">
P1: Archive requests are sent using the selected workspace client/root, so archiving from another workspace row can hit the wrong backend context.</violation>
</file>
Reply with feedback, questions, or to request a fix.
Re-trigger cubic
| opencodeClient, | ||
| sessionId, | ||
| archived, | ||
| selectedWorkspaceRoot || undefined, |
There was a problem hiding this comment.
P1: Archive requests are sent using the selected workspace client/root, so archiving from another workspace row can hit the wrong backend context.
Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. At apps/app/src/react-app/shell/session-route.tsx, line 2723:
<comment>Archive requests are sent using the selected workspace client/root, so archiving from another workspace row can hit the wrong backend context.</comment>
<file context>
@@ -2588,6 +2644,99 @@ export function SessionRoute() {
+ opencodeClient,
+ sessionId,
+ archived,
+ selectedWorkspaceRoot || undefined,
+ );
+ await refreshRouteState();
</file context>
Replace ~200 lines of manual localStorage code in session-memory.ts and ~80 lines of state/handlers/memos in session-route.tsx with a single Zustand store (session-management-store.ts) using zustand/middleware/persist. - Pin/order/groups read from the store via selectors imported directly by sidebar components (like useSessionActivityStore already does), avoiding context/prop drilling through 3 layers. - Reverted FlattenedSessionRow to its original type; group separators are rendered inline at the .map() call site instead of a discriminated union. - Removed 6 new fields from SidebarContextValue and corresponding props from AppSidebarProps and SessionPageSidebarProps. Net diff vs origin/dev shrinks from 933/82 to 569/78 (-39%).
There was a problem hiding this comment.
4 issues found across 7 files (changes from recent commits).
Prompt for AI agents (unresolved issues)
Check if these issues are valid — if so, understand the root cause of each and fix them. If appropriate, use sub-agents to investigate and fix each issue separately.
<file name="apps/app/src/react-app/shell/session-route.tsx">
<violation number="1" location="apps/app/src/react-app/shell/session-route.tsx:2723">
P1: Archive requests are sent using the selected workspace client/root, so archiving from another workspace row can hit the wrong backend context.</violation>
</file>
<file name="apps/app/src/react-app/domains/session/sidebar/session-management-store.ts">
<violation number="1" location="apps/app/src/react-app/domains/session/sidebar/session-management-store.ts:92">
P2: Workspace-specific session-management state cleanup was added but is unused, so forgetting a workspace leaves stale persisted order/group data.</violation>
</file>
<file name="apps/app/src/react-app/domains/session/sidebar/app-sidebar.tsx">
<violation number="1" location="apps/app/src/react-app/domains/session/sidebar/app-sidebar.tsx:177">
P2: The "New group" action is rendered as clickable even though no create-group callback is wired from SessionPage, so the menu item is a no-op.</violation>
</file>
Reply with feedback, questions, or to request a fix.
Re-trigger cubic
| }; | ||
| }), | ||
|
|
||
| forgetWorkspace: (workspaceId) => |
There was a problem hiding this comment.
P2: Workspace-specific session-management state cleanup was added but is unused, so forgetting a workspace leaves stale persisted order/group data.
Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. At apps/app/src/react-app/domains/session/sidebar/session-management-store.ts, line 92:
<comment>Workspace-specific session-management state cleanup was added but is unused, so forgetting a workspace leaves stale persisted order/group data.</comment>
<file context>
@@ -0,0 +1,126 @@
+ };
+ }),
+
+ forgetWorkspace: (workspaceId) =>
+ set((state) => {
+ const { [workspaceId]: _o, ...orderRest } = state.orderByWorkspace;
</file context>
| </DropdownMenuItem> | ||
| ))} | ||
| <DropdownMenuSeparator /> | ||
| <DropdownMenuItem onClick={() => ctx.onOpenCreateGroupModal?.(workspaceId)}> |
There was a problem hiding this comment.
P2: The "New group" action is rendered as clickable even though no create-group callback is wired from SessionPage, so the menu item is a no-op.
Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. At apps/app/src/react-app/domains/session/sidebar/app-sidebar.tsx, line 177:
<comment>The "New group" action is rendered as clickable even though no create-group callback is wired from SessionPage, so the menu item is a no-op.</comment>
<file context>
@@ -167,39 +158,35 @@ function SessionGroupSubmenu(props: {
- </>
- ) : null}
+ <DropdownMenuSeparator />
+ <DropdownMenuItem onClick={() => ctx.onOpenCreateGroupModal?.(workspaceId)}>
+ <FolderPlus className="size-4" />
+ {t("session_management.new_group")}
</file context>
Add a Dialog-based modal for creating custom session groups (separators). Clicking 'New group...' in the session dropdown submenu now opens a proper input dialog instead of a window.prompt. Uses the same Dialog/Input/Button primitives as the existing rename/delete modals.
- useCanManageSession always returns true (pin/group actions come from the store and should always be accessible, not gated on rename/delete) - Group separator detection compares against previous root-level row, not any row (avoids spurious separators between parent and children) - Reorder appends non-visible root IDs so hidden sessions keep their saved order when only a preview subset is shown - Wire forgetWorkspace store cleanup in handleForgetWorkspace so stale persisted order/group data is pruned when a workspace is removed
Groups are workspace-scoped, so creating them from the workspace '...' dropdown is the natural entry point alongside the per-session submenu.
There was a problem hiding this comment.
1 issue found across 2 files (changes from recent commits).
Prompt for AI agents (unresolved issues)
Check if these issues are valid — if so, understand the root cause of each and fix them. If appropriate, use sub-agents to investigate and fix each issue separately.
<file name="apps/app/src/react-app/domains/session/sidebar/app-sidebar.tsx">
<violation number="1" location="apps/app/src/react-app/domains/session/sidebar/app-sidebar.tsx:980">
P2: Reordering visible sessions can overwrite hidden root-session order because hidden IDs are appended from raw server order instead of existing manual order.</violation>
</file>
Tip: Review your code locally with the cubic CLI to iterate faster.
Re-trigger cubic
| const allRootIds = getRootSessions(activeSessions).map((s) => s.id); | ||
| const full = [...ids, ...allRootIds.filter((id) => !visible.has(id))]; |
There was a problem hiding this comment.
P2: Reordering visible sessions can overwrite hidden root-session order because hidden IDs are appended from raw server order instead of existing manual order.
Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. At apps/app/src/react-app/domains/session/sidebar/app-sidebar.tsx, line 980:
<comment>Reordering visible sessions can overwrite hidden root-session order because hidden IDs are appended from raw server order instead of existing manual order.</comment>
<file context>
@@ -971,13 +974,24 @@ function WorkspaceSidebarGroup({
+ onReorder={(ids) => {
+ // Append non-visible root IDs so hidden sessions keep their saved order.
+ const visible = new Set(ids);
+ const allRootIds = getRootSessions(activeSessions).map((s) => s.id);
+ const full = [...ids, ...allRootIds.filter((id) => !visible.has(id))];
+ store.getState().reorderSessions(workspace.id, full);
</file context>
| const allRootIds = getRootSessions(activeSessions).map((s) => s.id); | |
| const full = [...ids, ...allRootIds.filter((id) => !visible.has(id))]; | |
| const serverRootIds = getRootSessions(activeSessions).map((s) => s.id); | |
| const orderedRootIds = [...orderIds.filter((id) => serverRootIds.includes(id)), ...serverRootIds.filter((id) => !orderIds.includes(id))]; | |
| const full = [...ids, ...orderedRootIds.filter((id) => !visible.has(id))]; |
Session management primitives (pin, archive, custom groups, manual order)
From the team discussion on session management: instead of one opinionated
take, this PR exposes a few unopinionated primitives so people can manage their
own workflow (Omar's emoji/status renaming, ben's "let people control this +
custom separators", Jean's "needs an archive feature").
What's included
to
localStorage(openwork.react.pinnedSessions). Quick win Omar suggested.localStorage(openwork.react.sessionOrder). Mirrors the existingworkspace-reorder pattern.
"In progress", then anything you want) with per-session assignment via a
"Move to group" submenu. Persisted to
localStorage(
openwork.react.sessionGroups).session.time.archived(session.update). Archived sessions move to acollapsible "Archived (n)" section instead of being deleted — important for
orgs with audit/retention policies that forbid deletion. Unarchive restores
them.
All actions are available in both the
...dropdown and the right-clickcontext menu on each session.
Design notes
needed), following the precedent already set by workspace ordering in
session-memory.ts. Easy to migrate to a server DB later ("once we have ourdb up").
OpenCode already ships. The standard list endpoint still returns archived
sessions, so they're filtered client-side into the Archived section.
the sidebar renders exactly as before.
Files
session-memory.ts— new persistence helpers (pins, per-workspace order,groups + assignments) + cleanup on workspace forget.
opencode-session.ts—setSessionArchived()helper.sidebar/utils.ts— pin-first + manual-order sorting, archived partition,group-separator interleaving;
FlattenedSessionRowis now a discriminatedunion (
session|separator).sidebar/app-sidebar.tsx+app-sidebar-provider.tsx— menu items, pinindicator, drag
Reorder.Group, group separators, Archived section.chat/session-page.tsx+shell/session-route.tsx— prop plumbing + handlers.i18n/locales/en.ts— newsession_management.*keys.Tests run
End-to-end evidence (real Electron on Daytona, via CDP)
Drove the real desktop app in a Daytona sandbox: created a workspace, created
5 sessions, then exercised every primitive.
(Daytona preview URLs are not permanently stable; the mp4 is also archived
on the reusable
openwork-eval-artifactsvolume assession-mgmt-after.mp4.)Verified in the running app:
the
...dropdown).openwork.react.pinnedSessions.session.update({ time: { archived } })succeeds, sessionmoves into a collapsible Archived (1) section; active count drops 5 → 4.
sessions; sidebar renders the separators with sessions bucketed under each,
ungrouped sessions below, Archived at the bottom.
Final sidebar state (grouped + pinned + archived all at once):
Notes / follow-ups
(grouped view orders by group). Couldn't reliably script HTML5 drag over CDP,
but pin-first ordering (same code path) is shown working.
(matches the "a bit more broken in dev" note in the thread); a reload
bootstrapped it and everything worked. Unrelated to this change.