Skip to content

fix: New Session starts in research mode, not the last opened session's mode - #258

Merged
bbsngg merged 1 commit into
mainfrom
fix/new-session-mode
Nov 10, 2026
Merged

bbsngg merged 1 commit into
mainfrom
fix/new-session-mode

Conversation

@bbsngg

@bbsngg bbsngg commented Nov 6, 2026

Copy link
Copy Markdown
Contributor

Problem

Clicking New Session in the sidebar reused the mode of whatever session was opened last. handleSessionSelect copied the selected session's mode into the global, sessionStorage-backed newSessionMode. The sidebar buttons (desktop and mobile) and the blank chat tab then passed that value back into handleNewSession.

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_qa context 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:

  • "Ask about this file" in the file tree or editor (handleStartWorkspaceQa)
  • the mode toggle in the composer's "…" menu

I chose this over "research only when .pipeline/docs/research_brief.json is missing" for two reasons:

  • The mode of an unrelated session the user happened to open last says nothing about what they want next.
  • A file-dependent default would make New Session behave differently from project to project.

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 of useProjectsState into a pure module.
  • useProjectsState: every mode change now goes through one applyNewSessionModeEvent.
    • handleNewSession(project) no longer takes a mode.
    • Project creation also resets to research, so auto-intake runs.
    • The composer toggle now persists the user's choice, like the other entry points.
  • Sidebar (Sidebar, SidebarProjectList, SidebarProjectItem, SidebarProjectSessions) and MainContent: removed the newSessionMode prop and the mode argument. The type change means no caller can carry the old mode over again.

Tests

  • New src/utils/__tests__/newSessionMode.test.ts. It covers:
    • the rehearsal sequence: open a Workspace Q&A session → create a project → New Session gives research
    • a stale workspace_qa left in sessionStorage
    • the explicit Workspace Q&A entry points still working
  • npm run typecheck: passes.
  • npx vitest run: 565/566 pass. The one failure is server/utils/__tests__/codexCli.test.js > getBundledCodexCliInvocation, a path comparison that fails only because the local worktree symlinks node_modules from another checkout. This change does not touch it.
  • Not checked in the running app.

🤖 Generated with Claude Code

…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>
@bbsngg bbsngg mentioned this pull request Nov 10, 2026
1 of 2 tasks
@bbsngg
bbsngg merged commit 8e8df3d into main Nov 10, 2026
3 checks passed
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.

1 participant