Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
15 commits
Select commit Hold shift + click to select a range
def6141
feat(mobile): the AI Assistant in a sheet of the touch interface, wit…
Mavrick-F Nov 27, 2026
f97ca33
fix(ui): the scale bar leaves a map too short for it and the north arrow
Mavrick-F Nov 27, 2026
1941917
feat(mobile): the phone's Assistant settings describe the provider an…
Mavrick-F Nov 28, 2026
9af1a51
fix(assistant): asks that can't go are kept in order and said once; a…
Mavrick-F Nov 28, 2026
8f17810
fix(mobile): a message put in the box while Android's text field is o…
Mavrick-F Nov 28, 2026
a4b03ff
fix(mobile): a message sent while Android's text field is open on it …
Mavrick-F Nov 28, 2026
85092ba
fix(assistant): another message leaves the draft's pictures, and the …
Mavrick-F Nov 28, 2026
089d5ea
refactor(mobile): drop the switch for Layers on the bar, now that the…
Mavrick-F Nov 28, 2026
45d658a
test(assistant): give the waiting-message test's provider a model, so…
Mavrick-F Nov 28, 2026
c0e9c02
fix(assistant): say what a replaced text field sent isn't kept, and l…
Mavrick-F Nov 29, 2026
733495d
fix(assistant): a command's message leaves the draft and its pictures…
Mavrick-F Nov 29, 2026
394b8db
fix(mobile): the Assistant's words in display form once, and a replac…
Mavrick-F Nov 29, 2026
4cd281a
test(mobile): a tool call's words in display form once, with Latin in…
Mavrick-F Nov 29, 2026
5e536ef
fix(assistant): a message the user sent goes before one a command ask…
Mavrick-F Nov 29, 2026
4712f20
fix(assistant): a message a command asked for twice is kept twice whe…
Mavrick-F Nov 29, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 7 additions & 3 deletions apps/rustgis-mobile/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -94,9 +94,13 @@ Rust calls Java and never the other way: each frame the app collects what happen

## The touch interface

