Skip to content

Comments

Ask AI default new chat#1322

Draft
cjbell wants to merge 1 commit intomainfrom
cursor/ask-ai-default-new-chat-3f66
Draft

Ask AI default new chat#1322
cjbell wants to merge 1 commit intomainfrom
cursor/ask-ai-default-new-chat-3f66

Conversation

@cjbell
Copy link
Contributor

@cjbell cjbell commented Feb 20, 2026

Description

This PR modifies the Ask AI sidebar to always default to a new chat session when opened, rather than resuming the most recently active one. This ensures users consistently start with a fresh conversation, improving clarity and user experience.

This is achieved by:

  • Calling createNewSession() within openSidebar and toggleSidebar when the sidebar transitions to an open state.
  • Preventing the restoration of the last active chat session from local storage during the initial component mount.
  • Removing an associated unused variable.

Users can still access their previous chat history via the dropdown menu in the sidebar header.

Todos

Tasks

Screenshots


Open in Web Open in Cursor 

Co-authored-by: Chris Bell <chris@cjbell.co>
@cursor
Copy link

cursor bot commented Feb 20, 2026

Cursor Agent can help with this pull request. Just @cursor in comments and I'll start working on changes in this branch.
Learn more about Cursor Agents

@vercel
Copy link

vercel bot commented Feb 20, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
docs Ready Ready Preview, Comment Feb 20, 2026 3:26pm

Request Review

Copy link

@cursor cursor bot left a comment

Choose a reason for hiding this comment

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

Cursor Bugbot has reviewed your changes and found 3 potential issues.

Bugbot Autofix is OFF. To automatically fix reported issues with Cloud Agents, enable Autofix in the Cursor dashboard.

const openSidebar = useCallback(() => {
createNewSession();
setIsOpen(true);
}, [createNewSession]);
Copy link

Choose a reason for hiding this comment

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

openSidebar creates new session even when already open

Medium Severity

openSidebar unconditionally calls createNewSession() every time it's invoked, even if the sidebar is already open. This differs from toggleSidebar, which correctly guards with if (!prev) to only create a session when transitioning from closed to open. If openSidebar is called while the user is mid-conversation, it silently discards their current chat and replaces it with an empty session. The previous implementation was idempotent (setIsOpen(true) was a no-op when already open), and this change breaks that contract.

Fix in Cursor Fix in Web

}
return !prev;
});
}, [createNewSession]);
Copy link

Choose a reason for hiding this comment

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

Side effects inside React state updater function

Medium Severity

createNewSession() is called inside the setIsOpen state updater callback. React requires state updater functions to be pure. createNewSession() triggers multiple side effects (setChatSessions, setCurrentChatId, setMessages, etc.) and calls beforeSessionChangeRef.current?.(). In React Strict Mode (development), updater functions are invoked twice, which would create duplicate empty chat sessions each time the sidebar is toggled open.

Fix in Cursor Fix in Web

} else {
localStorage.removeItem(STORAGE_KEYS.currentChatId);
}
}
Copy link

Choose a reason for hiding this comment

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

Dead code: localStorage write with no reader remaining

Low Severity

The diff removed the code that reads STORAGE_KEYS.currentChatId from localStorage on mount, but left behind the effect that writes it (lines 168–176) and the currentChatId key in STORAGE_KEYS. This effect now runs on every session change, writing to localStorage with no consumer ever reading the value back, making it dead code.

Additional Locations (1)

Fix in Cursor Fix in Web

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.

2 participants