fix(tui): restore compaction model marker
This commit is contained in:
parent
634386fe0f
commit
76f205d260
13 changed files with 105 additions and 19 deletions
|
|
@ -732,6 +732,7 @@ export const { use: useData, provider: DataProvider } = createSimpleContext({
|
|||
Object.assign(current, {
|
||||
status: "completed",
|
||||
reason: event.data.reason,
|
||||
model: event.data.model,
|
||||
summary: event.data.text,
|
||||
recent: event.data.recent,
|
||||
})
|
||||
|
|
@ -742,6 +743,7 @@ export const { use: useData, provider: DataProvider } = createSimpleContext({
|
|||
type: "compaction",
|
||||
status: "completed",
|
||||
reason: event.data.reason,
|
||||
model: event.data.model,
|
||||
summary: event.data.text,
|
||||
recent: event.data.recent,
|
||||
time: { created: event.created },
|
||||
|
|
|
|||
|
|
@ -73,7 +73,7 @@ import { OPENCODE_BASE_MODE, useBindings, useCommandShortcut } from "../../keyma
|
|||
import { usePathFormatter } from "../../context/path-format"
|
||||
import { LocationProvider } from "../../context/location"
|
||||
import { createSessionRows, resolvePart, type PartRef, type SessionRow } from "./rows"
|
||||
import { switchLabel } from "../../util/model"
|
||||
import { compactionMarker, switchLabel } from "../../util/model"
|
||||
|
||||
addDefaultParsers(parsers.parsers)
|
||||
|
||||
|
|
@ -1306,10 +1306,14 @@ function SessionSkillMessage(props: { message: Extract<SessionMessageInfo, { typ
|
|||
|
||||
function CompactionMessage(props: { message: Extract<SessionMessageInfo, { type: "compaction" }> }) {
|
||||
const ctx = use()
|
||||
const local = useLocal()
|
||||
const { theme, syntax } = useTheme()
|
||||
const status = () => props.message.status
|
||||
const text = () => (props.message.status === "failed" ? props.message.error.message : props.message.summary)
|
||||
const content = createMemo(() => text().trim())
|
||||
const marker = createMemo(() =>
|
||||
compactionMarker(props.message.status === "completed" ? props.message.model : undefined, ctx.models()),
|
||||
)
|
||||
const color = () => (status() === "failed" ? theme.error : theme.textMuted)
|
||||
return (
|
||||
<box>
|
||||
|
|
@ -1344,6 +1348,16 @@ function CompactionMessage(props: { message: Extract<SessionMessageInfo, { type:
|
|||
/>
|
||||
</box>
|
||||
</Show>
|
||||
<Show when={marker()}>
|
||||
{(value) => (
|
||||
<box paddingLeft={3} marginTop={1}>
|
||||
<text>
|
||||
<span style={{ fg: local.agent.color(value().agent) }}>{Locale.titlecase(value().agent)}</span>
|
||||
<span style={{ fg: theme.textMuted }}> · {value().model}</span>
|
||||
</text>
|
||||
</box>
|
||||
)}
|
||||
</Show>
|
||||
</box>
|
||||
)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -7,6 +7,18 @@ export function formatRef(model: { providerID: string; id: string; variant?: str
|
|||
return [model.providerID, model.id, model.variant].filter((value) => value !== undefined).join("/")
|
||||
}
|
||||
|
||||
export function compactionMarker(
|
||||
model: { providerID: string; id: string; variant?: string } | undefined,
|
||||
models?: readonly { providerID: string; id: string; name: string }[],
|
||||
) {
|
||||
if (!model) return
|
||||
return {
|
||||
agent: "compaction",
|
||||
model:
|
||||
models?.find((item) => item.providerID === model.providerID && item.id === model.id)?.name ?? formatRef(model),
|
||||
}
|
||||
}
|
||||
|
||||
export function switchLabel(
|
||||
model: { providerID: string; id: string; variant?: string },
|
||||
models?: readonly { providerID: string; id: string; name: string }[],
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue