codex icon indicating copy to clipboard operation
codex copied to clipboard

CLI: /new blocks on an unsolicited worktree choice instead of staying in the current checkout

Open joshua-oss opened this issue 2 months ago • 9 comments

What version of Codex CLI is running?

codex-cli 0.159.0

What subscription do you have?

Not included; the problem occurs in the CLI's new-session UI before a model request.

What platform is your computer?

Ubuntu 24.04.4 LTS, Linux x86_64.

What issue are you seeing?

After restarting Codex and entering /new, the CLI blocks on a choice between using the current repository/checkout and creating a new worktree. The prompt was reported as asking where to start: in this repo or in a new worktree (paraphrased).

This is highly disruptive in an existing monorepo workflow that always uses the current checkout and current branch. Project instructions explicitly prohibit creating or proposing worktrees unless requested. A routine context reset should not introduce a mandatory repository-layout decision. It also interrupts terminal-driven workflows that expect /new to leave the composer ready for the next task.

The built-in worktrees feature was enabled by default: there was no explicit worktrees setting in user config, and codex features list reported worktrees stable true. This is not an installed worktrees plugin.

What steps can reproduce the bug?

  1. Run Codex CLI 0.159.0 from an existing Git repository with the default worktrees feature enabled.
  2. Work in the existing checkout/current branch; do not request an isolated worktree.
  3. Restart Codex and enter /new.
  4. Observe that starting the fresh chat requires answering the current-checkout versus new-worktree prompt.

The prompt occurrence is user-reported. Version and effective feature-flag state were checked locally.

What is the expected behavior?

/new should immediately start a fresh chat in the current working directory, checkout, and branch. Creating a new worktree should require an explicit action, such as --worktree or a dedicated command.

If the selector is retained, provide a clearly discoverable, persistent "always use current checkout; never ask again" preference, including support for applying it across a monorepo. Users should not have to investigate plugins and feature flags to restore uninterrupted new-chat behavior.

The official CLI documentation describes /new as a context reset within the same CLI session and repo: https://developers.openai.com/codex/cli/slash-commands

Additional information

Local mitigation applied:

codex features disable worktrees

This persisted the following in ~/.codex/config.toml:

[features]
worktrees = false

A subsequent codex features list confirmed worktrees stable false. The interactive /new behavior after restarting with this setting has not yet been verified; this report is about the default blocking UX, not a claim that the disable flag is broken.

Related: #48328 describes confusing wording in the same selector. This report requests that /new preserve the current checkout without requiring the selector at all, or offer a persistent no-prompt choice.

Full diagnostics/session logs are omitted because this report concerns a narrowly identified UI behavior and feature default.

joshua-oss avatar Sep 29 '26 16:09 joshua-oss

The current behavior is intended, but I understand and appreciate that you would prefer a different behavior. I'm changing this from a bug report to a feature request.

etraut-openai avatar Sep 30 '26 05:09 etraut-openai

I would very strongly prefer not being asked about worktrees on /new. Why is the start of a new conversation a relevant time to ask about this?

mdmayfield avatar Oct 24 '26 21:10 mdmayfield

There was a configuration fix for this but it appears to have stopped working.

[features]
worktrees = false

Jon-Schneider avatar Oct 28 '26 13:10 Jon-Schneider

3. The current behavior is intended, but I understand and appreciate that you would prefer a different behavior. I'm changing this from a bug report to a feature request.

As a user who relied on features.worktrees=false and is now forced to interact with the picker, despite having no desire to ever use worktrees... I'd like to express my deep disagreement with that intent.

I know my workflow. I've tried worktrees. I really wanted to make them work. I did not find a useful use case.

I do not want them forced into my workflow. The expressed intent forces them into my workflow.

rochester-software avatar Oct 31 '26 18:10 rochester-software

Could this request cover a supported user-level setting that disables managed worktree creation and use across Codex, suppresses worktree prompts, and prevents Codex from suggesting worktrees? The worktree-keep-count setting only controls cleanup retention; it does not disable worktrees.

In installed codex-cli 0.166.0, the version-pinned source marks Worktrees as a removed compatibility flag, says managed worktrees are always available, and skips the legacy worktrees key while parsing config. That means [features] worktrees = false cannot provide this control now: v0.166.0 source.

My standing repository instructions prohibit creating, suggesting, or asking about worktrees unless I explicitly request one, but the assistant has repeatedly asked. That is a separate instruction-following failure; this request is for an enforceable Codex product setting.

iendeavor123 avatar Nov 03 '26 03:11 iendeavor123

Can we please at least fix the setting to allow people to turn off this behavior? I would also recommend adding a "remember my choice" so at most the user needs to be prompted once. Asking the user on every new session does not seem like anything any typical dev organization would want. It's like asking the user, "Do you like strawberries?", or "will you be using the PIL library in this session", before every new session. People were able to use worktrees just fine before without being hijacked by a blocking prompt.

I use WhisperFlow voice dictation for nearly all of my codex CLI work and this prompt means I need to go to the keyboard an extra time for no good reason.

joshua-msft avatar Nov 04 '26 22:11 joshua-msft

This is no longer just a wording complaint. A Codex Desktop chat in my project was supplied with a managed-worktree working directory even though my standing instructions require the primary checkout and prohibit worktrees. I found it under ~/.codex/worktrees/<id>/hinoki-giving-app and removed that checkout from the primary repository.

I cannot establish from the evidence available which action supplied that cwd, whether Local mode was selected when the chat was first created, or whether the Desktop app created the worktree. I am not claiming a proven trigger. The user-visible result is still unacceptable: an explicit no-worktrees instruction did not keep this chat in the primary checkout, and I had to stop and clean up a separate checkout.

Please treat this as an enforceable product requirement, not a preference or prompt wording issue: Codex needs a persistent app-level “Never create or use worktrees” setting that blocks worktree creation and use in Desktop host/session creation and agent handoffs, and keeps new chats in the selected primary checkout unless I explicitly authorize a worktree. Please identify the team owning this, the current triage status, and the fix path. The old [features] worktrees = false setting is not a supported opt-out in the v0.166.0 source linked above.

iendeavor123 avatar Nov 16 '26 21:11 iendeavor123

I ran into this on macOS as well. I often use /new to reset the conversation while continuing in the same checkout. The picker adds a confirmation to every reset, even though the worktree choice hasn’t changed.

I tested a local TUI build where /new immediately starts in the current worktree by default. A persistent setting restores the existing picker, and /worktree remains available for isolated sessions. I verified both settings in a local Git repository. Would you consider adopting this behavior upstream?

peters1235 avatar Nov 19 '26 03:11 peters1235

/clear seems to provide the behavior you want. It clears the context and console output, and starts a new session without prompting about worktrees etc. This is with the Codex CLI 0.172.0.

dstaple avatar Nov 28 '26 16:11 dstaple