MCPcopy
hub / github.com/anomalyco/opencode / DebugBar

Function DebugBar

packages/app/src/components/debug-bar.tsx:110–498  ·  view source on GitHub ↗
(props: { inline?: boolean } = {})

Source from the content-addressed store, hash-verified

108}
109
110export function DebugBar(props: { inline?: boolean } = {}) {
111 const language = useLanguage()
112 const location = useLocation()
113 const routing = useIsRouting()
114 const [state, setState] = createStore({
115 cls: undefined as number | undefined,
116 delay: undefined as number | undefined,
117 fps: undefined as number | undefined,
118 gap: undefined as number | undefined,
119 heap: {
120 limit: undefined as number | undefined,
121 used: undefined as number | undefined,
122 },
123 inp: undefined as number | undefined,
124 jank: undefined as number | undefined,
125 long: {
126 block: undefined as number | undefined,
127 count: undefined as number | undefined,
128 max: undefined as number | undefined,
129 },
130 nav: {
131 dur: undefined as number | undefined,
132 pending: false,
133 },
134 })
135
136 const na = () => language.t("debugBar.na").toUpperCase()
137 const heap = () => (state.heap.limit ? (state.heap.used ?? 0) / state.heap.limit : undefined)
138 const heapv = () => {
139 const value = heap()
140 if (value === undefined) return na()
141 return `${Math.round(value * 100)}%`
142 }
143 const longv = () => (state.long.count === undefined ? na() : `${time(state.long.block) ?? na()}/${state.long.count}`)
144 const navv = () => (state.nav.pending ? "..." : (time(state.nav.dur) ?? na()))
145
146 let prev = ""
147 let start = 0
148 let init = false
149 let one = 0
150 let two = 0
151
152 createEffect(() => {
153 const busy = routing()
154 const next = `${location.pathname}${location.search}`
155
156 if (!init) {
157 init = true
158 prev = next
159 return
160 }
161
162 if (busy) {
163 if (one !== 0) cancelAnimationFrame(one)
164 if (two !== 0) cancelAnimationFrame(two)
165 one = 0
166 two = 0
167 if (start !== 0) return

Callers

nothing calls this directly

Calls 15

useLocationFunction · 0.85
setStateFunction · 0.85
syncLongFunction · 0.85
syncInpFunction · 0.85
syncHeapFunction · 0.85
navvFunction · 0.85
badFunction · 0.85
naFunction · 0.85
longvFunction · 0.85
mbFunction · 0.85
heapvFunction · 0.85
heapFunction · 0.85

Tested by

no test coverage detected