#17109: fix: preserve responseUsage across session resets
scripts
commands
stale
size: XS
Cluster:
Session Management Improvements
Fixes #17102
## Problem
The `/usage` command setting (`responseUsage`) was lost on session resets (daily/idle), while other preferences (`thinkingLevel`, `verboseLevel`, `reasoningLevel`, `ttsAuto`) were preserved. Users had to re-type `/usage full` after each reset.
## Root Cause
In `src/auto-reply/reply/session.ts`, `responseUsage` was only set from `baseEntry` (which is undefined on reset), while other settings used persisted fallbacks:
```ts
responseUsage: baseEntry?.responseUsage, // ❌ Lost on reset
```
## Solution
Added `persistedResponseUsage` handling to match other preferences:
1. Added `persistedResponseUsage` to `SessionResolution` type
2. Persist value when session is fresh or reset triggered
3. Use persisted value as fallback in session entry initialization
```ts
responseUsage: persistedResponseUsage ?? baseEntry?.responseUsage, // ✅ Preserved
```
## Impact
- `/usage` setting now persists across session resets
- Consistent behavior with other per-session preferences
- Users don't need to re-enable `/usage` after `/new`, `/reset`, or daily resets
<!-- greptile_comment -->
<h3>Greptile Summary</h3>
This PR fixes a bug where the `/usage` command setting (`responseUsage`) was lost during session resets (triggered by `/new`, `/reset`, or idle/daily timeouts), requiring users to re-enable it after each reset. The fix adds `persistedResponseUsage` handling to match the existing pattern used for other per-session preferences like `thinkingLevel`, `verboseLevel`, `reasoningLevel`, and `ttsAuto`. The implementation correctly persists the value when a session is fresh or when a reset is triggered, and uses the persisted value as a fallback during session initialization.
<h3>Confidence Score: 5/5</h3>
- This PR is safe to merge with no identified risks
- The fix follows the exact same pattern already established for other session preferences (`ttsAuto`, `thinkingLevel`, `verboseLevel`, `reasoningLevel`). The implementation is minimal, focused, and consistent across both files. Type definitions are correct, and the changes align with the existing codebase architecture. No logical errors, security issues, or unintended side effects detected.
- No files require special attention
<sub>Last reviewed commit: f7a45f0</sub>
<!-- greptile_other_comments_section -->
<!-- /greptile_comment -->
Most Similar PRs
#14358: fix: preserve session overrides (verbose, model) across /new or /rese…
by WyattSanders · 2026-02-12
80.7%
#22089: feat: persist default /usage mode via agents.defaults.usage
by AIflow-Labs · 2026-02-20
80.7%
#22387: fix: session_status context tracking undercount for cached providers
by 1ucian · 2026-02-21
79.8%
#21847: fix(session): /new and /reset no longer carry over model overrides
by hydro13 · 2026-02-20
79.6%
#8477: TUI: persist session token totals when usage metadata is missing
by LarHope · 2026-02-04
79.2%
#6653: fix: persist archived session entry on /new or /reset
by leicao-me · 2026-02-01
77.8%
#20650: fix(gateway): include deleted/reset sessions in usage.cost RPC (#20...
by lailoo · 2026-02-19
76.5%
#11613: fix: clear stale model metadata on /new and /reset
by mcaxtr · 2026-02-08
76.3%
#22465: fix: preserve session history after API error (400/503) in mid-conv...
by hhy5562877 · 2026-02-21
76.1%
#20770: fix: prevent stale session-entry overwrite during reset-model persi...
by coygeek · 2026-02-19
75.9%