Repository navigation
fix: New Session starts in research mode, not the last opened session's mode - #258
Merged
Merged
Conversation
…ssion's mode Opening a session copied its mode into the global, sessionStorage-backed newSessionMode, and the sidebar's New Session button (plus the blank chat tab) passed that value back into handleNewSession. After viewing a Workspace Q&A session, the first session of a freshly created project therefore opened in Workspace Q&A: no "Start a project" quick actions, auto-intake skipped, and a workspace_qa context prefix on the first message. Rule: every "start something new" entry point (New Session, new chat tab, project creation, chat-from-reference) resets to research mode. Workspace Q&A is entered only on purpose: the file tree / editor "ask about this file" actions (handleStartWorkspaceQa) or the composer's mode toggle. - Move the mode rule and its sessionStorage persistence into src/utils/newSessionMode.ts (pure, unit-tested). - handleNewSession no longer takes a mode; drop the newSessionMode prop from the sidebar so callers cannot carry the old mode over. - Project creation now also resets the mode, so auto-intake runs. - The composer toggle now persists the choice like the other entry points. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
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.
Problem
Clicking New Session in the sidebar reused the mode of whatever session was opened last.
handleSessionSelectcopied the selected session's mode into the global, sessionStorage-backednewSessionMode. The sidebar buttons (desktop and mobile) and the blank chat tab then passed that value back intohandleNewSession.So after looking at a Workspace Q&A session, the first session of a freshly created project opened as Workspace Q&A. That meant no "Start a project" quick actions, no auto-intake (it only runs in research mode), and a
workspace_qacontext prefix on the first message. We reproduced this on v1.3.0 in a demo rehearsal.Rule
Every "start something new" entry point resets to research mode: New Session, a new or blank chat tab, project creation, and chat-from-reference. You get Workspace Q&A only by choosing it:
handleStartWorkspaceQa)I chose this over "research only when
.pipeline/docs/research_brief.jsonis missing" for two reasons:Research mode is already the documented default, and the composer toggle is one click away.
Changes
src/utils/newSessionMode.ts: the rule (nextNewSessionMode) and the sessionStorage persistence, moved out ofuseProjectsStateinto a pure module.useProjectsState: every mode change now goes through oneapplyNewSessionModeEvent.handleNewSession(project)no longer takes a mode.Sidebar,SidebarProjectList,SidebarProjectItem,SidebarProjectSessions) andMainContent: removed thenewSessionModeprop and the mode argument. The type change means no caller can carry the old mode over again.Tests
src/utils/__tests__/newSessionMode.test.ts. It covers:workspace_qaleft in sessionStoragenpm run typecheck: passes.npx vitest run: 565/566 pass. The one failure isserver/utils/__tests__/codexCli.test.js > getBundledCodexCliInvocation, a path comparison that fails only because the local worktree symlinksnode_modulesfrom another checkout. This change does not touch it.🤖 Generated with Claude Code