fix(desktop): reset telemetry and context panel after /clear#4327
Open
ashishexee wants to merge 1 commit into
Open
fix(desktop): reset telemetry and context panel after /clear#4327ashishexee wants to merge 1 commit into
ashishexee wants to merge 1 commit into
Conversation
Fixes esengine#4186 Sub-bug (a): /clear sometimes fails to clear context (stale events re-populate state after reset). Fix: guard usage handler with turnActive check so stale events from the previous session are dropped after the reset action zeros the state. Sub-bug (b): token info and workspace context not refreshed after /clear. Three causes: 1. Tab telemetry not reset — ClearSession() resets the executor session but tab.usageTelemetry/readTelemetry accumulate forever. Fix: add resetTelemetry() and call it from App.ClearSession(). 2. ContextPanel not refreshed — dockRefreshKey only bumps on turn_done, so the panel keeps showing stale data. Fix: bump dockRefreshKey in confirmClearContext. 3. Stale info fallback — ContextPanel line 212 falls back to info.usedTokens when context.used is 0, which is stale. Fix: clear info state when context.used and sessionTokens are both 0.
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.
Closes #4186
Problem
After
/clear, the context panel still shows stale token counts and workspace context.Two sub-bugs:
/clearsometimes fails to clear context — staleusageevents from the previous session re-populate state after the reset action zeros it./clear.Root Causes
ClearSession()resets the executor session but NOTtab.usageTelemetry/tab.readTelemetry.ContextPanelreads from telemetry, returns stale data.dockRefreshKeyonly bumps onturn_done, so ContextPanel doesn't refresh after/clear.ContextPanel.tsxline 212 falls back toinfo.usedTokenswhencontext.used === 0, showing stale values.usageevent handler doesn't checkturnActive, so stale events arriving after reset re-accumulate into session tokens.Fix
resetTelemetry()onWorkspaceTab— called fromApp.ClearSession()after clearing the executor session.dockRefreshKeyinconfirmClearContextto force ContextPanel refresh.infostate in ContextPanel whencontext.used === 0 && sessionTokens === 0.usagehandler withturnActivecheck — stale events from a cleared session are dropped.sessionGencounter to State, incremented onreset— for future use to discard stale events by generation.Files Changed
desktop/tabs.go—resetTelemetry()methoddesktop/app.go— callstab.resetTelemetry()afterClearSession()desktop/frontend/src/App.tsx— bumpsdockRefreshKeyafter cleardesktop/frontend/src/components/ContextPanel.tsx— clears staleinfodesktop/frontend/src/lib/useController.ts—sessionGencounter,usageguard onturnActiveVerification