Skip to content

feat(cli): jcode session delete <id> with confirmation + cleanup (#153)#195

Merged
quangdang46 merged 1 commit into
masterfrom
feat/session-delete-command
May 22, 2026
Merged

feat(cli): jcode session delete <id> with confirmation + cleanup (#153)#195
quangdang46 merged 1 commit into
masterfrom
feat/session-delete-command

Conversation

@quangdang46
Copy link
Copy Markdown
Owner

What

Adds the missing jcode session delete subcommand requested in issue #153: #153. Users had to manually rm ~/.jcode/sessions/<id>.json which left journal files and sidecars behind.

Usage

jcode session delete <session>          # interactive: type 'yes'
jcode session delete <session> --force  # skip confirmation
jcode session delete <session> --json   # machine-readable output
                                        # (requires --force)

Changes

  • src/cli/args.rs: SessionCommand::Delete { session, force, json }.
  • src/cli/dispatch.rs: dispatch arm for the new variant.
  • src/cli/commands.rs: run_session_delete_command + SessionDeleteOutput JSON struct. Resolves via the existing find_session_by_name_or_id so memorable short names work. Refuses to prompt in JSON mode or non-TTY; whitelists deletable sidecars (.tmp / .swarm.json / .json.bak / .journal.jsonl) — never wildcards arbitrary files in the sessions dir. Invalidates the session-picker cache.
  • src/cli/commands_tests.rs: 2 unit tests.

Tests

$ cargo test -p jcode --lib run_session_delete
test result: ok. 2 passed; 0 failed

Notes

The second half of issue #153 ("add text files or directories to context") is unrelated to session deletion and is best filed as a separate UX issue (overlaps with #11 @path references).

Adds the missing `jcode session delete` subcommand requested in
issue #153. Users had to manually `rm ~/.jcode/sessions/<id>.json`
which left journal files and sidecars behind.

Behavior:
  jcode session delete <session>          # interactive: type 'yes'
  jcode session delete <session> --force  # skip confirmation
  jcode session delete <session> --json   # machine-readable output
                                          # (requires --force)

The command:
- Resolves the session via the existing `find_session_by_name_or_id`
  so memorable short names (`fox`, custom titles) work.
- Refuses to prompt in JSON mode or when stdin is not a TTY (CI safety).
- Deletes the snapshot, journal, and any sibling sidecars matching the
  same stem with whitelisted suffixes (.tmp, .swarm.json, .json.bak,
  .journal.jsonl) — never wildcards arbitrary files.
- Invalidates the session-picker cache so the TUI updates immediately.
- Reports either a human-readable line or a structured JSON object
  listing every file removed.

Two tests in src/cli/commands_tests.rs:
- run_session_delete_command_with_force_removes_files
- run_session_delete_command_in_json_mode_requires_force

Closes #153
@quangdang46 quangdang46 merged commit 4f2c969 into master May 22, 2026
zombi3butt pushed a commit to zombi3butt/jcode that referenced this pull request May 22, 2026
The fork's CI has never run (`gh api repos/quangdang46/jcode/actions/runs`
returns total_count=0 for both pull_request and push events) because
upstream's workflows assume a `DEPLOY_KEY` SSH secret that the fork
does not have.

Two changes:

1. Gate every `webfactory/ssh-agent@v0.9.0` step on
   `if: ${{ secrets.DEPLOY_KEY != '' }}` so the SSH agent setup is
   simply skipped when the secret is absent. This is safe here because
   none of this fork's Cargo git dependencies use SSH URLs:
   - `agentgrep` -> https://github.com/1jehuang/agentgrep.git
   - `mermaid-rs-renderer` -> https://github.com/1jehuang/mermaid-rs-renderer.git
   So the `actions/checkout@v4` step's empty `ssh-key` falls back to
   the GITHUB_TOKEN HTTPS path automatically. Applies to 5 jobs in
   ci.yml + 1 step in release.yml.

2. Add `workflow_dispatch:` to ci.yml so maintainers can trigger CI
   manually from the Actions tab while debugging without having to
   force-push a no-op commit.

Note for the fork owner: GitHub disables Actions on a freshly-forked
repo until you visit the Actions tab once and click 'I understand my
workflows, go ahead and enable them'. After this PR is merged AND the
fork's Actions are enabled, future PRs will automatically run CI.

Refs the absence of CI runs blocking PRs quangdang46#174-quangdang46#195.
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