Skip to content

Add explicit Codex session management #1

@morinim

Description

@morinim

The package already creates project-specific Codex buffers, but these buffers are currently treated mostly as an implementation detail. It would be useful to expose them as explicit “sessions”, allowing users to list, switch, kill, and optionally create named Codex sessions.

A session can initially be defined simply as:

one Codex buffer + one running Codex process + its conversation state

When working on the same project, it is common to use Codex for different parallel tasks: reviewing a diff, writing tests, explaining an error, preparing a commit message, or working on a refactor.

Using a single Codex buffer per project can make the conversation noisy and mix unrelated contexts. Explicit sessions would make it easier to keep different tasks separated while staying inside Emacs.

For example:

*codex:ultra:review*
*codex:ultra:tests*
*codex:ultra:refactor*
*codex:ultra:commit*

Each buffer would represent a separate Codex conversation.

Proposed features

Add a small set of session-management commands:

my-codex-list-sessions
my-codex-switch-session
my-codex-kill-session
my-codex-kill-all-sessions
my-codex-start-session

The first implementation could be intentionally simple: sessions are discovered by looking for buffers whose names match the Codex buffer naming convention.

For example:

(defun my-codex-session-buffers ()
  "Return all buffers that look like Codex session buffers."
  (seq-filter
   (lambda (buffer)
     (string-match-p "\\`\\*codex:" (buffer-name buffer)))
   (buffer-list)))

Named sessions

As a follow-up, my-codex-start-session could optionally ask for a session name:

Session name: review

The resulting buffer name could include the project name, session name, and project hash:

*codex:PROJECT:SESSION:HASH*

This would allow multiple Codex sessions for the same project without changing the current default behaviour.

Suggested implementation steps

  1. Add helpers to detect existing Codex session buffers.
  2. Add an interactive command to switch to an existing session.
  3. Add commands to kill one session or all sessions.
  4. Extend Codex startup to optionally accept a session name.
  5. Keep the current one-session-per-project behaviour as the default.

Notes

This should not require a persistent database or a complex session model at first. A buffer-based implementation would already provide most of the value and keep the feature simple to maintain.

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions