~bigbes/lethe

ref: 538e632d05ea9cd425e52f87d4877822bd721a75 lethe/web/src/lib/toolCalls.ts -rw-r--r-- 889 bytes
538e632d — Eugene Blikh collector: skip rejected rows after partial ingest 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'
  }
}