Conversation
The lock acquisition logic — polling at 500ms intervals, timing out after 30 seconds (`$JP_LOCK_DURATION`), and showing an interactive prompt on contention — was inline in `query.rs`. It is now extracted into `cmd::lock` and shared across all commands. As a result, `config set`, `conversation edit`, and `conversation rm` now poll and prompt on lock contention rather than failing immediately. In `jp_workspace`, `Workspace::lock_conversation` now returns a `LockResult` enum instead of `Option<ConversationLock>`. The enum variant `AlreadyLocked` carries the `ConversationHandle` back so callers avoid an extra `acquire_conversation` round-trip. Two new methods — `create_and_lock_conversation` and its `_with_id` variant — atomically create and lock a conversation, removing the repetitive create-then-acquire-then-lock pattern across call sites. `ConversationLock` now holds an `Option<Arc<ConversationFileLock>>` instead of a required `Arc`, so it works for in-memory workspaces without on-disk storage. The lock file placement falls back to workspace storage when user storage is absent, ensuring a flock can always be acquired. Signed-off-by: Jean Mertz <git@jeanmertz.com>
Signed-off-by: Jean Mertz <git@jeanmertz.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The lock acquisition logic — polling at 500ms intervals, timing out after 30 seconds (
$JP_LOCK_DURATION), and showing an interactive prompt on contention — was inline inquery.rs. It is now extracted intocmd::lockand shared across all commands. As a result,config set,conversation edit, andconversation rmnow poll and prompt on lock contention rather than failing immediately.In
jp_workspace,Workspace::lock_conversationnow returns aLockResultenum instead ofOption<ConversationLock>. The enum variantAlreadyLockedcarries theConversationHandleback so callers avoid an extraacquire_conversationround-trip. Two new methods —create_and_lock_conversationand its_with_idvariant — atomically create and lock a conversation, removing the repetitive create-then-acquire-then-lock pattern across call sites.ConversationLocknow holds anOption<Arc<ConversationFileLock>>instead of a requiredArc, so it works for in-memory workspaces without on-disk storage. The lock file placement falls back to workspace storage when user storage is absent, ensuring a flock can always be acquired.