mirror of
https://github.com/instructkr/claude-code.git
synced 2026-06-05 20:06:43 +00:00
fix: /clear preserves session_id to prevent resume divergence (#114)
/resume mode /clear now preserves the original session_id instead of generating a new one. This prevents the filename/meta-header divergence where /session list reported an id that --resume couldn't find. Generated with https://github.com/Yeachan-Heo/gajae-code Co-authored-by: Gajae Code <dev@gajae-code.com>
This commit is contained in:
@@ -3546,7 +3546,7 @@ ear], /color [scheme], /effort [low|medium|high], /fast, /summary, /tag [label],
|
|||||||
|
|
||||||
**Source.** Jobdori dogfood 2026-04-18 against `/tmp/cdJJ` on main HEAD `8b25daf` in response to Clawhip pinpoint nudge at `1494887723818029156`. Joins **Unplumbed-subsystem / declared-but-not-delivered** (#78, #96, #100, #102, #103, #107, #109, #111) as the ninth surface where spec advertises capability the implementation doesn't deliver on the machine-readable path. Joins **Session-handling** (#93, #112) — with #113, this cluster now covers reference-resolution semantics + concurrent-modification + programmatic management gap. Cross-cluster with **Silent-flag / documented-but-unenforced** (#96–#101, #104, #108, #111) on the help-vs-implementation-mismatch axis. Natural bundle: **#93 + #112 + #113** — session-handling triangle covering every axis (semantic / concurrency / management API). Also **#78 + #111 + #113** — declared-but-not-delivered triangle showing three distinct flavors: #78 fails-noisy (CLI variant → Prompt fallthrough), #111 fails-quiet (slash → wrong handler), **#113** no-handler-at-all (slash → unsupported-resumed error). Session tally: ROADMAP #113.
|
**Source.** Jobdori dogfood 2026-04-18 against `/tmp/cdJJ` on main HEAD `8b25daf` in response to Clawhip pinpoint nudge at `1494887723818029156`. Joins **Unplumbed-subsystem / declared-but-not-delivered** (#78, #96, #100, #102, #103, #107, #109, #111) as the ninth surface where spec advertises capability the implementation doesn't deliver on the machine-readable path. Joins **Session-handling** (#93, #112) — with #113, this cluster now covers reference-resolution semantics + concurrent-modification + programmatic management gap. Cross-cluster with **Silent-flag / documented-but-unenforced** (#96–#101, #104, #108, #111) on the help-vs-implementation-mismatch axis. Natural bundle: **#93 + #112 + #113** — session-handling triangle covering every axis (semantic / concurrency / management API). Also **#78 + #111 + #113** — declared-but-not-delivered triangle showing three distinct flavors: #78 fails-noisy (CLI variant → Prompt fallthrough), #111 fails-quiet (slash → wrong handler), **#113** no-handler-at-all (slash → unsupported-resumed error). Session tally: ROADMAP #113.
|
||||||
|
|
||||||
114. **Session reference-resolution is asymmetric with `/session list`: after `/clear --confirm`, the new session_id baked into the meta header diverges from the filename (the file is renamed-in-place as `<old-id>.jsonl`). `/session list` reads the meta header and reports the NEW session_id (e.g. `session-1776481564268-1`). But `claw --resume <that-id>` looks up by FILENAME stem in `sessions_root`, not by meta-header id, and fails with `"session not found"`. Net effect: `/session list` returns session ids that the `--resume` reference resolver cannot find. Also: `/clear` backup files (`<id>.jsonl.before-clear-<ts>.bak`) are filtered out of `/session list` (zero discoverability via JSON surface), and 0-byte session files at lookup path cause `--resume` to silently construct ephemeral-never-persisted sessions with fabricated ids not in `/session list` either** — dogfooded 2026-04-18 on main HEAD `43eac4d` from `/tmp/cdNN` and `/tmp/cdOO`.
|
114. **DONE — Session reference-resolution is asymmetric with `/session list`: after `/clear --confirm`, the new session_id baked into the meta header diverges from the filename (the file is renamed-in-place as `<old-id>.jsonl`). `/session list` reads the meta header and reports the NEW session_id (e.g. `session-1776481564268-1`). But `claw --resume <that-id>` looks up by FILENAME stem in `sessions_root`, not by meta-header id, and fails with `"session not found"`. Net effect: `/session list` returns session ids that the `--resume` reference resolver cannot find. Also: `/clear` backup files (`<id>.jsonl.before-clear-<ts>.bak`) are filtered out of `/session list` (zero discoverability via JSON surface), and 0-byte session files at lookup path cause `--resume` to silently construct ephemeral-never-persisted sessions with fabricated ids not in `/session list` either** — dogfooded 2026-04-18 on main HEAD `43eac4d` from `/tmp/cdNN` and `/tmp/cdOO`.
|
||||||
|
|
||||||
**Concrete repro.**
|
**Concrete repro.**
|
||||||
```
|
```
|
||||||
|
|||||||
@@ -6477,14 +6477,16 @@ fn run_resume_command(
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
let backup_path = write_session_clear_backup(session, session_path)?;
|
let backup_path = write_session_clear_backup(session, session_path)?;
|
||||||
|
// #114: preserve the session_id from the file to avoid filename/meta-header
|
||||||
|
// divergence. /clear is "empty this session," not "fork to a new session."
|
||||||
let previous_session_id = session.session_id.clone();
|
let previous_session_id = session.session_id.clone();
|
||||||
let cleared = new_cli_session()?;
|
let mut cleared = new_cli_session()?;
|
||||||
let new_session_id = cleared.session_id.clone();
|
cleared.session_id = previous_session_id.clone();
|
||||||
cleared.save_to_path(session_path)?;
|
cleared.save_to_path(session_path)?;
|
||||||
Ok(ResumeCommandOutcome {
|
Ok(ResumeCommandOutcome {
|
||||||
session: cleared,
|
session: cleared,
|
||||||
message: Some(format!(
|
message: Some(format!(
|
||||||
"Session cleared\n Mode resumed session reset\n Previous session {previous_session_id}\n Backup {}\n Resume previous claw --resume {}\n New session {new_session_id}\n Session file {}",
|
"Session cleared\n Mode resumed session reset\n Previous session {previous_session_id}\n Backup {}\n Resume previous claw --resume {}\n Session file {}",
|
||||||
backup_path.display(),
|
backup_path.display(),
|
||||||
backup_path.display(),
|
backup_path.display(),
|
||||||
session_path.display()
|
session_path.display()
|
||||||
@@ -6492,7 +6494,7 @@ fn run_resume_command(
|
|||||||
json: Some(serde_json::json!({
|
json: Some(serde_json::json!({
|
||||||
"kind": "clear",
|
"kind": "clear",
|
||||||
"previous_session_id": previous_session_id,
|
"previous_session_id": previous_session_id,
|
||||||
"new_session_id": new_session_id,
|
"new_session_id": previous_session_id,
|
||||||
"backup": backup_path.display().to_string(),
|
"backup": backup_path.display().to_string(),
|
||||||
"session_file": session_path.display().to_string(),
|
"session_file": session_path.display().to_string(),
|
||||||
})),
|
})),
|
||||||
|
|||||||
Reference in New Issue
Block a user