mirror of
https://gitea.toothfairyai.com/ToothFairyAI/tf_code.git
synced 2026-04-10 02:39:56 +00:00
fix(app): timeline jank
This commit is contained in:
@@ -762,10 +762,12 @@ function ContextToolGroup(props: { parts: ToolPart[]; busy?: boolean }) {
|
||||
</Collapsible.Trigger>
|
||||
<Collapsible.Content>
|
||||
<div data-component="context-tool-group-list">
|
||||
<For each={props.parts}>
|
||||
{(part) => {
|
||||
const trigger = contextToolTrigger(part, i18n)
|
||||
const running = part.state.status === "pending" || part.state.status === "running"
|
||||
<Index each={props.parts}>
|
||||
{(partAccessor) => {
|
||||
const trigger = createMemo(() => contextToolTrigger(partAccessor(), i18n))
|
||||
const running = createMemo(
|
||||
() => partAccessor().state.status === "pending" || partAccessor().state.status === "running",
|
||||
)
|
||||
return (
|
||||
<div data-slot="context-tool-group-item">
|
||||
<div data-component="tool-trigger">
|
||||
@@ -774,13 +776,13 @@ function ContextToolGroup(props: { parts: ToolPart[]; busy?: boolean }) {
|
||||
<div data-slot="basic-tool-tool-info-structured">
|
||||
<div data-slot="basic-tool-tool-info-main">
|
||||
<span data-slot="basic-tool-tool-title">
|
||||
<TextShimmer text={trigger.title} active={running} />
|
||||
<TextShimmer text={trigger().title} active={running()} />
|
||||
</span>
|
||||
<Show when={!running && trigger.subtitle}>
|
||||
<span data-slot="basic-tool-tool-subtitle">{trigger.subtitle}</span>
|
||||
<Show when={!running() && trigger().subtitle}>
|
||||
<span data-slot="basic-tool-tool-subtitle">{trigger().subtitle}</span>
|
||||
</Show>
|
||||
<Show when={!running && trigger.args?.length}>
|
||||
<For each={trigger.args}>
|
||||
<Show when={!running() && trigger().args?.length}>
|
||||
<For each={trigger().args}>
|
||||
{(arg) => <span data-slot="basic-tool-tool-arg">{arg}</span>}
|
||||
</For>
|
||||
</Show>
|
||||
@@ -792,7 +794,7 @@ function ContextToolGroup(props: { parts: ToolPart[]; busy?: boolean }) {
|
||||
</div>
|
||||
)
|
||||
}}
|
||||
</For>
|
||||
</Index>
|
||||
</div>
|
||||
</Collapsible.Content>
|
||||
</Collapsible>
|
||||
@@ -1096,30 +1098,30 @@ function ToolFileAccordion(props: { path: string; actions?: JSX.Element; childre
|
||||
|
||||
PART_MAPPING["tool"] = function ToolPartDisplay(props) {
|
||||
const i18n = useI18n()
|
||||
const part = props.part as ToolPart
|
||||
if (part.tool === "todowrite" || part.tool === "todoread") return null
|
||||
const part = () => props.part as ToolPart
|
||||
if (part().tool === "todowrite" || part().tool === "todoread") return null
|
||||
|
||||
const hideQuestion = createMemo(
|
||||
() => part.tool === "question" && (part.state.status === "pending" || part.state.status === "running"),
|
||||
() => part().tool === "question" && (part().state.status === "pending" || part().state.status === "running"),
|
||||
)
|
||||
|
||||
const emptyInput: Record<string, any> = {}
|
||||
const emptyMetadata: Record<string, any> = {}
|
||||
|
||||
const input = () => part.state?.input ?? emptyInput
|
||||
const input = () => part().state?.input ?? emptyInput
|
||||
// @ts-expect-error
|
||||
const partMetadata = () => part.state?.metadata ?? emptyMetadata
|
||||
const partMetadata = () => part().state?.metadata ?? emptyMetadata
|
||||
|
||||
const render = ToolRegistry.render(part.tool) ?? GenericTool
|
||||
const render = createMemo(() => ToolRegistry.render(part().tool) ?? GenericTool)
|
||||
|
||||
return (
|
||||
<Show when={!hideQuestion()}>
|
||||
<div data-component="tool-part-wrapper">
|
||||
<Switch>
|
||||
<Match when={part.state.status === "error" && part.state.error}>
|
||||
<Match when={part().state.status === "error" && (part().state as any).error}>
|
||||
{(error) => {
|
||||
const cleaned = error().replace("Error: ", "")
|
||||
if (part.tool === "question" && cleaned.includes("dismissed this question")) {
|
||||
if (part().tool === "question" && cleaned.includes("dismissed this question")) {
|
||||
return (
|
||||
<div style="width: 100%; display: flex; justify-content: flex-end;">
|
||||
<span class="text-13-regular text-text-weak cursor-default">
|
||||
@@ -1151,13 +1153,13 @@ PART_MAPPING["tool"] = function ToolPartDisplay(props) {
|
||||
</Match>
|
||||
<Match when={true}>
|
||||
<Dynamic
|
||||
component={render}
|
||||
component={render()}
|
||||
input={input()}
|
||||
tool={part.tool}
|
||||
tool={part().tool}
|
||||
metadata={partMetadata()}
|
||||
// @ts-expect-error
|
||||
output={part.state.output}
|
||||
status={part.state.status}
|
||||
output={part().state.output}
|
||||
status={part().state.status}
|
||||
hideDetails={props.hideDetails}
|
||||
defaultOpen={props.defaultOpen}
|
||||
/>
|
||||
@@ -1186,7 +1188,7 @@ PART_MAPPING["compaction"] = function CompactionPartDisplay() {
|
||||
PART_MAPPING["text"] = function TextPartDisplay(props) {
|
||||
const data = useData()
|
||||
const i18n = useI18n()
|
||||
const part = props.part as TextPart
|
||||
const part = () => props.part as TextPart
|
||||
const interrupted = createMemo(
|
||||
() =>
|
||||
props.message.role === "assistant" && (props.message as AssistantMessage).error?.name === "MessageAbortedError",
|
||||
@@ -1229,18 +1231,18 @@ PART_MAPPING["text"] = function TextPartDisplay(props) {
|
||||
return items.filter((x) => !!x).join(" \u00B7 ")
|
||||
})
|
||||
|
||||
const displayText = () => (part.text ?? "").trim()
|
||||
const displayText = () => (part().text ?? "").trim()
|
||||
const throttledText = createThrottledValue(displayText)
|
||||
const isLastTextPart = createMemo(() => {
|
||||
const last = (data.store.part?.[props.message.id] ?? [])
|
||||
.filter((item): item is TextPart => item?.type === "text" && !!item.text?.trim())
|
||||
.at(-1)
|
||||
return last?.id === part.id
|
||||
return last?.id === part().id
|
||||
})
|
||||
const showCopy = createMemo(() => {
|
||||
if (props.message.role !== "assistant") return isLastTextPart()
|
||||
if (props.showAssistantCopyPartID === null) return false
|
||||
if (typeof props.showAssistantCopyPartID === "string") return props.showAssistantCopyPartID === part.id
|
||||
if (typeof props.showAssistantCopyPartID === "string") return props.showAssistantCopyPartID === part().id
|
||||
return isLastTextPart()
|
||||
})
|
||||
const [copied, setCopied] = createSignal(false)
|
||||
@@ -1257,7 +1259,7 @@ PART_MAPPING["text"] = function TextPartDisplay(props) {
|
||||
<Show when={throttledText()}>
|
||||
<div data-component="text-part">
|
||||
<div data-slot="text-part-body">
|
||||
<Markdown text={throttledText()} cacheKey={part.id} />
|
||||
<Markdown text={throttledText()} cacheKey={part().id} />
|
||||
</div>
|
||||
<Show when={showCopy()}>
|
||||
<div data-slot="text-part-copy-wrapper" data-interrupted={interrupted() ? "" : undefined}>
|
||||
@@ -1288,14 +1290,14 @@ PART_MAPPING["text"] = function TextPartDisplay(props) {
|
||||
}
|
||||
|
||||
PART_MAPPING["reasoning"] = function ReasoningPartDisplay(props) {
|
||||
const part = props.part as ReasoningPart
|
||||
const text = () => part.text.trim()
|
||||
const part = () => props.part as ReasoningPart
|
||||
const text = () => part().text.trim()
|
||||
const throttledText = createThrottledValue(text)
|
||||
|
||||
return (
|
||||
<Show when={throttledText()}>
|
||||
<div data-component="reasoning-part">
|
||||
<Markdown text={throttledText()} cacheKey={part.id} />
|
||||
<Markdown text={throttledText()} cacheKey={part().id} />
|
||||
</div>
|
||||
</Show>
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user