Skip to content

bug: Missing validation for token calculations causes display issue #229

@johnsaigle

Description

@johnsaigle

A value of 0 for Tokens results in a negative percentage value at the lower bound of int64 (MinInt64)

Image

The bug is in this function, something to do with the float64 calculations being forcibly converted to int in the log statement. Claude is suggesting that this is what happens when a float NaN value is converted to an int but I didn't dig deeper to see if that's true.

https://github.com/sst/opencode/blob/34d68b777af3f28b4fba5e941e2e080a3a9c579a/packages/tui/internal/components/status/status.go#L50-L75

I'm not sure why the Tokens value ends up being 0 either.

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions