codex icon indicating copy to clipboard operation
codex copied to clipboard

Scope Codex chats to VS Code projects/workspaces

Open majid4466 opened this issue 1 year ago • 35 comments

What feature would you like to see?

Summary

Currently, Codex chats in the VS Code extension are global. The Recent Tasks list shows chats created in other projects/workspaces, which makes it hard to keep Codex sessions organized.

Proposed behavior

Scope Codex chats to the active VS Code project/workspace. Ideally:

  • Each project has its own Recent Tasks history.
  • Optionally, provide a way to switch between “global history” and “per-project history.”

Use case

Example: I worked in project TradeAssist yesterday and had two Codex chats there. Today, when I switched to a different project M1, those same TradeAssist chats still appeared in Recent Tasks. This makes it difficult to separate Codex sessions by project.

Benefits

  • Clear separation of Codex sessions per project.
  • Reduced confusion when working across multiple repositories.
  • Easier context management when returning to a project after time away.

Environment

  • VS Code version: 1.103.2
  • Codex extension version: 0.4.6
  • OS: Xubuntu 20.04

Are you interested in implementing this feature?

No response

Additional information

No response

majid4466 avatar Sep 13 '25 08:09 majid4466

It's insane this isn't the default behavior, when you have a lot of projects, finding your place again on editor restart is very challenging

pbarker avatar Oct 12 '25 01:10 pbarker

I think I'm slightly tripping... this was the case for me; for every project I had separate history of chats in Codex. Until literally yesterday where suddenly every chat appears on every project of mine and I learned (learn?) that it's default behaviour?

pherkan avatar Dec 18 '25 20:12 pherkan

Is there any movement on this? There is little to no benefit to having conversations unrelated to the current project showing up and sorting though them (while not being able to name conversations) is quite annoying.

thomasf1 avatar Jan 05 '26 10:01 thomasf1

Is there any movement on this? There is little to no benefit to having conversations unrelated to the current project showing up and sorting though them (while not being able to name conversations) is quite annoying.

While you can't name conversations, my make-do solution has has been prepending to the the first prompt message the uppercase repo name and ending it with a dot so that you can easily filter through the list, either at a quick glance from the last shown or via the search feature through "View all"/"Task History".

It shouldn't really be a hindrance to the quality of the response, I reckon, and that plus enough thread archiving makes it bearable for me.

Nesquik avatar Jan 05 '26 11:01 Nesquik

@Nesquik ah that's a good workaround for now yep. Thanks

pherkan avatar Jan 05 '26 11:01 pherkan

Yeah I also felt the need for this. BTW, I would usually try to write something like "This chat is about backend", thinking it would make the chat name "Backend Chats" or something like it happens in chatgpt ui. It's just pretext I guess like @Nesquik uses. That helped! Good workaround.

iarc13 avatar Jan 10 '26 13:01 iarc13

Is there any movement on this? There is little to no benefit to having conversations unrelated to the current project showing up and sorting though them (while not being able to name conversations) is quite annoying.

While you can't name conversations, my make-do solution has has been prepending to the the first prompt message the uppercase repo name and ending it with a dot so that you can easily filter through the list, either at a quick glance from the last shown or via the search feature through "View all"/"Task History".

It shouldn't really be a hindrance to the quality of the response, I reckon, and that plus enough thread archiving makes it bearable for me.

Thanks, I´ve started doing the same, it helps.

Noticed that in the latest version, the Chat window is blocked if you´re in the wrong project (which kind of baffles me to put that effort in but still just show all chats)

Image

thomasf1 avatar Jan 10 '26 14:01 thomasf1

FYI, in terms of competitor analysis: Antigravity does this; every agent window is scoped to the project.

dank-ubiq avatar Feb 02 '26 11:02 dank-ubiq

My project has several repos. In the morning, when I open a particular VSCode workspace, how am I supposed to know which task to reopen? I am guessing Openai would rather we use the Codex app where this is how it works.

paddywills avatar Feb 17 '26 08:02 paddywills

FYI, in terms of competitor analysis: Antigravity does this; every agent window is scoped to the project.

As does Claude Code (VSCode Extension)

gmmurray avatar Feb 17 '26 15:02 gmmurray

Would be really helpful if that worked in the extension as well. Using codex-cli in the terminal, we already get previous sessions scoped to the current cwd when doing codex resume.

JohnnyBill avatar Feb 26 '26 10:02 JohnnyBill

How is this not sorted out yet? The Codex app does, and so does the CLI. Hell, there's even a 'filter tasks by environment' button in the dropdown for sessions, but it says failed to load environments.

maxiedaniels avatar Feb 26 '26 19:02 maxiedaniels

Yeah, this is quite annoying. Could we please have this resolved?

m3h0w avatar Mar 09 '26 14:03 m3h0w

This is a security violation. It poisons contexts across repos. This should be #1 on OpenAI's backlog. This has already cost me a couple of days thinking I went crazy because Codex made this change without notifying the users adequately about the HUGE SECURITY VIOLATIONS this introduces. They strain a gnat but swallow a camel.

richrz avatar Mar 15 '26 06:03 richrz

This is affecting me in Codex desktop as a workspace/thread-scoping problem. If a one-off misc thread is started while I’m inside a repo workspace, the thread stays associated with that project in the left sidebar and I can’t find a clean way to move/re-home it later. Archive helps hide it, but doesn’t solve the underlying workspace assignment issue. A move/reassign-thread action would help a lot.

haritn avatar Mar 27 '26 20:03 haritn

Any update on this?

stephenjoly avatar Mar 31 '26 23:03 stephenjoly

I ended up building a workaround (tested on macos) for this while waiting on a native fix:

https://github.com/stephenjoly/codex-session-indexer https://stephenjoly.github.io/codex-session-indexer/

It reads Codex’s local session store (~/.codex/sessions + ~/.codex/session_index.jsonl) and generates a codex-sessions.md file inside each project directory, plus a global recent-session index.

So it does not change the built-in Recent Tasks UI in VS Code, but it does give you a per-project session history based on the recorded cwd, including:

  • most recent sessions
  • most active sessions
  • prompt counts
  • session lifetime
  • optional watcher / macOS daemon mode

Install:

curl -fsSL https://raw.githubusercontent.com/stephenjoly/codex-session-indexer/main/install.sh | bash

If anyone here tries it and has ideas for improvement, I’d love feedback.

stephenjoly avatar Apr 02 '26 00:04 stephenjoly

Any updates?

pravinkjana avatar Apr 27 '26 02:04 pravinkjana

devs, please prioritize this issue. Vscode+codex is barely usable because of the clutter from all threads from all projects without knowing which project they are from.

stablum avatar Apr 29 '26 15:04 stablum

I hit the same issue and used a small local patch as a workaround.

The idea is to insert the following code at the very top of the Codex VS Code extension’s out/extension.js, before the extension starts the Codex process. This sets process.env.CODEX_HOME according to vscode.workspace.name, so the later spawned codex app-server inherits the workspace-specific CODEX_HOME from its parent extension process.

(() => {
  const fs = require("fs");
  const path = require("path");
  const vscode = require("vscode");  
  const os = require("os");

  const n = vscode.workspace.name;
  const h = os.homedir();
  if (!n || !h) return;

  const src = path.join(h, ".codex");
  const dst = path.join(h, ".codex", "workspaces", n);

  fs.mkdirSync(dst, { recursive: true });

  const link = x => {
    const s = path.join(src, x);
    const t = path.join(dst, x);
    if (!fs.existsSync(s) || fs.existsSync(t)) return;

    const isDir = fs.statSync(s).isDirectory();
    fs.symlinkSync(s, t, isDir && process.platform === "win32" ? "junction" : isDir ? "dir" : "file");
  };

  [
    "auth.json",
    "config.toml",
    "AGENTS.md",
    "rules",
    "skills",
    "plugins",
    "agents",
  ].forEach(link);

  process.env.CODEX_HOME = dst;
})();

For Remote-SSH, the file is usually something like:

$HOME/.vscode-server/extensions/openai.chatgpt-*/out/extension.js

For local VS Code, it is usually something like:

$HOME/.vscode/extensions/openai.chatgpt-*/out/extension.js

This creates one Codex home per VS Code workspace:

~/.codex/workspaces/<workspace name>/

auth.json, config.toml, AGENTS.md, rules, skills, plugins, and agents are symlinked from ~/.codex, so each workspace can share configurations and you won’t need to log in again for each workspace. But sessions and session_index.jsonl are not linked, so they stay independent per workspace.

After this patch, new Codex sessions are stored under the workspace-specific CODEX_HOME. Existing sessions under ~/.codex need to be manually copied to the corresponding workspace directory if you want to keep using them.

xsjk avatar Apr 30 '26 11:04 xsjk