shelley: reset context window size when switching to new conversation

Philip Zeyliger created

Prompt: In a new worktree, make sure that the usage meter is tied to the relevant conversation. Currently it's not by conversation id, so the latest shows up incorrectly

The usage meter (context window progress bar) was showing stale data from
the previous conversation when the user started a new conversation. This
was because the contextWindowSize state was not reset to 0 when the
conversationId became null.

Fixed by adding setContextWindowSize(0) in the useEffect that handles
conversation changes, alongside the existing setMessages([]) call.

Change summary

ui/src/components/ChatInterface.tsx | 1 +
1 file changed, 1 insertion(+)

Detailed changes

ui/src/components/ChatInterface.tsx 🔗

@@ -461,6 +461,7 @@ function ChatInterface({
     } else {
       // No conversation yet, show empty state
       setMessages([]);
+      setContextWindowSize(0);
       setLoading(false);
     }