Repository navigation
feat(plugins): session process plugins stay running and hear the map #1553
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
e335640
d69c49a
faab2fc
221a67f
b0b289c
66369fc
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Large diffs are not rendered by default.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -277,6 +277,20 @@ impl Session { | |
| Err(p) => std::panic::resume_unwind(p), | ||
| } | ||
| } | ||
| /// Runs what a session plugin's program asks between its commands with the plugin's own | ||
| /// authority, as its commands run: the exact load, still current, narrowing the scope the app | ||
| /// is in (none at the frame's root, the trusted native convention). | ||
| #[cfg(not(target_arch = "wasm32"))] | ||
| pub(crate) fn as_session_plugin<T>( | ||
| &mut self, | ||
| plugin: Arc<rustgis_plugins::Plugin>, | ||
| f: impl FnOnce(&mut Session) -> T, | ||
| ) -> Result<T, String> { | ||
| if !rustgis_plugins::is_current(&plugin) { | ||
| return Err("the plugin was disabled, updated or removed".into()); | ||
| } | ||
| self.narrowed(Narrow::Plugin(super::plan::PluginPin(plugin)), f) | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Re-raised with new evidence (confidence: medium): between-command requests lose the initiating agent's or assistant's scope.
The same request is judged differently when the next command's prelude drains it ( Failure scenario: an agent with The earlier replies answered the plugin-permissions question, but this thread's scope point has no answer. Suggested direction: record the initiating scope's kind (or the scope itself) when the program starts, and narrow the frame's polls to it, so the frame and the command prelude judge a request the same way.
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Right that the two paths can differ, but only ever by narrowing: the drain at the start of a command runs inside that command's scope, so a request it answers is judged by the caller's scope intersected with the plugin's, never more than the plugin's own; the frame's poll judges it by the plugin's own authority, as designed for requests between commands. Making them identical would mean either widening a scope from inside a narrower one, which the policy refuses on purpose, or carrying the last caller's scope into the session, which the earlier thread answers. Leaving this to the maintainers as the design call it is. |
||
| } | ||
| /// Intersects nested plugin/item authority with its initiating scope. | ||
| pub(crate) fn narrowed<T>(&mut self, to: Narrow, f: impl FnOnce(&mut Session) -> T) -> Result<T, String> { | ||
| let mut scope = self.scope(); | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -519,6 +519,7 @@ pub(crate) fn entry( | |
| project: project.0, | ||
| opened: project.1, | ||
| partial, | ||
| plugin: None, | ||
| } | ||
| } | ||
|
|
||
|
|
@@ -573,6 +574,10 @@ pub struct LogEntry { | |
| /// wouldn't run as they ran. | ||
| #[serde(default, skip_serializing_if = "std::ops::Not::not")] | ||
| pub partial: bool, | ||
| /// The plugin whose session program asked for it between its commands: it counts with the | ||
| /// plugins' commands toward [`LOG_PLUGIN_LIMIT`]. | ||
| #[serde(default, skip_serializing_if = "Option::is_none")] | ||
| pub plugin: Option<String>, | ||
|
coderabbitai[bot] marked this conversation as resolved.
Resolved
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. AGENTS.md: "Never silent" (confidence: medium). Re-raised with new reasoning. This field is what the CSV export drops. The CSV header and Options: add a
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Fair, fixed in aa621a8: the CSV export has a |
||
| } | ||
|
|
||
| impl LogEntry { | ||
|
|
@@ -623,7 +628,7 @@ impl SessionLog { | |
| if self.off && !matches!(e.command.as_str(), "project.logCommands" | "project.clearLog") { | ||
| return; | ||
| } | ||
| let plugin = |e: &LogEntry| e.command.starts_with(rustgis_plugins::PREFIX); | ||
| let plugin = |e: &LogEntry| e.command.starts_with(rustgis_plugins::PREFIX) || e.plugin.is_some(); | ||
|
coderabbitai[bot] marked this conversation as resolved.
Resolved
|
||
| if plugin(&e) | ||
| && self.plugin_entries >= LOG_PLUGIN_LIMIT | ||
| && let Some(oldest) = self.entries.iter().position(plugin) | ||
|
|
@@ -649,7 +654,8 @@ impl SessionLog { | |
| /// into the last undo step ([`crate::Session::merge_undo`]). The entry keeps when the first | ||
| /// started, takes the last one's parameters, and adds up how long they took. | ||
| pub fn join_last(&mut self, mut e: LogEntry) { | ||
| if let Some(last) = self.entries.back_mut().filter(|l| l.ok && l.command == e.command) { | ||
| // A session plugin's entry between the steps isn't the user's step to join. | ||
| if let Some(last) = self.entries.back_mut().filter(|l| l.ok && l.command == e.command && l.plugin == e.plugin) { | ||
| e.at = last.at; | ||
| e.millis = last.millis.saturating_add(e.millis); | ||
| *last = e; | ||
|
|
@@ -713,7 +719,7 @@ impl SessionLog { | |
| /// line). Entry by entry, so a long log isn't held as text first. | ||
| pub fn write(&self, w: &mut dyn std::io::Write, csv: bool) -> std::io::Result<()> { | ||
| if csv { | ||
| w.write_all(b"time_utc,at,command,ok,millis,error,params,project\n")?; | ||
| w.write_all(b"time_utc,at,command,ok,millis,error,params,plugin,project\n")?; | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Compatibility (confidence: medium-low). The new Appending the column after
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. No released export has |
||
| } | ||
| self.entries.iter().try_for_each(|e| write_entry(w, e, csv)) | ||
| } | ||
|
|
@@ -740,14 +746,15 @@ fn write_entry(w: &mut dyn std::io::Write, e: &LogEntry, csv: bool) -> std::io:: | |
| if csv { | ||
| writeln!( | ||
| w, | ||
| "{},{},{},{},{},{},{},{}", | ||
| "{},{},{},{},{},{},{},{},{}", | ||
| e.time_utc(), | ||
| e.at, | ||
| csv_cell(&e.command), | ||
| e.ok, | ||
| e.millis, | ||
| csv_cell(e.error.as_deref().unwrap_or("")), | ||
| csv_cell(&e.params.to_string()), | ||
| csv_cell(e.plugin.as_deref().unwrap_or("")), | ||
| csv_cell(&e.project) | ||
| ) | ||
| } else { | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.