Visitar URL original
fix(tui): drop ttft from the assistant footer (#63759) · anomalyco/opencode@507c939 · GitHub
Skip to content

Commit 507c939

Browse files
authored
fix(tui): drop ttft from the assistant footer (#63759)
1 parent 191a69a commit 507c939

4 files changed

Lines changed: 5 additions & 23 deletions

File tree

‎packages/tui/src/routes/session/index.tsx‎

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2030,7 +2030,6 @@ function AssistantFooter(props: { message: SessionMessageAssistant }) {
20302030
const turn = () => ({ index: ctx.messageIndex(props.message.id), legacy: ctx.legacyTurns() })
20312031
const duration = createMemo(() => SessionTurn.duration(messages(), props.message, turn()))
20322032
const tokensPerSecond = createMemo(() => SessionTurn.tokensPerSecond(messages(), props.message, turn()))
2033-
const timeToFirstToken = createMemo(() => SessionTurn.timeToFirstToken(messages(), props.message, turn()))
20342033
const interrupted = createMemo(() => props.message.error?.message === "Step interrupted")
20352034
const freeLimit = createMemo(() => props.message.error?.type === "provider.free-limit")
20362035
const limitNotice = useLimitNotice(() => props.message)
@@ -2065,9 +2064,6 @@ function AssistantFooter(props: { message: SessionMessageAssistant }) {
20652064
<Show when={config.data.session.tps && tokensPerSecond()}>
20662065
{(value) => <span style={{ fg: theme.text.muted }}> · {value().toFixed(1)} tok/s</span>}
20672066
</Show>
2068-
<Show when={config.data.session.tps && ctx.terminal.width >= 36 && timeToFirstToken()}>
2069-
{(value) => <span style={{ fg: theme.text.muted }}> · {Locale.duration(value())} ttft</span>}
2070-
</Show>
20712067
<Show when={interrupted()}>
20722068
<span style={{ fg: theme.text.muted }}> · interrupted</span>
20732069
</Show>

‎packages/tui/test/app-lifecycle.test.tsx‎

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -795,7 +795,8 @@ test("keeps assistant footer metrics current after prepend, same-length refresh,
795795
(frame) => frame.includes("Original answer") && frame.includes("40.0 tok/s"),
796796
)
797797
expect(initial).toContain("Current input")
798-
expect(initial).toContain("4.0s \u00b7 40.0 tok/s \u00b7 500ms ttft")
798+
expect(initial).toContain("4.0s \u00b7 40.0 tok/s")
799+
expect(initial).not.toContain("ttft")
799800
expect(initial).not.toContain("Prepended input")
800801

801802
setup.mockInput.pressKey("g", { ctrl: true })
@@ -810,7 +811,7 @@ test("keeps assistant footer metrics current after prepend, same-length refresh,
810811
)
811812
expect(prepended).toContain("Current input")
812813
expect(prepended).toContain("Original answer")
813-
expect(prepended).toContain("4.0s \u00b7 40.0 tok/s \u00b7 500ms ttft")
814+
expect(prepended).toContain("4.0s \u00b7 40.0 tok/s")
814815

815816
// Refresh the latest page: length stays four, but the retained assistant moves from index three to one.
816817
refresh = true
@@ -826,7 +827,7 @@ test("keeps assistant footer metrics current after prepend, same-length refresh,
826827
)
827828
expect(refreshed).toContain("Current input")
828829
expect(refreshed).toContain("Original answer")
829-
expect(refreshed).toContain("4.0s \u00b7 40.0 tok/s \u00b7 500ms ttft")
830+
expect(refreshed).toContain("4.0s \u00b7 40.0 tok/s")
830831
expect(refreshed).toContain("3.0s \u00b7 50.0 tok/s")
831832

832833
setup.events.emit({
@@ -841,7 +842,7 @@ test("keeps assistant footer metrics current after prepend, same-length refresh,
841842
(frame) => frame.includes("Original answer") && !frame.includes("Later input") && !frame.includes("Later answer"),
842843
)
843844
expect(reverted).toContain("Current input")
844-
expect(reverted).toContain("4.0s \u00b7 40.0 tok/s \u00b7 500ms ttft")
845+
expect(reverted).toContain("4.0s \u00b7 40.0 tok/s")
845846
expect(reverted).not.toContain("50.0 tok/s")
846847
})
847848

@@ -2844,4 +2845,3 @@ test.each([44, 100])(
28442845
},
28452846
15_000,
28462847
)
2847-

‎packages/util/src/session-turn.test.ts‎

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@ test("measures decode throughput from the first streamed token", () => {
2222

2323
// 65 tokens over the 5s the provider spent streaming them, not the 10s that include waiting for the first.
2424
expect(SessionTurn.tokensPerSecond(messages, final)).toBe(13)
25-
expect(SessionTurn.timeToFirstToken(messages, final)).toBe(2_000)
2625
})
2726

2827
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"
3231

3332
// The old step counts its 4s request window, the new one its 3s decode window.
3433
expect(SessionTurn.tokensPerSecond(messages, final)).toBe(65 / 7)
35-
// Only the step that recorded a first token can report how long it waited for one.
36-
expect(SessionTurn.timeToFirstToken(messages, final)).toBe(1_000)
3734
})
3835

3936
test("measures request throughput including reasoning without tool time", () => {
@@ -42,7 +39,6 @@ test("measures request throughput including reasoning without tool time", () =>
4239
const messages = [input("user-1", 1_000), first, final]
4340

4441
expect(SessionTurn.tokensPerSecond(messages, final)).toBe(6.5)
45-
expect(SessionTurn.timeToFirstToken(messages, final)).toBeUndefined()
4642
first.time.streamed = undefined
4743
expect(SessionTurn.tokensPerSecond(messages, final)).toBeUndefined()
4844
})

‎packages/util/src/session-turn.ts‎

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -55,16 +55,6 @@ export function tokensPerSecond(messages: readonly Message[], message: Message,
5555
return output / (total / 1_000)
5656
}
5757

58-
/**
59-
* Milliseconds from the dispatch of the turn's first token-producing step to its first streamed token, or undefined
60-
* until a step records one.
61-
*/
62-
export function timeToFirstToken(messages: readonly Message[], message: Message, options: Options = {}) {
63-
const step = turnSteps(messages, message, options).find((item) => item.time.firstToken !== undefined)
64-
if (step?.time.firstToken === undefined) return
65-
return Math.max(0, step.time.firstToken - step.time.created)
66-
}
67-
6858
export function legacy(messages: readonly Message[]) {
6959
return !messages.some((message) => message.type === "idle")
7060
}

0 commit comments

Comments
 (0)