chore: cleanup (#17284)

This commit is contained in:
Adam
2026-03-13 06:27:58 -05:00
committed by GitHub
parent 46ba9c8170
commit 270cb0b8b4
23 changed files with 516 additions and 357 deletions

View File

@@ -1,4 +1,5 @@
import { Show, createEffect, createMemo, createSignal, on, onCleanup, onMount } from "solid-js"
import { Show, createEffect, createMemo, on, onCleanup, onMount } from "solid-js"
import { createStore } from "solid-js/store"
import { TextShimmer } from "./text-shimmer"
function common(active: string, done: string) {
@@ -35,8 +36,12 @@ export function ToolStatusTitle(props: {
const activeTail = createMemo(() => (suffix() ? split().active : props.activeText))
const doneTail = createMemo(() => (suffix() ? split().done : props.doneText))
const [width, setWidth] = createSignal("auto")
const [ready, setReady] = createSignal(false)
const [state, setState] = createStore({
width: "auto",
ready: false,
})
const width = () => state.width
const ready = () => state.ready
let activeRef: HTMLSpanElement | undefined
let doneRef: HTMLSpanElement | undefined
let frame: number | undefined
@@ -45,7 +50,7 @@ export function ToolStatusTitle(props: {
const measure = () => {
const target = props.active ? activeRef : doneRef
const px = contentWidth(target)
if (px > 0) setWidth(`${px}px`)
if (px > 0) setState("width", `${px}px`)
}
const schedule = () => {
@@ -62,13 +67,13 @@ export function ToolStatusTitle(props: {
const finish = () => {
if (typeof requestAnimationFrame !== "function") {
setReady(true)
setState("ready", true)
return
}
if (readyFrame !== undefined) cancelAnimationFrame(readyFrame)
readyFrame = requestAnimationFrame(() => {
readyFrame = undefined
setReady(true)
setState("ready", true)
})
}