~bigbes/lethe

ref: 8aeda698dc352ac3d1e93b667f56ad5dbd68d8b9 lethe/web/src/features/settings/DisplaySection.tsx -rw-r--r-- 3.6 KiB
8aeda698 — Eugene Blikh feat: add search UI layer — SearchTable, SearchFilters, SaveSearchForm, route, and styles 24 days ago
                                                                                
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
import React from 'react'
import { getThemePreference, setTheme } from '../../lib/theme'
import type { ThemePreference } from '../../lib/theme'
import { getDensityPreference, setDensity } from '../../lib/density'
import type { DensityPreference } from '../../lib/density'
import { getToolCallsPreference, setToolCalls } from '../../lib/toolCalls'
import type { ToolCallsPreference } from '../../lib/toolCalls'

export function DisplaySection(): React.JSX.Element {
  const [theme, setThemeState] = React.useState<ThemePreference>(getThemePreference)
  const [density, setDensityState] = React.useState<DensityPreference>(getDensityPreference)
  const [toolCalls, setToolCallsState] = React.useState<ToolCallsPreference>(
    getToolCallsPreference,
  )

  function handleThemeChange(value: ThemePreference) {
    setThemeState(value)
    setTheme(value === 'system' ? null : value)
  }

  function handleDensityChange(value: DensityPreference | null) {
    const next = value ?? 'cozy'
    setDensityState(next)
    setDensity(value)
  }

  function handleToolCallsChange(value: ToolCallsPreference | null) {
    const next = value ?? 'yes'
    setToolCallsState(next)
    setToolCalls(value)
  }

  return (
    <div className="display-section">
      <fieldset>
        <legend>Theme</legend>
        <label>
          <input
            type="radio"
            name="theme"
            value="system"
            checked={theme === 'system'}
            onChange={() => handleThemeChange('system')}
          />
          System
        </label>
        <label>
          <input
            type="radio"
            name="theme"
            value="light"
            checked={theme === 'light'}
            onChange={() => handleThemeChange('light')}
          />
          Light
        </label>
        <label>
          <input
            type="radio"
            name="theme"
            value="dark"
            checked={theme === 'dark'}
            onChange={() => handleThemeChange('dark')}
          />
          Dark
        </label>
        <div className="display-help">
          Follows your OS appearance setting when System is selected.
        </div>
      </fieldset>

      <fieldset>
        <legend>Row density</legend>
        <label>
          <input
            type="radio"
            name="density"
            value="cozy"
            checked={density === 'cozy'}
            onChange={() => handleDensityChange('cozy')}
          />
          Cozy
        </label>
        <label>
          <input
            type="radio"
            name="density"
            value="compact"
            checked={density === 'compact'}
            onChange={() => handleDensityChange('compact')}
          />
          Compact
        </label>
        <div className="display-help">
          Controls vertical spacing in session lists and project tables.
        </div>
      </fieldset>

      <fieldset>
        <legend>Tool calls</legend>
        <label>
          <input
            type="radio"
            name="toolCalls"
            value="yes"
            checked={toolCalls === 'yes'}
            onChange={() => handleToolCallsChange('yes')}
          />
          Show
        </label>
        <label>
          <input
            type="radio"
            name="toolCalls"
            value="no"
            checked={toolCalls === 'no'}
            onChange={() => handleToolCallsChange('no')}
          />
          Hide
        </label>
        <div className="display-help">
          Tool-call turns are hidden with CSS; they remain in the DOM for
          anchor-target and selection stability.
        </div>
      </fieldset>
    </div>
  )
}