opencode-tweaks 0.7.0 → 0.7.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +2 -1
- package/package.json +1 -1
- package/src/tweaks/model-panel.tsx +54 -36
package/README.md
CHANGED
|
@@ -198,7 +198,8 @@ The cost settings used to live in the Tokens entry. A choice saved there before
|
|
|
198
198
|
### Model
|
|
199
199
|
|
|
200
200
|
Model shows the model the session is using and its list price in the sidebar, under the quota. The name, provider,
|
|
201
|
-
and reasoning variant come from the session, so the card follows `/models`.
|
|
201
|
+
and reasoning variant come from the session, so the card follows `/models`. Click the `Model` header to collapse or
|
|
202
|
+
expand the card.
|
|
202
203
|
|
|
203
204
|
`Input price`, `Output price`, and `Cache read price` choose the rates, all in dollars per million tokens. The card
|
|
204
205
|
uses the catalog price that applies to the session's context, so a long-context tier shows the higher rate with its
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { Context, SlotMap } from "@opencode/plugin/tui/context"
|
|
2
2
|
import { TextAttributes } from "@opentui/core"
|
|
3
|
-
import { createEffect, createMemo, createSignal, onCleanup, Show } from "solid-js"
|
|
3
|
+
import { createEffect, createMemo, createSignal, For, onCleanup, Show } from "solid-js"
|
|
4
4
|
import { formatRate, priceFor } from "../usage/cost"
|
|
5
5
|
import { hasPriceSchedule, priceWindowFor } from "../usage/price-window"
|
|
6
6
|
import { formatTokens } from "../usage/tokens"
|
|
@@ -53,6 +53,7 @@ function ModelBody(props: {
|
|
|
53
53
|
}) {
|
|
54
54
|
const theme = () => props.context.theme
|
|
55
55
|
const [now, setNow] = createSignal(Date.now())
|
|
56
|
+
const [collapsed, setCollapsed] = createSignal(false)
|
|
56
57
|
|
|
57
58
|
const inputOn = () => props.store.read(modelTweak, INPUT).value === true
|
|
58
59
|
const outputOn = () => props.store.read(modelTweak, OUTPUT).value === true
|
|
@@ -106,26 +107,25 @@ function ModelBody(props: {
|
|
|
106
107
|
|
|
107
108
|
const rates = createMemo(() => {
|
|
108
109
|
const value = price()
|
|
109
|
-
if (!value) return
|
|
110
|
-
|
|
111
|
-
const
|
|
112
|
-
if (inputOn())
|
|
113
|
-
if (outputOn())
|
|
114
|
-
if (cacheOn())
|
|
115
|
-
if (
|
|
116
|
-
|
|
110
|
+
if (!value) return []
|
|
111
|
+
|
|
112
|
+
const rows: { label: string; value: string }[] = []
|
|
113
|
+
if (inputOn()) rows.push({ label: "in", value: formatRate(value.input) })
|
|
114
|
+
if (outputOn()) rows.push({ label: "out", value: formatRate(value.output) })
|
|
115
|
+
if (cacheOn()) rows.push({ label: "cache", value: formatRate(value.cache.read) })
|
|
116
|
+
if (rows.length > 0 && value.tier) {
|
|
117
|
+
rows.push({ label: "from", value: `>${formatTokens(value.tier.size, "compact")}` })
|
|
117
118
|
}
|
|
118
119
|
|
|
119
|
-
return
|
|
120
|
+
return rows
|
|
120
121
|
})
|
|
121
122
|
|
|
122
123
|
const variant = () => (variantOn() ? entry()?.ref.variant : undefined)
|
|
123
124
|
|
|
124
|
-
const
|
|
125
|
-
const
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
return parts.length > 0 ? parts.join(" · ") : undefined
|
|
125
|
+
const title = () => {
|
|
126
|
+
const name = entry()?.name
|
|
127
|
+
const selected = variant()
|
|
128
|
+
return selected ? `${name} · ${selected}` : name
|
|
129
129
|
}
|
|
130
130
|
|
|
131
131
|
const scheduled = () => {
|
|
@@ -139,10 +139,10 @@ function ModelBody(props: {
|
|
|
139
139
|
return priceWindowFor(ref, new Date(now()))
|
|
140
140
|
}
|
|
141
141
|
|
|
142
|
-
const
|
|
142
|
+
const stateValue = () => {
|
|
143
143
|
if (!peakOn() || !scheduled()) return undefined
|
|
144
|
-
const
|
|
145
|
-
return
|
|
144
|
+
const value = peak()
|
|
145
|
+
return value ? `${value.label} ×${value.multiplier} now` : "off-peak"
|
|
146
146
|
}
|
|
147
147
|
|
|
148
148
|
// The live peak marker follows the clock, so refresh it while the card can
|
|
@@ -156,28 +156,46 @@ function ModelBody(props: {
|
|
|
156
156
|
})
|
|
157
157
|
|
|
158
158
|
return (
|
|
159
|
-
<box flexDirection="column"
|
|
160
|
-
<
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
159
|
+
<box flexDirection="column">
|
|
160
|
+
<box
|
|
161
|
+
flexDirection="row"
|
|
162
|
+
justifyContent="space-between"
|
|
163
|
+
onMouseUp={() => setCollapsed((value) => !value)}
|
|
164
|
+
>
|
|
165
|
+
<text attributes={TextAttributes.BOLD} fg={theme().text.base}>
|
|
166
|
+
{collapsed() ? "▶" : "▼"} Model
|
|
166
167
|
</text>
|
|
167
|
-
<Show when={
|
|
168
|
-
<text fg={theme().text.
|
|
169
|
-
{
|
|
170
|
-
</text>
|
|
171
|
-
</Show>
|
|
172
|
-
<Show when={rates()}>
|
|
173
|
-
<text fg={theme().text.muted} wrapMode="word">
|
|
174
|
-
{rates()}
|
|
168
|
+
<Show when={entry()?.provider}>
|
|
169
|
+
<text attributes={TextAttributes.BOLD} fg={theme().text.base} wrapMode="none">
|
|
170
|
+
{entry()?.provider}
|
|
175
171
|
</text>
|
|
176
172
|
</Show>
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
173
|
+
</box>
|
|
174
|
+
<Show when={!collapsed()}>
|
|
175
|
+
<Show when={entry()} fallback={<text fg={theme().text.muted}>No model selected</text>}>
|
|
176
|
+
<text fg={theme().text.base} wrapMode="word">
|
|
177
|
+
{title()}
|
|
180
178
|
</text>
|
|
179
|
+
<For each={rates()}>
|
|
180
|
+
{(row) => (
|
|
181
|
+
<box flexDirection="row" gap={1}>
|
|
182
|
+
<text flexShrink={0} fg={theme().text.muted}>
|
|
183
|
+
{row.label.padEnd(5)}
|
|
184
|
+
</text>
|
|
185
|
+
<text fg={theme().text.base}>{row.value}</text>
|
|
186
|
+
</box>
|
|
187
|
+
)}
|
|
188
|
+
</For>
|
|
189
|
+
<Show when={stateValue()}>
|
|
190
|
+
<box flexDirection="row" gap={1}>
|
|
191
|
+
<text flexShrink={0} fg={theme().text.muted}>
|
|
192
|
+
{"state".padEnd(5)}
|
|
193
|
+
</text>
|
|
194
|
+
<text fg={peak() ? theme().text.feedback.warning.base : theme().text.muted}>
|
|
195
|
+
{stateValue()}
|
|
196
|
+
</text>
|
|
197
|
+
</box>
|
|
198
|
+
</Show>
|
|
181
199
|
</Show>
|
|
182
200
|
</Show>
|
|
183
201
|
</box>
|