Skip to content

The agent that grows with you

feat(desktop): interface mode resolver behind the presentation stores

brooklyn!41d4124fff79
diff --git a/apps/desktop/src/app/right-sidebar/store.ts b/apps/desktop/src/app/right-sidebar/store.ts
index b0e26f03886..e4808963327 100644
--- a/apps/desktop/src/app/right-sidebar/store.ts
+++ b/apps/desktop/src/app/right-sidebar/store.ts
@@ -1,12 +1,19 @@
import { atom } from 'nanostores'
import { persistBoolean, storedBoolean } from '@/lib/storage'
+import { modeBound } from '@/store/interface-mode'
const TAKEOVER_KEY = 'hermes.desktop.terminalTakeover'
-export const $terminalTakeover = atom(storedBoolean(TAKEOVER_KEY, false))
+// Simple mode rests the terminal closed without touching this preference; ⌃`
+// still brings it up for the session.
+const $terminalTakeoverPref = atom(storedBoolean(TAKEOVER_KEY, false))
-$terminalTakeover.subscribe(active => persistBoolean(TAKEOVER_KEY, active))
+$terminalTakeoverPref.subscribe(active => persistBoolean(TAKEOVER_KEY, active))
+
+export const $terminalTakeover = modeBound('terminalOpen', $terminalTakeoverPref, active =>
+ $terminalTakeoverPref.set(active)
+)
export const setTerminalTakeover = (active: boolean) => $terminalTakeover.set(active)
diff --git a/apps/desktop/src/store/interface-mode.test.ts b/apps/desktop/src/store/interface-mode.test.ts
new file mode 100644
index 00000000000..b0518c0134a
--- /dev/null
+++ b/apps/desktop/src/store/interface-mode.test.ts
@@ -0,0 +1,159 @@
+/**
+ * Interface mode is a resolver input, never a preference writer. These tests
+ * pin the precedence contract — sessionReveal ?? policy[mode] ?? userPref —
+ * and the promise that matters to an existing install: Advanced is a no-op and
+ * a round trip through Simple leaves every preference byte-identical.
+ */
+
+import { atom } from 'nanostores'
+import { beforeEach, describe, expect, it, vi } from 'vitest'
+
+const MODE_KEY = 'hermes.desktop.interfaceMode.v1'
+
+const loadStore = () => import('./interface-mode')
+
+describe('interface mode persistence', () => {
+ beforeEach(() => {
+ window.localStorage.clear()
+ vi.resetModules()
+ })
+
+ it('never writes a record for Advanced, so an untouched install stays untouched', async () => {
+ const { $interfaceMode, setInterfaceMode } = await loadStore()
+
+ expect($interfaceMode.get()).toBe('advanced')
+ setInterfaceMode('advanced')
+ expect(window.localStorage.getItem(MODE_KEY)).toBeNull()
+
+ setInterfaceMode('simple')
+ expect(window.localStorage.getItem(MODE_KEY)).not.toBeNull()
+
+ setInterfaceMode('advanced')
+ expect(window.localStorage.getItem(MODE_KEY)).toBeNull()
+ })
+
+ it('restores Simple across a reload and treats anything else as Advanced', async () => {
+ const first = await loadStore()
+
+ first.setInterfaceMode('simple')
+ vi.resetModules()
+ expect((await loadStore()).$interfaceMode.get()).toBe('simple')
+
+ window.localStorage.setItem(MODE_KEY, 'intermediate')
+ vi.resetModules()
+ expect((await loadStore()).$interfaceMode.get()).toBe('advanced')
+ })
+})
+
+describe('modeBound resolver', () => {
+ beforeEach(() => {
+ window.localStorage.clear()
+ vi.resetModules()
+ })
+
+ it('falls through to the preference in Advanced, and writes reach the preference', async () => {
+ const { modeBound } = await loadStore()
+ const $pref = atom(true)
+ const $bound = modeBound('statusbarVisible', $pref, value => $pref.set(value))
+
+ expect($bound.get()).toBe(true)
+
+ $bound.set(false)
+ expect($pref.get()).toBe(false)
+ expect($bound.get()).toBe(false)
+ })
+
+ it('shadows the preference in Simple without writing it, and lifts the shadow on the way back', async () => {
+ const { modeBound, setInterfaceMode } = await loadStore()
+ const $pref = atom(true)
+ const $bound = modeBound('statusbarVisible', $pref, value => $pref.set(value))
+
+ setInterfaceMode('simple')
+ expect($bound.get()).toBe(false)
+ expect($pref.get()).toBe(true)
+
+ setInterfaceMode('advanced')
+ expect($bound.get()).toBe(true)
+ })
+
+ it('routes a toggle made under a shadow to the session layer, cleared on the next mode change', async () => {
+ const { modeBound, setInterfaceMode } = await loadStore()
+ const $pref = atom(false)
+ const $bound = modeBound('terminalOpen', $pref, value => $pref.set(value))
+
+ setInterfaceMode('simple')
+ $bound.set(true)
+ expect($bound.get()).toBe(true)
+ expect($pref.get()).toBe(false)
+
+ setInterfaceMode('advanced')
+ expect($bound.get()).toBe(false)
+
+ setInterfaceMode('simple')
+ expect($bound.get()).toBe(false)
+ })
+
+ it('drops a shadowed write made as layout intent: the mode decides what rests, the preference stays', async () => {
+ const { asLayoutIntent, modeBound, setInterfaceMode } = await loadStore()
+ const $pref = atom(false)
+ const $bound = modeBound('terminalOpen', $pref, value => $pref.set(value))
+
+ setInterfaceMode('simple')
+ asLayoutIntent(() => $bound.set(true))
+ expect($bound.get()).toBe(false)
+ expect($pref.get()).toBe(false)
+
+ setInterfaceMode('advanced')
+ asLayoutIntent(() => $bound.set(true))
+ expect($pref.get()).toBe(true)
+ })
+
+ it('leaves a surface Simple has no opinion on alone', async () => {
+ const { modeBound, setInterfaceMode, $modeShadowed } = await loadStore()
+
+ setInterfaceMode('simple')
+ expect($modeShadowed('statusbarVisible').get()).toBe(true)
+
+ setInterfaceMode('advanced')
+ expect($modeShadowed('statusbarVisible').get()).toBe(false)
+
+ const $pref = atom<'product' | 'technical'>('technical')
+ const $bound = modeBound('toolViewMode', $pref, value => $pref.set(value))
+
+ expect($bound.get()).toBe('technical')
+ })
+
+ it('keeps the profile door open in Simple when there is a second profile to walk through', async () => {
+ const { modeBound, setInterfaceMode, setModeContext } = await loadStore()
+ const $pref = atom(true)
+ const $bound = modeBound('profileRailVisible', $pref, value => $pref.set(value))
+
+ setInterfaceMode('simple')
+ expect($bound.get()).toBe(false)
+
+ setModeContext({ profileCount: 2 })
+ expect($bound.get()).toBe(true)
+
+ setModeContext({ profileCount: 1 })
+ expect($bound.get()).toBe(false)
+ })
+})
+
+describe('tiers', () => {
+ beforeEach(() => {
+ window.localStorage.clear()
+ vi.resetModules()
+ })
+
+ it('shows untagged items everywhere and a tiered item only in its mode', async () => {
+ const { shownInMode, $showsAdvancedChrome, setInterfaceMode } = await loadStore()
+ const items = [{ id: 'settings' }, { id: 'hud', tier: 'advanced' as const }, { id: 'side', tier: 'simple' as const }]
+
+ expect(items.filter(shownInMode('advanced')).map(item => item.id)).toEqual(['settings', 'hud'])
+ expect(items.filter(shownInMode('simple')).map(item => item.id)).toEqual(['settings', 'side'])
+
+ expect($showsAdvancedChrome.get()).toBe(true)
+ setInterfaceMode('simple')
+ expect($showsAdvancedChrome.get()).toBe(false)
+ })
+})
diff --git a/apps/desktop/src/store/interface-mode.ts b/apps/desktop/src/store/interface-mode.ts
new file mode 100644
index 00000000000..2d4b9c7e2bf
--- /dev/null
+++ b/apps/desktop/src/store/interface-mode.ts
@@ -0,0 +1,243 @@
+import { atom, computed, type ReadableAtom, type WritableAtom } from 'nanostores'
+
+import { type Codec, persistentAtom } from '@/lib/persisted'
+import type { SidebarRowMeta } from '@/store/layout'
+import type { ToolViewMode } from '@/store/tool-view'
+
+// Interface mode: does this window show the machinery, or just the
+// conversation? Two answers. ADVANCED is the app as it has always been — every
+// preference the user set, honoured. SIMPLE is chat-first: the standing
+// developer instrumentation (statusbar, profile rail, terminal / files / review
+// panes, technical tool payloads, the artifacts / scheduled-jobs rows) rests
+// out of the way. Mode changes what is SHOWN, never what Hermes can do: every
+// route still answers ⌘K, every pane still answers its keybind and the agent's
+// `focus_pane`.
+//
+// A mode is a RESOLVER INPUT, not a preset that writes preferences. Three
+// layers, one precedence, one place:
+//
+// effective(surface) = sessionReveal ?? policy[mode] ?? userPreference
+//
+// `policy.advanced` is empty, so Advanced falls through to the user's own
+// atoms by construction and nothing is ever written on an existing install.
+// Simple SHADOWS a preference rather than overwriting it, so switching back
+// restores the exact prior setup with nothing to snapshot or repair. A toggle
+// pressed while a surface is shadowed (⌃` in Simple) lands in the session
+// layer — the terminal appears now, and the next launch is Simple's resting
+// state again — so a mode is a default, not a lock, and no session reveal can
+// pollute a preference the user set in the other mode.
+//
+// Consumers never learn the word "mode". A preference store wraps its own atom
+// in `modeBound` and exports the EFFECTIVE atom under the name everything
+// already reads; list surfaces (titlebar tools, sidebar nav rows) tag items
+// with a `tier` and run one `shownInMode` filter at the site they already
+// filter. Both keep the policy table below the single owner of the answer.
+
+export type InterfaceMode = 'advanced' | 'simple'
+
+/** Picker order — the quiet option first. */
+export const INTERFACE_MODES: readonly InterfaceMode[] = ['simple', 'advanced']
+
+export const DEFAULT_INTERFACE_MODE: InterfaceMode = 'advanced'
+
+const INTERFACE_MODE_STORAGE_KEY = 'hermes.desktop.interfaceMode.v1'
+
+// Advanced is the ABSENCE of a mode: encoded as "no key" so a user who never
+// touched the picker never gains a record, and clearing the key means Advanced.
+const modeCodec: Codec<InterfaceMode> = {
+ decode: raw => (raw === 'simple' ? 'simple' : DEFAULT_INTERFACE_MODE),
+ encode: mode => (mode === DEFAULT_INTERFACE_MODE ? null : mode)
+}
+
+export const $interfaceMode = persistentAtom<InterfaceMode>(
+ INTERFACE_MODE_STORAGE_KEY,
+ DEFAULT_INTERFACE_MODE,
+ modeCodec
+)
+
+export function setInterfaceMode(mode: InterfaceMode) {
+ $interfaceMode.set(mode)
+}
+
+/** The ⌘K row and the rebindable `view.toggleSimpleMode` action. */
+export function toggleSimpleMode() {
+ setInterfaceMode($interfaceMode.get() === 'simple' ? 'advanced' : 'simple')
+}
+
+// ---------------------------------------------------------------------------
+// Policy: every preference a mode may shadow, typed by what it holds.
+// ---------------------------------------------------------------------------
+
+/** What a policy may look at when its answer depends on the install. */
+export interface ModeContext {
+ profileCount: number
+}
+
+export interface ModePolicy {
+ fileBrowserOpen: boolean
+ hideCodeDiffs: boolean
+ profileRailVisible: boolean
+ reasoningCollapsedByDefault: boolean
+ reviewOpen: boolean
+ sidebarRowMeta: SidebarRowMeta[]
+ statusbarVisible: boolean
+ terminalOpen: boolean
+ toolViewMode: ToolViewMode
+}
+
+export type ModePolicyKey = keyof ModePolicy
+
+type PolicyEntry<K extends ModePolicyKey> = ((context: ModeContext) => ModePolicy[K]) | ModePolicy[K]
+
+type PolicyTable = { readonly [K in ModePolicyKey]?: PolicyEntry<K> }
+
+const SIMPLE_POLICY: PolicyTable = {
+ // Hide-style panes rest closed; their keybinds and the agent still reveal them.
+ fileBrowserOpen: false,
+ // Inline diffs are the review pane's job; the changed-files summary stays.
+ hideCodeDiffs: true,
+ // Hide a door only when there is somewhere else to go: with the statusbar
+ // (and its fallback profile dropdown) gone, a second profile makes the rail
+ // the only way to switch, so it stays for multi-profile installs.
+ profileRailVisible: context => context.profileCount > 1,
+ // A quiet "Thought for Ns" row instead of a live reasoning stream.
+ reasoningCollapsedByDefault: true,
+ reviewOpen: false,
+ // What was said and when — cost, tokens, PR and profile chips are readouts.
+ sidebarRowMeta: ['preview', 'updated'],
+ statusbarVisible: false,
+ terminalOpen: false,
+ // Product summaries; the technical payload view is the instrumentation itself.
+ toolViewMode: 'product'
+}
+
+// Advanced is deliberately `{}`: anything added here would stop being the
+// user's own preference the moment they opened the picker.
+const POLICY: Record<InterfaceMode, PolicyTable> = {
+ advanced: {},
+ simple: SIMPLE_POLICY
+}
+
+/** Does this mode have an opinion about the surface at all? */
+const shadows = (key: ModePolicyKey, mode: InterfaceMode) => key in POLICY[mode]
+
+// The install facts a policy may consult. Fed by the app shell (profile roster),
+// kept off this module's imports so preference stores can depend on it without
+// dragging the session graph in.
+export const $modeContext = atom<ModeContext>({ profileCount: 1 })
+
+export function setModeContext(patch: Partial<ModeContext>) {
+ $modeContext.set({ ...$modeContext.get(), ...patch })
+}
+
+// ---------------------------------------------------------------------------
+// Session layer: reveals made while a surface is shadowed. In memory only, so
+// a restart returns to the mode's resting state; cleared on mode change so a
+// reveal cannot leak into the other mode.
+// ---------------------------------------------------------------------------
+
+const $modeReveals = atom<Partial<ModePolicy>>({})
+
+$interfaceMode.listen(() => $modeReveals.set({}))
+
+function resolvePolicy<K extends ModePolicyKey>(
+ key: K,
+ mode: InterfaceMode,
+ context: ModeContext
+): ModePolicy[K] | undefined {
+ const entry = POLICY[mode][key] as PolicyEntry<K> | undefined
+
+ return typeof entry === 'function' ? entry(context) : entry
+}
+
+/**
+ * Wrap a preference in the mode resolver. Reads give the EFFECTIVE value;
+ * writes route to the session layer while the surface is shadowed and to the
+ * preference otherwise, so every existing toggle keeps working unchanged.
+ */
+export function modeBound<K extends ModePolicyKey>(
+ key: K,
+ $preference: ReadableAtom<ModePolicy[K]>,
+ setPreference: (value: ModePolicy[K]) => void
+): WritableAtom<ModePolicy[K]> {
+ const $effective = computed(
+ [$interfaceMode, $modeReveals, $modeContext, $preference],
+ (mode, reveals, context, preference): ModePolicy[K] => {
+ const policy = resolvePolicy(key, mode, context)
+
+ if (policy === undefined) {
+ return preference
+ }
+
+ return key in reveals ? (reveals[key] as ModePolicy[K]) : policy
+ }
+ )
+
+ // A computed store updates itself through its own `set`, so the routed write
+ // cannot live on it. Mirror it into a plain atom and route that atom's `set`.
+ const $bound = atom<ModePolicy[K]>($effective.get())
+ const mirror = $bound.set
+
+ $effective.subscribe(value => mirror(value as ModePolicy[K]))
+
+ $bound.set = value => {
+ if (!shadows(key, $interfaceMode.get())) {
+ setPreference(value)
+ } else if (!layoutIntent) {
+ $modeReveals.set({ ...$modeReveals.get(), [key]: value })
+ }
+ }
+
+ return $bound
+}
+
+// A layout pick opens and closes the panes it places through these same
+// setters. That is LAYOUT intent, not "show me this": while a surface is
+// shadowed the mode already decides what rests, so inside `asLayoutIntent`
+// a shadowed write is dropped rather than turned into a session reveal — and
+// Simple still never writes a preference.
+let layoutIntent = false
+
+export function asLayoutIntent(run: () => void) {
+ layoutIntent = true
+
+ try {
+ run()
+ } finally {
+ layoutIntent = false
+ }
+}
+
+const shadowedCache = new Map<ModePolicyKey, ReadableAtom<boolean>>()
+
+/** Is the surface's value the mode's, not the user's? Settings rows read it to
+ * say who set their value. Cached per key so `useStore` keeps one subscription. */
+export function $modeShadowed(key: ModePolicyKey): ReadableAtom<boolean> {
+ let cached = shadowedCache.get(key)
+
+ if (!cached) {
+ cached = computed($interfaceMode, mode => shadows(key, mode))
+ shadowedCache.set(key, cached)
+ }
+
+ return cached
+}
+
+// ---------------------------------------------------------------------------
+// Tiers: list surfaces declare which items are instrumentation.
+// ---------------------------------------------------------------------------
+
+/** A tier names the one mode an item belongs to; an item with no tier shows in every mode. */
+export type InterfaceTier = InterfaceMode
+
+export interface Tiered {
+ tier?: InterfaceTier
+}
+
+/** Predicate for the filter a list already runs: `items.filter(shownInMode(mode))`. */
+export function shownInMode(mode: InterfaceMode): (item: Tiered) => boolean {
+ return item => item.tier === undefined || item.tier === mode
+}
+
+/** The one derived boolean for surfaces that are a single element, not a list. */
+export const $showsAdvancedChrome: ReadableAtom<boolean> = computed($interfaceMode, mode => mode === 'advanced')
diff --git a/apps/desktop/src/store/profile-rail-prefs.ts b/apps/desktop/src/store/profile-rail-prefs.ts
index 97ba769bb79..726d89a92cf 100644
--- a/apps/desktop/src/store/profile-rail-prefs.ts
+++ b/apps/desktop/src/store/profile-rail-prefs.ts
@@ -1,10 +1,17 @@
import { Codecs, persistentAtom } from '@/lib/persisted'
+import { modeBound } from '@/store/interface-mode'
// The colored profile strip at the sidebar foot. For someone who runs profiles
// as bots it duplicates the footer's gateway selector, so it can be switched
// off; while it is off the statusbar grows a profile dropdown beside the
// gateway switcher so switching profiles never loses its door. On by default.
-export const $profileRailVisible = persistentAtom('hermes.desktop.profileRailVisible', true, Codecs.bool)
+// Simple mode rests it hidden (unless it is the only door left) without
+// touching this preference.
+const $profileRailVisiblePref = persistentAtom('hermes.desktop.profileRailVisible', true, Codecs.bool)
+
+export const $profileRailVisible = modeBound('profileRailVisible', $profileRailVisiblePref, value =>
+ $profileRailVisiblePref.set(value)
+)
export function toggleProfileRailVisible() {
$profileRailVisible.set(!$profileRailVisible.get())
diff --git a/apps/desktop/src/store/reasoning-disclosure.ts b/apps/desktop/src/store/reasoning-disclosure.ts
index fd42d198207..25c26c72098 100644
--- a/apps/desktop/src/store/reasoning-disclosure.ts
+++ b/apps/desktop/src/store/reasoning-disclosure.ts
@@ -1,13 +1,21 @@
import { atom } from 'nanostores'
import { persistBoolean, storedBoolean } from '@/lib/storage'
+import { modeBound } from '@/store/interface-mode'
const REASONING_COLLAPSED_BY_DEFAULT_STORAGE_KEY = 'hermes.desktop.reasoning.collapsedByDefault'
-/** Desktop-local presentation preference; shared backend config must not be changed by a single window. */
-export const $reasoningCollapsedByDefault = atom(storedBoolean(REASONING_COLLAPSED_BY_DEFAULT_STORAGE_KEY, false))
+/** Desktop-local presentation preference; shared backend config must not be changed by a single window.
+ * Simple mode rests reasoning collapsed without touching this preference. */
+const $reasoningCollapsedByDefaultPref = atom(storedBoolean(REASONING_COLLAPSED_BY_DEFAULT_STORAGE_KEY, false))
-$reasoningCollapsedByDefault.subscribe(value => persistBoolean(REASONING_COLLAPSED_BY_DEFAULT_STORAGE_KEY, value))
+$reasoningCollapsedByDefaultPref.subscribe(value => persistBoolean(REASONING_COLLAPSED_BY_DEFAULT_STORAGE_KEY, value))
+
+export const $reasoningCollapsedByDefault = modeBound(
+ 'reasoningCollapsedByDefault',
+ $reasoningCollapsedByDefaultPref,
+ value => $reasoningCollapsedByDefaultPref.set(value)
+)
export function setReasoningCollapsedByDefault(value: boolean) {
$reasoningCollapsedByDefault.set(value)
diff --git a/apps/desktop/src/store/review.ts b/apps/desktop/src/store/review.ts
index 9704ac338ea..25120515cba 100644
--- a/apps/desktop/src/store/review.ts
+++ b/apps/desktop/src/store/review.ts
@@ -9,6 +9,7 @@ import { desktopGit } from '@/lib/desktop-git'
import { isExcludedPath } from '@/lib/excluded-paths'
import { requestOneShot } from '@/lib/oneshot'
import { Codecs, persistentAtom } from '@/lib/persisted'
+import { modeBound } from '@/store/interface-mode'
import { refreshRepoStatus, repoStatusForCwd } from './coding-status'
import { stampSessionPrBranch } from './pull-requests'
@@ -36,7 +37,11 @@ const REVIEW_REFRESH_DEBOUNCE_MS = 100
const SHIP_INFO_STALE_MS = 30_000
// Persisted so the pane stays open across reloads (like the other rail panes).
-export const $reviewOpen = persistentAtom(OPEN_KEY, false, Codecs.bool)
+// Simple mode rests it closed without touching the preference; ⌘G still opens
+// it for the session.
+const $reviewOpenPref = persistentAtom(OPEN_KEY, false, Codecs.bool)
+
+export const $reviewOpen = modeBound('reviewOpen', $reviewOpenPref, open => $reviewOpenPref.set(open))
// The split-button's remembered default action ('commit' | 'commitPush').
export type CommitAction = 'commit' | 'commitPush'
diff --git a/apps/desktop/src/store/statusbar-prefs.ts b/apps/desktop/src/store/statusbar-prefs.ts
index c1857368c4b..346a58b5af8 100644
--- a/apps/desktop/src/store/statusbar-prefs.ts
+++ b/apps/desktop/src/store/statusbar-prefs.ts
@@ -1,5 +1,6 @@
import { Codecs, persistentAtom } from '@/lib/persisted'
import { readKey } from '@/lib/storage'
+import { modeBound } from '@/store/interface-mode'
// v1 (`hermes.desktop.statusbarHidden`) was seeded with the approval pill
// hidden, so every existing store carries an `approval-mode` the user never
@@ -16,7 +17,12 @@ const STATUSBAR_VISIBLE_STORAGE_KEY = 'hermes.desktop.statusbarVisible.v2'
// Whole-bar visibility, VS Code's `workbench.statusBar.visible`. On by default.
// Hiding it unmounts the bar (its 15s status poll goes with it), so the way back
// is the `view.toggleStatusbar` keybind or the ⌘K row, never the bar itself.
-export const $statusbarVisible = persistentAtom(STATUSBAR_VISIBLE_STORAGE_KEY, true, Codecs.bool)
+// Simple mode rests the bar hidden without touching this preference.
+const $statusbarVisiblePref = persistentAtom(STATUSBAR_VISIBLE_STORAGE_KEY, true, Codecs.bool)
+
+export const $statusbarVisible = modeBound('statusbarVisible', $statusbarVisiblePref, value =>
+ $statusbarVisiblePref.set(value)
+)
export function toggleStatusbarVisible() {
$statusbarVisible.set(!$statusbarVisible.get())
diff --git a/apps/desktop/src/store/tool-view.ts b/apps/desktop/src/store/tool-view.ts
index 67bf77e5f33..bf9c3dc09b6 100644
--- a/apps/desktop/src/store/tool-view.ts
+++ b/apps/desktop/src/store/tool-view.ts
@@ -1,6 +1,7 @@
import { atom, computed, type ReadableAtom } from 'nanostores'
import { persistBoolean, storedBoolean } from '@/lib/storage'
+import { modeBound } from '@/store/interface-mode'
export type ToolViewMode = 'product' | 'technical'
@@ -11,16 +12,22 @@ const HIDE_CODE_DIFFS_STORAGE_KEY = 'hermes.desktop.toolView.hideCodeDiffs'
const TOOL_DISCLOSURE_STORAGE_KEY = 'hermes.desktop.toolDisclosure.v1'
const MAX_DISCLOSURE_STATES = 240
-export const $toolViewMode = atom<ToolViewMode>(
+// Simple mode rests on product summaries, diffs folded, without touching either
+// preference.
+const $toolViewModePref = atom<ToolViewMode>(
storedBoolean(TOOL_VIEW_TECHNICAL_STORAGE_KEY, false) ? 'technical' : 'product'
)
-export const $hideCodeDiffs = atom(storedBoolean(HIDE_CODE_DIFFS_STORAGE_KEY, false))
+
+const $hideCodeDiffsPref = atom(storedBoolean(HIDE_CODE_DIFFS_STORAGE_KEY, false))
+
+export const $toolViewMode = modeBound('toolViewMode', $toolViewModePref, mode => $toolViewModePref.set(mode))
+export const $hideCodeDiffs = modeBound('hideCodeDiffs', $hideCodeDiffsPref, hidden => $hideCodeDiffsPref.set(hidden))
export const $toolDisclosureStates = atom<ToolDisclosureStates>(loadToolDisclosureStates())
const disclosureOpenCache = new Map<string, ReadableAtom<boolean | undefined>>()
const anyDisclosureOpenCache = new Map<string, ReadableAtom<boolean>>()
-$toolViewMode.subscribe(mode => persistBoolean(TOOL_VIEW_TECHNICAL_STORAGE_KEY, mode === 'technical'))
-$hideCodeDiffs.subscribe(hidden => persistBoolean(HIDE_CODE_DIFFS_STORAGE_KEY, hidden))
+$toolViewModePref.subscribe(mode => persistBoolean(TOOL_VIEW_TECHNICAL_STORAGE_KEY, mode === 'technical'))
+$hideCodeDiffsPref.subscribe(hidden => persistBoolean(HIDE_CODE_DIFFS_STORAGE_KEY, hidden))
$toolDisclosureStates.subscribe(persistToolDisclosureStates)
export function setToolViewMode(mode: ToolViewMode) {