mirror of
https://github.com/getcompanion-ai/co-mono.git
synced 2026-04-16 17:01:02 +00:00
fix: update footer state when rendering initial messages on resume/continue
This commit is contained in:
parent
4019acf1f0
commit
97ac82312f
4 changed files with 125 additions and 16 deletions
|
|
@ -36,10 +36,22 @@ export class FooterComponent {
|
|||
}
|
||||
}
|
||||
|
||||
// Calculate total tokens and % of context window
|
||||
const totalTokens = totalInput + totalOutput;
|
||||
// Get last assistant message for context percentage calculation
|
||||
const lastAssistantMessage = this.state.messages
|
||||
.slice()
|
||||
.reverse()
|
||||
.find((m) => m.role === "assistant") as AssistantMessage | undefined;
|
||||
|
||||
// Calculate context percentage from last message (input + output + cacheRead + cacheWrite)
|
||||
const contextTokens = lastAssistantMessage
|
||||
? lastAssistantMessage.usage.input +
|
||||
lastAssistantMessage.usage.output +
|
||||
lastAssistantMessage.usage.cacheRead +
|
||||
lastAssistantMessage.usage.cacheWrite
|
||||
: 0;
|
||||
const contextWindow = this.state.model.contextWindow;
|
||||
const contextPercent = contextWindow > 0 ? ((totalTokens / contextWindow) * 100).toFixed(1) : "0.0";
|
||||
const contextPercent =
|
||||
contextWindow > 0 ? `${((contextTokens / contextWindow) * 100).toFixed(1)}% (${contextWindow})` : "0.0%";
|
||||
|
||||
// Format token counts (similar to web-ui)
|
||||
const formatTokens = (count: number): string => {
|
||||
|
|
|
|||
|
|
@ -351,6 +351,9 @@ export class TuiRenderer {
|
|||
// Reset first user message flag for initial render
|
||||
this.isFirstUserMessage = true;
|
||||
|
||||
// Update footer with loaded state
|
||||
this.footer.updateState(state);
|
||||
|
||||
// Render messages
|
||||
for (let i = 0; i < state.messages.length; i++) {
|
||||
const message = state.messages[i];
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue