The all-in-one local AI studio for your desktop: chat, image and video generation and a coding agent in one free, open source app. Windows and Linux. No Docker, no terminal, no cloud required.
TypeScript agentai-chatai-studioall-in-onecoding-agentdesktop-appfluximage-generationlinuxllmlocal-ailocal-llmopen-sourceprivacyself-hostedstable-diffusionuncensoreduncensored-aivideo-generationwindows
feat(ui): der Klappzustand der Sidebar wird zum Vorzug statt zum Nebeneffekt
purpleb39aaa51bc57
diff --git a/src/lib/time-ago.ts b/src/lib/time-ago.tsnew file mode 100644index 00000000..3617a40e--- /dev/null+++ b/src/lib/time-ago.ts@@ -0,0 +1,14 @@+/** Compact relative timestamp for thin history rows: "now", "5m", "3h", "2d", "1w".+ * Ported 1:1 from apps/web/lib/time-ago.ts so the recent-chats list on the+ * desktop home screen reads exactly like the web one. */+export function timeAgo(ts: number, now: number = Date.now()): string {+ const s = Math.max(0, (now - ts) / 1000)+ if (s < 60) return 'now'+ const m = s / 60+ if (m < 60) return `${Math.floor(m)}m`+ const h = m / 60+ if (h < 24) return `${Math.floor(h)}h`+ const d = h / 24+ if (d < 7) return `${Math.floor(d)}d`+ return `${Math.floor(d / 7)}w`+}diff --git a/src/stores/__tests__/uiStore-explorer.test.ts b/src/stores/__tests__/uiStore-explorer.test.tsindex 91c24b61..0411b446 100644--- a/src/stores/__tests__/uiStore-explorer.test.ts+++ b/src/stores/__tests__/uiStore-explorer.test.ts@@ -4,8 +4,14 @@* This store was NOT persisted before. It carries currentView and* cloudGateOpen, so a naive persist would change what the app does on start:* it would reopen on whatever tab was left behind, or come up with the cloud- * gate on screen. partialize therefore has to hold EXACTLY the two explorer- * fields, and this test is the guard on that word "exactly".+ * gate on screen. partialize therefore has to hold EXACTLY the fields that+ * are a stated preference, and this test is the guard on that word "exactly".+ *+ * Widened in the web-parity round (2.6.8): sidebarOpen joined the written set.+ * It is the user saying "rail" or "list", the same class of choice as+ * explorerCollapsed, and forgetting it on every restart is the bug David+ * reported. currentView / cloudGateOpen / cloudTeaser stay forbidden, because+ * those steer where the app STARTS rather than how it looks.** Run: npx vitest run src/stores/__tests__/uiStore-explorer.test.ts*/@@ -42,37 +48,38 @@ import {} from '../uiStore'describe('what the ui store writes to disk', () => {- it('persists exactly explorerWidth and explorerCollapsed', () => {+ it('persists exactly explorerWidth, explorerCollapsed and sidebarOpen', () => {const partialize = useUIStore.persist.getOptions().partializeexpect(partialize).toBeTypeOf('function')const written = partialize!(useUIStore.getState()) as Record<string, unknown>- expect(Object.keys(written).sort()).toEqual(['explorerCollapsed', 'explorerWidth'])+ expect(Object.keys(written).sort()).toEqual(['explorerCollapsed', 'explorerWidth', 'sidebarOpen'])})it('counter-test: nothing that steers the app start comes along', () => {const partialize = useUIStore.persist.getOptions().partialize!const written = partialize(useUIStore.getState()) as Record<string, unknown>- for (const forbidden of ['currentView', 'cloudGateOpen', 'cloudTeaser', 'sidebarOpen']) {+ // sidebarOpen left this list in the web-parity round, see the file header.+ for (const forbidden of ['currentView', 'cloudGateOpen', 'cloudTeaser', 'settingsFocus']) {expect(written).not.toHaveProperty(forbidden)}// Actions must not ride along either, they would be dead weight in storage.expect(Object.values(written).every((v) => typeof v !== 'function')).toBe(true)})- it('keeps writing only those two after the state moved', () => {- useUIStore.setState({ currentView: 'settings', cloudGateOpen: true, explorerCollapsed: true, explorerWidth: 333 })+ it('keeps writing only those three after the state moved', () => {+ useUIStore.setState({ currentView: 'settings', cloudGateOpen: true, explorerCollapsed: true, explorerWidth: 333, sidebarOpen: true })const written = useUIStore.persist.getOptions().partialize!(useUIStore.getState()) as Record<string, unknown>- expect(written).toEqual({ explorerWidth: 333, explorerCollapsed: true })+ expect(written).toEqual({ explorerWidth: 333, explorerCollapsed: true, sidebarOpen: true })})it('and that is what actually lands in storage', () => {- useUIStore.setState({ currentView: 'benchmark', cloudGateOpen: true })+ useUIStore.setState({ currentView: 'benchmark', cloudGateOpen: true, sidebarOpen: false })useUIStore.getState().setExplorerWidth(420, 1600)useUIStore.getState().setExplorerCollapsed(true)const raw = memory.getItem('locally-uncensored-ui')expect(raw).toBeTruthy()const parsed = JSON.parse(raw!)- expect(parsed.state).toEqual({ explorerWidth: 420, explorerCollapsed: true })+ expect(parsed.state).toEqual({ explorerWidth: 420, explorerCollapsed: true, sidebarOpen: false })})})diff --git a/src/stores/uiStore.ts b/src/stores/uiStore.tsindex a598c8cb..a1239ca7 100644--- a/src/stores/uiStore.ts+++ b/src/stores/uiStore.ts@@ -82,7 +82,12 @@ export const useUIStore = create<UIState>()(persist((set) => ({currentView: 'chat',- sidebarOpen: true,+ // Collapsed by default, web parity (apps/web/stores/uiStore.ts:13-19):+ // the left column starts as a slim icon rail and the user expands it to+ // the full conversation list on demand. Unlike the web build this one is+ // persisted (see partialize), because a desktop app is not reloaded from+ // scratch on every visit and the choice should survive a restart.+ sidebarOpen: false,cloudGateOpen: false,cloudTeaser: null,pendingCloudModel: null,@@ -90,15 +95,17 @@ export const useUIStore = create<UIState>()(explorerCollapsed: false,settingsFocus: null,- // Sidebar visibility follows the view: it's the conversation list, which- // only makes sense in Chat. The hamburger toggle still works on other views;- // it just resets to the view's default on the next setView() call.+ // Navigation no longer touches sidebarOpen. The conversation list only+ // makes sense in Chat, and that rule now lives in the Sidebar itself+ // (showSidebar), the way the web build does it. Forcing the panel open+ // here used to undo the user's collapse on every trip through Models or+ // Settings, which is exactly what the web parity round removes.// A plain setView is somebody navigating by hand, so it drops any focus// a previous deep link left behind rather than firing it late.- setView: (view) => set({ currentView: view, sidebarOpen: view === 'chat', settingsFocus: null }),+ setView: (view) => set({ currentView: view, settingsFocus: null }),openSettingsAt: (focus) =>- set({ currentView: 'settings', sidebarOpen: false, settingsFocus: focus }),+ set({ currentView: 'settings', settingsFocus: focus }),clearSettingsFocus: () => set({ settingsFocus: null }),toggleSidebar: () => set((state) => ({ sidebarOpen: !state.sidebarOpen })),setSidebarOpen: (open) => set({ sidebarOpen: open }),@@ -111,13 +118,17 @@ export const useUIStore = create<UIState>()(}),{name: 'locally-uncensored-ui',- // EXACTLY the two explorer fields (plan C3 / R1). This store was not- // persisted at all before, and persisting it naively would carry- // currentView and cloudGateOpen across restarts: the app would reopen on- // whatever tab was left behind, or come up with the cloud gate on screen.+ // The two explorer fields (plan C3 / R1) plus sidebarOpen. Persisting+ // this store naively would carry currentView and cloudGateOpen across+ // restarts: the app would reopen on whatever tab was left behind, or+ // come up with the cloud gate on screen. Those stay out.+ // sidebarOpen joined in the web-parity round: it is a stated preference+ // ("I want the rail" / "I want the list"), not a leftover of one+ // session, and the app would forget it on every restart otherwise.partialize: (state) => ({explorerWidth: state.explorerWidth,explorerCollapsed: state.explorerCollapsed,+ sidebarOpen: state.sidebarOpen,}),},),