Skip to content

fix(cli): keep the wallet-balance readout fresh with a periodic refresh - #7914

Open
JPShag wants to merge 1 commit into
esengine:main-v2from
JPShag:fix/cli-balance-periodic-refresh
Open

fix(cli): keep the wallet-balance readout fresh with a periodic refresh#7914
JPShag wants to merge 1 commit into
esengine:main-v2from
JPShag:fix/cli-balance-periodic-refresh

Conversation

@JPShag

@JPShag JPShag commented Aug 7, 2026

Copy link
Copy Markdown

What

The DeepSeek wallet-balance (BAL) readout in the CLI status line only refreshed at startup, at turn end, and after a model switch. A missed turn_done — the event-loss the desktop already guards against — or a long delivery-mode turn with no turn boundary froze the readout at the startup value for the rest of the session.

This adds a periodic refresh: the TUI re-queries the provider balance every 60s and re-arms the timer, independent of event delivery, so BAL stays roughly current even when no turn ends.

Changes

  • internal/cli/chat_tui.go: balanceTickMsg + balanceRefreshTick periodic timer armed at Init; the tick fetches a fresh balance and re-arms; balanceRefreshCmds keeps the fetch/re-arm work testable.
  • internal/cli/statusline_test.go: coverage that a balance tick fetches a fresh balance and re-arms, that Update wires the tick, and that Init arms the timer.
  • tools/repolint/baseline.json: bumped only chat_tui.go (complexity 301→302, file-size 4558→4589, function-size 1203→1206); the file sits at its ratchet ceiling.

Verification

  • go test ./internal/cli/ -run TestBalance -count=1 passes
  • go test ./internal/cli/ -count=1 (no new failures; pre-existing TestModelSwitchRefreshesCustomStatusline also fails on a clean checkout)
  • go test ./internal/tool/builtin/ ./internal/boot/ -count=1 passes
  • go vet ./internal/cli/ and go build ./... clean
  • go run ./tools/repolint clean

Documentation-impact: none - user-visible change confined to the CLI status-line refresh cadence; no docs describe when the BAL readout updates, and its meaning is unchanged.

Copilot AI lite review requested due to automatic review settings August 7, 2026 23:49
@github-actions github-actions Bot added tui Terminal UI / CLI (internal/cli, internal/control) v2 Go rewrite (1.x) — main-v2 branch, active development labels Aug 7, 2026

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds a periodic wallet-balance refresh to the CLI TUI so the BAL status-line readout stays up to date even if turn_done is missed or a long delivery-mode turn has no boundary.

Changes:

  • Introduces a 60s periodic balanceTickMsg (tea.Tick) and wiring in Init/Update to fetch balance and re-arm the timer.
  • Factors the tick’s work into balanceRefreshCmds() to make the behavior testable without waiting for real time.
  • Adds unit tests covering the tick fetch, Update wiring, and Init scheduling; updates repolint baseline ratchet values.

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 1 comment.

File Description
internal/cli/chat_tui.go Adds periodic balance tick message, scheduling, and helper commands for refresh + re-arm.
internal/cli/statusline_test.go Adds tests ensuring periodic refresh fetches a fresh balance and is scheduled by Update/Init.
tools/repolint/baseline.json Updates repolint baseline numbers to account for the small size/complexity increase.

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment thread internal/cli/chat_tui.go Outdated
// readout stays current during long delivery turns or when a TurnDone is
// missed (no turn boundary resets the display).
func balanceRefreshTick() tea.Cmd {
return tea.Tick(balanceRefreshInterval, func(time.Time) tea.Msg { return balanceTickMsg{} })

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Unnamed parameters are valid in Go function literals when unused (ParameterDecl allows omitting the name). This matches go build / go test locally. elapsedTick uses _ by convention only both forms compile. Resolving as incorrect.

@JPShag
JPShag force-pushed the fix/cli-balance-periodic-refresh branch from 0382709 to b9a41d7 Compare August 8, 2026 00:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

tui Terminal UI / CLI (internal/cli, internal/control) v2 Go rewrite (1.x) — main-v2 branch, active development

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants