Skip to content

Conversation

@katzdave
Copy link
Collaborator

Noticed a regression here. When you open a new session, until you send your first message the context window display remains at 0.

Copilot AI review requested due to automatic review settings December 15, 2025 23:45
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

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,
});
Copy link

Copilot AI Dec 15, 2025

Choose a reason for hiding this comment

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

This token state initialization logic is duplicated. Extract it into a helper function to avoid maintenance issues if the token state structure changes.

Copilot generated this review using guidance from repository custom instructions.
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,
});
Copy link

Copilot AI Dec 15, 2025

Choose a reason for hiding this comment

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

This token state initialization logic is duplicated. Extract it into a helper function to avoid maintenance issues if the token state structure changes.

Copilot generated this review using guidance from repository custom instructions.
@katzdave katzdave merged commit 15aa818 into main Dec 16, 2025
22 of 23 checks passed
@katzdave katzdave deleted the dkatz/token-state-fix branch December 16, 2025 16:35
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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants