Skip to content

fix(workspace): Prune stale session entries#547

Merged
JeanMertz merged 1 commit intomainfrom
prr114
Apr 13, 2026
Merged

fix(workspace): Prune stale session entries#547
JeanMertz merged 1 commit intomainfrom
prr114

Conversation

@JeanMertz
Copy link
Copy Markdown
Collaborator

Previously, session_active_conversation and
session_previous_conversation could return stale IDs for conversations no longer in the workspace index. Both methods now filter against the index, returning None when the referenced conversation is gone.

cleanup_stale_files gains a second pass: after deciding whether to remove an entire session file, it now prunes individual history entries that reference deleted conversations. An entry is removed when the conversation is absent from disk and no other process holds its write lock — the lock check guards against a mid-persist race where a conversation is being written but not yet indexed.

To support the lock probe, jp_storage gains is_conversation_locked, which checks an existing lock file without creating one. The path resolution logic is extracted into a shared lock_file_path helper.

@JeanMertz JeanMertz marked this pull request as ready for review April 13, 2026 17:46
Previously, `session_active_conversation` and
`session_previous_conversation` could return stale IDs for conversations
no longer in the workspace index. Both methods now filter against the
index, returning `None` when the referenced conversation is gone.

`cleanup_stale_files` gains a second pass: after deciding whether to
remove an entire session file, it now prunes individual history entries
that reference deleted conversations. An entry is removed when the
conversation is absent from disk and no other process holds its write
lock — the lock check guards against a mid-persist race where a
conversation is being written but not yet indexed.

To support the lock probe, `jp_storage` gains `is_conversation_locked`,
which checks an existing lock file without creating one. The path
resolution logic is extracted into a shared `lock_file_path` helper.

Signed-off-by: Jean Mertz <git@jeanmertz.com>
@JeanMertz JeanMertz merged commit b63a168 into main Apr 13, 2026
13 checks passed
@JeanMertz JeanMertz deleted the prr114 branch April 13, 2026 19: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