MCPcopy Create free account
hub / github.com/GongShichen/LuminaCode / FormatContextWindowStatus

Function FormatContextWindowStatus

ui/context_status.go:34–55  ·  view source on GitHub ↗
(model string, usedTokens, limitTokens int, width int)

Source from the content-addressed store, hash-verified

32}
33
34func FormatContextWindowStatus(model string, usedTokens, limitTokens int, width int) string {
35 if width <= 0 {
36 width = 20
37 }
38 if model == "" && limitTokens <= 0 {
39 return ""
40 }
41 label := "Model: " + firstNonEmpty(model, "unknown")
42 if limitTokens <= 0 {
43 return label + " | Context: n/a"
44 }
45 if usedTokens < 0 {
46 usedTokens = 0
47 }
48 ratio := float64(usedTokens) / float64(limitTokens)
49 percent := int(math.Round(ratio * 100))
50 if percent < 0 {
51 percent = 0
52 }
53 bar := FormatContextProgressBar(usedTokens, limitTokens, width)
54 return fmt.Sprintf("%s | Context %s %d%% %s/%s", label, bar, percent, formatTokenCount(usedTokens), formatTokenCount(limitTokens))
55}
56
57func FormatContextProgressBar(usedTokens, limitTokens int, width int) string {
58 if width <= 0 {

Callers 4

formatStatusMethod · 0.85
formatIdleStatusMethod · 0.85
contextStatusTextMethod · 0.85

Calls 3

FormatContextProgressBarFunction · 0.85
formatTokenCountFunction · 0.85
firstNonEmptyFunction · 0.70