mirror of
https://github.com/anomalyco/opencode.git
synced 2026-11-20 01:08:31 +03:00
fix(tui): drop ttft from the assistant footer (#63759)
This commit is contained in:
@@ -2030,7 +2030,6 @@ function AssistantFooter(props: { message: SessionMessageAssistant }) {
|
||||
const turn = () => ({ index: ctx.messageIndex(props.message.id), legacy: ctx.legacyTurns() })
|
||||
const duration = createMemo(() => SessionTurn.duration(messages(), props.message, turn()))
|
||||
const tokensPerSecond = createMemo(() => SessionTurn.tokensPerSecond(messages(), props.message, turn()))
|
||||
const timeToFirstToken = createMemo(() => SessionTurn.timeToFirstToken(messages(), props.message, turn()))
|
||||
const interrupted = createMemo(() => props.message.error?.message === "Step interrupted")
|
||||
const freeLimit = createMemo(() => props.message.error?.type === "provider.free-limit")
|
||||
const limitNotice = useLimitNotice(() => props.message)
|
||||
@@ -2065,9 +2064,6 @@ function AssistantFooter(props: { message: SessionMessageAssistant }) {
|
||||
<Show when={config.data.session.tps && tokensPerSecond()}>
|
||||
{(value) => <span style={{ fg: theme.text.muted }}> · {value().toFixed(1)} tok/s</span>}
|
||||
</Show>
|
||||
<Show when={config.data.session.tps && ctx.terminal.width >= 36 && timeToFirstToken()}>
|
||||
{(value) => <span style={{ fg: theme.text.muted }}> · {Locale.duration(value())} ttft</span>}
|
||||
</Show>
|
||||
<Show when={interrupted()}>
|
||||
<span style={{ fg: theme.text.muted }}> · interrupted</span>
|
||||
</Show>
|
||||
|
||||
@@ -795,7 +795,8 @@ test("keeps assistant footer metrics current after prepend, same-length refresh,
|
||||
(frame) => frame.includes("Original answer") && frame.includes("40.0 tok/s"),
|
||||
)
|
||||
expect(initial).toContain("Current input")
|
||||
expect(initial).toContain("4.0s \u00b7 40.0 tok/s \u00b7 500ms ttft")
|
||||
expect(initial).toContain("4.0s \u00b7 40.0 tok/s")
|
||||
expect(initial).not.toContain("ttft")
|
||||
expect(initial).not.toContain("Prepended input")
|
||||
|
||||
setup.mockInput.pressKey("g", { ctrl: true })
|
||||
@@ -810,7 +811,7 @@ test("keeps assistant footer metrics current after prepend, same-length refresh,
|
||||
)
|
||||
expect(prepended).toContain("Current input")
|
||||
expect(prepended).toContain("Original answer")
|
||||
expect(prepended).toContain("4.0s \u00b7 40.0 tok/s \u00b7 500ms ttft")
|
||||
expect(prepended).toContain("4.0s \u00b7 40.0 tok/s")
|
||||
|
||||
// Refresh the latest page: length stays four, but the retained assistant moves from index three to one.
|
||||
refresh = true
|
||||
@@ -826,7 +827,7 @@ test("keeps assistant footer metrics current after prepend, same-length refresh,
|
||||
)
|
||||
expect(refreshed).toContain("Current input")
|
||||
expect(refreshed).toContain("Original answer")
|
||||
expect(refreshed).toContain("4.0s \u00b7 40.0 tok/s \u00b7 500ms ttft")
|
||||
expect(refreshed).toContain("4.0s \u00b7 40.0 tok/s")
|
||||
expect(refreshed).toContain("3.0s \u00b7 50.0 tok/s")
|
||||
|
||||
setup.events.emit({
|
||||
@@ -841,7 +842,7 @@ test("keeps assistant footer metrics current after prepend, same-length refresh,
|
||||
(frame) => frame.includes("Original answer") && !frame.includes("Later input") && !frame.includes("Later answer"),
|
||||
)
|
||||
expect(reverted).toContain("Current input")
|
||||
expect(reverted).toContain("4.0s \u00b7 40.0 tok/s \u00b7 500ms ttft")
|
||||
expect(reverted).toContain("4.0s \u00b7 40.0 tok/s")
|
||||
expect(reverted).not.toContain("50.0 tok/s")
|
||||
})
|
||||
|
||||
@@ -2844,4 +2845,3 @@ test.each([44, 100])(
|
||||
},
|
||||
15_000,
|
||||
)
|
||||
|
||||
|
||||
@@ -22,7 +22,6 @@ test("measures decode throughput from the first streamed token", () => {
|
||||
|
||||
// 65 tokens over the 5s the provider spent streaming them, not the 10s that include waiting for the first.
|
||||
expect(SessionTurn.tokensPerSecond(messages, final)).toBe(13)
|
||||
expect(SessionTurn.timeToFirstToken(messages, final)).toBe(2_000)
|
||||
})
|
||||
|
||||
test("falls back to the request window for steps recorded without a first token", () => {
|
||||
@@ -32,8 +31,6 @@ test("falls back to the request window for steps recorded without a first token"
|
||||
|
||||
// The old step counts its 4s request window, the new one its 3s decode window.
|
||||
expect(SessionTurn.tokensPerSecond(messages, final)).toBe(65 / 7)
|
||||
// Only the step that recorded a first token can report how long it waited for one.
|
||||
expect(SessionTurn.timeToFirstToken(messages, final)).toBe(1_000)
|
||||
})
|
||||
|
||||
test("measures request throughput including reasoning without tool time", () => {
|
||||
@@ -42,7 +39,6 @@ test("measures request throughput including reasoning without tool time", () =>
|
||||
const messages = [input("user-1", 1_000), first, final]
|
||||
|
||||
expect(SessionTurn.tokensPerSecond(messages, final)).toBe(6.5)
|
||||
expect(SessionTurn.timeToFirstToken(messages, final)).toBeUndefined()
|
||||
first.time.streamed = undefined
|
||||
expect(SessionTurn.tokensPerSecond(messages, final)).toBeUndefined()
|
||||
})
|
||||
|
||||
@@ -55,16 +55,6 @@ export function tokensPerSecond(messages: readonly Message[], message: Message,
|
||||
return output / (total / 1_000)
|
||||
}
|
||||
|
||||
/**
|
||||
* Milliseconds from the dispatch of the turn's first token-producing step to its first streamed token, or undefined
|
||||
* until a step records one.
|
||||
*/
|
||||
export function timeToFirstToken(messages: readonly Message[], message: Message, options: Options = {}) {
|
||||
const step = turnSteps(messages, message, options).find((item) => item.time.firstToken !== undefined)
|
||||
if (step?.time.firstToken === undefined) return
|
||||
return Math.max(0, step.time.firstToken - step.time.created)
|
||||
}
|
||||
|
||||
export function legacy(messages: readonly Message[]) {
|
||||
return !messages.some((message) => message.type === "idle")
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user