Improve the transcript: tool grouping, report auto-ack, context meter, spinner, Enter to send

This commit is contained in:
Ian Gulliver
2026-10-14 16:03:46 -07:00
parent ca2644374d
commit ab4c3d2c6f
19 changed files with 734 additions and 92 deletions
+39 -6
View File
@@ -58,12 +58,45 @@ type Block struct {
}
type Result struct {
Subtype string `json:"subtype"`
IsError bool `json:"is_error"`
Result string `json:"result"`
DurationMS int `json:"duration_ms"`
NumTurns int `json:"num_turns"`
TotalCostUSD float64 `json:"total_cost_usd"`
Subtype string `json:"subtype"`
IsError bool `json:"is_error"`
Result string `json:"result"`
DurationMS int `json:"duration_ms"`
NumTurns int `json:"num_turns"`
TotalCostUSD float64 `json:"total_cost_usd"`
ModelUsage map[string]ModelUsage `json:"modelUsage"`
}
type ModelUsage struct {
ContextWindow int `json:"contextWindow"`
}
type ContextUsage struct {
Model string
Tokens int
}
func (e Event) ContextUsage() (ContextUsage, error) {
msg := struct {
Message struct {
Model string `json:"model"`
Usage struct {
InputTokens int `json:"input_tokens"`
CacheCreationInputTokens int `json:"cache_creation_input_tokens"`
CacheReadInputTokens int `json:"cache_read_input_tokens"`
OutputTokens int `json:"output_tokens"`
} `json:"usage"`
} `json:"message"`
}{}
err := json.Unmarshal(e.Raw, &msg)
if err != nil {
return ContextUsage{}, err
}
u := msg.Message.Usage
return ContextUsage{
Model: msg.Message.Model,
Tokens: u.InputTokens + u.CacheCreationInputTokens + u.CacheReadInputTokens + u.OutputTokens,
}, nil
}
func (e Event) Blocks() ([]Block, error) {