-
Notifications
You must be signed in to change notification settings - Fork 2.3k
Fix context progress bar not resetting after /clear command #5652
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
99e9c7f to
396a338
Compare
Fixes block#5651 When using /clear to reset the conversation, the context progress bar was showing the old token usage percentage instead of resetting to 0%. This was because the /clear command cleared the messages but did not reset the token count metadata stored in the session database. Changes: - Reset total_tokens, input_tokens, and output_tokens to 0 when clearing the conversation in the /clear command handler - Token counts are now properly synchronized with the cleared state Testing: - Manually tested by building and running goose-cli v1.13.0 - Verified context bar resets to 0% after /clear command - Confirmed no compilation errors with cargo check Signed-off-by: Cat Bilyeu <[email protected]>
396a338 to
f11da5c
Compare
There was a problem hiding this 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 bug where the context progress bar was not resetting to 0% after using the /clear command. The issue occurred because clearing the conversation only removed messages but did not reset the token count metadata stored in the session database.
Key changes:
- Added token count reset logic to the
/clearcommand handler - Token counts (total_tokens, input_tokens, output_tokens) are now set to 0 when clearing the conversation
Improved the /clear command to maintain consistency between in-memory and database state, even if database operations fail: - Perform database operations before clearing in-memory state - Add recovery logic if token reset fails after conversation is cleared - Reset accumulated token counts (previously missed) - Clear in-memory messages only after confirming DB operations succeed This prevents inconsistent states where messages and token counts could become mismatched if database operations fail mid-execution. Addresses Co-Pilot feedback on PR block#5652 with a more robust solution that handles partial failure scenarios. Signed-off-by: Cat Bilyeu <[email protected]> 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <[email protected]>
- Remove unnecessary comments - Keep only current token counts reset (preserve accumulated tokens for desktop view) - Remove recovery logic, just error and continue if operations fail - Add newline before "Chat context cleared" message for better formatting Signed-off-by: Cat Bilyeu <[email protected]>
katzdave
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the fix!
crates/goose-cli/src/session/mod.rs
Outdated
| tracing::info!("Chat context cleared by user."); | ||
| output::render_message( | ||
| &Message::assistant().with_text("Chat context cleared."), | ||
| &Message::assistant().with_text("\nChat context cleared."), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think \n on the other end I wasn't seeing a line break before the next prompt but if this renders well can go with this too.
…eanup * 'main' of github.com:block/goose: (46 commits) Fix context progress bar not resetting after /clear command (#5652) docs: removing double announcements (#5714) docs: mcp sampling support (#5708) hackathon banner (#5710) Fix documentation-only change detection for push events (#5712) Added transaction commits to multi sql functions in session_manager (#5693) fix: improve and simplify tool call chain rendering (#5704) Fix: Always show autocompact threshold ui (#5701) chore: Update governance to include Discord (#5690) Ollama improvements (#5609) feat: add Supabase MCP server to registry (#5629) Unlist VS Code extension tutorials from MCP and experimental sections (#5677) fix: make image processing work in github copilot provider (#5687) fix: do not take into account gitignore in developer mcp (#5688) docs: session storage migration (#5682) New maintainers (#5685) chore: Update governance (#5660) chore(release): release version 1.14.0 (minor) (#5676) fix : action icons overlap session title in chat history (#5684) Document recent goose PRs (#5683) ...
* origin/main: (51 commits) Compaction resiliency improvements (#5618) docs: ask goose button (#5730) Update prompt injection detection metrics (due to errors exporting to datadog) (#5692) Spence/icon2 tokyo drift (#5728) docs: logs rotation and misc updates (#5727) docs: automatic ollama model detection (#5725) Fix context progress bar not resetting after /clear command (#5652) docs: removing double announcements (#5714) docs: mcp sampling support (#5708) hackathon banner (#5710) Fix documentation-only change detection for push events (#5712) Added transaction commits to multi sql functions in session_manager (#5693) fix: improve and simplify tool call chain rendering (#5704) Fix: Always show autocompact threshold ui (#5701) chore: Update governance to include Discord (#5690) Ollama improvements (#5609) feat: add Supabase MCP server to registry (#5629) Unlist VS Code extension tutorials from MCP and experimental sections (#5677) fix: make image processing work in github copilot provider (#5687) fix: do not take into account gitignore in developer mcp (#5688) ...
* main: (65 commits) Fix: Recipes respect the quiet flag (#5743) docs: update cli commands (#5744) Run smoke tests on a free runner (#5745) faster, cheaper (pick two): improve CI workflow and switch to free github runner (#5702) Compaction resiliency improvements (#5618) docs: ask goose button (#5730) Update prompt injection detection metrics (due to errors exporting to datadog) (#5692) Spence/icon2 tokyo drift (#5728) docs: logs rotation and misc updates (#5727) docs: automatic ollama model detection (#5725) Fix context progress bar not resetting after /clear command (#5652) docs: removing double announcements (#5714) docs: mcp sampling support (#5708) hackathon banner (#5710) Fix documentation-only change detection for push events (#5712) Added transaction commits to multi sql functions in session_manager (#5693) fix: improve and simplify tool call chain rendering (#5704) Fix: Always show autocompact threshold ui (#5701) chore: Update governance to include Discord (#5690) Ollama improvements (#5609) ...
* main: scan recipe for security when saving recipe (#5747) feat: trying grok for live test (#5732) Platform Extension MOIM (Minus One Info Message) (#5027) docs: remove hackathon banner (#5756) Fix: Recipes respect the quiet flag (#5743) docs: update cli commands (#5744) Run smoke tests on a free runner (#5745) faster, cheaper (pick two): improve CI workflow and switch to free github runner (#5702) Compaction resiliency improvements (#5618) docs: ask goose button (#5730) Update prompt injection detection metrics (due to errors exporting to datadog) (#5692) Spence/icon2 tokyo drift (#5728) docs: logs rotation and misc updates (#5727) docs: automatic ollama model detection (#5725) Fix context progress bar not resetting after /clear command (#5652) docs: removing double announcements (#5714) docs: mcp sampling support (#5708)
Signed-off-by: Cat Bilyeu <[email protected]> Co-authored-by: Claude <[email protected]> Co-authored-by: David Katz <[email protected]>
Signed-off-by: Cat Bilyeu <[email protected]> Co-authored-by: Claude <[email protected]> Co-authored-by: David Katz <[email protected]>
Signed-off-by: Cat Bilyeu <[email protected]> Co-authored-by: Claude <[email protected]> Co-authored-by: David Katz <[email protected]> Signed-off-by: Blair Allan <[email protected]>
Fixes #5651
Summary
When using /clear to reset the conversation, the context progress bar was showing the old token usage percentage instead of resetting to 0%.
This was because the /clear command cleared the messages but did not reset the token count metadata stored in the session database.
Changes:
Type of Change
AI Assistance
Testing
Related Issues
Relates to #5651
Discussion: #5651
Screenshots/Demos (for UX changes)
Before:


After:
Submitting a Recipe?
Email: