Skip to content

Fix Agent Mode New Task sidebar flow #645

Description

@marksftw

Problem

PR #642 intentionally keeps the terminology change separate from Agent initialization behavior. The shared sidebar now routes New Task to Agent Mode’s existing createSession() callback, but the action is disabled while Agent settings are initializing or otherwise locked.

That restores the existing readiness boundary and avoids adding a deferred-creation state machine to #642, but it leaves the brief disabled state originally reported during the Chat-to-Agent transition.

Current behavior

  • Chat Mode’s New Chat action continues to use addChat().
  • Agent Mode’s New Task action uses the existing createSession() flow once Agent settings are unlocked.
  • During Agent initialization, New Task is disabled.
  • There is no queued click, folder-selection handoff, explicit runtime-root parameter, or new persistence behavior in Rename Agent Mode chats and sessions to tasks #642.
  • If no project root is ready after initialization, the existing creation flow reports that a project folder must be selected first.

Desired behavior

  • New Task remains visually stable during the Chat-to-Agent transition, without briefly appearing disabled.
  • A click during initialization is handled deterministically once the required Agent state is ready.
  • The action never navigates to or clears Chat Mode.
  • With an existing project root, the new task uses that project and the current Agent settings.
  • Without a project root, the user can select a folder; cancellation is a no-op and a successful selection is used without stale React state.
  • Chat Mode remains unchanged.

Design decision required

Define when a blank task becomes durable: immediately when New Task is clicked, after project selection, or only when the first message is sent. The implementation should make that rule explicit and consistent across Agent new-task entry points.

Edge cases

  • Click before project, model, mode, runtime, and previous selection have been restored.
  • Runtime stopped, starting, or already running.
  • No project selected; folder picker success, cancellation, or error.
  • Multiple rapid clicks and avoiding duplicate empty tasks.
  • Compact sidebar closing after the action.
  • Active task selection changing while startup or folder selection is pending.
  • MCP selection and permission mode used by the new task.
  • Errors during runtime startup or task creation.

Tests

Add direct tests for initialization-time clicks, existing-project and no-project flows, picker cancellation, stale-state avoidance, repeated clicks, the chosen persistence rule, and unchanged Chat Mode behavior.

Related: #639, #642.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions