Luxe 0.1.3: your sessions on your phone, joinable sessions, and nested AGENTS.md
- luxe remote puts the sessions on your computer in reach of your own phone or tablet over Tailscale: write, steer, answer prompts, send photos, browse files, diffs and GitHub, with a paired device and your own Tailscale login. - luxe join lets another program on the same machine join a running session over the RPC protocol. - An AGENTS.md in a subfolder reaches the model the first time it works there. - Long sessions stay fast: no stall before each model call, lighter memory, cheaper drawing. - A session is open in one Luxe at a time, web_search shares results across its phrasings, and a grep glob starting with ! excludes. The CHANGELOG has the full list.
This commit is contained in:
@@ -86,6 +86,13 @@ fn git(root: &std::path::Path, arguments: &[&str]) {
|
||||
assert!(Command::new("git").args(arguments).current_dir(root).status().unwrap().success());
|
||||
}
|
||||
|
||||
/// Where the repository keeps its sessions: under `.luxe`, as Luxe does, where Guided Review never
|
||||
/// looks. Anywhere else they are untracked files a review reads, and on Windows an open session's
|
||||
/// claim locks its `.lock` file against that read, so the review never loads.
|
||||
fn sessions_root(root: &std::path::Path) -> std::path::PathBuf {
|
||||
root.join(".luxe").join("sessions")
|
||||
}
|
||||
|
||||
/// A repository with one committed file, changed in the working tree.
|
||||
fn changed_repository() -> tempfile::TempDir {
|
||||
let dir = tempfile::tempdir().unwrap();
|
||||
@@ -131,7 +138,7 @@ async fn guide_costs(
|
||||
async fn the_guide_runs_on_the_model_the_session_switched_to() {
|
||||
let repository = changed_repository();
|
||||
let root = repository.path();
|
||||
let mut store = JsonlSessionStore::new(root.join("sessions"));
|
||||
let mut store = JsonlSessionStore::new(sessions_root(root));
|
||||
let session = store.create("/tmp/a").unwrap();
|
||||
let asked = Arc::new(Mutex::new(Vec::new()));
|
||||
let mut config = engine_config(store, session, root);
|
||||
@@ -191,7 +198,7 @@ async fn the_guide_runs_on_the_model_the_session_switched_to() {
|
||||
async fn late_guide_spend_settles_to_the_session_that_asked() {
|
||||
let repository = changed_repository();
|
||||
let root = repository.path();
|
||||
let mut store = JsonlSessionStore::new(root.join("sessions"));
|
||||
let mut store = JsonlSessionStore::new(sessions_root(root));
|
||||
let asking = store.create("/tmp/a").unwrap();
|
||||
let other = store.create("/tmp/b").unwrap();
|
||||
let asked = Arc::new(Mutex::new(Vec::new()));
|
||||
@@ -243,7 +250,7 @@ async fn late_guide_spend_settles_to_the_session_that_asked() {
|
||||
assert!(!matches!(event, Event::TurnUsage { .. }), "published to the wrong session");
|
||||
}
|
||||
let usage_in = |session: &SessionId| {
|
||||
let entries = JsonlSessionStore::new(root.join("sessions")).load(session).unwrap();
|
||||
let entries = JsonlSessionStore::new(sessions_root(root)).load(session).unwrap();
|
||||
entries
|
||||
.iter()
|
||||
.filter(|entry| {
|
||||
@@ -266,7 +273,7 @@ async fn late_guide_spend_settles_to_the_session_that_asked() {
|
||||
async fn late_guide_spend_joins_its_session_when_it_is_open_again() {
|
||||
let repository = changed_repository();
|
||||
let root = repository.path();
|
||||
let mut store = JsonlSessionStore::new(root.join("sessions"));
|
||||
let mut store = JsonlSessionStore::new(sessions_root(root));
|
||||
let asking = store.create("/tmp/a").unwrap();
|
||||
let other = store.create("/tmp/b").unwrap();
|
||||
let asked = Arc::new(Mutex::new(Vec::new()));
|
||||
@@ -332,7 +339,7 @@ async fn late_guide_spend_joins_its_session_when_it_is_open_again() {
|
||||
|
||||
let totals = totals.expect("a session total");
|
||||
assert_eq!(review_tokens(totals), Some(1_000_000), "and still counted after the turn");
|
||||
let store = JsonlSessionStore::new(root.join("sessions"));
|
||||
let store = JsonlSessionStore::new(sessions_root(root));
|
||||
let entries = store.load(&asking).unwrap();
|
||||
let leaf = luxe_core::session::latest_leaf(&entries).unwrap();
|
||||
let path = store.active_path(&asking, &leaf).unwrap();
|
||||
|
||||
@@ -209,6 +209,45 @@ async fn lifecycle_hooks_follow_the_session_the_engine_is_on() {
|
||||
assert_eq!(after.last(), Some(&HookPoint::SessionEnd), "{after:?}");
|
||||
}
|
||||
|
||||
/// The engine holds the session it's on, and won't switch to one another process holds.
|
||||
///
|
||||
/// The break this catches: loading a session without claiming it, so two Luxes append to one log
|
||||
/// and a resume shows only one of their conversations.
|
||||
#[tokio::test]
|
||||
async fn a_session_held_by_another_process_is_not_switched_to() {
|
||||
let project = tempfile::tempdir().unwrap();
|
||||
let mut store = JsonlSessionStore::new(project.path().join("sessions"));
|
||||
let mine = store.create("/tmp/a").unwrap();
|
||||
let theirs = store.create("/tmp/b").unwrap();
|
||||
let lock = |id: &SessionId| store.session_path(id).unwrap().with_extension("lock");
|
||||
let (my_lock, their_lock) = (lock(&mine), lock(&theirs));
|
||||
let other_process = std::fs::File::create(&their_lock).unwrap();
|
||||
other_process.try_lock().unwrap();
|
||||
let (actions, mut events, task) =
|
||||
Engine::spawn_task(engine_config(store, mine.clone(), project.path()));
|
||||
|
||||
actions.send(Action::LoadSession(theirs.to_string())).await.unwrap();
|
||||
let refusal = first(&mut events, "the refusal", |event| match event {
|
||||
Event::Error(message) => Some(message),
|
||||
Event::SessionLoaded { session_id, .. } if session_id == theirs.0 => {
|
||||
panic!("switched to a session another process holds")
|
||||
}
|
||||
_ => None,
|
||||
})
|
||||
.await;
|
||||
assert!(refusal.contains("open in another Luxe"), "{refusal}");
|
||||
let claimed = std::fs::File::open(&my_lock).unwrap().try_lock().is_err();
|
||||
assert!(claimed, "the engine doesn't hold the session it's on");
|
||||
turn(&actions, &mut events, "still in my session").await;
|
||||
|
||||
actions.send(Action::Close).await.unwrap();
|
||||
let drained = tokio::spawn(async move { while events.recv().await.is_some() {} });
|
||||
tokio::time::timeout(WAIT, task).await.expect("the engine stops").unwrap();
|
||||
drained.abort();
|
||||
let theirs_log = std::fs::read_to_string(their_lock.with_extension("jsonl")).unwrap();
|
||||
assert!(!theirs_log.contains("still in my session"), "wrote into the held session");
|
||||
}
|
||||
|
||||
/// Reopening the session the engine is already on is not a switch: no hook hears of it.
|
||||
#[tokio::test]
|
||||
async fn reloading_the_same_session_starts_nothing_new() {
|
||||
|
||||
Reference in New Issue
Block a user