mirror of
https://github.com/instructkr/claw-code.git
synced 2026-04-14 03:54:50 +08:00
Keep latest session selection tied to real session recency
The next repo-local sweep target was ROADMAP #72: the `latest` managed-session alias could depend on filesystem mtime before the session's own persisted recency markers, which made the selection path vulnerable to coarse or misleading file timestamps. The fix promotes `updated_at_ms` into the summary/order path, keeps CLI wrappers in sync, and locks the mtime-vs-session-recency case with regression coverage. Constraint: Preserve existing managed-session storage layout while changing only the ordering signal Rejected: Keep sorting by filesystem mtime and just sleep longer in tests | hides the semantic ordering bug instead of fixing it Confidence: high Scope-risk: narrow Reversibility: clean Directive: Any future managed-session ordering change must keep runtime and CLI summary structs aligned on the same recency fields Tested: cargo fmt --all --check; cargo clippy --workspace --all-targets -- -D warnings; cargo test --workspace; architect review APPROVE Not-tested: Cross-filesystem behavior where persisted session JSON cannot be read and fallback ordering uses mtime only
This commit is contained in:
@@ -3122,6 +3122,7 @@ struct SessionHandle {
|
||||
struct ManagedSessionSummary {
|
||||
id: String,
|
||||
path: PathBuf,
|
||||
updated_at_ms: u64,
|
||||
modified_epoch_millis: u128,
|
||||
message_count: usize,
|
||||
parent_session_id: Option<String>,
|
||||
@@ -4711,6 +4712,7 @@ fn list_managed_sessions() -> Result<Vec<ManagedSessionSummary>, Box<dyn std::er
|
||||
.map(|session| ManagedSessionSummary {
|
||||
id: session.id,
|
||||
path: session.path,
|
||||
updated_at_ms: session.updated_at_ms,
|
||||
modified_epoch_millis: session.modified_epoch_millis,
|
||||
message_count: session.message_count,
|
||||
parent_session_id: session.parent_session_id,
|
||||
@@ -4726,6 +4728,7 @@ fn latest_managed_session() -> Result<ManagedSessionSummary, Box<dyn std::error:
|
||||
Ok(ManagedSessionSummary {
|
||||
id: session.id,
|
||||
path: session.path,
|
||||
updated_at_ms: session.updated_at_ms,
|
||||
modified_epoch_millis: session.modified_epoch_millis,
|
||||
message_count: session.message_count,
|
||||
parent_session_id: session.parent_session_id,
|
||||
|
||||
Reference in New Issue
Block a user