~bigbes/lethe

ref: 2d9d2b8ec08ee09cc64c5d925ab85716b1d7d1fb lethe/web/src/lib/toolCalls.ts -rw-r--r-- 889 bytes
2d9d2b8e — Eugene Blikh search: add /api/v1/search API and opencode collector parser 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
// Tool-calls display preference — side-effect-free at import time.
// Call bootstrapToolCalls() once from main.tsx before render.

export type ToolCallsPreference = 'yes' | 'no'

export function getToolCallsPreference(): ToolCallsPreference {
  const stored = localStorage.getItem('showToolCalls')
  if (stored === 'no') return 'no'
  return 'yes'
}

export function bootstrapToolCalls(): void {
  const val = getToolCallsPreference()
  document.documentElement.dataset['showToolcalls'] = val === 'yes' ? 'true' : 'false'
}

export function setToolCalls(value: ToolCallsPreference | null): void {
  if (value === null) {
    localStorage.removeItem('showToolCalls')
    document.documentElement.dataset['showToolcalls'] = 'true'
  } else {
    localStorage.setItem('showToolCalls', value)
    document.documentElement.dataset['showToolcalls'] = value === 'yes' ? 'true' : 'false'
  }
}