дзеркало
https://github.com/l0ng-ai/openidea.git
синхронізовано 2026-12-04 09:11:10 +02:00
* feat(agents): stream reply text as appends and repaint only changed blocks
The backend sends only the text added to a streaming message (AgentEvent::Append)
instead of the whole entry every flush. Replies render per top-level Markdown
block, keeping the DOM of blocks that didn't change, and streaming text is
revealed at a steady pace.
* feat(agents): fold finished turns and summarize work by what it did
A finished turn's work before its reply folds into one line under its message
("Reasoning · Ran 1 command · Read 4 files · 12s"), runs of tool calls say what
they did instead of how many there were, and reasoning stays open and bounded
while it streams. New Settings › Agents values choose turn folding, smooth text,
reasoning and tool call display, tool output expansion, the send key and what
sending does while the agent works; per-agent defaults are stored for new tasks.
* feat(agents): ask approvals and show progress above the composer
An approval the agent waits for is asked above the composer, answered with
1, 2, 3… when the focus isn't in a text field, and recorded in the
conversation once answered. Beside it: the plan's progress, the task's changed
files (opening the changes), running subagents and background work, queued
messages, and a line saying what the agent does now and for how long.
* feat(agents): one Settings › Agents page for every agent
Agents get their own settings group. Its page lists every agent this machine
runs, built in or installed from the ACP Registry, with what each needs
(update, not found, custom) beside the selected one's status, sign-in, the
settings its new tasks start with, and how it launches. Add Agent… opens the
ACP Registry in a dialog; Remove and Update act on registry agents in place.
Chat and MCP Server move under it, and Chat gains the sending and conversation
options.
* test(e2e): follow approvals to the tray and work into turn folds
* fix(agents): lay out agent defaults in rows and name reasoning in work summaries
* fix(settings): keep ⌘Enter as written in every locale
* feat(agents): show the ACP Registry as a list beside the selected agent
Add Agent lists registry agents compactly (name, and Installed or Update) and
shows the selected one's version, runtime, authors, description, links and
Install / Update / Remove beside the list, instead of a card per agent with
badges and a button on every row.
* fix(agents): open Add Agent at a fixed size with the list scrolling inside
* feat(agents): list every agent in one searchable list, installed first
Registry agents that can be installed now sit under the installed ones
instead of behind Add Agent. The selected agent's page puts Install,
Update and Remove next to its name and lays out Sign In, New Tasks and
Launch as titled sections with label rows.
* feat(settings): make Agents a group of Coding Agents, Chat and MCP Server
* feat(agents): show each task's agent icon and move chat placement to the options menu
Task rows and session tabs show the icon of the agent the task runs;
rows mark only tasks that are still working or need attention, since
their group already says the rest are ready. Chat in Tool Window and
Chat in Editor move from the header into the tool window's options
menu as a checked pair.
* fix(agents): put actions under a turn's final reply only, and keep selections clean
Interim messages of a turn no longer carry a time and action row, and
the final reply gets one once the turn ends. Code in replies uses a
tint of the text colour instead of an opaque fill, so a selection no
longer leaves light boxes around it, and diagram labels are skipped
when selecting across a reply.
* feat(toolwindows): let a window keep its options out of the title
A tool window can set plainTitle so its own options stay in the "⋮"
menu and its title gets no "▾". The Agents window uses it.
* fix(agents): line up the settings form of an agent
The selects of New Tasks share one width, and the label column is as
wide in every section, so the controls of New Tasks and Launch start
at the same place.
* fix(agents): call copying a task into a new one Fork everywhere
The task menu, the user message and the reply offered the same
operation as Copy to a New Task, Copy to a New Task From Here and
Branch Conversation from Here. They now read Fork Task and Fork from
Here.
* fix(agents): label the fork buttons and menu item just Fork
* fix(agents): label the task's terminal entry just Terminal
* fix(agents): fold the session header into the status line and quiet the chat chrome
- The task's terminal and changes buttons move to the end of the status line above
the composer; the header row that repeated the tab's title and status is gone.
- The status line leaves out the model when the composer's picker shows it.
- Your messages show their actions and send time beside "You" on hover instead of
in a row under them, so turns sit closer together.
- Session tabs show a dot only while something waits for you: an unread reply, a
question or an error. A spinner still marks a running task.
- The composer's attach buttons are plain toolbar icons, the image one monochrome;
in a narrow composer the model button drops the effort so the model stays readable.
* fix(agents): answer approvals only from the focused session and never cut a turn short to steer
Number keys answer an approval only while the focus is in its session.
With "Sends it into the turn", a message to an agent that can't take it
mid-turn (or a turn waiting for input) is queued instead of cancelling
the turn. A task waiting for you shows a dot instead of a spinner, and a
turn that ran into an error before its reply stays unfolded.
* fix(agents): keep text that streams while a conversation loads
Entry events that arrive while a conversation loads are applied on top
of the loaded copy instead of being lost to it, so a long reply no
longer reloads the whole conversation over and over. A reply that
streams on as appends marks its task unread even when its conversation
isn't open. The backend keeps only the length and end of the text it
sent, rather than a copy it compares in full on every flush.
* fix(agents): render HTML blocks whole and leave drawn diagrams alone while a reply streams
A reply with an HTML block (such as <details> around Markdown) renders
as one piece, so the block wraps what it should. While a reply streams,
only the text after its finished blocks is cut again, and a diagram
already drawn stays in place with its zoom and pan.
* fix(settings): read agent setting values it doesn't know as their defaults
A hand-edited agent setting with an unknown value, or a non-text value
in agent defaults, no longer makes the whole settings file be ignored.
* fix(agents): drop Open from a task's context menu
Clicking a task already opens it.
212 рядки
8.8 KiB
Rust
212 рядки
8.8 KiB
Rust
use crate::events::TauriSink;
|
||
use ide_core::{EventSink, IdeEvent, IdeResult, SharedSink};
|
||
use ide_language::{LanguageRegistry, Syntax};
|
||
use ide_workspace::RecentProjects;
|
||
use std::path::Path;
|
||
use std::sync::{Arc, OnceLock};
|
||
use std::time::Duration;
|
||
use tauri::{AppHandle, Manager};
|
||
|
||
pub use ide_host::{Host, Project};
|
||
|
||
/// Process-wide state shared by all windows: the backend [`Host`] (reachable
|
||
/// through `Deref`) plus what only the desktop shell has.
|
||
pub struct AppState {
|
||
pub app: AppHandle,
|
||
pub host: Arc<Host>,
|
||
pub startup: Startup,
|
||
pub updates: crate::updates::Updates,
|
||
pub recent: RecentProjects,
|
||
/// Plugins (`ide_host::plugins`), shared by all windows.
|
||
pub plugins: Arc<ide_host::plugins::PluginHost>,
|
||
/// The built-in web server (Open In › Browser, the editor's browser bar).
|
||
pub web: ide_web::WebServer,
|
||
/// Agents › MCP Server: built-in IDE tools for agents.
|
||
pub mcp: crate::commands::mcp::McpService,
|
||
/// Credential prompts of `ssh` / `git` child processes (`None` if it failed to start).
|
||
pub askpass: Option<ide_ssh::askpass::AskpassServer>,
|
||
/// Remote development connections, by window label.
|
||
pub remote_dev: crate::remote_dev::Connections,
|
||
/// Broadcasts to every window.
|
||
pub sink: SharedSink,
|
||
}
|
||
|
||
impl std::ops::Deref for AppState {
|
||
type Target = Host;
|
||
fn deref(&self) -> &Host {
|
||
&self.host
|
||
}
|
||
}
|
||
|
||
/// Start-up timings (`app_metrics`).
|
||
#[derive(Debug)]
|
||
pub struct Startup {
|
||
/// Process start → `main` (exec, code-signature scan, dynamic loading).
|
||
pub process_to_main: Option<Duration>,
|
||
/// Process start → `AppState::new` (Tauri / WebView boot before our code).
|
||
pub process_to_setup: Option<Duration>,
|
||
/// Time spent in `AppState::new`.
|
||
pub setup: Duration,
|
||
/// Process start → first IPC call that reached [`AppState::note_ipc`].
|
||
pub first_ipc: OnceLock<Duration>,
|
||
}
|
||
|
||
impl AppState {
|
||
pub fn new(app: AppHandle, local_data_dir: std::path::PathBuf) -> Result<Self, Box<dyn std::error::Error>> {
|
||
ide_workspace::process::mark_start();
|
||
let process_to_main = ide_workspace::process::before_main();
|
||
let process_to_setup = ide_workspace::process::process_age();
|
||
let started = std::time::Instant::now();
|
||
// Grammar set-up is not needed for the first paint: build it off the main thread.
|
||
let syntax: Arc<OnceLock<Arc<Syntax>>> = Arc::default();
|
||
{
|
||
let syntax = syntax.clone();
|
||
std::thread::Builder::new().name("openidea-syntax-init".into()).spawn(move || {
|
||
syntax.get_or_init(|| Arc::new(Syntax::new()));
|
||
})?;
|
||
}
|
||
let config_dir = app.path().app_config_dir()?;
|
||
let data_dir = app.path().app_data_dir()?;
|
||
std::fs::create_dir_all(&config_dir)?;
|
||
std::fs::create_dir_all(&data_dir)?;
|
||
if let Err(error) = std::fs::create_dir_all(&local_data_dir) {
|
||
tracing::warn!(?local_data_dir, %error, "cannot create local data directory");
|
||
}
|
||
tracing::info!(?data_dir, ?local_data_dir, "application data directories");
|
||
// Saved git HTTPS credentials (askpass answers them silently).
|
||
ide_ssh::git_creds::init(data_dir.join("git-credentials.json"));
|
||
// File › Invalidate Caches… requested at the last run.
|
||
let removed = ide_workspace::caches::apply_pending(&data_dir, &local_data_dir);
|
||
if !removed.is_empty() {
|
||
tracing::info!("invalidated caches: {removed:?}");
|
||
}
|
||
ide_host::data_dirs::migrate(&data_dir, &local_data_dir);
|
||
let global_sink: SharedSink = Arc::new(TauriSink { app: app.clone(), window: None });
|
||
let languages = Arc::new(LanguageRegistry::load(Some(&config_dir.join("languages")))?);
|
||
let sink_app = app.clone();
|
||
let host = Arc::new(Host::new(ide_host::HostConfig {
|
||
config_dir: config_dir.clone(),
|
||
data_dir: data_dir.clone(),
|
||
local_data_dir,
|
||
languages: languages.clone(),
|
||
syntax,
|
||
sink_for: Box::new(move |window| {
|
||
Arc::new(TauriSink { app: sink_app.clone(), window: Some(window.to_owned()) })
|
||
}),
|
||
owner: Self::owner_window,
|
||
runtime: tauri::async_runtime::handle().inner().clone(),
|
||
project_environment: false,
|
||
}));
|
||
Ok(Self {
|
||
recent: RecentProjects::load(&config_dir),
|
||
updates: Default::default(),
|
||
askpass: start_askpass(&app),
|
||
sink: global_sink,
|
||
plugins: crate::commands::plugin::create_host(&app, &data_dir, &host)?,
|
||
web: ide_web::WebServer::new(),
|
||
mcp: Default::default(),
|
||
remote_dev: crate::remote_dev::Connections::default(),
|
||
host,
|
||
startup: Startup {
|
||
process_to_main,
|
||
process_to_setup,
|
||
setup: started.elapsed(),
|
||
first_ipc: OnceLock::new(),
|
||
},
|
||
app,
|
||
})
|
||
}
|
||
|
||
/// Records the first IPC call for the start-up metric.
|
||
pub fn note_ipc(&self) {
|
||
self.startup.first_ipc.get_or_init(|| {
|
||
let age = ide_workspace::process::process_age().unwrap_or_else(ide_workspace::process::uptime);
|
||
let ms = |d: Option<Duration>| d.map_or(f64::NAN, |d| d.as_secs_f64() * 1000.0);
|
||
tracing::info!(
|
||
"startup: first IPC {:.0} ms after process start (main {:.0} ms, setup at {:.0} ms, took {:.1} ms)",
|
||
age.as_secs_f64() * 1000.0,
|
||
ms(self.startup.process_to_main),
|
||
ms(self.startup.process_to_setup),
|
||
self.startup.setup.as_secs_f64() * 1000.0
|
||
);
|
||
age
|
||
});
|
||
}
|
||
|
||
/// The window that owns what `window` starts: a settings window's parent, else `window`.
|
||
pub fn owner_window(window: &str) -> &str {
|
||
crate::windows::auxiliary_parent(window).unwrap_or(window)
|
||
}
|
||
|
||
/// Opens `root` in `window` and records it in the recent projects.
|
||
pub fn open_project(&self, window: &str, root: &Path) -> IdeResult<Arc<Project>> {
|
||
// A local project replaces a remote one in this window.
|
||
self.remote_dev.disconnect(window);
|
||
let project = self.host.open_project(window, root)?;
|
||
self.record_project(&project)?;
|
||
Ok(project)
|
||
}
|
||
|
||
pub fn record_project(&self, project: &Project) -> IdeResult<()> {
|
||
let info = ide_host::ops::project::info(project);
|
||
let attached = info.workspace.as_ref().is_some_and(|w| !w.is_container(&project.root));
|
||
let branch = if attached {
|
||
None
|
||
} else {
|
||
project.repos.read().primary().and_then(|r| r.branch_info().ok()).and_then(|b| b.head)
|
||
};
|
||
self.recent.touch(&project.root, branch)?;
|
||
self.recent.rename(&project.root, Some(&info.display_name))?;
|
||
crate::jump_list::refresh(&self.app, self.recent.list());
|
||
Ok(())
|
||
}
|
||
|
||
/// Opens `window` for editing the loose file `file` (LightEdit); not a recent project.
|
||
pub fn open_light(&self, window: &str, file: &Path) -> IdeResult<Arc<Project>> {
|
||
self.remote_dev.disconnect(window);
|
||
self.host.open_light(window, file)
|
||
}
|
||
|
||
/// Called on the event-loop thread (window destruction, the `close_project`
|
||
/// command), so it must not wait for the project's workers to shut down.
|
||
pub fn close_project(&self, window: &str) {
|
||
self.remote_dev.disconnect(window);
|
||
self.host.close_project_detached(window);
|
||
}
|
||
}
|
||
|
||
/// Serves askpass prompts to the focused window and routes `git`'s prompts there.
|
||
fn start_askpass(app: &AppHandle) -> Option<ide_ssh::askpass::AskpassServer> {
|
||
let exe = std::env::current_exe().ok()?;
|
||
let handle = app.clone();
|
||
let on_prompt = Arc::new(move |p: ide_ssh::askpass::AskpassPrompt| {
|
||
// A focused Settings window hands the prompt to its project window.
|
||
let window = crate::windows::target_window(&handle).map(|w| AppState::owner_window(w.label()).to_owned());
|
||
let remember = ide_ssh::askpass::remembers(&p.prompt);
|
||
TauriSink { app: handle.clone(), window }.emit(IdeEvent::Askpass {
|
||
id: p.id,
|
||
prompt: p.prompt,
|
||
kind: p.kind,
|
||
remember,
|
||
});
|
||
});
|
||
match ide_ssh::askpass::AskpassServer::start(exe, on_prompt) {
|
||
Ok(server) => {
|
||
ide_vcs::set_git_command_observer(
|
||
ide_ssh::askpass::COMMAND_ENV,
|
||
Arc::new(|id, success, stderr| {
|
||
if let Some(store) = ide_ssh::git_creds::get() {
|
||
store.command_finished(id, success, stderr);
|
||
}
|
||
}),
|
||
);
|
||
ide_vcs::set_askpass_env(server.env());
|
||
Some(server)
|
||
}
|
||
Err(e) => {
|
||
tracing::warn!("askpass unavailable: {}", e.message);
|
||
None
|
||
}
|
||
}
|
||
}
|