mirror of
https://github.com/anomalyco/opencode.git
synced 2026-11-16 05:01:03 +03:00
docs(plugin): show GUI plugins where session usage data lives (#61517)
This commit is contained in:
committed by
GitHub
Unverified
parent
9028e90039
commit
4b370b4020
@@ -2312,6 +2312,28 @@ interface NotifyResult {
|
||||
}
|
||||
```
|
||||
|
||||
### Usage data
|
||||
|
||||
A session's token, cost and plan figures are in its server's data, the same reactive store the app reads for the
|
||||
header's "28k · $0.28". Read them there rather than from opencode's database.
|
||||
|
||||
```ts
|
||||
import { lastAssistantWithUsage } from "@opencode/client/solid"
|
||||
|
||||
const data = session.server.data
|
||||
const info = () => data.session.get(session.id)
|
||||
|
||||
const tokens = () => info()?.tokens // this session's tokens by kind
|
||||
const cost = () => data.session.cost(session.id) // USD, with subagent sessions
|
||||
const step = () => lastAssistantWithUsage(data.session.message.list(session.id), info()?.revert?.messageID)
|
||||
const limits = () => (session.location ? data.location.usage.limits(session.location) : undefined)
|
||||
```
|
||||
|
||||
- `step()` is the assistant step whose tokens fill the context window now, as the app's context ring uses. Compare its
|
||||
`tokens` with the model's `limit.context` from `data.location.model.list`.
|
||||
- `limits()` holds the OpenCode Console budgets and Go plan allowance once `data.location.usage.sync(location)` has
|
||||
loaded them. It is `null` when the server reports none.
|
||||
|
||||
### Tabs
|
||||
|
||||
`ctx.tabs` reads and changes the shell's tab strip: the sessions and drafts open as tabs. This moves a session's tab to
|
||||
|
||||
Reference in New Issue
Block a user