Skip to content

Commit d879f26

Browse files
committed
fix(tui): respect Copilot context tier in prompt usage
1 parent af9d84c commit d879f26

1 file changed

Lines changed: 4 additions & 7 deletions

File tree

‎packages/tui/src/component/prompt/index.tsx‎

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@ import type { AssistantMessage, FilePart, UserMessage } from "@opencode-ai/sdk/v
4141
import { Locale } from "../../util/locale"
4242
import { errorMessage } from "../../util/error"
4343
import { formatDuration } from "../../util/format"
44+
import { contextLimit, formatSessionCost } from "../../util/accounting"
4445
import { createColors, createFrames } from "../../ui/spinner"
4546
import { useDialog } from "../../ui/dialog"
4647
import { DialogProvider as DialogProviderConnect } from "../dialog-provider"
@@ -96,11 +97,6 @@ export type PromptRef = {
9697
submit(): void
9798
}
9899

99-
const money = new Intl.NumberFormat("en-US", {
100-
style: "currency",
101-
currency: "USD",
102-
})
103-
104100
const DRAFT_RETENTION_MIN_CHARS = 20
105101

106102
function randomIndex(count: number) {
@@ -273,11 +269,12 @@ export function Prompt(props: PromptProps) {
273269
if (tokens <= 0) return
274270

275271
const model = sync.data.provider.find((item) => item.id === last.providerID)?.models[last.modelID]
276-
const pct = model?.limit.context ? `${Math.round((tokens / model.limit.context) * 100)}%` : undefined
272+
const limit = contextLimit(model, last.variant)
273+
const pct = limit ? `${Math.round((tokens / limit) * 100)}%` : undefined
277274
const cost = session?.cost ?? 0
278275
return {
279276
context: pct ? `${Locale.number(tokens)} (${pct})` : Locale.number(tokens),
280-
cost: cost > 0 ? money.format(cost) : undefined,
277+
cost: cost > 0 ? formatSessionCost(cost, msg) : undefined,
281278
}
282279
})
283280

0 commit comments

Comments
 (0)