Fix tokenState loading on new sessions#6129
Merged
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
This PR fixes a regression where the context window token counts displayed as 0 when opening a new session until the first message was sent. The fix initializes the token state from cached or fetched session data during session loading.
Key changes:
- Added token state initialization when loading a cached session
- Added token state initialization when fetching a session from the API
Comment on lines
+215
to
+222
| setTokenState({ | ||
| inputTokens: cached.session?.input_tokens ?? 0, | ||
| outputTokens: cached.session?.output_tokens ?? 0, | ||
| totalTokens: cached.session?.total_tokens ?? 0, | ||
| accumulatedInputTokens: cached.session?.accumulated_input_tokens ?? 0, | ||
| accumulatedOutputTokens: cached.session?.accumulated_output_tokens ?? 0, | ||
| accumulatedTotalTokens: cached.session?.accumulated_total_tokens ?? 0, | ||
| }); |
There was a problem hiding this comment.
This token state initialization logic is duplicated. Extract it into a helper function to avoid maintenance issues if the token state structure changes.
Comment on lines
+252
to
+259
| setTokenState({ | ||
| inputTokens: session?.input_tokens ?? 0, | ||
| outputTokens: session?.output_tokens ?? 0, | ||
| totalTokens: session?.total_tokens ?? 0, | ||
| accumulatedInputTokens: session?.accumulated_input_tokens ?? 0, | ||
| accumulatedOutputTokens: session?.accumulated_output_tokens ?? 0, | ||
| accumulatedTotalTokens: session?.accumulated_total_tokens ?? 0, | ||
| }); |
There was a problem hiding this comment.
This token state initialization logic is duplicated. Extract it into a helper function to avoid maintenance issues if the token state structure changes.
zanesq
approved these changes
Dec 15, 2025
katzdave
added a commit
that referenced
this pull request
Dec 16, 2025
zanesq
added a commit
that referenced
this pull request
Dec 16, 2025
* 'main' of github.com:block/goose: (22 commits) OpenRouter & Xai streaming (#5873) fix: resolve mcp-hermit cleanup path expansion issue (#5953) feat: add goose PR reviewer workflow (#6124) perf: Avoid repeated MCP queries during streaming responses (#6138) Fix YAML serialization for recipes with special characters (#5796) Add more posthog analytics (privacy aware) (#6122) docs: add Sugar MCP server to extensions registry (#6077) Fix tokenState loading on new sessions (#6129) bump bedrock dep versions (#6090) Don't persist ephemeral extensions when resuming sessions (#5974) chore(deps): bump mdast-util-to-hast from 13.2.0 to 13.2.1 in /ui/desktop (#5939) chore(deps): bump node-forge from 1.3.1 to 1.3.2 in /documentation (#5898) Add Scorecard supply-chain security workflow (#5810) Don't show subagent tool when we're a subagent (#6125) Fix keyboard shortcut conflict for Focus Goose Window (#5809) feat(goose-cli): add feature to disable update (#5886) workflow: enable docs-update-recipe-ref (#6132) fix: filter tools in Ollama streaming when chat mode is enabled (#6118) feat(mcp): platform extension for "code mode" MCP tool calling (#6030) workflow: auto-update recipe-reference on release (#5988) ... # Conflicts: # ui/desktop/src/App.tsx # ui/desktop/src/api/sdk.gen.ts # ui/desktop/src/components/ChatInput.tsx # ui/desktop/src/components/recipes/RecipesView.tsx
aharvard
added a commit
that referenced
this pull request
Dec 16, 2025
…nderer * feat/centralize-theme-context: refactor: simplify IPC handler with typed payload refactor: consolidate theme application to single useEffect refactor: simplify applyThemeToDocument with ternary fix: address PR feedback feat: centralize theme management with ThemeContext Fix tokenState loading on new sessions (#6129) bump bedrock dep versions (#6090)
zanesq
added a commit
that referenced
this pull request
Dec 16, 2025
…s-predefined-models * 'main' of github.com:block/goose: (81 commits) fix: display shell output as static text instead of spinner (#6041) fix : Custom providers with empty API keys show as configured in desktop (#6105) Add .agents/skills and ~/.config/agent/skills to skills discovery paths (#6139) fix: use instructions for system prompt and prompt for user message in subagents (#6121) Fix compaction loop for small models or large input (#5803) feat: Centralize theme management with ThemeContext (#6137) OpenRouter & Xai streaming (#5873) fix: resolve mcp-hermit cleanup path expansion issue (#5953) feat: add goose PR reviewer workflow (#6124) perf: Avoid repeated MCP queries during streaming responses (#6138) Fix YAML serialization for recipes with special characters (#5796) Add more posthog analytics (privacy aware) (#6122) docs: add Sugar MCP server to extensions registry (#6077) Fix tokenState loading on new sessions (#6129) bump bedrock dep versions (#6090) Don't persist ephemeral extensions when resuming sessions (#5974) chore(deps): bump mdast-util-to-hast from 13.2.0 to 13.2.1 in /ui/desktop (#5939) chore(deps): bump node-forge from 1.3.1 to 1.3.2 in /documentation (#5898) Add Scorecard supply-chain security workflow (#5810) Don't show subagent tool when we're a subagent (#6125) ... # Conflicts: # crates/goose/src/providers/formats/databricks.rs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Noticed a regression here. When you open a new session, until you send your first message the context window display remains at 0.