|
|
@@ -80,6 +80,7 @@ import { QuestionPrompt } from "./question"
|
|
|
import { DialogExportOptions } from "../../ui/dialog-export-options"
|
|
|
import * as Model from "../../util/model"
|
|
|
import { formatTranscript } from "../../util/transcript"
|
|
|
+import { setPreLayoutSiblingMargin } from "../../util/layout"
|
|
|
import { UI } from "@/cli/ui.ts"
|
|
|
import { useTuiConfig } from "../../context/tui-config"
|
|
|
import { nextThinkingMode, reasoningSummary, useThinkingMode, type ThinkingMode } from "../../context/thinking"
|
|
|
@@ -168,6 +169,7 @@ const context = createContext<{
|
|
|
showTimestamps: () => boolean
|
|
|
showDetails: () => boolean
|
|
|
showGenericToolOutput: () => boolean
|
|
|
+ userMessageIDs: () => ReadonlySet<string>
|
|
|
diffWrapMode: () => "word" | "none"
|
|
|
providers: () => ReadonlyMap<string, Provider>
|
|
|
sync: ReturnType<typeof useSync>
|
|
|
@@ -209,6 +211,14 @@ export function Session() {
|
|
|
),
|
|
|
),
|
|
|
)
|
|
|
+ const userMessageIDs = createMemo(
|
|
|
+ () =>
|
|
|
+ new Set(
|
|
|
+ messages()
|
|
|
+ .filter((message) => message.role === "user")
|
|
|
+ .map((message) => message.id),
|
|
|
+ ),
|
|
|
+ )
|
|
|
const permissions = createMemo(() => {
|
|
|
if (session()?.parentID) return []
|
|
|
return children().flatMap((x) => sync.data.permission[x.id] ?? [])
|
|
|
@@ -1160,6 +1170,7 @@ export function Session() {
|
|
|
showTimestamps,
|
|
|
showDetails,
|
|
|
showGenericToolOutput,
|
|
|
+ userMessageIDs,
|
|
|
diffWrapMode,
|
|
|
providers,
|
|
|
sync,
|
|
|
@@ -1895,9 +1906,7 @@ function InlineTool(props: {
|
|
|
pending={props.pending}
|
|
|
spinner={props.spinner}
|
|
|
subagent={props.subagent}
|
|
|
- separateAfter={(id) =>
|
|
|
- sync.data.message[ctx.sessionID]?.some((message) => message.role === "user" && message.id === id) ?? false
|
|
|
- }
|
|
|
+ separateAfter={(id) => id !== undefined && ctx.userMessageIDs().has(id)}
|
|
|
onMouseOver={() => clickable() && setHover(true)}
|
|
|
onMouseOut={() => setHover(false)}
|
|
|
onMouseUp={() => {
|
|
|
@@ -1934,35 +1943,24 @@ export function InlineToolRow(props: {
|
|
|
onMouseOut?: () => void
|
|
|
onMouseUp?: () => void
|
|
|
}) {
|
|
|
- const [margin, setMargin] = createSignal(0)
|
|
|
-
|
|
|
return (
|
|
|
<box
|
|
|
id={props.id}
|
|
|
- marginTop={margin()}
|
|
|
paddingLeft={3}
|
|
|
onMouseOver={props.onMouseOver}
|
|
|
onMouseOut={props.onMouseOut}
|
|
|
onMouseUp={props.onMouseUp}
|
|
|
- renderBefore={function () {
|
|
|
- const el = this as BoxRenderable
|
|
|
- const parent = el.parent
|
|
|
- if (!parent) {
|
|
|
- return
|
|
|
- }
|
|
|
- const children = parent.getChildren()
|
|
|
- const index = children.indexOf(el)
|
|
|
- const previous = children[index - 1]
|
|
|
- const previousInline = previous?.id.startsWith("tool-inline-") ?? false
|
|
|
- const previousSubagent = previous?.id.startsWith("tool-inline-subagent-") ?? false
|
|
|
- setMargin(
|
|
|
- previous?.id.startsWith("text-") ||
|
|
|
+ ref={(el: BoxRenderable) => {
|
|
|
+ setPreLayoutSiblingMargin(el, (previous) => {
|
|
|
+ const previousInline = previous?.id.startsWith("tool-inline-") ?? false
|
|
|
+ const previousSubagent = previous?.id.startsWith("tool-inline-subagent-") ?? false
|
|
|
+ return previous?.id.startsWith("text-") ||
|
|
|
previous?.id.startsWith("tool-block-") ||
|
|
|
(previousInline && previousSubagent !== Boolean(props.subagent)) ||
|
|
|
props.separateAfter?.(previous?.id)
|
|
|
? 1
|
|
|
- : 0,
|
|
|
- )
|
|
|
+ : 0
|
|
|
+ })
|
|
|
}}
|
|
|
>
|
|
|
<Switch>
|