Skip to content

feat(run): clean up the qodercli session directory too - #397

Merged
zpzjzj merged 1 commit into
alibaba:mainfrom
Walternater:feat/qoder-session-cleanup
Nov 16, 2026
Merged

zpzjzj merged 1 commit into
alibaba:mainfrom
Walternater:feat/qoder-session-cleanup

Conversation

@Walternater

Copy link
Copy Markdown
Contributor

Summary

Extends the opt-in session cleanup from #394 to qodercli, the first engine named in #267.

Qoder CLI keeps the same kind of per-workspace state as Claude Code: $HOME/.qoder/projects/<workspace-key>/ (CN edition: $HOME/.qoder-cn/projects/<workspace-key>/) holding the session transcript, sub-agent transcripts under <sessionID>/subagents/, and <sessionID>-session.json. With cleanup enabled it accumulated exactly like the Claude directories.

Related issues

Refs #267 — this lands the qodercli slice of the design input posted there.

Changes

  • QoderCLIAgent.CleanupSessionDir delegates to the shared removeAgentSessionDir, so every safeguard from feat(run): add opt-in cleanup of the Claude Code session directory #394 applies unchanged: ownership parsed from the top-level cwd/directories fields, keep when conflicting or unproven, two-phase discovery for hashed names, and the --no-delete / externally owned workspace guards.
  • qoderSessionLookup(configDir) is now shared by the resume lookup and the cleanup, and the projects root comes from the profile's configDir, so the global and CN editions clean their own trees and never each other's.
  • The evaluator no longer hardcodes claude_code as the only supported engine in its skip message.
  • Docs updated (en + zh CLI reference and writing-evals; the zh guide gains the session cleanup section) and CHANGELOG.

Test plan

  • make test passes
  • make verify passes (fmt + vet + lint, 0 issues)
  • Manual testing: not possible here — this environment has no qoder CLI, so this is fixture-level only, as noted in feat(agent): add session cleanup lifecycle for built-in and custom agents #267.
  • New cases in internal/agent/qodercli_test.go: directories identity, cwd identity, a directory naming another workspace, a second transcript for another workspace, no identity, an unparsable transcript, a hashed directory name, CN root isolation, and removal of nested sub-agent transcripts plus *-session.json.
  • Negative controls: dropping the ownership decision turns the keep-cases red; pointing cleanup at the global root turns the CN case red.

Notes for reviewers

  • Scope is deliberately qodercli only. qwen_code still reports unsupported because its chat files record no working directory, so ownership cannot be proven; the snapshot-diff shape discussed in feat(agent): add session cleanup lifecycle for built-in and custom agents #267 is a separate change.
  • The whole per-workspace directory is the removal unit: *-session.json and the sub-agent transcripts are part of this run too.

Disclosure: implemented with DeepSeek Harness (deepseek-v4.1-flash).

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 12, 2026 •

Copy link
Copy Markdown
Codex Review Summary: ✅ Completed

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-11-12T11:37:26.938565Z a4678e7 PR opened
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

Qoder CLI keeps the same per-workspace state as Claude Code: it writes
$HOME/.qoder/projects/<workspace-key>/ (or $HOME/.qoder-cn/ for the CN
edition) holding the session transcript, sub-agent transcripts under
<sessionID>/subagents/, and <sessionID>-session.json metadata. With the
opt-in cleanup in place, those directories accumulated exactly like the
Claude ones.

QoderCLIAgent now implements SessionDirCleaner through the shared
removeAgentSessionDir, so the same safeguards apply: the directory is
removed only when every transcript in it records this workspace, ownership
is parsed from the top-level cwd/directories fields rather than matched as
a string, discovery follows the lookup's two-phase shape, and unproven or
conflicting ownership keeps the directory.

The projects root is taken from the profile's configDir, so the global and
CN editions each clean their own tree and never the other's; the lookup and
the cleanup now share qoderSessionLookup so they cannot disagree about
which directory belongs to the run.

Tests are fixture-level only: this environment has no qoder CLI to run the
real thing. The cases cover directories identity, cwd identity, a shared
directory, no identity, an unparsable transcript, a hashed directory name,
the CN root, and the nested sub-agent/metadata files that go with the
directory.
@Walternater
Walternater force-pushed the feat/qoder-session-cleanup branch from a4678e7 to 7ef4869 Compare November 13, 2026 06:59
@Walternater

Copy link
Copy Markdown
Contributor Author

Rebased onto main (@1d624e0) to clear the conflict; only the CHANGELOG bullet and the two writing-evals paragraphs clashed, resolution keeps both sides. make test and make verify (0 issues) pass. No code changed.

@zpzjzj
zpzjzj added this pull request to the merge queue Nov 16, 2026
Merged via the queue into alibaba:main with commit 3a69cb9 Nov 16, 2026
16 checks passed
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.

2 participants