M3.7: lutra CLI and single instance

- crates/control: rendezvous file (<data_dir>/instance.json, port + random
  token, atomic write, 0600 on Unix, stale detection), token-protected
  listener (start_with_token, app.auth first, constant-time compare,
  10 s auth timeout), app.focus, and a blocking client (connect_live,
  request/execute/subscribe/next_event, open_folder/open_file/reveal)
- lutra-desktop: a normal start forwards its path to a running instance
  and exits, otherwise claims the rendezvous; --control instances skip it
  unless LUTRA_RENDEZVOUS_DIR is set; non-Unicode args are usage errors
- lutra-cli (binary lutra, now L6): path[:line[:column]] targets, folder ->
  project.open, file -> file.open (parent opened without a project, outside
  the project refused), editor.reveal, starts the desktop if needed,
  --wait until bufferClosed, --version/--help, exit codes 0/1/2
- tests: proptest target parsing, rendezvous read/write/stale, token check
  over TCP, forwarding against a test backend, --wait end to end
- docs: architecture, G7, ROADMAP (agent automation 18% est.), roadmap,
  README

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
danny 2026-10-18 00:23:09 +02:00
parent 9ccfc1bf6a
commit 9b278099cf
26 changed files with 2162 additions and 37 deletions

View file

@ -22,7 +22,7 @@ use std::time::Duration;
use lutra_control::{Backend, EventSink, Subscribers};
use lutra_engine::{CommandInfo, Effect, Engine, EngineError, Event, NotificationLevel};
use serde_json::{Map, Value, json};
use tauri::{AppHandle, Emitter};
use tauri::{AppHandle, Emitter, Manager};
use tauri_plugin_dialog::DialogExt;
use crate::screenshot;
@ -386,6 +386,19 @@ impl Backend for Host {
fn subscribe(&self, sink: EventSink) {
self.subscribers.add(sink);
}
/// Restores, shows and focuses the main window. Failures to restore or
/// show are ignored because focusing still works on a visible window;
/// the focus error is returned.
fn focus(&self) -> Result<(), String> {
let app = self.app.get().ok_or("the window is not open yet")?;
let window = app
.get_webview_window(MAIN_WINDOW)
.ok_or("the window is not open yet")?;
let _ = window.unminimize();
let _ = window.show();
window.set_focus().map_err(|e| e.to_string())
}
}
#[cfg(test)]