M1.3: engine workspace, file and buffer commands, event stream
State holds the open project (VFS project, watcher, watched directories)
and versioned buffers. New commands: project.open/close/children,
file.open/save/saveAll, buffer.get/edit/close. buffer.edit takes UTF-16
change sets based on a version and fails with the new stale_version code;
closing dirty buffers or projects without force fails with
unsaved_changes. Commands queue events (projectOpened, treeChanged,
bufferChanged, dirtyChanged, fileChangedOnDisk, ...) that the engine
returns in Outcome.events; Engine::pump_vfs maps changes on disk to
events and reloads clean buffers. project.children watches listed
directories, capped at 256 native / 32 polling, least recently listed
dropped first.
Control channel: events.subscribe streams {"event": ...} lines, with
bounded per-subscriber queues (lutra_control::Subscribers) and method docs
in methods.rs. testkit's EngineBackend and the desktop Host implement the
new Backend::subscribe. Verified with 14 engine integration tests, a TCP
events test and the running app over the control channel.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
parent
a63ab4ac45
commit
f1976c7d67
30 changed files with 2235 additions and 46 deletions
|
|
@ -4,7 +4,7 @@
|
|||
use serde::Serialize;
|
||||
use serde_json::Value;
|
||||
|
||||
use crate::{EngineError, State};
|
||||
use crate::{EngineError, Event, State};
|
||||
|
||||
/// Static metadata of a command.
|
||||
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
|
||||
|
|
@ -37,6 +37,9 @@ pub struct Outcome {
|
|||
pub value: Value,
|
||||
/// Effects for the host to apply, in order.
|
||||
pub effects: Vec<Effect>,
|
||||
/// State changes for the host to publish, oldest first. Filled by the
|
||||
/// engine from the events the command queued; commands leave it empty.
|
||||
pub events: Vec<Event>,
|
||||
}
|
||||
|
||||
impl Outcome {
|
||||
|
|
@ -45,6 +48,7 @@ impl Outcome {
|
|||
Self {
|
||||
value,
|
||||
effects: Vec::new(),
|
||||
events: Vec::new(),
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -53,6 +57,7 @@ impl Outcome {
|
|||
Self {
|
||||
value: Value::Null,
|
||||
effects: vec![effect],
|
||||
events: Vec::new(),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue