From a5ab449262d52d87a87b7f44a51faf16a200e702 Mon Sep 17 00:00:00 2001 From: nodemode-ai Date: Fri, 27 Nov 2026 21:44:55 -0500 Subject: [PATCH 01/15] feat(themes): one kinded list of all 21 themes and the shown theme ui/themes.ts now lists every theme with its kind and tells which theme the window shows for a mode, following the system when the mode is System. --- frontend/src/ui/themes.ts | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/frontend/src/ui/themes.ts b/frontend/src/ui/themes.ts index d8f3240..d33bce4 100644 --- a/frontend/src/ui/themes.ts +++ b/frontend/src/ui/themes.ts @@ -13,6 +13,25 @@ export const LIGHT_THEMES: ThemeEntry[] = [ { id: 'sage', label: 'Sage' }, { id: 'mist', label: 'Mist' }, { id: 'contrast', label: 'High contrast' }, ]; +export type ThemeKind = 'dark' | 'light'; +export interface KindedTheme extends ThemeEntry { kind: ThemeKind; name: string } + +export const ALL_THEMES: KindedTheme[] = [ + ...DARK_THEMES.map((t) => ({ ...t, kind: 'dark' as const, name: `${t.label} · dark` })), + ...LIGHT_THEMES.map((t) => ({ ...t, kind: 'light' as const, name: `${t.label} · light` })), +]; + +const systemLight = window.matchMedia('(prefers-color-scheme: light)'); +export const systemKind = (): ThemeKind => (systemLight.matches ? 'light' : 'dark'); +export const kindOfMode = (mode: string): ThemeKind => (mode === 'light' || mode === 'dark' ? mode : systemKind()); +export function onSystemKind(fn: () => void): void { systemLight.addEventListener('change', fn); } + +export function shownTheme(mode: string): { kind: ThemeKind; id: string } { + const kind = kindOfMode(mode); + const look = readLook(); + return { kind, id: kind === 'dark' ? look.dark : look.light }; +} + export const LOOK_KEY = 'formcite.look'; const OLED = ['amoled']; From 9c5c41cbfa8a2dcb4a4609fcdd03af7ecfea7c41 Mon Sep 17 00:00:00 2001 From: nodemode-ai Date: Fri, 27 Nov 2026 21:44:55 -0500 Subject: [PATCH 02/15] feat(preferences): all themes list that sets theme and mode in one pick Preferences gains a flat list of the 21 themes beside the two grids, kept in step with them, a following-the-system note beside the mode, and a reserved Details pane slot. --- frontend/src/styles/preferences.css | 9 ++++++ frontend/src/ui/preferences.ts | 48 ++++++++++++++++++++++++++--- 2 files changed, 52 insertions(+), 5 deletions(-) diff --git a/frontend/src/styles/preferences.css b/frontend/src/styles/preferences.css index 93341b2..1c3df7c 100644 --- a/frontend/src/styles/preferences.css +++ b/frontend/src/styles/preferences.css @@ -63,4 +63,13 @@ .fc-swatch-bar { background: var(--surface-2); border-inline-end: 1px solid var(--border); } .fc-swatch-line { align-self: center; height: var(--space-1); margin: 0 var(--space-2); border-radius: var(--radius-hair); background: var(--text-muted); } .fc-theme-name { overflow: hidden; white-space: nowrap; text-overflow: ellipsis; } +.fc-pr-row[data-row="mode"] { grid-template-columns: var(--fc-pr-label-w) minmax(0, 1fr) var(--fc-pr-label-w); } +.fc-pr-row[data-row="mode"] > .fc-pr-hint { text-align: end; } +.fc-theme-list { position: relative; margin: 0; padding: var(--space-1); list-style: none; height: calc(var(--fc-pr-row-h) * 7 + var(--space-1) * 2); overflow-y: auto; border: 1px solid var(--line-2); border-radius: var(--radius-sm); background: var(--surface-2); box-sizing: border-box; } +.fc-theme-list:focus-visible { outline: 2px solid var(--accent-color); outline-offset: 1px; } +.fc-theme-row { display: grid; grid-template-columns: var(--ctl-md) minmax(0, 1fr); align-items: center; column-gap: var(--space-2); height: var(--fc-pr-row-h); padding: 0 var(--space-2); border-radius: var(--radius-sm); color: var(--text-secondary); font-size: var(--fs-13); cursor: pointer; box-sizing: border-box; } +.fc-theme-row:hover { background: var(--hover); } +.fc-theme-row[aria-selected="true"] { background: var(--accent-color-dim); color: var(--text-primary); } +.fc-swatch-sm { height: var(--space-5); } +.fc-pref-slot { min-height: var(--fc-pr-row-h); } .fc-pr-error { margin: 0; height: var(--fc-pr-line-h); line-height: var(--fc-pr-line-h); color: var(--danger-text); font-size: var(--fs-12); overflow: hidden; white-space: nowrap; text-overflow: ellipsis; } diff --git a/frontend/src/ui/preferences.ts b/frontend/src/ui/preferences.ts index 00ec39d..b11353a 100644 --- a/frontend/src/ui/preferences.ts +++ b/frontend/src/ui/preferences.ts @@ -6,7 +6,7 @@ import type { LibraryInfo, NetOverview, NetService } from '../io/preferences'; import { delayedIndicator, el, escapeHtml, mountOnce, patchList, q, setChecked, setClass, setDisabled, setText, setValue } from './dom'; import { icon } from './icons'; import { loadWindowKey } from '../io/window-key'; -import { DARK_THEMES, LIGHT_THEMES, readLook, setLook, type ThemeEntry } from './themes'; +import { ALL_THEMES, DARK_THEMES, LIGHT_THEMES, onSystemKind, readLook, setLook, shownTheme, type ThemeEntry } from './themes'; const SWITCH = ''; @@ -17,17 +17,27 @@ function themeGrid(kind: 'dark' | 'light', label: string, list: ThemeEntry[]): s return `
${label}
${picks}
Used whenever the appearance is ${kind}.
`; } +function themeList(): string { + const rows = ALL_THEMES.map((t) => `
  • ${escapeHtml(t.name)}
  • `).join(''); + return `
    All themes
      ${rows}
    Picking one also switches the appearance to its kind.
    `; +} + function shell(): string { const themes = themeOptions().map((t) => ``).join(''); return `

    ${icon('sliders', 14)}Appearance

    -
    +
    ${themeGrid('dark', 'Dark theme', DARK_THEMES)} ${themeGrid('light', 'Light theme', LIGHT_THEMES)} + ${themeList()}
    +
    +

    ${icon('sliders', 14)}Details pane

    +
    +

    ${icon('link', 14)}Network

    FormCite connects to nothing unless you or an agent asks for a lookup. Every call is listed below.

    @@ -89,22 +99,50 @@ export function mountPreferences(engine: Engine, host: HTMLElement): void { return delayedIndicator(() => setClass(node, 'is-busy', true), () => setClass(node, 'is-busy', false)); }; - const showAppearance = (): void => { + const modeHint = q(root, '[data-role="mode-hint"]'); + const list = q(root, '.fc-theme-list'); + const rows = Array.from(list.querySelectorAll('.fc-theme-row')); + const showAppearance = (mode: string = currentAppearance().theme): void => { const a = currentAppearance(); - setValue(theme, a.theme); + setValue(theme, mode); setValue(accent, a.accent); const look = readLook(); for (const b of root.querySelectorAll('.fc-theme-pick')) { const on = String(b.dataset.v === (b.dataset.kind === 'dark' ? look.dark : look.light)); if (b.getAttribute('aria-checked') !== on) b.setAttribute('aria-checked', on); } + const shown = shownTheme(mode); + for (const r of rows) { + const on = String(r.dataset.kind === shown.kind && r.dataset.v === shown.id); + if (r.getAttribute('aria-selected') !== on) r.setAttribute('aria-selected', on); + } + setText(modeHint, mode === 'system' ? `Following the system (${shown.kind})` : ''); + }; + const pickRow = (r: HTMLElement): void => { + const kind = r.dataset.kind === 'light' ? 'light' : 'dark'; + const id = r.dataset.v ?? 'default'; + setLook(kind === 'dark' ? { dark: id } : { light: id }); + chooseTheme(engine, kind); + showAppearance(kind); }; root.addEventListener('click', (ev) => { + const r = (ev.target as Element).closest('.fc-theme-row'); + if (r) { pickRow(r); return; } const b = (ev.target as Element).closest('.fc-theme-pick'); if (!b || !b.dataset.v) return; setLook(b.dataset.kind === 'dark' ? { dark: b.dataset.v } : { light: b.dataset.v }); showAppearance(); }); + list.addEventListener('keydown', (ev) => { + if (ev.key !== 'ArrowDown' && ev.key !== 'ArrowUp') return; + ev.preventDefault(); + const at = rows.findIndex((r) => r.getAttribute('aria-selected') === 'true'); + const next = rows[Math.max(0, Math.min(rows.length - 1, at + (ev.key === 'ArrowDown' ? 1 : -1)))]; + pickRow(next); + if (next.offsetTop < list.scrollTop) list.scrollTop = next.offsetTop; + else if (next.offsetTop + next.offsetHeight > list.scrollTop + list.clientHeight) list.scrollTop = next.offsetTop + next.offsetHeight - list.clientHeight; + }); + onSystemKind(() => showAppearance()); const showNetwork = (n: NetOverview): void => { net = n; @@ -256,7 +294,7 @@ export function mountPreferences(engine: Engine, host: HTMLElement): void { })(); }); - engine.events.on('theme:changed', (id) => setValue(theme, id)); + engine.events.on('theme:changed', (id) => showAppearance(id)); engine.library.events.on('view', (view) => { if (view !== 'preferences') return; showAppearance(); From 8a6a70bd0b87d38f417adc4e680a07d5a544add4 Mon Sep 17 00:00:00 2001 From: nodemode-ai Date: Fri, 27 Nov 2026 21:45:05 -0500 Subject: [PATCH 03/15] feat(preferences): keep other keys in the appearance save and store the title field mode The appearance save now merges into the stored object, and a title field mode (fixed by default, or grow) lives in its own key with change listeners. --- frontend/src/engine/preferences.ts | 42 +++++++++++++++++++++++++++++- 1 file changed, 41 insertions(+), 1 deletion(-) diff --git a/frontend/src/engine/preferences.ts b/frontend/src/engine/preferences.ts index e6c6ac8..cb83ee4 100644 --- a/frontend/src/engine/preferences.ts +++ b/frontend/src/engine/preferences.ts @@ -35,7 +35,12 @@ function readAppearance(): Appearance { function saveAppearance(a: Appearance): void { try { - localStorage.setItem(KEY, JSON.stringify(a)); + let kept: Record = {}; + try { + const s = JSON.parse(localStorage.getItem(KEY) || 'null') as unknown; + if (s && typeof s === 'object' && !Array.isArray(s)) kept = s as Record; + } catch { kept = {}; } + localStorage.setItem(KEY, JSON.stringify({ ...kept, ...a })); } catch (e) { console.error('[appearance] save failed:', e); } @@ -76,6 +81,41 @@ export function chooseAccent(hex: string): void { applyAppearance(a); } +export type TitleField = 'fixed' | 'grow'; + +const DETAIL_KEY = 'formcite.detail'; +export const TITLE_FIELD_OPTIONS: { id: TitleField; label: string }[] = [{ id: 'grow', label: 'Grow with the title' }, { id: 'fixed', label: 'Fixed height' }]; +const titleFieldListeners = new Set<(m: TitleField) => void>(); + +function readDetailPrefs(): Record { + try { + const s = JSON.parse(localStorage.getItem(DETAIL_KEY) || 'null') as unknown; + if (s && typeof s === 'object' && !Array.isArray(s)) return s as Record; + } catch (e) { + console.error('[detail prefs] read failed:', e); + } + return {}; +} + +export function titleFieldMode(): TitleField { + return readDetailPrefs().titleField === 'grow' ? 'grow' : 'fixed'; +} + +export function setTitleFieldMode(mode: TitleField): void { + const m: TitleField = mode === 'grow' ? 'grow' : 'fixed'; + try { + localStorage.setItem(DETAIL_KEY, JSON.stringify({ ...readDetailPrefs(), titleField: m })); + } catch (e) { + console.error('[detail prefs] save failed:', e); + } + for (const fn of titleFieldListeners) fn(m); +} + +export function onTitleFieldMode(fn: (m: TitleField) => void): () => void { + titleFieldListeners.add(fn); + return () => { titleFieldListeners.delete(fn); }; +} + export function describeEntry(e: NetLogEntry): { when: string; what: string; result: string } { const when = e.time.replace('T', ' ').slice(0, 19); const result = e.error ? e.error : e.status === null ? 'no answer' : String(e.status); From 95af9739621ee91b11ba95bb659275890ac2bb8f Mon Sep 17 00:00:00 2001 From: nodemode-ai Date: Fri, 27 Nov 2026 21:45:05 -0500 Subject: [PATCH 04/15] feat(detail): shift enter saves the title and a fixed height title mode Shift or Ctrl or Cmd plus Enter saves the title, plain Enter does nothing, a muted hint sits in the title row, and the pane root carries data-title-field so the fixed mode keeps the box three lines tall. --- frontend/src/styles/detail.css | 8 +++++--- frontend/src/ui/detail.ts | 15 ++++++++++++++- 2 files changed, 19 insertions(+), 4 deletions(-) diff --git a/frontend/src/styles/detail.css b/frontend/src/styles/detail.css index f6724f5..830b393 100644 --- a/frontend/src/styles/detail.css +++ b/frontend/src/styles/detail.css @@ -35,9 +35,11 @@ .fc-dt-input { box-sizing: border-box; width: 100%; height: var(--dt-row-h); min-width: 0; padding: 0 var(--space-2); border: 1px solid var(--border); border-radius: var(--radius-sm); background: var(--surface); color: var(--text); font: inherit; } .fc-dt-input:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-wash); } .fc-dt-row[data-field="title"] { --dt-title-h: 36px; grid-template-columns: minmax(0, 1fr) var(--dt-mark-w); grid-template-rows: var(--text-lg) auto; height: auto; min-height: calc(var(--text-lg) + var(--dt-title-h) + var(--space-1)); row-gap: var(--space-1); align-items: start; } -.fc-dt-row[data-field="title"] > .fc-dt-label { grid-column: 1 / -1; } -.fc-dt-row[data-field="title"] > .fc-dt-input { height: auto; min-height: var(--dt-title-h); padding: var(--space-1h) var(--space-2); font-size: var(--text-md); font-weight: var(--weight-medium); line-height: 1.3; resize: none; overflow: hidden; overflow-wrap: anywhere; field-sizing: content; } -.fc-dt-row[data-field="title"] > .fc-dt-mark { align-self: center; } +.fc-dt-row[data-field="title"] > .fc-dt-label { grid-row: 1; grid-column: 1 / -1; } +.fc-dt-row[data-field="title"] > .fc-dt-hint { grid-row: 1; grid-column: 1; justify-self: end; align-self: center; color: var(--text-faint); font-size: var(--fs-11); white-space: nowrap; pointer-events: none; } +.fc-dt-row[data-field="title"] > .fc-dt-input { grid-row: 2; grid-column: 1; height: auto; min-height: var(--dt-title-h); padding: var(--space-1h) var(--space-2); font-size: var(--text-md); font-weight: var(--weight-medium); line-height: 1.3; resize: none; overflow: hidden; overflow-wrap: anywhere; field-sizing: content; } +.fc-dt-row[data-field="title"] > .fc-dt-mark { grid-row: 2; grid-column: 2; align-self: center; } +.fc-dt:not([data-title-field="grow"]) .fc-dt-row[data-field="title"] > .fc-dt-input { field-sizing: fixed; height: calc(3lh + 2 * var(--space-1h) + 2px); overflow-y: auto; } .fc-dt-block { height: var(--dt-block-h); padding: var(--space-1) var(--space-2); resize: none; overflow: auto; line-height: 1.4; } .fc-dt-mark { width: var(--dt-mark-w); height: var(--dt-mark-w); border-radius: 50%; background: transparent; } .fc-dt-row.is-saving .fc-dt-mark { background: var(--text-muted); } diff --git a/frontend/src/ui/detail.ts b/frontend/src/ui/detail.ts index c5573eb..814ec35 100644 --- a/frontend/src/ui/detail.ts +++ b/frontend/src/ui/detail.ts @@ -3,6 +3,7 @@ import { DetailModel, FIELDS, ROLES, TYPES, creatorBlank, fieldText, newCreator, import type { Attachment, ItemDetail, Note } from '../io/detail'; import { delayedIndicator, el, escapeHtml, patchList, q, setClass, setDisabled, setHidden, setText, setTitle, setValue, type Disposer } from './dom'; import { toast } from './toast'; +import { onTitleFieldMode, titleFieldMode } from '../engine/preferences'; const ICON = { trash: '', @@ -68,6 +69,7 @@ const AUTO_SIZE = typeof CSS !== 'undefined' && CSS.supports('field-sizing', 'co function fit(control: Control): void { if (AUTO_SIZE || !control.classList.contains('fc-dt-title')) return; + if (control.closest('.fc-dt')?.getAttribute('data-title-field') !== 'grow') { control.style.removeProperty('height'); return; } control.style.height = '0'; control.style.height = `${control.scrollHeight + 2}px`; } @@ -84,8 +86,10 @@ function fieldRow(spec: FieldSpec): HTMLElement { } else { control = ``; } + const hint = spec.key === 'title' ? `Shift+Enter to save` : ''; + if (hint) control = control.replace('