Skip to content

fix(del): pass --force to codex delete so it runs headless#7

Merged
jarvan1 merged 1 commit into
mainfrom
fix/codex-delete-force
Jul 9, 2026
Merged

fix(del): pass --force to codex delete so it runs headless#7
jarvan1 merged 1 commit into
mainfrom
fix/codex-delete-force

Conversation

@jarvan1

@jarvan1 jarvan1 commented Jul 9, 2026

Copy link
Copy Markdown
Owner

Problem

Deleting a codex session from the picker removed the rollout .jsonl file but left codex's index row behind (the threads row in ~/.codex/state_*.sqlite), so every deleted codex session leaked a dead entry that still shows up in codex resume.

Root cause

The picker runs codex delete <id> via exec.Command from a non-interactive context (no TTY). Recent codex-cli refuses there:

Error: cannot confirm session deletion without an interactive terminal; rerun with --force and a session UUID

Our native step is best-effort (_ = cmd.Run()), so this failure was swallowed — the file got removed by the fallback, masking that the index prune never ran.

Fix

Pass --force so the native prune actually runs headless. File removal still backs it up if the command is missing.

- p.nativeCmd = []string{"codex", "delete", s.ID}
+ p.nativeCmd = []string{"codex", "delete", "--force", s.ID}

Verification

  • Reproduced on codex-cli 0.142.5: plain codex delete <uuid> → refuses without TTY; codex delete --force <uuid>Deleted session <uuid>. and the threads row is gone.
  • Reconciled the local index vs rollout files afterward: 16 index rows == 16 files, zero orphans.
  • go build ./... && go vet ./... && go test ./... all pass; del test updated to expect the --force arg.

🤖 Generated with Claude Code

The picker runs `codex delete <id>` via exec from a non-interactive
context (no TTY). Recent codex-cli refuses there with "cannot confirm
session deletion without an interactive terminal; rerun with --force",
which our best-effort `_ = cmd.Run()` swallowed — so the rollout file
got removed but codex's index row (threads table in state_*.sqlite)
was left behind, accumulating a dead entry per deleted codex session.

Add --force so the native prune actually runs. File removal still
backs it up if the command is missing.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@jarvan1
jarvan1 merged commit 0be3596 into main Jul 9, 2026
1 check passed
@jarvan1
jarvan1 deleted the fix/codex-delete-force branch July 9, 2026 02:53
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