A phone starts in the touch interface: the map, a bar of four large buttons under it (Layers, Add
Data, Capture, More) and sheets that rise over the map. The Layers sheet switches between the
project's maps and layouts when it has more than one, shows and hides layers, zooms to one and
A phone starts in the touch interface: the map, with a Layers button at its top-right corner, a bar
of large buttons under it (Add Data, Capture, the AI Assistant once a provider is set up, More) and
sheets that rise over the map. Until then, **Set Up the Assistant** in the More sheet is the only
trace of the Assistant, and with its extension off there is none; its sheet types into Android's
own text field and stands full or half up, with a strip and Stop while it works
([AI Assistant › On a phone](../../docs/user-guide/assistant.md#on-a-phone)). The Layers sheet
switches between the project's maps and layouts when it has more than one, shows and hides layers, zooms to one and
makes one the active layer; the More sheet has Full Extent, undo and redo, the project, the
position, and **Use the Desktop Interface**, which brings back the ribbon and panes; **Touch
Interface**, on the View tab (or Use the Touch Interface in Command Search), returns to the phone's
Expand Down
60 changes: 54 additions & 6 deletions crates/assistant/src/agent.rs
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,19 @@ pub const INTERNAL_ERROR: &str = "RustGIS ran into an internal error while handl
const PICTURES_AS_NAMES: &str =
"This model doesn't read images: the pictures go to it as their names only. Pick a model that reads images to show them.";

/// An approval as the user was shown it ([`Agent::asking`]): the conversation, the run, the reply and the call it
/// is about (its place in the reply as well as its id, which a reply may repeat), and the
/// subagent's own when the call waiting is a subagent's.
#[derive(Clone, Debug, PartialEq, Eq, Hash)]
pub struct Asking {
conversation: u64,
generation: u64,
reply: u64,
place: usize,
call: String,
child: Option<Box<Asking>>,
}

pub struct Agent {
pub config: Config,
turns: Vec<Turn>,
Expand All @@ -103,6 +116,9 @@ pub struct Agent {
last_context: String,
/// Goes up when a run is stopped or cleared: responses to older requests are dropped.
generation: u64,
/// The replies whose calls were queued so far: with the generation, it names the reply a
/// call waiting for approval came in ([`Asking`]), as call ids repeat from reply to reply.
replies: u64,
/// Exact operations approved for the rest of this conversation and project generation.
always: Vec<Remembered>,
pending_policy: Option<Pending>,
Expand Down Expand Up @@ -204,6 +220,7 @@ impl Agent {
steps: 0,
last_context: String::new(),
generation: 0,
replies: 0,
always: Vec::new(),
pending_policy: None,
conversation: CONVERSATIONS.fetch_add(1, Ordering::Relaxed),
Expand Down Expand Up @@ -423,6 +440,27 @@ impl Agent {
self.pending_policy.as_ref().map(|p| p.review())
}

/// Which call [`Agent::pending`] is about, for [`Agent::decide`] to answer that one only: an
/// answer given to an approval no longer waiting (a second tap, a card drawn frames before)
/// is refused.
pub fn asking(&self) -> Option<Asking> {
let State::Calls(q, done) = &self.state else { return None };
let call = q.front()?;
let child = match &self.child {
Some(child) => Some(Box::new(child.asking()?)),
None if self.local_delegation(call) || self.pending_policy.is_some() => None,
None => return None,
};
Some(Asking {
conversation: self.conversation,
generation: self.generation,
reply: self.replies,
place: done.len(),
call: call.id.clone(),
child,
})
}

fn scope(&self) -> Scope {
Scope::assistant(self.conversation, self.live.clone())
}
Expand Down Expand Up @@ -888,6 +926,7 @@ impl Agent {
self.state = State::Idle;
return Step::Done;
}
self.replies = self.replies.wrapping_add(1);
self.state = State::Calls(calls.into(), Vec::new());
self.drain(s)
}
Expand Down Expand Up @@ -1126,18 +1165,24 @@ impl Agent {
}
}

/// The user's answer about [`Agent::pending`]; `always` approves calls like it for the rest of
/// the conversation.
pub fn decide(&mut self, allow: bool, always: bool, s: &mut Session) -> Step {
self.guard(|a| a.decide_unguarded(allow, always, s))
/// The user's answer about the approval they were shown, `asked` ([`Agent::asking`]); `always`
/// approves calls like it for the rest of the conversation. `None`, and nothing done, when
/// that approval is no longer the one waiting: answered already, stopped, or another call's.
pub fn decide(&mut self, asked: &Asking, allow: bool, always: bool, s: &mut Session) -> Option<Step> {
if self.asking().as_ref() != Some(asked) {
return None;
}
Some(self.guard(|a| a.decide_unguarded(allow, always, s)))
}

fn decide_unguarded(&mut self, allow: bool, always: bool, s: &mut Session) -> Step {
if !matches!(self.state, State::Calls(..)) {
return Step::Done;
}
if let Some(child) = self.child.as_mut() {
let step = child.decide(allow, always, s);
// The child's own approval was checked with this one's ([`Agent::asking`]); a panic
// in it ends the child, as its own guard says, not this run.
let step = child.guard(|c| c.decide_unguarded(allow, always, s));
return self.after_child(step, s);
}
if allow
Expand Down Expand Up @@ -1411,7 +1456,10 @@ pub fn run_blocking_with<E: Into<crate::Error>>(
}
Step::Confirm => {
let allow = agent.pending(s).is_some_and(|(what, why, access)| confirm(&what, &why, access));
agent.decide(allow, false, s)
match agent.asking() {
Some(asked) => agent.decide(&asked, allow, false, s).unwrap_or(Step::Done),
None => Step::Done,
}
}
Step::Retry(after) => {
std::thread::sleep(after);
Expand Down
2 changes: 1 addition & 1 deletion crates/assistant/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -37,5 +37,5 @@ pub mod skills;
mod tests;
pub mod tools;

pub use agent::{Agent, Entry, Step};
pub use agent::{Agent, Asking, Entry, Step};
pub use provider::{Api, Config, HttpRequest, HttpResponse, Note, PRESETS, Preset};
Loading
Loading