Files
openchamber/packages/ui/src/stores/useSessionDisplayStore.ts
T
Bohdan Triapitsyn 28aeb4950b refactor: simplify session list display
Makes minimal session rows the default
Removes session diff stat badges from navigation surfaces
Keeps expanded session rows in VS Code
2026-06-12 12:38:31 +03:00

45 lines
1.6 KiB
TypeScript

import { create } from 'zustand';
import { persist } from 'zustand/middleware';
export type SessionDisplayMode = 'default' | 'minimal';
type SessionDisplayStore = {
displayMode: SessionDisplayMode;
showRecentSection: boolean;
showArchivedSessions: boolean;
setDisplayMode: (mode: SessionDisplayMode) => void;
setShowRecentSection: (show: boolean) => void;
setShowArchivedSessions: (show: boolean) => void;
toggleRecentSection: () => void;
toggleArchivedSessions: () => void;
};
export const useSessionDisplayStore = create<SessionDisplayStore>()(
persist(
(set) => ({
displayMode: 'minimal',
showRecentSection: true,
showArchivedSessions: true,
setDisplayMode: (mode) => set({ displayMode: mode }),
setShowRecentSection: (show) => set({ showRecentSection: show }),
setShowArchivedSessions: (show) => set({ showArchivedSessions: show }),
toggleRecentSection: () => set((state) => ({ showRecentSection: !state.showRecentSection })),
toggleArchivedSessions: () => set((state) => ({ showArchivedSessions: !state.showArchivedSessions })),
}),
{
name: 'session-display-mode',
version: 1,
// v0 shipped 'default' as the only/initial mode, so most existing users
// have it persisted by accident rather than choice. Nudge everyone onto
// minimal once so the mode can be evaluated before removing it entirely.
migrate: (persisted, version) => {
const state = (persisted ?? {}) as Partial<SessionDisplayStore>;
if (version < 1) {
return { ...state, displayMode: 'minimal' };
}
return state;
},
},
),
);