Add a picker for jj bookmark list (#30883)

This PR adds a new picker for viewing a list of jj bookmarks, like you
would with `jj bookmark list`.

This is an exploration around what it would look like to begin adding
some dedicated jj features to Zed.

This is behind the `jj-ui` feature flag.

Release Notes:

- N/A
This commit is contained in:
Marshall Bowers 2025-05-17 18:42:45 +02:00 committed by GitHub
parent 122d6c9e4d
commit dd3956eaf1
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
16 changed files with 1644 additions and 152 deletions

41
crates/jj/src/jj_store.rs Normal file
View file

@ -0,0 +1,41 @@
use std::path::Path;
use std::sync::Arc;
use gpui::{App, Entity, Global, prelude::*};
use crate::{JujutsuRepository, RealJujutsuRepository};
/// Note: We won't ultimately be storing the jj store in a global, we're just doing this for exploration purposes.
struct GlobalJujutsuStore(Entity<JujutsuStore>);
impl Global for GlobalJujutsuStore {}
pub struct JujutsuStore {
repository: Arc<dyn JujutsuRepository>,
}
impl JujutsuStore {
pub fn init_global(cx: &mut App) {
let Some(repository) = RealJujutsuRepository::new(&Path::new(".")).ok() else {
return;
};
let repository = Arc::new(repository);
let jj_store = cx.new(|cx| JujutsuStore::new(repository, cx));
cx.set_global(GlobalJujutsuStore(jj_store));
}
pub fn try_global(cx: &App) -> Option<Entity<Self>> {
cx.try_global::<GlobalJujutsuStore>()
.map(|global| global.0.clone())
}
pub fn new(repository: Arc<dyn JujutsuRepository>, _cx: &mut Context<Self>) -> Self {
Self { repository }
}
pub fn repository(&self) -> &Arc<dyn JujutsuRepository> {
&self.repository
}
}